@webstrail/ui-library 0.0.0-stage → 1.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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +524 -3
  3. package/dist/components/Button/Button.d.ts +2 -0
  4. package/dist/components/Button/Button.types.d.ts +45 -0
  5. package/dist/components/Button/index.d.ts +2 -0
  6. package/dist/components/Checkbox/Checkbox.d.ts +2 -0
  7. package/dist/components/Checkbox/Checkbox.types.d.ts +38 -0
  8. package/dist/components/Checkbox/index.d.ts +2 -0
  9. package/dist/components/Input/Input.d.ts +2 -0
  10. package/dist/components/Input/Input.types.d.ts +87 -0
  11. package/dist/components/Input/index.d.ts +2 -0
  12. package/dist/components/Radio/Radio.d.ts +2 -0
  13. package/dist/components/Radio/Radio.types.d.ts +119 -0
  14. package/dist/components/Radio/RadioGroup.d.ts +2 -0
  15. package/dist/components/Radio/RadioGroupContext.d.ts +13 -0
  16. package/dist/components/Radio/index.d.ts +4 -0
  17. package/dist/components/Select/Select.d.ts +2 -0
  18. package/dist/components/Select/Select.types.d.ts +100 -0
  19. package/dist/components/Select/index.d.ts +2 -0
  20. package/dist/components/Switch/Switch.d.ts +2 -0
  21. package/dist/components/Switch/Switch.types.d.ts +82 -0
  22. package/dist/components/Switch/index.d.ts +2 -0
  23. package/dist/components/Textarea/Textarea.d.ts +2 -0
  24. package/dist/components/Textarea/Textarea.types.d.ts +61 -0
  25. package/dist/components/Textarea/index.d.ts +2 -0
  26. package/dist/components/index.d.ts +14 -0
  27. package/dist/config/config.types.d.ts +232 -0
  28. package/dist/config/defaultConfig.d.ts +2 -0
  29. package/dist/config/mergeConfig.d.ts +28 -0
  30. package/dist/context/UIContext.d.ts +6 -0
  31. package/dist/context/index.d.ts +1 -0
  32. package/dist/hooks/index.d.ts +3 -0
  33. package/dist/hooks/useComponentStyles.d.ts +26 -0
  34. package/dist/hooks/useUI.d.ts +6 -0
  35. package/dist/index.cjs +2 -0
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.ts +25 -0
  38. package/dist/index.js +1577 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/providers/UIProvider.d.ts +20 -0
  41. package/dist/providers/index.d.ts +2 -0
  42. package/dist/style.css +1 -0
  43. package/dist/types/common.d.ts +41 -0
  44. package/dist/types/index.d.ts +1 -0
  45. package/dist/utils/classNames.d.ts +11 -0
  46. package/dist/utils/resolveStyles.d.ts +28 -0
  47. package/package.json +104 -6
