@namroodinc/liquid-editorial 0.6.4 → 0.6.6

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 (242) hide show
  1. package/README.md +81 -1
  2. package/UPGRADING.md +160 -0
  3. package/dist/chunks/{Avatar-BTKqaJLP.cjs → Avatar-B_2lI7fS.cjs} +2 -2
  4. package/dist/chunks/{Avatar-BTKqaJLP.cjs.map → Avatar-B_2lI7fS.cjs.map} +1 -1
  5. package/dist/chunks/{Avatar-C1q2AUD-.js → Avatar-DdFEOumt.js} +3 -3
  6. package/dist/chunks/{Avatar-C1q2AUD-.js.map → Avatar-DdFEOumt.js.map} +1 -1
  7. package/dist/chunks/{Board-z688-51u.js → Board-B8wK079I.js} +2 -2
  8. package/dist/chunks/{Board-z688-51u.js.map → Board-B8wK079I.js.map} +1 -1
  9. package/dist/chunks/{Board-CUt4j2-8.cjs → Board-CMf5Azt0.cjs} +2 -2
  10. package/dist/chunks/{Board-CUt4j2-8.cjs.map → Board-CMf5Azt0.cjs.map} +1 -1
  11. package/dist/chunks/{ColourField-BwDb7ydB.js → ColourField-DC6cLb9h.js} +7 -3
  12. package/dist/chunks/ColourField-DC6cLb9h.js.map +1 -0
  13. package/dist/chunks/ColourField-NnFxLEsh.cjs +2 -0
  14. package/dist/chunks/ColourField-NnFxLEsh.cjs.map +1 -0
  15. package/dist/chunks/DatePicker-01sor8iD.cjs +2 -0
  16. package/dist/chunks/DatePicker-01sor8iD.cjs.map +1 -0
  17. package/dist/chunks/{DatePicker-C1zcScC3.js → DatePicker-DJAqXUDJ.js} +2 -2
  18. package/dist/chunks/DatePicker-DJAqXUDJ.js.map +1 -0
  19. package/dist/chunks/EntryPicker-CR8Phuzl.js +180 -0
  20. package/dist/chunks/EntryPicker-CR8Phuzl.js.map +1 -0
  21. package/dist/chunks/EntryPicker-D7JIgx23.cjs +2 -0
  22. package/dist/chunks/EntryPicker-D7JIgx23.cjs.map +1 -0
  23. package/dist/chunks/{FormEditor-C4PJu7ZF.js → FormEditor-BSfxVqLn.js} +192 -146
  24. package/dist/chunks/FormEditor-BSfxVqLn.js.map +1 -0
  25. package/dist/chunks/FormEditor-DNcSAnRF.cjs +2 -0
  26. package/dist/chunks/FormEditor-DNcSAnRF.cjs.map +1 -0
  27. package/dist/chunks/Message-CaX8Y1Xb.js +74 -0
  28. package/dist/chunks/Message-CaX8Y1Xb.js.map +1 -0
  29. package/dist/chunks/Message-DU31JAb3.cjs +2 -0
  30. package/dist/chunks/Message-DU31JAb3.cjs.map +1 -0
  31. package/dist/chunks/{RichTextEditor-DEJ-u-ZR.js → RichTextEditor-CNkwWist.js} +2 -2
  32. package/dist/chunks/{RichTextEditor-DEJ-u-ZR.js.map → RichTextEditor-CNkwWist.js.map} +1 -1
  33. package/dist/chunks/{RichTextEditor-Ddk7qaqg.cjs → RichTextEditor-DAnjElUO.cjs} +2 -2
  34. package/dist/chunks/{RichTextEditor-Ddk7qaqg.cjs.map → RichTextEditor-DAnjElUO.cjs.map} +1 -1
  35. package/dist/chunks/context-BONPXF-V.cjs.map +1 -1
  36. package/dist/chunks/context-CXvOl4Kt.js.map +1 -1
  37. package/dist/chunks/frame-BBVQTBcX.cjs +2 -0
  38. package/dist/chunks/frame-BBVQTBcX.cjs.map +1 -0
  39. package/dist/chunks/frame-De6IuTQz.js +189 -0
  40. package/dist/chunks/frame-De6IuTQz.js.map +1 -0
  41. package/dist/chunks/group-Bj9ZKc0R.cjs +2 -0
  42. package/dist/chunks/group-Bj9ZKc0R.cjs.map +1 -0
  43. package/dist/chunks/group-Ckz4Xya-.js +34 -0
  44. package/dist/chunks/group-Ckz4Xya-.js.map +1 -0
  45. package/dist/chunks/limit-BX6-o1a2.cjs +2 -0
  46. package/dist/chunks/limit-BX6-o1a2.cjs.map +1 -0
  47. package/dist/chunks/limit-ChteDN4T.js +18 -0
  48. package/dist/chunks/limit-ChteDN4T.js.map +1 -0
  49. package/dist/chunks/mergeRefs-C6_5pADN.js +19 -0
  50. package/dist/chunks/mergeRefs-C6_5pADN.js.map +1 -0
  51. package/dist/chunks/mergeRefs-CZ-SArlE.cjs +2 -0
  52. package/dist/chunks/mergeRefs-CZ-SArlE.cjs.map +1 -0
  53. package/dist/chunks/useLimit-BOmHKdJE.js +73 -0
  54. package/dist/chunks/useLimit-BOmHKdJE.js.map +1 -0
  55. package/dist/chunks/useLimit-DXe_VmYl.cjs +2 -0
  56. package/dist/chunks/useLimit-DXe_VmYl.cjs.map +1 -0
  57. package/dist/chunks/{useTooltip-D6cJji8v.js → useTooltip-C5gvEoYk.js} +2 -1
  58. package/dist/chunks/{useTooltip-D6cJji8v.js.map → useTooltip-C5gvEoYk.js.map} +1 -1
  59. package/dist/chunks/{useTooltip-CCf79zE9.cjs → useTooltip-bTE_a2Xn.cjs} +2 -2
  60. package/dist/chunks/{useTooltip-CCf79zE9.cjs.map → useTooltip-bTE_a2Xn.cjs.map} +1 -1
  61. package/dist/components/AppShell/index.cjs +1 -1
  62. package/dist/components/AppShell/index.js +1 -1
  63. package/dist/components/Avatar/index.cjs +1 -1
  64. package/dist/components/Avatar/index.js +1 -1
  65. package/dist/components/Banner/index.cjs +2 -0
  66. package/dist/components/Banner/index.cjs.map +1 -0
  67. package/dist/components/Banner/index.d.cts +6 -0
  68. package/dist/components/Banner/index.d.cts.map +1 -0
  69. package/dist/components/Banner/index.d.ts +6 -0
  70. package/dist/components/Banner/index.d.ts.map +1 -0
  71. package/dist/components/Banner/index.js +18 -0
  72. package/dist/components/Banner/index.js.map +1 -0
  73. package/dist/components/Banner/style.css +6 -0
  74. package/dist/components/Board/index.cjs +1 -1
  75. package/dist/components/Board/index.js +1 -1
  76. package/dist/components/Choice/index.cjs +1 -1
  77. package/dist/components/Choice/index.js +1 -1
  78. package/dist/components/ColourField/index.cjs +1 -1
  79. package/dist/components/ColourField/index.js +1 -1
  80. package/dist/components/DatePicker/index.cjs +1 -1
  81. package/dist/components/DatePicker/index.js +1 -1
  82. package/dist/components/Drawer/index.cjs +1 -1
  83. package/dist/components/Drawer/index.cjs.map +1 -1
  84. package/dist/components/Drawer/index.js +6 -2
  85. package/dist/components/Drawer/index.js.map +1 -1
  86. package/dist/components/EditLayout/index.cjs +1 -1
  87. package/dist/components/EditLayout/index.js +1 -1
  88. package/dist/components/EntryPicker/index.cjs +1 -2
  89. package/dist/components/EntryPicker/index.d.cts.map +1 -1
  90. package/dist/components/EntryPicker/index.d.ts.map +1 -1
  91. package/dist/components/EntryPicker/index.js +1 -171
  92. package/dist/components/EntryPicker/limit.d.cts +8 -0
  93. package/dist/components/EntryPicker/limit.d.cts.map +1 -0
  94. package/dist/components/EntryPicker/limit.d.ts +8 -0
  95. package/dist/components/EntryPicker/limit.d.ts.map +1 -0
  96. package/dist/components/Field/context.d.cts +6 -0
  97. package/dist/components/Field/context.d.cts.map +1 -1
  98. package/dist/components/Field/context.d.ts +6 -0
  99. package/dist/components/Field/context.d.ts.map +1 -1
  100. package/dist/components/Field/frame.d.cts +1 -1
  101. package/dist/components/Field/frame.d.cts.map +1 -1
  102. package/dist/components/Field/frame.d.ts +1 -1
  103. package/dist/components/Field/frame.d.ts.map +1 -1
  104. package/dist/components/Field/group.d.cts +1 -1
  105. package/dist/components/Field/group.d.cts.map +1 -1
  106. package/dist/components/Field/group.d.ts +1 -1
  107. package/dist/components/Field/group.d.ts.map +1 -1
  108. package/dist/components/Field/header.d.cts +12 -0
  109. package/dist/components/Field/header.d.cts.map +1 -0
  110. package/dist/components/Field/header.d.ts +12 -0
  111. package/dist/components/Field/header.d.ts.map +1 -0
  112. package/dist/components/Field/index.cjs +1 -1
  113. package/dist/components/Field/index.cjs.map +1 -1
  114. package/dist/components/Field/index.d.cts +1 -1
  115. package/dist/components/Field/index.d.cts.map +1 -1
  116. package/dist/components/Field/index.d.ts +1 -1
  117. package/dist/components/Field/index.d.ts.map +1 -1
  118. package/dist/components/Field/index.js +1 -1
  119. package/dist/components/Field/index.js.map +1 -1
  120. package/dist/components/Field/limit-reading.d.cts +12 -0
  121. package/dist/components/Field/limit-reading.d.cts.map +1 -0
  122. package/dist/components/Field/limit-reading.d.ts +12 -0
  123. package/dist/components/Field/limit-reading.d.ts.map +1 -0
  124. package/dist/components/Field/limit.d.cts +8 -0
  125. package/dist/components/Field/limit.d.cts.map +1 -0
  126. package/dist/components/Field/limit.d.ts +8 -0
  127. package/dist/components/Field/limit.d.ts.map +1 -0
  128. package/dist/components/Field/style.css +77 -0
  129. package/dist/components/Field/types.d.cts +12 -1
  130. package/dist/components/Field/types.d.cts.map +1 -1
  131. package/dist/components/Field/types.d.ts +12 -1
  132. package/dist/components/Field/types.d.ts.map +1 -1
  133. package/dist/components/Field/useLimit.d.cts +18 -0
  134. package/dist/components/Field/useLimit.d.cts.map +1 -0
  135. package/dist/components/Field/useLimit.d.ts +18 -0
  136. package/dist/components/Field/useLimit.d.ts.map +1 -0
  137. package/dist/components/FormEditor/README.md +62 -0
  138. package/dist/components/FormEditor/control.d.cts.map +1 -1
  139. package/dist/components/FormEditor/control.d.ts.map +1 -1
  140. package/dist/components/FormEditor/index.cjs +1 -1
  141. package/dist/components/FormEditor/index.d.cts.map +1 -1
  142. package/dist/components/FormEditor/index.d.ts.map +1 -1
  143. package/dist/components/FormEditor/index.js +1 -1
  144. package/dist/components/FormEditor/model.d.cts +21 -8
  145. package/dist/components/FormEditor/model.d.cts.map +1 -1
  146. package/dist/components/FormEditor/model.d.ts +21 -8
  147. package/dist/components/FormEditor/model.d.ts.map +1 -1
  148. package/dist/components/Menu/index.cjs +1 -1
  149. package/dist/components/Menu/index.cjs.map +1 -1
  150. package/dist/components/Menu/index.js +1 -1
  151. package/dist/components/Menu/index.js.map +1 -1
  152. package/dist/components/Modal/index.cjs +1 -1
  153. package/dist/components/Modal/index.cjs.map +1 -1
  154. package/dist/components/Modal/index.js +6 -2
  155. package/dist/components/Modal/index.js.map +1 -1
  156. package/dist/components/Popover/index.cjs +1 -1
  157. package/dist/components/Popover/index.js +1 -1
  158. package/dist/components/Popover/style.css +2 -1
  159. package/dist/components/Popover/useTooltip.d.cts.map +1 -1
  160. package/dist/components/Popover/useTooltip.d.ts.map +1 -1
  161. package/dist/components/RichTextEditor/index.cjs +1 -1
  162. package/dist/components/RichTextEditor/index.js +1 -1
  163. package/dist/components/SearchField/index.cjs +1 -1
  164. package/dist/components/SearchField/index.cjs.map +1 -1
  165. package/dist/components/SearchField/index.d.cts.map +1 -1
  166. package/dist/components/SearchField/index.d.ts.map +1 -1
  167. package/dist/components/SearchField/index.js +27 -22
  168. package/dist/components/SearchField/index.js.map +1 -1
  169. package/dist/components/Select/index.cjs +1 -1
  170. package/dist/components/Select/index.cjs.map +1 -1
  171. package/dist/components/Select/index.js +1 -1
  172. package/dist/components/Select/index.js.map +1 -1
  173. package/dist/components/SelectionCard/index.cjs +1 -1
  174. package/dist/components/SelectionCard/index.js +1 -1
  175. package/dist/components/SortableList/index.cjs +1 -1
  176. package/dist/components/SortableList/index.js +1 -1
  177. package/dist/components/Table/index.cjs +1 -1
  178. package/dist/components/Table/index.cjs.map +1 -1
  179. package/dist/components/Table/index.js +1 -1
  180. package/dist/components/Table/index.js.map +1 -1
  181. package/dist/components/TagsInput/index.cjs +1 -1
  182. package/dist/components/TagsInput/index.cjs.map +1 -1
  183. package/dist/components/TagsInput/index.d.cts.map +1 -1
  184. package/dist/components/TagsInput/index.d.ts.map +1 -1
  185. package/dist/components/TagsInput/index.js +36 -30
  186. package/dist/components/TagsInput/index.js.map +1 -1
  187. package/dist/components/TextField/index.cjs +1 -1
  188. package/dist/components/TextField/index.cjs.map +1 -1
  189. package/dist/components/TextField/index.d.cts.map +1 -1
  190. package/dist/components/TextField/index.d.ts.map +1 -1
  191. package/dist/components/TextField/index.js +35 -20
  192. package/dist/components/TextField/index.js.map +1 -1
  193. package/dist/components/Time/index.cjs +1 -1
  194. package/dist/components/Time/index.js +2 -2
  195. package/dist/components/Toast/index.cjs +1 -1
  196. package/dist/components/Toast/index.cjs.map +1 -1
  197. package/dist/components/Toast/index.d.cts.map +1 -1
  198. package/dist/components/Toast/index.d.ts.map +1 -1
  199. package/dist/components/Toast/index.js +35 -60
  200. package/dist/components/Toast/index.js.map +1 -1
  201. package/dist/components/Toast/style.css +5 -50
  202. package/dist/index.cjs +1 -1
  203. package/dist/index.d.cts +3 -1
  204. package/dist/index.d.cts.map +1 -1
  205. package/dist/index.d.ts +3 -1
  206. package/dist/index.d.ts.map +1 -1
  207. package/dist/index.js +17 -16
  208. package/dist/internal/Message.d.cts +23 -0
  209. package/dist/internal/Message.d.cts.map +1 -0
  210. package/dist/internal/Message.d.ts +23 -0
  211. package/dist/internal/Message.d.ts.map +1 -0
  212. package/dist/internal/mergeRefs.d.cts +5 -1
  213. package/dist/internal/mergeRefs.d.cts.map +1 -1
  214. package/dist/internal/mergeRefs.d.ts +5 -1
  215. package/dist/internal/mergeRefs.d.ts.map +1 -1
  216. package/dist/message.css +122 -0
  217. package/dist/styles.css +2 -0
  218. package/dist/tokens.css +36 -12
  219. package/package.json +1 -1
  220. package/dist/chunks/ColourField-Bk5O632x.cjs +0 -2
  221. package/dist/chunks/ColourField-Bk5O632x.cjs.map +0 -1
  222. package/dist/chunks/ColourField-BwDb7ydB.js.map +0 -1
  223. package/dist/chunks/DatePicker-BVsloqVY.cjs +0 -2
  224. package/dist/chunks/DatePicker-BVsloqVY.cjs.map +0 -1
  225. package/dist/chunks/DatePicker-C1zcScC3.js.map +0 -1
  226. package/dist/chunks/FormEditor-C4PJu7ZF.js.map +0 -1
  227. package/dist/chunks/FormEditor-Dd44EMp_.cjs +0 -2
  228. package/dist/chunks/FormEditor-Dd44EMp_.cjs.map +0 -1
  229. package/dist/chunks/frame-Bs_jaQRw.js +0 -70
  230. package/dist/chunks/frame-Bs_jaQRw.js.map +0 -1
  231. package/dist/chunks/frame-CNxvbg0D.cjs +0 -2
  232. package/dist/chunks/frame-CNxvbg0D.cjs.map +0 -1
  233. package/dist/chunks/group-CzbacuAY.js +0 -29
  234. package/dist/chunks/group-CzbacuAY.js.map +0 -1
  235. package/dist/chunks/group-pKDQtq-9.cjs +0 -2
  236. package/dist/chunks/group-pKDQtq-9.cjs.map +0 -1
  237. package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs +0 -2
  238. package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs.map +0 -1
  239. package/dist/chunks/mergeRefs-DGM402mE.js +0 -10
  240. package/dist/chunks/mergeRefs-DGM402mE.js.map +0 -1
  241. package/dist/components/EntryPicker/index.cjs.map +0 -1
  242. package/dist/components/EntryPicker/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColourField-Bk5O632x.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\", 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,CAAs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D,CAAA,CACM,CAAA,CACN,C,EAET,CAAC,E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColourField-BwDb7ydB.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\", 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,E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AAC,KAAK,GAAG;IACzE,WAAW,MAAU;KACnB,IAAM/C,IAAOf,EAAM,OAAO,OACpBmG,IAAQ,CAACpF,EAAK,KAAK,KAAK,EAAQjC,EAAYiC,CAAI;KAEtD,AADAqF,GAAKrF,GAAMoF,CAAK,GACZA,KACFhE,EAAOpB,CAAI;IAEf;IACA,SAAS,MAAU;KAIjB,AAHKmE,KACHmB,EAAQ,GAEVC,IAAStG,CAAK;IAChB;IACA,YAAY,MAAU;KAEpB,AADAuG,IAAYvG,CAAK,GACb,GAAM,qBAGNA,EAAM,QAAQ,WAAW,CAACkF,MAC5BlF,EAAM,eAAe,GACrBqG,EAAQ,IAENrG,EAAM,QAAQ,eAAe,CAACoF,KAAqB,CAACE,MACtDtF,EAAM,eAAe,GACrB,EAAU,UAAUA,EAAM,eAC1B2E,EAAQ,EAAI;IAEhB;GACD,CAAA;EACS,CAAA,GACZ,kBAAC6B,GAAD;GACE,WAAWpE;GACX,UAAU4C;GACV,QAAQO;GACR,OAAM;GACK;GACD;GACV,IAAIR;GACJ,MAAK;GACL,cAAW;GAGX,UAAU;GACV,WAAU;GAEV,UAAA,kBAAC7C,GAAD;IACU;IACR,SAASpB;IACA;IACI;IACL;IACR,iBAAiB,MAAS;KAExB,AADAuF,EAAQ,GACRlE,EAAOpB,CAAI;IACb;GACD,CAAA;EACM,CAAA,CACN;;AAET,CAAC"}
