Skip to content

Commit 7788037

Browse files
authored
Merge pull request #444 from rozzilla/chore/types/update
2 parents ce0a9f2 + 59ad4bd commit 7788037

File tree

3 files changed

+45
-54
lines changed

3 files changed

+45
-54
lines changed

index.d.ts

+3-43
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,18 @@ declare module "@platformatic/ui-components" {
3939
position?: string;
4040
}
4141

42-
export interface IconsType {
43-
CircleStopIcon: ComponentType<any>;
44-
RunningIcon: ComponentType<any>;
45-
[key: string]: string | ComponentType<any>;
46-
}
47-
4842
export const PlatformaticIcon: ComponentType<PlatformaticIconProps>;
4943
export const CopyAndPaste: ComponentType<CopyAndPasteProps>;
50-
export const Icons: IconsType;
51-
}
5244

53-
declare module "@platformatic/ui-components/src/components/icons" {
5445
interface IconProps {
5546
size?: string;
5647
color?: string;
5748
addImportantToColor?: boolean;
5849
className?: string;
5950
}
6051

61-
const Icons: {
52+
export const Icons: {
53+
AppIcon: ComponentType<IconProps>;
6254
AlertIcon: ComponentType<IconProps>;
6355
ArrowUpIcon: ComponentType<IconProps>;
6456
ArrowDownIcon: ComponentType<IconProps>;
@@ -67,36 +59,6 @@ declare module "@platformatic/ui-components/src/components/icons" {
6759
[key: string]: ComponentType<IconProps>;
6860
};
6961

70-
export default Icons;
71-
}
72-
73-
declare module "@platformatic/ui-components/src/components/constants" {
74-
export const WHITE: string;
75-
export const SMALL: string;
76-
export const POSITION_END: string;
77-
export const RICH_BLACK: string;
78-
export const BLACK_RUSSIAN: string;
79-
export const TRANSPARENT: string;
80-
export const MARGIN_0: string;
81-
export const OPACITY_15: string;
82-
export const OPACITY_30: string;
83-
export const OPACITY_100: string;
84-
export const WARNING_YELLOW: string;
85-
export const ANTI_FLASH_WHITE: string;
86-
export const DULLS_BACKGROUND_COLOR: string;
87-
export const ERROR_RED: string;
88-
export const LARGE: string;
89-
export const MEDIUM: string;
90-
export const MAIN_GREEN: string;
91-
export const BOX_SHADOW: string;
92-
export const UNDERLINE: string;
93-
export const MAIN_DARK_BLUE: string;
94-
export const DIRECTION_RIGHT: string;
95-
export const POSITION_CENTER: string;
96-
export const TINY: string;
97-
}
98-
99-
declare module "@platformatic/ui-components/src/components/forms" {
10062
interface ToggleSwitchProps {
10163
label?: string;
10264
labelClassName?: string;
@@ -147,13 +109,11 @@ declare module "@platformatic/ui-components/src/components/forms" {
147109
disabled?: boolean;
148110
}
149111

150-
const Forms: {
112+
export const Forms: {
151113
ToggleSwitch: ComponentType<ToggleSwitchProps>;
152114
Input: ComponentType<InputProps>;
153115
Select: ComponentType<SelectProps>;
154116
Checkbox: ComponentType<CheckboxProps>;
155117
RadioButton: ComponentType<RadioButtonProps>;
156118
};
157-
158-
export default Forms;
159119
}

src/components/index.d.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
declare module "@platformatic/ui-components/src/components/constants" {
2+
export const WHITE: string;
3+
export const SMALL: string;
4+
export const POSITION_END: string;
5+
export const RICH_BLACK: string;
6+
export const BLACK_RUSSIAN: string;
7+
export const TRANSPARENT: string;
8+
export const MARGIN_0: string;
9+
export const OPACITY_15: string;
10+
export const OPACITY_30: string;
11+
export const OPACITY_100: string;
12+
export const WARNING_YELLOW: string;
13+
export const ANTI_FLASH_WHITE: string;
14+
export const DULLS_BACKGROUND_COLOR: string;
15+
export const ERROR_RED: string;
16+
export const LARGE: string;
17+
export const MEDIUM: string;
18+
export const MAIN_GREEN: string;
19+
export const BOX_SHADOW: string;
20+
export const UNDERLINE: string;
21+
export const MAIN_DARK_BLUE: string;
22+
export const DIRECTION_RIGHT: string;
23+
export const POSITION_CENTER: string;
24+
export const TINY: string;
25+
}

test-d/index.test-d.ts

+17-11
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ import {
1212
TooltipAbsolute,
1313
PlatformaticIconProps,
1414
CopyAndPasteProps,
15-
IconsType,
1615
PlatformaticIcon,
1716
CopyAndPaste,
1817
Icons,
18+
Forms,
19+
ToggleSwitchProps,
20+
InputProps,
21+
SelectProps,
22+
CheckboxProps,
23+
RadioButtonProps,
24+
IconProps,
1925
} from "@platformatic/ui-components";
2026

27+
// Test that Forms components are properly typed as React ComponentType
28+
expectType<ComponentType<ToggleSwitchProps>>(Forms.ToggleSwitch);
29+
expectType<ComponentType<InputProps>>(Forms.Input);
30+
expectType<ComponentType<SelectProps>>(Forms.Select);
31+
expectType<ComponentType<CheckboxProps>>(Forms.Checkbox);
32+
expectType<ComponentType<RadioButtonProps>>(Forms.RadioButton);
33+
2134
// Test VerticalSeparatorProps interface
2235
expectAssignable<VerticalSeparatorProps>({});
2336
expectAssignable<VerticalSeparatorProps>({
@@ -70,17 +83,10 @@ expectType<ComponentType<any>>(TooltipAbsolute);
7083
expectType<ComponentType<PlatformaticIconProps>>(PlatformaticIcon);
7184
expectType<ComponentType<CopyAndPasteProps>>(CopyAndPaste);
7285

73-
// Test IconsType
74-
expectAssignable<IconsType>({
75-
CircleStopIcon: (() => null) as ComponentType<any>,
76-
RunningIcon: (() => null) as ComponentType<any>,
77-
customIcon: "string-value",
78-
});
79-
8086
// Test specific Icons exports
81-
expectType<ComponentType<any>>(Icons.CircleStopIcon);
82-
expectType<ComponentType<any>>(Icons.RunningIcon);
87+
expectType<ComponentType<IconProps>>(Icons.CircleStopIcon);
88+
expectType<ComponentType<IconProps>>(Icons.RunningIcon);
8389

8490
// Test that Icons allows string index access
8591
const dynamicIcon: string | ComponentType<any> = Icons["someIconName"];
86-
expectType<string | ComponentType<any>>(dynamicIcon);
92+
expectType<ComponentType<any>>(dynamicIcon);

0 commit comments

Comments
 (0)