@agentero/design-system 0.33.0 → 0.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mcp/manifests/components.html +71 -10
- package/mcp/manifests/components.json +22 -8
- package/package.json +1 -1
- package/src/field/context.d.ts +6 -2
- package/src/field/field.d.ts +4 -2
- package/src/field/field.js +30 -27
- package/src/field/index.d.ts +1 -1
- package/src/field-text/field-text.d.ts +1 -1
- package/src/form-text/form-text.d.ts +4 -4
- package/src/form-text/form-text.js +2 -2
|
@@ -588,13 +588,13 @@
|
|
|
588
588
|
<header>
|
|
589
589
|
<div class="wrap">
|
|
590
590
|
<h1>Manifest Debugger</h1>
|
|
591
|
-
<div class="summary"><a class="filter-pill all" data-k="all" href="#filter-all">All</a><span class="filter-pill ok" aria-disabled="true">35 components ok</span><span class="filter-pill ok" aria-disabled="true">
|
|
591
|
+
<div class="summary"><a class="filter-pill all" data-k="all" href="#filter-all">All</a><span class="filter-pill ok" aria-disabled="true">35 components ok</span><span class="filter-pill ok" aria-disabled="true">288 stories ok</span></div>
|
|
592
592
|
</div>
|
|
593
593
|
</header>
|
|
594
594
|
<main>
|
|
595
595
|
<div class="wrap">
|
|
596
596
|
<div class="note ok" style="margin-bottom: 16px;">
|
|
597
|
-
Using <code>react-component-meta</code>. Generation took <strong>
|
|
597
|
+
Using <code>react-component-meta</code>. Generation took <strong>3.9s</strong>.
|
|
598
598
|
</div>
|
|
599
599
|
<h2 class="section-title">Components</h2>
|
|
600
600
|
<div class="grid" role="list">
|
|
@@ -3463,8 +3463,8 @@ rest of the page from assistive technology, label included, and a
|
|
|
3463
3463
|
</Combobox.List>
|
|
3464
3464
|
</Combobox.Content>
|
|
3465
3465
|
</Combobox.Root>
|
|
3466
|
-
<Field.Description>The agency this agent will be added to.</Field.Description>
|
|
3467
3466
|
<Field.Error errors={[{ message: 'Pick an agency from the list' }]} />
|
|
3467
|
+
<Field.Description>The agency this agent will be added to.</Field.Description>
|
|
3468
3468
|
</FieldText>
|
|
3469
3469
|
);</code></pre>
|
|
3470
3470
|
</div>
|
|
@@ -5217,7 +5217,7 @@ actions outright unless the user needs to see them and understand why.</div>
|
|
|
5217
5217
|
<div class="badges">
|
|
5218
5218
|
<label for="c-12-components-field-props" class="badge ok as-toggle">6 prop types</label>
|
|
5219
5219
|
|
|
5220
|
-
<label for="c-12-components-field-stories" class="badge ok as-toggle">
|
|
5220
|
+
<label for="c-12-components-field-stories" class="badge ok as-toggle">17 stories</label>
|
|
5221
5221
|
|
|
5222
5222
|
|
|
5223
5223
|
</div>
|
|
@@ -5241,8 +5241,8 @@ absent when there is none.</div>
|
|
|
5241
5241
|
<div class="kv"><span class="chip">summary: Wraps a label, control, description and error into one field</span><span class="chip">example: <Field.Root invalid={!!error} required>
|
|
5242
5242
|
<Field.Label>Email</Field.Label>
|
|
5243
5243
|
<Input type="email" />
|
|
5244
|
-
<Field.Description>We only use this for policy documents.</Field.Description>
|
|
5245
5244
|
<Field.Error errors={[error]} />
|
|
5245
|
+
<Field.Description>We only use this for policy documents.</Field.Description>
|
|
5246
5246
|
</Field.Root></span></div>
|
|
5247
5247
|
</div>
|
|
5248
5248
|
|
|
@@ -5492,6 +5492,37 @@ either, the control carries no `aria-describedby` at all.</div>
|
|
|
5492
5492
|
<DemoInput type="email" />
|
|
5493
5493
|
<Field.Error errors={[undefined]} />
|
|
5494
5494
|
</Field.Root>;</code></pre>
|
|
5495
|
+
</div>
|
|
5496
|
+
<div class="note ok">
|
|
5497
|
+
<div class="row">
|
|
5498
|
+
<span class="ex-name">Error Before Description</span>
|
|
5499
|
+
<span class="badge ok">story ok</span>
|
|
5500
|
+
</div>
|
|
5501
|
+
<div>Error announced before the description, whenever it appears</div>
|
|
5502
|
+
<div class="hint">The error sits right under the control and is announced before the
|
|
5503
|
+
description, even when it appears after the description is on screen and
|
|
5504
|
+
carries an `id` of its own.</div>
|
|
5505
|
+
<pre><code>const ErrorBeforeDescription = () => {
|
|
5506
|
+
const [error, setError] = useState<string>();
|
|
5507
|
+
|
|
5508
|
+
return (
|
|
5509
|
+
<div className="flex flex-col items-start gap-4">
|
|
5510
|
+
<Field.Root
|
|
5511
|
+
orientation="vertical"
|
|
5512
|
+
disabled={false}
|
|
5513
|
+
readOnly={false}
|
|
5514
|
+
required={false}
|
|
5515
|
+
invalid={!!error}>
|
|
5516
|
+
<Label>Tax ID</Label>
|
|
5517
|
+
<DemoInput inputMode="numeric" />
|
|
5518
|
+
<Field.Error id="tax-id-error">{error}</Field.Error>
|
|
5519
|
+
<Field.Description>Nine digits, with or without the dash.</Field.Description>
|
|
5520
|
+
</Field.Root>
|
|
5521
|
+
<button type="button" onClick={() => setError('Enter the tax ID.')}>Validate
|
|
5522
|
+
</button>
|
|
5523
|
+
</div>
|
|
5524
|
+
);
|
|
5525
|
+
};</code></pre>
|
|
5495
5526
|
</div>
|
|
5496
5527
|
<div class="note ok">
|
|
5497
5528
|
<div class="row">
|
|
@@ -5743,8 +5774,8 @@ and `name`, and `FieldContext` with the errors, as the last story shows.</div>
|
|
|
5743
5774
|
<div class="kv"><span class="chip">summary: Field for a single-line text control, wiring the Input inside it</span><span class="chip">example: <FieldText invalid={!!error} required>
|
|
5744
5775
|
<Label>Email</Label>
|
|
5745
5776
|
<Input type="email" />
|
|
5746
|
-
<Field.Description>We only use this for policy documents.</Field.Description>
|
|
5747
5777
|
<Field.Error errors={[error]} />
|
|
5778
|
+
<Field.Description>We only use this for policy documents.</Field.Description>
|
|
5748
5779
|
</FieldText></span></div>
|
|
5749
5780
|
</div>
|
|
5750
5781
|
|
|
@@ -6163,7 +6194,7 @@ Validation is react-hook-form's alone.</div>
|
|
|
6163
6194
|
<div class="badges">
|
|
6164
6195
|
<label for="c-15-components-formtext-props" class="badge ok as-toggle">15 prop types</label>
|
|
6165
6196
|
|
|
6166
|
-
<label for="c-15-components-formtext-stories" class="badge ok as-toggle">
|
|
6197
|
+
<label for="c-15-components-formtext-stories" class="badge ok as-toggle">10 stories</label>
|
|
6167
6198
|
|
|
6168
6199
|
|
|
6169
6200
|
</div>
|
|
@@ -6226,9 +6257,9 @@ control?: Control<FieldValues, any, unknown>
|
|
|
6226
6257
|
controlId?: string
|
|
6227
6258
|
|
|
6228
6259
|
/**
|
|
6229
|
-
* Helper text shown under the control
|
|
6230
|
-
* `aria-describedby`. Use it for guidance the
|
|
6231
|
-
* details worth a click in `tooltip` instead.
|
|
6260
|
+
* Helper text shown under the control, below the error when there is one,
|
|
6261
|
+
* and announced through its `aria-describedby`. Use it for guidance the
|
|
6262
|
+
* user needs before typing; put details worth a click in `tooltip` instead.
|
|
6232
6263
|
*/
|
|
6233
6264
|
description?: ReactNode
|
|
6234
6265
|
|
|
@@ -6442,6 +6473,36 @@ not mark the field required: that stays an explicit `required` prop.</div>
|
|
|
6442
6473
|
<Button type="submit">Save</Button>
|
|
6443
6474
|
</Form.Root>
|
|
6444
6475
|
);
|
|
6476
|
+
};</code></pre>
|
|
6477
|
+
</div>
|
|
6478
|
+
<div class="note ok">
|
|
6479
|
+
<div class="row">
|
|
6480
|
+
<span class="ex-name">Error And Description</span>
|
|
6481
|
+
<span class="badge ok">story ok</span>
|
|
6482
|
+
</div>
|
|
6483
|
+
<div>Error under the input, above the helper text</div>
|
|
6484
|
+
<div class="hint">The error sits right under the input and the description stays below it, so
|
|
6485
|
+
the message lands next to the value it is about. Screen readers announce
|
|
6486
|
+
them in the same order.</div>
|
|
6487
|
+
<pre><code>const ErrorAndDescription = () => {
|
|
6488
|
+
const methods = useForm<TaxValues>({ defaultValues: { taxId: '' } });
|
|
6489
|
+
|
|
6490
|
+
return (
|
|
6491
|
+
<Form.Root
|
|
6492
|
+
methods={methods}
|
|
6493
|
+
onSubmit={onSubmit}
|
|
6494
|
+
aria-label="Tax details"
|
|
6495
|
+
className="flex flex-col items-start gap-7">
|
|
6496
|
+
<FormText
|
|
6497
|
+
name="taxId"
|
|
6498
|
+
label="Tax ID"
|
|
6499
|
+
description="Nine digits, with or without the dash."
|
|
6500
|
+
rules={{ required: 'Enter the tax ID.' }}
|
|
6501
|
+
inputProps={{ inputMode: 'numeric', autoComplete: 'off' }}
|
|
6502
|
+
/>
|
|
6503
|
+
<Button type="submit">Save</Button>
|
|
6504
|
+
</Form.Root>
|
|
6505
|
+
);
|
|
6445
6506
|
};</code></pre>
|
|
6446
6507
|
</div>
|
|
6447
6508
|
<div class="note ok">
|
|
@@ -2850,7 +2850,7 @@
|
|
|
2850
2850
|
{
|
|
2851
2851
|
"id": "components-combobox--inside-field-text",
|
|
2852
2852
|
"name": "Inside Field Text",
|
|
2853
|
-
"snippet": "const InsideFieldText = () => (\n <FieldText invalid required>\n <Label>Agency</Label>\n <Combobox.Root items={STATES}>\n <Combobox.Input placeholder=\"Search agencies\" />\n <Combobox.Content>\n <Combobox.Empty>No matches found</Combobox.Empty>\n <Combobox.List>\n {(state: string) => (\n <Combobox.Item key={state} value={state}>\n {state}\n </Combobox.Item>\n )}\n </Combobox.List>\n </Combobox.Content>\n </Combobox.Root>\n <Field.
|
|
2853
|
+
"snippet": "const InsideFieldText = () => (\n <FieldText invalid required>\n <Label>Agency</Label>\n <Combobox.Root items={STATES}>\n <Combobox.Input placeholder=\"Search agencies\" />\n <Combobox.Content>\n <Combobox.Empty>No matches found</Combobox.Empty>\n <Combobox.List>\n {(state: string) => (\n <Combobox.Item key={state} value={state}>\n {state}\n </Combobox.Item>\n )}\n </Combobox.List>\n </Combobox.Content>\n </Combobox.Root>\n <Field.Error errors={[{ message: 'Pick an agency from the list' }]} />\n <Field.Description>The agency this agent will be added to.</Field.Description>\n </FieldText>\n);",
|
|
2854
2854
|
"description": "Dropped into a `FieldText`, the input takes the label, the description and\nthe error from the field with nothing wired by hand: `Combobox.Input` reads the\nsame `InputContext` the plain `Input` does. It also points `aria-labelledby`\nat the label, so the name survives the list opening: Base UI then hides the\nrest of the page from assistive technology, label included, and a\n`<label for>` alone would stop naming the input."
|
|
2855
2855
|
},
|
|
2856
2856
|
{
|
|
@@ -5295,7 +5295,7 @@
|
|
|
5295
5295
|
"Field for a single-line text control, wiring the Input inside it"
|
|
5296
5296
|
],
|
|
5297
5297
|
"example": [
|
|
5298
|
-
"<FieldText invalid={!!error} required>\n <Label>Email</Label>\n <Input type=\"email\" />\n <Field.Description>We only use this for policy documents.</Field.Description>\n
|
|
5298
|
+
"<FieldText invalid={!!error} required>\n <Label>Email</Label>\n <Input type=\"email\" />\n <Field.Error errors={[error]} />\n <Field.Description>We only use this for policy documents.</Field.Description>\n</FieldText>"
|
|
5299
5299
|
]
|
|
5300
5300
|
},
|
|
5301
5301
|
"description": "FieldText is a `Field.Root` for a single-line text control. It provides\n`InputContext`, so the `Input` inside associates itself with the label and\nthe messages and takes `invalid`, `required`, `disabled` and `readOnly` from\nthe field — no `id`, `htmlFor`, `aria-describedby` or `aria-invalid` written\nby hand.\n\nIt knows nothing about form libraries, and its contexts compose: a provider\nnested inside it can extend `InputContext` with `value`, `onChange`, `onBlur`\nand `name`, and `FieldContext` with the errors, as the last story shows.",
|
|
@@ -5310,7 +5310,7 @@
|
|
|
5310
5310
|
"Field for a single-line text control, wiring the Input inside it"
|
|
5311
5311
|
],
|
|
5312
5312
|
"example": [
|
|
5313
|
-
"<FieldText invalid={!!error} required>\n <Label>Email</Label>\n <Input type=\"email\" />\n <Field.Description>We only use this for policy documents.</Field.Description>\n
|
|
5313
|
+
"<FieldText invalid={!!error} required>\n <Label>Email</Label>\n <Input type=\"email\" />\n <Field.Error errors={[error]} />\n <Field.Description>We only use this for policy documents.</Field.Description>\n</FieldText>"
|
|
5314
5314
|
]
|
|
5315
5315
|
},
|
|
5316
5316
|
"props": {
|
|
@@ -5504,7 +5504,7 @@
|
|
|
5504
5504
|
"Wraps a label, control, description and error into one field"
|
|
5505
5505
|
],
|
|
5506
5506
|
"example": [
|
|
5507
|
-
"<Field.Root invalid={!!error} required>\n <Field.Label>Email</Field.Label>\n <Input type=\"email\" />\n <Field.Description>We only use this for policy documents.</Field.Description>\n
|
|
5507
|
+
"<Field.Root invalid={!!error} required>\n <Field.Label>Email</Field.Label>\n <Input type=\"email\" />\n <Field.Error errors={[error]} />\n <Field.Description>We only use this for policy documents.</Field.Description>\n</Field.Root>"
|
|
5508
5508
|
]
|
|
5509
5509
|
},
|
|
5510
5510
|
"description": "Field lays out a single form field — label, control, helper text and error —\nand wires the accessibility relationships between them. `Field.Root`\ngenerates the ids and shares them through context: `Label` reads\n`LabelContext`, `Field.Description` and `Field.Error` read `FieldContext`,\nand a `Field<X>` such as `FieldText` provides the control's context. Nobody\npasses an `id` by hand.\n\nPresentational and form-library agnostic: pass `invalid` and the error\nmessages from whatever validates the form. Spacing between fields belongs to\n`Field.Group`, never to a margin on the field itself.\n\n`Field.Description` and `Field.Error` register themselves with the root, so\nthe control's `aria-describedby` lists exactly the messages on screen and is\nabsent when there is none.",
|
|
@@ -5519,7 +5519,7 @@
|
|
|
5519
5519
|
"Wraps a label, control, description and error into one field"
|
|
5520
5520
|
],
|
|
5521
5521
|
"example": [
|
|
5522
|
-
"<Field.Root invalid={!!error} required>\n <Field.Label>Email</Field.Label>\n <Input type=\"email\" />\n <Field.Description>We only use this for policy documents.</Field.Description>\n
|
|
5522
|
+
"<Field.Root invalid={!!error} required>\n <Field.Label>Email</Field.Label>\n <Input type=\"email\" />\n <Field.Error errors={[error]} />\n <Field.Description>We only use this for policy documents.</Field.Description>\n</Field.Root>"
|
|
5523
5523
|
]
|
|
5524
5524
|
},
|
|
5525
5525
|
"props": {
|
|
@@ -5718,6 +5718,13 @@
|
|
|
5718
5718
|
"description": "`Field.Error` renders nothing without a message, so it can stay mounted and\nreceive `undefined` entries while the field is valid. With no description\neither, the control carries no `aria-describedby` at all.",
|
|
5719
5719
|
"summary": "Error stays mounted and renders nothing while valid"
|
|
5720
5720
|
},
|
|
5721
|
+
{
|
|
5722
|
+
"id": "components-field--error-before-description",
|
|
5723
|
+
"name": "Error Before Description",
|
|
5724
|
+
"snippet": "const ErrorBeforeDescription = () => {\n const [error, setError] = useState<string>();\n\n return (\n <div className=\"flex flex-col items-start gap-4\">\n <Field.Root\n orientation=\"vertical\"\n disabled={false}\n readOnly={false}\n required={false}\n invalid={!!error}>\n <Label>Tax ID</Label>\n <DemoInput inputMode=\"numeric\" />\n <Field.Error id=\"tax-id-error\">{error}</Field.Error>\n <Field.Description>Nine digits, with or without the dash.</Field.Description>\n </Field.Root>\n <button type=\"button\" onClick={() => setError('Enter the tax ID.')}>Validate\n </button>\n </div>\n );\n};",
|
|
5725
|
+
"description": "The error sits right under the control and is announced before the\ndescription, even when it appears after the description is on screen and\ncarries an `id` of its own.",
|
|
5726
|
+
"summary": "Error announced before the description, whenever it appears"
|
|
5727
|
+
},
|
|
5721
5728
|
{
|
|
5722
5729
|
"id": "components-field--disabled",
|
|
5723
5730
|
"name": "Disabled",
|
|
@@ -5795,7 +5802,7 @@
|
|
|
5795
5802
|
"displayName": "FormText",
|
|
5796
5803
|
"exportName": "FormText",
|
|
5797
5804
|
"filePath": "/home/runner/work/design-system/design-system/src/form-text/index.ts",
|
|
5798
|
-
"description": "A complete text field bound to one react-hook-form value: label, `Input`,\
|
|
5805
|
+
"description": "A complete text field bound to one react-hook-form value: label, `Input`,\nvalidation error and helper text, laid out in the standard order and wired\nthrough `useController`. It renders inside a `Form.Root`, which provides the\nform, and needs only a `name`, which on a typed form must point at a string\n(`FormTextPath`). The `required`, `invalid` and error states\nreach the label, the input's `aria-*` attributes and the message with no\nids written by hand.\n\nUse it for the common case: a labelled single-line input in a form. When\nthe layout is different — an input with addons, another control, a\nmessage rendered elsewhere — compose the primitives yourself:\n`useController` with [FieldText](?path=/docs/components-fieldtext--docs),\n`Label`, `Input`, `Field.Description` and `Field.Error`. `FormText` adds no\nbehaviour of its own over that composition.\n\nErrors come from `useController`'s per-field state, never from\n`formState.errors`, so the message stays fresh under the React Compiler.\nWith `criteriaMode: 'all'` on the form the error carries every rule that\nfailed and `Field.Error` lists them all. An error on an array or object path\n(`error.root`) is not this field's: render a `Field.Error` for it where the\ngroup lives.",
|
|
5799
5806
|
"jsDocTags": {
|
|
5800
5807
|
"summary": [
|
|
5801
5808
|
"Label, Input, description and error bound to one react-hook-form field"
|
|
@@ -6021,7 +6028,7 @@
|
|
|
6021
6028
|
"type": {
|
|
6022
6029
|
"name": "ReactNode"
|
|
6023
6030
|
},
|
|
6024
|
-
"description": "Helper text shown under the control
|
|
6031
|
+
"description": "Helper text shown under the control, below the error when there is one,\nand announced through its `aria-describedby`. Use it for guidance the\nuser needs before typing; put details worth a click in `tooltip` instead.",
|
|
6025
6032
|
"defaultValue": null,
|
|
6026
6033
|
"parent": {
|
|
6027
6034
|
"name": "FormTextProps",
|
|
@@ -6156,6 +6163,13 @@
|
|
|
6156
6163
|
"description": "`rules` are react-hook-form's, and `name` accepts nested paths typed against\nthe form's values through the generic. `rules.required` validates but does\nnot mark the field required: that stays an explicit `required` prop.",
|
|
6157
6164
|
"summary": "Nested path with validation rules, typed through the generic"
|
|
6158
6165
|
},
|
|
6166
|
+
{
|
|
6167
|
+
"id": "components-formtext--error-and-description",
|
|
6168
|
+
"name": "Error And Description",
|
|
6169
|
+
"snippet": "const ErrorAndDescription = () => {\n const methods = useForm<TaxValues>({ defaultValues: { taxId: '' } });\n\n return (\n <Form.Root\n methods={methods}\n onSubmit={onSubmit}\n aria-label=\"Tax details\"\n className=\"flex flex-col items-start gap-7\">\n <FormText\n name=\"taxId\"\n label=\"Tax ID\"\n description=\"Nine digits, with or without the dash.\"\n rules={{ required: 'Enter the tax ID.' }}\n inputProps={{ inputMode: 'numeric', autoComplete: 'off' }}\n />\n <Button type=\"submit\">Save</Button>\n </Form.Root>\n );\n};",
|
|
6170
|
+
"description": "The error sits right under the input and the description stays below it, so\nthe message lands next to the value it is about. Screen readers announce\nthem in the same order.",
|
|
6171
|
+
"summary": "Error under the input, above the helper text"
|
|
6172
|
+
},
|
|
6159
6173
|
{
|
|
6160
6174
|
"id": "components-formtext--all-errors",
|
|
6161
6175
|
"name": "All Errors",
|
|
@@ -9696,6 +9710,6 @@
|
|
|
9696
9710
|
},
|
|
9697
9711
|
"meta": {
|
|
9698
9712
|
"docgen": "react-component-meta",
|
|
9699
|
-
"durationMs":
|
|
9713
|
+
"durationMs": 3879
|
|
9700
9714
|
}
|
|
9701
9715
|
}
|
package/package.json
CHANGED
package/src/field/context.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type FieldErrorLike = {
|
|
|
11
11
|
*/
|
|
12
12
|
types?: Record<string, string | string[] | boolean | undefined>;
|
|
13
13
|
} | undefined;
|
|
14
|
+
/** What a registered message is, which sets its place in `aria-describedby`. */
|
|
15
|
+
export type FieldMessageKind = 'error' | 'description';
|
|
14
16
|
/**
|
|
15
17
|
* State of the surrounding `Field.Root`, shared with the Field family
|
|
16
18
|
* (`Field.Description`, `Field.Error`) and with controls that have no context
|
|
@@ -39,9 +41,11 @@ export type FieldContextValue = {
|
|
|
39
41
|
/**
|
|
40
42
|
* Adds a message element to `describedBy` and returns the function that
|
|
41
43
|
* removes it. `Field.Description` and `Field.Error` call it from a layout
|
|
42
|
-
* effect; a custom message element can do the same.
|
|
44
|
+
* effect; a custom message element can do the same. Errors are listed first,
|
|
45
|
+
* then descriptions, then messages registered without a `kind`, each in the
|
|
46
|
+
* order they registered.
|
|
43
47
|
*/
|
|
44
|
-
registerMessage: (id: string) => () => void;
|
|
48
|
+
registerMessage: (id: string, kind?: FieldMessageKind) => () => void;
|
|
45
49
|
invalid: boolean;
|
|
46
50
|
disabled: boolean;
|
|
47
51
|
readOnly: boolean;
|
package/src/field/field.d.ts
CHANGED
|
@@ -141,8 +141,8 @@ export type FieldRootProps = ComponentPropsWithRef<'div'> & {
|
|
|
141
141
|
* <Field.Root invalid={!!error} required>
|
|
142
142
|
* <Field.Label>Email</Field.Label>
|
|
143
143
|
* <Input type="email" />
|
|
144
|
-
* <Field.Description>We only use this for policy documents.</Field.Description>
|
|
145
144
|
* <Field.Error errors={[error]} />
|
|
145
|
+
* <Field.Description>We only use this for policy documents.</Field.Description>
|
|
146
146
|
* </Field.Root>
|
|
147
147
|
*/
|
|
148
148
|
export declare const Root: {
|
|
@@ -201,7 +201,9 @@ export declare const Description: {
|
|
|
201
201
|
};
|
|
202
202
|
/**
|
|
203
203
|
* Validation feedback for the field, announced as an alert when it appears.
|
|
204
|
-
*
|
|
204
|
+
* Place it right after the control, before `Field.Description`: the control's
|
|
205
|
+
* `aria-describedby` reads the error first as well. Renders nothing without a
|
|
206
|
+
* message, so it can stay mounted unconditionally;
|
|
205
207
|
* set `invalid` on `Field.Root` alongside it. Takes `children` or an `errors`
|
|
206
208
|
* array, and a form adapter can supply `errors` through `FieldContext` so a
|
|
207
209
|
* bare `<Field.Error />` renders them. One per field: it takes the field's
|
package/src/field/field.js
CHANGED
|
@@ -38,31 +38,34 @@ var m = s({
|
|
|
38
38
|
] }
|
|
39
39
|
} },
|
|
40
40
|
defaultVariants: { orientation: "vertical" }
|
|
41
|
-
}), h = m(), g = ({ className: t, ...n }) => /* @__PURE__ */ f("div", {
|
|
41
|
+
}), h = m(), g = (e) => e === "error" ? 0 : e === "description" ? 1 : 2, _ = ({ className: t, ...n }) => /* @__PURE__ */ f("div", {
|
|
42
42
|
"data-slot": "field-group",
|
|
43
43
|
className: e(h.group(), t),
|
|
44
44
|
...n
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
_.displayName = "Field.Group";
|
|
47
|
+
var v = ({ className: n, orientation: r = "vertical", invalid: a = !1, disabled: o = !1, readOnly: s = !1, required: u = !1, controlId: p, ...m }) => {
|
|
48
|
+
let _ = l(), v = p ?? `${_}-control`, y = `${_}-label`, b = `${_}-description`, x = `${_}-error`, [S, C] = d([]), w = c((e, t) => (C((n) => n.some((t) => t.id === e) ? n : [...n, {
|
|
49
|
+
id: e,
|
|
50
|
+
kind: t
|
|
51
|
+
}]), () => C((t) => t.filter((t) => t.id !== e))), []), T = {
|
|
52
|
+
controlId: v,
|
|
53
|
+
labelId: y,
|
|
54
|
+
descriptionId: b,
|
|
55
|
+
errorId: x,
|
|
56
|
+
describedBy: [...S].sort((e, t) => g(e.kind) - g(t.kind)).map((e) => e.id).join(" ") || void 0,
|
|
57
|
+
registerMessage: w,
|
|
55
58
|
invalid: a,
|
|
56
59
|
disabled: o,
|
|
57
60
|
readOnly: s,
|
|
58
61
|
required: u
|
|
59
62
|
};
|
|
60
63
|
return /* @__PURE__ */ f(i, {
|
|
61
|
-
value:
|
|
64
|
+
value: T,
|
|
62
65
|
children: /* @__PURE__ */ f(t, {
|
|
63
66
|
value: {
|
|
64
|
-
id:
|
|
65
|
-
htmlFor:
|
|
67
|
+
id: y,
|
|
68
|
+
htmlFor: v,
|
|
66
69
|
required: u || void 0
|
|
67
70
|
},
|
|
68
71
|
children: /* @__PURE__ */ f("div", {
|
|
@@ -77,14 +80,14 @@ var _ = ({ className: n, orientation: r = "vertical", invalid: a = !1, disabled:
|
|
|
77
80
|
})
|
|
78
81
|
});
|
|
79
82
|
};
|
|
80
|
-
|
|
81
|
-
var
|
|
83
|
+
v.displayName = "Field.Root";
|
|
84
|
+
var y = ({ className: t, ...n }) => /* @__PURE__ */ f("div", {
|
|
82
85
|
"data-slot": "field-content",
|
|
83
86
|
className: e(h.content(), t),
|
|
84
87
|
...n
|
|
85
88
|
});
|
|
86
|
-
|
|
87
|
-
var
|
|
89
|
+
y.displayName = "Field.Content";
|
|
90
|
+
var b = ({ tooltip: e, tooltipSide: t, ...i }) => /* @__PURE__ */ p("div", {
|
|
88
91
|
"data-slot": "field-label",
|
|
89
92
|
className: h.label(),
|
|
90
93
|
children: [/* @__PURE__ */ f(n, { ...i }), e && /* @__PURE__ */ f(r, {
|
|
@@ -100,23 +103,23 @@ var y = ({ tooltip: e, tooltipSide: t, ...i }) => /* @__PURE__ */ p("div", {
|
|
|
100
103
|
})
|
|
101
104
|
})]
|
|
102
105
|
});
|
|
103
|
-
|
|
104
|
-
var
|
|
106
|
+
b.displayName = "Field.Label";
|
|
107
|
+
var x = ({ className: t, id: n, ...r }) => {
|
|
105
108
|
let i = a(), o = n ?? i?.descriptionId, s = i?.registerMessage;
|
|
106
|
-
return u(() => o ? s?.(o) : void 0, [s, o]), /* @__PURE__ */ f("p", {
|
|
109
|
+
return u(() => o ? s?.(o, "description") : void 0, [s, o]), /* @__PURE__ */ f("p", {
|
|
107
110
|
"data-slot": "field-description",
|
|
108
111
|
id: o,
|
|
109
112
|
className: e(h.description(), t),
|
|
110
113
|
...r
|
|
111
114
|
});
|
|
112
115
|
};
|
|
113
|
-
|
|
114
|
-
var
|
|
116
|
+
x.displayName = "Field.Description";
|
|
117
|
+
var S = (e) => {
|
|
115
118
|
let t = Object.values(e?.types ?? {}).flat().filter((e) => typeof e == "string" && e.length > 0);
|
|
116
119
|
return t.length ? t : e?.message ? [e.message] : [];
|
|
117
|
-
},
|
|
118
|
-
let s = a(), c = i ?? s?.errorId, l = r ?? s?.errors, d = s?.registerMessage, p = [...new Set(l?.flatMap(
|
|
119
|
-
return u(() => g && c ? d?.(c) : void 0, [
|
|
120
|
+
}, C = ({ className: t, children: n, errors: r, id: i, ...o }) => {
|
|
121
|
+
let s = a(), c = i ?? s?.errorId, l = r ?? s?.errors, d = s?.registerMessage, p = [...new Set(l?.flatMap(S))], m = n ?? (p.length > 1 ? /* @__PURE__ */ f("ul", { children: p.map((e) => /* @__PURE__ */ f("li", { children: e }, e)) }) : p[0]), g = !!m;
|
|
122
|
+
return u(() => g && c ? d?.(c, "error") : void 0, [
|
|
120
123
|
d,
|
|
121
124
|
g,
|
|
122
125
|
c
|
|
@@ -129,6 +132,6 @@ var x = (e) => {
|
|
|
129
132
|
children: m
|
|
130
133
|
}) : null;
|
|
131
134
|
};
|
|
132
|
-
|
|
135
|
+
C.displayName = "Field.Error";
|
|
133
136
|
//#endregion
|
|
134
|
-
export {
|
|
137
|
+
export { y as Content, x as Description, C as Error, _ as Group, b as Label, v as Root, m as fieldRecipe };
|
package/src/field/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { fieldRecipe } from './field';
|
|
2
2
|
export { FieldContext, useFieldContext } from './context';
|
|
3
3
|
export type { FieldContentProps, FieldGroupProps, FieldLabelProps, FieldRootProps, FieldVariants } from './field';
|
|
4
|
-
export type { FieldContextValue, FieldDescriptionProps, FieldErrorLike, FieldErrorProps } from './context';
|
|
4
|
+
export type { FieldContextValue, FieldDescriptionProps, FieldErrorLike, FieldErrorProps, FieldMessageKind } from './context';
|
|
5
5
|
export declare const Field: {
|
|
6
6
|
Root: {
|
|
7
7
|
({ className, orientation, invalid, disabled, readOnly, required, controlId: controlIdProp, ...props }: import('./field').FieldRootProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,8 +18,8 @@ export type FieldTextProps = FieldRootProps;
|
|
|
18
18
|
* <FieldText invalid={!!error} required>
|
|
19
19
|
* <Label>Email</Label>
|
|
20
20
|
* <Input type="email" />
|
|
21
|
-
* <Field.Description>We only use this for policy documents.</Field.Description>
|
|
22
21
|
* <Field.Error errors={[error]} />
|
|
22
|
+
* <Field.Description>We only use this for policy documents.</Field.Description>
|
|
23
23
|
* </FieldText>
|
|
24
24
|
*/
|
|
25
25
|
export declare const FieldText: {
|
|
@@ -55,9 +55,9 @@ export type FormTextProps<TFieldValues extends FieldValues = FieldValues, TName
|
|
|
55
55
|
/** The caption, rendered as the field's label. Text in almost every case. */
|
|
56
56
|
label: ReactNode;
|
|
57
57
|
/**
|
|
58
|
-
* Helper text shown under the control
|
|
59
|
-
* `aria-describedby`. Use it for guidance the
|
|
60
|
-
* details worth a click in `tooltip` instead.
|
|
58
|
+
* Helper text shown under the control, below the error when there is one,
|
|
59
|
+
* and announced through its `aria-describedby`. Use it for guidance the
|
|
60
|
+
* user needs before typing; put details worth a click in `tooltip` instead.
|
|
61
61
|
*/
|
|
62
62
|
description?: ReactNode;
|
|
63
63
|
/**
|
|
@@ -96,7 +96,7 @@ export type FormTextProps<TFieldValues extends FieldValues = FieldValues, TName
|
|
|
96
96
|
};
|
|
97
97
|
/**
|
|
98
98
|
* A complete text field bound to one react-hook-form value: label, `Input`,
|
|
99
|
-
*
|
|
99
|
+
* validation error and helper text, laid out in the standard order and wired
|
|
100
100
|
* through `useController`. It renders inside a `Form.Root`, which provides the
|
|
101
101
|
* form, and needs only a `name`, which on a typed form must point at a string
|
|
102
102
|
* (`FormTextPath`). The `required`, `invalid` and error states
|
|
@@ -30,8 +30,8 @@ var s = ({ name: s, control: c, rules: l, shouldUnregister: u, disabled: d, labe
|
|
|
30
30
|
children: f
|
|
31
31
|
}), /* @__PURE__ */ a(t.Content, { children: [
|
|
32
32
|
/* @__PURE__ */ i(n, { ...e(x, _ ?? {}) }),
|
|
33
|
-
|
|
34
|
-
/* @__PURE__ */ i(t.
|
|
33
|
+
/* @__PURE__ */ i(t.Error, { errors: b.error ? [b.error] : void 0 }),
|
|
34
|
+
p && /* @__PURE__ */ i(t.Description, { children: p })
|
|
35
35
|
] })]
|
|
36
36
|
});
|
|
37
37
|
};
|