@@ -1,2 +0,0 @@
1
- const e=require("./Icon-WOhlu6Rp.cjs"),t=require("../components/Button/index.cjs");;/* empty css */const n=require("./binding-tMjrUzkU.cjs"),r=require("../components/Popover/index.cjs");let i=require("react"),a=require("react/jsx-runtime");function o(e){let t=`${e.getMonth()+1}`.padStart(2,`0`),n=`${e.getDate()}`.padStart(2,`0`);return`${e.getFullYear()}-${t}-${n}`}function s(e){if(!e||!/^\d{4}-\d{2}-\d{2}$/.test(e))return null;let[t,n,r]=e.split(`-`).map(Number);if(!t||!n||!r)return null;let i=new Date(t,n-1,r);return Number.isNaN(i.getTime())||o(i)!==e?null:i}function c(e){return s(e)!==null}function l(e){let t=s(e);return t?t.toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`}):``}function u(...e){return e.filter(Boolean).join(` `)}var d=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function f(e,t,n){let r=s(e)?e:o(new Date);return t&&r<t?t:n&&r>n?n:r}function p(e){return e.toLocaleDateString(`en-GB`,{month:`long`,year:`numeric`})}function m(e){let t=new Date(e.getFullYear(),e.getMonth(),1),n=(t.getDay()+6)%7;return new Date(t.getFullYear(),t.getMonth(),1-n)}function h(e,t,n){return e?`primary`:t?`active`:n?`neutral`:`simple`}var g=(0,i.forwardRef)(function({value:e,endValue:r,onSelect:c,min:g,max:_,className:v,...y},b){let[x,S]=(0,i.useState)(()=>f(e,g,_)),[C,w]=(0,i.useState)(()=>s(x)??new Date),T=(0,i.useRef)(null),E=(0,i.useRef)(!1);(0,i.useEffect)(()=>{if(!s(e))return;let t=f(e,g,_),n=s(t)??new Date;S(t),w(new Date(n.getFullYear(),n.getMonth(),1))},[e,g,_]),(0,i.useEffect)(()=>{E.current&&(E.current=!1,T.current?.querySelector(`[data-focused]`)?.focus())},[x]);let D=Array.from({length:42},(e,t)=>{let n=m(C);return new Date(n.getFullYear(),n.getMonth(),n.getDate()+t)}),O=o(new Date),k=e=>{let t=new Date(C.getFullYear(),C.getMonth()+e,1);w(t),S(o(t))},A=e=>{let t=s(x)??new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()+e);E.current=!0,S(o(n)),w(new Date(n.getFullYear(),n.getMonth(),1))},j=e=>{let t={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7,PageUp:-28,PageDown:28}[e.key];t!==void 0&&(e.preventDefault(),A(t))};return(0,a.jsxs)(`div`,{ref:b,className:u(`ds-calendar`,v),...n.n(y),children:[(0,a.jsxs)(`div`,{className:`ds-calendar__head`,children:[(0,a.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`chevron-left`,"aria-label":`Previous month`,onClick:()=>k(-1)}),(0,a.jsx)(`span`,{className:`ds-calendar__month`,children:p(C)}),(0,a.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`chevron-right`,"aria-label":`Next month`,onClick:()=>k(1)})]}),(0,a.jsx)(`div`,{className:`ds-calendar__weekdays`,"aria-hidden":`true`,children:d.map(e=>(0,a.jsx)(`span`,{children:e.slice(0,2)},e))}),(0,a.jsx)(`div`,{ref:T,className:`ds-calendar__grid`,role:`grid`,onKeyDown:j,children:Array.from({length:6},(n,i)=>(0,a.jsx)(`div`,{role:`row`,className:`ds-calendar__row`,children:D.slice(i*7,i*7+7).map(n=>{let i=o(n),s=n.getMonth()!==C.getMonth(),u=g&&i<g||_&&i>_,d=!!(e&&r&&i>e&&i<r),f=i===e||i===r;return(0,a.jsx)(t.Button,{variant:h(f,d,i===O),size:`sm`,isIconOnly:!0,role:`gridcell`,"aria-label":l(i),tabIndex:i===x?0:-1,isDisabled:!!u,"aria-selected":f||void 0,"data-outside":s||void 0,"data-today":i===O||void 0,"data-in-range":d||void 0,"data-focused":i===x||void 0,className:`ds-calendar__day`,onClick:()=>{S(i),c?.(i)},children:n.getDate()},i)})},i))})]})});function _({value:o,defaultValue:s=``,onValueChange:c,size:d=`md`,placeholder:f=`Pick a date`,placement:p,min:m,max:h,isDisabled:_=!1,isInvalid:v=!1,isClearable:y=!1,clearLabel:b=`Clear date`,"aria-invalid":x,id:S,className:C,...w}){let[T,E]=(0,i.useState)(s),D=o??T,[O,k]=(0,i.useState)(!1),A=(0,i.useRef)(null),j=(0,i.useRef)(null),M=(0,i.useRef)(null),N=(0,i.useId)(),P=S??N;return O&&_&&k(!1),(0,i.useEffect)(()=>{if(!O)return;let e=M.current;(e?.querySelector(`[data-focused]:not(:disabled)`)??e)?.focus();let t=e=>{let t=e.target;!A.current?.contains(t)&&!M.current?.contains(t)&&k(!1)};return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[O]),(0,a.jsxs)(`div`,{className:u(`ds-datefield`,C),ref:A,onKeyDown:e=>{O&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),k(!1),j.current?.focus())},children:[(0,a.jsxs)(t.Button,{...n.n(w),ref:j,id:P,size:d,"aria-haspopup":`dialog`,"aria-expanded":O,"aria-invalid":v||x||void 0,isDisabled:_,"data-placeholder":D?void 0:``,className:`ds-field-skin ds-datefield__control`,onClick:()=>k(e=>!e),children:[(0,a.jsx)(`span`,{className:`ds-datefield__value`,children:D?l(D):f}),(0,a.jsx)(e.t,{name:`calendar`,size:16,className:`ds-datefield__glyph`})]}),y&&D&&(0,a.jsx)(t.Button,{variant:`simple`,size:d,isIconOnly:!0,iconStart:`x`,"aria-label":b,isDisabled:_,onClick:()=>{o===void 0&&E(``),c?.(``),k(!1),j.current?.focus()}}),(0,a.jsx)(r.Popover,{anchorRef:j,placement:p,anchorId:P,isOpen:O,align:`start`,panelRef:M,className:`ds-datefield__popover`,role:`dialog`,"aria-label":`Choose a date`,tabIndex:-1,children:(0,a.jsx)(g,{value:D,min:m,max:h,onSelect:e=>{o===void 0&&E(e),c?.(e),k(!1),j.current?.focus()}})})]})}function v(e,t,n){return s(e)?t?n===`min`?e>t?e:t:e<t?e:t:e:t}function y({value:e,defaultValue:t={start:``,end:``},onValueChange:r,size:o=`md`,min:s,max:c,isDisabled:l=!1,isClearable:d=!1,startLabel:f=`Start date`,endLabel:p=`End date`,placement:m,className:h,...g}){let[y,b]=(0,i.useState)(t),x=e??y,S=t=>{e===void 0&&b(t),r?.(t)},{attributes:C}=n.r(g);return(0,a.jsxs)(`div`,{...C,className:u(`ds-daterange`,h),children:[(0,a.jsx)(_,{"aria-invalid":g[`aria-invalid`],"aria-label":f,placement:m,size:o,value:x.start,min:s,max:v(x.end,c,`max`),isDisabled:l,isClearable:d,clearLabel:`Clear ${f}`,placeholder:f,onValueChange:e=>S({...x,start:e})}),(0,a.jsx)(`span`,{className:`ds-daterange__dash`,"aria-hidden":`true`,children:`–`}),(0,a.jsx)(_,{"aria-invalid":g[`aria-invalid`],"aria-label":p,placement:m,size:o,value:x.end,min:v(x.start,s,`min`),max:c,isDisabled:l,isClearable:d,clearLabel:`Clear ${p}`,placeholder:p,onValueChange:e=>S({...x,end:e})})]})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return g}});
2
- //# sourceMappingURL=DatePicker-BVsloqVY.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePicker-BVsloqVY.cjs","names":["forwardRef","useState","useRef","omitRequired","Button","useId","Icon","Popover","useGroupBinding","require_Icon","require_components_Button_index","require_binding","require_components_Popover_index","react","react_jsx_runtime","toIso","month","date","day","fromIso","value","year","isIsoDate","formatIsoDate","cx","parts","WEEKDAYS","focusableDay","min","max","monthLabel","startOfGrid","first","weekday","dayVariant","isEdge","inRange","isToday","Calendar","rest","focused","setFocused","setMonth","gridRef","shouldFocus","next","days","start","index","today","changeMonth","delta","move","base","deltaDays","onKeyDown","event","className","rowIndex","iso","isOutside","isDisabled","endValue","onSelect","DateField","ariaInvalid","internal","setInternal","defaultValue","current","isOpen","setOpen","rootRef","triggerRef","panelRef","generatedId","triggerId","id","panel","onPointerDown","target","isInvalid","open","placeholder","isClearable","clearLabel","onValueChange","rangeBound","endpoint","bound","kind","DateRangeField","binding","commit","attributes","startLabel","endLabel"],"sources":["../../src/components/DatePicker/date.ts","../../src/components/DatePicker/index.tsx"],"sourcesContent":["/** ISO calendar date, \"YYYY-MM-DD\" — the only date shape the system passes around. */\nexport type IsoDate = string;\n\nexport function toIso(date: Date): IsoDate {\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const day = `${date.getDate()}`.padStart(2, \"0\");\n return `${date.getFullYear()}-${month}-${day}`;\n}\n\nexport function fromIso(value: string | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) {\n return null;\n }\n const [year, month, day] = value.split(\"-\").map(Number);\n if (!year || !month || !day) {\n return null;\n }\n const date = new Date(year, month - 1, day);\n return Number.isNaN(date.getTime()) || toIso(date) !== value ? null : date;\n}\n\n/** A real calendar day in \"YYYY-MM-DD\" form, checked without locale formatting. */\nexport function isIsoDate(value: string) {\n return fromIso(value) !== null;\n}\n\n/** \"12 March 2026\" — the system's one long date format. */\nexport function formatIsoDate(value: string | undefined): string {\n const date = fromIso(value);\n if (!date) {\n return \"\";\n }\n return date.toLocaleDateString(\"en-GB\", { day: \"numeric\", month: \"long\", year: \"numeric\" });\n}\n","import { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Popover, type PopoverPlacement } from \"../Popover\";\nimport { omitRequired, useGroupBinding } from \"../Field/binding\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { formatIsoDate, fromIso, toIso, type IsoDate } from \"./date\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport { formatIsoDate } from \"./date\";\nexport type { IsoDate } from \"./date\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst WEEKDAYS = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"];\n\n/** The selected day, or today when none is valid, moved inside the bounds so it can take focus. */\nfunction focusableDay(value: string | undefined, min?: IsoDate, max?: IsoDate): IsoDate {\n const day = fromIso(value) ? (value as IsoDate) : toIso(new Date());\n if (min && day < min) {\n return min;\n }\n return max && day > max ? max : day;\n}\n\nfunction monthLabel(date: Date) {\n return date.toLocaleDateString(\"en-GB\", { month: \"long\", year: \"numeric\" });\n}\n\nfunction startOfGrid(month: Date) {\n const first = new Date(month.getFullYear(), month.getMonth(), 1);\n const weekday = (first.getDay() + 6) % 7; // Monday-first\n return new Date(first.getFullYear(), first.getMonth(), 1 - weekday);\n}\n\nfunction dayVariant(isEdge: boolean, inRange: boolean, isToday: boolean) {\n if (isEdge) {\n return \"primary\";\n }\n if (inRange) {\n return \"active\";\n }\n return isToday ? \"neutral\" : \"simple\";\n}\n\nexport interface CalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n /** Selected day, or the start of a selected span. */\n value?: IsoDate;\n /** End of a selected span. Set it to put the calendar in range mode. */\n endValue?: IsoDate;\n onSelect?: (value: IsoDate) => void;\n min?: IsoDate;\n max?: IsoDate;\n}\n\n/**\n * A month of days, Monday first. Arrow keys walk the grid; the month follows\n * the focused day, so a whole year is reachable from the keyboard.\n */\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>(function Calendar(\n { value, endValue, onSelect, min, max, className, ...rest },\n ref,\n) {\n const [focused, setFocused] = useState<IsoDate>(() => focusableDay(value, min, max));\n const [month, setMonth] = useState(() => fromIso(focused) ?? new Date());\n const gridRef = useRef<HTMLDivElement | null>(null);\n const shouldFocus = useRef(false);\n\n useEffect(() => {\n if (!fromIso(value)) {\n return;\n }\n const day = focusableDay(value, min, max);\n const next = fromIso(day) ?? new Date();\n // Controlled changes intentionally reposition the visible and roving-focus month.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setFocused(day);\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n }, [value, min, max]);\n\n useEffect(() => {\n if (!shouldFocus.current) {\n return;\n }\n shouldFocus.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(\"[data-focused]\")?.focus();\n }, [focused]);\n\n const days = Array.from({ length: 42 }, (_, index) => {\n const start = startOfGrid(month);\n return new Date(start.getFullYear(), start.getMonth(), start.getDate() + index);\n });\n\n const today = toIso(new Date());\n\n const changeMonth = (delta: number) => {\n const next = new Date(month.getFullYear(), month.getMonth() + delta, 1);\n setMonth(next);\n setFocused(toIso(next));\n };\n\n const move = (deltaDays: number) => {\n const base = fromIso(focused) ?? new Date();\n const next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + deltaDays);\n shouldFocus.current = true;\n setFocused(toIso(next));\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n };\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n const steps: Record<string, number> = {\n ArrowLeft: -1,\n ArrowRight: 1,\n ArrowUp: -7,\n ArrowDown: 7,\n PageUp: -28,\n PageDown: 28,\n };\n const delta = steps[event.key];\n if (delta === undefined) {\n return;\n }\n event.preventDefault();\n move(delta);\n };\n\n return (\n <div\n ref={ref}\n className={cx(\"ds-calendar\", className)}\n {...omitRequired(rest)}\n >\n <div className=\"ds-calendar__head\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-left\"\n aria-label=\"Previous month\"\n onClick={() => changeMonth(-1)}\n />\n <span className=\"ds-calendar__month\">{monthLabel(month)}</span>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-right\"\n aria-label=\"Next month\"\n onClick={() => changeMonth(1)}\n />\n </div>\n <div\n className=\"ds-calendar__weekdays\"\n aria-hidden=\"true\"\n >\n {WEEKDAYS.map((day) => (\n <span key={day}>{day.slice(0, 2)}</span>\n ))}\n </div>\n <div\n ref={gridRef}\n className=\"ds-calendar__grid\"\n role=\"grid\"\n onKeyDown={onKeyDown}\n >\n {Array.from({ length: 6 }, (_, rowIndex) => (\n <div\n role=\"row\"\n className=\"ds-calendar__row\"\n key={rowIndex}\n >\n {days.slice(rowIndex * 7, rowIndex * 7 + 7).map((day) => {\n const iso = toIso(day);\n const isOutside = day.getMonth() !== month.getMonth();\n const isDisabled = (min && iso < min) || (max && iso > max);\n const inRange = Boolean(value && endValue && iso > value && iso < endValue);\n const isEdge = iso === value || iso === endValue;\n return (\n <Button\n key={iso}\n variant={dayVariant(isEdge, inRange, iso === today)}\n size=\"sm\"\n isIconOnly\n role=\"gridcell\"\n aria-label={formatIsoDate(iso)}\n tabIndex={iso === focused ? 0 : -1}\n isDisabled={Boolean(isDisabled)}\n aria-selected={isEdge || undefined}\n data-outside={isOutside || undefined}\n data-today={iso === today || undefined}\n data-in-range={inRange || undefined}\n data-focused={iso === focused || undefined}\n className=\"ds-calendar__day\"\n onClick={() => {\n setFocused(iso);\n onSelect?.(iso);\n }}\n >\n {day.getDate()}\n </Button>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport interface DateFieldProps extends FieldBinding {\n /** Preferred side; the shared Popover flips when space requires it. */\n placement?: PopoverPlacement;\n value?: IsoDate;\n defaultValue?: IsoDate;\n onValueChange?: (value: IsoDate) => void;\n size?: FieldSize;\n placeholder?: string;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Show a separate clear action when populated. Defaults to false. */\n isClearable?: boolean;\n clearLabel?: string;\n className?: string;\n}\n\n/** One day, picked from a calendar. The field prints the long date, never a mask. */\nexport function DateField({\n value,\n defaultValue = \"\",\n onValueChange,\n size = \"md\",\n placeholder = \"Pick a date\",\n placement,\n min,\n max,\n isDisabled = false,\n isInvalid = false,\n isClearable = false,\n clearLabel = \"Clear date\",\n \"aria-invalid\": ariaInvalid,\n id,\n className,\n ...rest\n}: DateFieldProps) {\n const [internal, setInternal] = useState<IsoDate>(defaultValue);\n const current = value ?? internal;\n const [isOpen, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n if (isOpen && isDisabled) {\n setOpen(false);\n }\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n // The roving day is always in bounds; the panel takes focus only if bounds exclude every day.\n const panel = panelRef.current;\n (panel?.querySelector<HTMLButtonElement>(\"[data-focused]:not(:disabled)\") ?? panel)?.focus();\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !panelRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", onPointerDown);\n return () => document.removeEventListener(\"mousedown\", onPointerDown);\n }, [isOpen]);\n\n return (\n <div\n className={cx(\"ds-datefield\", className)}\n ref={rootRef}\n onKeyDown={(event) => {\n if (isOpen && event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n triggerRef.current?.focus();\n }\n }}\n >\n <Button\n {...omitRequired(rest)}\n ref={triggerRef}\n id={triggerId}\n size={size}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n isDisabled={isDisabled}\n data-placeholder={current ? undefined : \"\"}\n className=\"ds-field-skin ds-datefield__control\"\n onClick={() => setOpen((open) => !open)}\n >\n <span className=\"ds-datefield__value\">\n {current ? formatIsoDate(current) : placeholder}\n </span>\n <Icon\n name=\"calendar\"\n size={16}\n className=\"ds-datefield__glyph\"\n />\n </Button>\n {isClearable && current && (\n <Button\n variant=\"simple\"\n size={size}\n isIconOnly\n iconStart=\"x\"\n aria-label={clearLabel}\n isDisabled={isDisabled}\n onClick={() => {\n if (value === undefined) {\n setInternal(\"\");\n }\n onValueChange?.(\"\");\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n )}\n <Popover\n anchorRef={triggerRef}\n placement={placement}\n anchorId={triggerId}\n isOpen={isOpen}\n align=\"start\"\n panelRef={panelRef}\n className=\"ds-datefield__popover\"\n role=\"dialog\"\n aria-label=\"Choose a date\"\n // A click on the heading or padding 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 >\n <Calendar\n value={current}\n min={min}\n max={max}\n onSelect={(next) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n </Popover>\n </div>\n );\n}\n\nexport interface DateRangeValue {\n start: IsoDate;\n end: IsoDate;\n}\n\nexport interface DateRangeFieldProps extends FieldBinding {\n placement?: PopoverPlacement;\n value?: DateRangeValue;\n defaultValue?: DateRangeValue;\n onValueChange?: (value: DateRangeValue) => void;\n size?: FieldSize;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isClearable?: boolean;\n startLabel?: string;\n endLabel?: string;\n className?: string;\n}\n\nfunction rangeBound(endpoint: string, bound: string | undefined, kind: \"min\" | \"max\") {\n if (!fromIso(endpoint)) {\n return bound;\n }\n if (!bound) {\n return endpoint;\n }\n return kind === \"min\"\n ? endpoint > bound\n ? endpoint\n : bound\n : endpoint < bound\n ? endpoint\n : bound;\n}\n\n/** A span of days. The end field never offers a day before the start. */\nexport function DateRangeField({\n value,\n defaultValue = { start: \"\", end: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n isDisabled = false,\n isClearable = false,\n startLabel = \"Start date\",\n endLabel = \"End date\",\n placement,\n className,\n ...binding\n}: DateRangeFieldProps) {\n const [internal, setInternal] = useState<DateRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: DateRangeValue) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n const { attributes } = useGroupBinding(binding);\n\n return (\n <div\n {...attributes}\n className={cx(\"ds-daterange\", className)}\n >\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={startLabel}\n placement={placement}\n size={size}\n value={current.start}\n min={min}\n max={rangeBound(current.end, max, \"max\")}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${startLabel}`}\n placeholder={startLabel}\n onValueChange={(next) => commit({ ...current, start: next })}\n />\n <span\n className=\"ds-daterange__dash\"\n aria-hidden=\"true\"\n >\n –\n </span>\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={endLabel}\n placement={placement}\n size={size}\n value={current.end}\n min={rangeBound(current.start, min, \"min\")}\n max={max}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${endLabel}`}\n placeholder={endLabel}\n onValueChange={(next) => commit({ ...current, end: next })}\n />\n </div>\n );\n}\n"],"mappings":"A,gQAGA,SAAgBe,EAAM,EAAqB,CACzC,IAAMC,EAAQ,GAAGC,EAAK,SAAS,EAAI,IAAI,SAAS,EAAG,GAAG,EAChDC,EAAM,GAAGD,EAAK,QAAQ,IAAI,SAAS,EAAG,GAAG,EAC/C,MAAO,GAAGA,EAAK,YAAY,EAAE,GAAGD,EAAM,GAAGE,GAC3C,CAEA,SAAgBC,EAAQ,EAAwC,CAC9D,GAAI,CAACC,GAAS,CAAC,sBAAsB,KAAKA,CAAK,EAC7C,OAAO,KAET,GAAM,CAACC,EAAML,EAAOE,GAAOE,EAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,EACtD,GAAI,CAACC,GAAQ,CAACL,GAAS,CAACE,EACtB,OAAO,KAET,IAAMD,EAAO,IAAI,KAAKI,EAAML,EAAQ,EAAGE,CAAG,EAC1C,OAAO,OAAO,MAAMD,EAAK,QAAQ,CAAC,GAAKF,EAAME,CAAI,IAAMG,EAAQ,KAAOH,CACxE,CAGA,SAAgBK,EAAU,EAAe,CACvC,OAAOH,EAAQC,CAAK,IAAM,IAC5B,CAGA,SAAgBG,EAAc,EAAmC,CAC/D,IAAMN,EAAOE,EAAQC,CAAK,EAI1B,OAHKH,EAGEA,EAAK,mBAAmB,QAAS,CAAE,IAAK,UAAW,MAAO,OAAQ,KAAM,SAAU,CAAC,EAFjF,EAGX,CCpBA,SAASO,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAEA,IAAMC,EAAW,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EAGjE,SAASC,EAAa,EAA2B,EAAe,EAAwB,CACtF,IAAMT,EAAMC,EAAQC,CAAK,EAAKA,EAAoBL,EAAM,IAAI,IA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ACD,EAAA/B,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,qBACV,cAAY,OACb,SAAA,GAEK,CAAA,GACN,EAAAA,EAAA,IAAA,CAACkD,EAAD,CACE,eAAc4B,EAAQ,gBACtB,aAAYI,EACD,YACL,OACN,MAAO3B,EAAQ,IACf,IAAKkB,EAAWlB,EAAQ,MAAOzC,EAAK,KAAK,EACpC,MACO,aACC,cACb,WAAY,SAASoE,IACrB,YAAaA,EACb,cAAgB,GAASH,EAAO,CAAE,GAAGxB,EAAS,IAAKxB,CAAK,CAAC,CAC1D,CAAA,CACE,C,EAET,C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePicker-C1zcScC3.js","names":["Icon","toIso","month","date","day","fromIso","value","year","isIsoDate","formatIsoDate","cx","parts","WEEKDAYS","focusableDay","min","max","monthLabel","startOfGrid","first","weekday","dayVariant","isEdge","inRange","isToday","Calendar","forwardRef","rest","focused","setFocused","useState","setMonth","gridRef","useRef","shouldFocus","useEffect","next","days","start","index","today","changeMonth","delta","move","base","deltaDays","onKeyDown","event","className","omitRequired","Button","rowIndex","iso","isOutside","isDisabled","endValue","onSelect","DateField","ariaInvalid","internal","setInternal","defaultValue","current","isOpen","setOpen","rootRef","triggerRef","panelRef","generatedId","useId","triggerId","id","panel","onPointerDown","target","isInvalid","open","placeholder","isClearable","clearLabel","onValueChange","Popover","rangeBound","endpoint","bound","kind","DateRangeField","binding","commit","useGroupBinding","attributes","startLabel","endLabel"],"sources":["../../src/components/DatePicker/date.ts","../../src/components/DatePicker/index.tsx"],"sourcesContent":["/** ISO calendar date, \"YYYY-MM-DD\" — the only date shape the system passes around. */\nexport type IsoDate = string;\n\nexport function toIso(date: Date): IsoDate {\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const day = `${date.getDate()}`.padStart(2, \"0\");\n return `${date.getFullYear()}-${month}-${day}`;\n}\n\nexport function fromIso(value: string | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) {\n return null;\n }\n const [year, month, day] = value.split(\"-\").map(Number);\n if (!year || !month || !day) {\n return null;\n }\n const date = new Date(year, month - 1, day);\n return Number.isNaN(date.getTime()) || toIso(date) !== value ? null : date;\n}\n\n/** A real calendar day in \"YYYY-MM-DD\" form, checked without locale formatting. */\nexport function isIsoDate(value: string) {\n return fromIso(value) !== null;\n}\n\n/** \"12 March 2026\" — the system's one long date format. */\nexport function formatIsoDate(value: string | undefined): string {\n const date = fromIso(value);\n if (!date) {\n return \"\";\n }\n return date.toLocaleDateString(\"en-GB\", { day: \"numeric\", month: \"long\", year: \"numeric\" });\n}\n","import { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Popover, type PopoverPlacement } from \"../Popover\";\nimport { omitRequired, useGroupBinding } from \"../Field/binding\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { formatIsoDate, fromIso, toIso, type IsoDate } from \"./date\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport { formatIsoDate } from \"./date\";\nexport type { IsoDate } from \"./date\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst WEEKDAYS = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"];\n\n/** The selected day, or today when none is valid, moved inside the bounds so it can take focus. */\nfunction focusableDay(value: string | undefined, min?: IsoDate, max?: IsoDate): IsoDate {\n const day = fromIso(value) ? (value as IsoDate) : toIso(new Date());\n if (min && day < min) {\n return min;\n }\n return max && day > max ? max : day;\n}\n\nfunction monthLabel(date: Date) {\n return date.toLocaleDateString(\"en-GB\", { month: \"long\", year: \"numeric\" });\n}\n\nfunction startOfGrid(month: Date) {\n const first = new Date(month.getFullYear(), month.getMonth(), 1);\n const weekday = (first.getDay() + 6) % 7; // Monday-first\n return new Date(first.getFullYear(), first.getMonth(), 1 - weekday);\n}\n\nfunction dayVariant(isEdge: boolean, inRange: boolean, isToday: boolean) {\n if (isEdge) {\n return \"primary\";\n }\n if (inRange) {\n return \"active\";\n }\n return isToday ? \"neutral\" : \"simple\";\n}\n\nexport interface CalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n /** Selected day, or the start of a selected span. */\n value?: IsoDate;\n /** End of a selected span. Set it to put the calendar in range mode. */\n endValue?: IsoDate;\n onSelect?: (value: IsoDate) => void;\n min?: IsoDate;\n max?: IsoDate;\n}\n\n/**\n * A month of days, Monday first. Arrow keys walk the grid; the month follows\n * the focused day, so a whole year is reachable from the keyboard.\n */\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>(function Calendar(\n { value, endValue, onSelect, min, max, className, ...rest },\n ref,\n) {\n const [focused, setFocused] = useState<IsoDate>(() => focusableDay(value, min, max));\n const [month, setMonth] = useState(() => fromIso(focused) ?? new Date());\n const gridRef = useRef<HTMLDivElement | null>(null);\n const shouldFocus = useRef(false);\n\n useEffect(() => {\n if (!fromIso(value)) {\n return;\n }\n const day = focusableDay(value, min, max);\n const next = fromIso(day) ?? new Date();\n // Controlled changes intentionally reposition the visible and roving-focus month.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setFocused(day);\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n }, [value, min, max]);\n\n useEffect(() => {\n if (!shouldFocus.current) {\n return;\n }\n shouldFocus.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(\"[data-focused]\")?.focus();\n }, [focused]);\n\n const days = Array.from({ length: 42 }, (_, index) => {\n const start = startOfGrid(month);\n return new Date(start.getFullYear(), start.getMonth(), start.getDate() + index);\n });\n\n const today = toIso(new Date());\n\n const changeMonth = (delta: number) => {\n const next = new Date(month.getFullYear(), month.getMonth() + delta, 1);\n setMonth(next);\n setFocused(toIso(next));\n };\n\n const move = (deltaDays: number) => {\n const base = fromIso(focused) ?? new Date();\n const next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + deltaDays);\n shouldFocus.current = true;\n setFocused(toIso(next));\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n };\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n const steps: Record<string, number> = {\n ArrowLeft: -1,\n ArrowRight: 1,\n ArrowUp: -7,\n ArrowDown: 7,\n PageUp: -28,\n PageDown: 28,\n };\n const delta = steps[event.key];\n if (delta === undefined) {\n return;\n }\n event.preventDefault();\n move(delta);\n };\n\n return (\n <div\n ref={ref}\n className={cx(\"ds-calendar\", className)}\n {...omitRequired(rest)}\n >\n <div className=\"ds-calendar__head\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-left\"\n aria-label=\"Previous month\"\n onClick={() => changeMonth(-1)}\n />\n <span className=\"ds-calendar__month\">{monthLabel(month)}</span>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-right\"\n aria-label=\"Next month\"\n onClick={() => changeMonth(1)}\n />\n </div>\n <div\n className=\"ds-calendar__weekdays\"\n aria-hidden=\"true\"\n >\n {WEEKDAYS.map((day) => (\n <span key={day}>{day.slice(0, 2)}</span>\n ))}\n </div>\n <div\n ref={gridRef}\n className=\"ds-calendar__grid\"\n role=\"grid\"\n onKeyDown={onKeyDown}\n >\n {Array.from({ length: 6 }, (_, rowIndex) => (\n <div\n role=\"row\"\n className=\"ds-calendar__row\"\n key={rowIndex}\n >\n {days.slice(rowIndex * 7, rowIndex * 7 + 7).map((day) => {\n const iso = toIso(day);\n const isOutside = day.getMonth() !== month.getMonth();\n const isDisabled = (min && iso < min) || (max && iso > max);\n const inRange = Boolean(value && endValue && iso > value && iso < endValue);\n const isEdge = iso === value || iso === endValue;\n return (\n <Button\n key={iso}\n variant={dayVariant(isEdge, inRange, iso === today)}\n size=\"sm\"\n isIconOnly\n role=\"gridcell\"\n aria-label={formatIsoDate(iso)}\n tabIndex={iso === focused ? 0 : -1}\n isDisabled={Boolean(isDisabled)}\n aria-selected={isEdge || undefined}\n data-outside={isOutside || undefined}\n data-today={iso === today || undefined}\n data-in-range={inRange || undefined}\n data-focused={iso === focused || undefined}\n className=\"ds-calendar__day\"\n onClick={() => {\n setFocused(iso);\n onSelect?.(iso);\n }}\n >\n {day.getDate()}\n </Button>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport interface DateFieldProps extends FieldBinding {\n /** Preferred side; the shared Popover flips when space requires it. */\n placement?: PopoverPlacement;\n value?: IsoDate;\n defaultValue?: IsoDate;\n onValueChange?: (value: IsoDate) => void;\n size?: FieldSize;\n placeholder?: string;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Show a separate clear action when populated. Defaults to false. */\n isClearable?: boolean;\n clearLabel?: string;\n className?: string;\n}\n\n/** One day, picked from a calendar. The field prints the long date, never a mask. */\nexport function DateField({\n value,\n defaultValue = \"\",\n onValueChange,\n size = \"md\",\n placeholder = \"Pick a date\",\n placement,\n min,\n max,\n isDisabled = false,\n isInvalid = false,\n isClearable = false,\n clearLabel = \"Clear date\",\n \"aria-invalid\": ariaInvalid,\n id,\n className,\n ...rest\n}: DateFieldProps) {\n const [internal, setInternal] = useState<IsoDate>(defaultValue);\n const current = value ?? internal;\n const [isOpen, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n if (isOpen && isDisabled) {\n setOpen(false);\n }\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n // The roving day is always in bounds; the panel takes focus only if bounds exclude every day.\n const panel = panelRef.current;\n (panel?.querySelector<HTMLButtonElement>(\"[data-focused]:not(:disabled)\") ?? panel)?.focus();\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !panelRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", onPointerDown);\n return () => document.removeEventListener(\"mousedown\", onPointerDown);\n }, [isOpen]);\n\n return (\n <div\n className={cx(\"ds-datefield\", className)}\n ref={rootRef}\n onKeyDown={(event) => {\n if (isOpen && event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n triggerRef.current?.focus();\n }\n }}\n >\n <Button\n {...omitRequired(rest)}\n ref={triggerRef}\n id={triggerId}\n size={size}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n isDisabled={isDisabled}\n data-placeholder={current ? undefined : \"\"}\n className=\"ds-field-skin ds-datefield__control\"\n onClick={() => setOpen((open) => !open)}\n >\n <span className=\"ds-datefield__value\">\n {current ? formatIsoDate(current) : placeholder}\n </span>\n <Icon\n name=\"calendar\"\n size={16}\n className=\"ds-datefield__glyph\"\n />\n </Button>\n {isClearable && current && (\n <Button\n variant=\"simple\"\n size={size}\n isIconOnly\n iconStart=\"x\"\n aria-label={clearLabel}\n isDisabled={isDisabled}\n onClick={() => {\n if (value === undefined) {\n setInternal(\"\");\n }\n onValueChange?.(\"\");\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n )}\n <Popover\n anchorRef={triggerRef}\n placement={placement}\n anchorId={triggerId}\n isOpen={isOpen}\n align=\"start\"\n panelRef={panelRef}\n className=\"ds-datefield__popover\"\n role=\"dialog\"\n aria-label=\"Choose a date\"\n // A click on the heading or padding 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 >\n <Calendar\n value={current}\n min={min}\n max={max}\n onSelect={(next) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n </Popover>\n </div>\n );\n}\n\nexport interface DateRangeValue {\n start: IsoDate;\n end: IsoDate;\n}\n\nexport interface DateRangeFieldProps extends FieldBinding {\n placement?: PopoverPlacement;\n value?: DateRangeValue;\n defaultValue?: DateRangeValue;\n onValueChange?: (value: DateRangeValue) => void;\n size?: FieldSize;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isClearable?: boolean;\n startLabel?: string;\n endLabel?: string;\n className?: string;\n}\n\nfunction rangeBound(endpoint: string, bound: string | undefined, kind: \"min\" | \"max\") {\n if (!fromIso(endpoint)) {\n return bound;\n }\n if (!bound) {\n return endpoint;\n }\n return kind === \"min\"\n ? endpoint > bound\n ? endpoint\n : bound\n : endpoint < bound\n ? endpoint\n : bound;\n}\n\n/** A span of days. The end field never offers a day before the start. */\nexport function DateRangeField({\n value,\n defaultValue = { start: \"\", end: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n isDisabled = false,\n isClearable = false,\n startLabel = \"Start date\",\n endLabel = \"End date\",\n placement,\n className,\n ...binding\n}: DateRangeFieldProps) {\n const [internal, setInternal] = useState<DateRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: DateRangeValue) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n const { attributes } = useGroupBinding(binding);\n\n return (\n <div\n {...attributes}\n className={cx(\"ds-daterange\", className)}\n >\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={startLabel}\n placement={placement}\n size={size}\n value={current.start}\n min={min}\n max={rangeBound(current.end, max, \"max\")}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${startLabel}`}\n placeholder={startLabel}\n onValueChange={(next) => commit({ ...current, start: next })}\n />\n <span\n className=\"ds-daterange__dash\"\n aria-hidden=\"true\"\n >\n –\n </span>\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={endLabel}\n placement={placement}\n size={size}\n value={current.end}\n min={rangeBound(current.start, min, \"min\")}\n max={max}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${endLabel}`}\n placeholder={endLabel}\n onValueChange={(next) => commit({ ...current, end: next })}\n />\n </div>\n );\n}\n"],"mappings":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/DC,IAAUvD,KAASoD,GAEnB6B,KAAU,MAAyB;EAIvC,AAHIjF,MAAU,KAAA,KACZqD,EAAYxB,CAAI,GAElB4C,IAAgB5C,CAAI;CACtB,GACM,EAAE,kBAAeqD,EAAgBF,CAAO;CAE9C,OACE,kBAAC,OAAD;EACE,GAAIG;EACJ,WAAW/E,EAAG,gBAAgBqC,CAAS;EAFzC,UAAA;GAIE,kBAACS,GAAD;IACE,gBAAc8B,EAAQ;IACtB,cAAYI;IACD;IACL;IACN,OAAO7B,EAAQ;IACV;IACL,KAAKoB,EAAWpB,EAAQ,KAAK9C,GAAK,KAAK;IAC3B;IACC;IACb,YAAY,SAAS2E;IACrB,aAAaA;IACb,gBAAgB,MAASH,EAAO;KAAE,GAAG1B;KAAS,OAAO1B;IAAK,CAAC;GAC5D,CAAA;GACD,kBAAC,QAAD;IACE,WAAU;IACV,eAAY;IACb,UAAA;GAEK,CAAA;GACN,kBAACqB,GAAD;IACE,gBAAc8B,EAAQ;IACtB,cAAYK;IACD;IACL;IACN,OAAO9B,EAAQ;IACf,KAAKoB,EAAWpB,EAAQ,OAAO/C,GAAK,KAAK;IACpC;IACO;IACC;IACb,YAAY,SAAS6E;IACrB,aAAaA;IACb,gBAAgB,MAASJ,EAAO;KAAE,GAAG1B;KAAS,KAAK1B;IAAK,CAAC;GAC1D,CAAA;EACE;;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormEditor-C4PJu7ZF.js","names":["_Fragment","documentError","emptyDocument","RichTextEditor","parseColour","ColourField","sliderScale","preciseSum","Slider","clampToScale","RangeSlider","isIsoDate","DateField","Fragment$1","expandedWidths","fieldWidths","fieldTypes","assertModel","ids","field","model","assertChoices","assertSlider","assertMeasures","min","max","step","kind","values","option","value","linkCopy","fieldLabel","pickerCopy","defaults","selectedIds","isLink","link","key","parseUtcDateTime","match","canonical","date","hasRichText","node","requiredError","textError","richTextError","error","choiceError","stringList","item","listError","numberError","dateError","sliderValue","scale","rangeSliderValue","range","start","end","low","high","a","b","rangeError","colourError","linkError","itemLabel","itemsLabel","validators","fieldError","validateFormValues","Option","props","isDisabled","invalid","onChange","Card","RadioCard","CheckboxCard","Choice","Radio","Checkbox","ChoiceControl","multiple","selected","stored","Group","SelectionCardGroup","ChoiceGroup","accessibility","required","Button","SliderControl","shown","next","RangeSliderControl","AdditionalControl","raw","event","TagsInput","pickerValue","links","NumberControl","NumberField","SelectControl","isClearable","Select","PickerControl","EntryPicker","FormControl","shared","TextField","TextArea","Switch","FormEditorField","validation","useMemo","isErrorVisible","Container","Field","groupTypes","loadedValidationTypes","FormEditor","rest","internal","setInternal","useState","defaultValue","changed","setChanged","current","schema","commit","fieldId","previous","onValueChange","layout","columns","minColumnWidth","className","style","fieldDisabled","isLocked","isLoaded","showAllErrors","pickerItems","errors"],"sources":["../../src/components/RichTextEditor/expanded-width.ts","../../src/components/FormEditor/model.ts","../../src/components/FormEditor/choice-control.tsx","../../src/components/FormEditor/additional-control.tsx","../../src/components/FormEditor/control.tsx","../../src/components/FormEditor/index.tsx"],"sourcesContent":["/** Expanded writing measures: `wide` caps at the shared wide Modal width; `full` fills the viewport inside the scrim's gutters. */\nexport const expandedWidths = [\"wide\", \"full\"] as const;\n\nexport type RichTextEditorExpandedWidth = (typeof expandedWidths)[number];\n","import type { ReactNode } from \"react\";\nimport type { SelectOption } from \"../Select\";\nimport type { EntryPickerProps } from \"../EntryPicker\";\nimport type { JSONContent } from \"@tiptap/react\";\nimport { documentError } from \"../RichTextEditor/document\";\nimport type { RichTextDocument } from \"../RichTextEditor\";\nimport { expandedWidths, type RichTextEditorExpandedWidth } from \"../RichTextEditor/expanded-width\";\nimport { isIsoDate } from \"../DatePicker/date\";\nimport type { RangeSliderValue } from \"../Slider\";\nimport { clampToScale, preciseSum, sliderScale, type SliderScale } from \"../Slider/scale\";\nimport { parseColour } from \"../ColourField/colour\";\nimport type { PopoverPlacement } from \"../Popover\";\nimport type { ContainerWidth } from \"../Container\";\n\n/** The shared measures a field may cap at; checked against Container's scale. */\nconst fieldWidths = [\"sm\", \"md\", \"lg\"] as const satisfies readonly ContainerWidth[];\n\ninterface FormFieldBase {\n id: string;\n label: string;\n hint?: ReactNode;\n /** Maximum width of the whole field, using Container's measures and its `lg` default. */\n width?: (typeof fieldWidths)[number];\n placeholder?: string;\n required?: boolean;\n isDisabled?: boolean;\n}\n\ninterface SliderOptions {\n multiple?: never;\n min?: number;\n max?: number;\n step?: number;\n prefix?: string;\n suffix?: string;\n hasValueLabel?: boolean;\n}\n\ninterface ChoiceOptions {\n multiple?: never;\n autoFocus?: never;\n options: SelectOption[];\n appearance?: \"default\" | \"card\";\n /** Maximum options per row inside this group; independent of FormEditor columns. */\n columns?: 1 | 2 | 3;\n}\n\nexport type FormField = FormFieldBase &\n (\n | {\n type: \"shortText\";\n inputType?: \"text\" | \"email\";\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n }\n | {\n type: \"longText\";\n rows?: number;\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n }\n | { type: \"boolean\" | \"dateTime\"; autoFocus?: boolean; multiple?: never }\n | {\n type: \"richText\";\n expandedWidth?: RichTextEditorExpandedWidth;\n autoFocus?: never;\n multiple?: never;\n }\n | {\n type: \"number\";\n min?: number;\n max?: number;\n step?: number | \"any\";\n hasSteppers?: boolean;\n prefix?: string;\n suffix?: string;\n autoFocus?: boolean;\n multiple?: never;\n }\n | { type: \"select\"; options: SelectOption[]; autoFocus?: boolean; multiple?: never }\n | ({ type: \"slider\"; autoFocus?: boolean } & SliderOptions)\n | ({ type: \"rangeSlider\"; autoFocus?: never } & SliderOptions)\n | ({ type: \"radioGroup\" } & ChoiceOptions)\n | ({ type: \"checkboxGroup\" } & ChoiceOptions)\n | {\n type: \"colour\";\n multiple?: never;\n presets?: string[];\n showPresets?: boolean;\n picker?: \"custom\" | \"native\";\n placement?: PopoverPlacement;\n readOnly?: boolean;\n autoFocus?: boolean;\n }\n | { type: \"tags\"; max?: number; multiple?: never; autoFocus?: never }\n | {\n type: \"date\";\n min?: string;\n max?: string;\n placement?: PopoverPlacement;\n multiple?: never;\n autoFocus?: never;\n }\n | {\n type: \"asset\" | \"reference\";\n multiple?: boolean;\n autoFocus?: never;\n picker?: Pick<\n EntryPickerProps,\n \"label\" | \"addLabel\" | \"emptyLabel\" | \"itemLabel\" | \"itemsLabel\" | \"max\" | \"isReorderable\"\n >;\n }\n );\n\nexport type FieldOf<T extends FormField[\"type\"]> = Extract<FormField, { type: T }>;\n\n/** Layout only: no label, value, disabled state, or validation. */\nexport interface FormDivider {\n id: string;\n type: \"divider\";\n}\n\nexport type FormItem = FormField | FormDivider;\n\nexport interface FormSchema {\n fields: readonly FormItem[];\n}\n\nexport interface AssetValue {\n assetId: string;\n}\nexport interface ReferenceValue {\n entryId: string;\n}\nexport type FormFieldValue =\n | string\n | number\n | boolean\n | RichTextDocument\n | AssetValue\n | ReferenceValue\n | string[]\n | RangeSliderValue\n | AssetValue[]\n | ReferenceValue[];\nexport type FormValues = Record<string, FormFieldValue | undefined>;\nexport type FormErrors = Partial<Record<string, string>>;\n\nconst fieldTypes = new Set([\n \"shortText\",\n \"longText\",\n \"richText\",\n \"number\",\n \"boolean\",\n \"dateTime\",\n \"asset\",\n \"reference\",\n \"select\",\n \"slider\",\n \"rangeSlider\",\n \"colour\",\n \"radioGroup\",\n \"checkboxGroup\",\n \"tags\",\n \"date\",\n \"divider\",\n]);\n\nexport function assertModel(model: FormSchema) {\n const ids = new Set<string>();\n for (const field of model.fields) {\n if (!field.id?.trim() || ids.has(field.id)) {\n throw new Error(\"Form field IDs must be nonempty and unique.\");\n }\n if (!fieldTypes.has(field.type)) {\n throw new Error(`Unsupported form field type: ${field.type}`);\n }\n if (field.type === \"select\" || field.type === \"radioGroup\" || field.type === \"checkboxGroup\") {\n assertChoices(field);\n }\n if (field.type === \"slider\" || field.type === \"rangeSlider\") {\n assertSlider(field);\n }\n if (field.type !== \"divider\") {\n assertMeasures(field);\n }\n ids.add(field.id);\n }\n}\n\n/** Runtime schemas can carry any string; the types only cover typed schemas. */\nfunction assertMeasures(field: FormField) {\n if (field.width !== undefined && !fieldWidths.includes(field.width)) {\n throw new Error(`Field ${field.id} needs a width of sm, md or lg.`);\n }\n if (\n field.type === \"richText\" &&\n field.expandedWidth !== undefined &&\n !expandedWidths.includes(field.expandedWidth)\n ) {\n throw new Error(`Rich text field ${field.id} needs an expandedWidth of wide or full.`);\n }\n}\n\nfunction assertSlider(field: FieldOf<\"slider\" | \"rangeSlider\">) {\n const { min, max, step } = sliderScale(field);\n if (![min, max, step].every(Number.isFinite) || min >= max || step <= 0) {\n throw new Error(`Slider field ${field.id} needs finite min < max and a positive step.`);\n }\n if (field.type === \"rangeSlider\" && step > preciseSum(max, -min)) {\n throw new Error(`Range slider ${field.id} needs room for at least one step.`);\n }\n}\n\nfunction assertChoices(field: FieldOf<\"select\" | \"radioGroup\" | \"checkboxGroup\">) {\n if (!Array.isArray(field.options)) {\n const kind = field.type === \"select\" ? \"Select\" : \"Choice\";\n throw new Error(`${kind} field ${field.id} needs an options array.`);\n }\n if (field.type === \"select\") {\n return;\n }\n const values = field.options.map((option) => option.value);\n if (\n values.some((value) => typeof value !== \"string\" || !value.trim()) ||\n new Set(values).size !== values.length\n ) {\n throw new Error(`Choice field ${field.id} needs nonempty, unique option values.`);\n }\n}\n\nconst linkCopy = {\n asset: { key: \"assetId\", itemLabel: \"asset\", itemsLabel: \"assets\" },\n reference: { key: \"entryId\", itemLabel: \"entry\", itemsLabel: \"entries\" },\n} as const;\n\n/** The field's visible and accessible name. A picker's `label` overrides it. */\nexport function fieldLabel(field: FormField): string {\n return field.type === \"asset\" || field.type === \"reference\"\n ? (field.picker?.label ?? field.label)\n : field.label;\n}\n\n/** Picker action and item copy, with asset or entry wording for any option left out or undefined. */\nexport function pickerCopy(field: FieldOf<\"asset\" | \"reference\">) {\n const defaults = linkCopy[field.type];\n const {\n addLabel = `Choose ${fieldLabel(field)}`,\n emptyLabel,\n itemLabel = defaults.itemLabel,\n itemsLabel = defaults.itemsLabel,\n max,\n isReorderable,\n } = field.picker ?? {};\n return { addLabel, emptyLabel, itemLabel, itemsLabel, max, isReorderable };\n}\n\n/** The picked IDs, in stored order, skipping anything that isn't a link. */\nexport function selectedIds(field: FieldOf<\"asset\" | \"reference\">, value: unknown): string[] {\n const { key } = linkCopy[field.type];\n const links = Array.isArray(value) ? value : value === undefined ? [] : [value];\n return links.flatMap((link) =>\n isLink(link, key) ? [(link as Record<string, string>)[key]] : [],\n );\n}\n\n/** Accept UTC ISO strings without rolling invalid dates into the next month. */\nexport function parseUtcDateTime(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return;\n }\n const match = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?(?:Z|\\+00:00)$/.exec(\n value,\n );\n if (!match) {\n return;\n }\n const canonical = `${match[1]}:${match[2] ?? \"00\"}.${(match[3] ?? \"\").padEnd(3, \"0\")}Z`;\n const date = new Date(canonical);\n if (Number.isFinite(date.getTime()) && date.toISOString() === canonical) {\n return canonical;\n }\n}\n\nfunction isLink(value: unknown, key: \"assetId\" | \"entryId\"): boolean {\n return (\n !!value &&\n typeof value === \"object\" &&\n key in value &&\n typeof (value as Record<string, unknown>)[key] === \"string\" &&\n (value as Record<string, string>)[key].trim().length > 0\n );\n}\n\nfunction hasRichText(node: JSONContent): boolean {\n return !!node.text?.trim() || node.type === \"horizontalRule\" || !!node.content?.some(hasRichText);\n}\n\nfunction requiredError(field: FormField): string {\n return `${fieldLabel(field)} is required.`;\n}\n\nfunction textError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter text.\";\n }\n if (field.required && !value.trim()) {\n return requiredError(field);\n }\n if (\n (field.type === \"shortText\" || field.type === \"longText\") &&\n field.maxLength !== undefined &&\n value.length > field.maxLength\n ) {\n return `Enter no more than ${field.maxLength} characters.`;\n }\n}\n\nfunction richTextError(field: FormField, value: unknown): string | undefined {\n const error = documentError(value);\n if (error) {\n return error;\n }\n if (field.required && !hasRichText(value as RichTextDocument)) {\n return requiredError(field);\n }\n}\n\nfunction choiceError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Choose an available option.\";\n }\n if (value === \"\") {\n return field.required ? requiredError(field) : undefined;\n }\n // An empty list means the choices are still loading, so a stored value stays valid until they arrive.\n if (\n (field.type === \"select\" || field.type === \"radioGroup\") &&\n field.options.length > 0 &&\n !field.options.some((option) => option.value === value)\n ) {\n return \"Choose an available option.\";\n }\n}\n\nexport function stringList(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((item): item is string => typeof item === \"string\")\n : [];\n}\n\nfunction listError(field: FormField, value: unknown): string | undefined {\n if (\n !Array.isArray(value) ||\n !value.every((item) => typeof item === \"string\" && item.trim()) ||\n new Set(value).size !== value.length\n ) {\n return \"Enter a list of unique, nonempty text values.\";\n }\n if (field.required && !value.length) {\n return requiredError(field);\n }\n if (field.type === \"tags\" && field.max !== undefined && value.length > field.max) {\n return `Enter no more than ${field.max} tags.`;\n }\n if (\n field.type === \"checkboxGroup\" &&\n field.options.length &&\n value.some((item) => !field.options.some((option) => option.value === item))\n ) {\n return \"Choose available options.\";\n }\n}\n\nfunction numberError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n return \"Enter a finite number.\";\n }\n const { min, max }: { min?: number; max?: number } =\n field.type === \"slider\" || field.type === \"rangeSlider\"\n ? sliderScale(field)\n : field.type === \"number\"\n ? field\n : {};\n if (min !== undefined && value < min) {\n return `Enter a number of at least ${min}.`;\n }\n if (max !== undefined && value > max) {\n return `Enter a number no greater than ${max}.`;\n }\n}\n\nfunction dateError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter a valid calendar date (YYYY-MM-DD).\";\n }\n if (!value) {\n return field.required ? requiredError(field) : undefined;\n }\n if (!isIsoDate(value)) {\n return \"Enter a valid calendar date (YYYY-MM-DD).\";\n }\n if (field.type !== \"date\") {\n return;\n }\n if (field.min && value < field.min) {\n return `Choose a date on or after ${field.min}.`;\n }\n if (field.max && value > field.max) {\n return `Choose a date on or before ${field.max}.`;\n }\n}\n\n/**\n * Display positions for loaded values: out-of-scale numbers clamp and reversed\n * endpoints swap, without overwriting the stored data that validation reports.\n * A value that is not a finite number has no position, so the control is unset.\n */\nexport function sliderValue(value: unknown, scale: SliderScale): number | undefined {\n return typeof value === \"number\" && Number.isFinite(value)\n ? clampToScale(value, scale)\n : undefined;\n}\n\n/** A range with neither endpoint usable is unset; one usable endpoint pairs with the scale's end. */\nexport function rangeSliderValue(value: unknown, scale: SliderScale): RangeSliderValue | undefined {\n const range = value as Partial<Record<\"min\" | \"max\", unknown>> | null;\n const start = sliderValue(range?.min, scale);\n const end = sliderValue(range?.max, scale);\n if (start === undefined && end === undefined) {\n return undefined;\n }\n const [low, high] = [start ?? scale.min, end ?? scale.max].sort((a, b) => a - b);\n return { min: low, max: high };\n}\n\nfunction rangeError(field: FormField, value: unknown): string | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return \"Enter a range.\";\n }\n const range = value as Record<string, unknown>;\n const start = range.min;\n const end = range.max;\n const error = numberError(field, start) ?? numberError(field, end);\n if (error) {\n return error;\n }\n if ((start as number) > (end as number)) {\n return \"The start must not be greater than the end.\";\n }\n if (\n field.type === \"rangeSlider\" &&\n preciseSum(end as number, -(start as number)) < sliderScale(field).step\n ) {\n return \"Keep the range endpoints at least one step apart.\";\n }\n}\n\nfunction colourError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter a valid colour.\";\n }\n if (!value.trim()) {\n return field.required ? requiredError(field) : undefined;\n }\n return parseColour(value) ? undefined : \"Enter a valid colour.\";\n}\n\nfunction linkError(field: FormField, value: unknown): string | undefined {\n if (field.type !== \"asset\" && field.type !== \"reference\") {\n return;\n }\n const { key, itemLabel, itemsLabel } = linkCopy[field.type];\n if (!field.multiple) {\n return isLink(value, key) ? undefined : `Choose an ${itemLabel}.`;\n }\n if (!Array.isArray(value) || !value.every((item) => isLink(item, key))) {\n return `Choose a list of ${itemsLabel}.`;\n }\n if (field.required && value.length === 0) {\n return requiredError(field);\n }\n const max = field.picker?.max;\n if (max !== undefined && value.length > max) {\n return `Choose no more than ${max} ${pickerCopy(field).itemsLabel}.`;\n }\n}\n\nconst validators: Record<\n FormField[\"type\"],\n (field: FormField, value: unknown) => string | undefined\n> = {\n shortText: textError,\n longText: textError,\n richText: richTextError,\n number: numberError,\n slider: numberError,\n rangeSlider: rangeError,\n date: dateError,\n colour: colourError,\n radioGroup: choiceError,\n checkboxGroup: listError,\n tags: listError,\n boolean: (_field, value) => (typeof value === \"boolean\" ? undefined : \"Choose a boolean value.\"),\n dateTime: (_field, value) =>\n parseUtcDateTime(value) ? undefined : \"Enter a valid UTC date and time.\",\n select: choiceError,\n asset: linkError,\n reference: linkError,\n};\n\nexport function fieldError(field: FormField, value: unknown): string | undefined {\n if (value === undefined) {\n return field.required ? requiredError(field) : undefined;\n }\n return validators[field.type](field, value);\n}\n\n/** Validate data loaded from JSON as well as values emitted by FormEditor. */\nexport function validateFormValues(model: FormSchema, values: Record<string, unknown>): FormErrors {\n assertModel(model);\n return Object.fromEntries(\n model.fields.flatMap((field): [string, string][] => {\n if (field.type === \"divider\") {\n return [];\n }\n const error = fieldError(\n field,\n Object.hasOwn(values, field.id) ? values[field.id] : undefined,\n );\n return error ? [[field.id, error]] : [];\n }),\n );\n}\n","import { Button } from \"../Button\";\nimport { Checkbox, ChoiceGroup, Radio } from \"../Choice\";\nimport { CheckboxCard, RadioCard, SelectionCardGroup } from \"../SelectionCard\";\nimport type { SelectOption } from \"../Select\";\nimport type { ControlProps } from \"./control\";\nimport { stringList, type FieldOf } from \"./model\";\n\ntype ChoiceField = FieldOf<\"radioGroup\" | \"checkboxGroup\">;\n\nfunction Option({\n field,\n option,\n name,\n checked,\n isDisabled,\n invalid,\n onChange,\n}: {\n field: ChoiceField;\n option: SelectOption;\n name: string;\n checked: boolean;\n isDisabled: boolean;\n invalid: true | undefined;\n onChange: () => void;\n}) {\n const props = {\n name,\n value: option.value,\n checked,\n disabled: isDisabled || option.isDisabled,\n \"aria-invalid\": invalid,\n onChange: () => {\n if (!isDisabled && !option.isDisabled) {\n onChange();\n }\n },\n };\n if (field.appearance === \"card\") {\n const Card = field.type === \"radioGroup\" ? RadioCard : CheckboxCard;\n return (\n <Card\n {...props}\n title={option.label}\n description={option.description}\n />\n );\n }\n const Choice = field.type === \"radioGroup\" ? Radio : Checkbox;\n return (\n <Choice {...props}>\n <span>\n {option.label}\n {option.description && (\n <span className=\"ds-form-editor__option-description\">{option.description}</span>\n )}\n </span>\n </Choice>\n );\n}\n\nexport function ChoiceControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<ChoiceField>) {\n const multiple = field.type === \"checkboxGroup\";\n // Option values are nonempty, so a stored \"\" selects nothing.\n const selected = multiple\n ? stringList(stored)\n : typeof stored === \"string\" && stored\n ? [stored]\n : [];\n const Group = field.appearance === \"card\" ? SelectionCardGroup : ChoiceGroup;\n return (\n <>\n <Group\n {...accessibility}\n label={field.label}\n columns={field.columns ?? (field.appearance === \"card\" ? 2 : 1)}\n >\n {field.options.map((option) => (\n <Option\n key={option.value}\n field={field}\n option={option}\n name={accessibility.id}\n checked={selected.includes(option.value)}\n isDisabled={isDisabled}\n invalid={accessibility[\"aria-invalid\"]}\n onChange={() => {\n if (multiple) {\n onChange(\n selected.includes(option.value)\n ? selected.filter((value) => value !== option.value)\n : [...selected, option.value],\n );\n } else {\n onChange(option.value);\n }\n }}\n />\n ))}\n </Group>\n {!multiple && !required && selected.length > 0 && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isDisabled={isDisabled}\n onClick={() => onChange(undefined)}\n >\n Clear {field.label}\n </Button>\n )}\n </>\n );\n}\n","import { ColourField } from \"../ColourField\";\nimport { parseColour } from \"../ColourField/colour\";\nimport { DateField } from \"../DatePicker\";\nimport { RangeSlider, Slider } from \"../Slider\";\nimport { sliderScale } from \"../Slider/scale\";\nimport { TagsInput } from \"../TagsInput\";\nimport { ChoiceControl } from \"./choice-control\";\nimport type { ControlProps } from \"./control\";\nimport { rangeSliderValue, sliderValue, stringList, type FieldOf } from \"./model\";\n\ntype AdditionalField = FieldOf<\n \"slider\" | \"rangeSlider\" | \"date\" | \"colour\" | \"tags\" | \"radioGroup\" | \"checkboxGroup\"\n>;\n\nfunction SliderControl({\n field,\n stored,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"slider\">>) {\n const scale = sliderScale(field);\n const shown = sliderValue(stored, scale);\n return (\n <Slider\n {...accessibility}\n {...scale}\n prefix={field.prefix}\n suffix={field.suffix}\n hasValueLabel={field.hasValueLabel}\n valueText={shown === undefined ? (field.placeholder ?? \"Not set\") : undefined}\n autoFocus={field.autoFocus}\n isDisabled={isDisabled}\n value={shown ?? scale.min}\n onValueChange={onChange}\n // An unset thumb rests at the minimum, where a click or a key toward it fires\n // no change event. Committing stores the position the slider shows.\n onValueCommit={(next) => {\n if (shown === undefined) {\n onChange(next);\n }\n }}\n />\n );\n}\n\nfunction RangeSliderControl({\n field,\n stored,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"rangeSlider\">>) {\n const scale = sliderScale(field);\n const shown = rangeSliderValue(stored, scale);\n return (\n <RangeSlider\n {...accessibility}\n {...scale}\n prefix={field.prefix}\n suffix={field.suffix}\n hasValueLabel={field.hasValueLabel}\n minLabel={`${field.label} minimum`}\n maxLabel={`${field.label} maximum`}\n isDisabled={isDisabled}\n // Unset thumbs rest at both ends without a fill, so nothing looks chosen; a click\n // or key that leaves them there stores the full range they show.\n valueText={shown === undefined ? (field.placeholder ?? \"Not set\") : undefined}\n hasFill={shown !== undefined}\n value={shown ?? { min: scale.min, max: scale.max }}\n onValueChange={onChange}\n onValueCommit={(next) => {\n if (shown === undefined) {\n onChange(next);\n }\n }}\n />\n );\n}\n\nexport function AdditionalControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<AdditionalField>) {\n const props = { stored, isDisabled, required, accessibility, onChange };\n switch (field.type) {\n case \"radioGroup\":\n case \"checkboxGroup\":\n return (\n <ChoiceControl\n field={field}\n {...props}\n />\n );\n case \"rangeSlider\":\n return (\n <RangeSliderControl\n field={field}\n {...props}\n />\n );\n case \"slider\":\n return (\n <SliderControl\n field={field}\n {...props}\n />\n );\n case \"colour\":\n return (\n <ColourField\n {...accessibility}\n required={required}\n placeholder={field.placeholder}\n presets={field.presets}\n showPresets={field.showPresets}\n picker={field.picker}\n placement={field.placement}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n isDisabled={isDisabled}\n value={typeof stored === \"string\" ? stored : \"\"}\n onInput={(event) => {\n const raw = event.currentTarget.value;\n if (raw.trim() && !parseColour(raw)) {\n onChange(raw);\n }\n }}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n case \"tags\":\n return (\n <TagsInput\n {...accessibility}\n required={required}\n placeholder={field.placeholder}\n max={field.max}\n isDisabled={isDisabled}\n value={stringList(stored)}\n onValueChange={onChange}\n />\n );\n case \"date\":\n return (\n <DateField\n {...accessibility}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n placement={field.placement}\n isDisabled={isDisabled}\n isClearable\n clearLabel={`Clear ${field.label}`}\n value={typeof stored === \"string\" ? stored : \"\"}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n }\n}\n","import { EntryPicker, type EntryItem } from \"../EntryPicker\";\nimport type { FieldRenderProps } from \"../Field\";\nimport { NumberField } from \"../NumberField\";\nimport { RichTextEditor, type RichTextDocument } from \"../RichTextEditor\";\nimport { emptyDocument } from \"../RichTextEditor/document\";\nimport { Select } from \"../Select\";\nimport { Switch } from \"../Switch\";\nimport { TextArea, TextField } from \"../TextField\";\nimport { AdditionalControl } from \"./additional-control\";\nimport {\n parseUtcDateTime,\n pickerCopy,\n type FieldOf,\n type FormField,\n type FormFieldValue,\n} from \"./model\";\n\nfunction pickerValue(\n field: FieldOf<\"asset\" | \"reference\">,\n ids: string[],\n): FormFieldValue | undefined {\n if (field.type === \"asset\") {\n const links = ids.map((assetId) => ({ assetId }));\n return field.multiple ? links : links[0];\n }\n const links = ids.map((entryId) => ({ entryId }));\n return field.multiple ? links : links[0];\n}\n\ntype Accessibility = FieldRenderProps;\n\nexport interface ControlProps<F extends FormField> {\n field: F;\n stored: FormFieldValue | undefined;\n isDisabled: boolean;\n required: boolean | undefined;\n accessibility: Omit<Accessibility, \"required\">;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nfunction NumberControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"number\">>) {\n return (\n <NumberField\n {...accessibility}\n required={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n step={field.step ?? \"any\"}\n hasSteppers={field.hasSteppers ?? false}\n prefix={field.prefix}\n suffix={field.suffix}\n autoFocus={field.autoFocus}\n decreaseLabel={`Decrease ${field.label}`}\n increaseLabel={`Increase ${field.label}`}\n value={typeof stored === \"number\" && Number.isFinite(stored) ? stored : \"\"}\n onValueChange={(next) => {\n if (next === \"\" || Number.isFinite(next)) {\n onChange(next === \"\" ? undefined : next);\n }\n }}\n />\n );\n}\n\nfunction SelectControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"select\">>) {\n // Optional selects lead with an empty choice; picking it removes the key.\n const isClearable = !required && !field.options.some((option) => option.value === \"\");\n return (\n <Select\n {...accessibility}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n isInvalid={accessibility[\"aria-invalid\"]}\n options={\n isClearable\n ? [{ value: \"\", label: field.placeholder ?? \"None\" }, ...field.options]\n : field.options\n }\n placeholder={field.placeholder}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n}\n\nfunction PickerControl({\n field,\n selected,\n items,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"asset\" | \"reference\">> & { items: EntryItem[]; selected: string[] }) {\n return (\n <EntryPicker\n {...accessibility}\n items={items}\n value={selected}\n {...pickerCopy(field)}\n mode={field.multiple ? \"multiple\" : \"single\"}\n isDisabled={isDisabled}\n onValueChange={(ids) => onChange(pickerValue(field, ids))}\n />\n );\n}\n\ninterface FormControlProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n /** Picker fields' stored IDs, derived once by the owning field. */\n selected: string[] | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n accessibility: Accessibility;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nexport function FormControl({\n field,\n stored,\n selected,\n items,\n isDisabled,\n accessibility: { required, ...accessibility },\n onChange,\n}: FormControlProps) {\n const shared = { stored, isDisabled, required, accessibility, onChange };\n switch (field.type) {\n case \"shortText\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n type={field.inputType}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"longText\":\n return (\n <TextArea\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n rows={field.rows}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"number\":\n return (\n <NumberControl\n field={field}\n {...shared}\n />\n );\n case \"boolean\":\n return (\n <Switch\n {...accessibility}\n isDisabled={isDisabled}\n autoFocus={field.autoFocus}\n isSelected={stored === true}\n onSelectedChange={onChange}\n />\n );\n case \"dateTime\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n type=\"datetime-local\"\n step=\"0.001\"\n autoFocus={field.autoFocus}\n value={parseUtcDateTime(stored)?.slice(0, -1) ?? \"\"}\n onChange={(event) => onChange(parseUtcDateTime(`${event.target.value}Z`))}\n />\n );\n case \"richText\":\n return (\n <RichTextEditor\n {...accessibility}\n expandedWidth={field.expandedWidth}\n label={field.label}\n isRequired={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n format=\"json\"\n value={stored === undefined ? emptyDocument : (stored as RichTextDocument)}\n onChange={onChange}\n />\n );\n case \"select\":\n return (\n <SelectControl\n field={field}\n {...shared}\n />\n );\n case \"asset\":\n case \"reference\":\n return (\n <PickerControl\n field={field}\n items={items}\n selected={selected ?? []}\n {...shared}\n />\n );\n default:\n return (\n <AdditionalControl\n field={field}\n {...shared}\n />\n );\n }\n}\n","import { useMemo, useState, type CSSProperties, type HTMLAttributes } from \"react\";\nimport { Container } from \"../Container\";\nimport type { EntryItem } from \"../EntryPicker\";\nimport { Field } from \"../Field\";\nimport type { GridColumns } from \"../Grid\";\nimport { FormControl } from \"./control\";\nimport {\n assertModel,\n fieldError,\n fieldLabel,\n selectedIds,\n stringList,\n type FormField,\n type FormSchema,\n type FormErrors,\n type FormFieldValue,\n type FormValues,\n} from \"./model\";\nimport \"./style.css\";\n\nexport { validateFormValues } from \"./model\";\nexport type {\n AssetValue,\n FormField,\n FormDivider,\n FormItem,\n FormSchema,\n FormErrors,\n FormFieldValue,\n FormValues,\n ReferenceValue,\n} from \"./model\";\n\nexport interface FormChange {\n fieldId: string;\n}\n\nexport interface FormEditorProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"defaultValue\" | \"onChange\"\n> {\n schema: FormSchema;\n value?: FormValues;\n defaultValue?: FormValues;\n onValueChange?: (values: FormValues, change: FormChange) => void;\n /** Available assets or entries, keyed by field ID. Loading belongs to the app. */\n pickerItems?: Record<string, EntryItem[]>;\n /** App-provided messages take precedence over built-in validation. */\n errors?: FormErrors;\n isDisabled?: boolean;\n showAllErrors?: boolean;\n /** Columns at the widest. The form drops one whenever a field would be narrower than `minColumnWidth`. */\n columns?: GridColumns;\n /** Narrowest a field may get before the form drops a column. */\n minColumnWidth?: string;\n}\n\ninterface FormEditorFieldProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n error: string | undefined;\n isErrorVisible: boolean;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\n/** Validates only when its message can show, and only when its own field or value changes. */\nfunction FormEditorField({\n field,\n stored,\n items,\n isDisabled,\n error,\n isErrorVisible,\n onChange,\n}: FormEditorFieldProps) {\n const validation = useMemo(\n () => (error === undefined && isErrorVisible ? fieldError(field, stored) : undefined),\n [error, isErrorVisible, field, stored],\n );\n const selected = useMemo(\n () =>\n field.type === \"asset\" || field.type === \"reference\" ? selectedIds(field, stored) : undefined,\n [field, stored],\n );\n return (\n <Container\n width={field.width}\n padded={false}\n center={false}\n className=\"ds-form-editor__field\"\n >\n <Field\n label={field.type === \"dateTime\" ? `${field.label} (UTC)` : fieldLabel(field)}\n hint={field.hint}\n error={error ?? validation}\n isRequired={field.required}\n count={\n selected?.length ??\n (field.type === \"checkboxGroup\" ? stringList(stored).length : undefined)\n }\n isGroup={selected !== undefined || groupTypes.has(field.type)}\n >\n {(accessibility) => (\n <FormControl\n field={field}\n stored={stored}\n selected={selected}\n items={items}\n isDisabled={isDisabled}\n accessibility={accessibility}\n onChange={onChange}\n />\n )}\n </Field>\n </Container>\n );\n}\n\nconst groupTypes = new Set([\"radioGroup\", \"checkboxGroup\", \"rangeSlider\"]);\nconst loadedValidationTypes = new Set([\"slider\", \"rangeSlider\", \"date\", \"colour\"]);\n\n/** Ordered form controls. Loading, submission, and persistence belong to the app. */\nexport function FormEditor({\n schema,\n value,\n defaultValue = {},\n onValueChange,\n pickerItems = {},\n errors = {},\n isDisabled = false,\n showAllErrors = false,\n columns = 1,\n minColumnWidth = \"16rem\",\n className,\n style,\n ...rest\n}: FormEditorProps) {\n const [internal, setInternal] = useState<FormValues>(defaultValue);\n const [changed, setChanged] = useState<Set<string>>(() => new Set());\n const current = value ?? internal;\n useMemo(() => assertModel(schema), [schema]);\n\n const commit = (fieldId: string, next: FormFieldValue | undefined) => {\n const values = { ...current };\n if (next === undefined) {\n delete values[fieldId];\n } else {\n values[fieldId] = next;\n }\n if (value === undefined) {\n setInternal(values);\n }\n setChanged((previous) => new Set(previous).add(fieldId));\n onValueChange?.(values, { fieldId });\n };\n\n const layout =\n columns === \"auto\"\n ? { \"--form-editor-min-column\": minColumnWidth }\n : { \"--form-editor-columns\": columns, \"--form-editor-min-column\": minColumnWidth };\n\n return (\n <div\n className={[\"ds-form-editor\", columns === \"auto\" && \"ds-form-editor--auto\", className]\n .filter(Boolean)\n .join(\" \")}\n style={{ ...layout, ...style } as CSSProperties}\n {...rest}\n >\n {schema.fields.map((field) => {\n if (field.type === \"divider\") {\n return (\n <hr\n key={field.id}\n className=\"ds-form-editor__divider\"\n />\n );\n }\n const stored = Object.hasOwn(current, field.id) ? current[field.id] : undefined;\n const fieldDisabled = isDisabled || Boolean(field.isDisabled);\n const isLocked = fieldDisabled || (\"readOnly\" in field && Boolean(field.readOnly));\n // Explain loaded invalid values alongside the controls' invalid styling. Blank\n // strings are empty, so their required message waits like any other field's.\n const isLoaded = typeof stored === \"string\" ? stored.trim() !== \"\" : stored !== undefined;\n const isErrorVisible =\n showAllErrors ||\n changed.has(field.id) ||\n (isLoaded && loadedValidationTypes.has(field.type)) ||\n (field.type === \"number\" && typeof stored === \"number\");\n return (\n <FormEditorField\n key={field.id}\n field={field}\n stored={stored}\n items={pickerItems[field.id] ?? []}\n isDisabled={fieldDisabled}\n error={errors[field.id]}\n isErrorVisible={isErrorVisible}\n onChange={(next) => {\n if (!isLocked) {\n commit(field.id, next);\n }\n }}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,IAAac,IAAiB,CAAC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IAAI/G,EAAM,EAAE,KACnB8H,KAAYtB,GAAsB,IAAIxG,EAAM,IAAI,KAChDA,EAAM,SAAS,YAAY,OAAOoE,KAAW;GAChD,OACE,kBAAC6B,IAAD;IAES;IACC;IACR,OAAO+B,EAAYhI,EAAM,OAAO,CAAC;IACjC,YAAY4H;IACZ,OAAOK,EAAOjI,EAAM;IACJ;IAChB,WAAW,MAAS;KAClB,AAAK6H,KACHV,EAAOnH,EAAM,IAAI6E,CAAI;IAEzB;GACD,GAZM7E,EAAM,EAYZ;EAEL,CAAC;CACE,CAAA;AAET"}
@@ -1,2 +0,0 @@
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-Ddk7qaqg.cjs"),a=require("../components/Container/index.cjs"),o=require("../components/EntryPicker/index.cjs"),s=require("../components/NumberField/index.cjs"),c=require("../components/Select/index.cjs"),l=require("../components/Switch/index.cjs"),u=require("./ColourField-Bk5O632x.cjs"),d=require("./Slider-k8weRl34.cjs"),f=require("./DatePicker-BVsloqVY.cjs"),p=require("../components/TagsInput/index.cjs"),m=require("../components/Choice/index.cjs"),h=require("../components/SelectionCard/index.cjs");let g=require("react"),_=require("react/jsx-runtime");var v=[`wide`,`full`],y=[`sm`,`md`,`lg`],b=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`,`select`,`slider`,`rangeSlider`,`colour`,`radioGroup`,`checkboxGroup`,`tags`,`date`,`divider`]);function x(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(!b.has(n.type))throw Error(`Unsupported form field type: ${n.type}`);(n.type===`select`||n.type===`radioGroup`||n.type===`checkboxGroup`)&&w(n),(n.type===`slider`||n.type===`rangeSlider`)&&C(n),n.type!==`divider`&&S(n),t.add(n.id)}}function S(e){if(e.width!==void 0&&!y.includes(e.width))throw Error(`Field ${e.id} needs a width of sm, md or lg.`);if(e.type===`richText`&&e.expandedWidth!==void 0&&!v.includes(e.expandedWidth))throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`)}function C(e){let{min:t,max:n,step:r}=d.a(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>d.i(n,-t))throw Error(`Range slider ${e.id} needs room for at least one step.`)}function w(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 T={asset:{key:`assetId`,itemLabel:`asset`,itemsLabel:`assets`},reference:{key:`entryId`,itemLabel:`entry`,itemsLabel:`entries`}};function E(e){return e.type===`asset`||e.type===`reference`?e.picker?.label??e.label:e.label}function D(e){let t=T[e.type],{addLabel:n=`Choose ${E(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 O(e,t){let{key:n}=T[e.type];return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>A(e,n)?[e[n]]:[])}function k(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 A(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function j(e){return!!e.text?.trim()||e.type===`horizontalRule`||!!e.content?.some(j)}function M(e){return`${E(e)} is required.`}function N(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return M(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 P(e,t){let n=i.n(t);if(n)return n;if(e.required&&!j(t))return M(e)}function F(e,t){if(typeof t!=`string`)return`Choose an available option.`;if(t===``)return e.required?M(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 I(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function L(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 M(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 R(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`?d.a(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 z(e,t){if(typeof t!=`string`)return`Enter a valid calendar date (YYYY-MM-DD).`;if(!t)return e.required?M(e):void 0;if(!f.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 B(e,t){return typeof e==`number`&&Number.isFinite(e)?d.r(e,t):void 0}function V(e,t){let n=e,r=B(n?.min,t),i=B(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 H(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return`Enter a range.`;let n=t,r=n.min,i=n.max,a=R(e,r)??R(e,i);if(a)return a;if(r>i)return`The start must not be greater than the end.`;if(e.type===`rangeSlider`&&d.i(i,-r)<d.a(e).step)return`Keep the range endpoints at least one step apart.`}function U(t,n){return typeof n==`string`?n.trim()?e.i(n)?void 0:`Enter a valid colour.`:t.required?M(t):void 0:`Enter a valid colour.`}function W(e,t){if(e.type!==`asset`&&e.type!==`reference`)return;let{key:n,itemLabel:r,itemsLabel:i}=T[e.type];if(!e.multiple)return A(t,n)?void 0:`Choose an ${r}.`;if(!Array.isArray(t)||!t.every(e=>A(e,n)))return`Choose a list of ${i}.`;if(e.required&&t.length===0)return M(e);let a=e.picker?.max;if(a!==void 0&&t.length>a)return`Choose no more than ${a} ${D(e).itemsLabel}.`}var G={shortText:N,longText:N,richText:P,number:R,slider:R,rangeSlider:H,date:z,colour:U,radioGroup:F,checkboxGroup:L,tags:L,boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>k(t)?void 0:`Enter a valid UTC date and time.`,select:F,asset:W,reference:W};function K(e,t){return t===void 0?e.required?M(e):void 0:G[e.type](e,t)}function q(e,t){return x(e),Object.fromEntries(e.fields.flatMap(e=>{if(e.type===`divider`)return[];let n=K(e,Object.hasOwn(t,e.id)?t[e.id]:void 0);return n?[[e.id,n]]:[]}))}function J({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`?h.RadioCard:h.CheckboxCard;return(0,_.jsx)(n,{...s,title:t.label,description:t.description})}let c=e.type===`radioGroup`?m.Radio:m.Checkbox;return(0,_.jsx)(c,{...s,children:(0,_.jsxs)(`span`,{children:[t.label,t.description&&(0,_.jsx)(`span`,{className:`ds-form-editor__option-description`,children:t.description})]})})}function Y({field:e,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s=e.type===`checkboxGroup`,c=s?I(n):typeof n==`string`&&n?[n]:[],l=e.appearance===`card`?h.SelectionCardGroup:m.ChoiceGroup;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(l,{...a,label:e.label,columns:e.columns??(e.appearance===`card`?2:1),children:e.options.map(t=>(0,_.jsx)(J,{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,_.jsxs)(t.Button,{variant:`simple`,size:`sm`,isDisabled:r,onClick:()=>o(void 0),children:[`Clear `,e.label]})]})}function X({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=d.a(e),o=B(t,a);return(0,_.jsx)(d.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 Z({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=d.a(e),o=V(t,a);return(0,_.jsx)(d.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 Q({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,_.jsx)(Y,{field:t,...s});case`rangeSlider`:return(0,_.jsx)(Z,{field:t,...s});case`slider`:return(0,_.jsx)(X,{field:t,...s});case`colour`:return(0,_.jsx)(u.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,_.jsx)(p.TagsInput,{...a,required:i,placeholder:t.placeholder,max:t.max,isDisabled:r,value:I(n),onValueChange:o});case`date`:return(0,_.jsx)(f.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 $(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 ee({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){return(0,_.jsx)(s.NumberField,{...i,required:r,isDisabled:n,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step??`any`,hasSteppers:e.hasSteppers??!1,prefix:e.prefix,suffix:e.suffix,autoFocus:e.autoFocus,decreaseLabel:`Decrease ${e.label}`,increaseLabel:`Increase ${e.label}`,value:typeof t==`number`&&Number.isFinite(t)?t:``,onValueChange:e=>{(e===``||Number.isFinite(e))&&a(e===``?void 0:e)}})}function te({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){let o=!r&&!e.options.some(e=>e.value===``);return(0,_.jsx)(c.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 ne({field:e,selected:t,items:n,isDisabled:r,accessibility:i,onChange:a}){return(0,_.jsx)(o.EntryPicker,{...i,items:n,value:t,...D(e),mode:e.multiple?`multiple`:`single`,isDisabled:r,onValueChange:t=>a($(e,t))})}function re({field:e,stored:t,selected:n,items:a,isDisabled:o,accessibility:{required:s,...c},onChange:u}){let d={stored:t,isDisabled:o,required:s,accessibility:c,onChange:u};switch(e.type){case`shortText`:return(0,_.jsx)(r.TextField,{...c,required:s,disabled:o,placeholder:e.placeholder,type:e.inputType,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onChange:e=>u(e.target.value)});case`longText`:return(0,_.jsx)(r.TextArea,{...c,required:s,disabled:o,placeholder:e.placeholder,rows:e.rows,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onChange:e=>u(e.target.value)});case`number`:return(0,_.jsx)(ee,{field:e,...d});case`boolean`:return(0,_.jsx)(l.Switch,{...c,isDisabled:o,autoFocus:e.autoFocus,isSelected:t===!0,onSelectedChange:u});case`dateTime`:return(0,_.jsx)(r.TextField,{...c,required:s,disabled:o,type:`datetime-local`,step:`0.001`,autoFocus:e.autoFocus,value:k(t)?.slice(0,-1)??``,onChange:e=>u(k(`${e.target.value}Z`))});case`richText`:return(0,_.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:u});case`select`:return(0,_.jsx)(te,{field:e,...d});case`asset`:case`reference`:return(0,_.jsx)(ne,{field:e,items:a,selected:n??[],...d});default:return(0,_.jsx)(Q,{field:e,...d})}}function ie({field:e,stored:t,items:r,isDisabled:i,error:o,isErrorVisible:s,onChange:c}){let l=(0,g.useMemo)(()=>o===void 0&&s?K(e,t):void 0,[o,s,e,t]),u=(0,g.useMemo)(()=>e.type===`asset`||e.type===`reference`?O(e,t):void 0,[e,t]);return(0,_.jsx)(a.Container,{width:e.width,padded:!1,center:!1,className:`ds-form-editor__field`,children:(0,_.jsx)(n.Field,{label:e.type===`dateTime`?`${e.label} (UTC)`:E(e),hint:e.hint,error:o??l,isRequired:e.required,count:u?.length??(e.type===`checkboxGroup`?I(t).length:void 0),isGroup:u!==void 0||ae.has(e.type),children:n=>(0,_.jsx)(re,{field:e,stored:t,selected:u,items:r,isDisabled:i,accessibility:n,onChange:c})})})}var ae=new Set([`radioGroup`,`checkboxGroup`,`rangeSlider`]),oe=new Set([`slider`,`rangeSlider`,`date`,`colour`]);function se({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,g.useState)(n),[h,v]=(0,g.useState)(()=>new Set),y=t??p;(0,g.useMemo)(()=>x(e),[e]);let b=(e,n)=>{let i={...y};n===void 0?delete i[e]:i[e]=n,t===void 0&&m(i),v(t=>new Set(t).add(e)),r?.(i,{fieldId:e})},S=c===`auto`?{"--form-editor-min-column":l}:{"--form-editor-columns":c,"--form-editor-min-column":l};return(0,_.jsx)(`div`,{className:[`ds-form-editor`,c===`auto`&&`ds-form-editor--auto`,u].filter(Boolean).join(` `),style:{...S,...d},...f,children:e.fields.map(e=>{if(e.type===`divider`)return(0,_.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&&oe.has(e.type)||e.type===`number`&&typeof t==`number`;return(0,_.jsx)(ie,{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 q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return se}});
2
- //# sourceMappingURL=FormEditor-Dd44EMp_.cjs.map