@namroodinc/liquid-editorial 0.6.8 → 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.
Files changed (181) hide show
  1. package/README.md +110 -4
  2. package/UPGRADING.md +129 -0
  3. package/dist/chunks/CollectionView-BIuOL917.cjs +2 -0
  4. package/dist/chunks/CollectionView-BIuOL917.cjs.map +1 -0
  5. package/dist/chunks/CollectionView-Cr12UFWa.js +179 -0
  6. package/dist/chunks/CollectionView-Cr12UFWa.js.map +1 -0
  7. package/dist/chunks/{ColourField-DC6cLb9h.js → ColourField-B-tjjBfA.js} +2 -2
  8. package/dist/chunks/{ColourField-DC6cLb9h.js.map → ColourField-B-tjjBfA.js.map} +1 -1
  9. package/dist/chunks/{ColourField-NnFxLEsh.cjs → ColourField-ynUP1pfN.cjs} +2 -2
  10. package/dist/chunks/{ColourField-NnFxLEsh.cjs.map → ColourField-ynUP1pfN.cjs.map} +1 -1
  11. package/dist/chunks/FormEditor-C_4JbAnS.cjs +2 -0
  12. package/dist/chunks/FormEditor-C_4JbAnS.cjs.map +1 -0
  13. package/dist/chunks/{FormEditor-BkBhcYI5.js → FormEditor-ucTbDyQt.js} +177 -161
  14. package/dist/chunks/FormEditor-ucTbDyQt.js.map +1 -0
  15. package/dist/chunks/LoadState-B7GTDlWv.js +71 -0
  16. package/dist/chunks/LoadState-B7GTDlWv.js.map +1 -0
  17. package/dist/chunks/LoadState-C7tQ6fIP.cjs +2 -0
  18. package/dist/chunks/LoadState-C7tQ6fIP.cjs.map +1 -0
  19. package/dist/chunks/NumberField-1EYJdwDY.cjs +2 -0
  20. package/dist/chunks/NumberField-1EYJdwDY.cjs.map +1 -0
  21. package/dist/chunks/NumberField-DizR4NJv.js +178 -0
  22. package/dist/chunks/NumberField-DizR4NJv.js.map +1 -0
  23. package/dist/chunks/Slider-BfvNPjRJ.cjs +2 -0
  24. package/dist/chunks/Slider-BfvNPjRJ.cjs.map +1 -0
  25. package/dist/chunks/Slider-Cab6NqhK.js +168 -0
  26. package/dist/chunks/Slider-Cab6NqhK.js.map +1 -0
  27. package/dist/chunks/Wizard-B_CPW1V6.cjs +2 -0
  28. package/dist/chunks/Wizard-B_CPW1V6.cjs.map +1 -0
  29. package/dist/chunks/Wizard-C1iR5z44.js +99 -0
  30. package/dist/chunks/Wizard-C1iR5z44.js.map +1 -0
  31. package/dist/chunks/decimal-Ca7qJExZ.cjs +2 -0
  32. package/dist/chunks/decimal-Ca7qJExZ.cjs.map +1 -0
  33. package/dist/chunks/decimal-hq_W9D3s.js +15 -0
  34. package/dist/chunks/decimal-hq_W9D3s.js.map +1 -0
  35. package/dist/components/CollectionView/empty.d.cts +15 -0
  36. package/dist/components/CollectionView/empty.d.cts.map +1 -0
  37. package/dist/components/CollectionView/empty.d.ts +15 -0
  38. package/dist/components/CollectionView/empty.d.ts.map +1 -0
  39. package/dist/components/CollectionView/filters.d.cts +6 -0
  40. package/dist/components/CollectionView/filters.d.cts.map +1 -0
  41. package/dist/components/CollectionView/filters.d.ts +6 -0
  42. package/dist/components/CollectionView/filters.d.ts.map +1 -0
  43. package/dist/components/CollectionView/index.cjs +1 -0
  44. package/dist/components/CollectionView/index.d.cts +6 -0
  45. package/dist/components/CollectionView/index.d.cts.map +1 -0
  46. package/dist/components/CollectionView/index.d.ts +6 -0
  47. package/dist/components/CollectionView/index.d.ts.map +1 -0
  48. package/dist/components/CollectionView/index.js +2 -0
  49. package/dist/components/CollectionView/style.css +70 -0
  50. package/dist/components/CollectionView/toolbar.d.cts +5 -0
  51. package/dist/components/CollectionView/toolbar.d.cts.map +1 -0
  52. package/dist/components/CollectionView/toolbar.d.ts +5 -0
  53. package/dist/components/CollectionView/toolbar.d.ts.map +1 -0
  54. package/dist/components/CollectionView/types.d.cts +40 -0
  55. package/dist/components/CollectionView/types.d.cts.map +1 -0
  56. package/dist/components/CollectionView/types.d.ts +40 -0
  57. package/dist/components/CollectionView/types.d.ts.map +1 -0
  58. package/dist/components/ColourField/index.cjs +1 -1
  59. package/dist/components/ColourField/index.js +1 -1
  60. package/dist/components/EditLayout/style.css +1 -1
  61. package/dist/components/EditSection/index.cjs +2 -0
  62. package/dist/components/EditSection/index.cjs.map +1 -0
  63. package/dist/components/EditSection/index.d.cts +9 -0
  64. package/dist/components/EditSection/index.d.cts.map +1 -0
  65. package/dist/components/EditSection/index.d.ts +9 -0
  66. package/dist/components/EditSection/index.d.ts.map +1 -0
  67. package/dist/components/EditSection/index.js +22 -0
  68. package/dist/components/EditSection/index.js.map +1 -0
  69. package/dist/components/EditSection/style.css +31 -0
  70. package/dist/components/FormEditor/README.md +49 -7
  71. package/dist/components/FormEditor/index.cjs +1 -1
  72. package/dist/components/FormEditor/index.js +1 -1
  73. package/dist/components/FormEditor/model.d.cts +5 -0
  74. package/dist/components/FormEditor/model.d.cts.map +1 -1
  75. package/dist/components/FormEditor/model.d.ts +5 -0
  76. package/dist/components/FormEditor/model.d.ts.map +1 -1
  77. package/dist/components/ImageCropper/index.cjs +1 -1
  78. package/dist/components/ImageCropper/index.js +1 -1
  79. package/dist/components/LoadState/error.d.cts +13 -0
  80. package/dist/components/LoadState/error.d.cts.map +1 -0
  81. package/dist/components/LoadState/error.d.ts +13 -0
  82. package/dist/components/LoadState/error.d.ts.map +1 -0
  83. package/dist/components/LoadState/index.cjs +1 -0
  84. package/dist/components/LoadState/index.d.cts +15 -0
  85. package/dist/components/LoadState/index.d.cts.map +1 -0
  86. package/dist/components/LoadState/index.d.ts +15 -0
  87. package/dist/components/LoadState/index.d.ts.map +1 -0
  88. package/dist/components/LoadState/index.js +1 -0
  89. package/dist/components/LoadState/types.d.cts +3 -0
  90. package/dist/components/LoadState/types.d.cts.map +1 -0
  91. package/dist/components/LoadState/types.d.ts +3 -0
  92. package/dist/components/LoadState/types.d.ts.map +1 -0
  93. package/dist/components/LoadState/useRetryAttempt.d.cts +15 -0
  94. package/dist/components/LoadState/useRetryAttempt.d.cts.map +1 -0
  95. package/dist/components/LoadState/useRetryAttempt.d.ts +15 -0
  96. package/dist/components/LoadState/useRetryAttempt.d.ts.map +1 -0
  97. package/dist/components/MetaList/index.cjs +2 -0
  98. package/dist/components/MetaList/index.cjs.map +1 -0
  99. package/dist/components/MetaList/index.d.cts +7 -0
  100. package/dist/components/MetaList/index.d.cts.map +1 -0
  101. package/dist/components/MetaList/index.d.ts +7 -0
  102. package/dist/components/MetaList/index.d.ts.map +1 -0
  103. package/dist/components/MetaList/index.js +13 -0
  104. package/dist/components/MetaList/index.js.map +1 -0
  105. package/dist/components/MetaList/style.css +19 -0
  106. package/dist/components/NumberField/index.cjs +1 -2
  107. package/dist/components/NumberField/index.d.cts +10 -3
  108. package/dist/components/NumberField/index.d.cts.map +1 -1
  109. package/dist/components/NumberField/index.d.ts +10 -3
  110. package/dist/components/NumberField/index.d.ts.map +1 -1
  111. package/dist/components/NumberField/index.js +1 -128
  112. package/dist/components/NumberField/step.d.cts +29 -0
  113. package/dist/components/NumberField/step.d.cts.map +1 -0
  114. package/dist/components/NumberField/step.d.ts +29 -0
  115. package/dist/components/NumberField/step.d.ts.map +1 -0
  116. package/dist/components/PageHeader/index.cjs +2 -0
  117. package/dist/components/PageHeader/index.cjs.map +1 -0
  118. package/dist/components/PageHeader/index.d.cts +9 -0
  119. package/dist/components/PageHeader/index.d.cts.map +1 -0
  120. package/dist/components/PageHeader/index.d.ts +9 -0
  121. package/dist/components/PageHeader/index.d.ts.map +1 -0
  122. package/dist/components/PageHeader/index.js +27 -0
  123. package/dist/components/PageHeader/index.js.map +1 -0
  124. package/dist/components/PageHeader/style.css +39 -0
  125. package/dist/components/Slider/index.cjs +1 -1
  126. package/dist/components/Slider/index.d.cts.map +1 -1
  127. package/dist/components/Slider/index.d.ts.map +1 -1
  128. package/dist/components/Slider/index.js +1 -1
  129. package/dist/components/Slider/scale.d.cts +0 -2
  130. package/dist/components/Slider/scale.d.cts.map +1 -1
  131. package/dist/components/Slider/scale.d.ts +0 -2
  132. package/dist/components/Slider/scale.d.ts.map +1 -1
  133. package/dist/components/Stepper/index.cjs +1 -1
  134. package/dist/components/Stepper/index.cjs.map +1 -1
  135. package/dist/components/Stepper/index.d.cts +8 -0
  136. package/dist/components/Stepper/index.d.cts.map +1 -1
  137. package/dist/components/Stepper/index.d.ts +8 -0
  138. package/dist/components/Stepper/index.d.ts.map +1 -1
  139. package/dist/components/Stepper/index.js +15 -14
  140. package/dist/components/Stepper/index.js.map +1 -1
  141. package/dist/components/Stepper/style.css +53 -0
  142. package/dist/components/Wizard/actions.d.cts +13 -0
  143. package/dist/components/Wizard/actions.d.cts.map +1 -0
  144. package/dist/components/Wizard/actions.d.ts +13 -0
  145. package/dist/components/Wizard/actions.d.ts.map +1 -0
  146. package/dist/components/Wizard/index.cjs +1 -0
  147. package/dist/components/Wizard/index.d.cts +7 -0
  148. package/dist/components/Wizard/index.d.cts.map +1 -0
  149. package/dist/components/Wizard/index.d.ts +7 -0
  150. package/dist/components/Wizard/index.d.ts.map +1 -0
  151. package/dist/components/Wizard/index.js +2 -0
  152. package/dist/components/Wizard/review-table.d.cts +13 -0
  153. package/dist/components/Wizard/review-table.d.cts.map +1 -0
  154. package/dist/components/Wizard/review-table.d.ts +13 -0
  155. package/dist/components/Wizard/review-table.d.ts.map +1 -0
  156. package/dist/components/Wizard/style.css +13 -0
  157. package/dist/components/Wizard/types.d.cts +35 -0
  158. package/dist/components/Wizard/types.d.cts.map +1 -0
  159. package/dist/components/Wizard/types.d.ts +35 -0
  160. package/dist/components/Wizard/types.d.ts.map +1 -0
  161. package/dist/index.cjs +1 -1
  162. package/dist/index.d.cts +13 -1
  163. package/dist/index.d.cts.map +1 -1
  164. package/dist/index.d.ts +13 -1
  165. package/dist/index.d.ts.map +1 -1
  166. package/dist/index.js +36 -30
  167. package/dist/internal/decimal.d.cts +7 -0
  168. package/dist/internal/decimal.d.cts.map +1 -0
  169. package/dist/internal/decimal.d.ts +7 -0
  170. package/dist/internal/decimal.d.ts.map +1 -0
  171. package/dist/styles.css +5 -0
  172. package/package.json +1 -1
  173. package/dist/chunks/FormEditor-B4mtAxaU.cjs +0 -2
  174. package/dist/chunks/FormEditor-B4mtAxaU.cjs.map +0 -1
  175. package/dist/chunks/FormEditor-BkBhcYI5.js.map +0 -1
  176. package/dist/chunks/Slider-k8weRl34.cjs +0 -2
  177. package/dist/chunks/Slider-k8weRl34.cjs.map +0 -1
  178. package/dist/chunks/Slider-vdMFLX-H.js +0 -174
  179. package/dist/chunks/Slider-vdMFLX-H.js.map +0 -1
  180. package/dist/components/NumberField/index.cjs.map +0 -1
  181. package/dist/components/NumberField/index.js.map +0 -1
