@spark-ui/components 10.0.2 → 10.0.4

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 (44) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/checkbox/index.js +117 -478
  3. package/dist/checkbox/index.js.map +1 -1
  4. package/dist/checkbox/index.mjs +3 -4
  5. package/dist/checkbox/index.mjs.map +1 -1
  6. package/dist/{chunk-JC6KKYUQ.mjs → chunk-7BTJUYP3.mjs} +6 -5
  7. package/dist/{chunk-JC6KKYUQ.mjs.map → chunk-7BTJUYP3.mjs.map} +1 -1
  8. package/dist/combobox/index.js +301 -710
  9. package/dist/combobox/index.js.map +1 -1
  10. package/dist/combobox/index.mjs +3 -5
  11. package/dist/combobox/index.mjs.map +1 -1
  12. package/dist/dropdown/index.js +252 -662
  13. package/dist/dropdown/index.js.map +1 -1
  14. package/dist/dropdown/index.mjs +1 -4
  15. package/dist/dropdown/index.mjs.map +1 -1
  16. package/dist/form-field/index.mjs +373 -7
  17. package/dist/form-field/index.mjs.map +1 -1
  18. package/dist/input/index.js +47 -454
  19. package/dist/input/index.js.map +1 -1
  20. package/dist/input/index.mjs +1 -3
  21. package/dist/radio-group/index.js +47 -553
  22. package/dist/radio-group/index.js.map +1 -1
  23. package/dist/radio-group/index.mjs +3 -9
  24. package/dist/radio-group/index.mjs.map +1 -1
  25. package/dist/select/index.js +159 -569
  26. package/dist/select/index.js.map +1 -1
  27. package/dist/select/index.mjs +1 -4
  28. package/dist/select/index.mjs.map +1 -1
  29. package/dist/stepper/index.js +110 -516
  30. package/dist/stepper/index.js.map +1 -1
  31. package/dist/stepper/index.mjs +2 -5
  32. package/dist/stepper/index.mjs.map +1 -1
  33. package/dist/switch/index.js +96 -545
  34. package/dist/switch/index.js.map +1 -1
  35. package/dist/switch/index.mjs +3 -6
  36. package/dist/switch/index.mjs.map +1 -1
  37. package/dist/textarea/index.js +58 -465
  38. package/dist/textarea/index.js.map +1 -1
  39. package/dist/textarea/index.mjs +1 -3
  40. package/dist/textarea/index.mjs.map +1 -1
  41. package/package.json +20 -10
  42. package/tsup.config.ts +2 -1
  43. package/dist/chunk-7PMPYEHJ.mjs +0 -379
  44. package/dist/chunk-7PMPYEHJ.mjs.map +0 -1