@@ -0,0 +1,87 @@
1
+ import { InputHTMLAttributes, ReactNode, CSSProperties } from 'react';
2
+ import { BaseComponentProps } from '../../types/common';
3
+ import { InputStyles } from '../../config/config.types';
4
+ export type IconPlacement = 'inside' | 'outside';
5
+ export interface InputSubElementClassNames {
6
+ outerWrapper?: string;
7
+ outerIconBox?: string;
8
+ outerStartIcon?: string;
9
+ outerEndIcon?: string;
10
+ wrapper?: string;
11
+ input?: string;
12
+ label?: string;
13
+ floatingLabel?: string;
14
+ helperText?: string;
15
+ errorMessage?: string;
16
+ }
17
+ export interface InputSubElementStyles {
18
+ outerWrapper?: CSSProperties;
19
+ outerIconBox?: CSSProperties;
20
+ outerStartIcon?: CSSProperties;
21
+ outerEndIcon?: CSSProperties;
22
+ wrapper?: CSSProperties;
23
+ input?: CSSProperties;
24
+ label?: CSSProperties;
25
+ floatingLabel?: CSSProperties;
26
+ helperText?: CSSProperties;
27
+ errorMessage?: CSSProperties;
28
+ }
29
+ export interface InputProps extends BaseComponentProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'style' | 'className' | 'size'> {
30
+ /**
31
+ * Optional field label text or element.
32
+ */
33
+ label?: ReactNode;
34
+ /**
35
+ * Whether to display the label as a floating label that transitions to the top-corner on focus.
36
+ * Defaults to the configuration value in UIProvider (default: true).
37
+ */
38
+ floatingLabel?: boolean;
39
+ /**
40
+ * Explanatory helper text beneath the input.
41
+ */
42
+ helperText?: ReactNode;
43
+ /**
44
+ * Error message displayed beneath the input, toggling the error state.
45
+ */
46
+ errorMessage?: ReactNode;
47
+ /**
48
+ * Leading icon or element inside or outside the input container.
49
+ */
50
+ startIcon?: ReactNode;
51
+ /**
52
+ * Trailing icon or element inside or outside the input container.
53
+ */
54
+ endIcon?: ReactNode;
55
+ /**
56
+ * Placement of the startIcon. When 'outside', the icon is rendered in a separate box outside the input.
57
+ * Defaults to 'inside'.
58
+ */
59
+ startIconPlacement?: IconPlacement;
60
+ /**
61
+ * Placement of the endIcon. When 'outside', the icon is rendered in a separate box outside the input.
62
+ * Defaults to 'inside'.
63
+ */
64
+ endIconPlacement?: IconPlacement;
65
+ /**
66
+ * Dedicated outer leading icon rendered in a separate box outside the input.
67
+ * Shortcut for startIcon with startIconPlacement="outside".
68
+ */
69
+ outerStartIcon?: ReactNode;
70
+ /**
71
+ * Dedicated outer trailing icon rendered in a separate box outside the input.
72
+ * Shortcut for endIcon with endIconPlacement="outside".
73
+ */
74
+ outerEndIcon?: ReactNode;
75
+ /**
76
+ * Semantic styles override for this Input instance.
77
+ */
78
+ styles?: InputStyles;
79
+ /**
80
+ * Class name overrides for specific sub-elements of the Input.
81
+ */
82
+ slotClassNames?: InputSubElementClassNames;
83
+ /**
84
+ * Inline style overrides for specific sub-elements of the Input.
85
+ */
86
+ slotStyles?: InputSubElementStyles;
87
+ }
@@ -0,0 +1,2 @@
1
+ export { Input } from './Input';
2
+ export type { InputProps, InputSubElementClassNames, InputSubElementStyles } from './Input.types';
@@ -0,0 +1,2 @@
1
+ import { RadioProps } from './Radio.types';
2
+ export declare const Radio: import('react').ForwardRefExoticComponent<RadioProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,119 @@
1
+ import { InputHTMLAttributes, ReactNode, CSSProperties } from 'react';
2
+ import { BaseComponentProps, DimensionValue } from '../../types/common';
3
+ import { RadioStyles } from '../../config/config.types';
4
+ export interface RadioSubElementClassNames {
5
+ container?: string;
6
+ radio?: string;
7
+ control?: string;
8
+ labelWrapper?: string;
9
+ label?: string;
10
+ labelChecked?: string;
11
+ description?: string;
12
+ }
13
+ export interface RadioSubElementStyles {
14
+ container?: CSSProperties;
15
+ radio?: CSSProperties;
16
+ control?: CSSProperties;
17
+ labelWrapper?: CSSProperties;
18
+ label?: CSSProperties;
19
+ description?: CSSProperties;
20
+ }
21
+ export interface RadioProps extends BaseComponentProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'style' | 'className' | 'size' | 'type' | 'color'> {
22
+ /**
23
+ * Optional primary label.
24
+ */
25
+ label?: ReactNode;
26
+ /**
27
+ * Optional secondary description text beneath the label.
28
+ */
29
+ description?: ReactNode;
30
+ /**
31
+ * The value represented by this radio button.
32
+ */
33
+ value?: string;
34
+ /**
35
+ * Custom radio size (e.g. '18px', '22px', 20).
36
+ */
37
+ size?: DimensionValue;
38
+ /**
39
+ * Custom radio accent color (e.g. '#10b981', 'rgb(...)').
40
+ */
41
+ color?: string;
42
+ /**
43
+ * Semantic styles override for this Radio instance.
44
+ */
45
+ styles?: RadioStyles;
46
+ /**
47
+ * Custom class names for sub-elements.
48
+ */
49
+ slotClassNames?: RadioSubElementClassNames;
50
+ /**
51
+ * Custom inline styles for sub-elements.
52
+ */
53
+ slotStyles?: RadioSubElementStyles;
54
+ }
55
+ export interface RadioGroupOption {
56
+ value: string;
57
+ label: ReactNode;
58
+ description?: ReactNode;
59
+ disabled?: boolean;
60
+ size?: DimensionValue;
61
+ color?: string;
62
+ styles?: RadioStyles;
63
+ }
64
+ export interface RadioGroupProps extends BaseComponentProps {
65
+ /**
66
+ * Name attribute shared across all radio buttons in this group.
67
+ */
68
+ name?: string;
69
+ /**
70
+ * Controlled selected value.
71
+ */
72
+ value?: string;
73
+ /**
74
+ * Uncontrolled initial selected value.
75
+ */
76
+ defaultValue?: string;
77
+ /**
78
+ * Change callback fired when the selected value changes.
79
+ */
80
+ onChange?: (value: string) => void;
81
+ /**
82
+ * Convenient array of options to render automatically.
83
+ */
84
+ options?: RadioGroupOption[];
85
+ /**
86
+ * Layout direction for options.
87
+ * @default 'vertical'
88
+ */
89
+ direction?: 'vertical' | 'horizontal';
90
+ /**
91
+ * Optional group label / legend.
92
+ */
93
+ label?: ReactNode;
94
+ /**
95
+ * Optional error message.
96
+ */
97
+ errorMessage?: ReactNode;
98
+ /**
99
+ * Whether the entire group is disabled.
100
+ * @default false
101
+ */
102
+ disabled?: boolean;
103
+ /**
104
+ * Default size for radios in this group.
105
+ */
106
+ size?: DimensionValue;
107
+ /**
108
+ * Default accent color for radios in this group.
109
+ */
110
+ color?: string;
111
+ /**
112
+ * Children components (individual Radio components).
113
+ */
114
+ children?: ReactNode;
115
+ /**
116
+ * Semantic styles override applied to the group's radios.
117
+ */
118
+ styles?: RadioStyles;
119
+ }
@@ -0,0 +1,2 @@
1
+ import { RadioGroupProps } from './Radio.types';
2
+ export declare const RadioGroup: import('react').ForwardRefExoticComponent<RadioGroupProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,13 @@
1
+ import { RadioStyles } from '../../config/config.types';
2
+ import { DimensionValue } from '../../types/common';
3
+ export interface RadioGroupContextValue {
4
+ name?: string;
5
+ value?: string;
6
+ onChange?: (value: string) => void;
7
+ disabled?: boolean;
8
+ size?: DimensionValue;
9
+ color?: string;
10
+ groupStyles?: RadioStyles;
11
+ }
12
+ export declare const RadioGroupContext: import('react').Context<RadioGroupContextValue | null>;
13
+ export declare function useRadioGroup(): RadioGroupContextValue | null;
@@ -0,0 +1,4 @@
1
+ export { Radio } from './Radio';
2
+ export { RadioGroup } from './RadioGroup';
3
+ export { RadioGroupContext, useRadioGroup } from './RadioGroupContext';
4
+ export type { RadioProps, RadioSubElementClassNames, RadioSubElementStyles, RadioGroupProps, RadioGroupOption, } from './Radio.types';
@@ -0,0 +1,2 @@
1
+ import { SelectProps } from './Select.types';
2
+ export declare const Select: import('react').ForwardRefExoticComponent<SelectProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,100 @@
1
+ import { ReactNode, CSSProperties } from 'react';
2
+ import { BaseComponentProps } from '../../types/common';
3
+ import { SelectStyles } from '../../config/config.types';
4
+ export interface SelectOption {
5
+ value: string;
6
+ label: string;
7
+ disabled?: boolean;
8
+ }
9
+ export interface SelectSubElementClassNames {
10
+ container?: string;
11
+ wrapper?: string;
12
+ label?: string;
13
+ floatingLabel?: string;
14
+ trigger?: string;
15
+ value?: string;
16
+ placeholder?: string;
17
+ arrow?: string;
18
+ dropdown?: string;
19
+ option?: string;
20
+ selectedOption?: string;
21
+ checkIcon?: string;
22
+ errorMessage?: string;
23
+ }
24
+ export interface SelectSubElementStyles {
25
+ container?: CSSProperties;
26
+ wrapper?: CSSProperties;
27
+ label?: CSSProperties;
28
+ floatingLabel?: CSSProperties;
29
+ trigger?: CSSProperties;
30
+ value?: CSSProperties;
31
+ placeholder?: CSSProperties;
32
+ arrow?: CSSProperties;
33
+ dropdown?: CSSProperties;
34
+ option?: CSSProperties;
35
+ selectedOption?: CSSProperties;
36
+ checkIcon?: CSSProperties;
37
+ errorMessage?: CSSProperties;
38
+ }
39
+ export interface SelectProps extends BaseComponentProps {
40
+ /**
41
+ * Available options to select from.
42
+ */
43
+ options: SelectOption[];
44
+ /**
45
+ * Controlled selected value.
46
+ */
47
+ value?: string;
48
+ /**
49
+ * Uncontrolled initial value.
50
+ */
51
+ defaultValue?: string;
52
+ /**
53
+ * Placeholder text shown when no value is selected.
54
+ */
55
+ placeholder?: string;
56
+ /**
57
+ * Optional field label.
58
+ */
59
+ label?: ReactNode;
60
+ /**
61
+ * Whether to display as an animated floating label.
62
+ * If true, label glides to the top border on focus/selection.
63
+ * @default true
64
+ */
65
+ floatingLabel?: boolean;
66
+ /**
67
+ * Error message displayed beneath the select.
68
+ */
69
+ errorMessage?: ReactNode;
70
+ /**
71
+ * Whether the select is disabled.
72
+ * @default false
73
+ */
74
+ disabled?: boolean;
75
+ /**
76
+ * Required field marker.
77
+ * @default false
78
+ */
79
+ required?: boolean;
80
+ /**
81
+ * Change event callback.
82
+ */
83
+ onChange?: (value: string) => void;
84
+ /**
85
+ * Name attribute for form submissions.
86
+ */
87
+ name?: string;
88
+ /**
89
+ * Semantic styles override for this Select instance.
90
+ */
91
+ styles?: SelectStyles;
92
+ /**
93
+ * Custom class names for sub-elements.
94
+ */
95
+ slotClassNames?: SelectSubElementClassNames;
96
+ /**
97
+ * Custom inline styles for sub-elements.
98
+ */
99
+ slotStyles?: SelectSubElementStyles;
100
+ }
@@ -0,0 +1,2 @@
1
+ export { Select } from './Select';
2
+ export type { SelectProps, SelectOption, SelectSubElementClassNames, SelectSubElementStyles, } from './Select.types';
@@ -0,0 +1,2 @@
1
+ import { SwitchProps } from './Switch.types';
2
+ export declare const Switch: import('react').ForwardRefExoticComponent<SwitchProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,82 @@
1
+ import { ReactNode, CSSProperties, ChangeEvent } from 'react';
2
+ import { BaseComponentProps, ComponentSize } from '../../types/common';
3
+ import { SwitchStyles } from '../../config/config.types';
4
+ export interface SwitchSubElementClassNames {
5
+ container?: string;
6
+ track?: string;
7
+ thumb?: string;
8
+ labelWrapper?: string;
9
+ label?: string;
10
+ description?: string;
11
+ icon?: string;
12
+ }
13
+ export interface SwitchSubElementStyles {
14
+ container?: CSSProperties;
15
+ track?: CSSProperties;
16
+ thumb?: CSSProperties;
17
+ labelWrapper?: CSSProperties;
18
+ label?: CSSProperties;
19
+ description?: CSSProperties;
20
+ icon?: CSSProperties;
21
+ }
22
+ export interface SwitchProps extends BaseComponentProps {
23
+ /**
24
+ * Controlled checked state.
25
+ */
26
+ checked?: boolean;
27
+ /**
28
+ * Uncontrolled initial checked state.
29
+ * @default false
30
+ */
31
+ defaultChecked?: boolean;
32
+ /**
33
+ * Change callback invoked when state flips.
34
+ */
35
+ onChange?: (checked: boolean, event: ChangeEvent<HTMLInputElement>) => void;
36
+ /**
37
+ * Whether the switch is disabled.
38
+ * @default false
39
+ */
40
+ disabled?: boolean;
41
+ /**
42
+ * Pre-configured size variant.
43
+ * @default 'medium'
44
+ */
45
+ size?: ComponentSize;
46
+ /**
47
+ * Optional primary label text or element.
48
+ */
49
+ label?: ReactNode;
50
+ /**
51
+ * Optional secondary description text beneath the label.
52
+ */
53
+ description?: ReactNode;
54
+ /**
55
+ * Optional icon inside the thumb when checked.
56
+ */
57
+ checkedIcon?: ReactNode;
58
+ /**
59
+ * Optional icon inside the thumb when unchecked.
60
+ */
61
+ uncheckedIcon?: ReactNode;
62
+ /**
63
+ * HTML form submission name attribute.
64
+ */
65
+ name?: string;
66
+ /**
67
+ * HTML form submission value attribute.
68
+ */
69
+ value?: string;
70
+ /**
71
+ * Semantic styles override for this Switch instance.
72
+ */
73
+ styles?: SwitchStyles;
74
+ /**
75
+ * Custom class names for sub-elements.
76
+ */
77
+ slotClassNames?: SwitchSubElementClassNames;
78
+ /**
79
+ * Custom inline styles for sub-elements.
80
+ */
81
+ slotStyles?: SwitchSubElementStyles;
82
+ }
@@ -0,0 +1,2 @@
1
+ export { Switch } from './Switch';
2
+ export type { SwitchProps, SwitchSubElementClassNames, SwitchSubElementStyles, } from './Switch.types';
@@ -0,0 +1,2 @@
1
+ import { TextareaProps } from './Textarea.types';
2
+ export declare const Textarea: import('react').ForwardRefExoticComponent<TextareaProps & import('react').RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1,61 @@
1
+ import { TextareaHTMLAttributes, ReactNode, CSSProperties } from 'react';
2
+ import { BaseComponentProps } from '../../types/common';
3
+ import { TextareaStyles } from '../../config/config.types';
4
+ export interface TextareaSubElementClassNames {
5
+ container?: string;
6
+ label?: string;
7
+ floatingLabel?: string;
8
+ wrapper?: string;
9
+ textarea?: string;
10
+ helperText?: string;
11
+ errorMessage?: string;
12
+ counter?: string;
13
+ }
14
+ export interface TextareaSubElementStyles {
15
+ container?: CSSProperties;
16
+ label?: CSSProperties;
17
+ floatingLabel?: CSSProperties;
18
+ wrapper?: CSSProperties;
19
+ textarea?: CSSProperties;
20
+ helperText?: CSSProperties;
21
+ errorMessage?: CSSProperties;
22
+ counter?: CSSProperties;
23
+ }
24
+ export interface TextareaProps extends BaseComponentProps, Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'style' | 'className'> {
25
+ /**
26
+ * Field label.
27
+ */
28
+ label?: ReactNode;
29
+ /**
30
+ * Whether to display as an animated floating label.
31
+ * If true, label glides to the top border on focus/fill.
32
+ * @default true
33
+ */
34
+ floatingLabel?: boolean;
35
+ /**
36
+ * Explanatory helper text beneath the textarea.
37
+ */
38
+ helperText?: ReactNode;
39
+ /**
40
+ * Error message displayed beneath the textarea.
41
+ */
42
+ errorMessage?: ReactNode;
43
+ /**
44
+ * Whether to display character counter.
45
+ * If maxLength is provided, displays `${current} / ${maxLength}`.
46
+ * @default false
47
+ */
48
+ showCount?: boolean;
49
+ /**
50
+ * Semantic styles override for this Textarea instance.
51
+ */
52
+ styles?: TextareaStyles;
53
+ /**
54
+ * Class name overrides for sub-elements.
55
+ */
56
+ slotClassNames?: TextareaSubElementClassNames;
57
+ /**
58
+ * Inline style overrides for sub-elements.
59
+ */
60
+ slotStyles?: TextareaSubElementStyles;
61
+ }
@@ -0,0 +1,2 @@
1
+ export { Textarea } from './Textarea';
2
+ export type { TextareaProps, TextareaSubElementClassNames, TextareaSubElementStyles, } from './Textarea.types';
@@ -0,0 +1,14 @@
1
+ export { Button } from './Button';
2
+ export type { ButtonProps } from './Button';
3
+ export { Input } from './Input';
4
+ export type { InputProps, InputSubElementClassNames, InputSubElementStyles } from './Input';
5
+ export { Checkbox } from './Checkbox';
6
+ export type { CheckboxProps, CheckboxSubElementClassNames, CheckboxSubElementStyles, } from './Checkbox';
7
+ export { Select } from './Select';
8
+ export type { SelectProps, SelectOption, SelectSubElementClassNames, SelectSubElementStyles, } from './Select';
9
+ export { Textarea } from './Textarea';
10
+ export type { TextareaProps, TextareaSubElementClassNames, TextareaSubElementStyles, } from './Textarea';
11
+ export { Radio, RadioGroup, useRadioGroup, RadioGroupContext } from './Radio';
12
+ export type { RadioProps, RadioSubElementClassNames, RadioSubElementStyles, RadioGroupProps, RadioGroupOption, } from './Radio';
13
+ export { Switch } from './Switch';
14
+ export type { SwitchProps, SwitchSubElementClassNames, SwitchSubElementStyles } from './Switch';