@spark-ui/components 14.1.2 → 15.1.0

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 (38) hide show
  1. package/dist/FormFieldRequiredIndicator-CHfcoT2y.js +2 -0
  2. package/dist/FormFieldRequiredIndicator-CHfcoT2y.js.map +1 -0
  3. package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs +13 -0
  4. package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs.map +1 -0
  5. package/dist/dialog/Dialog.d.ts +1 -0
  6. package/dist/dialog/index.js +1 -1
  7. package/dist/dialog/index.js.map +1 -1
  8. package/dist/dialog/index.mjs +19 -18
  9. package/dist/dialog/index.mjs.map +1 -1
  10. package/dist/form-field/index.js +1 -1
  11. package/dist/form-field/index.js.map +1 -1
  12. package/dist/form-field/index.mjs +76 -81
  13. package/dist/form-field/index.mjs.map +1 -1
  14. package/dist/slider/Slider.d.ts +8 -13
  15. package/dist/slider/SliderContext.d.ts +7 -1
  16. package/dist/slider/SliderControl.d.ts +7 -0
  17. package/dist/slider/SliderIndicator.d.ts +7 -0
  18. package/dist/slider/SliderLabel.d.ts +13 -0
  19. package/dist/slider/SliderMaxValue.d.ts +6 -0
  20. package/dist/slider/SliderMinValue.d.ts +6 -0
  21. package/dist/slider/SliderThumb.d.ts +4 -11
  22. package/dist/slider/SliderThumbContext.d.ts +5 -0
  23. package/dist/slider/SliderTrack.d.ts +4 -11
  24. package/dist/slider/SliderTrack.styles.d.ts +1 -4
  25. package/dist/slider/SliderValue.d.ts +10 -0
  26. package/dist/slider/index.d.mts +13 -1
  27. package/dist/slider/index.d.ts +13 -1
  28. package/dist/slider/index.js +1 -1
  29. package/dist/slider/index.js.map +1 -1
  30. package/dist/slider/index.mjs +290 -127
  31. package/dist/slider/index.mjs.map +1 -1
  32. package/dist/slider/useSliderValueBoundaries.d.ts +12 -0
  33. package/dist/toast/index.js +1 -1
  34. package/dist/toast/index.js.map +1 -1
  35. package/dist/toast/index.mjs +154 -129
  36. package/dist/toast/index.mjs.map +1 -1
  37. package/dist/toast/types.d.ts +4 -1
  38. package/package.json +4 -4
@@ -1,80 +1,81 @@
1
- import { jsx as r, jsxs as I, Fragment as H } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as N, Fragment as H } from "react/jsx-runtime";
2
2
  import { cx as c } from "class-variance-authority";
3
- import { createContext as W, useContext as L, useId as y, useState as P, useCallback as j, useMemo as X, useEffect as z } from "react";
4
- import { a as _, S as B } from "../Slot-D2Bbf8Gw.mjs";
5
- import { AlertOutline as G } from "@spark-ui/icons/AlertOutline";
6
- import { Check as J } from "@spark-ui/icons/Check";
7
- import { WarningOutline as K } from "@spark-ui/icons/WarningOutline";
3
+ import { createContext as D, useContext as L, useId as I, useState as P, useCallback as q, useMemo as W, useEffect as z } from "react";
4
+ import { a as X, S as _ } from "../Slot-D2Bbf8Gw.mjs";
5
+ import { AlertOutline as B } from "@spark-ui/icons/AlertOutline";
6
+ import { Check as G } from "@spark-ui/icons/Check";
7
+ import { WarningOutline as J } from "@spark-ui/icons/WarningOutline";
8
8
  import { I as M } from "../Icon-Ck-dhfLd.mjs";
