qucoon-components 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +163 -178
- package/dist/index.es.js +22447 -23652
- package/dist/types/components/ui/button/BaseButton.d.ts +5 -4
- package/dist/types/components/ui/input/BaseInput.d.ts +6 -6
- package/dist/types/components/ui/label/EnhancedLabel.d.ts +24 -6
- package/dist/types/components/ui/menu/BaseSidebar.d.ts +4 -3
- package/dist/types/utilities/helpers/iconRenderer.d.ts +65 -0
- package/dist/types/utilities/helpers/index.d.ts +4 -0
- package/dist/types/utilities/hooks/useModal.d.ts +1 -1
- package/dist/types/utilities/index.d.ts +1 -0
- package/dist/types/utilities/types/iconTypes.d.ts +74 -0
- package/dist/types/utilities/types/index.d.ts +1 -0
- package/package.json +13 -6
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { default as React, CSSProperties
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
2
|
import { TypographyProps } from '../..';
|
|
3
|
+
import { IconType } from '../../../utilities';
|
|
3
4
|
export type BaseButtonProps = {
|
|
4
5
|
variant?: "primary" | "secondary" | "text";
|
|
5
6
|
type?: "icon" | "button" | "submit" | "reset";
|
|
6
|
-
startIcon?:
|
|
7
|
-
endIcon?:
|
|
8
|
-
textIcon?:
|
|
7
|
+
startIcon?: IconType;
|
|
8
|
+
endIcon?: IconType;
|
|
9
|
+
textIcon?: IconType;
|
|
9
10
|
text?: string;
|
|
10
11
|
isLoading?: boolean;
|
|
11
12
|
size?: "x-small" | "small" | "medium" | "large";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { default as React, CSSProperties
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
2
|
import { FormikValues } from 'formik';
|
|
3
3
|
import { EnhancedLabelProps } from '../label/EnhancedLabel';
|
|
4
|
-
import { Formik } from '../../../utilities';
|
|
4
|
+
import { Formik, IconRenderProps, IconType } from '../../../utilities';
|
|
5
5
|
export type BaseInputProps<T extends FormikValues> = {
|
|
6
|
-
startIcon?:
|
|
7
|
-
endIcon?:
|
|
8
|
-
startIconProps?:
|
|
9
|
-
endIconProps?:
|
|
6
|
+
startIcon?: IconType;
|
|
7
|
+
endIcon?: IconType;
|
|
8
|
+
startIconProps?: IconRenderProps;
|
|
9
|
+
endIconProps?: IconRenderProps;
|
|
10
10
|
label?: string;
|
|
11
11
|
labelStyle?: CSSProperties;
|
|
12
12
|
labelProps?: EnhancedLabelProps;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { default as React, CSSProperties
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
2
|
import { default as Typography } from '../typography/typography';
|
|
3
|
+
import { IconRenderProps, IconType } from '../../../utilities';
|
|
3
4
|
export type DefaultIconType = 'required' | 'info' | 'addition' | 'warning' | 'optional';
|
|
5
|
+
export interface DefaultIconConfig {
|
|
6
|
+
component: IconType;
|
|
7
|
+
defaultSize: string;
|
|
8
|
+
defaultColor: string;
|
|
9
|
+
defaultProps?: IconRenderProps;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
4
12
|
export type EnhancedLabelProps = {
|
|
5
13
|
/** The label text */
|
|
6
14
|
label?: string;
|
|
@@ -13,13 +21,13 @@ export type EnhancedLabelProps = {
|
|
|
13
21
|
/** Override default icon color */
|
|
14
22
|
defaultIconColor?: string;
|
|
15
23
|
/** Additional props for default icon */
|
|
16
|
-
defaultIconProps?:
|
|
24
|
+
defaultIconProps?: IconRenderProps;
|
|
17
25
|
/** Custom icon to display alongside the label (in addition to default icon) */
|
|
18
|
-
icon?:
|
|
26
|
+
icon?: IconType;
|
|
19
27
|
/** Icon position relative to the label */
|
|
20
28
|
iconPosition?: "start" | "end";
|
|
21
29
|
/** Props for the custom icon */
|
|
22
|
-
iconProps?:
|
|
30
|
+
iconProps?: IconRenderProps;
|
|
23
31
|
/** Custom icon size */
|
|
24
32
|
iconSize?: string;
|
|
25
33
|
/** Custom style for the label container */
|
|
@@ -35,10 +43,20 @@ export type EnhancedLabelProps = {
|
|
|
35
43
|
/** Gap between icons and text */
|
|
36
44
|
iconGap?: string;
|
|
37
45
|
required?: boolean;
|
|
38
|
-
requiredIcon?:
|
|
46
|
+
requiredIcon?: IconType;
|
|
39
47
|
requiredIconSize?: string;
|
|
40
|
-
requiredIconProps?:
|
|
48
|
+
requiredIconProps?: IconRenderProps;
|
|
41
49
|
showRequiredWithIcon?: boolean;
|
|
42
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Enhanced label component with flexible icon support using IconRenderer
|
|
53
|
+
*/
|
|
43
54
|
declare const EnhancedLabel: React.FC<EnhancedLabelProps>;
|
|
55
|
+
/**
|
|
56
|
+
* Utility function to get default icon configuration
|
|
57
|
+
*/
|
|
58
|
+
export declare const getDefaultIconConfig: (type: DefaultIconType) => DefaultIconConfig;
|
|
59
|
+
/**
|
|
60
|
+
// * Utility function to add custom default icon types
|
|
61
|
+
// */
|
|
44
62
|
export default EnhancedLabel;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { default as React
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
import { GetSupportCardProps } from '../card/GetSupportCard';
|
|
3
|
+
import { IconType } from '../../../utilities';
|
|
3
4
|
export type BaseSidebarModuleItemType = {
|
|
4
5
|
title: string;
|
|
5
|
-
icon?:
|
|
6
|
+
icon?: IconType;
|
|
6
7
|
tabRoute?: string;
|
|
7
8
|
onClick?: () => void;
|
|
8
9
|
disabled?: boolean;
|
|
@@ -13,7 +14,7 @@ export type BaseSidebarModuleConfig = {
|
|
|
13
14
|
moduleName?: string;
|
|
14
15
|
moduleRoute?: string;
|
|
15
16
|
moduleItems?: BaseSidebarModuleItemType[];
|
|
16
|
-
moduleIcon?:
|
|
17
|
+
moduleIcon?: IconType;
|
|
17
18
|
disabled?: boolean;
|
|
18
19
|
defaultOpen?: boolean;
|
|
19
20
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IconConfig, IconRenderProps, IconType } from '../types/iconTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for consistent icon rendering across the library
|
|
5
|
+
*/
|
|
6
|
+
export declare class IconRenderer {
|
|
7
|
+
private static config;
|
|
8
|
+
/**
|
|
9
|
+
* Update global icon configuration
|
|
10
|
+
*/
|
|
11
|
+
static configure(config: Partial<IconConfig>): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get current configuration
|
|
14
|
+
*/
|
|
15
|
+
static getConfig(): IconConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Render an icon with consistent styling and props
|
|
18
|
+
*/
|
|
19
|
+
static render(icon: IconType, props?: IconRenderProps, localConfig?: Partial<IconConfig>): React.ReactElement | null;
|
|
20
|
+
/**
|
|
21
|
+
* Render multiple icons with consistent spacing
|
|
22
|
+
*/
|
|
23
|
+
static renderGroup(icons: Array<{
|
|
24
|
+
icon: IconType;
|
|
25
|
+
props?: IconRenderProps;
|
|
26
|
+
key?: string | number;
|
|
27
|
+
}>, groupProps?: {
|
|
28
|
+
spacing?: string;
|
|
29
|
+
direction?: 'row' | 'column';
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: React.CSSProperties;
|
|
32
|
+
}): React.ReactElement | null;
|
|
33
|
+
/**
|
|
34
|
+
* Type-adaptive rendering logic
|
|
35
|
+
*/
|
|
36
|
+
private static renderWithAdaptation;
|
|
37
|
+
/**
|
|
38
|
+
* Smart function component renderer with type adaptation
|
|
39
|
+
*/
|
|
40
|
+
private static renderFunctionComponent;
|
|
41
|
+
/**
|
|
42
|
+
* Type-specific rendering logic
|
|
43
|
+
*/
|
|
44
|
+
private static renderByType;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hook for using icon renderer in components
|
|
48
|
+
*/
|
|
49
|
+
export declare function useIconRenderer(localConfig?: Partial<IconConfig>): {
|
|
50
|
+
render: (icon: IconType, props?: IconRenderProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
51
|
+
renderGroup: (icons: Array<{
|
|
52
|
+
icon: IconType;
|
|
53
|
+
props?: IconRenderProps;
|
|
54
|
+
key?: string | number;
|
|
55
|
+
}>, groupProps?: Parameters<typeof IconRenderer.renderGroup>[1]) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
56
|
+
config: IconConfig;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Simple render function for direct use
|
|
60
|
+
*/
|
|
61
|
+
export declare const renderIcon: typeof IconRenderer.render;
|
|
62
|
+
/**
|
|
63
|
+
* Export default instance
|
|
64
|
+
*/
|
|
65
|
+
export default IconRenderer;
|
|
@@ -12,7 +12,7 @@ export declare const useModal: <T extends keyof ModalRegistry>(type: T) => {
|
|
|
12
12
|
activeInstance: import('..').ModalInstance<keyof ModalRegistry>;
|
|
13
13
|
count: number;
|
|
14
14
|
focus: () => void;
|
|
15
|
-
data: import('../..').
|
|
15
|
+
data: import('../..').ConfirmationModalLayoutProps | import('../..').NotificationModalLayoutProps;
|
|
16
16
|
id: string;
|
|
17
17
|
};
|
|
18
18
|
export default useModal;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Universal icon type that works across React 18 and 19
|
|
4
|
+
* Supports multiple icon formats for maximum flexibility
|
|
5
|
+
*/
|
|
6
|
+
export type UniversalSVGProps = Omit<React.SVGProps<SVGSVGElement>, 'ref'> & {
|
|
7
|
+
ref?: React.Ref<SVGSVGElement> | React.LegacyRef<SVGSVGElement> | string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Smart SVG props type that adapts to React 18/19 differences
|
|
11
|
+
*/
|
|
12
|
+
export type SmartSVGProps = Omit<React.SVGProps<SVGSVGElement>, 'ref'> & {
|
|
13
|
+
ref?: React.Ref<SVGSVGElement> | React.LegacyRef<SVGSVGElement> | string;
|
|
14
|
+
} | any;
|
|
15
|
+
export type IconType = React.ReactElement<SmartSVGProps> | React.ComponentType<SmartSVGProps> | React.FC<SmartSVGProps> | ((props: SmartSVGProps) => React.ReactElement) | string | null | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Props for configuring icon rendering
|
|
18
|
+
*/
|
|
19
|
+
export interface IconRenderProps extends Omit<SmartSVGProps, 'width' | 'height'> {
|
|
20
|
+
/** Icon size - applies to both width and height */
|
|
21
|
+
size?: string | number;
|
|
22
|
+
/** Explicit width (overrides size) */
|
|
23
|
+
width?: string | number;
|
|
24
|
+
/** Explicit height (overrides size) */
|
|
25
|
+
height?: string | number;
|
|
26
|
+
/** CSS class name */
|
|
27
|
+
className?: string;
|
|
28
|
+
/** Additional styles */
|
|
29
|
+
style?: React.CSSProperties;
|
|
30
|
+
/** Alt text for string-based icons */
|
|
31
|
+
alt?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for default icon behavior
|
|
35
|
+
*/
|
|
36
|
+
export interface IconConfig {
|
|
37
|
+
/** Default size when none specified */
|
|
38
|
+
defaultSize: string | number;
|
|
39
|
+
/** Default props to apply to all icons */
|
|
40
|
+
defaultProps?: IconRenderProps;
|
|
41
|
+
/** Whether to add default className */
|
|
42
|
+
addDefaultClassName?: boolean;
|
|
43
|
+
/** Default className to add */
|
|
44
|
+
defaultClassName?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Icon position type for components that support multiple icons
|
|
48
|
+
*/
|
|
49
|
+
export type IconPosition = 'start' | 'end' | 'top' | 'bottom' | 'left' | 'right';
|
|
50
|
+
/**
|
|
51
|
+
* Props for components that accept icons with positions
|
|
52
|
+
*/
|
|
53
|
+
export interface IconPositionProps {
|
|
54
|
+
/** Start/left icon */
|
|
55
|
+
startIcon?: IconType;
|
|
56
|
+
/** End/right icon */
|
|
57
|
+
endIcon?: IconType;
|
|
58
|
+
/** Top icon */
|
|
59
|
+
topIcon?: IconType;
|
|
60
|
+
/** Bottom icon */
|
|
61
|
+
bottomIcon?: IconType;
|
|
62
|
+
/** Props for start icon */
|
|
63
|
+
startIconProps?: IconRenderProps;
|
|
64
|
+
/** Props for end icon */
|
|
65
|
+
endIconProps?: IconRenderProps;
|
|
66
|
+
/** Props for top icon */
|
|
67
|
+
topIconProps?: IconRenderProps;
|
|
68
|
+
/** Props for bottom icon */
|
|
69
|
+
bottomIconProps?: IconRenderProps;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Utility type for extracting icon prop names
|
|
73
|
+
*/
|
|
74
|
+
export type IconPropKey = `${IconPosition}Icon` | `${IconPosition}IconProps`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qucoon-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"axios": "^1.9.0",
|
|
32
32
|
"dompurify": "^3.1.6",
|
|
33
33
|
"file-saver": "^2.0.5",
|
|
34
|
-
"formik": "^2.4.6",
|
|
35
34
|
"lottie-react": "^2.4.0",
|
|
36
35
|
"luxon": "^3.5.0",
|
|
37
36
|
"moment": "^2.30.1",
|
|
@@ -54,10 +53,11 @@
|
|
|
54
53
|
"yup": "^1.4.0"
|
|
55
54
|
},
|
|
56
55
|
"peerDependencies": {
|
|
56
|
+
"formik": "^2.4.6",
|
|
57
57
|
"react": ">=18 <20",
|
|
58
58
|
"react-dom": ">=18 <20",
|
|
59
|
-
"@types/react": "
|
|
60
|
-
"@types/react-dom": "
|
|
59
|
+
"@types/react": "*",
|
|
60
|
+
"@types/react-dom": "*"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@react-buddy/ide-toolbox": "^2.4.0",
|
|
@@ -67,8 +67,6 @@
|
|
|
67
67
|
"@types/file-saver": "^2.0.7",
|
|
68
68
|
"@types/luxon": "^3.6.2",
|
|
69
69
|
"@types/node": "^22.15.3",
|
|
70
|
-
"@types/react": "^18.3.0",
|
|
71
|
-
"@types/react-dom": "^18.3.0",
|
|
72
70
|
"@types/uuid": "^10.0.0",
|
|
73
71
|
"@vitejs/plugin-react": "^4.3.4",
|
|
74
72
|
"barrelsby": "^2.8.1",
|
|
@@ -77,11 +75,20 @@
|
|
|
77
75
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
78
76
|
"glob": "^11.0.2",
|
|
79
77
|
"react": ">=18 <20",
|
|
78
|
+
"formik": "^2.4.6",
|
|
80
79
|
"react-dom": ">=18 <20",
|
|
81
80
|
"typescript": "^5.3.2",
|
|
82
81
|
"typescript-eslint": "^8.31.1",
|
|
83
82
|
"vite": "^6.3.1",
|
|
84
83
|
"vite-plugin-dts": "^4.5.3",
|
|
85
84
|
"vite-plugin-svgr": "^4.2.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependenciesMeta": {
|
|
87
|
+
"@types/react": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"@types/react-dom": {
|
|
91
|
+
"optional": true
|
|
92
|
+
}
|
|
86
93
|
}
|
|
87
94
|
}
|