@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,101 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { InputBaseProps } from '../../../types/component.types';
|
|
3
|
+
export interface TagInputProps extends Omit<InputBaseProps, 'value' | 'onChange' | 'type' | 'defaultValue' | 'onBlur'> {
|
|
4
|
+
/**
|
|
5
|
+
* Controlled tags array
|
|
6
|
+
*/
|
|
7
|
+
value?: string[];
|
|
8
|
+
/**
|
|
9
|
+
* Default tags (uncontrolled)
|
|
10
|
+
*/
|
|
11
|
+
defaultValue?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Callback when tags change
|
|
14
|
+
*/
|
|
15
|
+
onChange?: (tags: string[]) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Callback when input loses focus
|
|
18
|
+
*/
|
|
19
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Input label text
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Label placement
|
|
26
|
+
*/
|
|
27
|
+
labelPlacement?: 'top' | 'left';
|
|
28
|
+
/**
|
|
29
|
+
* Helper text displayed below the input
|
|
30
|
+
*/
|
|
31
|
+
helperText?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Error message (shows when error is true)
|
|
34
|
+
*/
|
|
35
|
+
errorMessage?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the input is in an error state
|
|
38
|
+
*/
|
|
39
|
+
error?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the field is required
|
|
42
|
+
*/
|
|
43
|
+
required?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum number of tags allowed
|
|
46
|
+
*/
|
|
47
|
+
maxTags?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Delimiters that trigger tag creation (default: Enter, comma)
|
|
50
|
+
*/
|
|
51
|
+
delimiters?: string[];
|
|
52
|
+
/**
|
|
53
|
+
* Allow duplicate tags
|
|
54
|
+
*/
|
|
55
|
+
allowDuplicates?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Transform tag before adding (e.g., lowercase, trim)
|
|
58
|
+
*/
|
|
59
|
+
transformTag?: (tag: string) => string;
|
|
60
|
+
/**
|
|
61
|
+
* Validate tag before adding
|
|
62
|
+
*/
|
|
63
|
+
validateTag?: (tag: string) => boolean | string;
|
|
64
|
+
/**
|
|
65
|
+
* Autocomplete suggestions
|
|
66
|
+
*/
|
|
67
|
+
suggestions?: string[];
|
|
68
|
+
/**
|
|
69
|
+
* Show autocomplete suggestions
|
|
70
|
+
*/
|
|
71
|
+
showSuggestions?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Placeholder for input field
|
|
74
|
+
*/
|
|
75
|
+
placeholder?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Custom tag render function
|
|
78
|
+
*/
|
|
79
|
+
renderTag?: (tag: string, onRemove: () => void) => React.ReactNode;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to clear input on blur
|
|
82
|
+
*/
|
|
83
|
+
clearOnBlur?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Add tag on blur
|
|
86
|
+
*/
|
|
87
|
+
addOnBlur?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* TagInput component for multi-value chip input
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* <TagInput
|
|
95
|
+
* label="Tags"
|
|
96
|
+
* placeholder="Add tags..."
|
|
97
|
+
* onChange={(tags) => console.log(tags)}
|
|
98
|
+
* />
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const TagInput: React.ForwardRefExoticComponent<TagInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ValidationResult, ValidationTiming } from '../Input/Input';
|
|
3
|
+
export interface TextareaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'size'> {
|
|
4
|
+
/**
|
|
5
|
+
* Label text to display above textarea
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Helper text to display below textarea
|
|
10
|
+
*/
|
|
11
|
+
helperText?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Error message to display when in error state
|
|
14
|
+
*/
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the textarea is in an error state
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
error?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Number of visible text rows
|
|
23
|
+
* @default 3
|
|
24
|
+
*/
|
|
25
|
+
rows?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Minimum number of rows (for auto-resize)
|
|
28
|
+
*/
|
|
29
|
+
minRows?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Maximum number of rows (for auto-resize)
|
|
32
|
+
*/
|
|
33
|
+
maxRows?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Auto-resize textarea based on content
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
autoResize?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Maximum character length
|
|
41
|
+
*/
|
|
42
|
+
maxLength?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Show character counter
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
showCounter?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Validation regex pattern
|
|
50
|
+
*/
|
|
51
|
+
validationRegex?: RegExp;
|
|
52
|
+
/**
|
|
53
|
+
* Callback fired when validation completes
|
|
54
|
+
*/
|
|
55
|
+
onValidate?: (result: ValidationResult) => void;
|
|
56
|
+
/**
|
|
57
|
+
* When to perform validation
|
|
58
|
+
* @default 'blur'
|
|
59
|
+
*/
|
|
60
|
+
validateOn?: ValidationTiming;
|
|
61
|
+
/**
|
|
62
|
+
* Control resize behavior
|
|
63
|
+
* @default 'vertical'
|
|
64
|
+
*/
|
|
65
|
+
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
|
|
66
|
+
/**
|
|
67
|
+
* ID for the textarea element
|
|
68
|
+
* Auto-generated if not provided
|
|
69
|
+
*/
|
|
70
|
+
id?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Data test ID for testing
|
|
73
|
+
*/
|
|
74
|
+
'data-testid'?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Textarea component
|
|
78
|
+
* Multi-line text input with auto-resize and character counting
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* <Textarea
|
|
83
|
+
* label="Description"
|
|
84
|
+
* placeholder="Enter description..."
|
|
85
|
+
* maxLength={200}
|
|
86
|
+
* showCounter
|
|
87
|
+
* />
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ComponentSize, ComponentVariant, InputBaseProps } from '../../../types';
|
|
3
|
+
export interface ToggleProps extends Omit<InputBaseProps, 'value' | 'onChange' | 'placeholder'> {
|
|
4
|
+
/**
|
|
5
|
+
* Toggle variant style
|
|
6
|
+
* @default 'primary'
|
|
7
|
+
*/
|
|
8
|
+
variant?: ComponentVariant;
|
|
9
|
+
/**
|
|
10
|
+
* Toggle size
|
|
11
|
+
* @default 'md'
|
|
12
|
+
*/
|
|
13
|
+
size?: ComponentSize;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the toggle is checked
|
|
16
|
+
*/
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Default checked state for uncontrolled component
|
|
20
|
+
*/
|
|
21
|
+
defaultChecked?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Callback fired when the toggle state changes
|
|
24
|
+
* @param checked - The new checked state
|
|
25
|
+
* @param event - The change event
|
|
26
|
+
*/
|
|
27
|
+
onChange?: (checked: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Label text to display next to toggle
|
|
30
|
+
*/
|
|
31
|
+
label?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Label placement relative to toggle
|
|
34
|
+
* @default 'end'
|
|
35
|
+
*/
|
|
36
|
+
labelPlacement?: 'start' | 'end';
|
|
37
|
+
/**
|
|
38
|
+
* Helper text to display below the toggle
|
|
39
|
+
*/
|
|
40
|
+
helperText?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Error message to display when toggle is in error state
|
|
43
|
+
*/
|
|
44
|
+
errorMessage?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the toggle is in an error state
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
error?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* ID for the input element (also used for label[for])
|
|
52
|
+
* Auto-generated if not provided
|
|
53
|
+
*/
|
|
54
|
+
id?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Toggle (Switch) component
|
|
58
|
+
* A toggle switch for boolean input with smooth animations
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <Toggle
|
|
63
|
+
* label="Enable notifications"
|
|
64
|
+
* checked={enabled}
|
|
65
|
+
* onChange={(checked) => setEnabled(checked)}
|
|
66
|
+
* />
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const Toggle: React.ForwardRefExoticComponent<ToggleProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './Input';
|
|
2
|
+
export * from './Textarea';
|
|
3
|
+
export * from './NumberInput';
|
|
4
|
+
export * from './PhoneInput';
|
|
5
|
+
export * from './TagInput';
|
|
6
|
+
export * from './Select';
|
|
7
|
+
export * from './Autocomplete';
|
|
8
|
+
export * from './Checkbox';
|
|
9
|
+
export * from './Radio';
|
|
10
|
+
export * from './Toggle';
|
|
11
|
+
export * from './Slider';
|
|
12
|
+
export * from './Rating';
|
|
13
|
+
export * from './ColorPicker';
|
|
14
|
+
export * from './DatePicker';
|
|
15
|
+
export * from './DateRangePicker';
|
|
16
|
+
export * from './FilePicker';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { MenuProps } from '../Menu';
|
|
3
|
+
import { IconName } from '../../../assets/icons';
|
|
4
|
+
import { ComponentVariant, ComponentSize } from '../../../types';
|
|
5
|
+
/**
|
|
6
|
+
* Dropdown item definition
|
|
7
|
+
*/
|
|
8
|
+
export interface DropdownItem {
|
|
9
|
+
/**
|
|
10
|
+
* Unique key for the item
|
|
11
|
+
*/
|
|
12
|
+
itemKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* Label to display
|
|
15
|
+
*/
|
|
16
|
+
label: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Optional icon (icon name or React element)
|
|
19
|
+
*/
|
|
20
|
+
icon?: ReactNode | IconName;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the item is disabled
|
|
23
|
+
*/
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether this is a divider (renders MenuDivider instead of MenuItem)
|
|
27
|
+
*/
|
|
28
|
+
divider?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Click handler for the item
|
|
31
|
+
*/
|
|
32
|
+
onClick?: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dropdown option for extracting labels (deprecated, use DropdownItem)
|
|
36
|
+
*/
|
|
37
|
+
export interface DropdownOption {
|
|
38
|
+
itemKey: string;
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Dropdown component props
|
|
43
|
+
*/
|
|
44
|
+
export interface DropdownProps extends Omit<MenuProps, 'trigger' | 'children'> {
|
|
45
|
+
/**
|
|
46
|
+
* Button text (shown when nothing is selected)
|
|
47
|
+
*/
|
|
48
|
+
label: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Button variant
|
|
51
|
+
* @default 'outline'
|
|
52
|
+
*/
|
|
53
|
+
variant?: ComponentVariant;
|
|
54
|
+
/**
|
|
55
|
+
* Button size
|
|
56
|
+
* @default 'md'
|
|
57
|
+
*/
|
|
58
|
+
size?: ComponentSize;
|
|
59
|
+
/**
|
|
60
|
+
* Show chevron icon
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
showChevron?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Button icon
|
|
66
|
+
*/
|
|
67
|
+
icon?: ReactNode | IconName;
|
|
68
|
+
/**
|
|
69
|
+
* Full width button
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
fullWidth?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Array of items to render as menu items
|
|
75
|
+
* If provided, children will be ignored
|
|
76
|
+
*/
|
|
77
|
+
items?: DropdownItem[];
|
|
78
|
+
/**
|
|
79
|
+
* Custom children (menu items)
|
|
80
|
+
* Only used if items prop is not provided
|
|
81
|
+
*/
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
}
|
|
84
|
+
export declare const Dropdown: React.FC<DropdownProps>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PopoverProps } from '../Popover';
|
|
3
|
+
import { SelectionMode } from './MenuContext';
|
|
4
|
+
/**
|
|
5
|
+
* Menu component props
|
|
6
|
+
*/
|
|
7
|
+
export interface MenuProps extends Omit<PopoverProps, 'children' | 'width'> {
|
|
8
|
+
/**
|
|
9
|
+
* Menu items (MenuList, MenuItem, etc.)
|
|
10
|
+
*/
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Selection mode
|
|
14
|
+
* @default 'none'
|
|
15
|
+
*/
|
|
16
|
+
selectionMode?: SelectionMode;
|
|
17
|
+
/**
|
|
18
|
+
* Selected item keys (controlled)
|
|
19
|
+
*/
|
|
20
|
+
selectedKeys?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Default selected keys (uncontrolled)
|
|
23
|
+
* @default []
|
|
24
|
+
*/
|
|
25
|
+
defaultSelectedKeys?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Callback when selection changes
|
|
28
|
+
*/
|
|
29
|
+
onSelectionChange?: (keys: string[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Callback when item is selected
|
|
32
|
+
*/
|
|
33
|
+
onAction?: (key: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Width configuration for menu
|
|
36
|
+
* - 'trigger': Match trigger element width
|
|
37
|
+
* - 'auto': Use natural content width
|
|
38
|
+
* - 'content': Use content width (fit-content)
|
|
39
|
+
* - 'max-content': Use maximum content width (takes width of widest item and target)
|
|
40
|
+
* - number: Fixed width in pixels
|
|
41
|
+
* @default 'max-content'
|
|
42
|
+
*/
|
|
43
|
+
width?: PopoverProps['width'];
|
|
44
|
+
/**
|
|
45
|
+
* Whether to automatically focus the first menu item when opened
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
autoFocusFirstItem?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether to scroll to the selected item when menu opens
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
scrollToSelected?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Enable keyboard type-ahead navigation
|
|
56
|
+
* When enabled, typing characters will jump to/cycle through matching items
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
enableTypeAhead?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Delay in milliseconds before resetting the type-ahead search string
|
|
62
|
+
* @default 500
|
|
63
|
+
*/
|
|
64
|
+
typeAheadDelay?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Menu component
|
|
68
|
+
* Provides context and keyboard navigation for menu items
|
|
69
|
+
*/
|
|
70
|
+
export declare const Menu: React.FC<MenuProps>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu context for sharing state across menu components
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Selection mode for menu
|
|
6
|
+
*/
|
|
7
|
+
export type SelectionMode = 'none' | 'single' | 'multi';
|
|
8
|
+
/**
|
|
9
|
+
* Menu context value
|
|
10
|
+
*/
|
|
11
|
+
export interface MenuContextValue {
|
|
12
|
+
/**
|
|
13
|
+
* Set of selected item keys
|
|
14
|
+
*/
|
|
15
|
+
selectedKeys: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Toggle selection for an item
|
|
18
|
+
*/
|
|
19
|
+
toggleSelection: (key: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Selection mode
|
|
22
|
+
*/
|
|
23
|
+
selectionMode: SelectionMode;
|
|
24
|
+
/**
|
|
25
|
+
* Close the menu
|
|
26
|
+
*/
|
|
27
|
+
closeMenu: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Currently focused item index (-1 means no item is focused)
|
|
30
|
+
*/
|
|
31
|
+
focusedIndex: number;
|
|
32
|
+
/**
|
|
33
|
+
* Set focused item index
|
|
34
|
+
*/
|
|
35
|
+
setFocusedIndex: (index: number) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Total number of items
|
|
38
|
+
*/
|
|
39
|
+
itemsCount: number;
|
|
40
|
+
/**
|
|
41
|
+
* Register a menu item and get assigned index
|
|
42
|
+
*/
|
|
43
|
+
registerItem: () => number;
|
|
44
|
+
/**
|
|
45
|
+
* Callback when item is clicked
|
|
46
|
+
*/
|
|
47
|
+
onItemAction?: (key: string) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to scroll to selected item when menu opens
|
|
50
|
+
*/
|
|
51
|
+
scrollToSelected?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether type-ahead keyboard navigation is enabled
|
|
54
|
+
*/
|
|
55
|
+
enableTypeAhead?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Register item label for type-ahead search
|
|
58
|
+
*/
|
|
59
|
+
registerItemLabel: (index: number, label: string) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Menu context
|
|
63
|
+
*/
|
|
64
|
+
export declare const MenuContext: import('react').Context<MenuContextValue | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Hook to access menu context
|
|
67
|
+
*/
|
|
68
|
+
export declare function useMenuContext(): MenuContextValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseComponentProps } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* MenuDivider component props
|
|
4
|
+
*/
|
|
5
|
+
export type MenuDividerProps = BaseComponentProps;
|
|
6
|
+
/**
|
|
7
|
+
* MenuDivider component
|
|
8
|
+
* Visual separator between menu items
|
|
9
|
+
*/
|
|
10
|
+
export declare const MenuDivider: React.FC<MenuDividerProps>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseComponentProps } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* MenuGroup component props
|
|
5
|
+
*/
|
|
6
|
+
export interface MenuGroupProps extends BaseComponentProps {
|
|
7
|
+
/**
|
|
8
|
+
* Group label
|
|
9
|
+
*/
|
|
10
|
+
label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Menu items
|
|
13
|
+
*/
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* MenuGroup component
|
|
18
|
+
* Groups related menu items with an optional label
|
|
19
|
+
*/
|
|
20
|
+
export declare const MenuGroup: React.FC<MenuGroupProps>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseComponentProps } from '../../../types';
|
|
3
|
+
import { IconName } from '../../../assets/icons';
|
|
4
|
+
/**
|
|
5
|
+
* MenuItem component props
|
|
6
|
+
*/
|
|
7
|
+
export interface MenuItemProps extends BaseComponentProps {
|
|
8
|
+
/**
|
|
9
|
+
* Unique key for this item
|
|
10
|
+
*/
|
|
11
|
+
itemKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether item is disabled
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Icon to display before text
|
|
19
|
+
*/
|
|
20
|
+
startIcon?: ReactNode | IconName;
|
|
21
|
+
/**
|
|
22
|
+
* Icon to display after text
|
|
23
|
+
*/
|
|
24
|
+
endIcon?: ReactNode | IconName;
|
|
25
|
+
/**
|
|
26
|
+
* Keyboard shortcut text to display
|
|
27
|
+
*/
|
|
28
|
+
shortcut?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Click handler
|
|
31
|
+
*/
|
|
32
|
+
onClick?: () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Item content
|
|
35
|
+
*/
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* MenuItem component
|
|
40
|
+
* Interactive menu item with selection, hover, and keyboard support
|
|
41
|
+
*/
|
|
42
|
+
export declare const MenuItem: React.FC<MenuItemProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseComponentProps } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* MenuList component props
|
|
5
|
+
*/
|
|
6
|
+
export interface MenuListProps extends BaseComponentProps {
|
|
7
|
+
/**
|
|
8
|
+
* Menu items
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* MenuList component
|
|
14
|
+
* Container for menu items with scrolling support
|
|
15
|
+
*/
|
|
16
|
+
export declare const MenuList: React.FC<MenuListProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Menu } from './Menu';
|
|
2
|
+
export type { MenuProps } from './Menu';
|
|
3
|
+
export { MenuList } from './MenuList';
|
|
4
|
+
export type { MenuListProps } from './MenuList';
|
|
5
|
+
export { MenuItem } from './MenuItem';
|
|
6
|
+
export type { MenuItemProps } from './MenuItem';
|
|
7
|
+
export { MenuDivider } from './MenuDivider';
|
|
8
|
+
export type { MenuDividerProps } from './MenuDivider';
|
|
9
|
+
export { MenuGroup } from './MenuGroup';
|
|
10
|
+
export type { MenuGroupProps } from './MenuGroup';
|
|
11
|
+
export { MenuContext, useMenuContext } from './MenuContext';
|
|
12
|
+
export type { MenuContextValue, SelectionMode } from './MenuContext';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { PopoverPosition, PopoverWidth } from '../../../utils';
|
|
3
|
+
import { BaseComponentProps } from '../../../types';
|
|
4
|
+
/**
|
|
5
|
+
* Popover component props
|
|
6
|
+
*/
|
|
7
|
+
export interface PopoverProps extends Omit<BaseComponentProps, 'children'> {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the popover is open (controlled)
|
|
10
|
+
*/
|
|
11
|
+
isOpen?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Default open state (uncontrolled)
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
defaultOpen?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Callback when open state changes
|
|
19
|
+
*/
|
|
20
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Popover position relative to trigger
|
|
23
|
+
* @default 'bottom'
|
|
24
|
+
*/
|
|
25
|
+
position?: PopoverPosition;
|
|
26
|
+
/**
|
|
27
|
+
* Gap between trigger and popover in pixels
|
|
28
|
+
* @default 8
|
|
29
|
+
*/
|
|
30
|
+
offset?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Allow position to flip if would overflow viewport
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
allowFlip?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Close on click outside
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
closeOnClickOutside?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Close on Escape key
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
closeOnEscape?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Trigger element (render prop or ReactNode)
|
|
48
|
+
*/
|
|
49
|
+
trigger: ReactNode | ((props: {
|
|
50
|
+
ref: RefObject<HTMLElement>;
|
|
51
|
+
}) => ReactNode);
|
|
52
|
+
/**
|
|
53
|
+
* Popover content
|
|
54
|
+
*/
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* Z-index for popover
|
|
58
|
+
*/
|
|
59
|
+
zIndex?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Width configuration for popover
|
|
62
|
+
* @default 'auto'
|
|
63
|
+
*/
|
|
64
|
+
width?: PopoverWidth;
|
|
65
|
+
/**
|
|
66
|
+
* Callback when popover is closed
|
|
67
|
+
*/
|
|
68
|
+
onClose?: () => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Popover component
|
|
72
|
+
* Base component for creating positioned overlays
|
|
73
|
+
*/
|
|
74
|
+
export declare const Popover: React.FC<PopoverProps>;
|