@namroodinc/liquid-editorial 0.3.3 → 0.4.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/AGENTS.md +4 -0
- package/README.md +19 -8
- package/UPGRADING.md +155 -0
- package/dist/chunks/ColourField-CJicr3OT.cjs +2 -0
- package/dist/chunks/ColourField-CJicr3OT.cjs.map +1 -0
- package/dist/chunks/{ColourField-Bd4twbaG.js → ColourField-DjHRiFDU.js} +74 -62
- package/dist/chunks/ColourField-DjHRiFDU.js.map +1 -0
- package/dist/chunks/DatePicker-D_6CQpUd.js +296 -0
- package/dist/chunks/DatePicker-D_6CQpUd.js.map +1 -0
- package/dist/chunks/DatePicker-aSlYLjtW.cjs +2 -0
- package/dist/chunks/DatePicker-aSlYLjtW.cjs.map +1 -0
- package/dist/chunks/FormEditor-CaskinQ1.js +586 -0
- package/dist/chunks/FormEditor-CaskinQ1.js.map +1 -0
- package/dist/chunks/FormEditor-DDylpJ9O.cjs +2 -0
- package/dist/chunks/FormEditor-DDylpJ9O.cjs.map +1 -0
- package/dist/chunks/Slider-k8weRl34.cjs +2 -0
- package/dist/chunks/Slider-k8weRl34.cjs.map +1 -0
- package/dist/chunks/Slider-vdMFLX-H.js +174 -0
- package/dist/chunks/Slider-vdMFLX-H.js.map +1 -0
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.d.cts.map +1 -1
- package/dist/components/Choice/index.d.ts.map +1 -1
- package/dist/components/Choice/index.js +2 -0
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.d.cts.map +1 -1
- package/dist/components/ColourField/index.d.ts.map +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/ColourField/value.d.cts +6 -0
- package/dist/components/ColourField/value.d.cts.map +1 -1
- package/dist/components/ColourField/value.d.ts +6 -0
- package/dist/components/ColourField/value.d.ts.map +1 -1
- package/dist/components/DatePicker/date.d.cts +9 -0
- package/dist/components/DatePicker/date.d.cts.map +1 -0
- package/dist/components/DatePicker/date.d.ts +9 -0
- package/dist/components/DatePicker/date.d.ts.map +1 -0
- package/dist/components/DatePicker/index.cjs +1 -2
- package/dist/components/DatePicker/index.d.cts +9 -6
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts +9 -6
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +1 -259
- package/dist/components/DatePicker/style.css +5 -0
- package/dist/components/Field/style.css +20 -0
- package/dist/components/FormEditor/README.md +375 -0
- package/dist/components/FormEditor/additional-control.d.cts +6 -0
- package/dist/components/FormEditor/additional-control.d.cts.map +1 -0
- package/dist/components/FormEditor/additional-control.d.ts +6 -0
- package/dist/components/FormEditor/additional-control.d.ts.map +1 -0
- package/dist/components/FormEditor/choice-control.d.cts +6 -0
- package/dist/components/FormEditor/choice-control.d.cts.map +1 -0
- package/dist/components/FormEditor/choice-control.d.ts +6 -0
- package/dist/components/FormEditor/choice-control.d.ts.map +1 -0
- package/dist/components/FormEditor/control.d.cts +8 -0
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts +8 -0
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +70 -2
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +70 -2
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/style.css +12 -0
- package/dist/components/Grid/style.css +2 -1
- package/dist/components/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.js +6 -6
- package/dist/components/ImageCropper/index.js.map +1 -1
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +4 -0
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts +2 -0
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.d.cts.map +1 -1
- package/dist/components/SelectionCard/index.d.ts.map +1 -1
- package/dist/components/SelectionCard/index.js +2 -1
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/Slider/index.cjs +1 -2
- package/dist/components/Slider/index.d.cts +14 -1
- package/dist/components/Slider/index.d.cts.map +1 -1
- package/dist/components/Slider/index.d.ts +14 -1
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js +1 -127
- package/dist/components/Slider/scale.d.cts +13 -0
- package/dist/components/Slider/scale.d.cts.map +1 -0
- package/dist/components/Slider/scale.d.ts +13 -0
- package/dist/components/Slider/scale.d.ts.map +1 -0
- package/dist/elements.css +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -20
- package/dist/reset.css +2 -0
- package/dist/styles.css +1 -0
- package/package.json +1 -1
- package/dist/chunks/ColourField-Bd4twbaG.js.map +0 -1
- package/dist/chunks/ColourField-BdAbjgmY.cjs +0 -2
- package/dist/chunks/ColourField-BdAbjgmY.cjs.map +0 -1
- package/dist/chunks/FormEditor-DRmPFe2E.js +0 -328
- package/dist/chunks/FormEditor-DRmPFe2E.js.map +0 -1
- package/dist/chunks/FormEditor-PVkvKep1.cjs +0 -2
- package/dist/chunks/FormEditor-PVkvKep1.cjs.map +0 -1
- package/dist/components/DatePicker/index.cjs.map +0 -1
- package/dist/components/DatePicker/index.js.map +0 -1
- package/dist/components/Slider/index.cjs.map +0 -1
- package/dist/components/Slider/index.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Contributing to this library
|
|
4
4
|
|
|
5
|
+
For FormEditor work, first read [the FormEditor agent reference](src/components/FormEditor/README.md). Keep its options, defaults, examples, value contracts, and architecture map current whenever FormEditor changes. Every new shared form control must receive a FormEditor adapter or have its exclusion explained in its decision document.
|
|
6
|
+
|
|
5
7
|
Add a decision document for every change going forward.
|
|
6
8
|
|
|
7
9
|
End every completed change handoff with a suggested Git commit subject and description in a copyable code block. Summarize the final change set and relevant verification.
|
|
@@ -12,4 +14,6 @@ Every releasable change set must update the `Unreleased` section in `UPGRADING.m
|
|
|
12
14
|
|
|
13
15
|
## Using the installed package
|
|
14
16
|
|
|
17
|
+
For FormEditor integration, read [the packaged FormEditor reference](dist/components/FormEditor/README.md). It documents supported schema options, stored values, validation, and application responsibilities.
|
|
18
|
+
|
|
15
19
|
For agents working in a consuming project: read `UPGRADING.md` beside this file in the installed package. Review every entry between the project's previous package version and the newly installed version, apply the relevant adoption steps in the consuming project, and run its verification checks. The contributor rules above apply to this library's source repository.
|
package/README.md
CHANGED
|
@@ -363,7 +363,7 @@ export function HelpPopover() {
|
|
|
363
363
|
}
|
|
364
364
|
```
|
|
365
365
|
|
|
366
|
-
The caller owns opening, closing, keyboard/focus semantics, and outside-click handling. A Modal or Drawer containing the anchor treats the open panel as its own, leaving Tab inside it to the panel. Use Menu, Select, Modal, or Drawer when their interactions fit. `matchAnchorWidth` suits listboxes; tall panels scroll without losing their scroll position during repositioning.
|
|
366
|
+
The caller owns opening, closing, keyboard/focus semantics, and outside-click handling. Pass `tabIndex={-1}` to a dialog panel so a click on its non-interactive content keeps focus inside it, where the caller's Escape handling still runs. A Modal or Drawer containing the anchor treats the open panel as its own, leaving Tab inside it to the panel. Use Menu, Select, Modal, or Drawer when their interactions fit. `matchAnchorWidth` suits listboxes; tall panels scroll without losing their scroll position during repositioning.
|
|
367
367
|
|
|
368
368
|
### Toast
|
|
369
369
|
|
|
@@ -791,7 +791,7 @@ import { Field, RangeSlider, Slider } from "@namroodinc/liquid-editorial";
|
|
|
791
791
|
</>;
|
|
792
792
|
```
|
|
793
793
|
|
|
794
|
-
Use `value`/`onValueChange` for controlled values, `isDisabled` to disable, and `hasValueLabel={false}` to hide printed values. Bind range sliders to a group Field and keep both member names.
|
|
794
|
+
Use `value`/`onValueChange` for controlled values, `isDisabled` to disable, and `hasValueLabel={false}` to hide printed values. `valueText` replaces the printed number (both numbers on RangeSlider) and is announced as `aria-valuetext`, for example `"Not set"` or `"Medium"`. `onValueCommit` reports the shown value after a click or step key on a thumb, even when it did not move, which lets a fallback position be accepted. RangeSlider's `hasFill={false}` leaves the span between the thumbs unpainted, so no range reads as chosen. Range thumbs stay exactly one step apart, including decimal steps such as `0.1`. Bind range sliders to a group Field and keep both member names.
|
|
795
795
|
|
|
796
796
|
### SearchField
|
|
797
797
|
|
|
@@ -849,7 +849,7 @@ export function PublicationSelect() {
|
|
|
849
849
|
}
|
|
850
850
|
```
|
|
851
851
|
|
|
852
|
-
Use `defaultValue` for uncontrolled selection, `placeholder` for an empty display, and `isDisabled`/`isInvalid` for field states. The default menu placement is bottom; top preference and automatic flipping are supported. An `aria-labelledby` binding also names its listbox. Select emits through `onValueChange`; adapt it explicitly when constructing submitted form data.
|
|
852
|
+
Use `defaultValue` for uncontrolled selection, `placeholder` for an empty display, and `isDisabled`/`isInvalid` for field states. Its trigger uses the shared `--field-radius`, matching text and colour fields; the floating menu uses the shared overlay radius. The default menu placement is bottom; top preference and automatic flipping are supported. An `aria-labelledby` binding also names its listbox. Select emits through `onValueChange`; adapt it explicitly when constructing submitted form data.
|
|
853
853
|
|
|
854
854
|
### Switch
|
|
855
855
|
|
|
@@ -931,7 +931,7 @@ export function Dates() {
|
|
|
931
931
|
}
|
|
932
932
|
```
|
|
933
933
|
|
|
934
|
-
Fields support `defaultValue`, sizes `sm`/`md`/`lg` (default `md`), `min`/`max`, and `isDisabled`. Placement defaults to bottom and can prefer top. Calendar uses `value`/`onSelect`; supply `endValue` to highlight a range. The app owns range-selection logic for a standalone Calendar. These date-only values differ from FormEditor's UTC `dateTime` values.
|
|
934
|
+
Fields support `defaultValue`, sizes `sm`/`md`/`lg` (default `md`), `min`/`max`, and `isDisabled`. Placement defaults to bottom and can prefer top. Opt into `isClearable` on DateField or DateRangeField; DateField also accepts `clearLabel` (default `"Clear date"`). Opening focuses the selected day, or today when the value is empty or invalid, moved inside `min`/`max`; that day is also the arrow-key starting point. Escape closes the calendar and restores its trigger without closing an enclosing dialog, including after a click on the calendar's heading or padding. Calendar uses `value`/`onSelect`; supply `endValue` to highlight a range. The app owns range-selection logic for a standalone Calendar. These date-only values differ from FormEditor's UTC `dateTime` values.
|
|
935
935
|
|
|
936
936
|
### TagsInput
|
|
937
937
|
|
|
@@ -1002,7 +1002,7 @@ Values emit as uppercase `#RRGGBB` or `#RRGGBBAA` with transparency. Clearing te
|
|
|
1002
1002
|
|
|
1003
1003
|
Use `defaultValue` for local state, `picker="native"` for OS selection, and `showPresets={false}` to hide supplied presets. Custom is the default picker. Both modes retain an opacity slider. Native selection and the optional supported screen eyedropper preserve opacity; presets replace the whole colour. The custom panel supports pointer/keyboard adjustments and remembers hue through grey/black.
|
|
1004
1004
|
|
|
1005
|
-
ColourField supports normal textbox props, refs, `size`, `readOnly`, `isDisabled`, `isInvalid`, and `placement="top"`/`"bottom"` (default bottom). The swatch is a pointer shortcut and the chevron is the picker tab stop. FormEditor
|
|
1005
|
+
ColourField supports normal textbox props, refs, `size`, `readOnly`, `isDisabled`, `isInvalid`, and `placement="top"`/`"bottom"` (default bottom). The swatch is a pointer shortcut and the chevron is the picker tab stop. Escape closes the picker and restores its opener without closing an enclosing Modal or Drawer, including after a click on the picker's padding or labels. FormEditor exposes it through `type: "colour"`.
|
|
1006
1006
|
|
|
1007
1007
|
### EntryPicker
|
|
1008
1008
|
|
|
@@ -1072,6 +1072,8 @@ Links open a URL modal from the toolbar or an existing body link. Saving preserv
|
|
|
1072
1072
|
|
|
1073
1073
|
### FormEditor
|
|
1074
1074
|
|
|
1075
|
+
The [FormEditor reference for agents](src/components/FormEditor/README.md) contains every schema option, default, value shape, examples, and the extension checklist. Installed packages include the same guide at `dist/components/FormEditor/README.md` ([packaged reference](dist/components/FormEditor/README.md)). Read it before integrating or extending the editor.
|
|
1076
|
+
|
|
1075
1077
|
`FormEditor` renders standard fields in schema order. Applications own state, choice loading, permissions, submission, and persistence:
|
|
1076
1078
|
|
|
1077
1079
|
```tsx
|
|
@@ -1086,6 +1088,7 @@ import {
|
|
|
1086
1088
|
const schema: FormSchema = {
|
|
1087
1089
|
fields: [
|
|
1088
1090
|
{ id: "title", type: "shortText", label: "Title", required: true },
|
|
1091
|
+
{ id: "status", type: "select", label: "Status", options: [{ value: "draft", label: "Draft" }, { value: "published", label: "Published" }] },
|
|
1089
1092
|
{ id: "gallery", type: "asset", label: "Gallery", multiple: true },
|
|
1090
1093
|
],
|
|
1091
1094
|
};
|
|
@@ -1105,14 +1108,22 @@ export function ContentEditor() {
|
|
|
1105
1108
|
// Before saving: validateFormValues(schema, value) returns errors keyed by field ID.
|
|
1106
1109
|
```
|
|
1107
1110
|
|
|
1108
|
-
Supported types are `shortText`, `longText`, `richText`, `number`, `boolean`, `dateTime`, `asset`, `reference`,
|
|
1111
|
+
Supported field types are `shortText`, `longText`, `richText`, `number`, `boolean`, `dateTime`, `asset`, `reference`, `select`, `slider`, `rangeSlider`, `colour`, `radioGroup`, `checkboxGroup`, `tags`, and `date`. Rich text stores a TipTap JSON document rooted at `doc`. Date-times use UTC ISO strings ending in `Z`; calendar dates use `YYYY-MM-DD`. Assets store `{ assetId }`; references store `{ entryId }`. Set `multiple: true` for an ordered array of these objects. `FormItem` includes value-bearing `FormField` and layout-only `FormDivider`: add `{ id: "section-rule", type: "divider" }` to span all columns without creating a value or validation error.
|
|
1112
|
+
|
|
1113
|
+
Radio and checkbox fields are groups, including when `options` contains one item. Set `appearance: "default" | "card"` and optional `columns: 1 | 2 | 3`. Options use `{ value, label, description?, isDisabled? }`. Radios store a string; checkboxes and tags store string arrays. Required groups need a selection; existing boolean switches still accept `false`. Range sliders store `{ min, max }` numbers. Colour fields support presets, alpha, and custom/native pickers, emitting canonical hex for valid edits and retaining invalid drafts for form validation.
|
|
1114
|
+
|
|
1115
|
+
**Select dropdowns** use `type: "select"` with `options: [{ value, label }]`. **Group option columns** use `columns: 1 | 2 | 3` on each `radioGroup` or `checkboxGroup` field, with either appearance. This controls options per row within that group; `<FormEditor columns={...}>` controls whole fields per row. Standalone ChoiceGroup and SelectionCardGroup also accept a `columns` prop. See the [agent guide examples](src/components/FormEditor/README.md#columns-within-each-group) and the FormEditor **GroupColumns** story for a live demonstration.
|
|
1109
1116
|
|
|
1110
|
-
|
|
1117
|
+
**Date picker types:** `date` renders the shared custom calendar popover and stores a day such as `"2026-11-02"`. `dateTime` renders the browser's native date-and-time input and stores a UTC timestamp such as `"2026-11-02T09:00:00.000Z"`; its label includes `(UTC)`. The native picker varies by browser/OS. Choose the type for the value your application needs.
|
|
1111
1118
|
|
|
1112
|
-
|
|
1119
|
+
Use `defaultValue` for an uncontrolled editor, `errors` for app-specific messages, `showAllErrors` after a submit attempt, and `isDisabled` to disable editing. Required and format errors appear after a field changes; loaded numeric, slider, range, calendar-date and colour fields validate immediately, except blank date and colour strings, which wait like other empty fields. `false` and `0` are populated values. Missing keys render controls without emitting changes; sliders show fallback positions without storing them. An unset slider or range slider prints `placeholder` or `"Not set"` (an unset range also has no fill) until a click or arrow key on a thumb stores the shown position or full range. Loaded slider values outside the scale, or reversed ranges, are drawn clamped and ordered while validation still reports them. Clearing a number, date, colour, select, radio group or single picker removes its key; empty text, rich-text documents and lists keep their shapes. Unrelated keys are preserved. Validation runs per field and is reused until that field or its value changes, so define schemas outside render or memoize them.
|
|
1120
|
+
|
|
1121
|
+
General forms can use select fields with `options: [{ value, label }]`, per-field `isDisabled`, and React-node hints. Optional selects lead with an empty choice, labelled with the field's `placeholder` or "None", that clears the value. Pass `options: []` while choices load; a stored value stays valid until they arrive. Text fields support `maxLength` and `readOnly`; short text also supports `inputType: "email"`, long text supports `rows`, and numeric fields support `min`, `max`, `step`, and `hasSteppers`. Steppers are named after their field, such as "Increase Width". `validateFormValues` enforces `maxLength`, numeric limits, and `picker.max`. `autoFocus` applies to text, number, select, boolean, UTC date-time, slider, and colour fields.
|
|
1113
1122
|
|
|
1114
1123
|
`columns` sets the most columns and defaults to one. The form drops a column whenever a field would be narrower than `minColumnWidth` (default `16rem`), measured against the form's own width, so it steps down inside drawers and modals. Use `columns="auto"` to fit as many columns as the width allows. FormEditor is not a size container, so it keeps its content width in flex rows and popovers.
|
|
1115
1124
|
|
|
1125
|
+
Plain `hr` elements use a single theme-aware muted border through `--rule-width` and `--rule-color`. This style is included in `styles.css` and the optional reset. FormEditor separators use the form's grid gap instead of their global block margins.
|
|
1126
|
+
|
|
1116
1127
|
Changes emit `onValueChange(nextValues, { fieldId })`. Use the changed field ID when adapting to APIs that accept patches, generated IDs, or dependent values. Runtime form schemas can hold JSX and live choices, so keep them separate from persisted content definitions. Picker field options such as `picker: { itemLabel: "image", itemsLabel: "images" }` provide contextual search and selection copy without putting data access in the library. `picker.label` overrides the field's name: its legend, accessible name, default "Choose …" action and required message. Omitted or `undefined` item and action options keep the asset or entry wording.
|
|
1117
1128
|
|
|
1118
1129
|
## Layout
|
package/UPGRADING.md
CHANGED
|
@@ -2,6 +2,161 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.4.1
|
|
6
|
+
|
|
7
|
+
### FormEditor number affixes
|
|
8
|
+
|
|
9
|
+
Number schema fields accept optional string `prefix` and `suffix`, forwarded to
|
|
10
|
+
the existing NumberField affixes. Values remain finite numbers; affixes are
|
|
11
|
+
presentation only. Existing schemas need no changes. Verify typing, clearing,
|
|
12
|
+
steppers, disabled controls and accessible labels in consuming forms.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 0.4.0
|
|
16
|
+
|
|
17
|
+
### Breaking changes
|
|
18
|
+
|
|
19
|
+
- `FormSchema.fields` is now `readonly FormItem[]` (`FormField | FormDivider`)
|
|
20
|
+
instead of `readonly FormField[]`. TypeScript that reads schema items as
|
|
21
|
+
fields, such as `schema.fields.find((field) => field.id === id)!.label` or
|
|
22
|
+
`schema.fields.map((field) => ({ ...field, required: true }))`, no longer
|
|
23
|
+
compiles. Narrow with `item.type !== "divider"` first, or declare literal
|
|
24
|
+
schemas with `satisfies FormSchema` so they keep their own item types. Schemas
|
|
25
|
+
that are only passed to FormEditor or `validateFormValues` need no change.
|
|
26
|
+
- `FormField` adds seven `type` discriminators, and `FormFieldValue` adds
|
|
27
|
+
`string[]` and `RangeSliderValue`. Exhaustive `never` checks over field types
|
|
28
|
+
or stored values need the new cases.
|
|
29
|
+
|
|
30
|
+
### Expanded FormEditor and packaged agent reference
|
|
31
|
+
|
|
32
|
+
Added `slider`, `rangeSlider`, `colour`, `radioGroup`, `checkboxGroup`, `tags`,
|
|
33
|
+
and `date` schema fields. The existing `select` dropdown is now included in the
|
|
34
|
+
expanded examples and has its own section in the agent guide. Radio/checkbox
|
|
35
|
+
groups accept one or more options, `appearance: "default" | "card"`, and
|
|
36
|
+
`columns: 1 | 2 | 3` on each field to set the options per row independently of
|
|
37
|
+
FormEditor's field columns. The GroupColumns story demonstrates all four group
|
|
38
|
+
styles with live column controls.
|
|
39
|
+
Existing boolean fields remain switches. Required groups need a selection;
|
|
40
|
+
required booleans still accept `false`. The shared controls supply their existing
|
|
41
|
+
styling, keyboard behavior, picker modes and disabled states.
|
|
42
|
+
|
|
43
|
+
`FormSchema.fields` now accepts `FormItem`, the union of value-bearing `FormField`
|
|
44
|
+
and layout-only `FormDivider`. Add `{ id, type: "divider" }` for a full-width
|
|
45
|
+
horizontal rule with no label, value or validation. Plain `hr` elements throughout
|
|
46
|
+
the library, including rich text, use the theme's muted `--rule-color` and
|
|
47
|
+
`--rule-width`. FormEditor uses grid spacing around its rules.
|
|
48
|
+
|
|
49
|
+
#### Adoption
|
|
50
|
+
|
|
51
|
+
Read `dist/components/FormEditor/README.md` in the installed package for every
|
|
52
|
+
supported prop, schema option, value shape and integration example. The guide is
|
|
53
|
+
copied from the source FormEditor folder and linked from AGENTS.md. Agents adding
|
|
54
|
+
shared form controls must also add their FormEditor adapter or document an
|
|
55
|
+
exclusion in a decision document, and keep the guide current.
|
|
56
|
+
|
|
57
|
+
Keep application-owned values, loading, permissions and saving. New arrays store
|
|
58
|
+
strings, and two-thumb range sliders use `{ min, max }` with two finite numeric
|
|
59
|
+
endpoints. Calendar dates are `YYYY-MM-DD`, distinct from existing UTC `dateTime`.
|
|
60
|
+
Cleared scalar selections remove their keys; empty tag/checkbox arrays remain.
|
|
61
|
+
Invalid colour drafts are retained in FormValues so pre-save validation rejects
|
|
62
|
+
them; valid edits use canonical hex. Continue running `validateFormValues` before
|
|
63
|
+
saving. Narrow `item.type !== "divider"` before reading field-only properties
|
|
64
|
+
when iterating `schema.fields` (see Breaking changes). Tests that read an unset
|
|
65
|
+
FormEditor slider or range slider's printed value should expect `"Not set"` or
|
|
66
|
+
the field's `placeholder`; tests that expected an empty calendar to focus its first enabled
|
|
67
|
+
day should expect today, or the nearest bound.
|
|
68
|
+
|
|
69
|
+
#### Compatibility
|
|
70
|
+
|
|
71
|
+
No public API is removed or renamed, and no dependency or manual version change
|
|
72
|
+
is introduced. Existing schemas and stored values retain their runtime behavior.
|
|
73
|
+
Widening `FormSchema.fields` and the field and value unions is a type-level
|
|
74
|
+
breaking change, listed above, so this release is a minor version below 1.0.
|
|
75
|
+
Update exhaustive switches and custom persistence adapters when adopting the new
|
|
76
|
+
types. Slider and RangeSlider `valueText`/`onValueCommit`, RangeSlider `hasFill`
|
|
77
|
+
and Popover `tabIndex` are optional and default to the previous output. `gap="none"` spacing is unchanged; custom `calc()` expressions
|
|
78
|
+
that read `--grid-gap` now receive a length. Dividers require unique IDs just
|
|
79
|
+
like fields. The global `hr` style is visible with aggregate styles even without
|
|
80
|
+
the optional reset; override it locally if a consuming surface needs another rule.
|
|
81
|
+
|
|
82
|
+
The local unreleased `numberRange` and `dateRange` FormEditor adapters are deferred
|
|
83
|
+
and are not supported schema types. Remove those fields from local schemas or
|
|
84
|
+
compose the existing standalone NumberRangeField/DateRangeField controls outside
|
|
85
|
+
FormEditor. The standalone APIs remain available. These adapters were never part
|
|
86
|
+
of a published package version; the cumulative release removes no published API.
|
|
87
|
+
|
|
88
|
+
Standalone DateField adds opt-in `isClearable` and `clearLabel`; DateRangeField
|
|
89
|
+
adds `isClearable`. Defaults remain false. Clearing returns focus to the date
|
|
90
|
+
trigger. DateRangeField now respects both global bounds and the other endpoint,
|
|
91
|
+
including when loaded endpoints lie outside those bounds. Standalone NumberRangeField
|
|
92
|
+
steppers now include their endpoint label, such as `Increase Minimum`. Update exact button
|
|
93
|
+
name assertions accordingly.
|
|
94
|
+
|
|
95
|
+
Opening a calendar now focuses the selected day, or today when the value is empty
|
|
96
|
+
or invalid, moved inside `min`/`max`; arrow keys start from that day. Escape closes
|
|
97
|
+
that calendar and returns focus to its trigger while leaving an enclosing Modal
|
|
98
|
+
or Drawer open, including after a click on the calendar's heading or padding.
|
|
99
|
+
Disabling an open DateField closes its calendar. Popover accepts an optional
|
|
100
|
+
`tabIndex`; DateField sets `-1` on its calendar dialog so clicks keep focus inside.
|
|
101
|
+
|
|
102
|
+
Slider and RangeSlider add an optional `valueText`, printed instead of the
|
|
103
|
+
number(s) and announced as `aria-valuetext`, and `onValueCommit`, which reports
|
|
104
|
+
the shown value after a click or step key on a thumb even when it did not move.
|
|
105
|
+
RangeSlider also adds `hasFill` (default `true`); `false` leaves the span between
|
|
106
|
+
the thumbs unpainted. RangeSlider thumbs now stop exactly one step apart with
|
|
107
|
+
decimal steps; previously `0.3 - 0.1` could emit `0.19999999999999998`.
|
|
108
|
+
ColourField drops a typed draft when a parent that stored the invalid text then
|
|
109
|
+
restores another value, including the value from before the edit. Its picker
|
|
110
|
+
dialog also sets `tabIndex={-1}`, so Escape after a click on the picker's padding
|
|
111
|
+
or labels closes only the picker, not an enclosing Modal or Drawer.
|
|
112
|
+
|
|
113
|
+
FormEditor sliders and range sliders with no stored value print `placeholder` or
|
|
114
|
+
`"Not set"` and store their shown position (the full range, for a range slider,
|
|
115
|
+
which is drawn without a fill while unset) on a click or an arrow, Home, End or
|
|
116
|
+
Page key, so the minimum or full range can be chosen directly. Loaded slider values outside the scale, and
|
|
117
|
+
reversed ranges, are drawn clamped and ordered while validation still reports
|
|
118
|
+
them. Decimal scales such as `min: 0.2, max: 0.3, step: 0.1` no longer fail
|
|
119
|
+
schema checks or one-step range validation through floating-point error.
|
|
120
|
+
Required date and colour fields loaded as blank strings wait for an edit or
|
|
121
|
+
`showAllErrors` before showing their required message, and an optional radio
|
|
122
|
+
group stored as `""` shows no clear action. `validateFormValues` now uses only
|
|
123
|
+
pure date, colour and slider helpers rather than importing the calendar UI.
|
|
124
|
+
|
|
125
|
+
ChoiceGroup and SelectionCardGroup now size their responsive columns against
|
|
126
|
+
their own width, stepping down before an option would be narrower than
|
|
127
|
+
`--choice-card-min-width` (default `15rem`). This also applies outside FormEditor
|
|
128
|
+
and prevents cramped cards when there is no container ancestor. It works with
|
|
129
|
+
`gap="none"`, whose `--grid-gap` value is now `0px` rather than a unitless `0`,
|
|
130
|
+
and the column minimum leaves 1px of slack so rounding never drops a column.
|
|
131
|
+
|
|
132
|
+
Button-based inputs, including Select and DateField triggers, explicitly retain
|
|
133
|
+
`--field-radius` even when Button styles load after Field styles. The default is
|
|
134
|
+
4px, matching text and colour fields. Ordinary action buttons and floating panels
|
|
135
|
+
keep their existing radius tokens. No application changes are required; local
|
|
136
|
+
radius overrides can be removed if they only compensated for import order.
|
|
137
|
+
|
|
138
|
+
The agent guide and stories now distinguish `date` (custom calendar popover,
|
|
139
|
+
date-only string) from `dateTime` (native browser date/time input, UTC timestamp).
|
|
140
|
+
Their behavior and value contracts are unchanged.
|
|
141
|
+
|
|
142
|
+
#### Verification
|
|
143
|
+
|
|
144
|
+
Run consuming typechecks, tests and builds. Test new value serialization and
|
|
145
|
+
clears, required one-option groups, both appearances, disabled choices, loaded
|
|
146
|
+
choices, select dropdown selection/clearing, group option columns and invalid
|
|
147
|
+
colour drafts. Check group legends, option
|
|
148
|
+
and endpoint names, radio keyboard navigation across multiple forms, calendar
|
|
149
|
+
clearing/focus, and popovers inside Modal/Drawer. Review separators and responsive
|
|
150
|
+
columns in every theme. Confirm the packaged guide and imported styles resolve.
|
|
151
|
+
Compare Select, calendar, colour and text input radii, including late-loaded
|
|
152
|
+
Button styles and custom `--field-radius` overrides. Check unset required
|
|
153
|
+
slider and range slider labels, fills and click/keyboard commits, decimal range sliders, loaded
|
|
154
|
+
out-of-range slider values, Discard after invalid colour typing, empty and
|
|
155
|
+
future-bounded calendars, Escape after clicking a calendar heading or colour
|
|
156
|
+
picker padding inside a Modal or Drawer, and `gap="none"` card groups at several widths.
|
|
157
|
+
Library maintainers run full validation, refresh Fallow reports and verify
|
|
158
|
+
React 18/19 ESM/CommonJS packages and the guide's examples against the packed build.
|
|
159
|
+
|
|
5
160
|
## 0.3.3
|
|
6
161
|
|
|
7
162
|
### Complete component guide and Fallow quality gate
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./Icon-BBoWP_Y6.cjs"),l=require("../components/Button/index.cjs"),u=require("./mergeRefs-Bc3qS0Tt.cjs"),d=require("./dialogFocus-B9iqKl3I.cjs"),f=require("../components/TextField/index.cjs"),p=require("../components/FieldAffix/index.cjs"),m=require("../components/Popover/index.cjs"),h=require("./Slider-k8weRl34.cjs");let g=require("react"),_=require("react/jsx-runtime"),v=require("colord"),y=require("colord/plugins/names");y=s(y,1),(0,v.extend)([y.default]);var b={h:0,s:100,v:0,a:1};function x(e){let t=e.trim();if(!t)return null;let n=t.replace(/^#/,``),r=n.length<5?[...n].map(e=>e+e).join(``):n,i=/^(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(n)?(0,v.colord)({r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16),a:r.length===8?parseInt(r.slice(6),16)/255:1}):(0,v.colord)(t);return i.isValid()?i:null}function S(e){return(0,v.colord)(e).toHex().toUpperCase()}function C(e){return x(e)?.toHex().toUpperCase()??``}function w(e,t=b){let n=x(e);if(!n||n.toHex().toUpperCase()===S(t))return t;let{r,g:i,b:a,a:o}=n.rgba,s=Math.max(r,i,a),c=s-Math.min(r,i,a),l=c===0?t.h:s===r?(i-a)/c*60:s===i?((a-r)/c+2)*60:((r-i)/c+4)*60;l<0&&(l+=360);let u={h:l,s:s?c/s*100:0,v:s/255*100,a:o};return{...u,h:u.s===0?t.h:u.h,s:u.v===0?t.s:u.s}}function T(e){let t=e.closest(`[aria-modal='true']`)??document.body,n=d.n(t).filter(e=>!e.closest(`.ds-popover`));(n[n.map(t=>e.contains(t)).lastIndexOf(!0)+1]??n[0])?.focus({preventScroll:!0})}function E(e){return Math.max(0,Math.min(100,e))}function D({colour:e,isDisabled:t,onChange:n}){let r=(0,g.useRef)(null),i=t=>{let r=t.currentTarget.getBoundingClientRect();r.width&&r.height&&n({...e,s:E((t.clientX-r.left)/r.width*100),v:E((1-(t.clientY-r.top)/r.height)*100)})};return(0,_.jsx)(`div`,{className:`ds-colour-panel__square`,role:`slider`,tabIndex:t?-1:0,"aria-label":`Saturation and brightness`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(e.s),"aria-valuetext":`Saturation ${Math.round(e.s)}%, brightness ${Math.round(e.v)}%`,"aria-disabled":t||void 0,onKeyDown:r=>{if(t)return;let i=r.shiftKey?10:1,a={ArrowLeft:{s:E(e.s-i)},ArrowRight:{s:E(e.s+i)},ArrowDown:{v:E(e.v-i)},ArrowUp:{v:E(e.v+i)},Home:{s:0},End:{s:100}}[r.key];a&&(r.preventDefault(),n({...e,...a}))},onPointerDown:e=>{t||e.button!==0||(e.preventDefault(),e.currentTarget.focus(),r.current=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),i(e))},onPointerMove:e=>{!t&&r.current===e.pointerId&&i(e)},onPointerUp:e=>{r.current===e.pointerId&&(r.current=null,e.currentTarget.releasePointerCapture(e.pointerId))},onPointerCancel:()=>{r.current=null},onLostPointerCapture:()=>{r.current=null},children:(0,_.jsx)(`span`,{className:`ds-colour-panel__thumb`,style:{left:`${e.s}%`,top:`${100-e.v}%`}})})}function O({value:e,defaultValue:t=``,onValueChange:n}){let[r,i]=(0,g.useState)(t),a=e??r,[o,s]=(0,g.useState)(()=>({source:a,colour:w(a)})),c=o.colour;return o.source!==a&&(c=w(a,c),s({source:a,colour:c})),{current:a,colour:c,commit:t=>{let r=typeof t==`string`?C(t):S(t);s({source:r,colour:typeof t==`string`?w(t,c):t}),e===void 0&&i(r),n?.(r)}}}function k(e,t){let[n,r]=(0,g.useState)(null);return n&&n.source!==e&&n.text===e&&r({source:e,text:e}),{text:n?.source===e?n.text:t||e,type:(t,n)=>r({source:n?C(t):e,text:t}),discard:()=>r(null)}}function A(){return window.EyeDropper}var j=()=>()=>{},M=[],N=8;function P(e,t,n){let r=t%N,i=r+Math.floor((n-1-r)/N)*N;switch(e){case`Home`:return 0;case`End`:return n-1;case`ArrowRight`:return(t+1)%n;case`ArrowLeft`:return(t-1+n)%n;case`ArrowDown`:return t+N<n?t+N:r;case`ArrowUp`:return t>=N?t-N:i;default:return}}var F=(0,g.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,...r},i){let{current:a,colour:o,commit:s}=O({value:e,defaultValue:t,onValueChange:n});return(0,_.jsx)(I,{...r,ref:i,colour:o,current:a,onColourChange:s})}),I=(0,g.forwardRef)(function({colour:e,current:t,onColourChange:n,presets:r=M,showPresets:i=!0,picker:a=`custom`,isDisabled:o=!1,className:s,style:u,...d},f){let p=(0,g.useRef)(null),m=(0,g.useRef)(!0),v=(0,g.useRef)(o),[y,b]=(0,g.useState)(!1),[T,E]=(0,g.useState)(``),O=(0,g.useSyncExternalStore)(j,()=>!!A(),()=>!1),k=(0,g.useId)(),F=C(t),I=S({...e,a:1}),L=(0,g.useMemo)(()=>{let e=new Map;for(let t of r){let n=C(t);n&&!e.has(n)&&e.set(n,t)}return[...e].map(([e,t])=>({normalised:e,preset:t}))},[r]),R=L.findIndex(e=>e.normalised===F);(0,g.useEffect)(()=>{v.current=o},[o]),(0,g.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let z=async()=>{let t=A();if(!(!t||o||y)){b(!0),E(``);try{let r=await new t().open();m.current&&!v.current&&x(r.sRGBHex)&&n({...w(r.sRGBHex,e),a:e.a})}catch(e){m.current&&!(e instanceof DOMException&&e.name===`AbortError`)&&E(`Unable to pick a colour from the screen. Try again.`)}finally{m.current&&b(!1)}}};return(0,_.jsxs)(`div`,{...d,ref:f,className:[`ds-colour-panel`,s].filter(Boolean).join(` `),"data-disabled":o||void 0,style:{...u,"--colour-hue":`hsl(${e.h} 100% 50%)`,"--colour-rgb":I,"--colour-rgba":S(e)},children:[(0,_.jsxs)(`div`,{className:`ds-colour-panel__head`,children:[(0,_.jsx)(`span`,{children:`Colour`}),(0,_.jsx)(`span`,{className:`ds-colour-panel__value`,children:F||`No colour`})]}),a===`custom`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(D,{colour:e,isDisabled:o,onChange:n}),(0,_.jsxs)(`div`,{className:`ds-colour-panel__hue-row`,children:[O&&(0,_.jsx)(l.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`pipette`,"aria-label":`Pick from screen`,isDisabled:o,"aria-busy":y||void 0,onClick:()=>void z()}),(0,_.jsx)(h.n,{className:`ds-colour-panel__hue`,value:e.h,min:0,max:360,step:1,hasValueLabel:!1,"aria-label":`Hue`,"aria-valuetext":`${Math.round(e.h)} degrees`,isDisabled:o,onValueChange:t=>n({...e,h:t}),onKeyDown:t=>{if(!t.shiftKey||![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(t.key))return;t.preventDefault();let r=t.key===`ArrowRight`||t.key===`ArrowUp`?15:-15;n({...e,h:Math.max(0,Math.min(360,e.h+r))})}})]})]}):(0,_.jsxs)(`div`,{className:`ds-colour-panel__native`,children:[(0,_.jsx)(`input`,{ref:p,type:`color`,value:I,tabIndex:-1,"aria-hidden":`true`,disabled:o,onChange:t=>{x(t.target.value)&&n({...w(t.target.value,e),a:e.a})}}),(0,_.jsx)(l.Button,{variant:`neutral`,size:`sm`,iconStart:`pipette`,isDisabled:o,onClick:()=>{let e=p.current;if(e)try{e.showPicker?e.showPicker():e.click()}catch{e.click()}},children:`Custom colour…`})]}),(0,_.jsxs)(`div`,{className:`ds-colour-panel__opacity`,children:[(0,_.jsx)(`label`,{htmlFor:`${k}-opacity`,children:`Opacity`}),(0,_.jsx)(h.n,{id:`${k}-opacity`,className:`ds-colour-panel__alpha`,value:Math.round(e.a*100),min:0,max:100,step:1,suffix:`%`,isDisabled:o,onValueChange:t=>n({...e,a:t/100})})]}),i&&L.length>0&&(0,_.jsxs)(`div`,{className:`ds-colour-panel__presets`,children:[(0,_.jsx)(`span`,{id:k,className:`ds-colour-panel__presets-label`,children:`Presets`}),(0,_.jsx)(`div`,{className:`ds-colour-panel__grid`,role:`radiogroup`,"aria-labelledby":k,style:{"--colour-preset-columns":N},onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role='radio']`)),n=t.indexOf(e.target),r=n<0?void 0:P(e.key,n,t.length);r!==void 0&&(e.preventDefault(),t[r]?.focus(),t[r]?.click())},children:L.map(({normalised:e,preset:t},r)=>{let i=r===R;return(0,_.jsx)(l.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,role:`radio`,"aria-checked":i,"aria-label":t,title:t,tabIndex:r===Math.max(0,R)?0:-1,isDisabled:o,className:`ds-colour-panel__preset`,onClick:()=>n(t),children:(0,_.jsx)(`span`,{className:`ds-colour-swatch`,style:{"--colour-swatch":e},children:i&&(0,_.jsx)(c.t,{name:`check`,size:16,strokeWidth:3})})},e)})})]}),T&&(0,_.jsx)(`span`,{className:`ds-colour-panel__error`,role:`status`,children:T})]})}),L=(0,g.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,onValidityChange:r,presets:i,showPresets:a,picker:o,placement:s,isDisabled:c=!1,disabled:h,readOnly:v,isInvalid:y,"aria-invalid":b,id:S,className:w,onBlur:E,onKeyDown:D,...A},j){let{current:M,colour:N,commit:P}=O({value:e,defaultValue:t,onValueChange:n}),[F,L]=(0,g.useState)(!1),R=(0,g.useRef)(null),z=(0,g.useRef)(null),B=(0,g.useRef)(null),V=(0,g.useRef)(null),H=(0,g.useId)(),U=S??`${H}-input`,W=C(M),{text:G,type:K,discard:q}=k(M,W),J=!(!G.trim()||x(G)),Y=c||h;F&&(Y||v)&&L(!1);let X=F&&!Y&&!v;(0,g.useEffect)(()=>{r?.(!J),z.current?.setCustomValidity(J?`Enter a colour, such as #0052CC or rebeccapurple.`:``)},[J,r]),(0,g.useEffect)(()=>{if(!X)return;V.current&&d.n(V.current)[0]?.focus({preventScroll:!0});let e=e=>{let t=e.target;t&&!R.current?.contains(t)&&!V.current?.contains(t)&&L(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[X]);let Z=e=>{B.current=e,L(!X)},Q=()=>{L(!1),B.current?.focus({preventScroll:!0})},$={"aria-label":X?`Close colour picker`:`Open colour picker`,"aria-haspopup":`dialog`,"aria-expanded":X,"aria-controls":X?H:void 0,isDisabled:Y||v};return(0,_.jsxs)(`div`,{className:`ds-colour-field`,ref:R,onBlur:e=>{let t=e.relatedTarget;t&&!R.current?.contains(t)&&!V.current?.contains(t)&&L(!1)},onKeyDown:e=>{if(X&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Q()),!X||e.key!==`Tab`||!V.current?.contains(e.target))return;let t=d.n(V.current);(e.shiftKey?e.target===t[0]:e.target===t.at(-1))&&(e.preventDefault(),e.stopPropagation(),L(!1),e.shiftKey?B.current?.focus({preventScroll:!0}):R.current&&T(R.current))},children:[(0,_.jsx)(p.FieldAffix,{isLeadInteractive:!0,isTrailInteractive:!0,lead:(0,_.jsx)(l.Button,{"aria-hidden":`true`,tabIndex:-1,isDisabled:$.isDisabled,variant:`simple`,size:`xs`,isIconOnly:!0,onMouseDown:e=>e.preventDefault(),onClick:()=>{B.current=z.current,X?Q():L(!0)},children:(0,_.jsx)(`span`,{className:`ds-colour-swatch ds-colour-field__swatch`,style:{"--colour-swatch":W||`transparent`}})}),trail:(0,_.jsx)(l.Button,{...$,variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`chevron-down`,onClick:e=>Z(e.currentTarget)}),children:(0,_.jsx)(f.TextField,{...A,ref:u.t(z,j),id:U,disabled:Y,readOnly:v,spellCheck:!1,autoComplete:`off`,value:G,"aria-invalid":J||y||b||void 0,"aria-haspopup":`dialog`,"aria-controls":X?H:void 0,className:[`ds-colour-field__input`,w].filter(Boolean).join(` `),onChange:e=>{let t=e.target.value,n=!t.trim()||!!x(t);K(t,n),n&&P(t)},onBlur:e=>{J||q(),E?.(e)},onKeyDown:e=>{D?.(e),!e.defaultPrevented&&(e.key===`Enter`&&!J&&(e.preventDefault(),q()),e.key===`ArrowDown`&&!Y&&!v&&(e.preventDefault(),B.current=e.currentTarget,L(!0)))}})}),(0,_.jsx)(m.Popover,{anchorRef:z,anchorId:U,isOpen:X,placement:s,panelRef:V,id:H,role:`dialog`,"aria-label":`Choose a colour`,tabIndex:-1,className:`ds-colour-field__popover`,children:(0,_.jsx)(I,{colour:N,current:W,presets:i,showPresets:a,picker:o,onColourChange:e=>{q(),P(e)}})})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return L}});
|
|
2
|
+
//# sourceMappingURL=ColourField-CJicr3OT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColourField-CJicr3OT.cjs","names":["extend","namesPlugin","tabbableControls","useRef","useState","forwardRef","useRef","useState","useSyncExternalStore","useId","useMemo","_Fragment","Button","Slider","Icon","forwardRef","useState","useRef","useId","tabbableControls","FieldAffix","Button","TextField","mergeRefs","Popover","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__copyProps","from","keys","i","n","key","to","except","k","desc","__toESM","mod","isNodeMode","target","require_Icon","require_components_Button_index","require_mergeRefs","require_dialogFocus","require_components_TextField_index","require_components_FieldAffix_index","require_components_Popover_index","require_Slider","react","react_jsx_runtime","colord","colord_plugins_names","emptyColour","parseColour","text","value","hex","digits","digit","colour","colourHex","normaliseColour","colourState","parsed","previous","max","g","b","delta","h","next","focusAfterField","boundary","root","controls","element","clamp","ColourSquare","dragging","update","rect","event","onChange","isDisabled","step","change","useColourValue","internal","setInternal","defaultValue","current","selection","setSelection","onValueChange","useColourDraft","draft","setDraft","isValid","eyeDropperConstructor","subscribe","noPresets","presetColumns","presetTarget","column","index","lastInColumn","count","ColourPanel","rest","ColourPanelContent","commit","inputRef","active","disabledRef","isPicking","setPicking","pickerError","setPickerError","hasEyeDropper","presetsId","rgb","swatches","unique","preset","presets","normalised","selectedIndex","swatch","pickFromScreen","EyeDropper","result","onColourChange","error","className","style","picker","input","a","showPresets","radios","selected","ColourField","ariaInvalid","isOpen","setOpen","rootRef","openerRef","panelRef","panelId","fieldId","id","invalid","effectiveDisabled","disabled","readOnly","visible","onValidityChange","outside","toggle","opener","close","triggerProps","ref","isInvalid","valid","type","discard","onBlur","onKeyDown"],"sources":["../../src/components/ColourField/colour.ts","../../src/components/ColourField/focus.ts","../../src/components/ColourField/square.tsx","../../src/components/ColourField/value.ts","../../src/components/ColourField/panel.tsx","../../src/components/ColourField/index.tsx"],"sourcesContent":["import { colord, extend } from \"colord\";\nimport namesPlugin from \"colord/plugins/names\";\n\nextend([namesPlugin]);\n\nexport interface Colour {\n h: number;\n s: number;\n v: number;\n a: number;\n}\n\nconst emptyColour: Colour = { h: 0, s: 100, v: 0, a: 1 };\n\nexport function parseColour(value: string) {\n const text = value.trim();\n if (!text) {\n return null;\n }\n const hex = text.replace(/^#/, \"\");\n // Colord's string hex parser rounds alpha to two decimals. Decode hex bytes\n // first so a typed alpha survives normalisation and later opacity edits.\n const digits = hex.length < 5 ? [...hex].map((digit) => digit + digit).join(\"\") : hex;\n const colour = /^(?:[\\da-f]{3,4}|[\\da-f]{6}|[\\da-f]{8})$/i.test(hex)\n ? colord({\n r: parseInt(digits.slice(0, 2), 16),\n g: parseInt(digits.slice(2, 4), 16),\n b: parseInt(digits.slice(4, 6), 16),\n a: digits.length === 8 ? parseInt(digits.slice(6), 16) / 255 : 1,\n })\n : colord(text);\n return colour.isValid() ? colour : null;\n}\n\nexport function colourHex(colour: Colour) {\n return colord(colour).toHex().toUpperCase();\n}\n\nexport function normaliseColour(value: string) {\n return parseColour(value)?.toHex().toUpperCase() ?? \"\";\n}\n\n/** Preserve latent hue in greys, and saturation in black, including parent echoes. */\nexport function colourState(value: string, previous = emptyColour): Colour {\n const parsed = parseColour(value);\n if (!parsed || parsed.toHex().toUpperCase() === colourHex(previous)) {\n return previous;\n }\n // Keep full HSV precision: changing opacity must not quantise the RGB value.\n const { r, g, b, a } = parsed.rgba;\n const max = Math.max(r, g, b);\n const delta = max - Math.min(r, g, b);\n let h =\n delta === 0\n ? previous.h\n : max === r\n ? ((g - b) / delta) * 60\n : max === g\n ? ((b - r) / delta + 2) * 60\n : ((r - g) / delta + 4) * 60;\n if (h < 0) {\n h += 360;\n }\n const next = { h, s: max ? (delta / max) * 100 : 0, v: (max / 255) * 100, a };\n return { ...next, h: next.s === 0 ? previous.h : next.h, s: next.v === 0 ? previous.s : next.s };\n}\n","import { tabbableControls } from \"../../internal/dialogFocus\";\n\n/** Continue after the composed field, respecting an enclosing modal's focus boundary. */\nexport function focusAfterField(root: HTMLElement) {\n const boundary = root.closest<HTMLElement>(\"[aria-modal='true']\") ?? document.body;\n const controls = tabbableControls(boundary).filter((element) => !element.closest(\".ds-popover\"));\n const last = controls.map((element) => root.contains(element)).lastIndexOf(true);\n const next = controls[last + 1] ?? controls[0];\n next?.focus({ preventScroll: true });\n}\n","import { useRef, type KeyboardEvent, type PointerEvent } from \"react\";\nimport type { Colour } from \"./colour\";\n\ninterface ColourSquareProps {\n colour: Colour;\n isDisabled: boolean;\n onChange: (colour: Colour) => void;\n}\n\nfunction clamp(value: number) {\n return Math.max(0, Math.min(100, value));\n}\n\nexport function ColourSquare({ colour, isDisabled, onChange }: ColourSquareProps) {\n const dragging = useRef<number | null>(null);\n const update = (event: PointerEvent<HTMLDivElement>) => {\n const rect = event.currentTarget.getBoundingClientRect();\n if (!rect.width || !rect.height) {\n return;\n }\n onChange({\n ...colour,\n s: clamp(((event.clientX - rect.left) / rect.width) * 100),\n v: clamp((1 - (event.clientY - rect.top) / rect.height) * 100),\n });\n };\n const handleKey = (event: KeyboardEvent) => {\n if (isDisabled) {\n return;\n }\n const step = event.shiftKey ? 10 : 1;\n const changes: Record<string, Partial<Colour>> = {\n ArrowLeft: { s: clamp(colour.s - step) },\n ArrowRight: { s: clamp(colour.s + step) },\n ArrowDown: { v: clamp(colour.v - step) },\n ArrowUp: { v: clamp(colour.v + step) },\n Home: { s: 0 },\n End: { s: 100 },\n };\n const change = changes[event.key];\n if (!change) {\n return;\n }\n event.preventDefault();\n onChange({ ...colour, ...change });\n };\n return (\n <div\n className=\"ds-colour-panel__square\"\n role=\"slider\"\n tabIndex={isDisabled ? -1 : 0}\n aria-label=\"Saturation and brightness\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(colour.s)}\n aria-valuetext={`Saturation ${Math.round(colour.s)}%, brightness ${Math.round(colour.v)}%`}\n aria-disabled={isDisabled || undefined}\n onKeyDown={handleKey}\n onPointerDown={(event) => {\n if (isDisabled || event.button !== 0) {\n return;\n }\n event.preventDefault();\n event.currentTarget.focus();\n dragging.current = event.pointerId;\n event.currentTarget.setPointerCapture(event.pointerId);\n update(event);\n }}\n onPointerMove={(event) => {\n if (!isDisabled && dragging.current === event.pointerId) {\n update(event);\n }\n }}\n onPointerUp={(event) => {\n if (dragging.current !== event.pointerId) {\n return;\n }\n dragging.current = null;\n event.currentTarget.releasePointerCapture(event.pointerId);\n }}\n onPointerCancel={() => {\n dragging.current = null;\n }}\n onLostPointerCapture={() => {\n dragging.current = null;\n }}\n >\n <span\n className=\"ds-colour-panel__thumb\"\n style={{ left: `${colour.s}%`, top: `${100 - colour.v}%` }}\n />\n </div>\n );\n}\n","import { useState } from \"react\";\nimport { colourHex, colourState, normaliseColour, type Colour } from \"./colour\";\n\nexport interface ColourValueProps {\n value?: string;\n defaultValue?: string;\n /** Uppercase hex (including alpha when needed), or an empty string when cleared. */\n onValueChange?: (value: string) => void;\n}\n\nexport function useColourValue({ value, defaultValue = \"\", onValueChange }: ColourValueProps) {\n const [internal, setInternal] = useState(defaultValue);\n const current = value ?? internal;\n const [selection, setSelection] = useState(() => ({\n source: current,\n colour: colourState(current),\n }));\n let colour = selection.colour;\n if (selection.source !== current) {\n colour = colourState(current, colour);\n setSelection({ source: current, colour });\n }\n\n const commit = (next: string | Colour) => {\n const hex = typeof next === \"string\" ? normaliseColour(next) : colourHex(next);\n setSelection({\n source: hex,\n colour: typeof next === \"string\" ? colourState(next, colour) : next,\n });\n if (value === undefined) {\n setInternal(hex);\n }\n onValueChange?.(hex);\n };\n\n return { current, colour, commit };\n}\n\n/** Typed text the field shows until it is committed, blurred, or replaced. */\nexport function useColourDraft(current: string, hex: string) {\n const [draft, setDraft] = useState<{ source: string; text: string } | null>(null);\n // A draft belongs to the value it was typed over. A parent that stores the invalid\n // text (FormEditor does) takes it over, so restoring the earlier value then wins.\n if (draft && draft.source !== current && draft.text === current) {\n setDraft({ source: current, text: current });\n }\n const text = draft?.source === current ? draft.text : hex || current;\n /** Valid text becomes the committed hex; invalid text stays over the current value. */\n const type = (next: string, isValid: boolean) =>\n setDraft({ source: isValid ? normaliseColour(next) : current, text: next });\n return { text, type, discard: () => setDraft(null) };\n}\n","import {\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type HTMLAttributes,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Slider } from \"../Slider\";\nimport { colourHex, colourState, normaliseColour, parseColour, type Colour } from \"./colour\";\nimport { ColourSquare } from \"./square\";\nimport { useColourValue, type ColourValueProps } from \"./value\";\nimport \"./style.css\";\n\nexport interface ColourPickerOptions {\n presets?: string[];\n showPresets?: boolean;\n picker?: \"custom\" | \"native\";\n isDisabled?: boolean;\n}\n\nexport interface ColourPanelProps\n extends\n Omit<HTMLAttributes<HTMLDivElement>, \"defaultValue\" | \"onChange\">,\n ColourValueProps,\n ColourPickerOptions {}\n\ninterface EyeDropperInstance {\n open: () => Promise<{ sRGBHex: string }>;\n}\nfunction eyeDropperConstructor() {\n return (window as Window & { EyeDropper?: new () => EyeDropperInstance }).EyeDropper;\n}\nconst subscribe = () => () => {};\nconst noPresets: string[] = [];\nconst presetColumns = 8;\n\n/** Where a key moves within the preset grid; rows wrap within their column. */\nfunction presetTarget(key: string, index: number, count: number) {\n const column = index % presetColumns;\n const lastInColumn = column + Math.floor((count - 1 - column) / presetColumns) * presetColumns;\n switch (key) {\n case \"Home\":\n return 0;\n case \"End\":\n return count - 1;\n case \"ArrowRight\":\n return (index + 1) % count;\n case \"ArrowLeft\":\n return (index - 1 + count) % count;\n case \"ArrowDown\":\n return index + presetColumns < count ? index + presetColumns : column;\n case \"ArrowUp\":\n return index >= presetColumns ? index - presetColumns : lastInColumn;\n default:\n return undefined;\n }\n}\n\n/** A standalone colour selection surface, also composed by ColourField. */\nexport const ColourPanel = forwardRef<HTMLDivElement, ColourPanelProps>(function ColourPanel(\n { value, defaultValue, onValueChange, ...rest },\n ref,\n) {\n const { current, colour, commit } = useColourValue({ value, defaultValue, onValueChange });\n return (\n <ColourPanelContent\n {...rest}\n ref={ref}\n colour={colour}\n current={current}\n onColourChange={commit}\n />\n );\n});\n\ninterface ColourPanelContentProps extends Omit<\n ColourPanelProps,\n \"value\" | \"defaultValue\" | \"onValueChange\"\n> {\n colour: Colour;\n current: string;\n onColourChange: (colour: Colour | string) => void;\n}\n\nexport const ColourPanelContent = forwardRef<HTMLDivElement, ColourPanelContentProps>(\n function ColourPanelContent(\n {\n colour,\n current,\n onColourChange,\n presets = noPresets,\n showPresets = true,\n picker = \"custom\",\n isDisabled = false,\n className,\n style,\n ...rest\n },\n ref,\n ) {\n const inputRef = useRef<HTMLInputElement>(null);\n const active = useRef(true);\n const disabledRef = useRef(isDisabled);\n const [isPicking, setPicking] = useState(false);\n const [pickerError, setPickerError] = useState(\"\");\n const hasEyeDropper = useSyncExternalStore(\n subscribe,\n () => Boolean(eyeDropperConstructor()),\n () => false,\n );\n const presetsId = useId();\n const hex = normaliseColour(current);\n const rgb = colourHex({ ...colour, a: 1 });\n // Equivalent spellings collapse onto the first; each preset is parsed once.\n const swatches = useMemo(() => {\n const unique = new Map<string, string>();\n for (const preset of presets) {\n const normalised = normaliseColour(preset);\n if (normalised && !unique.has(normalised)) {\n unique.set(normalised, preset);\n }\n }\n return [...unique].map(([normalised, preset]) => ({ normalised, preset }));\n }, [presets]);\n const selectedIndex = swatches.findIndex((swatch) => swatch.normalised === hex);\n useEffect(() => {\n disabledRef.current = isDisabled;\n }, [isDisabled]);\n useEffect(() => {\n active.current = true;\n return () => {\n active.current = false;\n };\n }, []);\n\n const pickFromScreen = async () => {\n const EyeDropper = eyeDropperConstructor();\n if (!EyeDropper || isDisabled || isPicking) {\n return;\n }\n setPicking(true);\n setPickerError(\"\");\n try {\n const result = await new EyeDropper().open();\n if (active.current && !disabledRef.current) {\n if (parseColour(result.sRGBHex)) {\n onColourChange({ ...colourState(result.sRGBHex, colour), a: colour.a });\n }\n }\n } catch (error) {\n if (active.current && !(error instanceof DOMException && error.name === \"AbortError\")) {\n setPickerError(\"Unable to pick a colour from the screen. Try again.\");\n }\n } finally {\n if (active.current) {\n setPicking(false);\n }\n }\n };\n\n return (\n <div\n {...rest}\n ref={ref}\n className={[\"ds-colour-panel\", className].filter(Boolean).join(\" \")}\n data-disabled={isDisabled || undefined}\n style={\n {\n ...style,\n \"--colour-hue\": `hsl(${colour.h} 100% 50%)`,\n \"--colour-rgb\": rgb,\n \"--colour-rgba\": colourHex(colour),\n } as CSSProperties\n }\n >\n <div className=\"ds-colour-panel__head\">\n <span>Colour</span>\n <span className=\"ds-colour-panel__value\">{hex || \"No colour\"}</span>\n </div>\n {picker === \"custom\" ? (\n <>\n <ColourSquare\n colour={colour}\n isDisabled={isDisabled}\n onChange={onColourChange}\n />\n <div className=\"ds-colour-panel__hue-row\">\n {hasEyeDropper && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"pipette\"\n aria-label=\"Pick from screen\"\n isDisabled={isDisabled}\n // Busy, not pending: a pending Button disables itself and drops focus.\n aria-busy={isPicking || undefined}\n onClick={() => void pickFromScreen()}\n />\n )}\n <Slider\n className=\"ds-colour-panel__hue\"\n value={colour.h}\n min={0}\n max={360}\n step={1}\n hasValueLabel={false}\n aria-label=\"Hue\"\n aria-valuetext={`${Math.round(colour.h)} degrees`}\n isDisabled={isDisabled}\n onValueChange={(h) => onColourChange({ ...colour, h })}\n onKeyDown={(event) => {\n if (\n !event.shiftKey ||\n ![\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\"].includes(event.key)\n ) {\n return;\n }\n event.preventDefault();\n const delta = event.key === \"ArrowRight\" || event.key === \"ArrowUp\" ? 15 : -15;\n onColourChange({ ...colour, h: Math.max(0, Math.min(360, colour.h + delta)) });\n }}\n />\n </div>\n </>\n ) : (\n <div className=\"ds-colour-panel__native\">\n <input\n ref={inputRef}\n type=\"color\"\n value={rgb}\n tabIndex={-1}\n aria-hidden=\"true\"\n disabled={isDisabled}\n onChange={(event) => {\n if (parseColour(event.target.value)) {\n onColourChange({ ...colourState(event.target.value, colour), a: colour.a });\n }\n }}\n />\n <Button\n variant=\"neutral\"\n size=\"sm\"\n iconStart=\"pipette\"\n isDisabled={isDisabled}\n onClick={() => {\n const input = inputRef.current;\n if (!input) {\n return;\n }\n try {\n if (input.showPicker) {\n input.showPicker();\n } else {\n input.click();\n }\n } catch {\n input.click();\n }\n }}\n >\n Custom colour…\n </Button>\n </div>\n )}\n <div className=\"ds-colour-panel__opacity\">\n <label htmlFor={`${presetsId}-opacity`}>Opacity</label>\n <Slider\n id={`${presetsId}-opacity`}\n className=\"ds-colour-panel__alpha\"\n value={Math.round(colour.a * 100)}\n min={0}\n max={100}\n step={1}\n suffix=\"%\"\n isDisabled={isDisabled}\n onValueChange={(a) => onColourChange({ ...colour, a: a / 100 })}\n />\n </div>\n {showPresets && swatches.length > 0 && (\n <div className=\"ds-colour-panel__presets\">\n <span\n id={presetsId}\n className=\"ds-colour-panel__presets-label\"\n >\n Presets\n </span>\n <div\n className=\"ds-colour-panel__grid\"\n role=\"radiogroup\"\n aria-labelledby={presetsId}\n style={{ \"--colour-preset-columns\": presetColumns } as CSSProperties}\n onKeyDown={(event) => {\n const radios = Array.from(\n event.currentTarget.querySelectorAll<HTMLButtonElement>(\"[role='radio']\"),\n );\n const index = radios.indexOf(event.target as HTMLButtonElement);\n const next = index < 0 ? undefined : presetTarget(event.key, index, radios.length);\n if (next === undefined) {\n return;\n }\n event.preventDefault();\n radios[next]?.focus();\n radios[next]?.click();\n }}\n >\n {swatches.map(({ normalised, preset }, index) => {\n const selected = index === selectedIndex;\n return (\n <Button\n key={normalised}\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n role=\"radio\"\n aria-checked={selected}\n aria-label={preset}\n title={preset}\n tabIndex={index === Math.max(0, selectedIndex) ? 0 : -1}\n isDisabled={isDisabled}\n className=\"ds-colour-panel__preset\"\n onClick={() => onColourChange(preset)}\n >\n <span\n className=\"ds-colour-swatch\"\n style={{ \"--colour-swatch\": normalised } as CSSProperties}\n >\n {selected && (\n <Icon\n name=\"check\"\n size={16}\n strokeWidth={3}\n />\n )}\n </span>\n </Button>\n );\n })}\n </div>\n </div>\n )}\n {pickerError && (\n <span\n className=\"ds-colour-panel__error\"\n role=\"status\"\n >\n {pickerError}\n </span>\n )}\n </div>\n );\n },\n);\n","import { forwardRef, useEffect, useId, useRef, useState, type CSSProperties } from \"react\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport { Popover, type PopoverPlacement } from \"../Popover\";\nimport { TextField, type TextFieldProps } from \"../TextField\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { normaliseColour, parseColour } from \"./colour\";\nimport { tabbableControls } from \"../../internal/dialogFocus\";\nimport { focusAfterField } from \"./focus\";\nimport { ColourPanelContent, type ColourPickerOptions } from \"./panel\";\nimport { useColourDraft, useColourValue, type ColourValueProps } from \"./value\";\nimport \"./style.css\";\n\nexport { ColourPanel } from \"./panel\";\nexport type { ColourPanelProps } from \"./panel\";\n\nexport interface ColourFieldProps\n extends\n Omit<TextFieldProps, \"value\" | \"defaultValue\" | \"onChange\" | \"type\" | \"children\">,\n ColourValueProps,\n ColourPickerOptions {\n isInvalid?: boolean;\n placement?: PopoverPlacement;\n /** Parsing validity; an empty value is valid and native required validation remains separate. */\n onValidityChange?: (isValid: boolean) => void;\n}\n\n/** A typed colour value and a visual picker, bound to the shared Field frame. */\nexport const ColourField = forwardRef<HTMLInputElement, ColourFieldProps>(function ColourField(\n {\n value,\n defaultValue,\n onValueChange,\n onValidityChange,\n presets,\n showPresets,\n picker,\n placement,\n isDisabled = false,\n disabled,\n readOnly,\n isInvalid,\n \"aria-invalid\": ariaInvalid,\n id,\n className,\n onBlur,\n onKeyDown,\n ...rest\n },\n ref,\n) {\n const { current, colour, commit } = useColourValue({ value, defaultValue, onValueChange });\n const [isOpen, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const openerRef = useRef<HTMLElement | null>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const panelId = useId();\n const fieldId = id ?? `${panelId}-input`;\n const hex = normaliseColour(current);\n const { text, type, discard } = useColourDraft(current, hex);\n const invalid = Boolean(text.trim() && !parseColour(text));\n const effectiveDisabled = isDisabled || disabled;\n if (isOpen && (effectiveDisabled || readOnly)) {\n setOpen(false);\n }\n const visible = isOpen && !effectiveDisabled && !readOnly;\n\n useEffect(() => {\n onValidityChange?.(!invalid);\n inputRef.current?.setCustomValidity(\n invalid ? \"Enter a colour, such as #0052CC or rebeccapurple.\" : \"\",\n );\n }, [invalid, onValidityChange]);\n\n useEffect(() => {\n if (!visible) {\n return;\n }\n if (panelRef.current) {\n tabbableControls(panelRef.current)[0]?.focus({ preventScroll: true });\n }\n const outside = (event: MouseEvent) => {\n const target = event.target as Node;\n if (target && !rootRef.current?.contains(target) && !panelRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", outside);\n return () => document.removeEventListener(\"mousedown\", outside);\n }, [visible]);\n\n const toggle = (opener: HTMLElement) => {\n openerRef.current = opener;\n setOpen(!visible);\n };\n const close = () => {\n setOpen(false);\n openerRef.current?.focus({ preventScroll: true });\n };\n const triggerProps = {\n \"aria-label\": visible ? \"Close colour picker\" : \"Open colour picker\",\n \"aria-haspopup\": \"dialog\" as const,\n \"aria-expanded\": visible,\n \"aria-controls\": visible ? panelId : undefined,\n isDisabled: effectiveDisabled || readOnly,\n };\n\n return (\n <div\n className=\"ds-colour-field\"\n ref={rootRef}\n onBlur={(event) => {\n const target = event.relatedTarget as Node | null;\n if (target && !rootRef.current?.contains(target) && !panelRef.current?.contains(target)) {\n setOpen(false);\n }\n }}\n onKeyDown={(event) => {\n if (visible && event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n close();\n }\n if (!visible || event.key !== \"Tab\" || !panelRef.current?.contains(event.target as Node)) {\n return;\n }\n const controls = tabbableControls(panelRef.current);\n const atBoundary = event.shiftKey\n ? event.target === controls[0]\n : event.target === controls.at(-1);\n if (!atBoundary) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n if (event.shiftKey) {\n openerRef.current?.focus({ preventScroll: true });\n } else if (rootRef.current) {\n focusAfterField(rootRef.current);\n }\n }}\n >\n <FieldAffix\n isLeadInteractive\n isTrailInteractive\n lead={\n // A pointer shortcut only: the chevron is the one keyboard and screen\n // reader trigger. The swatch never takes focus; the input gets it back.\n <Button\n aria-hidden=\"true\"\n tabIndex={-1}\n isDisabled={triggerProps.isDisabled}\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n openerRef.current = inputRef.current;\n if (visible) {\n close();\n } else {\n setOpen(true);\n }\n }}\n >\n <span\n className=\"ds-colour-swatch ds-colour-field__swatch\"\n style={{ \"--colour-swatch\": hex || \"transparent\" } as CSSProperties}\n />\n </Button>\n }\n trail={\n <Button\n {...triggerProps}\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"chevron-down\"\n onClick={(event) => toggle(event.currentTarget)}\n />\n }\n >\n <TextField\n {...rest}\n ref={mergeRefs(inputRef, ref)}\n id={fieldId}\n disabled={effectiveDisabled}\n readOnly={readOnly}\n spellCheck={false}\n autoComplete=\"off\"\n value={text}\n aria-invalid={invalid || isInvalid || ariaInvalid || undefined}\n aria-haspopup=\"dialog\"\n aria-controls={visible ? panelId : undefined}\n className={[\"ds-colour-field__input\", className].filter(Boolean).join(\" \")}\n onChange={(event) => {\n const next = event.target.value;\n const valid = !next.trim() || Boolean(parseColour(next));\n type(next, valid);\n if (valid) {\n commit(next);\n }\n }}\n onBlur={(event) => {\n if (!invalid) {\n discard();\n }\n onBlur?.(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) {\n return;\n }\n if (event.key === \"Enter\" && !invalid) {\n event.preventDefault();\n discard();\n }\n if (event.key === \"ArrowDown\" && !effectiveDisabled && !readOnly) {\n event.preventDefault();\n openerRef.current = event.currentTarget;\n setOpen(true);\n }\n }}\n />\n </FieldAffix>\n <Popover\n anchorRef={inputRef}\n anchorId={fieldId}\n isOpen={visible}\n placement={placement}\n panelRef={panelRef}\n id={panelId}\n role=\"dialog\"\n aria-label=\"Choose a colour\"\n // A click on the padding or a label focuses the dialog rather than the page,\n // so the field's own Escape handler still runs before an enclosing Modal's.\n tabIndex={-1}\n className=\"ds-colour-field__popover\"\n >\n <ColourPanelContent\n colour={colour}\n current={hex}\n presets={presets}\n showPresets={showPresets}\n picker={picker}\n onColourChange={(next) => {\n discard();\n commit(next);\n }}\n />\n </Popover>\n </div>\n );\n});\n"],"mappings":"A,07BAGAA,EAAAA,EAAAA,OAAAA,CAAO,CAACC,EAAAA,OAAW,CAAC,EASpB,IAAMwD,EAAsB,CAAE,EAAG,EAAG,EAAG,IAAK,EAAG,EAAG,EAAG,C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