@ngrok/mantle 0.73.1 → 0.73.2

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 (96) hide show
  1. package/dist/accordion.d.ts +1 -1
  2. package/dist/agent.json +1 -1
  3. package/dist/alert-dialog.d.ts +8 -8
  4. package/dist/alert.d.ts +3 -3
  5. package/dist/anchor.d.ts +1 -1
  6. package/dist/{as-child-C2PttRwz.d.ts → as-child-CpZKMqTE.d.ts} +1 -1
  7. package/dist/badge.d.ts +2 -2
  8. package/dist/{button-CoGmk7_d.d.ts → button-DbHFERMB.d.ts} +6 -6
  9. package/dist/button.d.ts +3 -3
  10. package/dist/card.d.ts +1 -1
  11. package/dist/checkbox.d.ts +1 -1
  12. package/dist/code-block.d.ts +3 -3
  13. package/dist/code-block_highlight-utils.d.ts +1 -1
  14. package/dist/code.d.ts +1 -1
  15. package/dist/color.d.ts +1 -1
  16. package/dist/combobox.d.ts +2 -2
  17. package/dist/command.d.ts +4 -4
  18. package/dist/data-table.d.ts +3 -3
  19. package/dist/{deep-non-nullable-CT7hWCFG.d.ts → deep-non-nullable-Xu7ckQM6.d.ts} +1 -1
  20. package/dist/description-list.d.ts +1 -1
  21. package/dist/dialog.d.ts +2 -2
  22. package/dist/{direction-CVntIxOS.d.ts → direction-D9IZ1wW6.d.ts} +1 -1
  23. package/dist/{dropdown-menu-DVvNlA72.d.ts → dropdown-menu-CvOiQUSZ.d.ts} +2 -2
  24. package/dist/dropdown-menu.d.ts +1 -1
  25. package/dist/empty.d.ts +2 -2
  26. package/dist/field-context-B7Z1cmZW.js +2 -0
  27. package/dist/field-context-B7Z1cmZW.js.map +1 -0
  28. package/dist/field.d.ts +138 -67
  29. package/dist/field.js +1 -1
  30. package/dist/field.js.map +1 -1
  31. package/dist/hooks.d.ts +3 -3
  32. package/dist/hooks.js +1 -1
  33. package/dist/{icon-D_BMDi_q.d.ts → icon-BJ7q2RXZ.d.ts} +2 -2
  34. package/dist/{icon-button-Dty-yfE2.d.ts → icon-button-BDTb-lxs.d.ts} +3 -3
  35. package/dist/icon.d.ts +3 -3
  36. package/dist/icons.d.ts +3 -3
  37. package/dist/{in-view-DdIrfU4u.d.ts → in-view-BUgyu-Tk.d.ts} +1 -1
  38. package/dist/{in-view-BLZVEGFC.js → in-view-CeVqeGbv.js} +1 -1
  39. package/dist/{in-view-BLZVEGFC.js.map → in-view-CeVqeGbv.js.map} +1 -1
  40. package/dist/{index-TI92Xpg5.d.ts → index-BbZBDzPh.d.ts} +1 -1
  41. package/dist/{index-j46YISoN.d.ts → index-BhlxYL_y.d.ts} +1 -1
  42. package/dist/{index-DIBURJqf.d.ts → index-CWXKBva-.d.ts} +3 -3
  43. package/dist/{index-CVk4t5hk.d.ts → index-DS_4n2eb.d.ts} +1 -1
  44. package/dist/input.d.ts +4 -4
  45. package/dist/input.js +1 -1
  46. package/dist/{is-input-CEEoHxXN.js → is-input-CtUHJGgL.js} +1 -1
  47. package/dist/{is-input-CEEoHxXN.js.map → is-input-CtUHJGgL.js.map} +1 -1
  48. package/dist/llms.txt +1 -1
  49. package/dist/media-object.d.ts +1 -1
  50. package/dist/multi-select.d.ts +2 -2
  51. package/dist/multi-select.js +1 -1
  52. package/dist/multi-select.js.map +1 -1
  53. package/dist/otp-input.d.ts +2 -2
  54. package/dist/otp-input.js +1 -1
  55. package/dist/otp-input.js.map +1 -1
  56. package/dist/pagination.d.ts +3 -3
  57. package/dist/pagination.js +1 -1
  58. package/dist/{primitive-Ed9cel2r.d.ts → primitive-qkxTYBUY.d.ts} +1 -1
  59. package/dist/radio-group.d.ts +1 -1
  60. package/dist/radio-group.js +1 -1
  61. package/dist/radio-group.js.map +1 -1
  62. package/dist/{resolve-pre-rendered-props-DxvamgE6.d.ts → resolve-pre-rendered-props-BONSCwYA.d.ts} +1 -1
  63. package/dist/sandboxed-on-click.d.ts +1 -1
  64. package/dist/select-B7orOUPj.js +2 -0
  65. package/dist/select-B7orOUPj.js.map +1 -0
  66. package/dist/{select-8ymlL8kC.d.ts → select-SZFFzYs0.d.ts} +3 -3
  67. package/dist/select.d.ts +1 -1
  68. package/dist/select.js +1 -1
  69. package/dist/separator.d.ts +1 -1
  70. package/dist/sheet.d.ts +2 -2
  71. package/dist/slider.d.ts +17 -0
  72. package/dist/slider.js +1 -1
  73. package/dist/slider.js.map +1 -1
  74. package/dist/slot.d.ts +1 -1
  75. package/dist/split-button.d.ts +3 -3
  76. package/dist/{svg-only-CLbMy439.d.ts → svg-only-D4uqM1OC.d.ts} +2 -2
  77. package/dist/switch.d.ts +1 -1
  78. package/dist/{table-BWxS7pXj.d.ts → table-CjSQkfZe.d.ts} +1 -1
  79. package/dist/table.d.ts +1 -1
  80. package/dist/tabs.js +1 -1
  81. package/dist/text-area.d.ts +1 -1
  82. package/dist/theme.d.ts +2 -2
  83. package/dist/{themes-f2W5S6xS.d.ts → themes-FPux5kIu.d.ts} +1 -1
  84. package/dist/toast.d.ts +3 -3
  85. package/dist/{types-DnghL1WE.d.ts → types-QKZ5fvaQ.d.ts} +1 -1
  86. package/dist/types.d.ts +5 -5
  87. package/dist/{use-prefers-reduced-motion-YUurmkwx.js → use-prefers-reduced-motion-Bpx8G3UT.js} +1 -1
  88. package/dist/{use-prefers-reduced-motion-YUurmkwx.js.map → use-prefers-reduced-motion-Bpx8G3UT.js.map} +1 -1
  89. package/dist/utils.d.ts +2 -2
  90. package/dist/utils.js +1 -1
  91. package/dist/{validation-DF1z7YDr.d.ts → validation-CBSOmooP.d.ts} +1 -1
  92. package/dist/{variant-props-B4io4uA_.d.ts → variant-props-BZbM__kQ.d.ts} +2 -2
  93. package/dist/{with-style-props-CW8buMhK.d.ts → with-style-props-xzZLnIrF.d.ts} +1 -1
  94. package/package.json +1 -1
  95. package/dist/select-BBB_e15a.js +0 -2
  96. package/dist/select-BBB_e15a.js.map +0 -1
