@namroodinc/liquid-editorial 0.6.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/UPGRADING.md +64 -0
- package/dist/chunks/{ColourField-DC6cLb9h.js → ColourField-B-tjjBfA.js} +2 -2
- package/dist/chunks/{ColourField-DC6cLb9h.js.map → ColourField-B-tjjBfA.js.map} +1 -1
- package/dist/chunks/{ColourField-NnFxLEsh.cjs → ColourField-ynUP1pfN.cjs} +2 -2
- package/dist/chunks/{ColourField-NnFxLEsh.cjs.map → ColourField-ynUP1pfN.cjs.map} +1 -1
- package/dist/chunks/FormEditor-C_4JbAnS.cjs +2 -0
- package/dist/chunks/FormEditor-C_4JbAnS.cjs.map +1 -0
- package/dist/chunks/{FormEditor-BkBhcYI5.js → FormEditor-ucTbDyQt.js} +177 -161
- package/dist/chunks/FormEditor-ucTbDyQt.js.map +1 -0
- package/dist/chunks/NumberField-1EYJdwDY.cjs +2 -0
- package/dist/chunks/NumberField-1EYJdwDY.cjs.map +1 -0
- package/dist/chunks/NumberField-DizR4NJv.js +178 -0
- package/dist/chunks/NumberField-DizR4NJv.js.map +1 -0
- package/dist/chunks/Slider-BfvNPjRJ.cjs +2 -0
- package/dist/chunks/Slider-BfvNPjRJ.cjs.map +1 -0
- package/dist/chunks/Slider-Cab6NqhK.js +168 -0
- package/dist/chunks/Slider-Cab6NqhK.js.map +1 -0
- package/dist/chunks/decimal-Ca7qJExZ.cjs +2 -0
- package/dist/chunks/decimal-Ca7qJExZ.cjs.map +1 -0
- package/dist/chunks/decimal-hq_W9D3s.js +15 -0
- package/dist/chunks/decimal-hq_W9D3s.js.map +1 -0
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/FormEditor/README.md +33 -7
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +5 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +5 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.js +1 -1
- package/dist/components/NumberField/index.cjs +1 -2
- package/dist/components/NumberField/index.d.cts +10 -3
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts +10 -3
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +1 -128
- package/dist/components/NumberField/step.d.cts +29 -0
- package/dist/components/NumberField/step.d.cts.map +1 -0
- package/dist/components/NumberField/step.d.ts +29 -0
- package/dist/components/NumberField/step.d.ts.map +1 -0
- package/dist/components/Slider/index.cjs +1 -1
- package/dist/components/Slider/index.d.cts.map +1 -1
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js +1 -1
- package/dist/components/Slider/scale.d.cts +0 -2
- package/dist/components/Slider/scale.d.cts.map +1 -1
- package/dist/components/Slider/scale.d.ts +0 -2
- package/dist/components/Slider/scale.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/internal/decimal.d.cts +7 -0
- package/dist/internal/decimal.d.cts.map +1 -0
- package/dist/internal/decimal.d.ts +7 -0
- package/dist/internal/decimal.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/chunks/FormEditor-B4mtAxaU.cjs +0 -2
- package/dist/chunks/FormEditor-B4mtAxaU.cjs.map +0 -1
- package/dist/chunks/FormEditor-BkBhcYI5.js.map +0 -1
- package/dist/chunks/Slider-k8weRl34.cjs +0 -2
- package/dist/chunks/Slider-k8weRl34.cjs.map +0 -1
- package/dist/chunks/Slider-vdMFLX-H.js +0 -174
- package/dist/chunks/Slider-vdMFLX-H.js.map +0 -1
- package/dist/components/NumberField/index.cjs.map +0 -1
- package/dist/components/NumberField/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -864,7 +864,7 @@ import { Field, NumberField, NumberRangeField } from "@namroodinc/liquid-editori
|
|
|
864
864
|
</>;
|
|
865
865
|
```
|
|
866
866
|
|
|
867
|
-
Use `value`/`onValueChange` for controlled numbers and ranges; sizes are `sm`, `md` (default), and `lg`. Steppers honor `min`, `max`, and `step`; typing stays editable. Set `hasSteppers={false}`
|
|
867
|
+
Use `value`/`onValueChange` for controlled numbers and ranges; sizes are `sm`, `md` (default), and `lg`. Steppers and ArrowUp/ArrowDown honor `min`, `max`, and `step`; typing stays editable. A numeric `step` keeps stepped values on the grid `min + k × step` (from 0 without `min`), so they never fail browser step validation, and `max` stops at the last grid value inside it. An empty field counts as 0, but its first press lands on a bound at or beyond 0 (an empty `min={1}` field gives 1). With `step="any"`, steppers move by 1, or by the largest power of ten below the range when `min` and `max` are at most 1 apart, keeping the typed precision. The steppers stay out of the tab order and never take focus, so a tap does not open the soft keyboard. Set `hasSteppers={false}` to hide them. Name steppers after their field when several are present; `isDisabled` disables the whole widget.
|
|
868
868
|
|
|
869
869
|
### Slider
|
|
870
870
|
|
|
@@ -1235,7 +1235,7 @@ Radio and checkbox fields are groups, including when `options` contains one item
|
|
|
1235
1235
|
|
|
1236
1236
|
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.
|
|
1237
1237
|
|
|
1238
|
-
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 `
|
|
1238
|
+
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`, `hasSteppers`, `decreaseLabel`, and `increaseLabel`. Number fields show NumberField's − / + buttons by default, with NumberField's stepping rules above; set `hasSteppers: false` to hide them. Steppers are named after their field, such as "Increase Width"; translate the names with `decreaseLabel` and `increaseLabel`. The default `step: "any"` accepts typed decimals while the buttons move by 1, or by 0.1 across a 0–1 range; set a numeric `step` for another increment. Number schemas need finite bounds with `min <= max` and a positive step or `"any"`. See FormEditor's **NumberSteppers** story for bounds, affixes, typing-only, translated and disabled examples. `validateFormValues` enforces `maxLength`, numeric limits, and `picker.max`. `autoFocus` applies to text, number, select, boolean, UTC date-time, slider, and colour fields.
|
|
1239
1239
|
|
|
1240
1240
|
`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.
|
|
1241
1241
|
|
package/UPGRADING.md
CHANGED
|
@@ -2,6 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.7.0
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- FormEditor number fields now show NumberField's − / + steppers when
|
|
10
|
+
`hasSteppers` is omitted (previously hidden). Queries such as
|
|
11
|
+
`getByRole("button")` beside a FormEditor can now match several buttons, and
|
|
12
|
+
narrow layouts gain two buttons per number field. Set `hasSteppers: false` to
|
|
13
|
+
keep a field typing-only.
|
|
14
|
+
- NumberField steppers (standalone, in NumberRangeField and in FormEditor) are
|
|
15
|
+
out of the tab order (`tabindex="-1"`) and no longer move focus to the input
|
|
16
|
+
when pressed. Keyboard users step with ArrowUp/ArrowDown in the input; tests
|
|
17
|
+
that tabbed to "Decrease …"/"Increase …" or expected the input to gain focus
|
|
18
|
+
after a press need updating.
|
|
19
|
+
- NumberField stepping follows new rules (below): numeric steps snap to the
|
|
20
|
+
`min`-based grid, an empty field's first press lands on a bound at or beyond 0,
|
|
21
|
+
and `step="any"` moves by a power of ten below narrow ranges. Tests that
|
|
22
|
+
asserted the previous off-grid or `min + step` results need updating.
|
|
23
|
+
- FormEditor and `validateFormValues` now throw for number fields with non-finite
|
|
24
|
+
bounds, `min > max`, a `step` that is neither positive nor `"any"`, or empty
|
|
25
|
+
`decreaseLabel`/`increaseLabel`.
|
|
26
|
+
|
|
27
|
+
### FormEditor number steppers by default, with grid-aligned stepping
|
|
28
|
+
|
|
29
|
+
FormEditor number fields show NumberField's shared − / + buttons unless
|
|
30
|
+
`hasSteppers: false`. The adapter passes `hasSteppers` through, so NumberField
|
|
31
|
+
owns the default. New `decreaseLabel` and `increaseLabel` schema options replace
|
|
32
|
+
the default "Decrease {label}"/"Increase {label}" names for translation.
|
|
33
|
+
|
|
34
|
+
NumberField's steppers and ArrowUp/ArrowDown share one set of rules:
|
|
35
|
+
|
|
36
|
+
- A numeric `step` keeps stepped values on the grid `min + k × step` (from 0
|
|
37
|
+
without `min`). Off-grid values move to the neighbouring grid value, and `max`
|
|
38
|
+
stops at the last grid value inside it, so stepping never produces a value the
|
|
39
|
+
browser rejects as a step mismatch.
|
|
40
|
+
- An empty field counts as 0, but its first press lands on a bound at or beyond
|
|
41
|
+
0: an empty `min: 1` field gives 1, and `min: 0` gives 0.
|
|
42
|
+
- `step: "any"` moves by 1, or by the largest power of ten below the range when
|
|
43
|
+
`min` and `max` are at most 1 apart (0.1 for 0–1). Results keep the operands'
|
|
44
|
+
precision instead of rounding to 10 places.
|
|
45
|
+
- Out-of-range values only step back towards their range; a direction that
|
|
46
|
+
cannot move disables its stepper.
|
|
47
|
+
- Steppers stay out of the tab order and keep focus where it is, so a tap does
|
|
48
|
+
not open the soft keyboard and a second Enter cannot submit a form.
|
|
49
|
+
|
|
50
|
+
Adoption: set `hasSteppers: false` on fields that should stay typing-only. Add
|
|
51
|
+
`decreaseLabel`/`increaseLabel` to number fields in translated forms. Fix any
|
|
52
|
+
schema that now throws. If your form wraps FormEditor in a `<form>` and relies
|
|
53
|
+
on `validateFormValues`, add `noValidate` (as the FormEditor guide's example now
|
|
54
|
+
does): a typed number off a numeric step's grid still fails the browser's own
|
|
55
|
+
constraint validation. Update tests and selectors listed above.
|
|
56
|
+
|
|
57
|
+
Compatibility: explicit `hasSteppers` values keep their meaning. Value contracts
|
|
58
|
+
are unchanged. The `onKeyDown` you pass to NumberField runs first; calling
|
|
59
|
+
`preventDefault()` there for an arrow key skips NumberField's stepping, and
|
|
60
|
+
read-only inputs do not step. No dependency or manual version change.
|
|
61
|
+
|
|
62
|
+
Verification: run `npm run validate` and consuming lint/typechecks/tests/build.
|
|
63
|
+
Review FormEditor's NumberSteppers story in all four themes at desktop, 390px and
|
|
64
|
+
320px widths. Check the default buttons, the empty-minimum, ratio and translated
|
|
65
|
+
fields, the opt-out, min/max stops on the step grid, ArrowUp/ArrowDown, that
|
|
66
|
+
Tab moves between inputs without stopping on steppers, that pressing a stepper
|
|
67
|
+
leaves focus where it was, disabled controls, affixes and clearing.
|
|
68
|
+
|
|
5
69
|
## 0.6.9
|
|
6
70
|
|
|
7
71
|
### Shared collection, editor, loading and wizard presentation
|
|
@@ -6,7 +6,7 @@ import { TextField as i } from "../components/TextField/index.js";
|
|
|
6
6
|
import { FieldAffix as a } from "../components/FieldAffix/index.js";
|
|
7
7
|
import { Popover as o } from "../components/Popover/index.js";
|
|
8
8
|
import { i as s, n as c, r as l, t as u } from "./colour-CYEF4Q_n.js";
|
|
9
|
-
import { n as d } from "./Slider-
|
|
9
|
+
import { n as d } from "./Slider-Cab6NqhK.js";
|
|
10
10
|
import { forwardRef as f, useEffect as p, useId as m, useMemo as h, useRef as g, useState as _, useSyncExternalStore as v } from "react";
|
|
11
11
|
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/ColourField/focus.ts
|
|
@@ -469,4 +469,4 @@ var M = f(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
469
469
|
//#endregion
|
|
470
470
|
export { M as n, P as t };
|
|
471
471
|
|
|
472
|
-
//# sourceMappingURL=ColourField-
|
|
472
|
+
//# sourceMappingURL=ColourField-B-tjjBfA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColourField-DC6cLb9h.js","names":["_Fragment","Icon","mergeRefs","tabbableControls","parseColour","colourState","normaliseColour","colourHex","Slider","Fragment$1","focusAfterField","boundary","root","controls","element","clamp","value","ColourSquare","dragging","useRef","update","rect","event","onChange","colour","isDisabled","step","change","useColourValue","internal","setInternal","useState","defaultValue","current","selection","setSelection","hex","next","onValueChange","useColourDraft","draft","setDraft","isValid","eyeDropperConstructor","subscribe","noPresets","presetColumns","presetTarget","column","index","lastInColumn","count","key","ColourPanel","forwardRef","rest","ColourPanelContent","commit","inputRef","active","disabledRef","isPicking","setPicking","pickerError","setPickerError","hasEyeDropper","useSyncExternalStore","presetsId","useId","rgb","swatches","useMemo","unique","preset","presets","normalised","selectedIndex","swatch","useEffect","pickFromScreen","EyeDropper","result","onColourChange","error","className","style","picker","Button","delta","input","a","showPresets","radios","selected","ColourField","ariaInvalid","isOpen","setOpen","rootRef","openerRef","panelRef","panelId","fieldId","id","invalid","text","effectiveDisabled","disabled","readOnly","visible","onValidityChange","outside","target","toggle","opener","close","triggerProps","FieldAffix","TextField","ref","isInvalid","valid","type","discard","onBlur","onKeyDown","Popover"],"sources":["../../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 { 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\", \"ds-field-surface\", 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 align=\"start\"\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":";;;;;;;;;;;;AAGA,SAAgBU,EAAgB,GAAmB;CACjD,IAAMC,IAAWC,EAAK,QAAqB,qBAAqB,KAAK,SAAS,MACxEC,IAAWV,EAAiBQ,CAAQ,CAAC,CAAC,QAAQ,MAAY,CAACG,EAAQ,QAAQ,aAAa,CAAC;CAG/F,CADaD,EADAA,EAAS,KAAK,MAAYD,EAAK,SAASE,CAAO,CAAC,CAAC,CAAC,YAAY,EACrD,IAAO,MAAMD,EAAS,GAAA,EACtC,MAAM,EAAE,eAAe,GAAK,CAAC;AACrC;;;ACAA,SAASE,EAAM,GAAe;CAC5B,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,KAAKC,CAAK,CAAC;AACzC;AAEA,SAAgBC,EAAa,EAAE,WAAQ,eAAY,eAA+B;CA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pB;IACA;IACI;IACL;IACR,iBAAiB,MAAS;KAExB,AADAuF,EAAQ,GACRlE,EAAOpB,CAAI;IACb;GACD,CAAA;EACM,CAAA,CACN;;AAET,CAAC"}
|
|
1
|
+
{"version":3,"file":"ColourField-B-tjjBfA.js","names":["_Fragment","Icon","mergeRefs","tabbableControls","parseColour","colourState","normaliseColour","colourHex","Slider","Fragment$1","focusAfterField","boundary","root","controls","element","clamp","value","ColourSquare","dragging","useRef","update","rect","event","onChange","colour","isDisabled","step","change","useColourValue","internal","setInternal","useState","defaultValue","current","selection","setSelection","hex","next","onValueChange","useColourDraft","draft","setDraft","isValid","eyeDropperConstructor","subscribe","noPresets","presetColumns","presetTarget","column","index","lastInColumn","count","key","ColourPanel","forwardRef","rest","ColourPanelContent","commit","inputRef","active","disabledRef","isPicking","setPicking","pickerError","setPickerError","hasEyeDropper","useSyncExternalStore","presetsId","useId","rgb","swatches","useMemo","unique","preset","presets","normalised","selectedIndex","swatch","useEffect","pickFromScreen","EyeDropper","result","onColourChange","error","className","style","picker","Button","delta","input","a","showPresets","radios","selected","ColourField","ariaInvalid","isOpen","setOpen","rootRef","openerRef","panelRef","panelId","fieldId","id","invalid","text","effectiveDisabled","disabled","readOnly","visible","onValidityChange","outside","target","toggle","opener","close","triggerProps","FieldAffix","TextField","ref","isInvalid","valid","type","discard","onBlur","onKeyDown","Popover"],"sources":["../../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 { 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\", \"ds-field-surface\", 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 align=\"start\"\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":";;;;;;;;;;;;AAGA,SAAgBU,EAAgB,GAAmB;CACjD,IAAMC,IAAWC,EAAK,QAAqB,qBAAqB,KAAK,SAAS,MACxEC,IAAWV,EAAiBQ,CAAQ,CAAC,CAAC,QAAQ,MAAY,CAACG,EAAQ,QAAQ,aAAa,CAAC;CAG/F,CADaD,EADAA,EAAS,KAAK,MAAYD,EAAK,SAASE,CAAO,CAAC,CAAC,CAAC,YAAY,EACrD,IAAO,MAAMD,EAAS,GAAA,EACtC,MAAM,EAAE,eAAe,GAAK,CAAC;AACrC;;;ACAA,SAASE,EAAM,GAAe;CAC5B,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,KAAKC,CAAK,CAAC;AACzC;AAEA,SAAgBC,EAAa,EAAE,WAAQ,eAAY,eAA+B;CAChF,IAAMC,IAAWC,EAAsB,IAAI,GACrCC,KAAU,MAAwC;EACtD,IAAMC,IAAOC,EAAM,cAAc,sBAAsB;EACvD,AAAKD,EAAK,SAAUA,EAAK,UAGzBE,EAAS;GACP,GAAGC;GACH,GAAGT,GAAQO,EAAM,UAAUD,EAAK,QAAQA,EAAK,QAAS,GAAG;GACzD,GAAGN,GAAO,KAAKO,EAAM,UAAUD,EAAK,OAAOA,EAAK,UAAU,GAAG;EAC/D,CAAC;CACH;CAqBA,OACE,kBAAC,OAAD;EACE,WAAU;EACV,MAAK;EACL,UAAUI,IAAa,KAAK;EAC5B,cAAW;EACX,iBAAe;EACf,iBA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,iBAAec,IAAUR,IAAU,KAAA;IACnC,WAAW,CAAC,0BAA0BjB,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;IACzE,WAAW,MAAU;KACnB,IAAM/C,IAAOf,EAAM,OAAO,OACpBmG,IAAQ,CAACpF,EAAK,KAAK,KAAK,EAAQjC,EAAYiC,CAAI;KAEtD,AADAqF,GAAKrF,GAAMoF,CAAK,GACZA,KACFhE,EAAOpB,CAAI;IAEf;IACA,SAAS,MAAU;KAIjB,AAHKmE,KACHmB,EAAQ,GAEVC,IAAStG,CAAK;IAChB;IACA,YAAY,MAAU;KAEpB,AADAuG,IAAYvG,CAAK,GACb,GAAM,qBAGNA,EAAM,QAAQ,WAAW,CAACkF,MAC5BlF,EAAM,eAAe,GACrBqG,EAAQ,IAENrG,EAAM,QAAQ,eAAe,CAACoF,KAAqB,CAACE,MACtDtF,EAAM,eAAe,GACrB,EAAU,UAAUA,EAAM,eAC1B2E,EAAQ,EAAI;IAEhB;GACD,CAAA;EACS,CAAA,GACZ,kBAAC6B,GAAD;GACE,WAAWpE;GACX,UAAU4C;GACV,QAAQO;GACR,OAAM;GACK;GACD;GACV,IAAIR;GACJ,MAAK;GACL,cAAW;GAGX,UAAU;GACV,WAAU;GAEV,UAAA,kBAAC7C,GAAD;IACU;IACR,SAASpB;IACA;IACI;IACL;IACR,iBAAiB,MAAS;KAExB,AADAuF,EAAQ,GACRlE,EAAOpB,CAAI;IACb;GACD,CAAA;EACM,CAAA,CACN;;AAET,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./colour-BmtxDlWF.cjs"),t=require("./Icon-WOhlu6Rp.cjs"),n=require("../components/Button/index.cjs"),r=require("./mergeRefs-CZ-SArlE.cjs"),i=require("./portalScope-BVA1-Ypu.cjs"),a=require("../components/TextField/index.cjs"),o=require("../components/FieldAffix/index.cjs"),s=require("../components/Popover/index.cjs"),c=require("./Slider-k8weRl34.cjs");let l=require("react"),u=require("react/jsx-runtime");function d(e){let t=e.closest(`[aria-modal='true']`)??document.body,n=i.s(t).filter(e=>!e.closest(`.ds-popover`));(n[n.map(t=>e.contains(t)).lastIndexOf(!0)+1]??n[0])?.focus({preventScroll:!0})}function f(e){return Math.max(0,Math.min(100,e))}function p({colour:e,isDisabled:t,onChange:n}){let r=(0,l.useRef)(null),i=t=>{let r=t.currentTarget.getBoundingClientRect();r.width&&r.height&&n({...e,s:f((t.clientX-r.left)/r.width*100),v:f((1-(t.clientY-r.top)/r.height)*100)})};return(0,u.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:f(e.s-i)},ArrowRight:{s:f(e.s+i)},ArrowDown:{v:f(e.v-i)},ArrowUp:{v:f(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,u.jsx)(`span`,{className:`ds-colour-panel__thumb`,style:{left:`${e.s}%`,top:`${100-e.v}%`}})})}function m({value:t,defaultValue:n=``,onValueChange:r}){let[i,a]=(0,l.useState)(n),o=t??i,[s,c]=(0,l.useState)(()=>({source:o,colour:e.n(o)})),u=s.colour;return s.source!==o&&(u=e.n(o,u),c({source:o,colour:u})),{current:o,colour:u,commit:n=>{let i=typeof n==`string`?e.r(n):e.t(n);c({source:i,colour:typeof n==`string`?e.n(n,u):n}),t===void 0&&a(i),r?.(i)}}}function h(t,n){let[r,i]=(0,l.useState)(null);return r&&r.source!==t&&r.text===t&&i({source:t,text:t}),{text:r?.source===t?r.text:n||t,type:(n,r)=>i({source:r?e.r(n):t,text:n}),discard:()=>i(null)}}function g(){return window.EyeDropper}var _=()=>()=>{},v=[],y=8;function b(e,t,n){let r=t%y,i=r+Math.floor((n-1-r)/y)*y;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+y<n?t+y:r;case`ArrowUp`:return t>=y?t-y:i;default:return}}var x=(0,l.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,...r},i){let{current:a,colour:o,commit:s}=m({value:e,defaultValue:t,onValueChange:n});return(0,u.jsx)(S,{...r,ref:i,colour:o,current:a,onColourChange:s})}),S=(0,l.forwardRef)(function({colour:r,current:i,onColourChange:a,presets:o=v,showPresets:s=!0,picker:d=`custom`,isDisabled:f=!1,className:m,style:h,...x},S){let C=(0,l.useRef)(null),w=(0,l.useRef)(!0),T=(0,l.useRef)(f),[E,D]=(0,l.useState)(!1),[O,k]=(0,l.useState)(``),A=(0,l.useSyncExternalStore)(_,()=>!!g(),()=>!1),j=(0,l.useId)(),M=e.r(i),N=e.t({...r,a:1}),P=(0,l.useMemo)(()=>{let t=new Map;for(let n of o){let r=e.r(n);r&&!t.has(r)&&t.set(r,n)}return[...t].map(([e,t])=>({normalised:e,preset:t}))},[o]),F=P.findIndex(e=>e.normalised===M);(0,l.useEffect)(()=>{T.current=f},[f]),(0,l.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let I=async()=>{let t=g();if(!(!t||f||E)){D(!0),k(``);try{let n=await new t().open();w.current&&!T.current&&e.i(n.sRGBHex)&&a({...e.n(n.sRGBHex,r),a:r.a})}catch(e){w.current&&!(e instanceof DOMException&&e.name===`AbortError`)&&k(`Unable to pick a colour from the screen. Try again.`)}finally{w.current&&D(!1)}}};return(0,u.jsxs)(`div`,{...x,ref:S,className:[`ds-colour-panel`,`ds-field-surface`,m].filter(Boolean).join(` `),"data-disabled":f||void 0,style:{...h,"--colour-hue":`hsl(${r.h} 100% 50%)`,"--colour-rgb":N,"--colour-rgba":e.t(r)},children:[(0,u.jsxs)(`div`,{className:`ds-colour-panel__head`,children:[(0,u.jsx)(`span`,{children:`Colour`}),(0,u.jsx)(`span`,{className:`ds-colour-panel__value`,children:M||`No colour`})]}),d===`custom`?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(p,{colour:r,isDisabled:f,onChange:a}),(0,u.jsxs)(`div`,{className:`ds-colour-panel__hue-row`,children:[A&&(0,u.jsx)(n.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`pipette`,"aria-label":`Pick from screen`,isDisabled:f,"aria-busy":E||void 0,onClick:()=>void I()}),(0,u.jsx)(c.n,{className:`ds-colour-panel__hue`,value:r.h,min:0,max:360,step:1,hasValueLabel:!1,"aria-label":`Hue`,"aria-valuetext":`${Math.round(r.h)} degrees`,isDisabled:f,onValueChange:e=>a({...r,h:e}),onKeyDown:e=>{if(!e.shiftKey||![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key))return;e.preventDefault();let t=e.key===`ArrowRight`||e.key===`ArrowUp`?15:-15;a({...r,h:Math.max(0,Math.min(360,r.h+t))})}})]})]}):(0,u.jsxs)(`div`,{className:`ds-colour-panel__native`,children:[(0,u.jsx)(`input`,{ref:C,type:`color`,value:N,tabIndex:-1,"aria-hidden":`true`,disabled:f,onChange:t=>{e.i(t.target.value)&&a({...e.n(t.target.value,r),a:r.a})}}),(0,u.jsx)(n.Button,{variant:`neutral`,size:`sm`,iconStart:`pipette`,isDisabled:f,onClick:()=>{let e=C.current;if(e)try{e.showPicker?e.showPicker():e.click()}catch{e.click()}},children:`Custom colour…`})]}),(0,u.jsxs)(`div`,{className:`ds-colour-panel__opacity`,children:[(0,u.jsx)(`label`,{htmlFor:`${j}-opacity`,children:`Opacity`}),(0,u.jsx)(c.n,{id:`${j}-opacity`,className:`ds-colour-panel__alpha`,value:Math.round(r.a*100),min:0,max:100,step:1,suffix:`%`,isDisabled:f,onValueChange:e=>a({...r,a:e/100})})]}),s&&P.length>0&&(0,u.jsxs)(`div`,{className:`ds-colour-panel__presets`,children:[(0,u.jsx)(`span`,{id:j,className:`ds-colour-panel__presets-label`,children:`Presets`}),(0,u.jsx)(`div`,{className:`ds-colour-panel__grid`,role:`radiogroup`,"aria-labelledby":j,style:{"--colour-preset-columns":y},onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role='radio']`)),n=t.indexOf(e.target),r=n<0?void 0:b(e.key,n,t.length);r!==void 0&&(e.preventDefault(),t[r]?.focus(),t[r]?.click())},children:P.map(({normalised:e,preset:r},i)=>{let o=i===F;return(0,u.jsx)(n.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,role:`radio`,"aria-checked":o,"aria-label":r,title:r,tabIndex:i===Math.max(0,F)?0:-1,isDisabled:f,className:`ds-colour-panel__preset`,onClick:()=>a(r),children:(0,u.jsx)(`span`,{className:`ds-colour-swatch`,style:{"--colour-swatch":e},children:o&&(0,u.jsx)(t.t,{name:`check`,size:16,strokeWidth:3})})},e)})})]}),O&&(0,u.jsx)(`span`,{className:`ds-colour-panel__error`,role:`status`,children:O})]})}),C=(0,l.forwardRef)(function({value:t,defaultValue:c,onValueChange:f,onValidityChange:p,presets:g,showPresets:_,picker:v,placement:y,isDisabled:b=!1,disabled:x,readOnly:C,isInvalid:w,"aria-invalid":T,id:E,className:D,onBlur:O,onKeyDown:k,...A},j){let{current:M,colour:N,commit:P}=m({value:t,defaultValue:c,onValueChange:f}),[F,I]=(0,l.useState)(!1),L=(0,l.useRef)(null),R=(0,l.useRef)(null),z=(0,l.useRef)(null),B=(0,l.useRef)(null),V=(0,l.useId)(),H=E??`${V}-input`,U=e.r(M),{text:W,type:G,discard:K}=h(M,U),q=!(!W.trim()||e.i(W)),J=b||x;F&&(J||C)&&I(!1);let Y=F&&!J&&!C;(0,l.useEffect)(()=>{p?.(!q),R.current?.setCustomValidity(q?`Enter a colour, such as #0052CC or rebeccapurple.`:``)},[q,p]),(0,l.useEffect)(()=>{if(!Y)return;B.current&&i.s(B.current)[0]?.focus({preventScroll:!0});let e=e=>{let t=e.target;t&&!L.current?.contains(t)&&!B.current?.contains(t)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Y]);let X=e=>{z.current=e,I(!Y)},Z=()=>{I(!1),z.current?.focus({preventScroll:!0})},Q={"aria-label":Y?`Close colour picker`:`Open colour picker`,"aria-haspopup":`dialog`,"aria-expanded":Y,"aria-controls":Y?V:void 0,isDisabled:J||C};return(0,u.jsxs)(`div`,{className:`ds-colour-field`,ref:L,onBlur:e=>{let t=e.relatedTarget;t&&!L.current?.contains(t)&&!B.current?.contains(t)&&I(!1)},onKeyDown:e=>{if(Y&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Z()),!Y||e.key!==`Tab`||!B.current?.contains(e.target))return;let t=i.s(B.current);(e.shiftKey?e.target===t[0]:e.target===t.at(-1))&&(e.preventDefault(),e.stopPropagation(),I(!1),e.shiftKey?z.current?.focus({preventScroll:!0}):L.current&&d(L.current))},children:[(0,u.jsx)(o.FieldAffix,{isLeadInteractive:!0,isTrailInteractive:!0,lead:(0,u.jsx)(n.Button,{"aria-hidden":`true`,tabIndex:-1,isDisabled:Q.isDisabled,variant:`simple`,size:`xs`,isIconOnly:!0,onMouseDown:e=>e.preventDefault(),onClick:()=>{z.current=R.current,Y?Z():I(!0)},children:(0,u.jsx)(`span`,{className:`ds-colour-swatch ds-colour-field__swatch`,style:{"--colour-swatch":U||`transparent`}})}),trail:(0,u.jsx)(n.Button,{...Q,variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`chevron-down`,onClick:e=>X(e.currentTarget)}),children:(0,u.jsx)(a.TextField,{...A,ref:r.t(R,j),id:H,disabled:J,readOnly:C,spellCheck:!1,autoComplete:`off`,value:W,"aria-invalid":q||w||T||void 0,"aria-haspopup":`dialog`,"aria-controls":Y?V:void 0,className:[`ds-colour-field__input`,D].filter(Boolean).join(` `),onChange:t=>{let n=t.target.value,r=!n.trim()||!!e.i(n);G(n,r),r&&P(n)},onBlur:e=>{q||K(),O?.(e)},onKeyDown:e=>{k?.(e),!e.defaultPrevented&&(e.key===`Enter`&&!q&&(e.preventDefault(),K()),e.key===`ArrowDown`&&!J&&!C&&(e.preventDefault(),z.current=e.currentTarget,I(!0)))}})}),(0,u.jsx)(s.Popover,{anchorRef:R,anchorId:H,isOpen:Y,align:`start`,placement:y,panelRef:B,id:V,role:`dialog`,"aria-label":`Choose a colour`,tabIndex:-1,className:`ds-colour-field__popover`,children:(0,u.jsx)(S,{colour:N,current:U,presets:g,showPresets:_,picker:v,onColourChange:e=>{K(),P(e)}})})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return C}});
|
|
2
|
-
//# sourceMappingURL=ColourField-
|
|
1
|
+
const e=require("./colour-BmtxDlWF.cjs"),t=require("./Icon-WOhlu6Rp.cjs"),n=require("../components/Button/index.cjs"),r=require("./mergeRefs-CZ-SArlE.cjs"),i=require("./portalScope-BVA1-Ypu.cjs"),a=require("../components/TextField/index.cjs"),o=require("../components/FieldAffix/index.cjs"),s=require("../components/Popover/index.cjs"),c=require("./Slider-BfvNPjRJ.cjs");let l=require("react"),u=require("react/jsx-runtime");function d(e){let t=e.closest(`[aria-modal='true']`)??document.body,n=i.s(t).filter(e=>!e.closest(`.ds-popover`));(n[n.map(t=>e.contains(t)).lastIndexOf(!0)+1]??n[0])?.focus({preventScroll:!0})}function f(e){return Math.max(0,Math.min(100,e))}function p({colour:e,isDisabled:t,onChange:n}){let r=(0,l.useRef)(null),i=t=>{let r=t.currentTarget.getBoundingClientRect();r.width&&r.height&&n({...e,s:f((t.clientX-r.left)/r.width*100),v:f((1-(t.clientY-r.top)/r.height)*100)})};return(0,u.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:f(e.s-i)},ArrowRight:{s:f(e.s+i)},ArrowDown:{v:f(e.v-i)},ArrowUp:{v:f(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,u.jsx)(`span`,{className:`ds-colour-panel__thumb`,style:{left:`${e.s}%`,top:`${100-e.v}%`}})})}function m({value:t,defaultValue:n=``,onValueChange:r}){let[i,a]=(0,l.useState)(n),o=t??i,[s,c]=(0,l.useState)(()=>({source:o,colour:e.n(o)})),u=s.colour;return s.source!==o&&(u=e.n(o,u),c({source:o,colour:u})),{current:o,colour:u,commit:n=>{let i=typeof n==`string`?e.r(n):e.t(n);c({source:i,colour:typeof n==`string`?e.n(n,u):n}),t===void 0&&a(i),r?.(i)}}}function h(t,n){let[r,i]=(0,l.useState)(null);return r&&r.source!==t&&r.text===t&&i({source:t,text:t}),{text:r?.source===t?r.text:n||t,type:(n,r)=>i({source:r?e.r(n):t,text:n}),discard:()=>i(null)}}function g(){return window.EyeDropper}var _=()=>()=>{},v=[],y=8;function b(e,t,n){let r=t%y,i=r+Math.floor((n-1-r)/y)*y;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+y<n?t+y:r;case`ArrowUp`:return t>=y?t-y:i;default:return}}var x=(0,l.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,...r},i){let{current:a,colour:o,commit:s}=m({value:e,defaultValue:t,onValueChange:n});return(0,u.jsx)(S,{...r,ref:i,colour:o,current:a,onColourChange:s})}),S=(0,l.forwardRef)(function({colour:r,current:i,onColourChange:a,presets:o=v,showPresets:s=!0,picker:d=`custom`,isDisabled:f=!1,className:m,style:h,...x},S){let C=(0,l.useRef)(null),w=(0,l.useRef)(!0),T=(0,l.useRef)(f),[E,D]=(0,l.useState)(!1),[O,k]=(0,l.useState)(``),A=(0,l.useSyncExternalStore)(_,()=>!!g(),()=>!1),j=(0,l.useId)(),M=e.r(i),N=e.t({...r,a:1}),P=(0,l.useMemo)(()=>{let t=new Map;for(let n of o){let r=e.r(n);r&&!t.has(r)&&t.set(r,n)}return[...t].map(([e,t])=>({normalised:e,preset:t}))},[o]),F=P.findIndex(e=>e.normalised===M);(0,l.useEffect)(()=>{T.current=f},[f]),(0,l.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let I=async()=>{let t=g();if(!(!t||f||E)){D(!0),k(``);try{let n=await new t().open();w.current&&!T.current&&e.i(n.sRGBHex)&&a({...e.n(n.sRGBHex,r),a:r.a})}catch(e){w.current&&!(e instanceof DOMException&&e.name===`AbortError`)&&k(`Unable to pick a colour from the screen. Try again.`)}finally{w.current&&D(!1)}}};return(0,u.jsxs)(`div`,{...x,ref:S,className:[`ds-colour-panel`,`ds-field-surface`,m].filter(Boolean).join(` `),"data-disabled":f||void 0,style:{...h,"--colour-hue":`hsl(${r.h} 100% 50%)`,"--colour-rgb":N,"--colour-rgba":e.t(r)},children:[(0,u.jsxs)(`div`,{className:`ds-colour-panel__head`,children:[(0,u.jsx)(`span`,{children:`Colour`}),(0,u.jsx)(`span`,{className:`ds-colour-panel__value`,children:M||`No colour`})]}),d===`custom`?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(p,{colour:r,isDisabled:f,onChange:a}),(0,u.jsxs)(`div`,{className:`ds-colour-panel__hue-row`,children:[A&&(0,u.jsx)(n.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`pipette`,"aria-label":`Pick from screen`,isDisabled:f,"aria-busy":E||void 0,onClick:()=>void I()}),(0,u.jsx)(c.n,{className:`ds-colour-panel__hue`,value:r.h,min:0,max:360,step:1,hasValueLabel:!1,"aria-label":`Hue`,"aria-valuetext":`${Math.round(r.h)} degrees`,isDisabled:f,onValueChange:e=>a({...r,h:e}),onKeyDown:e=>{if(!e.shiftKey||![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key))return;e.preventDefault();let t=e.key===`ArrowRight`||e.key===`ArrowUp`?15:-15;a({...r,h:Math.max(0,Math.min(360,r.h+t))})}})]})]}):(0,u.jsxs)(`div`,{className:`ds-colour-panel__native`,children:[(0,u.jsx)(`input`,{ref:C,type:`color`,value:N,tabIndex:-1,"aria-hidden":`true`,disabled:f,onChange:t=>{e.i(t.target.value)&&a({...e.n(t.target.value,r),a:r.a})}}),(0,u.jsx)(n.Button,{variant:`neutral`,size:`sm`,iconStart:`pipette`,isDisabled:f,onClick:()=>{let e=C.current;if(e)try{e.showPicker?e.showPicker():e.click()}catch{e.click()}},children:`Custom colour…`})]}),(0,u.jsxs)(`div`,{className:`ds-colour-panel__opacity`,children:[(0,u.jsx)(`label`,{htmlFor:`${j}-opacity`,children:`Opacity`}),(0,u.jsx)(c.n,{id:`${j}-opacity`,className:`ds-colour-panel__alpha`,value:Math.round(r.a*100),min:0,max:100,step:1,suffix:`%`,isDisabled:f,onValueChange:e=>a({...r,a:e/100})})]}),s&&P.length>0&&(0,u.jsxs)(`div`,{className:`ds-colour-panel__presets`,children:[(0,u.jsx)(`span`,{id:j,className:`ds-colour-panel__presets-label`,children:`Presets`}),(0,u.jsx)(`div`,{className:`ds-colour-panel__grid`,role:`radiogroup`,"aria-labelledby":j,style:{"--colour-preset-columns":y},onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role='radio']`)),n=t.indexOf(e.target),r=n<0?void 0:b(e.key,n,t.length);r!==void 0&&(e.preventDefault(),t[r]?.focus(),t[r]?.click())},children:P.map(({normalised:e,preset:r},i)=>{let o=i===F;return(0,u.jsx)(n.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,role:`radio`,"aria-checked":o,"aria-label":r,title:r,tabIndex:i===Math.max(0,F)?0:-1,isDisabled:f,className:`ds-colour-panel__preset`,onClick:()=>a(r),children:(0,u.jsx)(`span`,{className:`ds-colour-swatch`,style:{"--colour-swatch":e},children:o&&(0,u.jsx)(t.t,{name:`check`,size:16,strokeWidth:3})})},e)})})]}),O&&(0,u.jsx)(`span`,{className:`ds-colour-panel__error`,role:`status`,children:O})]})}),C=(0,l.forwardRef)(function({value:t,defaultValue:c,onValueChange:f,onValidityChange:p,presets:g,showPresets:_,picker:v,placement:y,isDisabled:b=!1,disabled:x,readOnly:C,isInvalid:w,"aria-invalid":T,id:E,className:D,onBlur:O,onKeyDown:k,...A},j){let{current:M,colour:N,commit:P}=m({value:t,defaultValue:c,onValueChange:f}),[F,I]=(0,l.useState)(!1),L=(0,l.useRef)(null),R=(0,l.useRef)(null),z=(0,l.useRef)(null),B=(0,l.useRef)(null),V=(0,l.useId)(),H=E??`${V}-input`,U=e.r(M),{text:W,type:G,discard:K}=h(M,U),q=!(!W.trim()||e.i(W)),J=b||x;F&&(J||C)&&I(!1);let Y=F&&!J&&!C;(0,l.useEffect)(()=>{p?.(!q),R.current?.setCustomValidity(q?`Enter a colour, such as #0052CC or rebeccapurple.`:``)},[q,p]),(0,l.useEffect)(()=>{if(!Y)return;B.current&&i.s(B.current)[0]?.focus({preventScroll:!0});let e=e=>{let t=e.target;t&&!L.current?.contains(t)&&!B.current?.contains(t)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Y]);let X=e=>{z.current=e,I(!Y)},Z=()=>{I(!1),z.current?.focus({preventScroll:!0})},Q={"aria-label":Y?`Close colour picker`:`Open colour picker`,"aria-haspopup":`dialog`,"aria-expanded":Y,"aria-controls":Y?V:void 0,isDisabled:J||C};return(0,u.jsxs)(`div`,{className:`ds-colour-field`,ref:L,onBlur:e=>{let t=e.relatedTarget;t&&!L.current?.contains(t)&&!B.current?.contains(t)&&I(!1)},onKeyDown:e=>{if(Y&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Z()),!Y||e.key!==`Tab`||!B.current?.contains(e.target))return;let t=i.s(B.current);(e.shiftKey?e.target===t[0]:e.target===t.at(-1))&&(e.preventDefault(),e.stopPropagation(),I(!1),e.shiftKey?z.current?.focus({preventScroll:!0}):L.current&&d(L.current))},children:[(0,u.jsx)(o.FieldAffix,{isLeadInteractive:!0,isTrailInteractive:!0,lead:(0,u.jsx)(n.Button,{"aria-hidden":`true`,tabIndex:-1,isDisabled:Q.isDisabled,variant:`simple`,size:`xs`,isIconOnly:!0,onMouseDown:e=>e.preventDefault(),onClick:()=>{z.current=R.current,Y?Z():I(!0)},children:(0,u.jsx)(`span`,{className:`ds-colour-swatch ds-colour-field__swatch`,style:{"--colour-swatch":U||`transparent`}})}),trail:(0,u.jsx)(n.Button,{...Q,variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`chevron-down`,onClick:e=>X(e.currentTarget)}),children:(0,u.jsx)(a.TextField,{...A,ref:r.t(R,j),id:H,disabled:J,readOnly:C,spellCheck:!1,autoComplete:`off`,value:W,"aria-invalid":q||w||T||void 0,"aria-haspopup":`dialog`,"aria-controls":Y?V:void 0,className:[`ds-colour-field__input`,D].filter(Boolean).join(` `),onChange:t=>{let n=t.target.value,r=!n.trim()||!!e.i(n);G(n,r),r&&P(n)},onBlur:e=>{q||K(),O?.(e)},onKeyDown:e=>{k?.(e),!e.defaultPrevented&&(e.key===`Enter`&&!q&&(e.preventDefault(),K()),e.key===`ArrowDown`&&!J&&!C&&(e.preventDefault(),z.current=e.currentTarget,I(!0)))}})}),(0,u.jsx)(s.Popover,{anchorRef:R,anchorId:H,isOpen:Y,align:`start`,placement:y,panelRef:B,id:V,role:`dialog`,"aria-label":`Choose a colour`,tabIndex:-1,className:`ds-colour-field__popover`,children:(0,u.jsx)(S,{colour:N,current:U,presets:g,showPresets:_,picker:v,onColourChange:e=>{K(),P(e)}})})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return C}});
|
|
2
|
+
//# sourceMappingURL=ColourField-ynUP1pfN.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColourField-NnFxLEsh.cjs","names":["tabbableControls","useRef","useState","colourState","normaliseColour","colourHex","forwardRef","useRef","useState","useSyncExternalStore","useId","normaliseColour","colourHex","useMemo","parseColour","colourState","_Fragment","Button","Slider","Icon","forwardRef","useState","useRef","useId","normaliseColour","parseColour","tabbableControls","FieldAffix","Button","TextField","mergeRefs","Popover","require_colour","require_Icon","require_components_Button_index","require_mergeRefs","require_portalScope","require_components_TextField_index","require_components_FieldAffix_index","require_components_Popover_index","require_Slider","react","react_jsx_runtime","focusAfterField","boundary","root","controls","element","clamp","value","ColourSquare","dragging","update","rect","event","onChange","colour","isDisabled","step","change","useColourValue","internal","setInternal","defaultValue","current","selection","setSelection","hex","next","onValueChange","useColourDraft","draft","setDraft","isValid","eyeDropperConstructor","subscribe","noPresets","presetColumns","presetTarget","column","index","lastInColumn","count","key","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","delta","input","a","showPresets","radios","selected","ColourField","ariaInvalid","isOpen","setOpen","rootRef","openerRef","panelRef","panelId","fieldId","id","invalid","text","effectiveDisabled","disabled","readOnly","visible","onValidityChange","outside","target","toggle","opener","close","triggerProps","ref","isInvalid","valid","type","discard","onBlur","onKeyDown"],"sources":["../../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 { 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\", \"ds-field-surface\", 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 align=\"start\"\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,yaAGA,SAAgB2C,EAAgB,EAAmB,CACjD,IAAMC,EAAWC,EAAK,QAAqB,qBAAqB,GAAK,SAAS,KACxEC,EAAW9C,EAAAA,EAAiB4C,CAAQ,CAAC,CAAC,OAAQ,GAAY,CAACG,EAAQ,QAAQ,aAAa,CAAC,GAElFD,EADAA,EAAS,IAAK,GAAYD,EAAK,SAASE,CAAO,CAAC,CAAC,CAAC,YAAY,EACrD,EAAO,IAAMD,EAAS,GAAA,EACtC,MAAM,CAAE,cAAe,EAAK,CAAC,CACrC,CCAA,SAASE,EAAM,EAAe,CAC5B,OAAO,K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AAU,GACV,UAAU,2BAEV,UAAA,EAAApF,EAAA,IAAA,CAAC4C,EAAD,CACU,SACR,QAASnB,EACA,UACI,cACL,SACR,eAAiB,GAAS,CACxB+E,EAAQ,EACR3D,EAAOnB,CAAI,CACb,CACD,CAAA,CACM,CAAA,CACN,C,EAET,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"ColourField-ynUP1pfN.cjs","names":["tabbableControls","useRef","useState","colourState","normaliseColour","colourHex","forwardRef","useRef","useState","useSyncExternalStore","useId","normaliseColour","colourHex","useMemo","parseColour","colourState","_Fragment","Button","Slider","Icon","forwardRef","useState","useRef","useId","normaliseColour","parseColour","tabbableControls","FieldAffix","Button","TextField","mergeRefs","Popover","require_colour","require_Icon","require_components_Button_index","require_mergeRefs","require_portalScope","require_components_TextField_index","require_components_FieldAffix_index","require_components_Popover_index","require_Slider","react","react_jsx_runtime","focusAfterField","boundary","root","controls","element","clamp","value","ColourSquare","dragging","update","rect","event","onChange","colour","isDisabled","step","change","useColourValue","internal","setInternal","defaultValue","current","selection","setSelection","hex","next","onValueChange","useColourDraft","draft","setDraft","isValid","eyeDropperConstructor","subscribe","noPresets","presetColumns","presetTarget","column","index","lastInColumn","count","key","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","delta","input","a","showPresets","radios","selected","ColourField","ariaInvalid","isOpen","setOpen","rootRef","openerRef","panelRef","panelId","fieldId","id","invalid","text","effectiveDisabled","disabled","readOnly","visible","onValidityChange","outside","target","toggle","opener","close","triggerProps","ref","isInvalid","valid","type","discard","onBlur","onKeyDown"],"sources":["../../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 { 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\", \"ds-field-surface\", 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 align=\"start\"\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,yaAGA,SAAgB2C,EAAgB,EAAmB,CACjD,IAAMC,EAAWC,EAAK,QAAqB,qBAAqB,GAAK,SAAS,KACxEC,EAAW9C,EAAAA,EAAiB4C,CAAQ,CAAC,CAAC,OAAQ,GAAY,CAACG,EAAQ,QAAQ,aAAa,CAAC,GAElFD,EADAA,EAAS,IAAK,GAAYD,EAAK,SAASE,CAAO,CAAC,CAAC,CAAC,YAAY,EACrD,EAAO,IAAMD,EAAS,GAAA,EACtC,MAAM,CAAE,cAAe,EAAK,CAAC,CACrC,CCAA,SAASE,EAAM,EAAe,CAC5B,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,IAAKC,CAAK,CAAC,CACzC,CAEA,SAAgBC,EAAa,CAAE,SAAQ,aAAY,YAA+B,CAChF,IAAMC,GAAA,EAAWlD,EAAAA,OAAAA,CAAsB,IAAI,EACrCmD,EAAU,GAAwC,CACtD,IAAMC,EAAOC,EAAM,cAAc,sBAAsB,EAClDD,EAAK,OAAUA,EAAK,QAGzBE,EAAS,CACP,GAAGC,EACH,EAAG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