@@ -1,379 +0,0 @@
1
- import {
2
- Label
3
- } from "./chunk-HLXYG643.mjs";
4
- import {
5
- Icon
6
- } from "./chunk-AESXFMCC.mjs";
7
- import {
8
- Slot,
9
- Slottable
10
- } from "./chunk-4F5DOL57.mjs";
11
-
12
- // src/form-field/FormField.tsx
13
- import { cx } from "class-variance-authority";
14
- import { useId as useId2 } from "react";
15
-
16
- // src/form-field/FormFieldContext.tsx
17
- import { createContext, useContext } from "react";
18
- var FormFieldContext = createContext(null);
19
- var ID_PREFIX = ":form-field";
20
- var useFormField = () => {
21
- const context = useContext(FormFieldContext);
22
- if (!context) {
23
- throw Error("useFormField must be used within a FormField provider");
24
- }
25
- return context;
26
- };
27
-
28
- // src/form-field/FormFieldProvider.tsx
29
- import { useCallback, useId, useMemo, useState } from "react";
30
- import { jsx } from "react/jsx-runtime";
31
- var FormFieldProvider = ({
32
- id,
33
- name,
34
- disabled = false,
35
- readOnly = false,
36
- state,
37
- isRequired,
38
- children
39
- }) => {
40
- const labelId = `${ID_PREFIX}-label-${useId()}`;
41
- const [messageIds, setMessageIds] = useState([]);
42
- const description = messageIds.length > 0 ? messageIds.join(" ") : void 0;
43
- const handleMessageIdAdd = useCallback((msgId) => {
44
- setMessageIds((ids) => [...ids, msgId]);
45
- }, []);
46
- const handleMessageIdRemove = useCallback((msgId) => {
47
- setMessageIds((ids) => ids.filter((current) => current !== msgId));
48
- }, []);
49
- const value = useMemo(() => {
50
- const isInvalid = state === "error";
51
- return {
52
- id,
53
- labelId,
54
- name,
55
- disabled,
56
- readOnly,
57
- state,
58
- isRequired,
59
- isInvalid,
60
- description,
61
- onMessageIdAdd: handleMessageIdAdd,
62
- onMessageIdRemove: handleMessageIdRemove
63
- };
64
- }, [
65
- id,
66
- labelId,
67
- name,
68
- disabled,
69
- readOnly,
70
- description,
71
- state,
72
- isRequired,
73
- handleMessageIdAdd,
74
- handleMessageIdRemove
75
- ]);
76
- return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value, children });
77
- };
78
- FormFieldProvider.displayName = "FormFieldProvider";
79
-
80
- // src/form-field/FormField.tsx
81
- import { jsx as jsx2 } from "react/jsx-runtime";
82
- var FormField = ({
83
- className,
84
- disabled = false,
85
- readOnly = false,
86
- name,
87
- state,
88
- isRequired = false,
89
- asChild = false,
90
- ref,
91
- ...others
92
- }) => {
93
- const id = `${ID_PREFIX}-${useId2()}`;
94
- const Component = asChild ? Slot : "div";
95
- return /* @__PURE__ */ jsx2(
96
- FormFieldProvider,
97
- {
98
- id,
99
- name,
100
- isRequired,
101
- disabled,
102
- readOnly,
103
- state,
104
- children: /* @__PURE__ */ jsx2(
105
- Component,
106
- {
107
- ref,
108
- "data-spark-component": "form-field",
109
- className: cx(className, "gap-sm flex flex-col"),
110
- ...others
111
- }
112
- )
113
- }
114
- );
115
- };
116
- FormField.displayName = "FormField";
117
-
118
- // src/form-field/FormFieldStateMessage.tsx
119
- import { AlertOutline } from "@spark-ui/icons/AlertOutline";
120
- import { Check } from "@spark-ui/icons/Check";
121
- import { WarningOutline } from "@spark-ui/icons/WarningOutline";
122
- import { cx as cx3 } from "class-variance-authority";
123
-
124
- // src/form-field/FormFieldMessage.tsx
125
- import { cx as cx2 } from "class-variance-authority";
126
- import { useEffect, useId as useId3 } from "react";
127
- import { jsx as jsx3 } from "react/jsx-runtime";
128
- var FormFieldMessage = ({
129
- id: idProp,
130
- className,
131
- ref,
132
- ...others
133
- }) => {
134
- const { onMessageIdAdd, onMessageIdRemove } = useFormField();
135
- const currentId = `${ID_PREFIX}-message-${useId3()}`;
136
- const id = idProp || currentId;
137
- useEffect(() => {
138
- onMessageIdAdd(id);
139
- return () => {
140
- onMessageIdRemove(id);
141
- };
142
- }, [id, onMessageIdAdd, onMessageIdRemove]);
143
- return /* @__PURE__ */ jsx3(
144
- "span",
145
- {
146
- ref,
147
- id,
148
- "data-spark-component": "form-field-message",
149
- className: cx2(className, "text-caption"),
150
- ...others
151
- }
152
- );
153
- };
154
- FormFieldMessage.displayName = "FormField.Message";
155
-
156
- // src/form-field/FormFieldStateMessage.tsx
157
- import { jsx as jsx4, jsxs } from "react/jsx-runtime";
158
- var FormFieldStateMessage = ({
159
- className,
160
- state,
161
- children,
162
- ref,
163
- ...others
164
- }) => {
165
- const field = useFormField();
166
- if (field.state !== state) {
167
- return null;
168
- }
169
- return /* @__PURE__ */ jsxs(
170
- FormFieldMessage,
171
- {
172
- ref,
173
- "data-spark-component": "form-field-state-message",
174
- "aria-live": "polite",
175
- className: cx3(
176
- "gap-sm flex items-center",
177
- state === "error" ? "text-error" : "text-on-surface/dim-1",
178
- className
179
- ),
180
- ...others,
181
- children: [
182
- state === "alert" && /* @__PURE__ */ jsx4(Icon, { size: "sm", children: /* @__PURE__ */ jsx4(WarningOutline, {}) }),
183
- state === "error" && /* @__PURE__ */ jsx4(Icon, { size: "sm", intent: "error", children: /* @__PURE__ */ jsx4(AlertOutline, {}) }),
184
- state === "success" && /* @__PURE__ */ jsx4(Icon, { size: "sm", children: /* @__PURE__ */ jsx4(Check, {}) }),
185
- children
186
- ]
187
- }
188
- );
189
- };
190
- FormFieldStateMessage.displayName = "FormField.StateMessage";
191
-
192
- // src/form-field/FormFieldAlertMessage.tsx
193
- import { jsx as jsx5 } from "react/jsx-runtime";
194
- var FormFieldAlertMessage = ({ ref, ...props }) => {
195
- return /* @__PURE__ */ jsx5(
196
- FormFieldStateMessage,
197
- {
198
- ref,
199
- "data-spark-component": "form-field-alert-message",
200
- state: "alert",
201
- ...props
202
- }
203
- );
204
- };
205
- FormFieldAlertMessage.displayName = "FormField.AlertMessage";
206
-
207
- // src/form-field/FormFieldCharactersCount.tsx
208
- import { cx as cx4 } from "class-variance-authority";
209
- import { jsx as jsx6 } from "react/jsx-runtime";
210
- var FormFieldCharactersCount = ({
211
- className,
212
- value = "",
213
- maxLength,
214
- ref,
215
- ...others
216
- }) => {
217
- const displayValue = `${value.length}/${maxLength}`;
218
- return /* @__PURE__ */ jsx6(
219
- "span",
220
- {
221
- ref,
222
- "data-spark-component": "form-field-characters-count",
223
- className: cx4(className, "text-caption", "text-neutral"),
224
- ...others,
225
- children: displayValue
226
- }
227
- );
228
- };
229
- FormFieldCharactersCount.displayName = "FormField.CharactersCount";
230
-
231
- // src/form-field/FormFieldControl.tsx
232
- import { useContext as useContext2 } from "react";
233
- import { Fragment, jsx as jsx7 } from "react/jsx-runtime";
234
- var useFormFieldControl = () => {
235
- const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } = useContext2(FormFieldContext) || {};
236
- return {
237
- id,
238
- name,
239
- description,
240
- disabled,
241
- readOnly,
242
- state,
243
- labelId,
244
- isInvalid,
245
- isRequired
246
- };
247
- };
248
- var FormFieldControl = ({ children }) => {
249
- const props = useFormFieldControl();
250
- return /* @__PURE__ */ jsx7(Fragment, { children: children(props) });
251
- };
252
- FormFieldControl.displayName = "FormField.Control";
253
-
254
- // src/form-field/FormFieldErrorMessage.tsx
255
- import { jsx as jsx8 } from "react/jsx-runtime";
256
- var FormFieldErrorMessage = ({ ref, ...props }) => {
257
- return /* @__PURE__ */ jsx8(
258
- FormFieldStateMessage,
259
- {
260
- ref,
261
- "data-spark-component": "form-field-error-message",
262
- state: "error",
263
- ...props
264
- }
265
- );
266
- };
267
- FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
268
-
269
- // src/form-field/FormFieldHelperMessage.tsx
270
- import { cx as cx5 } from "class-variance-authority";
271
- import { jsx as jsx9 } from "react/jsx-runtime";
272
- var FormFieldHelperMessage = ({
273
- className,
274
- ref,
275
- ...others
276
- }) => {
277
- return /* @__PURE__ */ jsx9(
278
- FormFieldMessage,
279
- {
280
- ref,
281
- "data-spark-component": "form-field-helper-message",
282
- className: cx5("text-on-surface/dim-1", className),
283
- ...others
284
- }
285
- );
286
- };
287
- FormFieldHelperMessage.displayName = "FormField.HelperMessage";
288
-
289
- // src/form-field/FormFieldLabel.tsx
290
- import { cx as cx7 } from "class-variance-authority";
291
-
292
- // src/form-field/FormFieldRequiredIndicator.tsx
293
- import { cx as cx6 } from "class-variance-authority";
294
- import { jsx as jsx10 } from "react/jsx-runtime";
295
- var FormFieldRequiredIndicator = ({
296
- className,
297
- ref,
298
- ...props
299
- }) => {
300
- return /* @__PURE__ */ jsx10(Label.RequiredIndicator, { ref, className: cx6("ml-sm", className), ...props });
301
- };
302
- FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
303
-
304
- // src/form-field/FormFieldLabel.tsx
305
- import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs2 } from "react/jsx-runtime";
306
- var FormFieldLabel = ({
307
- htmlFor: htmlForProp,
308
- className,
309
- children,
310
- requiredIndicator = /* @__PURE__ */ jsx11(FormFieldRequiredIndicator, {}),
311
- asChild,
312
- ref,
313
- ...others
314
- }) => {
315
- const control = useFormField();
316
- const { disabled, labelId, isRequired } = control;
317
- const htmlFor = asChild ? void 0 : htmlForProp || control.id;
318
- return /* @__PURE__ */ jsx11(
319
- Label,
320
- {
321
- ref,
322
- id: labelId,
323
- "data-spark-component": "form-field-label",
324
- htmlFor,
325
- className: cx7(className, disabled ? "text-on-surface/dim-3 pointer-events-none" : void 0),
326
- asChild,
327
- ...others,
328
- children: /* @__PURE__ */ jsxs2(Fragment2, { children: [
329
- /* @__PURE__ */ jsx11(Slottable, { children }),
330
- isRequired && requiredIndicator
331
- ] })
332
- }
333
- );
334
- };
335
- FormFieldLabel.displayName = "FormField.Label";
336
-
337
- // src/form-field/FormFieldSuccessMessage.tsx
338
- import { jsx as jsx12 } from "react/jsx-runtime";
339
- var FormFieldSuccessMessage = ({ ref, ...props }) => {
340
- return /* @__PURE__ */ jsx12(
341
- FormFieldStateMessage,
342
- {
343
- ref,
344
- "data-spark-component": "form-field-success-message",
345
- state: "success",
346
- ...props
347
- }
348
- );
349
- };
350
- FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
351
-
352
- // src/form-field/index.ts
353
- var FormField2 = Object.assign(FormField, {
354
- Label: FormFieldLabel,
355
- Control: FormFieldControl,
356
- StateMessage: FormFieldStateMessage,
357
- SuccessMessage: FormFieldSuccessMessage,
358
- AlertMessage: FormFieldAlertMessage,
359
- ErrorMessage: FormFieldErrorMessage,
360
- HelperMessage: FormFieldHelperMessage,
361
- RequiredIndicator: FormFieldRequiredIndicator,
362
- CharactersCount: FormFieldCharactersCount
363
- });
364
- FormField2.displayName = "FormField";
365
- FormFieldLabel.displayName = "FormField.Label";
366
- FormFieldControl.displayName = "FormField.Control";
367
- FormFieldStateMessage.displayName = "FormField.StateMessage";
368
- FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
369
- FormFieldAlertMessage.displayName = "FormField.AlertMessage";
370
- FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
371
- FormFieldHelperMessage.displayName = "FormField.HelperMessage";
372
- FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
373
- FormFieldCharactersCount.displayName = "FormField.CharactersCount";
374
-
375
- export {
376
- useFormFieldControl,
377
- FormField2 as FormField
378
- };
379
- //# sourceMappingURL=chunk-7PMPYEHJ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/form-field/FormField.tsx","../src/form-field/FormFieldContext.tsx","../src/form-field/FormFieldProvider.tsx","../src/form-field/FormFieldStateMessage.tsx","../src/form-field/FormFieldMessage.tsx","../src/form-field/FormFieldAlertMessage.tsx","../src/form-field/FormFieldCharactersCount.tsx","../src/form-field/FormFieldControl.tsx","../src/form-field/FormFieldErrorMessage.tsx","../src/form-field/FormFieldHelperMessage.tsx","../src/form-field/FormFieldLabel.tsx","../src/form-field/FormFieldRequiredIndicator.tsx","../src/form-field/FormFieldSuccessMessage.tsx","../src/form-field/index.ts"],"sourcesContent":["import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useId } from 'react'\n\nimport { Slot } from '../slot'\nimport { FormFieldContextState, ID_PREFIX } from './FormFieldContext'\nimport { FormFieldProvider } from './FormFieldProvider'\n\nexport interface FormFieldProps\n extends ComponentPropsWithoutRef<'div'>,\n Pick<FormFieldContextState, 'name' | 'state' | 'isRequired'> {\n /**\n * Change the component to the HTML tag or custom component of the only child. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.\n */\n asChild?: boolean\n /**\n * When `true`, prevents the user from interacting.\n */\n disabled?: boolean\n /**\n * Sets the component as interactive or not.\n */\n readOnly?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const FormField = ({\n className,\n disabled = false,\n readOnly = false,\n name,\n state,\n isRequired = false,\n asChild = false,\n ref,\n ...others\n}: FormFieldProps) => {\n const id = `${ID_PREFIX}-${useId()}`\n const Component = asChild ? Slot : 'div'\n\n return (\n <FormFieldProvider\n id={id}\n name={name}\n isRequired={isRequired}\n disabled={disabled}\n readOnly={readOnly}\n state={state}\n >\n <Component\n ref={ref}\n data-spark-component=\"form-field\"\n className={cx(className, 'gap-sm flex flex-col')}\n {...others}\n />\n </FormFieldProvider>\n )\n}\n\nFormField.displayName = 'FormField'\n","import { createContext, useContext } from 'react'\n\nexport interface FormFieldContextState {\n /**\n * Generated id for the input component.\n */\n id: string\n /**\n * Generated id for the label component.\n */\n labelId?: string\n /**\n * The name of the input. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * A set of ids separated by a space used to describe the input component given by a set of messages.\n */\n description?: string\n /**\n * Disables the field and its associated input\n */\n disabled?: boolean\n /**\n * Marks the field and its associated input as read only\n */\n readOnly?: boolean\n /**\n * The validation state of the input.\n */\n state?: 'error' | 'success' | 'alert'\n /**\n * If true, the form field will be invalid.\n */\n isInvalid?: boolean\n /**\n * If true, the form field will be required.\n */\n isRequired?: boolean\n /**\n * Callback used to store a descriptive message.\n */\n onMessageIdAdd: (id: string) => void\n /**\n * Callback used to remove a descriptive message.\n */\n onMessageIdRemove: (id: string) => void\n}\n\nexport const FormFieldContext = createContext<FormFieldContextState | null>(null)\n\nexport const ID_PREFIX = ':form-field'\n\nexport const useFormField = () => {\n const context = useContext(FormFieldContext)\n\n if (!context) {\n throw Error('useFormField must be used within a FormField provider')\n }\n\n return context\n}\n","import { ReactNode, useCallback, useId, useMemo, useState } from 'react'\n\nimport { FormFieldContext, FormFieldContextState, ID_PREFIX } from './FormFieldContext'\n\nexport interface FormFieldProviderProps\n extends Pick<\n FormFieldContextState,\n 'id' | 'name' | 'disabled' | 'readOnly' | 'state' | 'isRequired'\n > {\n children: ReactNode\n}\n\nexport const FormFieldProvider = ({\n id,\n name,\n disabled = false,\n readOnly = false,\n state,\n isRequired,\n children,\n}: FormFieldProviderProps) => {\n const labelId = `${ID_PREFIX}-label-${useId()}`\n const [messageIds, setMessageIds] = useState<string[]>([])\n const description = messageIds.length > 0 ? messageIds.join(' ') : undefined\n\n const handleMessageIdAdd = useCallback((msgId: string) => {\n setMessageIds(ids => [...ids, msgId])\n }, [])\n\n const handleMessageIdRemove = useCallback((msgId: string) => {\n setMessageIds(ids => ids.filter(current => current !== msgId))\n }, [])\n\n const value = useMemo(() => {\n const isInvalid = state === 'error'\n\n return {\n id,\n labelId,\n name,\n disabled,\n readOnly,\n state,\n isRequired,\n isInvalid,\n description,\n onMessageIdAdd: handleMessageIdAdd,\n onMessageIdRemove: handleMessageIdRemove,\n }\n }, [\n id,\n labelId,\n name,\n disabled,\n readOnly,\n description,\n state,\n isRequired,\n handleMessageIdAdd,\n handleMessageIdRemove,\n ])\n\n return <FormFieldContext.Provider value={value}>{children}</FormFieldContext.Provider>\n}\n\nFormFieldProvider.displayName = 'FormFieldProvider'\n","import { AlertOutline } from '@spark-ui/icons/AlertOutline'\nimport { Check } from '@spark-ui/icons/Check'\nimport { WarningOutline } from '@spark-ui/icons/WarningOutline'\nimport { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { Icon } from '../icon'\nimport { useFormField } from './FormFieldContext'\nimport { FormFieldMessage, FormFieldMessageProps } from './FormFieldMessage'\n\nexport interface FormFieldStateMessageProps extends FormFieldMessageProps {\n state: 'error' | 'alert' | 'success'\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldStateMessage = ({\n className,\n state,\n children,\n ref,\n ...others\n}: FormFieldStateMessageProps) => {\n const field = useFormField()\n\n if (field.state !== state) {\n return null\n }\n\n return (\n <FormFieldMessage\n ref={ref}\n data-spark-component=\"form-field-state-message\"\n aria-live=\"polite\"\n className={cx(\n 'gap-sm flex items-center',\n state === 'error' ? 'text-error' : 'text-on-surface/dim-1',\n className\n )}\n {...others}\n >\n {state === 'alert' && (\n <Icon size=\"sm\">\n <WarningOutline />\n </Icon>\n )}\n {state === 'error' && (\n <Icon size=\"sm\" intent=\"error\">\n <AlertOutline />\n </Icon>\n )}\n {state === 'success' && (\n <Icon size=\"sm\">\n <Check />\n </Icon>\n )}\n\n {children}\n </FormFieldMessage>\n )\n}\n\nFormFieldStateMessage.displayName = 'FormField.StateMessage'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useEffect, useId } from 'react'\n\nimport { ID_PREFIX, useFormField } from './FormFieldContext'\n\nexport type FormFieldMessageProps = ComponentPropsWithoutRef<'span'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldMessage = ({\n id: idProp,\n className,\n ref,\n ...others\n}: FormFieldMessageProps) => {\n const { onMessageIdAdd, onMessageIdRemove } = useFormField()\n const currentId = `${ID_PREFIX}-message-${useId()}`\n const id = idProp || currentId\n\n useEffect(() => {\n onMessageIdAdd(id)\n\n return () => {\n onMessageIdRemove(id)\n }\n }, [id, onMessageIdAdd, onMessageIdRemove])\n\n return (\n <span\n ref={ref}\n id={id}\n data-spark-component=\"form-field-message\"\n className={cx(className, 'text-caption')}\n {...others}\n />\n )\n}\n\nFormFieldMessage.displayName = 'FormField.Message'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldAlertMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldAlertMessage = ({ ref, ...props }: FormFieldAlertMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-alert-message\"\n state=\"alert\"\n {...props}\n />\n )\n}\n\nFormFieldAlertMessage.displayName = 'FormField.AlertMessage'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref } from 'react'\n\nexport type FormFieldCharactersCountProps = ComponentPropsWithoutRef<'span'> & {\n /**\n * Current value for the input this component belongs to.\n */\n value?: string\n /**\n * Maximum numeric value to be displayed.\n */\n maxLength: number\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldCharactersCount = ({\n className,\n value = '',\n maxLength,\n ref,\n ...others\n}: FormFieldCharactersCountProps) => {\n const displayValue = `${value.length}/${maxLength}`\n\n return (\n <span\n ref={ref}\n data-spark-component=\"form-field-characters-count\"\n className={cx(className, 'text-caption', 'text-neutral')}\n {...others}\n >\n {displayValue}\n </span>\n )\n}\n\nFormFieldCharactersCount.displayName = 'FormField.CharactersCount'\n","import { ReactNode, useContext } from 'react'\n\nimport { FormFieldContext, FormFieldContextState } from './FormFieldContext'\n\ntype State = Partial<\n Pick<\n FormFieldContextState,\n | 'id'\n | 'name'\n | 'description'\n | 'labelId'\n | 'disabled'\n | 'readOnly'\n | 'state'\n | 'isInvalid'\n | 'isRequired'\n >\n>\n\nexport interface FormFieldControlProps {\n children: (state: State) => ReactNode\n}\n\nexport const useFormFieldControl = () => {\n const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } =\n useContext(FormFieldContext) || {}\n\n return {\n id,\n name,\n description,\n disabled,\n readOnly,\n state,\n labelId,\n isInvalid,\n isRequired,\n } as State\n}\n\nexport const FormFieldControl = ({ children }: FormFieldControlProps) => {\n const props = useFormFieldControl()\n\n return <>{children(props)}</>\n}\n\nFormFieldControl.displayName = 'FormField.Control'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldErrorMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldErrorMessage = ({ ref, ...props }: FormFieldErrorMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-error-message\"\n state=\"error\"\n {...props}\n />\n )\n}\n\nFormFieldErrorMessage.displayName = 'FormField.ErrorMessage'\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { FormFieldMessage, FormFieldMessageProps } from './FormFieldMessage'\n\nexport type FormFieldHelperMessageProps = FormFieldMessageProps & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldHelperMessage = ({\n className,\n ref,\n ...others\n}: FormFieldHelperMessageProps) => {\n return (\n <FormFieldMessage\n ref={ref}\n data-spark-component=\"form-field-helper-message\"\n className={cx('text-on-surface/dim-1', className)}\n {...others}\n />\n )\n}\n\nFormFieldHelperMessage.displayName = 'FormField.HelperMessage'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, Ref } from 'react'\n\nimport { Label, LabelProps } from '../label'\nimport { Slottable } from '../slot'\nimport { useFormField } from './FormFieldContext'\nimport { FormFieldRequiredIndicator } from './FormFieldRequiredIndicator'\n\nexport interface FormFieldLabelProps extends LabelProps {\n /**\n * Element shown when the input is required inside the label.\n */\n requiredIndicator?: ReactNode\n ref?: Ref<HTMLLabelElement>\n}\n\nexport const FormFieldLabel = ({\n htmlFor: htmlForProp,\n className,\n children,\n requiredIndicator = <FormFieldRequiredIndicator />,\n asChild,\n ref,\n ...others\n}: FormFieldLabelProps) => {\n const control = useFormField()\n\n const { disabled, labelId, isRequired } = control\n const htmlFor = asChild ? undefined : htmlForProp || control.id\n\n return (\n <Label\n ref={ref}\n id={labelId}\n data-spark-component=\"form-field-label\"\n htmlFor={htmlFor}\n className={cx(className, disabled ? 'text-on-surface/dim-3 pointer-events-none' : undefined)}\n asChild={asChild}\n {...others}\n >\n <>\n <Slottable>{children}</Slottable>\n {isRequired && requiredIndicator}\n </>\n </Label>\n )\n}\n\nFormFieldLabel.displayName = 'FormField.Label'\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { Label, LabelRequiredIndicatorProps } from '../label'\n\nexport type FormFieldRequiredIndicatorProps = LabelRequiredIndicatorProps & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldRequiredIndicator = ({\n className,\n ref,\n ...props\n}: FormFieldRequiredIndicatorProps) => {\n return <Label.RequiredIndicator ref={ref} className={cx('ml-sm', className)} {...props} />\n}\n\nFormFieldRequiredIndicator.displayName = 'FormField.RequiredIndicator'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldSuccessMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldSuccessMessage = ({ ref, ...props }: FormFieldSuccessMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-success-message\"\n state=\"success\"\n {...props}\n />\n )\n}\n\nFormFieldSuccessMessage.displayName = 'FormField.SuccessMessage'\n","import { FormField as Root } from './FormField'\nimport { FormFieldAlertMessage } from './FormFieldAlertMessage'\nimport { FormFieldCharactersCount } from './FormFieldCharactersCount'\nimport { FormFieldControl } from './FormFieldControl'\nimport { FormFieldErrorMessage } from './FormFieldErrorMessage'\nimport { FormFieldHelperMessage } from './FormFieldHelperMessage'\nimport { FormFieldLabel } from './FormFieldLabel'\nimport { FormFieldRequiredIndicator } from './FormFieldRequiredIndicator'\nimport { FormFieldStateMessage } from './FormFieldStateMessage'\nimport { FormFieldSuccessMessage } from './FormFieldSuccessMessage'\n\nexport const FormField: typeof Root & {\n Label: typeof FormFieldLabel\n Control: typeof FormFieldControl\n StateMessage: typeof FormFieldStateMessage\n SuccessMessage: typeof FormFieldSuccessMessage\n AlertMessage: typeof FormFieldAlertMessage\n ErrorMessage: typeof FormFieldErrorMessage\n HelperMessage: typeof FormFieldHelperMessage\n RequiredIndicator: typeof FormFieldRequiredIndicator\n CharactersCount: typeof FormFieldCharactersCount\n} = Object.assign(Root, {\n Label: FormFieldLabel,\n Control: FormFieldControl,\n StateMessage: FormFieldStateMessage,\n SuccessMessage: FormFieldSuccessMessage,\n AlertMessage: FormFieldAlertMessage,\n ErrorMessage: FormFieldErrorMessage,\n HelperMessage: FormFieldHelperMessage,\n RequiredIndicator: FormFieldRequiredIndicator,\n CharactersCount: FormFieldCharactersCount,\n})\n\nFormField.displayName = 'FormField'\nFormFieldLabel.displayName = 'FormField.Label'\nFormFieldControl.displayName = 'FormField.Control'\nFormFieldStateMessage.displayName = 'FormField.StateMessage'\nFormFieldSuccessMessage.displayName = 'FormField.SuccessMessage'\nFormFieldAlertMessage.displayName = 'FormField.AlertMessage'\nFormFieldErrorMessage.displayName = 'FormField.ErrorMessage'\nFormFieldHelperMessage.displayName = 'FormField.HelperMessage'\nFormFieldRequiredIndicator.displayName = 'FormField.RequiredIndicator'\nFormFieldCharactersCount.displayName = 'FormField.CharactersCount'\n\nexport { type FormFieldProps } from './FormField'\nexport { type FormFieldStateMessageProps } from './FormFieldStateMessage'\nexport { type FormFieldControl, useFormFieldControl } from './FormFieldControl'\nexport { type FormFieldHelperMessageProps } from './FormFieldHelperMessage'\nexport { type FormFieldSuccessMessageProps } from './FormFieldSuccessMessage'\nexport { type FormFieldAlertMessageProps } from './FormFieldAlertMessage'\nexport { type FormFieldErrorMessageProps } from './FormFieldErrorMessage'\nexport { type FormFieldLabelProps } from './FormFieldLabel'\nexport { type FormFieldRequiredIndicatorProps } from './FormFieldRequiredIndicator'\nexport { type FormFieldCharactersCountProps } from './FormFieldCharactersCount'\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS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AA,EACd,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,CAAC;AAEDA,WAAU,cAAc;AACxB,eAAe,cAAc;AAC7B,iBAAiB,cAAc;AAC/B,sBAAsB,cAAc;AACpC,wBAAwB,cAAc;AACtC,sBAAsB,cAAc;AACpC,sBAAsB,cAAc;AACpC,uBAAuB,cAAc;AACrC,2BAA2B,cAAc;AACzC,yBAAyB,cAAc;","names":["useId","jsx","useId","cx","cx","useId","jsx","useId","cx","jsx","cx","jsx","cx","jsx","useContext","jsx","useContext","jsx","cx","jsx","cx","cx","cx","jsx","cx","Fragment","jsx","jsxs","cx","jsx","FormField"]}