package/dist/field.d.ts CHANGED
@@ -1,14 +1,16 @@
1
- import { t as WithAsChild } from "./as-child-C2PttRwz.js";
2
- import { n as IconButtonProps } from "./icon-button-Dty-yfE2.js";
3
- import { a as ValidationState, c as parseValidation, i as ValidationProp, l as resolveValidation, n as ParsedValidation, o as WithValidation, r as Validation, s as isAriaInvalid, t as AriaInvalid } from "./validation-DF1z7YDr.js";
4
- import { t as Slot } from "./index-j46YISoN.js";
1
+ import { t as WithAsChild } from "./as-child-CpZKMqTE.js";
2
+ import { n as IconButtonProps } from "./icon-button-BDTb-lxs.js";
3
+ import { a as ValidationState, c as parseValidation, i as ValidationProp, l as resolveValidation, n as ParsedValidation, o as WithValidation, r as Validation, s as isAriaInvalid, t as AriaInvalid } from "./validation-CBSOmooP.js";
4
+ import { t as Slot } from "./index-BhlxYL_y.js";
5
5
  import * as _$react from "react";
6
6
  import { ComponentProps, ReactElement, ReactNode } from "react";
7
7
  import * as _$_radix_ui_react_popover0 from "@radix-ui/react-popover";
8
8
 
9
9
  //#region src/components/field/field-context.d.ts
10
10
  /**
11
- * ARIA props that `Field.Control` applies to the field's focusable control.
11
+ * ARIA and identity props that `Field.Control` applies to the field's
12
+ * focusable control. `id` and `name` come from the surrounding `Field.Item`
13
+ * so a caller only needs to declare `name` once.
12
14
  */
13
15
  type FieldControlAriaProps = {
14
16
  /**
@@ -23,6 +25,15 @@ type FieldControlAriaProps = {
23
25
  * The resolved ARIA invalid state for the focusable control.
24
26
  */
25
27
  "aria-invalid"?: ComponentProps<"input">["aria-invalid"];
28
+ /**
29
+ * Stable DOM id for the focusable control, generated by `Field.Item` and
30
+ * also used as `Field.Label`'s default `htmlFor`.
31
+ */
32
+ id?: string;
33
+ /**
34
+ * Form value identity from `Field.Item`'s required `name` prop.
35
+ */
36
+ name?: string;
26
37
  };
