@true-tech-team/react-components 0.0.1
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/README.md +586 -0
- package/index.css +1 -0
- package/index.d.ts +15 -0
- package/index.js +1 -0
- package/index.mjs +5224 -0
- package/lib/assets/icons/index.d.ts +105 -0
- package/lib/components/buttons/Button/Button.d.ts +49 -0
- package/lib/components/buttons/Button/index.d.ts +3 -0
- package/lib/components/buttons/IconButton/IconButton.d.ts +48 -0
- package/lib/components/buttons/IconButton/index.d.ts +3 -0
- package/lib/components/buttons/index.d.ts +2 -0
- package/lib/components/display/Icon/Icon.d.ts +43 -0
- package/lib/components/display/Icon/index.d.ts +3 -0
- package/lib/components/display/index.d.ts +1 -0
- package/lib/components/forms/FormBuilder/FormBuilder.d.ts +109 -0
- package/lib/components/forms/FormBuilder/hooks/index.d.ts +2 -0
- package/lib/components/forms/FormBuilder/hooks/useFormState.d.ts +5 -0
- package/lib/components/forms/FormBuilder/hooks/useFormValidation.d.ts +11 -0
- package/lib/components/forms/FormBuilder/index.d.ts +4 -0
- package/lib/components/forms/FormBuilder/types.d.ts +193 -0
- package/lib/components/forms/index.d.ts +1 -0
- package/lib/components/index.d.ts +50 -0
- package/lib/components/inputs/Autocomplete/Autocomplete.d.ts +109 -0
- package/lib/components/inputs/Autocomplete/index.d.ts +2 -0
- package/lib/components/inputs/Checkbox/Checkbox.d.ts +85 -0
- package/lib/components/inputs/Checkbox/index.d.ts +2 -0
- package/lib/components/inputs/ColorPicker/ColorPicker.d.ts +82 -0
- package/lib/components/inputs/ColorPicker/index.d.ts +2 -0
- package/lib/components/inputs/DatePicker/DatePicker.d.ts +81 -0
- package/lib/components/inputs/DatePicker/index.d.ts +2 -0
- package/lib/components/inputs/DateRangePicker/DateRangePicker.d.ts +115 -0
- package/lib/components/inputs/DateRangePicker/index.d.ts +2 -0
- package/lib/components/inputs/FilePicker/FilePicker.d.ts +101 -0
- package/lib/components/inputs/FilePicker/index.d.ts +2 -0
- package/lib/components/inputs/Input/Input.d.ts +171 -0
- package/lib/components/inputs/Input/index.d.ts +3 -0
- package/lib/components/inputs/NumberInput/NumberInput.d.ts +18 -0
- package/lib/components/inputs/NumberInput/index.d.ts +2 -0
- package/lib/components/inputs/PhoneInput/PhoneInput.d.ts +87 -0
- package/lib/components/inputs/PhoneInput/index.d.ts +2 -0
- package/lib/components/inputs/Radio/Radio.d.ts +45 -0
- package/lib/components/inputs/Radio/RadioGroup.d.ts +88 -0
- package/lib/components/inputs/Radio/index.d.ts +4 -0
- package/lib/components/inputs/Rating/Rating.d.ts +22 -0
- package/lib/components/inputs/Rating/index.d.ts +2 -0
- package/lib/components/inputs/Select/Select.d.ts +142 -0
- package/lib/components/inputs/Select/index.d.ts +2 -0
- package/lib/components/inputs/Slider/Slider.d.ts +29 -0
- package/lib/components/inputs/Slider/index.d.ts +2 -0
- package/lib/components/inputs/TagInput/TagInput.d.ts +101 -0
- package/lib/components/inputs/TagInput/index.d.ts +2 -0
- package/lib/components/inputs/Textarea/Textarea.d.ts +90 -0
- package/lib/components/inputs/Textarea/index.d.ts +2 -0
- package/lib/components/inputs/Toggle/Toggle.d.ts +69 -0
- package/lib/components/inputs/Toggle/index.d.ts +2 -0
- package/lib/components/inputs/index.d.ts +16 -0
- package/lib/components/overlays/Dropdown/Dropdown.d.ts +84 -0
- package/lib/components/overlays/Dropdown/index.d.ts +2 -0
- package/lib/components/overlays/Menu/Menu.d.ts +70 -0
- package/lib/components/overlays/Menu/MenuContext.d.ts +68 -0
- package/lib/components/overlays/Menu/MenuDivider.d.ts +10 -0
- package/lib/components/overlays/Menu/MenuGroup.d.ts +20 -0
- package/lib/components/overlays/Menu/MenuItem.d.ts +42 -0
- package/lib/components/overlays/Menu/MenuList.d.ts +16 -0
- package/lib/components/overlays/Menu/index.d.ts +12 -0
- package/lib/components/overlays/Popover/Popover.d.ts +74 -0
- package/lib/components/overlays/Popover/index.d.ts +2 -0
- package/lib/components/overlays/Portal/Portal.d.ts +24 -0
- package/lib/components/overlays/Portal/index.d.ts +2 -0
- package/lib/components/overlays/Tooltip/Tooltip.d.ts +51 -0
- package/lib/components/overlays/Tooltip/index.d.ts +2 -0
- package/lib/components/overlays/index.d.ts +5 -0
- package/lib/contexts/ThemeContext/ThemeContext.d.ts +40 -0
- package/lib/contexts/ThemeContext/index.d.ts +2 -0
- package/lib/contexts/index.d.ts +2 -0
- package/lib/decorators/ComponentDecorator/ComponentDecorator.d.ts +57 -0
- package/lib/decorators/ComponentDecorator/index.d.ts +3 -0
- package/lib/decorators/index.d.ts +2 -0
- package/lib/hooks/index.d.ts +11 -0
- package/lib/hooks/useClickOutside/index.d.ts +1 -0
- package/lib/hooks/useClickOutside/useClickOutside.d.ts +9 -0
- package/lib/hooks/useDebounce/index.d.ts +1 -0
- package/lib/hooks/useDebounce/useDebounce.d.ts +10 -0
- package/lib/hooks/useEscapeKey/index.d.ts +1 -0
- package/lib/hooks/useEscapeKey/useEscapeKey.d.ts +9 -0
- package/lib/hooks/useFocusTrap/index.d.ts +1 -0
- package/lib/hooks/useFocusTrap/useFocusTrap.d.ts +8 -0
- package/lib/hooks/useHover/index.d.ts +2 -0
- package/lib/hooks/useHover/useHover.d.ts +59 -0
- package/lib/hooks/usePopoverPosition/index.d.ts +2 -0
- package/lib/hooks/usePopoverPosition/usePopoverPosition.d.ts +58 -0
- package/lib/hooks/usePortal/index.d.ts +2 -0
- package/lib/hooks/usePortal/usePortal.d.ts +23 -0
- package/lib/hooks/useTheme/index.d.ts +1 -0
- package/lib/providers/GlobalProvider/GlobalProvider.d.ts +56 -0
- package/lib/providers/GlobalProvider/index.d.ts +3 -0
- package/lib/providers/index.d.ts +2 -0
- package/lib/types/component.types.d.ts +129 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/theme.types.d.ts +139 -0
- package/lib/utils/colorUtils.d.ts +71 -0
- package/lib/utils/dateUtils.d.ts +91 -0
- package/lib/utils/dom.d.ts +50 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/positioning.d.ts +59 -0
- package/lib/utils/theme-utils.d.ts +105 -0
- package/lib/utils/validation.d.ts +120 -0
- package/package.json +55 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Portal component props
|
|
4
|
+
*/
|
|
5
|
+
export interface PortalProps {
|
|
6
|
+
/**
|
|
7
|
+
* Content to render in portal
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* ID of the portal container
|
|
12
|
+
* @default 'portal-root'
|
|
13
|
+
*/
|
|
14
|
+
containerId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Z-index for portal container
|
|
17
|
+
*/
|
|
18
|
+
zIndex?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Portal component
|
|
22
|
+
* Renders children into a portal container outside the DOM hierarchy
|
|
23
|
+
*/
|
|
24
|
+
export declare const Portal: React.FC<PortalProps>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PopoverPosition } from '../../../utils';
|
|
3
|
+
import { BaseComponentProps } from '../../../types';
|
|
4
|
+
/**
|
|
5
|
+
* Tooltip component props
|
|
6
|
+
*/
|
|
7
|
+
export interface TooltipProps extends Omit<BaseComponentProps, 'children'> {
|
|
8
|
+
/**
|
|
9
|
+
* Tooltip content (what to display in tooltip)
|
|
10
|
+
*/
|
|
11
|
+
content: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Element to trigger tooltip
|
|
14
|
+
*/
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Tooltip position
|
|
18
|
+
* @default 'top'
|
|
19
|
+
*/
|
|
20
|
+
position?: PopoverPosition;
|
|
21
|
+
/**
|
|
22
|
+
* Delay before showing tooltip (ms)
|
|
23
|
+
* @default 200
|
|
24
|
+
*/
|
|
25
|
+
delayShow?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Delay before hiding tooltip (ms)
|
|
28
|
+
* @default 0
|
|
29
|
+
*/
|
|
30
|
+
delayHide?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Disable tooltip
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Show arrow pointing to trigger
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
showArrow?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Gap between trigger and tooltip
|
|
43
|
+
* @default 8
|
|
44
|
+
*/
|
|
45
|
+
offset?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Tooltip component
|
|
49
|
+
* Displays helpful text on hover/focus
|
|
50
|
+
*/
|
|
51
|
+
export declare const Tooltip: React.FC<TooltipProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ThemeMode, ThemeConfig, ThemeOverride } from '../../types';
|
|
3
|
+
interface ThemeContextValue {
|
|
4
|
+
mode: ThemeMode;
|
|
5
|
+
setMode: (mode: ThemeMode) => void;
|
|
6
|
+
toggleMode: () => void;
|
|
7
|
+
themeOverride?: ThemeOverride;
|
|
8
|
+
setThemeOverride: (override?: ThemeOverride) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface ThemeProviderProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
defaultMode?: ThemeMode;
|
|
13
|
+
themeConfig?: ThemeConfig;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ThemeProvider component that manages theme state
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <ThemeProvider defaultMode="light">
|
|
21
|
+
* <App />
|
|
22
|
+
* </ThemeProvider>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function ThemeProvider({ children, defaultMode, themeConfig, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* Hook to access theme context
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error} If used outside of ThemeProvider
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* function MyComponent() {
|
|
34
|
+
* const { mode, toggleMode } = useTheme();
|
|
35
|
+
* return <button onClick={toggleMode}>Current mode: {mode}</button>;
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function useTheme(): ThemeContextValue;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CSSVariables } from '../../types';
|
|
3
|
+
export interface ComponentDecoratorProps {
|
|
4
|
+
/**
|
|
5
|
+
* Component name for data-component attribute
|
|
6
|
+
*/
|
|
7
|
+
componentName: string;
|
|
8
|
+
/**
|
|
9
|
+
* CSS module classes for the root element
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Test ID for testing
|
|
14
|
+
*/
|
|
15
|
+
'data-testid'?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Custom CSS variables for component customization
|
|
18
|
+
*/
|
|
19
|
+
cssVariables?: CSSVariables;
|
|
20
|
+
/**
|
|
21
|
+
* Root element type
|
|
22
|
+
*/
|
|
23
|
+
as?: keyof JSX.IntrinsicElements;
|
|
24
|
+
/**
|
|
25
|
+
* Children to render
|
|
26
|
+
*/
|
|
27
|
+
children: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Additional props to spread on root element
|
|
30
|
+
*/
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Higher-order component that wraps components with standard props and styling
|
|
35
|
+
*
|
|
36
|
+
* @param Component - The component to wrap
|
|
37
|
+
* @param componentName - Name of the component for data attributes
|
|
38
|
+
* @param defaultClassName - Default CSS class to apply
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { withComponentDecorator } from '../../decorators';
|
|
43
|
+
* import styles from './Button.module.scss';
|
|
44
|
+
*
|
|
45
|
+
* const ButtonBase = ({ children, variant }) => (
|
|
46
|
+
* <span className={styles[`button--${variant}`]}>{children}</span>
|
|
47
|
+
* );
|
|
48
|
+
*
|
|
49
|
+
* export const Button = withComponentDecorator(
|
|
50
|
+
* ButtonBase,
|
|
51
|
+
* 'button',
|
|
52
|
+
* styles.button
|
|
53
|
+
* );
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function withComponentDecorator<P extends object>(Component: React.ComponentType<P>, componentName: string, defaultClassName?: string): React.ForwardRefExoticComponent<React.PropsWithoutRef<P & Omit<ComponentDecoratorProps, "componentName">> & React.RefAttributes<HTMLDivElement>>;
|
|
57
|
+
export default withComponentDecorator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { useTheme } from './useTheme';
|
|
2
|
+
export { usePortal } from './usePortal';
|
|
3
|
+
export type { UsePortalOptions } from './usePortal';
|
|
4
|
+
export { useClickOutside } from './useClickOutside';
|
|
5
|
+
export { useEscapeKey } from './useEscapeKey';
|
|
6
|
+
export { useFocusTrap } from './useFocusTrap';
|
|
7
|
+
export { usePopoverPosition } from './usePopoverPosition';
|
|
8
|
+
export type { UsePopoverPositionOptions, UsePopoverPositionReturn, } from './usePopoverPosition';
|
|
9
|
+
export { useHover } from './useHover';
|
|
10
|
+
export type { UseHoverOptions, UseHoverReturn, HoverProps } from './useHover';
|
|
11
|
+
export { useDebounce } from './useDebounce';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useClickOutside } from './useClickOutside';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Detect clicks outside a referenced element
|
|
4
|
+
* @param ref - Reference to the element
|
|
5
|
+
* @param handler - Callback to execute when clicking outside
|
|
6
|
+
* @param enabled - Whether the hook is active
|
|
7
|
+
* @param excludeRefs - Additional refs to exclude from outside click detection (e.g., trigger elements)
|
|
8
|
+
*/
|
|
9
|
+
export declare function useClickOutside<T extends HTMLElement>(ref: RefObject<T>, handler: (event: MouseEvent | TouchEvent) => void, enabled?: boolean, excludeRefs?: Array<RefObject<HTMLElement>>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useDebounce } from './useDebounce';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useEscapeKey } from './useEscapeKey';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for handling Escape key press
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Handle Escape key press
|
|
6
|
+
* @param handler - Callback to execute when Escape is pressed
|
|
7
|
+
* @param enabled - Whether the hook is active
|
|
8
|
+
*/
|
|
9
|
+
export declare function useEscapeKey(handler: (event: KeyboardEvent) => void, enabled?: boolean): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFocusTrap } from './useFocusTrap';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Trap focus within an element
|
|
4
|
+
* @param ref - Reference to the container element
|
|
5
|
+
* @param enabled - Whether the focus trap is active
|
|
6
|
+
* @param autoFocus - Whether to automatically focus the first element on mount
|
|
7
|
+
*/
|
|
8
|
+
export declare function useFocusTrap<T extends HTMLElement>(ref: RefObject<T>, enabled?: boolean, autoFocus?: boolean): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for detecting hover state with configurable delays
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Options for hover detection
|
|
6
|
+
*/
|
|
7
|
+
export interface UseHoverOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Callback when hover starts
|
|
10
|
+
*/
|
|
11
|
+
onHoverStart?: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Callback when hover ends
|
|
14
|
+
*/
|
|
15
|
+
onHoverEnd?: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Delay before triggering hover start (ms)
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
delayEnter?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Delay before triggering hover end (ms)
|
|
23
|
+
* @default 0
|
|
24
|
+
*/
|
|
25
|
+
delayLeave?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Disable hover detection
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Props to spread on the element
|
|
34
|
+
*/
|
|
35
|
+
export interface HoverProps {
|
|
36
|
+
onMouseEnter: () => void;
|
|
37
|
+
onMouseLeave: () => void;
|
|
38
|
+
onFocus: () => void;
|
|
39
|
+
onBlur: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Return value from useHover
|
|
43
|
+
*/
|
|
44
|
+
export interface UseHoverReturn {
|
|
45
|
+
/**
|
|
46
|
+
* Whether element is currently hovered
|
|
47
|
+
*/
|
|
48
|
+
isHovered: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Props to spread on the element
|
|
51
|
+
*/
|
|
52
|
+
hoverProps: HoverProps;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Detect hover state with configurable delays
|
|
56
|
+
* @param options - Hover configuration options
|
|
57
|
+
* @returns Hover state and props
|
|
58
|
+
*/
|
|
59
|
+
export declare function useHover(options?: UseHoverOptions): UseHoverReturn;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import { PopoverPosition, PopoverWidth } from '../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Options for popover positioning
|
|
5
|
+
*/
|
|
6
|
+
export interface UsePopoverPositionOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the popover is open
|
|
9
|
+
*/
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Preferred position for the popover
|
|
13
|
+
* @default 'bottom'
|
|
14
|
+
*/
|
|
15
|
+
position?: PopoverPosition;
|
|
16
|
+
/**
|
|
17
|
+
* Gap between trigger and popover in pixels
|
|
18
|
+
* @default 8
|
|
19
|
+
*/
|
|
20
|
+
offset?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Allow position to flip if would overflow viewport
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
allowFlip?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Width configuration for popover
|
|
28
|
+
* @default 'auto'
|
|
29
|
+
*/
|
|
30
|
+
width?: PopoverWidth;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Return value from usePopoverPosition
|
|
34
|
+
*/
|
|
35
|
+
export interface UsePopoverPositionReturn {
|
|
36
|
+
/**
|
|
37
|
+
* Ref to attach to popover element
|
|
38
|
+
*/
|
|
39
|
+
popoverRef: RefObject<HTMLDivElement>;
|
|
40
|
+
/**
|
|
41
|
+
* Ref to attach to trigger element
|
|
42
|
+
*/
|
|
43
|
+
triggerRef: RefObject<HTMLElement>;
|
|
44
|
+
/**
|
|
45
|
+
* Style object to apply to popover
|
|
46
|
+
*/
|
|
47
|
+
style: CSSProperties;
|
|
48
|
+
/**
|
|
49
|
+
* Actual position used (may differ from preferred if flipped)
|
|
50
|
+
*/
|
|
51
|
+
actualPosition: PopoverPosition;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Calculate and manage popover position
|
|
55
|
+
* @param options - Positioning options
|
|
56
|
+
* @returns Refs and styles for positioning
|
|
57
|
+
*/
|
|
58
|
+
export declare function usePopoverPosition(options: UsePopoverPositionOptions): UsePopoverPositionReturn;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for creating and managing portal containers
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Options for portal configuration
|
|
6
|
+
*/
|
|
7
|
+
export interface UsePortalOptions {
|
|
8
|
+
/**
|
|
9
|
+
* ID of the portal container element
|
|
10
|
+
* @default 'portal-root'
|
|
11
|
+
*/
|
|
12
|
+
containerId?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Z-index for the portal container
|
|
15
|
+
*/
|
|
16
|
+
zIndex?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create or get a portal container element
|
|
20
|
+
* @param options - Portal configuration options
|
|
21
|
+
* @returns Portal container element
|
|
22
|
+
*/
|
|
23
|
+
export declare function usePortal(options?: UsePortalOptions): HTMLElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTheme } from '../../contexts/ThemeContext';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ThemeConfig } from '../../types';
|
|
3
|
+
export interface GlobalProviderProps {
|
|
4
|
+
/**
|
|
5
|
+
* Child components to render
|
|
6
|
+
*/
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Theme configuration
|
|
10
|
+
*/
|
|
11
|
+
themeConfig?: ThemeConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to inject global styles (default: true)
|
|
14
|
+
*/
|
|
15
|
+
injectGlobalStyles?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* GlobalProvider component that wraps the entire application
|
|
19
|
+
*
|
|
20
|
+
* Provides:
|
|
21
|
+
* - Theme context for dark/light mode switching
|
|
22
|
+
* - Global CSS styles and utility classes
|
|
23
|
+
* - CSS custom properties for theming
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { GlobalProvider } from '@true-tech-team/ui-components';
|
|
28
|
+
*
|
|
29
|
+
* function App() {
|
|
30
|
+
* return (
|
|
31
|
+
* <GlobalProvider themeConfig={{ mode: 'dark' }}>
|
|
32
|
+
* <YourApp />
|
|
33
|
+
* </GlobalProvider>
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* With custom theme override:
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <GlobalProvider
|
|
42
|
+
* themeConfig={{
|
|
43
|
+
* mode: 'light',
|
|
44
|
+
* theme: {
|
|
45
|
+
* colors: {
|
|
46
|
+
* primary: '#0066ff',
|
|
47
|
+
* },
|
|
48
|
+
* },
|
|
49
|
+
* }}
|
|
50
|
+
* >
|
|
51
|
+
* <App />
|
|
52
|
+
* </GlobalProvider>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function GlobalProvider({ children, themeConfig, injectGlobalStyles, }: GlobalProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export default GlobalProvider;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Base props that all components should accept
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseComponentProps {
|
|
6
|
+
/**
|
|
7
|
+
* Additional CSS class name
|
|
8
|
+
*/
|
|
9
|
+
className?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Data test ID for testing
|
|
12
|
+
*/
|
|
13
|
+
'data-testid'?: string;
|
|
14
|
+
/**
|
|
15
|
+
* ARIA label for accessibility
|
|
16
|
+
*/
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Custom inline styles
|
|
20
|
+
*/
|
|
21
|
+
style?: CSSProperties;
|
|
22
|
+
/**
|
|
23
|
+
* Component children
|
|
24
|
+
*/
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Props for components that support size variations
|
|
29
|
+
*/
|
|
30
|
+
export type ComponentSize = 'sm' | 'md' | 'lg';
|
|
31
|
+
/**
|
|
32
|
+
* Extended size options for components with more granular sizing
|
|
33
|
+
*/
|
|
34
|
+
export type ExtendedComponentSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
35
|
+
/**
|
|
36
|
+
* Props for components that support color variants
|
|
37
|
+
*/
|
|
38
|
+
export type ComponentVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'success' | 'warning' | 'danger';
|
|
39
|
+
/**
|
|
40
|
+
* Props for components that support semantic colors
|
|
41
|
+
*/
|
|
42
|
+
export type SemanticColor = 'success' | 'warning' | 'error' | 'info';
|
|
43
|
+
/**
|
|
44
|
+
* Common button-like component props
|
|
45
|
+
*/
|
|
46
|
+
export interface ButtonBaseProps extends BaseComponentProps {
|
|
47
|
+
/**
|
|
48
|
+
* Whether the component is disabled
|
|
49
|
+
*/
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Click handler
|
|
53
|
+
*/
|
|
54
|
+
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Type attribute for button elements
|
|
57
|
+
*/
|
|
58
|
+
type?: 'button' | 'submit' | 'reset';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Common input-like component props
|
|
62
|
+
*/
|
|
63
|
+
export interface InputBaseProps extends BaseComponentProps {
|
|
64
|
+
/**
|
|
65
|
+
* Whether the input is disabled
|
|
66
|
+
*/
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the input is read-only
|
|
70
|
+
*/
|
|
71
|
+
readOnly?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the input is required
|
|
74
|
+
*/
|
|
75
|
+
required?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Input name attribute
|
|
78
|
+
*/
|
|
79
|
+
name?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Input value
|
|
82
|
+
*/
|
|
83
|
+
value?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Placeholder text
|
|
86
|
+
*/
|
|
87
|
+
placeholder?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Change handler
|
|
90
|
+
*/
|
|
91
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* CSS variable customization props
|
|
95
|
+
*/
|
|
96
|
+
export type CSSVariables = Record<string, string | number>;
|
|
97
|
+
/**
|
|
98
|
+
* Component decorator props
|
|
99
|
+
*/
|
|
100
|
+
export interface ComponentDecoratorProps {
|
|
101
|
+
/**
|
|
102
|
+
* Component name for data-component attribute and BEM naming
|
|
103
|
+
*/
|
|
104
|
+
componentName: string;
|
|
105
|
+
/**
|
|
106
|
+
* CSS module classes for the root element
|
|
107
|
+
*/
|
|
108
|
+
className?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Test ID for testing
|
|
111
|
+
*/
|
|
112
|
+
'data-testid'?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Custom CSS variables for component customization
|
|
115
|
+
*/
|
|
116
|
+
cssVariables?: CSSVariables;
|
|
117
|
+
/**
|
|
118
|
+
* Root element type
|
|
119
|
+
*/
|
|
120
|
+
as?: keyof JSX.IntrinsicElements;
|
|
121
|
+
/**
|
|
122
|
+
* Children to render
|
|
123
|
+
*/
|
|
124
|
+
children: ReactNode;
|
|
125
|
+
/**
|
|
126
|
+
* Additional props to spread on root element
|
|
127
|
+
*/
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { ColorFamily, ColorShade, ThemeColorTokens, ThemeSpacing, ThemeTypography, ThemeBorderRadius, ThemeShadows, Theme, ThemeOverride, ThemeConfig, ThemeMode, } from './theme.types';
|
|
2
|
+
export type { BaseComponentProps, ComponentSize, ExtendedComponentSize, ComponentVariant, SemanticColor, ButtonBaseProps, InputBaseProps, CSSVariables, ComponentDecoratorProps, } from './component.types';
|