9
- import { Label as O } from "../label/index.mjs";
10
- const C = W(null), x = ":form-field", b = () => {
9
+ import { Label as K } from "../label/index.mjs";
10
+ import { F as y } from "../FormFieldRequiredIndicator-DTnCGiX2.mjs";
11
+ const C = D(null), x = ":form-field", b = () => {
11
12
  const s = L(C);
12
13
  if (!s)
13
14
  throw Error("useFormField must be used within a FormField provider");
14
15
  return s;
15
- }, T = ({
16
+ }, O = ({
16
17
  id: s,
17
18
  name: e,
18
- disabled: o = !1,
19
+ disabled: a = !1,
19
20
  readOnly: l = !1,
20
- state: a,
21
+ state: o,
21
22
  isRequired: i,
22
23
  children: d
23
24
  }) => {
24
- const t = `${x}-label-${y()}`, [n, m] = P([]), p = n.length > 0 ? n.join(" ") : void 0, u = j((f) => {
25
+ const t = `${x}-label-${I()}`, [n, m] = P([]), p = n.length > 0 ? n.join(" ") : void 0, u = q((f) => {
25
26
  m((h) => [...h, f]);
26
- }, []), q = j((f) => {
27
- m((h) => h.filter((D) => D !== f));
28
- }, []), V = X(() => ({
27
+ }, []), j = q((f) => {
28
+ m((h) => h.filter((V) => V !== f));
29
+ }, []), w = W(() => ({
29
30
  id: s,
30
31
  labelId: t,
31
32
  name: e,
32
- disabled: o,
33
+ disabled: a,
33
34
  readOnly: l,
34
- state: a,
35
+ state: o,
35
36
  isRequired: i,
36
- isInvalid: a === "error",
37
+ isInvalid: o === "error",
37
38
  description: p,
38
39
  onMessageIdAdd: u,
39
- onMessageIdRemove: q
40
+ onMessageIdRemove: j
40
41
  }), [
41
42
  s,
42
43
  t,
43
44
  e,
44
- o,
45
+ a,
45
46
  l,
46
47
  p,
47
- a,
48
+ o,
48
49
  i,
49
50
  u,
50
- q
51
+ j
51
52
  ]);
52
- return /* @__PURE__ */ r(C.Provider, { value: V, children: d });
53
+ return /* @__PURE__ */ r(C.Provider, { value: w, children: d });
53
54
  };
54
- T.displayName = "FormFieldProvider";
55
- const w = ({
55
+ O.displayName = "FormFieldProvider";
56
+ const T = ({
56
57
  className: s,
57
58
  disabled: e = !1,
58
- readOnly: o = !1,
59
+ readOnly: a = !1,
59
60
  name: l,
60
- state: a,
61
+ state: o,
61
62
  isRequired: i = !1,
62
63
  asChild: d = !1,
63
64
  ref: t,
64
65
  ...n
65
66
  }) => {
66
- const m = `${x}-${y()}`;
67
+ const m = `${x}-${I()}`;
67
68
  return /* @__PURE__ */ r(
68
- T,
69
+ O,
69
70
  {
70
71
  id: m,
71
72
  name: l,
72
73
  isRequired: i,
73
74
  disabled: e,
74
- readOnly: o,
75
- state: a,
75
+ readOnly: a,
76
+ state: o,
76
77
  children: /* @__PURE__ */ r(
77
- d ? _ : "div",
78
+ d ? X : "div",
78
79
  {
79
80
  ref: t,
80
81
  "data-spark-component": "form-field",
@@ -85,20 +86,20 @@ const w = ({
85
86
  }
86
87
  );
87
88
  };
88
- w.displayName = "FormField";
89
+ T.displayName = "FormField";
89
90
  const g = ({
90
91
  id: s,
91
92
  className: e,
92
- ref: o,
93
+ ref: a,
93
94
  ...l
94
95
  }) => {
95
- const { onMessageIdAdd: a, onMessageIdRemove: i } = b(), d = `${x}-message-${y()}`, t = s || d;
96
- return z(() => (a(t), () => {
96
+ const { onMessageIdAdd: o, onMessageIdRemove: i } = b(), d = `${x}-message-${I()}`, t = s || d;
97
+ return z(() => (o(t), () => {
97
98
  i(t);
98
- }), [t, a, i]), /* @__PURE__ */ r(
99
+ }), [t, o, i]), /* @__PURE__ */ r(
99
100
  "span",
100
101
  {
101
- ref: o,
102
+ ref: a,
102
103
  id: t,
103
104
  "data-spark-component": "form-field-message",
104
105
  className: c(e, "text-caption"),
@@ -110,10 +111,10 @@ g.displayName = "FormField.Message";
110
111
  const F = ({
111
112
  className: s,
112
113
  state: e,
113
- children: o,
114
+ children: a,
114
115
  ref: l,
115
- ...a
116
- }) => b().state !== e ? null : /* @__PURE__ */ I(
116
+ ...o
117
+ }) => b().state !== e ? null : /* @__PURE__ */ N(
117
118
  g,
118
119
  {
119
120
  ref: l,
@@ -123,12 +124,12 @@ const F = ({
123
124
  e === "error" ? "text-error" : "text-on-surface/dim-1",
124
125
  s
125
126
  ),
126
- ...a,
127
+ ...o,
127
128
  children: [
128
- e === "alert" && /* @__PURE__ */ r(M, { size: "sm", children: /* @__PURE__ */ r(K, {}) }),
129
- e === "error" && /* @__PURE__ */ r(M, { size: "sm", intent: "error", children: /* @__PURE__ */ r(G, {}) }),
130
- e === "success" && /* @__PURE__ */ r(M, { size: "sm", children: /* @__PURE__ */ r(J, {}) }),
131
- o
129
+ e === "alert" && /* @__PURE__ */ r(M, { size: "sm", children: /* @__PURE__ */ r(J, {}) }),
130
+ e === "error" && /* @__PURE__ */ r(M, { size: "sm", intent: "error", children: /* @__PURE__ */ r(B, {}) }),
131
+ e === "success" && /* @__PURE__ */ r(M, { size: "sm", children: /* @__PURE__ */ r(G, {}) }),
132
+ a
132
133
  ]
133
134
  }
134
135
  );
@@ -146,9 +147,9 @@ v.displayName = "FormField.AlertMessage";
146
147
  const S = ({
147
148
  className: s,
148
149
  value: e = "",
149
- maxLength: o,
150
+ maxLength: a,
150
151
  description: l,
151
- liveAnnouncement: a,
152
+ liveAnnouncement: o,
152
153
  ref: i,
153
154
  ...d
154
155
  }) => {
@@ -158,7 +159,7 @@ const S = ({
158
159
  n(e);
159
160
  }, 1e3);
160
161
  return () => clearTimeout(m);
161
- }, [e]), /* @__PURE__ */ I("span", { className: "ml-auto self-start", children: [
162
+ }, [e]), /* @__PURE__ */ N("span", { className: "ml-auto self-start", children: [
162
163
  l && /* @__PURE__ */ r(g, { className: "default:sr-only", children: l }),
163
164
  /* @__PURE__ */ r(
164
165
  "span",
@@ -168,21 +169,21 @@ const S = ({
168
169
  "data-spark-component": "form-field-characters-count",
169
170
  className: c(s, "text-caption", "text-neutral"),
170
171
  ...d,
171
- children: `${e.length}/${o}`
172
+ children: `${e.length}/${a}`
172
173
  }
173
174
  ),
174
- a && /* @__PURE__ */ r("span", { className: "sr-only", "aria-live": "polite", children: a({ remainingChars: o - t.length }) })
175
+ o && /* @__PURE__ */ r("span", { className: "sr-only", "aria-live": "polite", children: o({ remainingChars: a - t.length }) })
175
176
  ] });
176
177
  };
177
178
  S.displayName = "FormField.CharactersCount";
178
179
  const Q = () => {
179
- const { id: s, name: e, description: o, disabled: l, readOnly: a, state: i, labelId: d, isInvalid: t, isRequired: n } = L(C) || {};
180
+ const { id: s, name: e, description: a, disabled: l, readOnly: o, state: i, labelId: d, isInvalid: t, isRequired: n } = L(C) || {};
180
181
  return {
181
182
  id: s,
182
183
  name: e,
183
- description: o,
184
+ description: a,
184
185
  disabled: l,
185
- readOnly: a,
186
+ readOnly: o,
186
187
  state: i,
187
188
  labelId: d,
188
189
  isInvalid: t,
@@ -193,7 +194,7 @@ const Q = () => {
193
194
  return /* @__PURE__ */ r(H, { children: s(e) });
194
195
  };
195
196
  k.displayName = "FormField.Control";
196
- const R = ({ ref: s, ...e }) => /* @__PURE__ */ r(
197
+ const $ = ({ ref: s, ...e }) => /* @__PURE__ */ r(
197
198
  F,
198
199
  {
199
200
  ref: s,
@@ -202,49 +203,43 @@ const R = ({ ref: s, ...e }) => /* @__PURE__ */ r(
202
203
  ...e
203
204
  }
204
205
  );
205
- R.displayName = "FormField.ErrorMessage";
206
- const $ = ({
206
+ $.displayName = "FormField.ErrorMessage";
207
+ const R = ({
207
208
  className: s,
208
209
  ref: e,
209
- ...o
210
+ ...a
210
211
  }) => /* @__PURE__ */ r(
211
212
  g,
212
213
  {
213
214
  ref: e,
214
215
  "data-spark-component": "form-field-helper-message",
215
216
  className: c("text-on-surface/dim-1", s),
216
- ...o
217
+ ...a
217
218
  }
218
219
  );
219
- $.displayName = "FormField.HelperMessage";
220
- const N = ({
221
- className: s,
222
- ref: e,
223
- ...o
224
- }) => /* @__PURE__ */ r(O.RequiredIndicator, { ref: e, className: c("ml-sm", s), ...o });
225
- N.displayName = "FormField.RequiredIndicator";
220
+ R.displayName = "FormField.HelperMessage";
226
221
  const A = ({
227
222
  htmlFor: s,
228
223
  className: e,
229
- children: o,
230
- requiredIndicator: l = /* @__PURE__ */ r(N, {}),
231
- asChild: a,
224
+ children: a,
225
+ requiredIndicator: l = /* @__PURE__ */ r(y, {}),
226
+ asChild: o,
232
227
  ref: i,
233
228
  ...d
234
229
  }) => {
235
- const t = b(), { disabled: n, labelId: m, isRequired: p } = t, u = a ? void 0 : s || t.id;
230
+ const t = b(), { disabled: n, labelId: m, isRequired: p } = t, u = o ? void 0 : s || t.id;
236
231
  return /* @__PURE__ */ r(
237
- O,
232
+ K,
238
233
  {
239
234
  ref: i,
240
235
  id: m,
241
236
  "data-spark-component": "form-field-label",
242
237
  htmlFor: u,
243
238
  className: c(e, n ? "text-on-surface/dim-3 pointer-events-none" : void 0),
244
- asChild: a,
239
+ asChild: o,
245
240
  ...d,
246
- children: /* @__PURE__ */ I(H, { children: [
247
- /* @__PURE__ */ r(B, { children: o }),
241
+ children: /* @__PURE__ */ N(H, { children: [
242
+ /* @__PURE__ */ r(_, { children: a }),
248
243
  p && l
249
244
  ] })
250
245
  }
@@ -261,15 +256,15 @@ const E = ({ ref: s, ...e }) => /* @__PURE__ */ r(
261
256
  }
262
257
  );
263
258
  E.displayName = "FormField.SuccessMessage";
264
- const U = Object.assign(w, {
259
+ const U = Object.assign(T, {
265
260
  Label: A,
266
261
  Control: k,
267
262
  StateMessage: F,
268
263
  SuccessMessage: E,
269
264
  AlertMessage: v,
270
- ErrorMessage: R,
271
- HelperMessage: $,
272
- RequiredIndicator: N,
265
+ ErrorMessage: $,
266
+ HelperMessage: R,
267
+ RequiredIndicator: y,
273
268
  CharactersCount: S
274
269
  });
275
270
  U.displayName = "FormField";
@@ -278,9 +273,9 @@ k.displayName = "FormField.Control";
278
273
  F.displayName = "FormField.StateMessage";
279
274
  E.displayName = "FormField.SuccessMessage";
280
275
  v.displayName = "FormField.AlertMessage";
281
- R.displayName = "FormField.ErrorMessage";
282
- $.displayName = "FormField.HelperMessage";
283
- N.displayName = "FormField.RequiredIndicator";
276
+ $.displayName = "FormField.ErrorMessage";
277
+ R.displayName = "FormField.HelperMessage";
278
+ y.displayName = "FormField.RequiredIndicator";
284
279
  S.displayName = "FormField.CharactersCount";
285
280
  export {
286
281
  U as FormField,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/form-field/FormFieldContext.tsx","../../src/form-field/FormFieldProvider.tsx","../../src/form-field/FormField.tsx","../../src/form-field/FormFieldMessage.tsx","../../src/form-field/FormFieldStateMessage.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/FormFieldRequiredIndicator.tsx","../../src/form-field/FormFieldLabel.tsx","../../src/form-field/FormFieldSuccessMessage.tsx","../../src/form-field/index.ts"],"sourcesContent":["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 { 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 { 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 { 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 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 { 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, useEffect, useState } from 'react'\n\nimport { FormFieldMessage } from './FormFieldMessage'\n\nexport type FormFieldCharactersCountProps = ComponentPropsWithoutRef<'span'> & {\n /**\n * This description is for the screen reader, read when the input is focused.\n */\n description?: string\n /**\n * The live announcement is for the screen read after a delay once the input value changes.\n */\n liveAnnouncement?: ({ remainingChars }: { remainingChars: number }) => string\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 description,\n liveAnnouncement,\n ref,\n ...others\n}: FormFieldCharactersCountProps) => {\n const [throttledValue, setThrottledValue] = useState(value)\n\n /**\n * The value is throttled to avoid spamming the aria-live region (and consequently the screen reader).\n */\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setThrottledValue(value)\n }, 1000)\n\n return () => clearTimeout(timeoutId)\n }, [value])\n\n return (\n <span className=\"ml-auto self-start\">\n {description && (\n <FormFieldMessage className=\"default:sr-only\">{description}</FormFieldMessage>\n )}\n <span\n ref={ref}\n aria-hidden\n data-spark-component=\"form-field-characters-count\"\n className={cx(className, 'text-caption', 'text-neutral')}\n {...others}\n >\n {`${value.length}/${maxLength}`}\n </span>\n\n {liveAnnouncement && (\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveAnnouncement({ remainingChars: maxLength - throttledValue.length })}\n </span>\n )}\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 { 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 { 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 { 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"],"names":["FormFieldContext","createContext","ID_PREFIX","useFormField","context","useContext","FormFieldProvider","id","name","disabled","readOnly","state","isRequired","children","labelId","useId","messageIds","setMessageIds","useState","description","handleMessageIdAdd","useCallback","msgId","ids","handleMessageIdRemove","current","value","useMemo","jsx","FormField","className","asChild","ref","others","Slot","cx","FormFieldMessage","idProp","onMessageIdAdd","onMessageIdRemove","currentId","useEffect","FormFieldStateMessage","jsxs","Icon","WarningOutline","AlertOutline","Check","FormFieldAlertMessage","props","FormFieldCharactersCount","maxLength","liveAnnouncement","throttledValue","setThrottledValue","timeoutId","useFormFieldControl","isInvalid","FormFieldControl","Fragment","FormFieldErrorMessage","FormFieldHelperMessage","FormFieldRequiredIndicator","Label","FormFieldLabel","htmlForProp","requiredIndicator","control","htmlFor","Slottable","FormFieldSuccessMessage","Root"],"mappings":";;;;;;;;;AAiDO,MAAMA,IAAmBC,EAA4C,IAAI,GAEnEC,IAAY,eAEZC,IAAe,MAAM;AAChC,QAAMC,IAAUC,EAAWL,CAAgB;AAE3C,MAAI,CAACI;AACH,UAAM,MAAM,uDAAuD;AAGrE,SAAOA;AACT,GCjDaE,IA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U,EAAAgB,GAAA,EACE,UAAA;AAAA,QAAA,gBAAA/B,EAACyC,KAAW,UAAAxD,GAAS;AAAA,QACpBD,KAAcsD;AAAA,MAAA,EAAA,CACjB;AAAA,IAAA;AAAA,EAAA;AAGN;AAEAF,EAAe,cAAc;ACxCtB,MAAMM,IAA0B,CAAC,EAAE,KAAAtC,GAAK,GAAGiB,QAE9C,gBAAArB;AAAA,EAACc;AAAA,EAAA;AAAA,IACC,KAAAV;AAAA,IACA,wBAAqB;AAAA,IACrB,OAAM;AAAA,IACL,GAAGiB;AAAA,EAAA;AAAA;AAKVqB,EAAwB,cAAc;ACR/B,MAAMzC,IAUT,OAAO,OAAO0C,GAAM;AAAA,EACtB,OAAOP;AAAA,EACP,SAASN;AAAA,EACT,cAAchB;AAAA,EACd,gBAAgB4B;AAAA,EAChB,cAActB;AAAA,EACd,cAAcY;AAAA,EACd,eAAeC;AAAA,EACf,mBAAmBC;AAAA,EACnB,iBAAiBZ;AACnB,CAAC;AAEDrB,EAAU,cAAc;AACxBmC,EAAe,cAAc;AAC7BN,EAAiB,cAAc;AAC/BhB,EAAsB,cAAc;AACpC4B,EAAwB,cAAc;AACtCtB,EAAsB,cAAc;AACpCY,EAAsB,cAAc;AACpCC,EAAuB,cAAc;AACrCC,EAA2B,cAAc;AACzCZ,EAAyB,cAAc;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/form-field/FormFieldContext.tsx","../../src/form-field/FormFieldProvider.tsx","../../src/form-field/FormField.tsx","../../src/form-field/FormFieldMessage.tsx","../../src/form-field/FormFieldStateMessage.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/FormFieldSuccessMessage.tsx","../../src/form-field/index.ts"],"sourcesContent":["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 { 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 { 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 { 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 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 { 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, useEffect, useState } from 'react'\n\nimport { FormFieldMessage } from './FormFieldMessage'\n\nexport type FormFieldCharactersCountProps = ComponentPropsWithoutRef<'span'> & {\n /**\n * This description is for the screen reader, read when the input is focused.\n */\n description?: string\n /**\n * The live announcement is for the screen read after a delay once the input value changes.\n */\n liveAnnouncement?: ({ remainingChars }: { remainingChars: number }) => string\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 description,\n liveAnnouncement,\n ref,\n ...others\n}: FormFieldCharactersCountProps) => {\n const [throttledValue, setThrottledValue] = useState(value)\n\n /**\n * The value is throttled to avoid spamming the aria-live region (and consequently the screen reader).\n */\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setThrottledValue(value)\n }, 1000)\n\n return () => clearTimeout(timeoutId)\n }, [value])\n\n return (\n <span className=\"ml-auto self-start\">\n {description && (\n <FormFieldMessage className=\"default:sr-only\">{description}</FormFieldMessage>\n )}\n <span\n ref={ref}\n aria-hidden\n data-spark-component=\"form-field-characters-count\"\n className={cx(className, 'text-caption', 'text-neutral')}\n {...others}\n >\n {`${value.length}/${maxLength}`}\n </span>\n\n {liveAnnouncement && (\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveAnnouncement({ remainingChars: maxLength - throttledValue.length })}\n </span>\n )}\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 { 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"],"names":["FormFieldContext","createContext","ID_PREFIX","useFormField","context","useContext","FormFieldProvider","id","name","disabled","readOnly","state","isRequired","children","labelId","useId","messageIds","setMessageIds","useState","description","handleMessageIdAdd","useCallback","msgId","ids","handleMessageIdRemove","current","value","useMemo","jsx","FormField","className","asChild","ref","others","Slot","cx","FormFieldMessage","idProp","onMessageIdAdd","onMessageIdRemove","currentId","useEffect","FormFieldStateMessage","jsxs","Icon","WarningOutline","AlertOutline","Check","FormFieldAlertMessage","props","FormFieldCharactersCount","maxLength","liveAnnouncement","throttledValue","setThrottledValue","timeoutId","useFormFieldControl","isInvalid","FormFieldControl","Fragment","FormFieldErrorMessage","FormFieldHelperMessage","FormFieldLabel","htmlForProp","requiredIndicator","FormFieldRequiredIndicator","control","htmlFor","Label","Slottable","FormFieldSuccessMessage","Root"],"mappings":";;;;;;;;;;AAiDO,MAAMA,IAAmBC,EAA4C,IAAI,GAEnEC,IAAY,eAEZC,IAAe,MAAM;AAChC,QAAMC,IAAUC,EAAWL,CAAgB;AAE3C,MAAI,CAACI;AACH,UAAM,MAAM,uDAAuD;AAGrE,SAAOA;AACT,GCjDaE,IAAoB,CAAC;AAAA,EAChC,IAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AACF,MAA8B;AAC5B,QAAMC,IAAU,GAAGZ,CAAS,UAAUa,GAAO,IACvC,CAACC,GAAYC,CAAa,IAAIC,EAAmB,CAAA,CAAE,GACnDC,IAAcH,EAAW,SAAS,IAAIA,EAAW,KAAK,GAAG,IAAI,QAE7DI,IAAqBC,EAAY,CAACC,MAAkB;AACxD,IAAAL,EAA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iBf;AACnB,CAAC;AAEDrB,EAAU,cAAc;AACxBiC,EAAe,cAAc;AAC7BJ,EAAiB,cAAc;AAC/BhB,EAAsB,cAAc;AACpC4B,EAAwB,cAAc;AACtCtB,EAAsB,cAAc;AACpCY,EAAsB,cAAc;AACpCC,EAAuB,cAAc;AACrCI,EAA2B,cAAc;AACzCf,EAAyB,cAAc;"}
@@ -1,28 +1,23 @@
1
- import { Slider as RadixSlider } from 'radix-ui';
2
- import { PropsWithChildren, Ref } from 'react';
1
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
2
+ import { ComponentProps, PropsWithChildren, Ref } from 'react';
3
3
  import { SliderRangeVariantsProps } from './SliderTrack.styles';
4
- export interface SliderProps extends Omit<RadixSlider.SliderProps, 'dir' | 'orientation' | 'inverted' | 'minStepsBetweenThumbs'>, PropsWithChildren<SliderRangeVariantsProps> {
5
- /**
6
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
7
- * @default false
8
- */
9
- asChild?: boolean;
4
+ export interface SliderProps extends Omit<ComponentProps<typeof BaseSlider.Root>, 'render' | 'orientation' | 'onValueChange' | 'onValueCommitted'>, PropsWithChildren<SliderRangeVariantsProps> {
10
5
  /**
11
6
  * The value of the slider when initially rendered. Use when you do not need to control the state of the slider.
12
7
  */
13
- defaultValue?: number[];
8
+ defaultValue?: number;
14
9
  /**
15
10
  * The controlled value of the slider. Must be used in conjunction with `onValueChange`.
16
11
  */
17
- value?: number[];
12
+ value?: number;
18
13
  /**
19
14
  * Event handler called when the value changes.
20
15
  */
21
- onValueChange?: (value: number[]) => void;
16
+ onValueChange?: (value: number) => void;
22
17
  /**
23
18
  * Event handler called when the value changes at the end of an interaction. Useful when you only need to capture a final value e.g. to update a backend service.
24
19
  */
25
- onValueCommit?: (value: number[]) => void;
20
+ onValueCommit?: (value: number) => void;
26
21
  /**
27
22
  * The name of the slider. Submitted with its owning form as part of a name/value pair.
28
23
  * If wrapped with a FormField with a name, will be inherited from it.
@@ -55,6 +50,6 @@ export interface SliderProps extends Omit<RadixSlider.SliderProps, 'dir' | 'orie
55
50
  ref?: Ref<HTMLDivElement>;
56
51
  }
57
52
  export declare const Slider: {
58
- ({ asChild, intent, shape, children, className, ref, disabled: disabledProp, readOnly: readOnlyProp, name: nameProp, ...rest }: SliderProps): import("react/jsx-runtime").JSX.Element;
53
+ ({ intent, children, className, ref, value: valueProp, defaultValue: defaultValueProp, disabled: disabledProp, readOnly: readOnlyProp, name: nameProp, onValueChange, onValueCommit, min, max, ...rest }: SliderProps): import("react/jsx-runtime").JSX.Element;
59
54
  displayName: string;
60
55
  };
@@ -1,7 +1,13 @@
1
+ import { RefObject } from 'react';
1
2
  import { SliderProps } from './Slider';
2
- export type SliderContextInterface = Pick<SliderProps, 'intent' | 'shape'> & {
3
+ export type SliderContextInterface = Pick<SliderProps, 'intent' | 'min' | 'max'> & {
3
4
  fieldLabelId?: string;
4
5
  fieldId?: string;
6
+ onLabelId?: (id: string | undefined) => void;
7
+ hasValueInThumb: boolean;
8
+ registerValueInThumb: () => () => void;
9
+ controlRef: RefObject<HTMLElement | null>;
10
+ thumbRef: RefObject<HTMLElement | null>;
5
11
  };
6
12
  export declare const SliderContext: import('react').Context<SliderContextInterface>;
7
13
  export declare const useSliderContext: () => SliderContextInterface;
@@ -0,0 +1,7 @@
1
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
2
+ import { ComponentProps } from 'react';
3
+ export type SliderControlProps = Omit<ComponentProps<typeof BaseSlider.Control>, 'render'>;
4
+ export declare const SliderControl: {
5
+ ({ className, ref, ...rest }: SliderControlProps): import("react/jsx-runtime").JSX.Element;
6
+ displayName: string;
7
+ };
@@ -0,0 +1,7 @@
1
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
2
+ import { ComponentProps } from 'react';
3
+ export type SliderIndicatorProps = Omit<ComponentProps<typeof BaseSlider.Indicator>, 'render'>;
4
+ export declare const SliderIndicator: {
5
+ ({ className, ref, ...rest }: SliderIndicatorProps): import("react/jsx-runtime").JSX.Element;
6
+ displayName: string;
7
+ };
@@ -0,0 +1,13 @@
1
+ import { ReactNode, Ref } from 'react';
2
+ import { LabelProps } from '../label';
3
+ export interface SliderLabelProps extends LabelProps {
4
+ /**
5
+ * Element shown when the input is required inside the label.
6
+ */
7
+ requiredIndicator?: ReactNode;
8
+ ref?: Ref<HTMLLabelElement>;
9
+ }
10
+ export declare const SliderLabel: {
11
+ ({ htmlFor: htmlForProp, id: idProp, className, children, requiredIndicator, asChild, ref, ...others }: SliderLabelProps): import("react/jsx-runtime").JSX.Element;
12
+ displayName: string;
13
+ };
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SliderMaxValueProps {
3
+ className?: string;
4
+ children?: (value: number) => ReactNode;
5
+ }
6
+ export declare const SliderMaxValue: import('react').ForwardRefExoticComponent<SliderMaxValueProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SliderMinValueProps {
3
+ className?: string;
4
+ children?: (value: number) => ReactNode;
5
+ }
6
+ export declare const SliderMinValue: import('react').ForwardRefExoticComponent<SliderMinValueProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,14 +1,7 @@
1
- import { Slider as RadixSlider } from 'radix-ui';
2
- import { Ref } from 'react';
3
- export interface SliderThumbProps extends RadixSlider.SliderThumbProps {
4
- /**
5
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
6
- * @default false
7
- */
8
- asChild?: boolean;
9
- ref?: Ref<HTMLSpanElement>;
10
- }
1
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
2
+ import { ComponentProps, PropsWithChildren } from 'react';
3
+ export type SliderThumbProps = Omit<ComponentProps<typeof BaseSlider.Thumb>, 'render' | 'index'> & PropsWithChildren;
11
4
  export declare const SliderThumb: {
12
- ({ asChild, className, onPointerDown, onKeyDown, onBlur, ref: forwardedRef, ...rest }: SliderThumbProps): import("react/jsx-runtime").JSX.Element;
5
+ ({ className, ref: forwardedRef, children, ...rest }: SliderThumbProps): import("react/jsx-runtime").JSX.Element;
13
6
  displayName: string;
14
7
  };
@@ -0,0 +1,5 @@
1
+ export interface SliderThumbContextValue {
2
+ isInsideThumb: true;
3
+ }
4
+ export declare const SliderThumbContext: import('react').Context<SliderThumbContextValue | null>;
5
+ export declare const useSliderThumbContext: () => SliderThumbContextValue | null;
@@ -1,14 +1,7 @@
1
- import { Slider as RadixSlider } from 'radix-ui';
2
- import { Ref } from 'react';
3
- export interface SliderTrackProps extends RadixSlider.SliderTrackProps, RadixSlider.SliderRangeProps {
4
- /**
5
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
6
- * @default false
7
- */
8
- asChild?: boolean;
9
- ref?: Ref<HTMLDivElement>;
10
- }
1
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
2
+ import { ComponentProps } from 'react';
3
+ export type SliderTrackProps = Omit<ComponentProps<typeof BaseSlider.Track>, 'render'>;
11
4
  export declare const SliderTrack: {
12
- ({ asChild, className, ref, ...rest }: SliderTrackProps): import("react/jsx-runtime").JSX.Element;
5
+ ({ className, ref, ...rest }: SliderTrackProps): import("react/jsx-runtime").JSX.Element;
13
6
  displayName: string;
14
7
  };
@@ -1,9 +1,6 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
- export declare const trackVariants: (props?: ({
3
- shape?: "square" | "rounded" | null | undefined;
4
- } & import('class-variance-authority/types').ClassProp) | undefined) => string;
2
+ export declare const trackVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
5
3
  export declare const rangeVariants: (props?: ({
6
4
  intent?: "main" | "alert" | "error" | "support" | "accent" | "basic" | "success" | "info" | "neutral" | null | undefined;
7
- shape?: "square" | "rounded" | null | undefined;
8
5
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
9
6
  export type SliderRangeVariantsProps = VariantProps<typeof rangeVariants>;
@@ -0,0 +1,10 @@
1
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
2
+ import { ComponentProps } from 'react';
3
+ export type SliderValueProps = Omit<ComponentProps<typeof BaseSlider.Value>, 'render'>;
4
+ /**
5
+ * Normalizes Base UI's (formattedValues, values) to single (formatted, value) for the render prop.
6
+ */
7
+ export declare const SliderValue: {
8
+ ({ className, children, ref, ...rest }: SliderValueProps): import("react/jsx-runtime").JSX.Element;
9
+ displayName: string;
10
+ };