27
38
  /**
28
39
  * Context value owned by `Field.Item` and consumed by message/control parts.
@@ -46,16 +57,56 @@ type FieldErrorMessage = string | null | undefined | false;
46
57
  //#endregion
47
58
  //#region src/components/field/field.d.ts
48
59
  /**
49
- * Props for the `Field.Errors` convenience renderer. It owns its generated
50
- * children, so use `Field.ErrorList` / `Field.ErrorItem` directly when custom
51
- * list contents or polymorphic list markup are needed.
60
+ * A single form field — `Label`, a control (`Input`, `Select`, `Checkbox`,
61
+ * etc.), and any `Field.Description`, `Field.Errors`, or `Field.ErrorList` siblings stacked
62
+ * vertically with a consistent `gap-1.5` so help and error messaging sit
63
+ * tightly under the input.
64
+ *
65
+ * Renders a plain `<div>` — the `<label htmlFor>` ↔ control association
66
+ * already provides the right semantics for a single field, so no implicit
67
+ * `role` is added. `Field.Item` owns the contextual description/error IDs
68
+ * that `Field.Control` applies to the focusable control. Rendered errors
69
+ * infer an `"error"` validation state unless `validation` is supplied as an
70
+ * explicit override.
71
+ *
72
+ * **Single-slot constraint.** A `Field.Item` owns one description ID and one
73
+ * errors ID, so render at most one `Field.Description` and one
74
+ * `Field.Errors` *or* `Field.ErrorList` (not both) per item. A second instance
75
+ * would duplicate the slot `id` in the DOM. Pass multiple messages to
76
+ * `Field.Errors`, or multiple `Field.ErrorItem` children to `Field.ErrorList`,
77
+ * instead.
78
+ *
79
+ * @see https://mantle.ngrok.com/components/field
80
+ *
81
+ * @example
82
+ * ```tsx
83
+ * <Field.Group>
84
+ * <Field.Item name="apiKey">
85
+ * <Field.LabelRow>
86
+ * <Field.Label>
87
+ * API key <Field.Optional />
88
+ * </Field.Label>
89
+ * <Field.Help>
90
+ * <Field.HelpTrigger label="What is an API key?" />
91
+ * <Field.HelpContent>Copy this from the dashboard.</Field.HelpContent>
92
+ * </Field.Help>
93
+ * </Field.LabelRow>
94
+ * <Field.Control>
95
+ * <Input />
96
+ * </Field.Control>
97
+ * <Field.Errors messages={["API key is required."]} />
98
+ * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
99
+ * </Field.Item>
100
+ * </Field.Group>
101
+ * ```
52
102
  */