@@ -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;CAChF,IAAMC,IAAWC,EAAsB,IAAI,GACrCC,KAAU,MAAwC;EACtD,IAAMC,IAAOC,EAAM,cAAc,sBAAsB;EACvD,AAAKD,EAAK,SAAUA,EAAK,UAGzBE,EAAS;GACP,GAAGC;GACH,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A.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,iBAAe;EACf,iBAAe,KAAK,MAAMD,EAAO,CAAC;EAClC,kBAAgB,cAAc,KAAK,MAAMA,EAAO,CAAC,EAAE,gBAAgB,KAAK,MAAMA,EAAO,CAAC,EAAE;EACxF,iBAAeC,KAAc,KAAA;EAC7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ACpBmG,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-NnFxLEsh.cjs.map
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,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,EA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+ {"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,EAAGR,GAAQM,EAAM,QAAUD,EAAK,MAAQA,EAAK,MAAS,GAAG,EACzD,EAAGL,GAAO,GAAKM,EAAM,QAAUD,EAAK,KAAOA,EAAK,QAAU,GAAG,CAC/D,CAAC,CACH,EAqBA,OACE,EAAAX,EAAA,IAAA,CAAC,MAAD,CACE,UAAU,0BACV,KAAK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,yBAA0BhB,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EACzE,SAAW,GAAU,CACnB,IAAM1C,EAAOd,EAAM,OAAO,MACpB0F,EAAQ,CAAC5E,EAAK,KAAK,GAAK,EAAQ3C,EAAAA,EAAY2C,CAAI,EACtD6E,EAAK7E,EAAM4E,CAAK,EACZA,GACFzD,EAAOnB,CAAI,CAEf,EACA,OAAS,GAAU,CACZ6D,GACHiB,EAAQ,EAEVC,IAAS7F,CAAK,CAChB,EACA,UAAY,GAAU,CACpB8F,IAAY9F,CAAK,EACb,GAAM,mBAGNA,EAAM,MAAQ,SAAW,CAAC2E,IAC5B3E,EAAM,eAAe,EACrB4F,EAAQ,GAEN5F,EAAM,MAAQ,aAAe,CAAC6E,GAAqB,CAACE,IACtD/E,EAAM,eAAe,EACrB,EAAU,QAAUA,EAAM,cAC1BoE,EAAQ,EAAI,GAEhB,CACD,CAAA,CACS,CAAA,GACZ,EAAAhF,EAAA,IAAA,CAACX,EAAAA,QAAD,CACE,UAAWyD,EACX,SAAUuC,EACV,OAAQO,EACR,MAAM,QACK,YACD,WACV,GAAIR,EACJ,KAAK,SACL,aAAW,kBAGX,SAAU,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"}
@@ -0,0 +1,2 @@
1
+ const e=require("./colour-BmtxDlWF.cjs"),t=require("../components/Button/index.cjs"),n=require("../components/Field/index.cjs"),r=require("../components/TextField/index.cjs"),i=require("./RichTextEditor-DAnjElUO.cjs"),a=require("../components/Container/index.cjs"),o=require("./EntryPicker-daSkD4aR.cjs"),s=require("./decimal-Ca7qJExZ.cjs"),c=require("./NumberField-1EYJdwDY.cjs"),l=require("../components/Select/index.cjs"),u=require("../components/Switch/index.cjs"),d=require("./ColourField-ynUP1pfN.cjs"),f=require("./Slider-BfvNPjRJ.cjs"),p=require("./DatePicker-01sor8iD.cjs"),m=require("../components/TagsInput/index.cjs"),h=require("../components/Choice/index.cjs"),g=require("../components/SelectionCard/index.cjs");let _=require("react"),v=require("react/jsx-runtime");var y=[`wide`,`full`],b=[`sm`,`md`,`lg`],x=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`,`select`,`slider`,`rangeSlider`,`colour`,`radioGroup`,`checkboxGroup`,`tags`,`date`,`divider`]);function S(e){let t=new Set;for(let n of e.fields){if(!n.id?.trim()||t.has(n.id))throw Error(`Form field IDs must be nonempty and unique.`);if(!x.has(n.type))throw Error(`Unsupported form field type: ${n.type}`);n.type!==`divider`&&(ee(n),k(n),w(n)),t.add(n.id)}}function ee(e){switch(e.type){case`select`:case`radioGroup`:case`checkboxGroup`:return ne(e);case`slider`:case`rangeSlider`:return A(e);case`number`:return j(e)}}var te=new Set([`shortText`,`longText`,`tags`,`asset`,`reference`]);function C(e){return te.has(e.type)}function w(e){if(C(e)){if(e.limitDisplay!==void 0&&![`used`,`remaining`].includes(e.limitDisplay))throw Error(`Field ${e.id} needs a limitDisplay of used or remaining.`);if(e.limitVisibility!==void 0&&![`always`,`nearLimit`].includes(e.limitVisibility))throw Error(`Field ${e.id} needs a limitVisibility of always or nearLimit.`);if(e.showLimitRing!==void 0&&typeof e.showLimitRing!=`boolean`)throw Error(`Field ${e.id} needs a boolean showLimitRing.`)}}function T(e,t,n){return C(e)?{limitDisplay:e.limitDisplay,limitVisibility:e.limitVisibility,showLimitRing:e.showLimitRing,limit:E(e,t,n??[])}:{}}function E(e,t,n){switch(e.type){case`shortText`:case`longText`:return e.maxLength===void 0?void 0:{count:D(t).length,max:e.maxLength};case`tags`:return e.max===void 0?void 0:{count:U(t).length,max:e.max};default:return o.n(O(e),n.length,P(e).max)}}function D(e){return typeof e==`string`?e:``}function O(e){return e.multiple?`multiple`:`single`}function k(e){if(e.width!==void 0&&!b.includes(e.width))throw Error(`Field ${e.id} needs a width of sm, md or lg.`);if(e.type===`richText`&&e.expandedWidth!==void 0&&!y.includes(e.expandedWidth))throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`)}function A(e){let{min:t,max:n,step:r}=f.i(e);if(![t,n,r].every(Number.isFinite)||t>=n||r<=0)throw Error(`Slider field ${e.id} needs finite min < max and a positive step.`);if(e.type===`rangeSlider`&&r>s.n(n,-t))throw Error(`Range slider ${e.id} needs room for at least one step.`)}function j(e){let{min:t,max:n,step:r=`any`}=e;if([t,n].some(e=>e!==void 0&&!Number.isFinite(e))||t!==void 0&&n!==void 0&&t>n||r!==`any`&&!(Number.isFinite(r)&&r>0))throw Error(`Number field ${e.id} needs finite min <= max and a positive step or "any".`);if([e.decreaseLabel,e.increaseLabel].some(e=>e!==void 0&&(typeof e!=`string`||!e.trim())))throw Error(`Number field ${e.id} needs nonempty stepper labels.`)}function ne(e){if(!Array.isArray(e.options)){let t=e.type===`select`?`Select`:`Choice`;throw Error(`${t} field ${e.id} needs an options array.`)}if(e.type===`select`)return;let t=e.options.map(e=>e.value);if(t.some(e=>typeof e!=`string`||!e.trim())||new Set(t).size!==t.length)throw Error(`Choice field ${e.id} needs nonempty, unique option values.`)}var M={asset:{key:`assetId`,itemLabel:`asset`,itemsLabel:`assets`},reference:{key:`entryId`,itemLabel:`entry`,itemsLabel:`entries`}};function N(e){return e.type===`asset`||e.type===`reference`?e.picker?.label??e.label:e.label}function P(e){let t=M[e.type],{addLabel:n=`Choose ${N(e)}`,emptyLabel:r,itemLabel:i=t.itemLabel,itemsLabel:a=t.itemsLabel,max:o,isReorderable:s}=e.picker??{};return{addLabel:n,emptyLabel:r,itemLabel:i,itemsLabel:a,max:o,isReorderable:s}}function F(e,t){let{key:n}=M[e.type];return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>L(e,n)?[e[n]]:[])}function I(e){if(typeof e!=`string`)return;let t=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);if(!t)return;let n=`${t[1]}:${t[2]??`00`}.${(t[3]??``).padEnd(3,`0`)}Z`,r=new Date(n);if(Number.isFinite(r.getTime())&&r.toISOString()===n)return n}function L(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function R(e){return!!e.text?.trim()||e.type===`horizontalRule`||!!e.content?.some(R)}function z(e){return`${N(e)} is required.`}function B(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return z(e);if((e.type===`shortText`||e.type===`longText`)&&e.maxLength!==void 0&&t.length>e.maxLength)return`Enter no more than ${e.maxLength} characters.`}function V(e,t){let n=i.n(t);if(n)return n;if(e.required&&!R(t))return z(e)}function H(e,t){if(typeof t!=`string`)return`Choose an available option.`;if(t===``)return e.required?z(e):void 0;if((e.type===`select`||e.type===`radioGroup`)&&e.options.length>0&&!e.options.some(e=>e.value===t))return`Choose an available option.`}function U(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function W(e,t){if(!Array.isArray(t)||!t.every(e=>typeof e==`string`&&e.trim())||new Set(t).size!==t.length)return`Enter a list of unique, nonempty text values.`;if(e.required&&!t.length)return z(e);if(e.type===`tags`&&e.max!==void 0&&t.length>e.max)return`Enter no more than ${e.max} tags.`;if(e.type===`checkboxGroup`&&e.options.length&&t.some(t=>!e.options.some(e=>e.value===t)))return`Choose available options.`}function G(e,t){if(typeof t!=`number`||!Number.isFinite(t))return`Enter a finite number.`;let{min:n,max:r}=e.type===`slider`||e.type===`rangeSlider`?f.i(e):e.type===`number`?e:{};if(n!==void 0&&t<n)return`Enter a number of at least ${n}.`;if(r!==void 0&&t>r)return`Enter a number no greater than ${r}.`}function K(e,t){if(typeof t!=`string`)return`Enter a valid calendar date (YYYY-MM-DD).`;if(!t)return e.required?z(e):void 0;if(!p.a(t))return`Enter a valid calendar date (YYYY-MM-DD).`;if(e.type===`date`){if(e.min&&t<e.min)return`Choose a date on or after ${e.min}.`;if(e.max&&t>e.max)return`Choose a date on or before ${e.max}.`}}function q(e,t){return typeof e==`number`&&Number.isFinite(e)?f.r(e,t):void 0}function J(e,t){let n=e,r=q(n?.min,t),i=q(n?.max,t);if(r===void 0&&i===void 0)return;let[a,o]=[r??t.min,i??t.max].sort((e,t)=>e-t);return{min:a,max:o}}function Y(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return`Enter a range.`;let n=t,r=n.min,i=n.max,a=G(e,r)??G(e,i);if(a)return a;if(r>i)return`The start must not be greater than the end.`;if(e.type===`rangeSlider`&&s.n(i,-r)<f.i(e).step)return`Keep the range endpoints at least one step apart.`}function X(t,n){return typeof n==`string`?n.trim()?e.i(n)?void 0:`Enter a valid colour.`:t.required?z(t):void 0:`Enter a valid colour.`}function Z(e,t){if(e.type!==`asset`&&e.type!==`reference`)return;let{key:n,itemLabel:r,itemsLabel:i}=M[e.type];if(!e.multiple)return L(t,n)?void 0:`Choose an ${r}.`;if(!Array.isArray(t)||!t.every(e=>L(e,n)))return`Choose a list of ${i}.`;if(e.required&&t.length===0)return z(e);let a=e.picker?.max;if(a!==void 0&&t.length>a)return`Choose no more than ${a} ${P(e).itemsLabel}.`}var re={shortText:B,longText:B,richText:V,number:G,slider:G,rangeSlider:Y,date:K,colour:X,radioGroup:H,checkboxGroup:W,tags:W,boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>I(t)?void 0:`Enter a valid UTC date and time.`,select:H,asset:Z,reference:Z};function Q(e,t){return t===void 0?e.required?z(e):void 0:re[e.type](e,t)}function ie(e,t){return S(e),Object.fromEntries(e.fields.flatMap(e=>{if(e.type===`divider`)return[];let n=Q(e,Object.hasOwn(t,e.id)?t[e.id]:void 0);return n?[[e.id,n]]:[]}))}function ae({field:e,option:t,name:n,checked:r,isDisabled:i,invalid:a,onChange:o}){let s={name:n,value:t.value,checked:r,disabled:i||t.isDisabled,"aria-invalid":a,onChange:()=>{!i&&!t.isDisabled&&o()}};if(e.appearance===`card`){let n=e.type===`radioGroup`?g.RadioCard:g.CheckboxCard;return(0,v.jsx)(n,{...s,title:t.label,description:t.description})}let c=e.type===`radioGroup`?h.Radio:h.Checkbox;return(0,v.jsx)(c,{...s,children:(0,v.jsxs)(`span`,{children:[t.label,t.description&&(0,v.jsx)(`span`,{className:`ds-form-editor__option-description`,children:t.description})]})})}function oe({field:e,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s=e.type===`checkboxGroup`,c=s?U(n):typeof n==`string`&&n?[n]:[],l=e.appearance===`card`?g.SelectionCardGroup:h.ChoiceGroup;return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l,{...a,label:e.label,columns:e.columns??(e.appearance===`card`?2:1),children:e.options.map(t=>(0,v.jsx)(ae,{field:e,option:t,name:a.id,checked:c.includes(t.value),isDisabled:r,invalid:a[`aria-invalid`],onChange:()=>{o(s?c.includes(t.value)?c.filter(e=>e!==t.value):[...c,t.value]:t.value)}},t.value))}),!s&&!i&&c.length>0&&(0,v.jsxs)(t.Button,{variant:`simple`,size:`sm`,isDisabled:r,onClick:()=>o(void 0),children:[`Clear `,e.label]})]})}function se({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=f.i(e),o=q(t,a);return(0,v.jsx)(f.n,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,valueText:o===void 0?e.placeholder??`Not set`:void 0,autoFocus:e.autoFocus,isDisabled:n,value:o??a.min,onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function ce({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=f.i(e),o=J(t,a);return(0,v.jsx)(f.t,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,minLabel:`${e.label} minimum`,maxLabel:`${e.label} maximum`,isDisabled:n,valueText:o===void 0?e.placeholder??`Not set`:void 0,hasFill:o!==void 0,value:o??{min:a.min,max:a.max},onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function le({field:t,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s={stored:n,isDisabled:r,required:i,accessibility:a,onChange:o};switch(t.type){case`radioGroup`:case`checkboxGroup`:return(0,v.jsx)(oe,{field:t,...s});case`rangeSlider`:return(0,v.jsx)(ce,{field:t,...s});case`slider`:return(0,v.jsx)(se,{field:t,...s});case`colour`:return(0,v.jsx)(d.t,{...a,required:i,placeholder:t.placeholder,presets:t.presets,showPresets:t.showPresets,picker:t.picker,placement:t.placement,readOnly:t.readOnly,autoFocus:t.autoFocus,isDisabled:r,value:typeof n==`string`?n:``,onInput:t=>{let n=t.currentTarget.value;n.trim()&&!e.i(n)&&o(n)},onValueChange:e=>o(e===``?void 0:e)});case`tags`:return(0,v.jsx)(m.TagsInput,{...a,required:i,placeholder:t.placeholder,max:t.max,isDisabled:r,value:U(n),onValueChange:o});case`date`:return(0,v.jsx)(p.n,{...a,placeholder:t.placeholder,min:t.min,max:t.max,placement:t.placement,isDisabled:r,isClearable:!0,clearLabel:`Clear ${t.label}`,value:typeof n==`string`?n:``,onValueChange:e=>o(e===``?void 0:e)})}}function ue(e,t){if(e.type===`asset`){let n=t.map(e=>({assetId:e}));return e.multiple?n:n[0]}let n=t.map(e=>({entryId:e}));return e.multiple?n:n[0]}function de({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){return(0,v.jsx)(c.t,{...i,required:r,isDisabled:n,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step??`any`,hasSteppers:e.hasSteppers,prefix:e.prefix,suffix:e.suffix,autoFocus:e.autoFocus,decreaseLabel:e.decreaseLabel??`Decrease ${e.label}`,increaseLabel:e.increaseLabel??`Increase ${e.label}`,value:typeof t==`number`&&Number.isFinite(t)?t:``,onValueChange:e=>{(e===``||Number.isFinite(e))&&a(e===``?void 0:e)}})}function $({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){let o=!r&&!e.options.some(e=>e.value===``);return(0,v.jsx)(l.Select,{...i,"aria-required":r||void 0,isDisabled:n,isInvalid:i[`aria-invalid`],options:o?[{value:``,label:e.placeholder??`None`},...e.options]:e.options,placeholder:e.placeholder,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onValueChange:e=>a(e===``?void 0:e)})}function fe({field:e,selected:t,items:n,isDisabled:r,accessibility:i,onChange:a}){return(0,v.jsx)(o.t,{...i,items:n,value:t,...P(e),mode:O(e),isDisabled:r,onValueChange:t=>a(ue(e,t))})}function pe({field:e,stored:t,selected:n,items:a,isDisabled:o,accessibility:{required:s,...c},onChange:l}){let d={stored:t,isDisabled:o,required:s,accessibility:c,onChange:l};switch(e.type){case`shortText`:return(0,v.jsx)(r.TextField,{...c,required:s,disabled:o,placeholder:e.placeholder,type:e.inputType,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:D(t),onChange:e=>l(e.target.value)});case`longText`:return(0,v.jsx)(r.TextArea,{...c,required:s,disabled:o,placeholder:e.placeholder,rows:e.rows,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:D(t),onChange:e=>l(e.target.value)});case`number`:return(0,v.jsx)(de,{field:e,...d});case`boolean`:return(0,v.jsx)(u.Switch,{...c,isDisabled:o,autoFocus:e.autoFocus,isSelected:t===!0,onSelectedChange:l});case`dateTime`:return(0,v.jsx)(r.TextField,{...c,required:s,disabled:o,type:`datetime-local`,step:`0.001`,autoFocus:e.autoFocus,value:I(t)?.slice(0,-1)??``,onChange:e=>l(I(`${e.target.value}Z`))});case`richText`:return(0,v.jsx)(i.t,{...c,expandedWidth:e.expandedWidth,label:e.label,isRequired:s,isDisabled:o,placeholder:e.placeholder,format:`json`,value:t===void 0?i.r:t,onChange:l});case`select`:return(0,v.jsx)($,{field:e,...d});case`asset`:case`reference`:return(0,v.jsx)(fe,{field:e,items:a,selected:n??[],...d});default:return(0,v.jsx)(le,{field:e,...d})}}function me({field:e,stored:t,items:r,isDisabled:i,error:o,isErrorVisible:s,onChange:c}){let l=(0,_.useMemo)(()=>o===void 0&&s?Q(e,t):void 0,[o,s,e,t]),u=(0,_.useMemo)(()=>e.type===`asset`||e.type===`reference`?F(e,t):void 0,[e,t]);return(0,v.jsx)(a.Container,{width:e.width,padded:!1,center:!1,className:`ds-form-editor__field`,children:(0,v.jsx)(n.Field,{...T(e,t,u),label:e.type===`dateTime`?`${e.label} (UTC)`:N(e),hint:e.hint,labelHint:e.labelHint,error:o??l,isRequired:e.required,count:u?.length??(e.type===`checkboxGroup`?U(t).length:void 0),isGroup:u!==void 0||he.has(e.type),children:n=>(0,v.jsx)(pe,{field:e,stored:t,selected:u,items:r,isDisabled:i,accessibility:n,onChange:c})})})}var he=new Set([`radioGroup`,`checkboxGroup`,`rangeSlider`]),ge=new Set([`slider`,`rangeSlider`,`date`,`colour`]);function _e({schema:e,value:t,defaultValue:n={},onValueChange:r,pickerItems:i={},errors:a={},isDisabled:o=!1,showAllErrors:s=!1,columns:c=1,minColumnWidth:l=`16rem`,className:u,style:d,...f}){let[p,m]=(0,_.useState)(n),[h,g]=(0,_.useState)(()=>new Set),y=t??p;(0,_.useMemo)(()=>S(e),[e]);let b=(e,n)=>{let i={...y};n===void 0?delete i[e]:i[e]=n,t===void 0&&m(i),g(t=>new Set(t).add(e)),r?.(i,{fieldId:e})},x=c===`auto`?{"--form-editor-min-column":l}:{"--form-editor-columns":c,"--form-editor-min-column":l};return(0,v.jsx)(`div`,{className:[`ds-form-editor`,c===`auto`&&`ds-form-editor--auto`,u].filter(Boolean).join(` `),style:{...x,...d},...f,children:e.fields.map(e=>{if(e.type===`divider`)return(0,v.jsx)(`hr`,{className:`ds-form-editor__divider`},e.id);let t=Object.hasOwn(y,e.id)?y[e.id]:void 0,n=o||!!e.isDisabled,r=n||`readOnly`in e&&!!e.readOnly,c=typeof t==`string`?t.trim()!==``:t!==void 0,l=s||h.has(e.id)||c&&ge.has(e.type)||e.type===`number`&&typeof t==`number`;return(0,v.jsx)(me,{field:e,stored:t,items:i[e.id]??[],isDisabled:n,error:a[e.id],isErrorVisible:l,onChange:t=>{r||b(e.id,t)}},e.id)})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _e}});
2
+ //# sourceMappingURL=FormEditor-C_4JbAnS.cjs.map