@arctura/atomics 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/dist/hooks.cjs +1 -0
- package/dist/hooks.js +2 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +1980 -0
- package/dist/lib/hooks.d.ts +5 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/useBreakpoints.d.ts +48 -0
- package/dist/lib/useBreakpoints.d.ts.map +1 -0
- package/dist/lib/useControlled.d.ts +38 -0
- package/dist/lib/useControlled.d.ts.map +1 -0
- package/dist/src/badge/Badge.d.ts +116 -0
- package/dist/src/badge/Badge.d.ts.map +1 -0
- package/dist/src/badge/index.d.ts +3 -0
- package/dist/src/badge/index.d.ts.map +1 -0
- package/dist/src/buttons/Button.d.ts +126 -0
- package/dist/src/buttons/Button.d.ts.map +1 -0
- package/dist/src/buttons/Fab.d.ts +114 -0
- package/dist/src/buttons/Fab.d.ts.map +1 -0
- package/dist/src/buttons/IconButton.d.ts +105 -0
- package/dist/src/buttons/IconButton.d.ts.map +1 -0
- package/dist/src/buttons/index.d.ts +9 -0
- package/dist/src/buttons/index.d.ts.map +1 -0
- package/dist/src/card/Card.d.ts +35 -0
- package/dist/src/card/Card.d.ts.map +1 -0
- package/dist/src/card/Footer.d.ts +67 -0
- package/dist/src/card/Footer.d.ts.map +1 -0
- package/dist/src/card/Header.d.ts +56 -0
- package/dist/src/card/Header.d.ts.map +1 -0
- package/dist/src/card/Media.d.ts +65 -0
- package/dist/src/card/Media.d.ts.map +1 -0
- package/dist/src/card/index.d.ts +11 -0
- package/dist/src/card/index.d.ts.map +1 -0
- package/dist/src/carousel/Carousel.d.ts +124 -0
- package/dist/src/carousel/Carousel.d.ts.map +1 -0
- package/dist/src/carousel/Hero.d.ts +156 -0
- package/dist/src/carousel/Hero.d.ts.map +1 -0
- package/dist/src/carousel/index.d.ts +4 -0
- package/dist/src/carousel/index.d.ts.map +1 -0
- package/dist/src/drawer/Drawer.d.ts +40 -0
- package/dist/src/drawer/Drawer.d.ts.map +1 -0
- package/dist/src/drawer/index.d.ts +5 -0
- package/dist/src/drawer/index.d.ts.map +1 -0
- package/dist/src/form/Form.d.ts +168 -0
- package/dist/src/form/Form.d.ts.map +1 -0
- package/dist/src/form/TextArea.d.ts +266 -0
- package/dist/src/form/TextArea.d.ts.map +1 -0
- package/dist/src/form/TextInput.d.ts +200 -0
- package/dist/src/form/TextInput.d.ts.map +1 -0
- package/dist/src/form/index.d.ts +7 -0
- package/dist/src/form/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/list/List.d.ts +122 -0
- package/dist/src/list/List.d.ts.map +1 -0
- package/dist/src/list/ListItem.d.ts +157 -0
- package/dist/src/list/ListItem.d.ts.map +1 -0
- package/dist/src/list/index.d.ts +6 -0
- package/dist/src/list/index.d.ts.map +1 -0
- package/dist/src/progress-stepper/Connector.d.ts +48 -0
- package/dist/src/progress-stepper/Connector.d.ts.map +1 -0
- package/dist/src/progress-stepper/Node.d.ts +75 -0
- package/dist/src/progress-stepper/Node.d.ts.map +1 -0
- package/dist/src/progress-stepper/ProgressStepper.d.ts +108 -0
- package/dist/src/progress-stepper/ProgressStepper.d.ts.map +1 -0
- package/dist/src/progress-stepper/Step.d.ts +93 -0
- package/dist/src/progress-stepper/Step.d.ts.map +1 -0
- package/dist/src/progress-stepper/index.d.ts +10 -0
- package/dist/src/progress-stepper/index.d.ts.map +1 -0
- package/dist/src/select/Select.d.ts +98 -0
- package/dist/src/select/Select.d.ts.map +1 -0
- package/dist/src/select/index.d.ts +5 -0
- package/dist/src/select/index.d.ts.map +1 -0
- package/dist/src/typography/Link.d.ts +86 -0
- package/dist/src/typography/Link.d.ts.map +1 -0
- package/dist/src/typography/Typography.d.ts +148 -0
- package/dist/src/typography/Typography.d.ts.map +1 -0
- package/dist/src/typography/index.d.ts +7 -0
- package/dist/src/typography/index.d.ts.map +1 -0
- package/dist/src/utils/capitalize.d.ts +3 -0
- package/dist/src/utils/capitalize.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/useBreakpoints-CXOalIdM.js +37 -0
- package/dist/useBreakpoints-nd-Blu7O.cjs +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { FC, FormHTMLAttributes, JSX, ReactNode, Ref, SubmitEvent } from 'react';
|
|
2
|
+
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
/**
|
|
4
|
+
* A form adornment can be either a FontAwesome `IconDefinition` or an image descriptor.
|
|
5
|
+
* - When an `IconDefinition` is passed, the component renders a FontAwesome icon.
|
|
6
|
+
* - When an object is passed it should provide a `src` (image `src`) and optional `alt` text.
|
|
7
|
+
*/
|
|
8
|
+
type FormAdornment = IconDefinition | {
|
|
9
|
+
src: string;
|
|
10
|
+
alt?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Theme color options accepted by the form for adornments and text.
|
|
14
|
+
*
|
|
15
|
+
* - 'accent' | 'primary' | 'secondary' | 'subtle' map to theme token names.
|
|
16
|
+
* - 'black' | 'white' | 'inverse' are additional semantic colors used by the UI.
|
|
17
|
+
*/
|
|
18
|
+
type FormColor = 'accent' | 'black' | 'inverse' | 'primary' | 'secondary' | 'subtle' | 'white';
|
|
19
|
+
/**
|
|
20
|
+
* Class names for the disclaimer sub-elements.
|
|
21
|
+
*/
|
|
22
|
+
interface DisclaimerClasses {
|
|
23
|
+
/** Classes applied to the disclaimer adornment (icon or image). */
|
|
24
|
+
adornment?: string;
|
|
25
|
+
/** Classes applied to the disclaimer container wrapper. */
|
|
26
|
+
container?: string;
|
|
27
|
+
/** Classes applied to the disclaimer text element. */
|
|
28
|
+
text?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Top-level class overrides for the `Form` component parts.
|
|
32
|
+
*
|
|
33
|
+
* Each property is optional and, when provided, will be merged with the
|
|
34
|
+
* component's internal class names.
|
|
35
|
+
*/
|
|
36
|
+
interface FormClasses {
|
|
37
|
+
/** Classes applied to the header/start adornment. */
|
|
38
|
+
adornment?: string;
|
|
39
|
+
/** Classes applied to the main body wrapper containing form children. */
|
|
40
|
+
body?: string;
|
|
41
|
+
/** Classes for the disclaimer sub-elements. */
|
|
42
|
+
disclaimer?: DisclaimerClasses;
|
|
43
|
+
/** Classes applied to the form header. */
|
|
44
|
+
header?: string;
|
|
45
|
+
/** Classes applied to the form footer. */
|
|
46
|
+
footer?: string;
|
|
47
|
+
/** Classes applied to the wrapper that contains the footer action buttons. */
|
|
48
|
+
footerButtonsContainer?: string;
|
|
49
|
+
/** Classes applied to the root `<form>` element. */
|
|
50
|
+
form?: string;
|
|
51
|
+
/** Classes applied to the submit button container. */
|
|
52
|
+
submitButton?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Descriptor for the optional disclaimer shown in the form footer.
|
|
56
|
+
*
|
|
57
|
+
* - `adornment`: optional `FormAdornment` to display beside the text.
|
|
58
|
+
* - `text`: the disclaimer string to render.
|
|
59
|
+
*/
|
|
60
|
+
type FormDisclaimer = {
|
|
61
|
+
adornment?: FormAdornment;
|
|
62
|
+
text?: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Props accepted by the `Form` component.
|
|
66
|
+
*
|
|
67
|
+
* Extends native `FormHTMLAttributes<HTMLFormElement>` (excluding
|
|
68
|
+
* `className`) and exposes additional configuration used by the component
|
|
69
|
+
* such as adornments, color tokens, class overrides, and an optional
|
|
70
|
+
* disclaimer rendered in the footer.
|
|
71
|
+
*/
|
|
72
|
+
interface FormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, 'className' | 'onChange' | 'onSubmit'> {
|
|
73
|
+
/** Accessible label for the form (maps to `aria-label`). */
|
|
74
|
+
'aria-label'?: string;
|
|
75
|
+
/** ID of an element that labels the form (maps to `aria-labelledby`). */
|
|
76
|
+
'aria-labelledby'?: string;
|
|
77
|
+
/** Native HTML `action` attribute (submission URL). */
|
|
78
|
+
action?: JSX.IntrinsicElements['form']['action'];
|
|
79
|
+
/** Color used for adornments and accents inside the form (maps to theme tokens). */
|
|
80
|
+
adornmentColor?: FormColor;
|
|
81
|
+
/** Child nodes to render inside the form (inputs, buttons, etc.). */
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
/** Additional CSS classes to apply to the form container. */
|
|
84
|
+
classes?: FormClasses;
|
|
85
|
+
/** Color used for text elements in the form and disclaimer (maps to theme tokens). */
|
|
86
|
+
color?: FormColor;
|
|
87
|
+
/** Optional disclaimer shown in the form footer; includes an optional adornment and text. */
|
|
88
|
+
disclaimer?: FormDisclaimer;
|
|
89
|
+
/** Encoding type for the form, e.g. `multipart/form-data` for file uploads. */
|
|
90
|
+
encType?: JSX.IntrinsicElements['form']['encType'];
|
|
91
|
+
/** Optional adornment to render at the end of the form header (icon or image). */
|
|
92
|
+
endAdornment?: FormAdornment;
|
|
93
|
+
/** Controlled error state for the form, derived from child field validation. */
|
|
94
|
+
error?: boolean;
|
|
95
|
+
/** `id` attribute for the form element. */
|
|
96
|
+
id?: string;
|
|
97
|
+
/** HTTP method used when submitting the form (`get` | `post`). */
|
|
98
|
+
method?: JSX.IntrinsicElements['form']['method'];
|
|
99
|
+
/** `name` attribute for the form. */
|
|
100
|
+
name?: string;
|
|
101
|
+
/** When true, disables the browser's native validation (`noValidate`). */
|
|
102
|
+
noValidate?: boolean;
|
|
103
|
+
/** Change event handler for the form element. */
|
|
104
|
+
onChange?: (values: FormValue[], error: boolean) => void;
|
|
105
|
+
/** Reset event handler for the form element. */
|
|
106
|
+
onReset?: (event: SubmitEvent<HTMLFormElement>) => void;
|
|
107
|
+
/** Submit event handler for the form element. */
|
|
108
|
+
onSubmit?: (event: SubmitEvent<HTMLFormElement>, values?: FormValue[], error?: boolean) => void;
|
|
109
|
+
/** Ref to access the underlying HTML form element. */
|
|
110
|
+
ref?: Ref<HTMLFormElement>;
|
|
111
|
+
/** Optional adornment to render at the start of the form header (icon or image). */
|
|
112
|
+
startAdornment?: FormAdornment;
|
|
113
|
+
/** Optional title displayed next to adornments in the form header. */
|
|
114
|
+
title?: string;
|
|
115
|
+
/** Initial values for form fields, used to populate internal state. */
|
|
116
|
+
value?: FormValue[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Internal representation of a form field's value used for mapping children
|
|
120
|
+
* into a predictable, typed state structure.
|
|
121
|
+
*
|
|
122
|
+
* - `key`: unique identifier generated for the field when mapping children.
|
|
123
|
+
* - `type`: discriminant for the field component type (`TextInput` or `TextArea`).
|
|
124
|
+
* - `value`: current string value for the field.
|
|
125
|
+
* - `error`: optional boolean flag indicating the field has a validation error.
|
|
126
|
+
*/
|
|
127
|
+
interface FormValue {
|
|
128
|
+
/** Whether the field currently has a validation error. */
|
|
129
|
+
error?: boolean;
|
|
130
|
+
/** Unique key generated when mapping children into form state. */
|
|
131
|
+
key?: string;
|
|
132
|
+
/** Component type of the field (`TextInput` or `TextArea`). */
|
|
133
|
+
type?: 'TextInput' | 'TextArea';
|
|
134
|
+
/** Current string value for the field. */
|
|
135
|
+
value?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Form component - a wrapper around the native HTML `<form>` element.
|
|
139
|
+
*
|
|
140
|
+
* Renders optional `startAdornment` and `endAdornment` (icons or images) with
|
|
141
|
+
* an optional `title`, then renders `children` which should contain form
|
|
142
|
+
* controls. All standard HTML form attributes are forwarded via `...rest`.
|
|
143
|
+
*
|
|
144
|
+
* @param {FormProps} props - Configuration props for the form component.
|
|
145
|
+
* @returns {JSX.Element} The rendered form element.
|
|
146
|
+
* @example
|
|
147
|
+
* ```tsx
|
|
148
|
+
* import { Form, Button } from '@/src';
|
|
149
|
+
* import { faPaperPlane } from '@fortawesome/free-solid-svg-icons';
|
|
150
|
+
*
|
|
151
|
+
* const MyForm = () => (
|
|
152
|
+
* <Form
|
|
153
|
+
* action="/submit"
|
|
154
|
+
* method="post"
|
|
155
|
+
* title="Contact Us"
|
|
156
|
+
* startAdornment={faPaperPlane}
|
|
157
|
+
* >
|
|
158
|
+
* <input type="text" name="name" placeholder="Your Name" required />
|
|
159
|
+
* <input type="email" name="email" placeholder="Your Email" required />
|
|
160
|
+
* <Button type="submit">Send</Button>
|
|
161
|
+
* </Form>
|
|
162
|
+
* );
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
declare const Form: FC<FormProps>;
|
|
166
|
+
export { Form };
|
|
167
|
+
export type { FormValue };
|
|
168
|
+
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/form/Form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,EAAE,EACF,kBAAkB,EAClB,GAAG,EAEH,SAAS,EACT,GAAG,EACH,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAexE;;;;GAIG;AACH,KAAK,aAAa,GAAG,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE;;;;;GAKG;AACH,KAAK,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/F;;GAEG;AACH,UAAU,iBAAiB;IACzB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,UAAU,WAAW;IACnB,qDAAqD;IAC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;;;;;;;;;;;;;;;;GA2BG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAsSvB,CAAC;AAIF,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import type { ChangeEvent, FC, FocusEvent, InputEvent, KeyboardEvent, MouseEvent, ReactNode, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
/**
|
|
4
|
+
* An adornment that can be rendered inside the `TextArea`.
|
|
5
|
+
* It can be:
|
|
6
|
+
* - custom React `children` (e.g. text or elements),
|
|
7
|
+
* - an image specified by `src`/`alt`,
|
|
8
|
+
* - or an icon (FontAwesome `IconDefinition`).
|
|
9
|
+
* Each variant may include an optional `onClick` handler.
|
|
10
|
+
*/
|
|
11
|
+
type TextAreaAdornment = {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
onClick?: (event: MouseEvent) => void;
|
|
14
|
+
} | {
|
|
15
|
+
alt?: string;
|
|
16
|
+
src: string;
|
|
17
|
+
onClick?: (event: MouseEvent) => void;
|
|
18
|
+
} | {
|
|
19
|
+
icon: IconDefinition;
|
|
20
|
+
onClick?: (event: MouseEvent) => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Colors available for adornments and label text.
|
|
24
|
+
*
|
|
25
|
+
* Allowed values:
|
|
26
|
+
* - 'accent': Accent color from the theme.
|
|
27
|
+
* - 'black': Standard black color.
|
|
28
|
+
* - 'inverse': Inverted color for dark backgrounds.
|
|
29
|
+
* - 'primary': Primary theme color.
|
|
30
|
+
* - 'secondary': Secondary theme color.
|
|
31
|
+
* - 'subtle': Subtle color for less emphasis.
|
|
32
|
+
* - 'white': White color for dark backgrounds.
|
|
33
|
+
* Note: 'inverse' and 'white' are intended for use on dark backgrounds, while 'accent', 'black', 'primary', 'secondary', and 'subtle' are for light backgrounds.
|
|
34
|
+
*/
|
|
35
|
+
type TextAreaAdornmentColor = 'accent' | 'black' | 'inverse' | 'primary' | 'secondary' | 'subtle' | 'white';
|
|
36
|
+
/**
|
|
37
|
+
* Text color variants for the textarea content.
|
|
38
|
+
*
|
|
39
|
+
* Allowed values:
|
|
40
|
+
* - 'black': Standard black text.
|
|
41
|
+
* - 'inverse': Inverted color for dark backgrounds.
|
|
42
|
+
* - 'primary': Primary theme color.
|
|
43
|
+
* - 'white': White text for dark backgrounds.
|
|
44
|
+
* Note: 'inverse' and 'white' are intended for use on dark backgrounds, while 'black' and 'primary' are for light backgrounds.
|
|
45
|
+
*/
|
|
46
|
+
type TextAreaColor = 'black' | 'inverse' | 'primary' | 'white';
|
|
47
|
+
/**
|
|
48
|
+
* Size presets for the textarea: 'sm', 'md', or 'lg'.
|
|
49
|
+
* These control the width and height of the textarea, unless `fullWidth` is true.
|
|
50
|
+
* - sm: Small size.
|
|
51
|
+
* - md: Medium size.
|
|
52
|
+
* - lg: Large size.
|
|
53
|
+
*/
|
|
54
|
+
type TextAreaSize = 'sm' | 'md' | 'lg';
|
|
55
|
+
/**
|
|
56
|
+
* Visual status states that affect border and label coloring.
|
|
57
|
+
* - 'error': Indicates an error state, typically with red styling.
|
|
58
|
+
* - 'success': Indicates a successful state, typically with green styling.
|
|
59
|
+
* - 'warning': Indicates a warning state, typically with yellow/orange styling.
|
|
60
|
+
*/
|
|
61
|
+
type TextAreaStatus = 'error' | 'success' | 'warning';
|
|
62
|
+
/**
|
|
63
|
+
* Optional CSS class overrides for `TextArea` sub-elements.
|
|
64
|
+
* Provide any of these to customize styling or to merge with the default classes.
|
|
65
|
+
* - `adornment`: class applied to each adornment element (icons/buttons).
|
|
66
|
+
* - `adornmentContainer`: class applied to the wrapper that contains adornments.
|
|
67
|
+
* - `container`: class applied to the root container of the component.
|
|
68
|
+
* - `label`: class applied to the label element.
|
|
69
|
+
* - `textarea`: class applied to the underlying `<textarea>` element.
|
|
70
|
+
*/
|
|
71
|
+
interface TextAreaClasses {
|
|
72
|
+
adornment?: string;
|
|
73
|
+
adornmentContainer?: string;
|
|
74
|
+
container?: string;
|
|
75
|
+
label?: string;
|
|
76
|
+
textarea?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Props for the `TextArea` component.
|
|
80
|
+
* Extends native `TextareaHTMLAttributes` except `cols`, `onError`, and `rows` to
|
|
81
|
+
* provide a controlled API tailored for this component.
|
|
82
|
+
* @extends {Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'cols' | 'onError' | 'rows'>}
|
|
83
|
+
*/
|
|
84
|
+
interface TextAreaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'cols' | 'onError' | 'rows'> {
|
|
85
|
+
/**
|
|
86
|
+
* ID of the element that describes this textarea (for `aria-describedby`).
|
|
87
|
+
*/
|
|
88
|
+
'aria-describedby'?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Accessible label for the textarea (for `aria-label`).
|
|
91
|
+
*/
|
|
92
|
+
'aria-label'?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the textarea is in an invalid state (for `aria-invalid`).
|
|
95
|
+
*/
|
|
96
|
+
'aria-invalid'?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Color used for adornments and label text.
|
|
99
|
+
*/
|
|
100
|
+
adornmentColor?: TextAreaAdornmentColor;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the textarea should receive focus automatically on mount.
|
|
103
|
+
*/
|
|
104
|
+
autoFocus?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Override or extend CSS classes for internal sub-elements.
|
|
107
|
+
*/
|
|
108
|
+
classes?: TextAreaClasses;
|
|
109
|
+
/**
|
|
110
|
+
* Show a clear button to reset the textarea value.
|
|
111
|
+
*/
|
|
112
|
+
clearable?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Text color variant for the textarea content.
|
|
115
|
+
*/
|
|
116
|
+
color?: TextAreaColor;
|
|
117
|
+
/**
|
|
118
|
+
* Number of columns (width) for the textarea.
|
|
119
|
+
*/
|
|
120
|
+
cols?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Initial uncontrolled value for the textarea.
|
|
123
|
+
*/
|
|
124
|
+
defaultValue?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Disable the textarea.
|
|
127
|
+
*/
|
|
128
|
+
disabled?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Adornments rendered at the end of the textarea (icons, images, or nodes).
|
|
131
|
+
*/
|
|
132
|
+
endAdornments?: TextAreaAdornment[];
|
|
133
|
+
/**
|
|
134
|
+
* Mark the textarea as showing an error state.
|
|
135
|
+
*/
|
|
136
|
+
error?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Make the textarea take full width of its container.
|
|
139
|
+
*/
|
|
140
|
+
fullWidth?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* The `id` attribute for the textarea.
|
|
143
|
+
*/
|
|
144
|
+
id?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Optional label text displayed above the textarea.
|
|
147
|
+
*/
|
|
148
|
+
label?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Maximum allowed length of the value.
|
|
151
|
+
*/
|
|
152
|
+
maxLength?: number;
|
|
153
|
+
/**
|
|
154
|
+
* Minimum required length of the value.
|
|
155
|
+
*/
|
|
156
|
+
minLength?: number;
|
|
157
|
+
/**
|
|
158
|
+
* The `name` attribute for form submission.
|
|
159
|
+
*/
|
|
160
|
+
name?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Change event handler for controlled usage.
|
|
163
|
+
*/
|
|
164
|
+
onChange?: (event: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Handler invoked when the clear button is clicked.
|
|
167
|
+
*/
|
|
168
|
+
onClear?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
169
|
+
/**
|
|
170
|
+
* Input event handler.
|
|
171
|
+
*/
|
|
172
|
+
onInput?: (event: InputEvent<HTMLTextAreaElement>) => void;
|
|
173
|
+
/**
|
|
174
|
+
* Blur event handler.
|
|
175
|
+
*/
|
|
176
|
+
onBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
177
|
+
/**
|
|
178
|
+
* Focus event handler.
|
|
179
|
+
*/
|
|
180
|
+
onFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
181
|
+
/**
|
|
182
|
+
* Key down event handler.
|
|
183
|
+
*/
|
|
184
|
+
onKeyDown?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
185
|
+
/**
|
|
186
|
+
* Key up event handler.
|
|
187
|
+
*/
|
|
188
|
+
onKeyUp?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
189
|
+
/**
|
|
190
|
+
* Mouse down handler on the textarea element.
|
|
191
|
+
*/
|
|
192
|
+
onMouseDown?: (event: MouseEvent<HTMLTextAreaElement>) => void;
|
|
193
|
+
/**
|
|
194
|
+
* Placeholder text shown when the textarea is empty.
|
|
195
|
+
*/
|
|
196
|
+
placeholder?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Render the textarea as read-only.
|
|
199
|
+
*/
|
|
200
|
+
readonly?: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Whether the field is required.
|
|
203
|
+
*/
|
|
204
|
+
required?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Number of visible rows for the textarea.
|
|
207
|
+
*/
|
|
208
|
+
rows?: number;
|
|
209
|
+
/**
|
|
210
|
+
* Size preset controlling width/height when not fullWidth.
|
|
211
|
+
*/
|
|
212
|
+
size?: TextAreaSize;
|
|
213
|
+
/**
|
|
214
|
+
* Whether spell checking is enabled.
|
|
215
|
+
*/
|
|
216
|
+
spellCheck?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Adornments rendered at the start of the textarea.
|
|
219
|
+
*/
|
|
220
|
+
startAdornments?: TextAreaAdornment[];
|
|
221
|
+
/**
|
|
222
|
+
* Visual status (error, success, warning) to style the control.
|
|
223
|
+
*/
|
|
224
|
+
status?: TextAreaStatus;
|
|
225
|
+
/**
|
|
226
|
+
* Controlled value for the textarea.
|
|
227
|
+
*/
|
|
228
|
+
value?: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* `TextArea` — a controlled/uncontrolled textarea with optional adornments.
|
|
232
|
+
*
|
|
233
|
+
* Features:
|
|
234
|
+
* - Supports `value` (controlled) or `defaultValue` (uncontrolled) handled via `useControlled`.
|
|
235
|
+
* - `startAdornments` and `endAdornments` accept icons, images, or custom children.
|
|
236
|
+
* - `clearable` renders a clear button that resets the value or calls `onClear`.
|
|
237
|
+
* - Accepts `classes` to override internal element classNames and `adornmentColor`, `color`, `size`, `status` to adjust styling.
|
|
238
|
+
* - Preserves native textarea attributes (placeholder, rows, spellCheck, keyboard handlers, etc.).
|
|
239
|
+
*
|
|
240
|
+
* Accessibility:
|
|
241
|
+
* - Supports `aria-label`, `aria-describedby`, and `aria-invalid` props.
|
|
242
|
+
*
|
|
243
|
+
* @param props - `TextAreaProps` describing appearance, behavior, and event handlers.
|
|
244
|
+
* @returns A JSX element rendering the styled textarea with optional adornments.
|
|
245
|
+
* @example
|
|
246
|
+
* ```tsx
|
|
247
|
+
* import { TextArea } from '@/src';
|
|
248
|
+
*
|
|
249
|
+
* const MyTextArea = () => (
|
|
250
|
+
* <TextArea
|
|
251
|
+
* label="Your Message"
|
|
252
|
+
* placeholder="Type your message here..."
|
|
253
|
+
* adornmentColor="primary"
|
|
254
|
+
* color="primary"
|
|
255
|
+
* size="md"
|
|
256
|
+
* clearable
|
|
257
|
+
* startAdornments={[{ icon: faCoffee, onClick: () => alert('Start adornment clicked!') }]}
|
|
258
|
+
* endAdornments={[{ children: 'End', onClick: () => alert('End adornment clicked!') }]}
|
|
259
|
+
* onChange={(e) => console.log('TextArea value:', e.target.value)}
|
|
260
|
+
* />
|
|
261
|
+
* );
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
declare const TextArea: FC<TextAreaProps>;
|
|
265
|
+
export { TextArea };
|
|
266
|
+
//# sourceMappingURL=TextArea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/form/TextArea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,EAAE,EACF,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,sBAAsB,EACvB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAOxE;;;;;;;GAOG;AACH,KAAK,iBAAiB,GAClB;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CAAE,GAC9D;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CAAE,CAAC;AAEpE;;;;;;;;;;;;GAYG;AACH,KAAK,sBAAsB,GACvB,QAAQ,GACR,OAAO,GACP,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,GACR,OAAO,CAAC;AAEZ;;;;;;;;;GASG;AACH,KAAK,aAAa,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/D;;;;;;GAMG;AACH,KAAK,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvC;;;;;GAKG;AACH,KAAK,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtD;;;;;;;;GAQG;AACH,UAAU,eAAe;IACvB,SAAS,CAAC,EAAE,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAoN/B,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { ChangeEvent, FC, FocusEvent, InputEvent, InputHTMLAttributes, JSX, KeyboardEvent, MouseEvent, Ref } from 'react';
|
|
2
|
+
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
/**
|
|
4
|
+
* Adornment for `TextInput` — either a FontAwesome `IconDefinition`
|
|
5
|
+
* or an image object `{ src, alt? }`.
|
|
6
|
+
*/
|
|
7
|
+
type TextInputAdornment = IconDefinition | {
|
|
8
|
+
src: string;
|
|
9
|
+
alt?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Colors available for adornments and small text styles.
|
|
13
|
+
* Allowed values:
|
|
14
|
+
* - 'primary'
|
|
15
|
+
* - 'secondary'
|
|
16
|
+
* - 'accent'
|
|
17
|
+
* - 'subtle'
|
|
18
|
+
* - 'inverse'
|
|
19
|
+
* - 'black'
|
|
20
|
+
* - 'white'
|
|
21
|
+
*/
|
|
22
|
+
type TextInputAdornmentColor = 'primary' | 'secondary' | 'accent' | 'subtle' | 'inverse' | 'black' | 'white';
|
|
23
|
+
/**
|
|
24
|
+
* Optional class overrides for `TextInput` sub-elements.
|
|
25
|
+
* Use these to merge or replace default styles on internal parts.
|
|
26
|
+
*/
|
|
27
|
+
interface TextInputClasses {
|
|
28
|
+
/** Root container for the component. */
|
|
29
|
+
container?: string;
|
|
30
|
+
/** Class applied to the clear button/icon. */
|
|
31
|
+
clearButton?: string;
|
|
32
|
+
/** Class applied to the end adornment element. */
|
|
33
|
+
endAdornment?: string;
|
|
34
|
+
/** Class applied to the helper text element. */
|
|
35
|
+
helper?: string;
|
|
36
|
+
/** Class applied to the native input element. */
|
|
37
|
+
input?: string;
|
|
38
|
+
/** Class applied to the input container (border/wrapper). */
|
|
39
|
+
inputContainer?: string;
|
|
40
|
+
/** Class applied to the label element. */
|
|
41
|
+
label?: string;
|
|
42
|
+
/** Class applied to the start adornment element. */
|
|
43
|
+
startAdornment?: string;
|
|
44
|
+
/** Class applied to the toggle button (e.g., show password). */
|
|
45
|
+
toggleButton?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Text color variants for the input element.
|
|
49
|
+
* Allowed values:
|
|
50
|
+
* - 'black': Standard black text
|
|
51
|
+
* - 'inverse': Inverted color for dark backgrounds
|
|
52
|
+
* - 'primary': Primary theme color
|
|
53
|
+
* - 'white': White text for dark backgrounds
|
|
54
|
+
*/
|
|
55
|
+
type TextInputColor = 'black' | 'inverse' | 'primary' | 'white';
|
|
56
|
+
/**
|
|
57
|
+
* Size presets for the input.
|
|
58
|
+
* Allowed values:
|
|
59
|
+
* - 'sm': Small size with reduced padding and font size
|
|
60
|
+
* - 'md': Medium size (default) with balanced padding and font size
|
|
61
|
+
* - 'lg': Large size with increased padding and font size for better readability
|
|
62
|
+
*/
|
|
63
|
+
type TextInputSize = 'sm' | 'md' | 'lg';
|
|
64
|
+
/**
|
|
65
|
+
* Visual status variants used for border/helper coloring.
|
|
66
|
+
* Allowed values: 'success', 'warning', 'error'
|
|
67
|
+
*/
|
|
68
|
+
type TextInputStatus = 'success' | 'warning' | 'error';
|
|
69
|
+
/**
|
|
70
|
+
* Supported input `type` values for this component.
|
|
71
|
+
* This excludes non-textual types; the component supports common textual
|
|
72
|
+
* types such as 'text', 'email', 'tel', 'url', 'number', 'password', 'search', etc.
|
|
73
|
+
*/
|
|
74
|
+
type TextInputType = Exclude<JSX.IntrinsicElements['input']['type'], 'button' | 'checkbox' | 'date' | 'datetime-local' | 'month' | 'radio' | 'range' | 'time' | 'week'>;
|
|
75
|
+
/**
|
|
76
|
+
* Props for `TextInput`.
|
|
77
|
+
* Extends native input attributes (omitting component-controlled `size`, `pattern`, `onError`).
|
|
78
|
+
*/
|
|
79
|
+
interface TextInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'pattern' | 'onError'> {
|
|
80
|
+
/** ID of the element that describes this input (helper or error message). */
|
|
81
|
+
'aria-describedby'?: string;
|
|
82
|
+
/** Accessible label for the input when a visible label is not present. */
|
|
83
|
+
'aria-label'?: string;
|
|
84
|
+
/** Indicates the input has a validation error (true/false). */
|
|
85
|
+
'aria-invalid'?: boolean;
|
|
86
|
+
/** Color theme to use for adornments and small text. */
|
|
87
|
+
adornmentColor?: TextInputAdornmentColor;
|
|
88
|
+
/** Native `autocomplete` value (e.g., 'on', 'off', 'email'). */
|
|
89
|
+
autoComplete?: string;
|
|
90
|
+
/** Autofocus the input on mount. */
|
|
91
|
+
autoFocus?: boolean;
|
|
92
|
+
/** Class overrides for component sub-elements. */
|
|
93
|
+
classes?: TextInputClasses;
|
|
94
|
+
/** Show a clear button inside the input. */
|
|
95
|
+
clearable?: boolean;
|
|
96
|
+
/** Text color variant for the input. */
|
|
97
|
+
color?: TextInputColor;
|
|
98
|
+
/** Default (uncontrolled) value for the input. */
|
|
99
|
+
defaultValue?: string;
|
|
100
|
+
/** Disable the input. */
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
/** Adornment to render at the end of the input. */
|
|
103
|
+
endAdornment?: TextInputAdornment;
|
|
104
|
+
/** External error state (controlled). */
|
|
105
|
+
error?: boolean;
|
|
106
|
+
/** When true, input expands to fill available width. */
|
|
107
|
+
fullWidth?: boolean;
|
|
108
|
+
/** Helper or error text displayed below the input. */
|
|
109
|
+
helperText?: string;
|
|
110
|
+
/** Element id attribute. */
|
|
111
|
+
id?: string;
|
|
112
|
+
/** Native `inputmode` value hinting the type of virtual keyboard. */
|
|
113
|
+
inputMode?: JSX.IntrinsicElements['input']['inputMode'];
|
|
114
|
+
/** Visible label text for the input. */
|
|
115
|
+
label?: string;
|
|
116
|
+
/** Maximum allowed length of the input value. */
|
|
117
|
+
maxLength?: number;
|
|
118
|
+
/** Minimum allowed length of the input value. */
|
|
119
|
+
minLength?: number;
|
|
120
|
+
/** Name attribute for form submission. */
|
|
121
|
+
name?: string;
|
|
122
|
+
/** Validation pattern (RegExp) applied client-side. */
|
|
123
|
+
pattern?: RegExp;
|
|
124
|
+
/** Placeholder text shown when the input is empty. */
|
|
125
|
+
placeholder?: string;
|
|
126
|
+
/** Make the input read-only. */
|
|
127
|
+
readOnly?: boolean;
|
|
128
|
+
/** Forwarded ref to the native input element. */
|
|
129
|
+
ref?: Ref<HTMLInputElement>;
|
|
130
|
+
/** Whether the input is required. */
|
|
131
|
+
required?: boolean;
|
|
132
|
+
/** Show a toggle for password visibility when `type='password'`. */
|
|
133
|
+
showPasswordToggle?: boolean;
|
|
134
|
+
/** Size variant of the input. */
|
|
135
|
+
size?: TextInputSize;
|
|
136
|
+
/** Visual status for styling (affects border/helper color). */
|
|
137
|
+
status?: TextInputStatus;
|
|
138
|
+
/** Enable browser spell checking. */
|
|
139
|
+
spellCheck?: boolean;
|
|
140
|
+
/** Adornment to render at the start of the input. */
|
|
141
|
+
startAdornment?: TextInputAdornment;
|
|
142
|
+
/** Input `type` (textual types only). */
|
|
143
|
+
type?: TextInputType;
|
|
144
|
+
/** Change event handler. */
|
|
145
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
146
|
+
/** Clear button click handler. Receives the event and current error state. */
|
|
147
|
+
onClear?: (event: MouseEvent<HTMLButtonElement>, error: boolean) => void;
|
|
148
|
+
/** Callback invoked when the error state changes. */
|
|
149
|
+
onError?: (error: boolean) => void;
|
|
150
|
+
/** Low-level input event handler. */
|
|
151
|
+
onInput?: (event: InputEvent<HTMLInputElement>) => void;
|
|
152
|
+
/** Blur event handler. */
|
|
153
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
154
|
+
/** Focus event handler. */
|
|
155
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
156
|
+
/** Key down handler. */
|
|
157
|
+
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
158
|
+
/** Key up handler. */
|
|
159
|
+
onKeyUp?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
160
|
+
/** Key down handler for the input element. */
|
|
161
|
+
onMouseDown?: (event: MouseEvent<HTMLInputElement>) => void;
|
|
162
|
+
/** Controlled value for the input. */
|
|
163
|
+
value?: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* `TextInput` — a fully featured, accessible text input component.
|
|
167
|
+
*
|
|
168
|
+
* Features:
|
|
169
|
+
* - Optional `label`, `helperText`, and required marker
|
|
170
|
+
* - Start / end adornments (icons or images)
|
|
171
|
+
* - Optional clear button (`clearable`) and password visibility toggle
|
|
172
|
+
* - Controlled or uncontrolled usage via `value` / `defaultValue` and `useControlled`
|
|
173
|
+
* - Visual `status` variants (`success` | `warning` | `error`) and per-prop `adornmentColor`
|
|
174
|
+
*
|
|
175
|
+
* Accessibility:
|
|
176
|
+
* - Supports `aria-describedby`, `aria-label`, and `aria-invalid` props
|
|
177
|
+
* - Uses `type='password'` toggle with accessible labels on toggle button
|
|
178
|
+
* - Leaves focus styling to `:focus-visible` (keyboard focus) and exposes classes via `classes` prop
|
|
179
|
+
*
|
|
180
|
+
* @param props - Props for the `TextInput` component, extending native input attributes with additional features.
|
|
181
|
+
* @returns JSX element representing the `TextInput` component.
|
|
182
|
+
* @example
|
|
183
|
+
* ```tsx
|
|
184
|
+
* import { TextInput } from '@/src';
|
|
185
|
+
*
|
|
186
|
+
* const MyTextInput = () => (
|
|
187
|
+
* <TextInput
|
|
188
|
+
* label="Username"
|
|
189
|
+
* placeholder="Enter your username"
|
|
190
|
+
* helperText="Must be 4-16 characters"
|
|
191
|
+
* required
|
|
192
|
+
* pattern={/^[a-zA-Z0-9]{4,16}$/}
|
|
193
|
+
* onError={(error) => console.log('Validation error:', error)}
|
|
194
|
+
* />
|
|
195
|
+
* );
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare const TextInput: FC<TextInputProps>;
|
|
199
|
+
export { TextInput };
|
|
200
|
+
//# sourceMappingURL=TextInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../src/form/TextInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,EAAE,EACF,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,GAAG,EACH,aAAa,EACb,UAAU,EACV,GAAG,EACJ,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAMxE;;;GAGG;AACH,KAAK,kBAAkB,GAAG,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;;GAUG;AACH,KAAK,uBAAuB,GACxB,SAAS,GACT,WAAW,GACX,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ;;;GAGG;AACH,UAAU,gBAAgB;IACxB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,KAAK,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,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