53
- type FieldErrorsProps = Omit<ComponentProps<"ul">, "children" | "id"> & {
103
+ type FieldItemProps = ComponentProps<"div"> & WithAsChild & WithValidation & {
54
104
  /**
55
- * Validation messages to render. Strings are trimmed, and empty, nullish,
56
- * or false values are ignored before rendering the list.
105
+ * Form-value name for the field. Required so `Field.Control` can splat
106
+ * it onto the focusable child while `Field.Item` owns the stable
107
+ * generated control id used by `Field.Label`'s `htmlFor`.
57
108
  */
58
- messages?: readonly FieldErrorMessage[];
109
+ name: string;
59
110
  };
60
111
  type FieldControlSlotProps = Omit<ComponentProps<typeof Slot>, "aria-describedby" | "aria-errormessage" | "aria-invalid" | "children">;
61
112
  /**
@@ -63,7 +114,7 @@ type FieldControlSlotProps = Omit<ComponentProps<typeof Slot>, "aria-describedby
63
114
  * any HTML/Slot props and a forwarded ref — those land on the single child
64
115
  * element along with the generated ARIA props.
65
116
  */
66
- type FieldControlElementProps = FieldControlSlotProps & WithValidation & {
117
+ type FieldControlElementProps = FieldControlSlotProps & {
67
118
  /**
68
119
  * A single control element to receive the field ARIA props.
69
120
  */
@@ -76,7 +127,7 @@ type FieldControlElementProps = FieldControlSlotProps & WithValidation & {
76
127
  * Slot props are marked `never` so passing e.g. `className` alongside a
77
128
  * render-prop child is a type error rather than a silently ignored prop.
78
129
  */
79
- type FieldControlRenderProps = WithValidation & {
130
+ type FieldControlRenderProps = {
80
131
  /**
81
132
  * A render function that places the field ARIA props onto a control of
82
133
  * the caller's choosing. Used for compound controls or wrappers where
@@ -84,6 +135,18 @@ type FieldControlRenderProps = WithValidation & {
84
135
  */
85
136
  children: (props: FieldControlAriaProps) => ReactNode;
86
137
  } & { [K in keyof FieldControlSlotProps]?: never };
138
+ /**
139
+ * Props for the `Field.Errors` convenience renderer. It owns its generated
140
+ * children, so use `Field.ErrorList` / `Field.ErrorItem` directly when custom
141
+ * list contents or polymorphic list markup are needed.
142
+ */
143
+ type FieldErrorsProps = Omit<ComponentProps<"ul">, "children" | "id"> & {
144
+ /**
145
+ * Validation messages to render. Strings are trimmed, and empty, nullish,
146
+ * or false values are ignored before rendering the list.
147
+ */
148
+ messages?: readonly FieldErrorMessage[];
149
+ };
87
150
  /**
88
151
  * Compound component for semantic, accessible form fields. Composes a
89
152
  * `Field.Label`, control (`Input`, `Select`, etc.), `Field.Description`, and
@@ -116,9 +179,9 @@ type FieldControlRenderProps = WithValidation & {
116
179
  * @example
117
180
  * ```tsx
118
181
  * <Field.Group>
119
- * <Field.Item>
182
+ * <Field.Item name="apiKey">
120
183
  * <Field.LabelRow>
121
- * <Field.Label htmlFor="api-key">
184
+ * <Field.Label>
122
185
  * API key <Field.Optional />
123
186
  * </Field.Label>
124
187
  * <Field.Help>
@@ -127,7 +190,7 @@ type FieldControlRenderProps = WithValidation & {
127
190
  * </Field.Help>
128
191
  * </Field.LabelRow>
129
192
  * <Field.Control>
130
- * <Input id="api-key" name="apiKey" />
193
+ * <Input />
131
194
  * </Field.Control>
132
195
  * <Field.Errors messages={["API key is required."]} />
133
196
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -145,9 +208,9 @@ declare const Field: {
145
208
  * @example
146
209
  * ```tsx
147
210
  * <Field.Group>
148
- * <Field.Item>
211
+ * <Field.Item name="apiKey">
149
212
  * <Field.LabelRow>
150
- * <Field.Label htmlFor="api-key">
213
+ * <Field.Label>
151
214
  * API key <Field.Optional />
152
215
  * </Field.Label>
153
216
  * <Field.Help>
@@ -156,7 +219,7 @@ declare const Field: {
156
219
  * </Field.Help>
157
220
  * </Field.LabelRow>
158
221
  * <Field.Control>
159
- * <Input id="api-key" name="apiKey" />
222
+ * <Input />
160
223
  * </Field.Control>
161
224
  * <Field.Errors messages={["API key is required."]} />
162
225
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -164,7 +227,7 @@ declare const Field: {
164
227
  * </Field.Group>
165
228
  * ```
166
229
  */
167
- readonly Item: _$react.ForwardRefExoticComponent<Omit<_$react.ClassAttributes<HTMLDivElement> & _$react.HTMLAttributes<HTMLDivElement> & WithAsChild & WithValidation, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
230
+ readonly Item: _$react.ForwardRefExoticComponent<Omit<FieldItemProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
168
231
  /**
169
232
  * Applies generated field ARIA props and validation state to a single
170
233
  * focusable control. Accepts either a single React element child (cloned
@@ -177,11 +240,11 @@ declare const Field: {
177
240
  *
178
241
  * @example
179
242
  * ```tsx
180
- * // Element child — Slot clones the generated ARIA props onto <Input/>.
181
- * <Field.Item>
182
- * <Field.Label htmlFor="api-key">API key</Field.Label>
243
+ * // Element child — Slot splats id, name, and ARIA props onto <Input/>.
244
+ * <Field.Item name="apiKey">
245
+ * <Field.Label>API key</Field.Label>
183
246
  * <Field.Control>
184
- * <Input id="api-key" name="apiKey" />
247
+ * <Input />
185
248
  * </Field.Control>
186
249
  * <Field.Errors messages={["API key is required."]} />
187
250
  * </Field.Item>
@@ -189,14 +252,14 @@ declare const Field: {
189
252
  *
190
253
  * @example
191
254
  * ```tsx
192
- * // Render-prop child — caller spreads the ARIA props onto an inner
193
- * // element when the focusable target is nested (e.g. inside a <label>).
194
- * <Field.Item>
255
+ * // Render-prop child — caller spreads the props onto an inner element
256
+ * // when the focusable target is nested (e.g. inside a <label>).
257
+ * <Field.Item name="acceptTerms">
195
258
  * <Field.Control>
196
- * {(ariaProps) => (
259
+ * {(controlProps) => (
197
260
  * <label>
198
261
  * Accept terms
199
- * <input type="checkbox" {...ariaProps} />
262
+ * <input type="checkbox" {...controlProps} />
200
263
  * </label>
201
264
  * )}
202
265
  * </Field.Control>
@@ -213,9 +276,9 @@ declare const Field: {
213
276
  * @example
214
277
  * ```tsx
215
278
  * <Field.Group>
216
- * <Field.Item>
279
+ * <Field.Item name="apiKey">
217
280
  * <Field.LabelRow>
218
- * <Field.Label htmlFor="api-key">
281
+ * <Field.Label>
219
282
  * API key <Field.Optional />
220
283
  * </Field.Label>
221
284
  * <Field.Help>
@@ -224,7 +287,7 @@ declare const Field: {
224
287
  * </Field.Help>
225
288
  * </Field.LabelRow>
226
289
  * <Field.Control>
227
- * <Input id="api-key" name="apiKey" />
290
+ * <Input />
228
291
  * </Field.Control>
229
292
  * <Field.Errors messages={["API key is required."]} />
230
293
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -269,16 +332,23 @@ declare const Field: {
269
332
  */
270
333
  readonly Legend: _$react.ForwardRefExoticComponent<Omit<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>, "ref"> & _$react.RefAttributes<HTMLLegendElement>>;
271
334
  /**
272
- * The Mantle `Label`, exposed on `Field` for field composition.
335
+ * The Mantle `Label`, exposed on `Field` for field composition. Inside a
336
+ * `Field.Item`, `htmlFor` defaults to the same stable id that `Field.Control`
337
+ * splats onto its focusable child — so the label-to-control association is
338
+ * automatic from `Field.Item`'s required `name` and you don't need to thread
339
+ * a matching `htmlFor` / `id` pair by hand. Pass an explicit `htmlFor` to
340
+ * opt out (e.g. when the focusable element is rendered outside of
341
+ * `Field.Control`).
273
342
  *
274
343
  * @see https://mantle.ngrok.com/components/label
275
344
  *
276
345
  * @example
277
346
  * ```tsx
347
+ * // htmlFor is wired automatically from Field.Item's name.
278
348
  * <Field.Group>
279
- * <Field.Item>
349
+ * <Field.Item name="apiKey">
280
350
  * <Field.LabelRow>
281
- * <Field.Label htmlFor="api-key">
351
+ * <Field.Label>
282
352
  * API key <Field.Optional />
283
353
  * </Field.Label>
284
354
  * <Field.Help>
@@ -287,7 +357,7 @@ declare const Field: {
287
357
  * </Field.Help>
288
358
  * </Field.LabelRow>
289
359
  * <Field.Control>
290
- * <Input id="api-key" name="apiKey" />
360
+ * <Input />
291
361
  * </Field.Control>
292
362
  * <Field.Errors messages={["API key is required."]} />
293
363
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -295,9 +365,9 @@ declare const Field: {
295
365
  * </Field.Group>
296
366
  * ```
297
367
  */
298
- readonly Label: _$react.ForwardRefExoticComponent<Omit<_$react.DetailedHTMLProps<_$react.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
368
+ readonly Label: _$react.ForwardRefExoticComponent<Omit<Omit<_$react.DetailedHTMLProps<_$react.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
299
369
  disabled?: boolean;
300
- } & _$react.RefAttributes<HTMLLabelElement>>;
370
+ } & _$react.RefAttributes<HTMLLabelElement>, "ref"> & _$react.RefAttributes<HTMLLabelElement>>;
301
371
  /**
302
372
  * Horizontal layout container for the label area of a field. Aligns a
303
373
  * `<Field.Label>` (which may contain `Field.Optional`) with adjacent affordances
@@ -308,9 +378,9 @@ declare const Field: {
308
378
  * @example
309
379
  * ```tsx
310
380
  * <Field.Group>
311
- * <Field.Item>
381
+ * <Field.Item name="apiKey">
312
382
  * <Field.LabelRow>
313
- * <Field.Label htmlFor="api-key">
383
+ * <Field.Label>
314
384
  * API key <Field.Optional />
315
385
  * </Field.Label>
316
386
  * <Field.Help>
@@ -319,7 +389,7 @@ declare const Field: {
319
389
  * </Field.Help>
320
390
  * </Field.LabelRow>
321
391
  * <Field.Control>
322
- * <Input id="api-key" name="apiKey" />
392
+ * <Input />
323
393
  * </Field.Control>
324
394
  * <Field.Errors messages={["API key is required."]} />
325
395
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -338,9 +408,9 @@ declare const Field: {
338
408
  * @example
339
409
  * ```tsx
340
410
  * <Field.Group>
341
- * <Field.Item>
411
+ * <Field.Item name="apiKey">
342
412
  * <Field.LabelRow>
343
- * <Field.Label htmlFor="api-key">
413
+ * <Field.Label>
344
414
  * API key <Field.Optional />
345
415
  * </Field.Label>
346
416
  * <Field.Help>
@@ -349,7 +419,7 @@ declare const Field: {
349
419
  * </Field.Help>
350
420
  * </Field.LabelRow>
351
421
  * <Field.Control>
352
- * <Input id="api-key" name="apiKey" />
422
+ * <Input />
353
423
  * </Field.Control>
354
424
  * <Field.Errors messages={["API key is required."]} />
355
425
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -368,9 +438,9 @@ declare const Field: {
368
438
  * @example
369
439
  * ```tsx
370
440
  * <Field.Group>
371
- * <Field.Item>
441
+ * <Field.Item name="apiKey">
372
442
  * <Field.LabelRow>
373
- * <Field.Label htmlFor="api-key">
443
+ * <Field.Label>
374
444
  * API key <Field.Optional />
375
445
  * </Field.Label>
376
446
  * <Field.Help>
@@ -379,7 +449,7 @@ declare const Field: {
379
449
  * </Field.Help>
380
450
  * </Field.LabelRow>
381
451
  * <Field.Control>
382
- * <Input id="api-key" name="apiKey" />
452
+ * <Input />
383
453
  * </Field.Control>
384
454
  * <Field.Errors messages={["API key is required."]} />
385
455
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -404,9 +474,9 @@ declare const Field: {
404
474
  * @example
405
475
  * ```tsx
406
476
  * <Field.Group>
407
- * <Field.Item>
477
+ * <Field.Item name="apiKey">
408
478
  * <Field.LabelRow>
409
- * <Field.Label htmlFor="api-key">
479
+ * <Field.Label>
410
480
  * API key <Field.Optional />
411
481
  * </Field.Label>
412
482
  * <Field.Help>
@@ -415,7 +485,7 @@ declare const Field: {
415
485
  * </Field.Help>
416
486
  * </Field.LabelRow>
417
487
  * <Field.Control>
418
- * <Input id="api-key" name="apiKey" />
488
+ * <Input />
419
489
  * </Field.Control>
420
490
  * <Field.Errors messages={["API key is required."]} />
421
491
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -437,9 +507,9 @@ declare const Field: {
437
507
  * @example
438
508
  * ```tsx
439
509
  * <Field.Group>
440
- * <Field.Item>
510
+ * <Field.Item name="apiKey">
441
511
  * <Field.LabelRow>
442
- * <Field.Label htmlFor="api-key">
512
+ * <Field.Label>
443
513
  * API key <Field.Optional />
444
514
  * </Field.Label>
445
515
  * <Field.Help>
@@ -448,7 +518,7 @@ declare const Field: {
448
518
  * </Field.Help>
449
519
  * </Field.LabelRow>
450
520
  * <Field.Control>
451
- * <Input id="api-key" name="apiKey" />
521
+ * <Input />
452
522
  * </Field.Control>
453
523
  * <Field.Errors messages={["API key is required."]} />
454
524
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -465,9 +535,9 @@ declare const Field: {
465
535
  * @example
466
536
  * ```tsx
467
537
  * <Field.Group>
468
- * <Field.Item>
538
+ * <Field.Item name="apiKey">
469
539
  * <Field.LabelRow>
470
- * <Field.Label htmlFor="api-key">
540
+ * <Field.Label>
471
541
  * API key <Field.Optional />
472
542
  * </Field.Label>
473
543
  * <Field.Help>
@@ -476,7 +546,7 @@ declare const Field: {
476
546
  * </Field.Help>
477
547
  * </Field.LabelRow>
478
548
  * <Field.Control>
479
- * <Input id="api-key" name="apiKey" />
549
+ * <Input />
480
550
  * </Field.Control>
481
551
  * <Field.Errors messages={["API key is required."]} />
482
552
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -495,9 +565,9 @@ declare const Field: {
495
565
  * @example
496
566
  * ```tsx
497
567
  * <Field.Group>
498
- * <Field.Item>
568
+ * <Field.Item name="apiKey">
499
569
  * <Field.LabelRow>
500
- * <Field.Label htmlFor="api-key">
570
+ * <Field.Label>
501
571
  * API key <Field.Optional />
502
572
  * </Field.Label>
503
573
  * <Field.Help>
@@ -506,7 +576,7 @@ declare const Field: {
506
576
  * </Field.Help>
507
577
  * </Field.LabelRow>
508
578
  * <Field.Control>
509
- * <Input id="api-key" name="apiKey" />
579
+ * <Input />
510
580
  * </Field.Control>
511
581
  * <Field.Errors messages={["API key is required."]} />
512
582
  * <Field.Description>You can find this in the ngrok dashboard.</Field.Description>
@@ -524,10 +594,10 @@ declare const Field: {
524
594
  * @example
525
595
  * ```tsx
526
596
  * <Field.Group>
527
- * <Field.Item>
528
- * <Field.Label htmlFor="username">Username</Field.Label>
597
+ * <Field.Item name="username">
598
+ * <Field.Label>Username</Field.Label>
529
599
  * <Field.Control>
530
- * <Input id="username" name="username" />
600
+ * <Input />
531
601
  * </Field.Control>
532
602
  * <Field.ErrorList>
533
603
  * <Field.ErrorItem>Must be at least 3 characters.</Field.ErrorItem>
@@ -548,10 +618,10 @@ declare const Field: {
548
618
  * @example
549
619
  * ```tsx
550
620
  * <Field.Group>
551
- * <Field.Item>
552
- * <Field.Label htmlFor="username">Username</Field.Label>
621
+ * <Field.Item name="username">
622
+ * <Field.Label>Username</Field.Label>
553
623
  * <Field.Control>
554
- * <Input id="username" name="username" />
624
+ * <Input />
555
625
  * </Field.Control>
556
626
  * <Field.ErrorList>
557
627
  * <Field.ErrorItem>Must be at least 3 characters.</Field.ErrorItem>
@@ -582,7 +652,8 @@ type FieldError = {
582
652
  * Handles the shapes TanStack form yields for Zod, Standard Schema, and
583
653
  * thrown `Error` validators: items may be strings, objects with `.message`,
584
654
  * `undefined`, `null`, or `false`. Empty / whitespace-only messages are
585
- * dropped so callers don't have to filter again.
655
+ * dropped and duplicate messages are collapsed so callers don't have to filter
656
+ * again.
586
657
  *
587
658
  * @example
588
659
  * ```tsx
package/dist/field.js CHANGED
@@ -1,2 +1,2 @@
1
- import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./slot-D_ZUrdEW.js";import{t as n}from"./icon-button-ZKN0sRIJ.js";import{i as r,n as i,r as a,t as o}from"./validation-BYME8rWN.js";import{t as s}from"./use-isomorphic-layout-effect-CNSD0lhi.js";import{t as c}from"./label-x6FcOpxc.js";import{t as l}from"./popover-CoZxokw_.js";import{Children as u,Fragment as d,cloneElement as f,createContext as p,forwardRef as m,isValidElement as h,useCallback as g,useContext as _,useId as v,useMemo as y,useState as b}from"react";import x from"tiny-invariant";import{jsx as S}from"react/jsx-runtime";import{QuestionIcon as C}from"@phosphor-icons/react/Question";const w=p(null),T=({"aria-invalid":e,context:t,validation:n})=>{let r=a({"aria-invalid":e,defaultAriaInvalid:!1,validation:n??t?.validation});return{ariaProps:{"aria-describedby":t?`${t.descriptionId} ${t.errorId}`:void 0,"aria-errormessage":r.isInvalid&&t?t.errorId:void 0,"aria-invalid":r.ariaInvalid},validation:r.validation}},E=e=>e?.map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)??[],D=e=>!(e==null||typeof e==`boolean`||typeof e==`string`&&e.trim().length===0),O=({children:e,errorItemType:t})=>{let n=!1;return u.forEach(e,e=>{if(!(n||e==null||typeof e==`boolean`)){if(typeof e==`string`){e.trim().length>0&&(n=!0);return}if(!h(e)){n=!0;return}if(e.type===t){n=D(e.props.children);return}if(e.type===d){n=O({children:e.props.children,errorItemType:t});return}n=!0}}),n},k=m(({className:t,...n},r)=>S(`fieldset`,{ref:r,"data-slot":`field-set`,className:e(`flex w-full min-w-0 flex-col gap-4 border-0 p-0`,t),...n}));k.displayName=`FieldSet`;const A=m(({className:t,...n},r)=>S(`legend`,{ref:r,"data-slot":`field-legend`,className:e(`text-strong mb-1.5 text-sm font-medium font-sans`,t),...n}));A.displayName=`FieldLegend`;const j=m(({asChild:n,className:r,...i},a)=>S(n?t:`div`,{ref:a,"data-slot":`field-label-row`,className:e(`flex items-center gap-1`,r),...i}));j.displayName=`FieldLabelRow`;const M=l.Root,N=m(({appearance:t=`ghost`,className:r,icon:i=S(C,{}),label:a,size:o=`xs`,type:s=`button`,...c},u)=>S(l.Trigger,{asChild:!0,children:S(n,{ref:u,appearance:t,className:e(`text-body -my-0.5`,r),icon:i,label:a,size:o,type:s,...c})}));N.displayName=`FieldHelpTrigger`;const P=m((e,t)=>S(l.Content,{ref:t,"data-slot":`field-help-content`,...e}));P.displayName=`FieldHelpContent`;const F=m(({asChild:n,children:r,className:i,...a},o)=>S(n?t:`span`,{ref:o,"data-slot":`field-optional`,className:e(`text-muted text-sm font-normal font-sans`,i),...a,children:r??`(Optional)`}));F.displayName=`FieldOptional`;const I=m(({asChild:n,className:r,...i},a)=>S(n?t:`div`,{ref:a,"data-slot":`field-group`,className:e(`flex w-full flex-col gap-4`,r),...i}));I.displayName=`FieldGroup`;const L=m(({asChild:n,children:i,className:a,validation:s,...c},l)=>{let u=n?t:`div`,d=v(),f=v(),[p,m]=b(!1),h=r(s??(p?`error`:void 0)),_=g(()=>(m(!0),()=>{m(!1)}),[]),x=y(()=>({descriptionId:d,errorId:f,hasErrors:p,registerError:_,validation:h}),[d,f,p,_,h]);return S(w.Provider,{value:x,children:S(o,{validation:h,children:S(u,{ref:l,"data-slot":`field-item`,"data-validation":h,className:e(`flex w-full flex-col gap-1.5`,a),...c,children:i})})})});L.displayName=`FieldItem`;const R=m(({children:e,validation:n,...r},i)=>{let a=_(w);if(typeof e==`function`){let t=T({context:a,validation:n});return S(o,{validation:t.validation,children:e(t.ariaProps)})}x(h(e),`Field.Control expects a single React element child (or a render-prop function). Got a non-element value (string, array, fragment, null, or undefined). Wrap the control in a single element, or use the function child form: <Field.Control>{(props) => <YourControl {...props} />}</Field.Control>.`);let s=T({"aria-invalid":e.props[`aria-invalid`],context:a,validation:n});return S(o,{validation:s.validation,children:S(t,{ref:i,...r,children:f(e,s.ariaProps)})})});R.displayName=`FieldControl`;const z=m(({asChild:n,className:r,...i},a)=>S(n?t:`p`,{ref:a,"data-slot":`field-description`,id:_(w)?.descriptionId,className:e(`text-body text-sm leading-4`,`[:where([data-slot=field-error-list]+&)]:-mt-1.5`,r),...i}));z.displayName=`FieldDescription`;const B=m(({children:t,className:n,...r},i)=>D(t)?S(`li`,{ref:i,"data-slot":`field-error`,className:e(`text-danger-600 text-sm leading-4`,n),...r,children:t}):null);B.displayName=`FieldErrorItem`;const V=m(({messages:e,...t},n)=>S(H,{ref:n,...t,children:E(e).map((e,t)=>S(B,{children:e},t))}));V.displayName=`FieldErrors`;const H=m(({asChild:n,children:r,className:i,...a},o)=>{let c=O({children:r,errorItemType:B}),l=_(w),u=l?.registerError;return s(()=>{if(!(!c||u==null))return u()},[c,u]),c?S(n?t:`ul`,{ref:o,"data-slot":`field-error-list`,id:l?.errorId,role:`list`,className:e(`m-0 flex w-full flex-col list-none p-0`,i),...a,children:r}):null});H.displayName=`FieldErrorList`;const U={Item:L,Control:R,Group:I,Set:k,Legend:A,Label:c,LabelRow:j,Help:M,HelpTrigger:N,HelpContent:P,Optional:F,Description:z,Errors:V,ErrorList:H,ErrorItem:B},W=e=>E(e?.map(e=>typeof e==`string`||!e?e:e.message));export{U as Field,i as isAriaInvalid,a as parseValidation,r as resolveValidation,W as toErrorMessages};
1
+ import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./slot-D_ZUrdEW.js";import{t as n}from"./icon-button-ZKN0sRIJ.js";import{i as r,n as i,r as a,t as o}from"./validation-BYME8rWN.js";import{t as s}from"./use-isomorphic-layout-effect-CNSD0lhi.js";import{t as c}from"./label-x6FcOpxc.js";import{t as l}from"./popover-CoZxokw_.js";import{n as u,r as d,t as f}from"./field-context-B7Z1cmZW.js";import{Children as p,Fragment as m,cloneElement as h,forwardRef as g,isValidElement as _,useCallback as v,useContext as y,useId as b,useMemo as x,useState as S}from"react";import C from"tiny-invariant";import{jsx as w}from"react/jsx-runtime";import{QuestionIcon as T}from"@phosphor-icons/react/Question";const E=e=>{let t=[],n=new Set;for(let r of e??[]){if(typeof r!=`string`)continue;let e=r.trim();e.length===0||n.has(e)||(n.add(e),t.push(e))}return t},D=e=>!(e==null||typeof e==`boolean`||typeof e==`string`&&e.trim().length===0),O=({children:e,errorItemType:t})=>{let n=!1;return p.forEach(e,e=>{if(!(n||e==null||typeof e==`boolean`)){if(typeof e==`string`){e.trim().length>0&&(n=!0);return}if(!_(e)){n=!0;return}if(e.type===t){n=D(e.props.children);return}if(e.type===m){n=O({children:e.props.children,errorItemType:t});return}n=!0}}),n},k=g(({className:t,...n},r)=>w(`fieldset`,{ref:r,"data-slot":`field-set`,className:e(`flex w-full min-w-0 flex-col gap-4 border-0 p-0`,t),...n}));k.displayName=`FieldSet`;const A=g(({className:t,...n},r)=>w(`legend`,{ref:r,"data-slot":`field-legend`,className:e(`text-strong mb-1.5 text-sm font-medium font-sans`,t),...n}));A.displayName=`FieldLegend`;const j=g(({htmlFor:e,...t},n)=>{let r=y(u);return w(c,{ref:n,htmlFor:e??r?.controlId,...t})});j.displayName=`FieldLabel`;const M=g(({asChild:n,className:r,...i},a)=>w(n?t:`div`,{ref:a,"data-slot":`field-label-row`,className:e(`flex items-center gap-1`,r),...i}));M.displayName=`FieldLabelRow`;const N=l.Root,P=g(({appearance:t=`ghost`,className:r,icon:i=w(T,{}),label:a,size:o=`xs`,type:s=`button`,...c},u)=>w(l.Trigger,{asChild:!0,children:w(n,{ref:u,appearance:t,className:e(`text-body -my-0.5`,r),icon:i,label:a,size:o,type:s,...c})}));P.displayName=`FieldHelpTrigger`;const F=g((e,t)=>w(l.Content,{ref:t,"data-slot":`field-help-content`,...e}));F.displayName=`FieldHelpContent`;const I=g(({asChild:n,children:r,className:i,...a},o)=>w(n?t:`span`,{ref:o,"data-slot":`field-optional`,className:e(`text-muted text-sm font-normal font-sans`,i),...a,children:r??`(Optional)`}));I.displayName=`FieldOptional`;const L=g(({asChild:n,className:r,...i},a)=>w(n?t:`div`,{ref:a,"data-slot":`field-group`,className:e(`flex w-full flex-col gap-4`,r),...i}));L.displayName=`FieldGroup`;const R=g(({asChild:n,children:i,className:a,name:s,validation:c,...l},d)=>{let f=n?t:`div`,p=b(),m=b(),h=b(),[g,_]=S(!1),y=r(c??(g?`error`:void 0)),C=v(()=>(_(!0),()=>{_(!1)}),[]),T=x(()=>({controlId:p,descriptionId:m,errorId:h,hasErrors:g,name:s,registerError:C,validation:y}),[p,m,h,g,s,C,y]);return w(u.Provider,{value:T,children:w(o,{validation:y,children:w(f,{ref:d,"data-slot":`field-item`,"data-validation":y,className:e(`flex w-full flex-col gap-1.5`,a),...l,children:i})})})});R.displayName=`FieldItem`;const z=g(({children:e,...n},r)=>{let i=y(u),a=d({context:i});return typeof e==`function`?w(o,{validation:a.validation,children:w(f.Provider,{value:i?a.ariaProps:null,children:e(a.ariaProps)})}):(C(_(e),`Field.Control expects a single React element child (or a render-prop function). Got a non-element value (string, array, fragment, null, or undefined). Wrap the control in a single element, or use the function child form: <Field.Control>{(props) => <YourControl {...props} />}</Field.Control>.`),w(o,{validation:a.validation,children:w(f.Provider,{value:i?a.ariaProps:null,children:w(t,{ref:r,...n,children:h(e,a.ariaProps)})})}))});z.displayName=`FieldControl`;const B=g(({asChild:n,className:r,...i},a)=>w(n?t:`p`,{ref:a,"data-slot":`field-description`,id:y(u)?.descriptionId,className:e(`text-body text-sm leading-4`,`[:where([data-slot=field-error-list]+&)]:-mt-1.5`,r),...i}));B.displayName=`FieldDescription`;const V=g(({children:t,className:n,...r},i)=>D(t)?w(`li`,{ref:i,"data-slot":`field-error`,className:e(`text-danger-600 text-sm leading-4`,n),...r,children:t}):null);V.displayName=`FieldErrorItem`;const H=g(({messages:e,...t},n)=>w(U,{ref:n,...t,children:E(e).map((e,t)=>w(V,{children:e},t))}));H.displayName=`FieldErrors`;const U=g(({asChild:n,children:r,className:i,...a},o)=>{let c=O({children:r,errorItemType:V}),l=y(u),d=l?.registerError;return s(()=>{if(!(!c||d==null))return d()},[c,d]),c?w(n?t:`ul`,{ref:o,"data-slot":`field-error-list`,id:l?.errorId,role:`list`,className:e(`m-0 flex w-full flex-col list-none p-0`,i),...a,children:r}):null});U.displayName=`FieldErrorList`;const W={Item:R,Control:z,Group:L,Set:k,Legend:A,Label:j,LabelRow:M,Help:N,HelpTrigger:P,HelpContent:F,Optional:I,Description:B,Errors:H,ErrorList:U,ErrorItem:V},G=e=>E(e?.map(e=>typeof e==`string`||!e?e:e.message));export{W as Field,i as isAriaInvalid,a as parseValidation,r as resolveValidation,G as toErrorMessages};
2
2
  //# sourceMappingURL=field.js.map