@namroodinc/liquid-editorial 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/UPGRADING.md +152 -0
- package/dist/chunks/{Board-BaQ04nWg.cjs → Board-BPA6mVhf.cjs} +2 -2
- package/dist/chunks/{Board-BaQ04nWg.cjs.map → Board-BPA6mVhf.cjs.map} +1 -1
- package/dist/chunks/{Board-CUhF8pTX.js → Board-CcIF7jS0.js} +2 -2
- package/dist/chunks/{Board-CUhF8pTX.js.map → Board-CcIF7jS0.js.map} +1 -1
- package/dist/chunks/{ColourField-CJicr3OT.cjs → ColourField-BQ4a5tAV.cjs} +2 -2
- package/dist/chunks/{ColourField-CJicr3OT.cjs.map → ColourField-BQ4a5tAV.cjs.map} +1 -1
- package/dist/chunks/{ColourField-DjHRiFDU.js → ColourField-Doew1hLw.js} +3 -3
- package/dist/chunks/{ColourField-DjHRiFDU.js.map → ColourField-Doew1hLw.js.map} +1 -1
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs → DatePicker-C0-609Zx.cjs} +2 -2
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs.map → DatePicker-C0-609Zx.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-D_6CQpUd.js → DatePicker-DmeWUsOS.js} +2 -2
- package/dist/chunks/{DatePicker-D_6CQpUd.js.map → DatePicker-DmeWUsOS.js.map} +1 -1
- package/dist/chunks/{FormEditor-M7tNidFo.js → FormEditor-DTnFO4oS.js} +172 -154
- package/dist/chunks/FormEditor-DTnFO4oS.js.map +1 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs +2 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs.map +1 -0
- package/dist/chunks/Icon-D1kx7-1c.js +81 -0
- package/dist/chunks/Icon-D1kx7-1c.js.map +1 -0
- package/dist/chunks/Icon-D38lQXNe.cjs +2 -0
- package/dist/chunks/Icon-D38lQXNe.cjs.map +1 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js +483 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js.map +1 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs +2 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs.map +1 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs +2 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs.map +1 -0
- package/dist/chunks/movableHost-NJj_FsAu.js +23 -0
- package/dist/chunks/movableHost-NJj_FsAu.js.map +1 -0
- package/dist/chunks/portalScope-AzzPM54i.js +105 -0
- package/dist/chunks/portalScope-AzzPM54i.js.map +1 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs +2 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs.map +1 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js +87 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js.map +1 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs +2 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs.map +1 -0
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +59 -75
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +3 -0
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +107 -121
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/FormEditor/README.md +75 -4
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +2 -1
- package/dist/components/FormEditor/model.d.cts +8 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +8 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/style.css +7 -0
- package/dist/components/Icon/icons.d.cts +2 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +2 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts +9 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts +9 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +37 -45
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +8 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +44 -37
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Popover/style.css +3 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.cts +28 -0
- package/dist/components/RichTextEditor/expansion.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.ts +28 -0
- package/dist/components/RichTextEditor/expansion.d.ts.map +1 -0
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts +4 -4
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +4 -4
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/style.css +85 -4
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -30
- package/dist/internal/dialogFocus.d.cts +8 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +8 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/dist/internal/movableHost.d.cts +20 -0
- package/dist/internal/movableHost.d.cts.map +1 -0
- package/dist/internal/movableHost.d.ts +20 -0
- package/dist/internal/movableHost.d.ts.map +1 -0
- package/dist/internal/portalScope.d.cts +23 -0
- package/dist/internal/portalScope.d.cts.map +1 -0
- package/dist/internal/portalScope.d.ts +23 -0
- package/dist/internal/portalScope.d.ts.map +1 -0
- package/dist/internal/useModalDialog.d.cts +22 -0
- package/dist/internal/useModalDialog.d.cts.map +1 -0
- package/dist/internal/useModalDialog.d.ts +22 -0
- package/dist/internal/useModalDialog.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/chunks/FormEditor-M7tNidFo.js.map +0 -1
- package/dist/chunks/FormEditor-UzbPdiJo.cjs +0 -2
- package/dist/chunks/FormEditor-UzbPdiJo.cjs.map +0 -1
- package/dist/chunks/Icon-BBoWP_Y6.cjs +0 -2
- package/dist/chunks/Icon-BBoWP_Y6.cjs.map +0 -1
- package/dist/chunks/Icon-XNismJDm.js +0 -79
- package/dist/chunks/Icon-XNismJDm.js.map +0 -1
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs +0 -2
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DjR10XJ-.js +0 -370
- package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +0 -1
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +0 -2
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +0 -1
- package/dist/chunks/dialogFocus-BFoyeTpA.js +0 -48
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +0 -1
- package/dist/chunks/dialogStack-6yv3NXFD.js +0 -43
- package/dist/chunks/dialogStack-6yv3NXFD.js.map +0 -1
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs +0 -2
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -251,7 +251,7 @@ export function ArticleMenu({ onEdit, onDelete }: { onEdit: () => void; onDelete
|
|
|
251
251
|
|
|
252
252
|
### Modal
|
|
253
253
|
|
|
254
|
-
A controlled dialog for a focused task. Supply `isOpen`, `onClose`, and a string `title`. Size defaults to `"md"`; `"dialog"` and `"
|
|
254
|
+
A controlled dialog for a focused task. Supply `isOpen`, `onClose`, and a string `title`. Size defaults to `"md"`; `"dialog"`, `"wide"` and `"full"` (the viewport inside the scrim's gutters) are also available.
|
|
255
255
|
|
|
256
256
|
```tsx
|
|
257
257
|
import { useState } from "react";
|
|
@@ -286,7 +286,9 @@ export function ConfirmPublish({ onPublish }: { onPublish: () => void }) {
|
|
|
286
286
|
}
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
-
Modal portals to the body, traps Tab
|
|
289
|
+
Modal portals to the body, traps Tab and locks scrolling. Opening focuses the first control unless focus is already inside the panel (for example through `autoFocus`). Closing returns focus to the opener only when closing dropped it, and falls back to the opener's nearest focusable container, such as an enclosing Drawer, when the opener can no longer take focus. Tab wraps between the first and last rendered controls, counting a radio group as one stop, and focus that leaves the panel returns on the next Tab. Escape, the scrim, and Close request dismissal; the app updates `isOpen`. A popup inside the panel (Menu, Select, DateField) handles Escape first, and Escape that ends an IME composition never closes the dialog. Nested dialogs share the dialog stack and scroll lock.
|
|
290
|
+
|
|
291
|
+
`hasHeader={false}` removes the title band and its Close button. The title (and description) still name and describe the dialog, so provide another visible way to close it. `aria-label` or `aria-labelledby` replace the title as the dialog's name, as on Drawer. Modal and Drawer share one dialog hook, so their focus, Escape and Tab behaviour match.
|
|
290
292
|
|
|
291
293
|
### Drawer
|
|
292
294
|
|
|
@@ -324,7 +326,7 @@ export function MetadataDrawer() {
|
|
|
324
326
|
|
|
325
327
|
Use `variant="navigation"` for compact navigation, `closeLabel` for contextual dismissal copy, and a React-node `title` for a brand. Supply `aria-label` for an independent dialog name. `portalContainer` can keep a navigation drawer inside a positioned element; the default covers the viewport from `document.body`.
|
|
326
328
|
|
|
327
|
-
Keep Drawer mounted while changing `isOpen`: closing immediately makes the exiting panel inert and accessibility-hidden, restores focus without scrolling, and releases its scroll lock; DOM removal follows the transition. Tests should await removal. Tab
|
|
329
|
+
Keep Drawer mounted while changing `isOpen`: closing immediately makes the exiting panel inert and accessibility-hidden, restores focus without scrolling, and releases its scroll lock; DOM removal follows the transition. Tests should await removal. Focus and Tab follow Modal's rules. Only the topmost dialog handles Tab/Escape, and an open popup inside Drawer can handle Escape first. Nested dialogs keep body scrolling locked until the last one closes; scrollbar compensation preserves layout widths.
|
|
328
330
|
|
|
329
331
|
### Popover
|
|
330
332
|
|
|
@@ -1066,7 +1068,13 @@ export function ArticleBody() {
|
|
|
1066
1068
|
}
|
|
1067
1069
|
```
|
|
1068
1070
|
|
|
1069
|
-
Use `value`/`onChange` for controlled content or `defaultValue` for local content. Sizes are `sm`, `md` (default), and `lg`; `isDisabled` prevents editing. `toolbarExtra` appends app controls. Unsupported JSON produces an error and remains uneditable until corrected.
|
|
1071
|
+
Use `value`/`onChange` for controlled content or `defaultValue` for local content. Sizes are `sm`, `md` (default), and `lg`; `isDisabled` prevents editing. `toolbarExtra` appends app controls before the expand button. Unsupported JSON produces an error and remains uneditable until corrected.
|
|
1072
|
+
|
|
1073
|
+
Every editor includes Expand editor / Collapse editor controls. The expanded writing view is a headerless `Modal` (`hasHeader={false}`), so it shares Modal's scrim, frame, motion, focus trap, scroll lock and Escape handling. Set `expandedWidth="wide"` (default, Modal's 920px `wide` size) or `expandedWidth="full"` (Modal's `full` size: viewport width with 24px gutters). The existing `size` prop controls inline height. The same mounted TipTap editor, toolbar, `toolbarExtra` controls, selection, undo history and HTML/JSON callbacks remain in use; toggling alone does not emit changes. Both transitions bring the caret into view. Escape, the collapse control or a direct scrim press returns the editor inline. A nested link dialog closes first on Escape. Disabling the editor or loading unsupported content closes expansion and keeps focus in the nearest focusable container around the editor.
|
|
1074
|
+
|
|
1075
|
+
Escape typed in the editor is no longer swallowed: it closes the expanded view, or an enclosing Modal or Drawer when inline. Escape bound by an editor extension, or ending an IME composition, stays with the editor.
|
|
1076
|
+
|
|
1077
|
+
`.ds-rte` remains the outermost element, so `className`, the forwarded ref and grid or flex placement keep working. While expanded, it keeps its height and shows a placeholder; the toolbar and content (`.ds-rte__surface`) move into the Modal (`.ds-rte__modal`) and back without remounting. Style the toolbar and content through `.ds-rte__surface` rather than descendant selectors under `.ds-rte`. Overlays opened from the editor carry its `data-theme`, `lang` and `dir`. Server-rendered editors hydrate inline markup first and move it into the expandable host once, straight after hydration. Expansion is local UI state and is not saved with content.
|
|
1070
1078
|
|
|
1071
1079
|
Links open a URL modal from the toolbar or an existing body link. Saving preserves selected text/formatting; with no selection, the URL becomes linked text. Existing links offer Remove link. The application owns storage and any server-side processing of editor output.
|
|
1072
1080
|
|
|
@@ -1761,7 +1769,7 @@ Set `data-theme` on the document root to `light` (the default), `dark`, `cherry-
|
|
|
1761
1769
|
}
|
|
1762
1770
|
```
|
|
1763
1771
|
|
|
1764
|
-
Theme tokens are included in `styles.css`. Import `@namroodinc/liquid-editorial/tokens.css` when you only need the token system. Keep themes on the document root so body-portaled dialogs and popovers inherit them. Layouts support RTL and reduced-motion preferences where described in their guides.
|
|
1772
|
+
Theme tokens are included in `styles.css`. Import `@namroodinc/liquid-editorial/tokens.css` when you only need the token system. Keep themes on the document root so body-portaled dialogs and popovers inherit them. Overlays opened from inside a component that knows its place on the page carry that place's `data-theme`, `lang` and `dir` as attributes: a Popover takes them from its anchor, and RichTextEditor's expanded view, link dialog and anything opened from them take them from the editor. Other Modals and Drawers inherit from the document root; pass `dir` to Drawer explicitly where needed. Layouts support RTL and reduced-motion preferences where described in their guides.
|
|
1765
1773
|
|
|
1766
1774
|
## Upgrading
|
|
1767
1775
|
|
package/UPGRADING.md
CHANGED
|
@@ -2,6 +2,158 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.5.0
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- FormEditor now wraps every value-bearing `.ds-field` in a shared Container.
|
|
10
|
+
Update direct-child CSS selectors to account for `.ds-form-editor__field`
|
|
11
|
+
between `.ds-form-editor` and `.ds-field`.
|
|
12
|
+
- Omitted field widths default to `"lg"`, capping existing fields at
|
|
13
|
+
`--width-lg` (60rem). Review forms with columns wider than that measure.
|
|
14
|
+
- RichTextEditor's toolbar and content now sit in
|
|
15
|
+
`.ds-rte__slot > .ds-rte__host > .ds-rte__surface` inside `.ds-rte`, and move
|
|
16
|
+
into a Modal (`.ds-rte__modal`) while expanded. Selectors through
|
|
17
|
+
`.ds-rte > div`, or descendant selectors under `.ds-rte`, no longer reach the
|
|
18
|
+
expanded toolbar and content; target `.ds-rte__surface` instead. `.ds-rte`
|
|
19
|
+
stays the outermost element, so `className`, the ref and layout are unchanged.
|
|
20
|
+
- Escape typed in an inline RichTextEditor now reaches an enclosing Drawer and
|
|
21
|
+
closes it, as it already closed an enclosing Modal. Escape bound by an editor
|
|
22
|
+
extension, or ending an IME composition, still stays with the editor.
|
|
23
|
+
|
|
24
|
+
### RichTextEditor expanded writing view
|
|
25
|
+
|
|
26
|
+
Every RichTextEditor, including FormEditor rich-text fields, gains a right-aligned
|
|
27
|
+
Expand editor / Collapse editor button. The writing view is a headerless Modal,
|
|
28
|
+
so it shares Modal's scrim, frame, motion, dialog stack, focus trap, nested
|
|
29
|
+
scroll lock and Escape rules. The inline frame keeps its height and shows a
|
|
30
|
+
placeholder. Escape, the collapse button or a direct scrim press returns the
|
|
31
|
+
editor inline; a nested link dialog handles Escape first. Both transitions bring
|
|
32
|
+
the caret into view. Disabling the editor or loading unsupported content closes
|
|
33
|
+
expansion and keeps focus in the nearest focusable container around the editor.
|
|
34
|
+
|
|
35
|
+
Dialog focus trapping now treats links being edited as document content rather
|
|
36
|
+
than additional native Tab stops. Explicit tab stops and noneditable widget
|
|
37
|
+
links continue to participate normally.
|
|
38
|
+
|
|
39
|
+
#### Adoption and compatibility
|
|
40
|
+
|
|
41
|
+
No opt-in is required. Set `expandedWidth: "wide" | "full"` on a standalone
|
|
42
|
+
RichTextEditor or FormEditor's `richText` schema field. `"wide"` uses Modal's
|
|
43
|
+
920px `wide` size; `"full"` uses Modal's new `full` size, the viewport width with
|
|
44
|
+
24px gutters. Runtime schemas with any other `expandedWidth` now throw
|
|
45
|
+
`Rich text field <id> needs an expandedWidth of wide or full.` Inline height
|
|
46
|
+
still uses standalone `size: "sm" | "md" | "lg"` (`md`); there is no
|
|
47
|
+
`editorSize` alias. `RichTextEditorExpandedWidth` is exported from the root and
|
|
48
|
+
component entry points. `toolbarExtra` remains before the expand control.
|
|
49
|
+
|
|
50
|
+
The same mounted editor, toolbar and `toolbarExtra` controls preserve content,
|
|
51
|
+
selection, undo history and controlled updates, and the forwarded ref keeps one
|
|
52
|
+
`.ds-rte` node. Disabling and re-enabling no longer moves the editor, so its
|
|
53
|
+
scroll position and selection stay put; focus leaves a disabled editor as it
|
|
54
|
+
leaves a native disabled control. Server-rendered editors hydrate their inline
|
|
55
|
+
markup, then move it into the expandable host once. Toggling does not emit
|
|
56
|
+
HTML/JSON changes, and FormEditor stores the same document shape. The writing
|
|
57
|
+
view and link dialog carry the editor's `data-theme`, `lang` and `dir`.
|
|
58
|
+
Expansion is local UI state and does not require a content migration.
|
|
59
|
+
|
|
60
|
+
#### Verification
|
|
61
|
+
|
|
62
|
+
Typecheck new options and review selectors listed under breaking changes. Check
|
|
63
|
+
typing, formatting, selection and undo/redo before and after expansion,
|
|
64
|
+
including controlled HTML/JSON. Verify placeholder height, wide/full widths,
|
|
65
|
+
toolbar wrapping, content scrolling and that the caret is visible after each
|
|
66
|
+
transition. Check keyboard focus, Escape and link dialogs, Escape inside an
|
|
67
|
+
enclosing Modal or Drawer, IME input, disabled/error transitions, unmount
|
|
68
|
+
cleanup, scoped themes, language, direction and reduced motion.
|
|
69
|
+
|
|
70
|
+
### Shared dialog behaviour and overlay scope
|
|
71
|
+
|
|
72
|
+
Modal and Drawer now share one internal dialog hook, so their focus, Escape and
|
|
73
|
+
Tab behaviour match:
|
|
74
|
+
|
|
75
|
+
- Modal leaves Escape to a popup inside it (Menu, Select, DateField), as Drawer
|
|
76
|
+
already did. Neither closes on an Escape that ends an IME composition.
|
|
77
|
+
- Opening keeps focus that `autoFocus` or the caller already placed inside the
|
|
78
|
+
panel; otherwise the first control is focused as before.
|
|
79
|
+
- Closing returns focus to the opener only when closing dropped it. When the
|
|
80
|
+
opener can no longer take focus, focus moves to its nearest focusable
|
|
81
|
+
container, such as an enclosing Drawer panel, instead of the page.
|
|
82
|
+
- A direct scrim press no longer moves focus before closing.
|
|
83
|
+
|
|
84
|
+
Modal gains `hasHeader={false}`, which removes the title band and Close button
|
|
85
|
+
while the title still names the dialog, and `size="full"`. Like Drawer, it takes
|
|
86
|
+
its name from `aria-label` or `aria-labelledby` when given. Modal's header
|
|
87
|
+
alignment is unchanged.
|
|
88
|
+
|
|
89
|
+
Popovers carry their anchor's `data-theme`, `lang` and `dir` to their
|
|
90
|
+
body-mounted panel and to overlays opened from it. RichTextEditor does the same
|
|
91
|
+
for its writing view and link dialog. Other Modals and Drawers still inherit
|
|
92
|
+
from the document root, and Drawer's explicit `dir` wins. Modal, Drawer and
|
|
93
|
+
Popover panels now set `color: var(--color-text)` themselves rather than
|
|
94
|
+
inheriting the page's text colour.
|
|
95
|
+
|
|
96
|
+
#### Adoption and compatibility
|
|
97
|
+
|
|
98
|
+
No changes are required. Review Modals that relied on Escape closing them while
|
|
99
|
+
a popup inside was open, and apps whose body text colour differs from
|
|
100
|
+
`--color-text` inside dialogs, drawers or popovers.
|
|
101
|
+
|
|
102
|
+
#### Verification
|
|
103
|
+
|
|
104
|
+
Open and close Modals and Drawers with keyboard and pointer, including nested
|
|
105
|
+
pickers and popups, `autoFocus` fields and openers that become disabled. Check
|
|
106
|
+
Escape with an IME. Check popovers inside a scoped `data-theme`, `lang` or `dir`
|
|
107
|
+
region, and dialog text colour in each theme.
|
|
108
|
+
|
|
109
|
+
### FormEditor field widths
|
|
110
|
+
|
|
111
|
+
Every value-bearing schema field accepts an optional `width: "sm" | "md" | "lg"`.
|
|
112
|
+
FormEditor wraps the whole Field (label, control, hint and error) in Container
|
|
113
|
+
with `padded={false}`, `center={false}` and the field's width. Container owns
|
|
114
|
+
the `"lg"` default and the shared measures: `--width-sm` (30rem), `--width-md`
|
|
115
|
+
(40rem) and `--width-lg` (60rem). Fields shrink to a narrower grid column and
|
|
116
|
+
sit at the start of a wider one. Dividers keep spanning all columns.
|
|
117
|
+
Stored values, validation results and standalone Field props are unchanged.
|
|
118
|
+
|
|
119
|
+
#### Adoption
|
|
120
|
+
|
|
121
|
+
Set `width: "sm"` or `width: "md"` on fields that need a narrower measure;
|
|
122
|
+
omit it or use `"lg"` for the default. Adjust any direct-child selectors as
|
|
123
|
+
described above. Read the packaged FormEditor reference for examples and the
|
|
124
|
+
layout contract.
|
|
125
|
+
|
|
126
|
+
#### Compatibility
|
|
127
|
+
|
|
128
|
+
FormEditor disables size containment and the container name on its field
|
|
129
|
+
wrappers, without changing standalone Container. Forms in popovers, flex rows
|
|
130
|
+
or `auto` tracks keep their content width, picker drag overlays stay aligned
|
|
131
|
+
with the pointer, and container queries
|
|
132
|
+
inside fields resolve against the same ancestor as before. Schemas loaded at
|
|
133
|
+
runtime now fail fast if `width` is anything other than `"sm"`, `"md"` or
|
|
134
|
+
`"lg"`: FormEditor and `validateFormValues` throw
|
|
135
|
+
`Field <id> needs a width of sm, md or lg.`
|
|
136
|
+
|
|
137
|
+
#### Verification
|
|
138
|
+
|
|
139
|
+
Typecheck the consuming project with any new `width` options. Check explicit and
|
|
140
|
+
default widths in wide and narrow forms, multi-column layouts, modals, drawers
|
|
141
|
+
and any content-sized slot such as a popover. Confirm labels, hints, errors and
|
|
142
|
+
grouped controls stay together, dividers span the form, fields do not overflow,
|
|
143
|
+
and reordering a multiple asset or reference picker keeps the dragged row under
|
|
144
|
+
the pointer. Verify editing and clearing still preserve the expected values and
|
|
145
|
+
accessibility bindings.
|
|
146
|
+
|
|
147
|
+
## 0.4.1
|
|
148
|
+
|
|
149
|
+
### FormEditor number affixes
|
|
150
|
+
|
|
151
|
+
Number schema fields accept optional string `prefix` and `suffix`, forwarded to
|
|
152
|
+
the existing NumberField affixes. Values remain finite numbers; affixes are
|
|
153
|
+
presentation only. Existing schemas need no changes. Verify typing, clearing,
|
|
154
|
+
steppers, disabled controls and accessible labels in consuming forms.
|
|
155
|
+
|
|
156
|
+
|
|
5
157
|
## 0.4.0
|
|
6
158
|
|
|
7
159
|
### Breaking changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./Icon-
|
|
2
|
-
//# sourceMappingURL=Board-
|
|
1
|
+
const e=require("./Icon-D38lQXNe.cjs"),t=require("../components/Button/index.cjs"),n=require("./mergeRefs-Bc3qS0Tt.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("@dnd-kit/core"),o=require("@dnd-kit/sortable"),s=require("@dnd-kit/utilities");function c({active:e,over:t},n){if(!t)return;let r=t.data.current??{},i=r.type===`column`?String(t.id):String(r.columnId??``),a=n.indexOf(i);if(!(a<0||i===String(e.id)))return{columnId:String(e.id),toIndex:a}}function l({active:e,over:t}){if(!t)return;let n=String(e.data.current?.columnId??``),r=t.data.current??{},i=r.type===`card`,a=String(r.columnId??(i?``:t.id)),o=i?r.sortable?.index??0:(r.items??[]).length;if(a&&(n!==a||String(e.id)!==String(t.id)))return{cardId:String(e.id),fromColumnId:n,toColumnId:a,toIndex:o}}var u=(e,t)=>{let{currentCoordinates:n,context:r}=t;if(e.code===`ArrowLeft`||e.code===`ArrowRight`){let t=r.droppableContainers.getEnabled().filter(e=>e.data.current?.type===`column-body`).sort((e,t)=>(e.rect.current?.left??0)-(t.rect.current?.left??0)),i=r.active?.rect.current.translated;if(!i)return;let a=t[t.findIndex(e=>(e.rect.current?.left??0)<=i.left+1&&(e.rect.current?.right??0)>=i.left-1)+(e.code===`ArrowRight`?1:-1)]?.rect.current;return a?(e.preventDefault(),{x:a.left+a.width/2-i.width/2,y:n.y}):void 0}return(0,o.sortableKeyboardCoordinates)(e,t)},d=e=>{let t=e.active.data.current?.type===`column`,n=e.droppableContainers.filter(e=>{let n=e.data.current?.type;return t?n===`column`:n!==`column`}),r={...e,droppableContainers:n};if(t)return(0,a.closestCorners)(r);let i=(0,a.pointerWithin)(r);if(i.length>0){let e=e=>n.find(t=>t.id===e)?.data.current?.type===`card`?0:1;return[...i].sort((t,n)=>e(t.id)-e(n.id))}return(0,a.closestCorners)(r)},f=(0,r.createContext)({activeId:null,activeType:null,overColumnId:null}),p=(0,r.forwardRef)(function({columnIds:t,onMove:n,onColumnMove:s,renderDragOverlay:p,renderColumnDragOverlay:m,className:h,children:g,..._},v){let y=(0,r.useId)(),[b,x]=(0,r.useState)(null),[S,C]=(0,r.useState)(null),[w,T]=(0,r.useState)(null),E=(0,a.useSensors)((0,a.useSensor)(a.PointerSensor,{activationConstraint:{distance:4}}),(0,a.useSensor)(a.KeyboardSensor,{coordinateGetter:u})),D=(0,r.useCallback)(e=>{x(String(e.active.id)),C(e.active.data.current?.type===`column`?`column`:`card`)},[]),O=(0,r.useCallback)(e=>{let t=e.over;if(!t){T(null);return}let n=t.data.current??{},r=n.type===`column`?String(t.id):String(n.columnId??``);T(r||null)},[]),k=(0,r.useCallback)(()=>{x(null),C(null),T(null)},[]),A=(0,r.useCallback)(e=>{let{active:r,over:i}=e;if(k(),i){if(r.data.current?.type===`column`){let n=c(e,t??[]);n&&s?.(n)}else{let t=l(e);t&&n?.(t)}}},[t,s,n,k]),j=(0,r.useMemo)(()=>({activeId:b,activeType:S,overColumnId:w}),[b,S,w]),M=(0,i.jsx)(`div`,{ref:v,className:[`ds-board`,h].filter(Boolean).join(` `),..._,children:g});return(0,i.jsx)(f.Provider,{value:j,children:(0,i.jsxs)(a.DndContext,{id:`ds-board-${y}`,sensors:E,collisionDetection:d,measuring:{droppable:{strategy:a.MeasuringStrategy.Always}},onDragStart:D,onDragOver:O,onDragEnd:A,onDragCancel:k,children:[t?(0,i.jsx)(o.SortableContext,{items:t,strategy:o.horizontalListSortingStrategy,children:M}):M,(0,i.jsxs)(a.DragOverlay,{children:[b&&S===`card`?(0,i.jsxs)(`div`,{className:`ds-board-card`,"data-overlay":!0,children:[(0,i.jsx)(`span`,{className:`ds-board-card__handle`,"aria-hidden":`true`,children:(0,i.jsx)(e.t,{name:`grip-vertical`})}),(0,i.jsx)(`div`,{className:`ds-board-card__content`,children:p?.(b)})]}):null,b&&S===`column`?(0,i.jsx)(`div`,{className:`ds-board-column`,"data-overlay":!0,children:m?.(b)}):null]})]})})}),m=(0,r.forwardRef)(function({id:e,title:c,itemIds:l,count:u,action:d,isDraggable:p=!0,className:m,children:h,...g},_){let{activeType:v,overColumnId:y}=(0,r.useContext)(f),{setNodeRef:b}=(0,a.useDroppable)({id:`${e}::body`,data:{type:`column-body`,columnId:e,items:l}}),{attributes:x,listeners:S,setNodeRef:C,transform:w,transition:T,isDragging:E}=(0,o.useSortable)({id:e,disabled:!p,data:{type:`column`,columnId:e,items:l}});return(0,i.jsxs)(`section`,{ref:n.t(C,_),style:{transform:s.CSS.Translate.toString(w),transition:T},className:[`ds-board-column`,m].filter(Boolean).join(` `),"data-over":v===`card`&&y===e||void 0,"data-dragging":E||void 0,"aria-label":c,...g,children:[p&&(0,i.jsx)(t.Button,{variant:`simple`,size:`sm`,iconStart:`grip-horizontal`,className:`ds-board-column__grip`,"aria-label":`Reorder ${c}`,...x,...S}),(0,i.jsxs)(`header`,{className:`ds-board-column__head`,children:[(0,i.jsx)(`span`,{className:`ds-board-column__title`,children:c}),(0,i.jsx)(`span`,{className:`ds-board-column__count`,children:u??l.length}),d&&(0,i.jsx)(`span`,{className:`ds-board-column__action`,children:d})]}),(0,i.jsx)(`div`,{ref:b,className:`ds-board-column__body`,children:(0,i.jsx)(o.SortableContext,{items:l,strategy:o.verticalListSortingStrategy,children:h})})]})}),h=(0,r.forwardRef)(function({id:e,columnId:a,label:c,className:l,children:u,...d},p){let{attributes:m,listeners:h,setNodeRef:g,transform:_,transition:v,isDragging:y}=(0,o.useSortable)({id:e,data:{type:`card`,columnId:a}}),{activeId:b}=(0,r.useContext)(f);return(0,i.jsxs)(`div`,{ref:n.t(g,p),style:{transform:s.CSS.Translate.toString(_),transition:v},className:[`ds-board-card`,l].filter(Boolean).join(` `),"data-dragging":y||void 0,"data-idle":b&&b!==e?``:void 0,...d,children:[(0,i.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`grip-vertical`,className:`ds-board-card__handle`,"aria-label":c?`Move ${c}`:`Move card`,...m,...h}),(0,i.jsx)(`div`,{className:`ds-board-card__content`,children:u})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
|
|
2
|
+
//# sourceMappingURL=Board-BPA6mVhf.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Board-BaQ04nWg.cjs","names":["sortableKeyboardCoordinates","closestCorners","pointerWithin","createContext","forwardRef","useId","useState","useSensors","useSensor","PointerSensor","KeyboardSensor","useCallback","useMemo","DndContext","MeasuringStrategy","SortableContext","horizontalListSortingStrategy","DragOverlay","Icon","useContext","useDroppable","useSortable","mergeRefs","CSS","Button","verticalListSortingStrategy","require_Icon","require_components_Button_index","require_mergeRefs","react","react_jsx_runtime","_dnd_kit_core","_dnd_kit_sortable","_dnd_kit_utilities","columnMove","over","data","columnId","\"type\"","\"columnId\"","toIndex","columnIds","active","cardMove","fromColumnId","onCard","toColumnId","\"sortable\"","\"items\"","boardCoordinateGetter","args","event","containers","context","c","a","b","activeRect","rect","currentCoordinates","boardCollisionDetection","isColumn","type","container","scoped","within","rank","id","BoardContext","Board","rest","dndId","activeId","setActiveId","activeType","setActiveType","overColumnId","setOverColumnId","sensors","handleStart","handleOver","overData","reset","handleEnd","move","onColumnMove","onMove","value","board","className","renderDragOverlay","renderColumnDragOverlay","BoardColumn","setBodyRef","itemIds","setColumnRef","isDraggable","ref","transform","isDragging","title","attributes","listeners","count","action","BoardCard","setNodeRef","label"],"sources":["../../src/components/Board/moves.ts","../../src/components/Board/keyboard.ts","../../src/components/Board/index.tsx"],"sourcesContent":["import type { DragEndEvent } from \"@dnd-kit/core\";\nimport type { BoardColumnMove, BoardMove } from \".\";\n\nexport function columnMove(\n { active, over }: DragEndEvent,\n columnIds: string[],\n): BoardColumnMove | undefined {\n if (!over) {\n return;\n }\n const data = over.data.current ?? {};\n const columnId = data[\"type\"] === \"column\" ? String(over.id) : String(data[\"columnId\"] ?? \"\");\n const toIndex = columnIds.indexOf(columnId);\n if (toIndex < 0 || columnId === String(active.id)) {\n return;\n }\n return { columnId: String(active.id), toIndex };\n}\n\nexport function cardMove({ active, over }: DragEndEvent): BoardMove | undefined {\n if (!over) {\n return;\n }\n const fromColumnId = String(active.data.current?.[\"columnId\"] ?? \"\");\n const data = over.data.current ?? {};\n const onCard = data[\"type\"] === \"card\";\n const toColumnId = String(data[\"columnId\"] ?? (onCard ? \"\" : over.id));\n // A card occupies a precise slot; empty lane space appends to the lane.\n const toIndex = onCard\n ? ((data[\"sortable\"] as { index: number } | undefined)?.index ?? 0)\n : ((data[\"items\"] as string[] | undefined) ?? []).length;\n if (!toColumnId) {\n return;\n }\n if (fromColumnId === toColumnId && String(active.id) === String(over.id)) {\n return;\n }\n return { cardId: String(active.id), fromColumnId, toColumnId, toIndex };\n}\n","import type { KeyboardCoordinateGetter } from \"@dnd-kit/core\";\nimport { sortableKeyboardCoordinates } from \"@dnd-kit/sortable\";\n\n/**\n * Arrow up/down sorts inside a lane; left/right jumps lanes, which the stock\n * sortable getter does not do.\n */\nexport const boardCoordinateGetter: KeyboardCoordinateGetter = (event, args) => {\n const { currentCoordinates, context } = args;\n if (event.code === \"ArrowLeft\" || event.code === \"ArrowRight\") {\n const containers = context.droppableContainers\n .getEnabled()\n .filter((c) => c.data.current?.[\"type\"] === \"column-body\")\n .sort((a, b) => (a.rect.current?.left ?? 0) - (b.rect.current?.left ?? 0));\n const activeRect = context.active?.rect.current.translated;\n if (!activeRect) {\n return undefined;\n }\n const index = containers.findIndex(\n (c) =>\n (c.rect.current?.left ?? 0) <= activeRect.left + 1 &&\n (c.rect.current?.right ?? 0) >= activeRect.left - 1,\n );\n const next = containers[index + (event.code === \"ArrowRight\" ? 1 : -1)];\n const rect = next?.rect.current;\n if (!rect) {\n return undefined;\n }\n event.preventDefault();\n return { x: rect.left + rect.width / 2 - activeRect.width / 2, y: currentCoordinates.y };\n }\n return sortableKeyboardCoordinates(event, args);\n};\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n closestCorners,\n pointerWithin,\n MeasuringStrategy,\n useDroppable,\n useSensor,\n useSensors,\n type CollisionDetection,\n type DragEndEvent,\n type DragOverEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport {\n SortableContext,\n horizontalListSortingStrategy,\n useSortable,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { cardMove, columnMove } from \"./moves\";\nimport { boardCoordinateGetter } from \"./keyboard\";\nimport \"./style.css\";\n\nexport interface BoardMove {\n cardId: string;\n fromColumnId: string;\n toColumnId: string;\n /** Index the card lands on inside the destination column. */\n toIndex: number;\n}\n\nexport interface BoardColumnMove {\n columnId: string;\n toIndex: number;\n}\n\ninterface BoardContextValue {\n activeId: string | null;\n activeType: \"card\" | \"column\" | null;\n /** The lane the pointer is currently over, whatever it is actually over. */\n overColumnId: string | null;\n}\n\n/**\n * A lane's body sits inside the lane's frame, so a raw corner-distance\n * strategy lets the body steal the hit from the lane itself — most visibly at\n * the board ends, where the last lane then never shifts aside to open the\n * drop gap. Resolve by what is being dragged: a column only ever hits other\n * columns; a card hits the card under the pointer first, then the lane body\n * under it, then whatever is nearest.\n */\nconst boardCollisionDetection: CollisionDetection = (args) => {\n const isColumn = args.active.data.current?.[\"type\"] === \"column\";\n const containers = args.droppableContainers.filter((container) => {\n const type = container.data.current?.[\"type\"];\n return isColumn ? type === \"column\" : type !== \"column\";\n });\n const scoped = { ...args, droppableContainers: containers };\n if (isColumn) {\n return closestCorners(scoped);\n }\n const within = pointerWithin(scoped);\n if (within.length > 0) {\n const rank = (id: (typeof within)[number][\"id\"]) =>\n containers.find((c) => c.id === id)?.data.current?.[\"type\"] === \"card\" ? 0 : 1;\n return [...within].sort((a, b) => rank(a.id) - rank(b.id));\n }\n return closestCorners(scoped);\n};\n\nconst BoardContext = createContext<BoardContextValue>({\n activeId: null,\n activeType: null,\n overColumnId: null,\n});\n\nexport interface BoardProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onDragEnd\"> {\n /** Column ids in render order. Required for columns to be re-orderable. */\n columnIds?: string[];\n /** Fired once a card is dropped somewhere new. Apply it to your own state. */\n onMove?: (move: BoardMove) => void;\n /** Fired once a column is dropped in a new position. */\n onColumnMove?: (move: BoardColumnMove) => void;\n /** Rendered inside the drag overlay while a card is in the air. */\n renderDragOverlay?: (cardId: string) => ReactNode;\n /** Rendered inside the drag overlay while a column is in the air. */\n renderColumnDragOverlay?: (columnId: string) => ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A column board with pointer and keyboard dragging. The board owns the drag\n * mechanics only — the card data stays yours; react to `onMove`.\n */\nexport const Board = forwardRef<HTMLDivElement, BoardProps>(function Board(\n {\n columnIds,\n onMove,\n onColumnMove,\n renderDragOverlay,\n renderColumnDragOverlay,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const dndId = useId();\n const [activeId, setActiveId] = useState<string | null>(null);\n const [activeType, setActiveType] = useState<\"card\" | \"column\" | null>(null);\n const [overColumnId, setOverColumnId] = useState<string | null>(null);\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),\n useSensor(KeyboardSensor, { coordinateGetter: boardCoordinateGetter }),\n );\n\n const handleStart = useCallback((event: DragStartEvent) => {\n setActiveId(String(event.active.id));\n setActiveType(event.active.data.current?.[\"type\"] === \"column\" ? \"column\" : \"card\");\n }, []);\n\n /* Cards land on cards as often as on empty space, so the lane a drag is over\n * is always resolved back to a column id — one highlight, one meaning. */\n const handleOver = useCallback((event: DragOverEvent) => {\n const over = event.over;\n if (!over) {\n setOverColumnId(null);\n return;\n }\n const overData = over.data.current ?? {};\n const columnId =\n overData[\"type\"] === \"column\" ? String(over.id) : String(overData[\"columnId\"] ?? \"\");\n setOverColumnId(columnId || null);\n }, []);\n\n const reset = useCallback(() => {\n setActiveId(null);\n setActiveType(null);\n setOverColumnId(null);\n }, []);\n\n const handleEnd = useCallback(\n (event: DragEndEvent) => {\n const { active, over } = event;\n reset();\n if (!over) {\n return;\n }\n\n /* Columns reorder among themselves; a column never lands inside a lane. */\n if (active.data.current?.[\"type\"] === \"column\") {\n const move = columnMove(event, columnIds ?? []);\n if (move) {\n onColumnMove?.(move);\n }\n } else {\n const move = cardMove(event);\n if (move) {\n onMove?.(move);\n }\n }\n },\n [columnIds, onColumnMove, onMove, reset],\n );\n\n const value = useMemo(\n () => ({ activeId, activeType, overColumnId }),\n [activeId, activeType, overColumnId],\n );\n\n const board = (\n <div\n ref={ref}\n className={[\"ds-board\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {children}\n </div>\n );\n\n return (\n <BoardContext.Provider value={value}>\n <DndContext\n id={`ds-board-${dndId}`}\n sensors={sensors}\n collisionDetection={boardCollisionDetection}\n /* Lanes scroll and change height mid-drag, so positions are re-read\n * continuously — without this the shift animation misfires. */\n measuring={{ droppable: { strategy: MeasuringStrategy.Always } }}\n\n onDragStart={handleStart}\n onDragOver={handleOver}\n onDragEnd={handleEnd}\n onDragCancel={reset}\n >\n {columnIds ? (\n <SortableContext\n items={columnIds}\n strategy={horizontalListSortingStrategy}\n >\n {board}\n </SortableContext>\n ) : (\n board\n )}\n <DragOverlay>\n {activeId && activeType === \"card\" ? (\n <div\n className=\"ds-board-card\"\n data-overlay\n >\n <span\n className=\"ds-board-card__handle\"\n aria-hidden=\"true\"\n >\n <Icon name=\"grip-vertical\" />\n </span>\n <div className=\"ds-board-card__content\">{renderDragOverlay?.(activeId)}</div>\n </div>\n ) : null}\n {activeId && activeType === \"column\" ? (\n <div\n className=\"ds-board-column\"\n data-overlay\n >\n {renderColumnDragOverlay?.(activeId)}\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n </BoardContext.Provider>\n );\n});\n\nexport interface BoardColumnProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n title: string;\n /** Card ids in render order — the sortable contract for this column. */\n itemIds: string[];\n /** Shown beside the title; defaults to the number of cards. */\n count?: number;\n /** A control in the column head, e.g. an add button or a menu. */\n action?: ReactNode;\n /** Set false to pin a lane in place. */\n isDraggable?: boolean;\n children?: ReactNode;\n}\n\n/**\n * One lane of the board. Heavy frame, hairline head rule, scrolling body, and\n * a grip on top of the head that drags the whole lane sideways.\n */\nexport const BoardColumn = forwardRef<HTMLElement, BoardColumnProps>(function BoardColumn(\n { id, title, itemIds, count, action, isDraggable = true, className, children, ...rest },\n ref,\n) {\n const { activeType, overColumnId } = useContext(BoardContext);\n const { setNodeRef: setBodyRef } = useDroppable({\n id: `${id}::body`,\n data: { type: \"column-body\", columnId: id, items: itemIds },\n });\n const {\n attributes,\n listeners,\n setNodeRef: setColumnRef,\n transform,\n transition,\n isDragging,\n } = useSortable({\n id,\n disabled: !isDraggable,\n data: { type: \"column\", columnId: id, items: itemIds },\n });\n\n return (\n <section\n ref={mergeRefs(setColumnRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-column\", className].filter(Boolean).join(\" \")}\n data-over={(activeType === \"card\" && overColumnId === id) || undefined}\n data-dragging={isDragging || undefined}\n\n aria-label={title}\n {...rest}\n >\n {isDraggable && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"grip-horizontal\"\n className=\"ds-board-column__grip\"\n aria-label={`Reorder ${title}`}\n {...attributes}\n {...listeners}\n />\n )}\n <header className=\"ds-board-column__head\">\n <span className=\"ds-board-column__title\">{title}</span>\n <span className=\"ds-board-column__count\">{count ?? itemIds.length}</span>\n {action && <span className=\"ds-board-column__action\">{action}</span>}\n </header>\n <div\n ref={setBodyRef}\n className=\"ds-board-column__body\"\n >\n <SortableContext\n items={itemIds}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </div>\n </section>\n );\n});\n\nexport interface BoardCardProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n columnId: string;\n /** Accessible name announced when the card is picked up. */\n label?: string;\n children?: ReactNode;\n}\n\n/**\n * A draggable card. The grip on the left is the handle, so the card body can\n * hold links and buttons; the grip is a real button for keyboard users:\n * space to pick up, arrows to move, space to drop.\n */\nexport const BoardCard = forwardRef<HTMLDivElement, BoardCardProps>(function BoardCard(\n { id, columnId, label, className, children, ...rest },\n ref,\n) {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n data: { type: \"card\", columnId },\n });\n const { activeId } = useContext(BoardContext);\n\n return (\n <div\n ref={mergeRefs(setNodeRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-card\", className].filter(Boolean).join(\" \")}\n data-dragging={isDragging || undefined}\n data-idle={activeId && activeId !== id ? \"\" : undefined}\n {...rest}\n >\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"grip-vertical\"\n className=\"ds-board-card__handle\"\n aria-label={label ? `Move ${label}` : \"Move card\"}\n {...attributes}\n {...listeners}\n />\n <div className=\"ds-board-card__content\">{children}</div>\n </div>\n );\n});\n"],"mappings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GAC7B,YAAW3B,GAAYA,IAAaL,EAAK,GAAK,IAAA,GAC9C,GAAIG,EANN,SAAA,EAQE,EAAAxC,EAAA,IAAA,CAACN,EAAAA,OAAD,CACE,QAAQ,SACR,KAAK,KACL,WAAA,GACA,UAAU,gBACV,UAAU,wBACV,aAAYmF,EAAQ,QAAQA,IAAU,YACtC,GAAIN,EACJ,GAAIC,CACL,CAAA,GACD,EAAAxE,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,yBAA0B,UAAc,CAAA,CACpD,C,EAET,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"Board-BPA6mVhf.cjs","names":["sortableKeyboardCoordinates","closestCorners","pointerWithin","createContext","forwardRef","useId","useState","useSensors","useSensor","PointerSensor","KeyboardSensor","useCallback","useMemo","DndContext","MeasuringStrategy","SortableContext","horizontalListSortingStrategy","DragOverlay","Icon","useContext","useDroppable","useSortable","mergeRefs","CSS","Button","verticalListSortingStrategy","require_Icon","require_components_Button_index","require_mergeRefs","react","react_jsx_runtime","_dnd_kit_core","_dnd_kit_sortable","_dnd_kit_utilities","columnMove","over","data","columnId","\"type\"","\"columnId\"","toIndex","columnIds","active","cardMove","fromColumnId","onCard","toColumnId","\"sortable\"","\"items\"","boardCoordinateGetter","args","event","containers","context","c","a","b","activeRect","rect","currentCoordinates","boardCollisionDetection","isColumn","type","container","scoped","within","rank","id","BoardContext","Board","rest","dndId","activeId","setActiveId","activeType","setActiveType","overColumnId","setOverColumnId","sensors","handleStart","handleOver","overData","reset","handleEnd","move","onColumnMove","onMove","value","board","className","renderDragOverlay","renderColumnDragOverlay","BoardColumn","setBodyRef","itemIds","setColumnRef","isDraggable","ref","transform","isDragging","title","attributes","listeners","count","action","BoardCard","setNodeRef","label"],"sources":["../../src/components/Board/moves.ts","../../src/components/Board/keyboard.ts","../../src/components/Board/index.tsx"],"sourcesContent":["import type { DragEndEvent } from \"@dnd-kit/core\";\nimport type { BoardColumnMove, BoardMove } from \".\";\n\nexport function columnMove(\n { active, over }: DragEndEvent,\n columnIds: string[],\n): BoardColumnMove | undefined {\n if (!over) {\n return;\n }\n const data = over.data.current ?? {};\n const columnId = data[\"type\"] === \"column\" ? String(over.id) : String(data[\"columnId\"] ?? \"\");\n const toIndex = columnIds.indexOf(columnId);\n if (toIndex < 0 || columnId === String(active.id)) {\n return;\n }\n return { columnId: String(active.id), toIndex };\n}\n\nexport function cardMove({ active, over }: DragEndEvent): BoardMove | undefined {\n if (!over) {\n return;\n }\n const fromColumnId = String(active.data.current?.[\"columnId\"] ?? \"\");\n const data = over.data.current ?? {};\n const onCard = data[\"type\"] === \"card\";\n const toColumnId = String(data[\"columnId\"] ?? (onCard ? \"\" : over.id));\n // A card occupies a precise slot; empty lane space appends to the lane.\n const toIndex = onCard\n ? ((data[\"sortable\"] as { index: number } | undefined)?.index ?? 0)\n : ((data[\"items\"] as string[] | undefined) ?? []).length;\n if (!toColumnId) {\n return;\n }\n if (fromColumnId === toColumnId && String(active.id) === String(over.id)) {\n return;\n }\n return { cardId: String(active.id), fromColumnId, toColumnId, toIndex };\n}\n","import type { KeyboardCoordinateGetter } from \"@dnd-kit/core\";\nimport { sortableKeyboardCoordinates } from \"@dnd-kit/sortable\";\n\n/**\n * Arrow up/down sorts inside a lane; left/right jumps lanes, which the stock\n * sortable getter does not do.\n */\nexport const boardCoordinateGetter: KeyboardCoordinateGetter = (event, args) => {\n const { currentCoordinates, context } = args;\n if (event.code === \"ArrowLeft\" || event.code === \"ArrowRight\") {\n const containers = context.droppableContainers\n .getEnabled()\n .filter((c) => c.data.current?.[\"type\"] === \"column-body\")\n .sort((a, b) => (a.rect.current?.left ?? 0) - (b.rect.current?.left ?? 0));\n const activeRect = context.active?.rect.current.translated;\n if (!activeRect) {\n return undefined;\n }\n const index = containers.findIndex(\n (c) =>\n (c.rect.current?.left ?? 0) <= activeRect.left + 1 &&\n (c.rect.current?.right ?? 0) >= activeRect.left - 1,\n );\n const next = containers[index + (event.code === \"ArrowRight\" ? 1 : -1)];\n const rect = next?.rect.current;\n if (!rect) {\n return undefined;\n }\n event.preventDefault();\n return { x: rect.left + rect.width / 2 - activeRect.width / 2, y: currentCoordinates.y };\n }\n return sortableKeyboardCoordinates(event, args);\n};\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n closestCorners,\n pointerWithin,\n MeasuringStrategy,\n useDroppable,\n useSensor,\n useSensors,\n type CollisionDetection,\n type DragEndEvent,\n type DragOverEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport {\n SortableContext,\n horizontalListSortingStrategy,\n useSortable,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { cardMove, columnMove } from \"./moves\";\nimport { boardCoordinateGetter } from \"./keyboard\";\nimport \"./style.css\";\n\nexport interface BoardMove {\n cardId: string;\n fromColumnId: string;\n toColumnId: string;\n /** Index the card lands on inside the destination column. */\n toIndex: number;\n}\n\nexport interface BoardColumnMove {\n columnId: string;\n toIndex: number;\n}\n\ninterface BoardContextValue {\n activeId: string | null;\n activeType: \"card\" | \"column\" | null;\n /** The lane the pointer is currently over, whatever it is actually over. */\n overColumnId: string | null;\n}\n\n/**\n * A lane's body sits inside the lane's frame, so a raw corner-distance\n * strategy lets the body steal the hit from the lane itself — most visibly at\n * the board ends, where the last lane then never shifts aside to open the\n * drop gap. Resolve by what is being dragged: a column only ever hits other\n * columns; a card hits the card under the pointer first, then the lane body\n * under it, then whatever is nearest.\n */\nconst boardCollisionDetection: CollisionDetection = (args) => {\n const isColumn = args.active.data.current?.[\"type\"] === \"column\";\n const containers = args.droppableContainers.filter((container) => {\n const type = container.data.current?.[\"type\"];\n return isColumn ? type === \"column\" : type !== \"column\";\n });\n const scoped = { ...args, droppableContainers: containers };\n if (isColumn) {\n return closestCorners(scoped);\n }\n const within = pointerWithin(scoped);\n if (within.length > 0) {\n const rank = (id: (typeof within)[number][\"id\"]) =>\n containers.find((c) => c.id === id)?.data.current?.[\"type\"] === \"card\" ? 0 : 1;\n return [...within].sort((a, b) => rank(a.id) - rank(b.id));\n }\n return closestCorners(scoped);\n};\n\nconst BoardContext = createContext<BoardContextValue>({\n activeId: null,\n activeType: null,\n overColumnId: null,\n});\n\nexport interface BoardProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onDragEnd\"> {\n /** Column ids in render order. Required for columns to be re-orderable. */\n columnIds?: string[];\n /** Fired once a card is dropped somewhere new. Apply it to your own state. */\n onMove?: (move: BoardMove) => void;\n /** Fired once a column is dropped in a new position. */\n onColumnMove?: (move: BoardColumnMove) => void;\n /** Rendered inside the drag overlay while a card is in the air. */\n renderDragOverlay?: (cardId: string) => ReactNode;\n /** Rendered inside the drag overlay while a column is in the air. */\n renderColumnDragOverlay?: (columnId: string) => ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A column board with pointer and keyboard dragging. The board owns the drag\n * mechanics only — the card data stays yours; react to `onMove`.\n */\nexport const Board = forwardRef<HTMLDivElement, BoardProps>(function Board(\n {\n columnIds,\n onMove,\n onColumnMove,\n renderDragOverlay,\n renderColumnDragOverlay,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const dndId = useId();\n const [activeId, setActiveId] = useState<string | null>(null);\n const [activeType, setActiveType] = useState<\"card\" | \"column\" | null>(null);\n const [overColumnId, setOverColumnId] = useState<string | null>(null);\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),\n useSensor(KeyboardSensor, { coordinateGetter: boardCoordinateGetter }),\n );\n\n const handleStart = useCallback((event: DragStartEvent) => {\n setActiveId(String(event.active.id));\n setActiveType(event.active.data.current?.[\"type\"] === \"column\" ? \"column\" : \"card\");\n }, []);\n\n /* Cards land on cards as often as on empty space, so the lane a drag is over\n * is always resolved back to a column id — one highlight, one meaning. */\n const handleOver = useCallback((event: DragOverEvent) => {\n const over = event.over;\n if (!over) {\n setOverColumnId(null);\n return;\n }\n const overData = over.data.current ?? {};\n const columnId =\n overData[\"type\"] === \"column\" ? String(over.id) : String(overData[\"columnId\"] ?? \"\");\n setOverColumnId(columnId || null);\n }, []);\n\n const reset = useCallback(() => {\n setActiveId(null);\n setActiveType(null);\n setOverColumnId(null);\n }, []);\n\n const handleEnd = useCallback(\n (event: DragEndEvent) => {\n const { active, over } = event;\n reset();\n if (!over) {\n return;\n }\n\n /* Columns reorder among themselves; a column never lands inside a lane. */\n if (active.data.current?.[\"type\"] === \"column\") {\n const move = columnMove(event, columnIds ?? []);\n if (move) {\n onColumnMove?.(move);\n }\n } else {\n const move = cardMove(event);\n if (move) {\n onMove?.(move);\n }\n }\n },\n [columnIds, onColumnMove, onMove, reset],\n );\n\n const value = useMemo(\n () => ({ activeId, activeType, overColumnId }),\n [activeId, activeType, overColumnId],\n );\n\n const board = (\n <div\n ref={ref}\n className={[\"ds-board\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {children}\n </div>\n );\n\n return (\n <BoardContext.Provider value={value}>\n <DndContext\n id={`ds-board-${dndId}`}\n sensors={sensors}\n collisionDetection={boardCollisionDetection}\n /* Lanes scroll and change height mid-drag, so positions are re-read\n * continuously — without this the shift animation misfires. */\n measuring={{ droppable: { strategy: MeasuringStrategy.Always } }}\n\n onDragStart={handleStart}\n onDragOver={handleOver}\n onDragEnd={handleEnd}\n onDragCancel={reset}\n >\n {columnIds ? (\n <SortableContext\n items={columnIds}\n strategy={horizontalListSortingStrategy}\n >\n {board}\n </SortableContext>\n ) : (\n board\n )}\n <DragOverlay>\n {activeId && activeType === \"card\" ? (\n <div\n className=\"ds-board-card\"\n data-overlay\n >\n <span\n className=\"ds-board-card__handle\"\n aria-hidden=\"true\"\n >\n <Icon name=\"grip-vertical\" />\n </span>\n <div className=\"ds-board-card__content\">{renderDragOverlay?.(activeId)}</div>\n </div>\n ) : null}\n {activeId && activeType === \"column\" ? (\n <div\n className=\"ds-board-column\"\n data-overlay\n >\n {renderColumnDragOverlay?.(activeId)}\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n </BoardContext.Provider>\n );\n});\n\nexport interface BoardColumnProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n title: string;\n /** Card ids in render order — the sortable contract for this column. */\n itemIds: string[];\n /** Shown beside the title; defaults to the number of cards. */\n count?: number;\n /** A control in the column head, e.g. an add button or a menu. */\n action?: ReactNode;\n /** Set false to pin a lane in place. */\n isDraggable?: boolean;\n children?: ReactNode;\n}\n\n/**\n * One lane of the board. Heavy frame, hairline head rule, scrolling body, and\n * a grip on top of the head that drags the whole lane sideways.\n */\nexport const BoardColumn = forwardRef<HTMLElement, BoardColumnProps>(function BoardColumn(\n { id, title, itemIds, count, action, isDraggable = true, className, children, ...rest },\n ref,\n) {\n const { activeType, overColumnId } = useContext(BoardContext);\n const { setNodeRef: setBodyRef } = useDroppable({\n id: `${id}::body`,\n data: { type: \"column-body\", columnId: id, items: itemIds },\n });\n const {\n attributes,\n listeners,\n setNodeRef: setColumnRef,\n transform,\n transition,\n isDragging,\n } = useSortable({\n id,\n disabled: !isDraggable,\n data: { type: \"column\", columnId: id, items: itemIds },\n });\n\n return (\n <section\n ref={mergeRefs(setColumnRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-column\", className].filter(Boolean).join(\" \")}\n data-over={(activeType === \"card\" && overColumnId === id) || undefined}\n data-dragging={isDragging || undefined}\n\n aria-label={title}\n {...rest}\n >\n {isDraggable && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"grip-horizontal\"\n className=\"ds-board-column__grip\"\n aria-label={`Reorder ${title}`}\n {...attributes}\n {...listeners}\n />\n )}\n <header className=\"ds-board-column__head\">\n <span className=\"ds-board-column__title\">{title}</span>\n <span className=\"ds-board-column__count\">{count ?? itemIds.length}</span>\n {action && <span className=\"ds-board-column__action\">{action}</span>}\n </header>\n <div\n ref={setBodyRef}\n className=\"ds-board-column__body\"\n >\n <SortableContext\n items={itemIds}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </div>\n </section>\n );\n});\n\nexport interface BoardCardProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n columnId: string;\n /** Accessible name announced when the card is picked up. */\n label?: string;\n children?: ReactNode;\n}\n\n/**\n * A draggable card. The grip on the left is the handle, so the card body can\n * hold links and buttons; the grip is a real button for keyboard users:\n * space to pick up, arrows to move, space to drop.\n */\nexport const BoardCard = forwardRef<HTMLDivElement, BoardCardProps>(function BoardCard(\n { id, columnId, label, className, children, ...rest },\n ref,\n) {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n data: { type: \"card\", columnId },\n });\n const { activeId } = useContext(BoardContext);\n\n return (\n <div\n ref={mergeRefs(setNodeRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-card\", className].filter(Boolean).join(\" \")}\n data-dragging={isDragging || undefined}\n data-idle={activeId && activeId !== id ? \"\" : undefined}\n {...rest}\n >\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"grip-vertical\"\n className=\"ds-board-card__handle\"\n aria-label={label ? `Move ${label}` : \"Move card\"}\n {...attributes}\n {...listeners}\n />\n <div className=\"ds-board-card__content\">{children}</div>\n </div>\n );\n});\n"],"mappings":"A,yQAGA,SAAgBkC,EACd,CAAE,SAAQ,QACV,EAC6B,CAC7B,GAAI,CAACC,EACH,OAEF,IAAMC,EAAOD,EAAK,KAAK,SAAW,CAAC,EAC7BE,EAAWD,EAAKE,OAAY,SAAW,OAAOH,EAAK,EAAE,EAAI,OAAOC,EAAKG,UAAe,EAAE,EACtFC,EAAUC,EAAU,QAAQJ,CAAQ,EAC1C,GAAI,IAAU,GAAKA,IAAa,OAAOK,EAAO,EAAE,GAGhD,MAAO,CAAE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AAA,CACpD,C,EAET,CAAC,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./Icon-
|
|
1
|
+
import { t as e } from "./Icon-D1kx7-1c.js";
|
|
2
2
|
import { Button as t } from "../components/Button/index.js";
|
|
3
3
|
import { t as n } from "./mergeRefs-DGM402mE.js";
|
|
4
4
|
import { createContext as r, forwardRef as i, useCallback as a, useContext as o, useId as s, useMemo as c, useState as l } from "react";
|
|
@@ -236,4 +236,4 @@ var A = (e, t) => {
|
|
|
236
236
|
//#endregion
|
|
237
237
|
export { F as n, P as r, N as t };
|
|
238
238
|
|
|
239
|
-
//# sourceMappingURL=Board-
|
|
239
|
+
//# sourceMappingURL=Board-CcIF7jS0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Board-CUhF8pTX.js","names":["Icon","mergeRefs","columnMove","over","data","columnId","\"type\"","\"columnId\"","toIndex","columnIds","active","cardMove","fromColumnId","onCard","toColumnId","\"sortable\"","\"items\"","boardCoordinateGetter","args","event","containers","context","c","a","b","activeRect","rect","currentCoordinates","sortableKeyboardCoordinates","boardCollisionDetection","isColumn","type","container","scoped","closestCorners","within","pointerWithin","rank","id","BoardContext","createContext","Board","forwardRef","rest","dndId","useId","activeId","setActiveId","useState","activeType","setActiveType","overColumnId","setOverColumnId","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleStart","useCallback","handleOver","overData","reset","handleEnd","move","onColumnMove","onMove","value","useMemo","board","className","DndContext","MeasuringStrategy","SortableContext","horizontalListSortingStrategy","DragOverlay","renderDragOverlay","renderColumnDragOverlay","BoardColumn","useContext","setBodyRef","useDroppable","itemIds","setColumnRef","useSortable","isDraggable","ref","CSS","transform","isDragging","title","Button","attributes","listeners","count","action","verticalListSortingStrategy","BoardCard","setNodeRef","label"],"sources":["../../src/components/Board/moves.ts","../../src/components/Board/keyboard.ts","../../src/components/Board/index.tsx"],"sourcesContent":["import type { DragEndEvent } from \"@dnd-kit/core\";\nimport type { BoardColumnMove, BoardMove } from \".\";\n\nexport function columnMove(\n { active, over }: DragEndEvent,\n columnIds: string[],\n): BoardColumnMove | undefined {\n if (!over) {\n return;\n }\n const data = over.data.current ?? {};\n const columnId = data[\"type\"] === \"column\" ? String(over.id) : String(data[\"columnId\"] ?? \"\");\n const toIndex = columnIds.indexOf(columnId);\n if (toIndex < 0 || columnId === String(active.id)) {\n return;\n }\n return { columnId: String(active.id), toIndex };\n}\n\nexport function cardMove({ active, over }: DragEndEvent): BoardMove | undefined {\n if (!over) {\n return;\n }\n const fromColumnId = String(active.data.current?.[\"columnId\"] ?? \"\");\n const data = over.data.current ?? {};\n const onCard = data[\"type\"] === \"card\";\n const toColumnId = String(data[\"columnId\"] ?? (onCard ? \"\" : over.id));\n // A card occupies a precise slot; empty lane space appends to the lane.\n const toIndex = onCard\n ? ((data[\"sortable\"] as { index: number } | undefined)?.index ?? 0)\n : ((data[\"items\"] as string[] | undefined) ?? []).length;\n if (!toColumnId) {\n return;\n }\n if (fromColumnId === toColumnId && String(active.id) === String(over.id)) {\n return;\n }\n return { cardId: String(active.id), fromColumnId, toColumnId, toIndex };\n}\n","import type { KeyboardCoordinateGetter } from \"@dnd-kit/core\";\nimport { sortableKeyboardCoordinates } from \"@dnd-kit/sortable\";\n\n/**\n * Arrow up/down sorts inside a lane; left/right jumps lanes, which the stock\n * sortable getter does not do.\n */\nexport const boardCoordinateGetter: KeyboardCoordinateGetter = (event, args) => {\n const { currentCoordinates, context } = args;\n if (event.code === \"ArrowLeft\" || event.code === \"ArrowRight\") {\n const containers = context.droppableContainers\n .getEnabled()\n .filter((c) => c.data.current?.[\"type\"] === \"column-body\")\n .sort((a, b) => (a.rect.current?.left ?? 0) - (b.rect.current?.left ?? 0));\n const activeRect = context.active?.rect.current.translated;\n if (!activeRect) {\n return undefined;\n }\n const index = containers.findIndex(\n (c) =>\n (c.rect.current?.left ?? 0) <= activeRect.left + 1 &&\n (c.rect.current?.right ?? 0) >= activeRect.left - 1,\n );\n const next = containers[index + (event.code === \"ArrowRight\" ? 1 : -1)];\n const rect = next?.rect.current;\n if (!rect) {\n return undefined;\n }\n event.preventDefault();\n return { x: rect.left + rect.width / 2 - activeRect.width / 2, y: currentCoordinates.y };\n }\n return sortableKeyboardCoordinates(event, args);\n};\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n closestCorners,\n pointerWithin,\n MeasuringStrategy,\n useDroppable,\n useSensor,\n useSensors,\n type CollisionDetection,\n type DragEndEvent,\n type DragOverEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport {\n SortableContext,\n horizontalListSortingStrategy,\n useSortable,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { cardMove, columnMove } from \"./moves\";\nimport { boardCoordinateGetter } from \"./keyboard\";\nimport \"./style.css\";\n\nexport interface BoardMove {\n cardId: string;\n fromColumnId: string;\n toColumnId: string;\n /** Index the card lands on inside the destination column. */\n toIndex: number;\n}\n\nexport interface BoardColumnMove {\n columnId: string;\n toIndex: number;\n}\n\ninterface BoardContextValue {\n activeId: string | null;\n activeType: \"card\" | \"column\" | null;\n /** The lane the pointer is currently over, whatever it is actually over. */\n overColumnId: string | null;\n}\n\n/**\n * A lane's body sits inside the lane's frame, so a raw corner-distance\n * strategy lets the body steal the hit from the lane itself — most visibly at\n * the board ends, where the last lane then never shifts aside to open the\n * drop gap. Resolve by what is being dragged: a column only ever hits other\n * columns; a card hits the card under the pointer first, then the lane body\n * under it, then whatever is nearest.\n */\nconst boardCollisionDetection: CollisionDetection = (args) => {\n const isColumn = args.active.data.current?.[\"type\"] === \"column\";\n const containers = args.droppableContainers.filter((container) => {\n const type = container.data.current?.[\"type\"];\n return isColumn ? type === \"column\" : type !== \"column\";\n });\n const scoped = { ...args, droppableContainers: containers };\n if (isColumn) {\n return closestCorners(scoped);\n }\n const within = pointerWithin(scoped);\n if (within.length > 0) {\n const rank = (id: (typeof within)[number][\"id\"]) =>\n containers.find((c) => c.id === id)?.data.current?.[\"type\"] === \"card\" ? 0 : 1;\n return [...within].sort((a, b) => rank(a.id) - rank(b.id));\n }\n return closestCorners(scoped);\n};\n\nconst BoardContext = createContext<BoardContextValue>({\n activeId: null,\n activeType: null,\n overColumnId: null,\n});\n\nexport interface BoardProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onDragEnd\"> {\n /** Column ids in render order. Required for columns to be re-orderable. */\n columnIds?: string[];\n /** Fired once a card is dropped somewhere new. Apply it to your own state. */\n onMove?: (move: BoardMove) => void;\n /** Fired once a column is dropped in a new position. */\n onColumnMove?: (move: BoardColumnMove) => void;\n /** Rendered inside the drag overlay while a card is in the air. */\n renderDragOverlay?: (cardId: string) => ReactNode;\n /** Rendered inside the drag overlay while a column is in the air. */\n renderColumnDragOverlay?: (columnId: string) => ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A column board with pointer and keyboard dragging. The board owns the drag\n * mechanics only — the card data stays yours; react to `onMove`.\n */\nexport const Board = forwardRef<HTMLDivElement, BoardProps>(function Board(\n {\n columnIds,\n onMove,\n onColumnMove,\n renderDragOverlay,\n renderColumnDragOverlay,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const dndId = useId();\n const [activeId, setActiveId] = useState<string | null>(null);\n const [activeType, setActiveType] = useState<\"card\" | \"column\" | null>(null);\n const [overColumnId, setOverColumnId] = useState<string | null>(null);\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),\n useSensor(KeyboardSensor, { coordinateGetter: boardCoordinateGetter }),\n );\n\n const handleStart = useCallback((event: DragStartEvent) => {\n setActiveId(String(event.active.id));\n setActiveType(event.active.data.current?.[\"type\"] === \"column\" ? \"column\" : \"card\");\n }, []);\n\n /* Cards land on cards as often as on empty space, so the lane a drag is over\n * is always resolved back to a column id — one highlight, one meaning. */\n const handleOver = useCallback((event: DragOverEvent) => {\n const over = event.over;\n if (!over) {\n setOverColumnId(null);\n return;\n }\n const overData = over.data.current ?? {};\n const columnId =\n overData[\"type\"] === \"column\" ? String(over.id) : String(overData[\"columnId\"] ?? \"\");\n setOverColumnId(columnId || null);\n }, []);\n\n const reset = useCallback(() => {\n setActiveId(null);\n setActiveType(null);\n setOverColumnId(null);\n }, []);\n\n const handleEnd = useCallback(\n (event: DragEndEvent) => {\n const { active, over } = event;\n reset();\n if (!over) {\n return;\n }\n\n /* Columns reorder among themselves; a column never lands inside a lane. */\n if (active.data.current?.[\"type\"] === \"column\") {\n const move = columnMove(event, columnIds ?? []);\n if (move) {\n onColumnMove?.(move);\n }\n } else {\n const move = cardMove(event);\n if (move) {\n onMove?.(move);\n }\n }\n },\n [columnIds, onColumnMove, onMove, reset],\n );\n\n const value = useMemo(\n () => ({ activeId, activeType, overColumnId }),\n [activeId, activeType, overColumnId],\n );\n\n const board = (\n <div\n ref={ref}\n className={[\"ds-board\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {children}\n </div>\n );\n\n return (\n <BoardContext.Provider value={value}>\n <DndContext\n id={`ds-board-${dndId}`}\n sensors={sensors}\n collisionDetection={boardCollisionDetection}\n /* Lanes scroll and change height mid-drag, so positions are re-read\n * continuously — without this the shift animation misfires. */\n measuring={{ droppable: { strategy: MeasuringStrategy.Always } }}\n\n onDragStart={handleStart}\n onDragOver={handleOver}\n onDragEnd={handleEnd}\n onDragCancel={reset}\n >\n {columnIds ? (\n <SortableContext\n items={columnIds}\n strategy={horizontalListSortingStrategy}\n >\n {board}\n </SortableContext>\n ) : (\n board\n )}\n <DragOverlay>\n {activeId && activeType === \"card\" ? (\n <div\n className=\"ds-board-card\"\n data-overlay\n >\n <span\n className=\"ds-board-card__handle\"\n aria-hidden=\"true\"\n >\n <Icon name=\"grip-vertical\" />\n </span>\n <div className=\"ds-board-card__content\">{renderDragOverlay?.(activeId)}</div>\n </div>\n ) : null}\n {activeId && activeType === \"column\" ? (\n <div\n className=\"ds-board-column\"\n data-overlay\n >\n {renderColumnDragOverlay?.(activeId)}\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n </BoardContext.Provider>\n );\n});\n\nexport interface BoardColumnProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n title: string;\n /** Card ids in render order — the sortable contract for this column. */\n itemIds: string[];\n /** Shown beside the title; defaults to the number of cards. */\n count?: number;\n /** A control in the column head, e.g. an add button or a menu. */\n action?: ReactNode;\n /** Set false to pin a lane in place. */\n isDraggable?: boolean;\n children?: ReactNode;\n}\n\n/**\n * One lane of the board. Heavy frame, hairline head rule, scrolling body, and\n * a grip on top of the head that drags the whole lane sideways.\n */\nexport const BoardColumn = forwardRef<HTMLElement, BoardColumnProps>(function BoardColumn(\n { id, title, itemIds, count, action, isDraggable = true, className, children, ...rest },\n ref,\n) {\n const { activeType, overColumnId } = useContext(BoardContext);\n const { setNodeRef: setBodyRef } = useDroppable({\n id: `${id}::body`,\n data: { type: \"column-body\", columnId: id, items: itemIds },\n });\n const {\n attributes,\n listeners,\n setNodeRef: setColumnRef,\n transform,\n transition,\n isDragging,\n } = useSortable({\n id,\n disabled: !isDraggable,\n data: { type: \"column\", columnId: id, items: itemIds },\n });\n\n return (\n <section\n ref={mergeRefs(setColumnRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-column\", className].filter(Boolean).join(\" \")}\n data-over={(activeType === \"card\" && overColumnId === id) || undefined}\n data-dragging={isDragging || undefined}\n\n aria-label={title}\n {...rest}\n >\n {isDraggable && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"grip-horizontal\"\n className=\"ds-board-column__grip\"\n aria-label={`Reorder ${title}`}\n {...attributes}\n {...listeners}\n />\n )}\n <header className=\"ds-board-column__head\">\n <span className=\"ds-board-column__title\">{title}</span>\n <span className=\"ds-board-column__count\">{count ?? itemIds.length}</span>\n {action && <span className=\"ds-board-column__action\">{action}</span>}\n </header>\n <div\n ref={setBodyRef}\n className=\"ds-board-column__body\"\n >\n <SortableContext\n items={itemIds}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </div>\n </section>\n );\n});\n\nexport interface BoardCardProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n columnId: string;\n /** Accessible name announced when the card is picked up. */\n label?: string;\n children?: ReactNode;\n}\n\n/**\n * A draggable card. The grip on the left is the handle, so the card body can\n * hold links and buttons; the grip is a real button for keyboard users:\n * space to pick up, arrows to move, space to drop.\n */\nexport const BoardCard = forwardRef<HTMLDivElement, BoardCardProps>(function BoardCard(\n { id, columnId, label, className, children, ...rest },\n ref,\n) {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n data: { type: \"card\", columnId },\n });\n const { activeId } = useContext(BoardContext);\n\n return (\n <div\n ref={mergeRefs(setNodeRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-card\", className].filter(Boolean).join(\" \")}\n data-dragging={isDragging || undefined}\n data-idle={activeId && activeId !== id ? \"\" : undefined}\n {...rest}\n >\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"grip-vertical\"\n className=\"ds-board-card__handle\"\n aria-label={label ? `Move ${label}` : \"Move card\"}\n {...attributes}\n {...listeners}\n />\n <div className=\"ds-board-card__content\">{children}</div>\n </div>\n );\n});\n"],"mappings":";;;;;;;;;AAGA,SAAgBE,EACd,EAAE,WAAQ,WACV,GAC6B;CAC7B,IAAI,CAACC,GACH;CAEF,IAAMC,IAAOD,EAAK,KAAK,WAAW,CAAC,GAC7BE,IAAWD,EAAKE,SAAY,WAAW,OAAOH,EAAK,EAAE,IAAI,OAAOC,EAAKG,YAAe,EAAE,GACtFC,IAAUC,EAAU,QAAQJ,CAAQ;CAC1C,IAAI,MAA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AC9C,GAAIK;EANN,UAAA,CAQE,kBAACgD,GAAD;GACE,SAAQ;GACR,MAAK;GACL,YAAA;GACA,WAAU;GACV,WAAU;GACV,cAAYQ,IAAQ,QAAQA,MAAU;GACtC,GAAIP;GACJ,GAAIC;EACL,CAAA,GACD,kBAAC,OAAD;GAAK,WAAU;GAA0B;EAAc,CAAA,CACpD;;AAET,CAAC"}
|
|
1
|
+
{"version":3,"file":"Board-CcIF7jS0.js","names":["Icon","mergeRefs","columnMove","over","data","columnId","\"type\"","\"columnId\"","toIndex","columnIds","active","cardMove","fromColumnId","onCard","toColumnId","\"sortable\"","\"items\"","boardCoordinateGetter","args","event","containers","context","c","a","b","activeRect","rect","currentCoordinates","sortableKeyboardCoordinates","boardCollisionDetection","isColumn","type","container","scoped","closestCorners","within","pointerWithin","rank","id","BoardContext","createContext","Board","forwardRef","rest","dndId","useId","activeId","setActiveId","useState","activeType","setActiveType","overColumnId","setOverColumnId","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleStart","useCallback","handleOver","overData","reset","handleEnd","move","onColumnMove","onMove","value","useMemo","board","className","DndContext","MeasuringStrategy","SortableContext","horizontalListSortingStrategy","DragOverlay","renderDragOverlay","renderColumnDragOverlay","BoardColumn","useContext","setBodyRef","useDroppable","itemIds","setColumnRef","useSortable","isDraggable","ref","CSS","transform","isDragging","title","Button","attributes","listeners","count","action","verticalListSortingStrategy","BoardCard","setNodeRef","label"],"sources":["../../src/components/Board/moves.ts","../../src/components/Board/keyboard.ts","../../src/components/Board/index.tsx"],"sourcesContent":["import type { DragEndEvent } from \"@dnd-kit/core\";\nimport type { BoardColumnMove, BoardMove } from \".\";\n\nexport function columnMove(\n { active, over }: DragEndEvent,\n columnIds: string[],\n): BoardColumnMove | undefined {\n if (!over) {\n return;\n }\n const data = over.data.current ?? {};\n const columnId = data[\"type\"] === \"column\" ? String(over.id) : String(data[\"columnId\"] ?? \"\");\n const toIndex = columnIds.indexOf(columnId);\n if (toIndex < 0 || columnId === String(active.id)) {\n return;\n }\n return { columnId: String(active.id), toIndex };\n}\n\nexport function cardMove({ active, over }: DragEndEvent): BoardMove | undefined {\n if (!over) {\n return;\n }\n const fromColumnId = String(active.data.current?.[\"columnId\"] ?? \"\");\n const data = over.data.current ?? {};\n const onCard = data[\"type\"] === \"card\";\n const toColumnId = String(data[\"columnId\"] ?? (onCard ? \"\" : over.id));\n // A card occupies a precise slot; empty lane space appends to the lane.\n const toIndex = onCard\n ? ((data[\"sortable\"] as { index: number } | undefined)?.index ?? 0)\n : ((data[\"items\"] as string[] | undefined) ?? []).length;\n if (!toColumnId) {\n return;\n }\n if (fromColumnId === toColumnId && String(active.id) === String(over.id)) {\n return;\n }\n return { cardId: String(active.id), fromColumnId, toColumnId, toIndex };\n}\n","import type { KeyboardCoordinateGetter } from \"@dnd-kit/core\";\nimport { sortableKeyboardCoordinates } from \"@dnd-kit/sortable\";\n\n/**\n * Arrow up/down sorts inside a lane; left/right jumps lanes, which the stock\n * sortable getter does not do.\n */\nexport const boardCoordinateGetter: KeyboardCoordinateGetter = (event, args) => {\n const { currentCoordinates, context } = args;\n if (event.code === \"ArrowLeft\" || event.code === \"ArrowRight\") {\n const containers = context.droppableContainers\n .getEnabled()\n .filter((c) => c.data.current?.[\"type\"] === \"column-body\")\n .sort((a, b) => (a.rect.current?.left ?? 0) - (b.rect.current?.left ?? 0));\n const activeRect = context.active?.rect.current.translated;\n if (!activeRect) {\n return undefined;\n }\n const index = containers.findIndex(\n (c) =>\n (c.rect.current?.left ?? 0) <= activeRect.left + 1 &&\n (c.rect.current?.right ?? 0) >= activeRect.left - 1,\n );\n const next = containers[index + (event.code === \"ArrowRight\" ? 1 : -1)];\n const rect = next?.rect.current;\n if (!rect) {\n return undefined;\n }\n event.preventDefault();\n return { x: rect.left + rect.width / 2 - activeRect.width / 2, y: currentCoordinates.y };\n }\n return sortableKeyboardCoordinates(event, args);\n};\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n closestCorners,\n pointerWithin,\n MeasuringStrategy,\n useDroppable,\n useSensor,\n useSensors,\n type CollisionDetection,\n type DragEndEvent,\n type DragOverEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport {\n SortableContext,\n horizontalListSortingStrategy,\n useSortable,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { cardMove, columnMove } from \"./moves\";\nimport { boardCoordinateGetter } from \"./keyboard\";\nimport \"./style.css\";\n\nexport interface BoardMove {\n cardId: string;\n fromColumnId: string;\n toColumnId: string;\n /** Index the card lands on inside the destination column. */\n toIndex: number;\n}\n\nexport interface BoardColumnMove {\n columnId: string;\n toIndex: number;\n}\n\ninterface BoardContextValue {\n activeId: string | null;\n activeType: \"card\" | \"column\" | null;\n /** The lane the pointer is currently over, whatever it is actually over. */\n overColumnId: string | null;\n}\n\n/**\n * A lane's body sits inside the lane's frame, so a raw corner-distance\n * strategy lets the body steal the hit from the lane itself — most visibly at\n * the board ends, where the last lane then never shifts aside to open the\n * drop gap. Resolve by what is being dragged: a column only ever hits other\n * columns; a card hits the card under the pointer first, then the lane body\n * under it, then whatever is nearest.\n */\nconst boardCollisionDetection: CollisionDetection = (args) => {\n const isColumn = args.active.data.current?.[\"type\"] === \"column\";\n const containers = args.droppableContainers.filter((container) => {\n const type = container.data.current?.[\"type\"];\n return isColumn ? type === \"column\" : type !== \"column\";\n });\n const scoped = { ...args, droppableContainers: containers };\n if (isColumn) {\n return closestCorners(scoped);\n }\n const within = pointerWithin(scoped);\n if (within.length > 0) {\n const rank = (id: (typeof within)[number][\"id\"]) =>\n containers.find((c) => c.id === id)?.data.current?.[\"type\"] === \"card\" ? 0 : 1;\n return [...within].sort((a, b) => rank(a.id) - rank(b.id));\n }\n return closestCorners(scoped);\n};\n\nconst BoardContext = createContext<BoardContextValue>({\n activeId: null,\n activeType: null,\n overColumnId: null,\n});\n\nexport interface BoardProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onDragEnd\"> {\n /** Column ids in render order. Required for columns to be re-orderable. */\n columnIds?: string[];\n /** Fired once a card is dropped somewhere new. Apply it to your own state. */\n onMove?: (move: BoardMove) => void;\n /** Fired once a column is dropped in a new position. */\n onColumnMove?: (move: BoardColumnMove) => void;\n /** Rendered inside the drag overlay while a card is in the air. */\n renderDragOverlay?: (cardId: string) => ReactNode;\n /** Rendered inside the drag overlay while a column is in the air. */\n renderColumnDragOverlay?: (columnId: string) => ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A column board with pointer and keyboard dragging. The board owns the drag\n * mechanics only — the card data stays yours; react to `onMove`.\n */\nexport const Board = forwardRef<HTMLDivElement, BoardProps>(function Board(\n {\n columnIds,\n onMove,\n onColumnMove,\n renderDragOverlay,\n renderColumnDragOverlay,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const dndId = useId();\n const [activeId, setActiveId] = useState<string | null>(null);\n const [activeType, setActiveType] = useState<\"card\" | \"column\" | null>(null);\n const [overColumnId, setOverColumnId] = useState<string | null>(null);\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),\n useSensor(KeyboardSensor, { coordinateGetter: boardCoordinateGetter }),\n );\n\n const handleStart = useCallback((event: DragStartEvent) => {\n setActiveId(String(event.active.id));\n setActiveType(event.active.data.current?.[\"type\"] === \"column\" ? \"column\" : \"card\");\n }, []);\n\n /* Cards land on cards as often as on empty space, so the lane a drag is over\n * is always resolved back to a column id — one highlight, one meaning. */\n const handleOver = useCallback((event: DragOverEvent) => {\n const over = event.over;\n if (!over) {\n setOverColumnId(null);\n return;\n }\n const overData = over.data.current ?? {};\n const columnId =\n overData[\"type\"] === \"column\" ? String(over.id) : String(overData[\"columnId\"] ?? \"\");\n setOverColumnId(columnId || null);\n }, []);\n\n const reset = useCallback(() => {\n setActiveId(null);\n setActiveType(null);\n setOverColumnId(null);\n }, []);\n\n const handleEnd = useCallback(\n (event: DragEndEvent) => {\n const { active, over } = event;\n reset();\n if (!over) {\n return;\n }\n\n /* Columns reorder among themselves; a column never lands inside a lane. */\n if (active.data.current?.[\"type\"] === \"column\") {\n const move = columnMove(event, columnIds ?? []);\n if (move) {\n onColumnMove?.(move);\n }\n } else {\n const move = cardMove(event);\n if (move) {\n onMove?.(move);\n }\n }\n },\n [columnIds, onColumnMove, onMove, reset],\n );\n\n const value = useMemo(\n () => ({ activeId, activeType, overColumnId }),\n [activeId, activeType, overColumnId],\n );\n\n const board = (\n <div\n ref={ref}\n className={[\"ds-board\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {children}\n </div>\n );\n\n return (\n <BoardContext.Provider value={value}>\n <DndContext\n id={`ds-board-${dndId}`}\n sensors={sensors}\n collisionDetection={boardCollisionDetection}\n /* Lanes scroll and change height mid-drag, so positions are re-read\n * continuously — without this the shift animation misfires. */\n measuring={{ droppable: { strategy: MeasuringStrategy.Always } }}\n\n onDragStart={handleStart}\n onDragOver={handleOver}\n onDragEnd={handleEnd}\n onDragCancel={reset}\n >\n {columnIds ? (\n <SortableContext\n items={columnIds}\n strategy={horizontalListSortingStrategy}\n >\n {board}\n </SortableContext>\n ) : (\n board\n )}\n <DragOverlay>\n {activeId && activeType === \"card\" ? (\n <div\n className=\"ds-board-card\"\n data-overlay\n >\n <span\n className=\"ds-board-card__handle\"\n aria-hidden=\"true\"\n >\n <Icon name=\"grip-vertical\" />\n </span>\n <div className=\"ds-board-card__content\">{renderDragOverlay?.(activeId)}</div>\n </div>\n ) : null}\n {activeId && activeType === \"column\" ? (\n <div\n className=\"ds-board-column\"\n data-overlay\n >\n {renderColumnDragOverlay?.(activeId)}\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n </BoardContext.Provider>\n );\n});\n\nexport interface BoardColumnProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n title: string;\n /** Card ids in render order — the sortable contract for this column. */\n itemIds: string[];\n /** Shown beside the title; defaults to the number of cards. */\n count?: number;\n /** A control in the column head, e.g. an add button or a menu. */\n action?: ReactNode;\n /** Set false to pin a lane in place. */\n isDraggable?: boolean;\n children?: ReactNode;\n}\n\n/**\n * One lane of the board. Heavy frame, hairline head rule, scrolling body, and\n * a grip on top of the head that drags the whole lane sideways.\n */\nexport const BoardColumn = forwardRef<HTMLElement, BoardColumnProps>(function BoardColumn(\n { id, title, itemIds, count, action, isDraggable = true, className, children, ...rest },\n ref,\n) {\n const { activeType, overColumnId } = useContext(BoardContext);\n const { setNodeRef: setBodyRef } = useDroppable({\n id: `${id}::body`,\n data: { type: \"column-body\", columnId: id, items: itemIds },\n });\n const {\n attributes,\n listeners,\n setNodeRef: setColumnRef,\n transform,\n transition,\n isDragging,\n } = useSortable({\n id,\n disabled: !isDraggable,\n data: { type: \"column\", columnId: id, items: itemIds },\n });\n\n return (\n <section\n ref={mergeRefs(setColumnRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-column\", className].filter(Boolean).join(\" \")}\n data-over={(activeType === \"card\" && overColumnId === id) || undefined}\n data-dragging={isDragging || undefined}\n\n aria-label={title}\n {...rest}\n >\n {isDraggable && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"grip-horizontal\"\n className=\"ds-board-column__grip\"\n aria-label={`Reorder ${title}`}\n {...attributes}\n {...listeners}\n />\n )}\n <header className=\"ds-board-column__head\">\n <span className=\"ds-board-column__title\">{title}</span>\n <span className=\"ds-board-column__count\">{count ?? itemIds.length}</span>\n {action && <span className=\"ds-board-column__action\">{action}</span>}\n </header>\n <div\n ref={setBodyRef}\n className=\"ds-board-column__body\"\n >\n <SortableContext\n items={itemIds}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </div>\n </section>\n );\n});\n\nexport interface BoardCardProps extends HTMLAttributes<HTMLDivElement> {\n id: string;\n columnId: string;\n /** Accessible name announced when the card is picked up. */\n label?: string;\n children?: ReactNode;\n}\n\n/**\n * A draggable card. The grip on the left is the handle, so the card body can\n * hold links and buttons; the grip is a real button for keyboard users:\n * space to pick up, arrows to move, space to drop.\n */\nexport const BoardCard = forwardRef<HTMLDivElement, BoardCardProps>(function BoardCard(\n { id, columnId, label, className, children, ...rest },\n ref,\n) {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n data: { type: \"card\", columnId },\n });\n const { activeId } = useContext(BoardContext);\n\n return (\n <div\n ref={mergeRefs(setNodeRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-board-card\", className].filter(Boolean).join(\" \")}\n data-dragging={isDragging || undefined}\n data-idle={activeId && activeId !== id ? \"\" : undefined}\n {...rest}\n >\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"grip-vertical\"\n className=\"ds-board-card__handle\"\n aria-label={label ? `Move ${label}` : \"Move card\"}\n {...attributes}\n {...listeners}\n />\n <div className=\"ds-board-card__content\">{children}</div>\n </div>\n );\n});\n"],"mappings":";;;;;;;;;AAGA,SAAgBE,EACd,EAAE,WAAQ,WACV,GAC6B;CAC7B,IAAI,CAACC,GACH;CAEF,IAAMC,IAAOD,EAAK,KAAK,WAAW,CAAC,GAC7BE,IAAWD,EAAKE,SAAY,WAAW,OAAOH,EAAK,EAAE,IAAI,OAAOC,EAAKG,YAAe,EAAE,GACtFC,IAAUC,EAAU,QAAQJ,CAAQ;CAC1C,IAAI,MAAU,KAAKA,MAAa,OAAOK,EAAO,EAAE,IAGhD,OAAO;EAAE,UAAU,OAAOA,EAAO,EAAE;EAAG;CAAQ;AAChD;AAEA,SAAgBC,EAAS,EAAE,WAAQ,WAA6C;CAC9E,IAAI,CAACR,GACH;CAEF,IAAMS,IAAe,OAAOF,EAAO,KAAK,SAAUH,YAAe,EAAE,GAC7DH,IAAOD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C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./Icon-BBoWP_Y6.cjs"),l=require("../components/Button/index.cjs"),u=require("./mergeRefs-Bc3qS0Tt.cjs"),d=require("./dialogFocus-B9iqKl3I.cjs"),f=require("../components/TextField/index.cjs"),p=require("../components/FieldAffix/index.cjs"),m=require("../components/Popover/index.cjs"),h=require("./Slider-k8weRl34.cjs");let g=require("react"),_=require("react/jsx-runtime"),v=require("colord"),y=require("colord/plugins/names");y=s(y,1),(0,v.extend)([y.default]);var b={h:0,s:100,v:0,a:1};function x(e){let t=e.trim();if(!t)return null;let n=t.replace(/^#/,``),r=n.length<5?[...n].map(e=>e+e).join(``):n,i=/^(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(n)?(0,v.colord)({r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16),a:r.length===8?parseInt(r.slice(6),16)/255:1}):(0,v.colord)(t);return i.isValid()?i:null}function S(e){return(0,v.colord)(e).toHex().toUpperCase()}function C(e){return x(e)?.toHex().toUpperCase()??``}function w(e,t=b){let n=x(e);if(!n||n.toHex().toUpperCase()===S(t))return t;let{r,g:i,b:a,a:o}=n.rgba,s=Math.max(r,i,a),c=s-Math.min(r,i,a),l=c===0?t.h:s===r?(i-a)/c*60:s===i?((a-r)/c+2)*60:((r-i)/c+4)*60;l<0&&(l+=360);let u={h:l,s:s?c/s*100:0,v:s/255*100,a:o};return{...u,h:u.s===0?t.h:u.h,s:u.v===0?t.s:u.s}}function T(e){let t=e.closest(`[aria-modal='true']`)??document.body,n=d.n(t).filter(e=>!e.closest(`.ds-popover`));(n[n.map(t=>e.contains(t)).lastIndexOf(!0)+1]??n[0])?.focus({preventScroll:!0})}function E(e){return Math.max(0,Math.min(100,e))}function D({colour:e,isDisabled:t,onChange:n}){let r=(0,g.useRef)(null),i=t=>{let r=t.currentTarget.getBoundingClientRect();r.width&&r.height&&n({...e,s:E((t.clientX-r.left)/r.width*100),v:E((1-(t.clientY-r.top)/r.height)*100)})};return(0,_.jsx)(`div`,{className:`ds-colour-panel__square`,role:`slider`,tabIndex:t?-1:0,"aria-label":`Saturation and brightness`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(e.s),"aria-valuetext":`Saturation ${Math.round(e.s)}%, brightness ${Math.round(e.v)}%`,"aria-disabled":t||void 0,onKeyDown:r=>{if(t)return;let i=r.shiftKey?10:1,a={ArrowLeft:{s:E(e.s-i)},ArrowRight:{s:E(e.s+i)},ArrowDown:{v:E(e.v-i)},ArrowUp:{v:E(e.v+i)},Home:{s:0},End:{s:100}}[r.key];a&&(r.preventDefault(),n({...e,...a}))},onPointerDown:e=>{t||e.button!==0||(e.preventDefault(),e.currentTarget.focus(),r.current=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),i(e))},onPointerMove:e=>{!t&&r.current===e.pointerId&&i(e)},onPointerUp:e=>{r.current===e.pointerId&&(r.current=null,e.currentTarget.releasePointerCapture(e.pointerId))},onPointerCancel:()=>{r.current=null},onLostPointerCapture:()=>{r.current=null},children:(0,_.jsx)(`span`,{className:`ds-colour-panel__thumb`,style:{left:`${e.s}%`,top:`${100-e.v}%`}})})}function O({value:e,defaultValue:t=``,onValueChange:n}){let[r,i]=(0,g.useState)(t),a=e??r,[o,s]=(0,g.useState)(()=>({source:a,colour:w(a)})),c=o.colour;return o.source!==a&&(c=w(a,c),s({source:a,colour:c})),{current:a,colour:c,commit:t=>{let r=typeof t==`string`?C(t):S(t);s({source:r,colour:typeof t==`string`?w(t,c):t}),e===void 0&&i(r),n?.(r)}}}function k(e,t){let[n,r]=(0,g.useState)(null);return n&&n.source!==e&&n.text===e&&r({source:e,text:e}),{text:n?.source===e?n.text:t||e,type:(t,n)=>r({source:n?C(t):e,text:t}),discard:()=>r(null)}}function A(){return window.EyeDropper}var j=()=>()=>{},M=[],N=8;function P(e,t,n){let r=t%N,i=r+Math.floor((n-1-r)/N)*N;switch(e){case`Home`:return 0;case`End`:return n-1;case`ArrowRight`:return(t+1)%n;case`ArrowLeft`:return(t-1+n)%n;case`ArrowDown`:return t+N<n?t+N:r;case`ArrowUp`:return t>=N?t-N:i;default:return}}var F=(0,g.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,...r},i){let{current:a,colour:o,commit:s}=O({value:e,defaultValue:t,onValueChange:n});return(0,_.jsx)(I,{...r,ref:i,colour:o,current:a,onColourChange:s})}),I=(0,g.forwardRef)(function({colour:e,current:t,onColourChange:n,presets:r=M,showPresets:i=!0,picker:a=`custom`,isDisabled:o=!1,className:s,style:u,...d},f){let p=(0,g.useRef)(null),m=(0,g.useRef)(!0),v=(0,g.useRef)(o),[y,b]=(0,g.useState)(!1),[T,E]=(0,g.useState)(``),O=(0,g.useSyncExternalStore)(j,()=>!!A(),()=>!1),k=(0,g.useId)(),F=C(t),I=S({...e,a:1}),L=(0,g.useMemo)(()=>{let e=new Map;for(let t of r){let n=C(t);n&&!e.has(n)&&e.set(n,t)}return[...e].map(([e,t])=>({normalised:e,preset:t}))},[r]),R=L.findIndex(e=>e.normalised===F);(0,g.useEffect)(()=>{v.current=o},[o]),(0,g.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let z=async()=>{let t=A();if(!(!t||o||y)){b(!0),E(``);try{let r=await new t().open();m.current&&!v.current&&x(r.sRGBHex)&&n({...w(r.sRGBHex,e),a:e.a})}catch(e){m.current&&!(e instanceof DOMException&&e.name===`AbortError`)&&E(`Unable to pick a colour from the screen. Try again.`)}finally{m.current&&b(!1)}}};return(0,_.jsxs)(`div`,{...d,ref:f,className:[`ds-colour-panel`,s].filter(Boolean).join(` `),"data-disabled":o||void 0,style:{...u,"--colour-hue":`hsl(${e.h} 100% 50%)`,"--colour-rgb":I,"--colour-rgba":S(e)},children:[(0,_.jsxs)(`div`,{className:`ds-colour-panel__head`,children:[(0,_.jsx)(`span`,{children:`Colour`}),(0,_.jsx)(`span`,{className:`ds-colour-panel__value`,children:F||`No colour`})]}),a===`custom`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(D,{colour:e,isDisabled:o,onChange:n}),(0,_.jsxs)(`div`,{className:`ds-colour-panel__hue-row`,children:[O&&(0,_.jsx)(l.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`pipette`,"aria-label":`Pick from screen`,isDisabled:o,"aria-busy":y||void 0,onClick:()=>void z()}),(0,_.jsx)(h.n,{className:`ds-colour-panel__hue`,value:e.h,min:0,max:360,step:1,hasValueLabel:!1,"aria-label":`Hue`,"aria-valuetext":`${Math.round(e.h)} degrees`,isDisabled:o,onValueChange:t=>n({...e,h:t}),onKeyDown:t=>{if(!t.shiftKey||![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(t.key))return;t.preventDefault();let r=t.key===`ArrowRight`||t.key===`ArrowUp`?15:-15;n({...e,h:Math.max(0,Math.min(360,e.h+r))})}})]})]}):(0,_.jsxs)(`div`,{className:`ds-colour-panel__native`,children:[(0,_.jsx)(`input`,{ref:p,type:`color`,value:I,tabIndex:-1,"aria-hidden":`true`,disabled:o,onChange:t=>{x(t.target.value)&&n({...w(t.target.value,e),a:e.a})}}),(0,_.jsx)(l.Button,{variant:`neutral`,size:`sm`,iconStart:`pipette`,isDisabled:o,onClick:()=>{let e=p.current;if(e)try{e.showPicker?e.showPicker():e.click()}catch{e.click()}},children:`Custom colour…`})]}),(0,_.jsxs)(`div`,{className:`ds-colour-panel__opacity`,children:[(0,_.jsx)(`label`,{htmlFor:`${k}-opacity`,children:`Opacity`}),(0,_.jsx)(h.n,{id:`${k}-opacity`,className:`ds-colour-panel__alpha`,value:Math.round(e.a*100),min:0,max:100,step:1,suffix:`%`,isDisabled:o,onValueChange:t=>n({...e,a:t/100})})]}),i&&L.length>0&&(0,_.jsxs)(`div`,{className:`ds-colour-panel__presets`,children:[(0,_.jsx)(`span`,{id:k,className:`ds-colour-panel__presets-label`,children:`Presets`}),(0,_.jsx)(`div`,{className:`ds-colour-panel__grid`,role:`radiogroup`,"aria-labelledby":k,style:{"--colour-preset-columns":N},onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role='radio']`)),n=t.indexOf(e.target),r=n<0?void 0:P(e.key,n,t.length);r!==void 0&&(e.preventDefault(),t[r]?.focus(),t[r]?.click())},children:L.map(({normalised:e,preset:t},r)=>{let i=r===R;return(0,_.jsx)(l.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,role:`radio`,"aria-checked":i,"aria-label":t,title:t,tabIndex:r===Math.max(0,R)?0:-1,isDisabled:o,className:`ds-colour-panel__preset`,onClick:()=>n(t),children:(0,_.jsx)(`span`,{className:`ds-colour-swatch`,style:{"--colour-swatch":e},children:i&&(0,_.jsx)(c.t,{name:`check`,size:16,strokeWidth:3})})},e)})})]}),T&&(0,_.jsx)(`span`,{className:`ds-colour-panel__error`,role:`status`,children:T})]})}),L=(0,g.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,onValidityChange:r,presets:i,showPresets:a,picker:o,placement:s,isDisabled:c=!1,disabled:h,readOnly:v,isInvalid:y,"aria-invalid":b,id:S,className:w,onBlur:E,onKeyDown:D,...A},j){let{current:M,colour:N,commit:P}=O({value:e,defaultValue:t,onValueChange:n}),[F,L]=(0,g.useState)(!1),R=(0,g.useRef)(null),z=(0,g.useRef)(null),B=(0,g.useRef)(null),V=(0,g.useRef)(null),H=(0,g.useId)(),U=S??`${H}-input`,W=C(M),{text:G,type:K,discard:q}=k(M,W),J=!(!G.trim()||x(G)),Y=c||h;F&&(Y||v)&&L(!1);let X=F&&!Y&&!v;(0,g.useEffect)(()=>{r?.(!J),z.current?.setCustomValidity(J?`Enter a colour, such as #0052CC or rebeccapurple.`:``)},[J,r]),(0,g.useEffect)(()=>{if(!X)return;V.current&&d.n(V.current)[0]?.focus({preventScroll:!0});let e=e=>{let t=e.target;t&&!R.current?.contains(t)&&!V.current?.contains(t)&&L(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[X]);let Z=e=>{B.current=e,L(!X)},Q=()=>{L(!1),B.current?.focus({preventScroll:!0})},$={"aria-label":X?`Close colour picker`:`Open colour picker`,"aria-haspopup":`dialog`,"aria-expanded":X,"aria-controls":X?H:void 0,isDisabled:Y||v};return(0,_.jsxs)(`div`,{className:`ds-colour-field`,ref:R,onBlur:e=>{let t=e.relatedTarget;t&&!R.current?.contains(t)&&!V.current?.contains(t)&&L(!1)},onKeyDown:e=>{if(X&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Q()),!X||e.key!==`Tab`||!V.current?.contains(e.target))return;let t=d.n(V.current);(e.shiftKey?e.target===t[0]:e.target===t.at(-1))&&(e.preventDefault(),e.stopPropagation(),L(!1),e.shiftKey?B.current?.focus({preventScroll:!0}):R.current&&T(R.current))},children:[(0,_.jsx)(p.FieldAffix,{isLeadInteractive:!0,isTrailInteractive:!0,lead:(0,_.jsx)(l.Button,{"aria-hidden":`true`,tabIndex:-1,isDisabled:$.isDisabled,variant:`simple`,size:`xs`,isIconOnly:!0,onMouseDown:e=>e.preventDefault(),onClick:()=>{B.current=z.current,X?Q():L(!0)},children:(0,_.jsx)(`span`,{className:`ds-colour-swatch ds-colour-field__swatch`,style:{"--colour-swatch":W||`transparent`}})}),trail:(0,_.jsx)(l.Button,{...$,variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`chevron-down`,onClick:e=>Z(e.currentTarget)}),children:(0,_.jsx)(f.TextField,{...A,ref:u.t(z,j),id:U,disabled:Y,readOnly:v,spellCheck:!1,autoComplete:`off`,value:G,"aria-invalid":J||y||b||void 0,"aria-haspopup":`dialog`,"aria-controls":X?H:void 0,className:[`ds-colour-field__input`,w].filter(Boolean).join(` `),onChange:e=>{let t=e.target.value,n=!t.trim()||!!x(t);K(t,n),n&&P(t)},onBlur:e=>{J||q(),E?.(e)},onKeyDown:e=>{D?.(e),!e.defaultPrevented&&(e.key===`Enter`&&!J&&(e.preventDefault(),q()),e.key===`ArrowDown`&&!Y&&!v&&(e.preventDefault(),B.current=e.currentTarget,L(!0)))}})}),(0,_.jsx)(m.Popover,{anchorRef:z,anchorId:U,isOpen:X,placement:s,panelRef:V,id:H,role:`dialog`,"aria-label":`Choose a colour`,tabIndex:-1,className:`ds-colour-field__popover`,children:(0,_.jsx)(I,{colour:N,current:W,presets:i,showPresets:a,picker:o,onColourChange:e=>{q(),P(e)}})})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return L}});
|
|
2
|
-
//# sourceMappingURL=ColourField-
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./Icon-D38lQXNe.cjs"),l=require("../components/Button/index.cjs"),u=require("./mergeRefs-Bc3qS0Tt.cjs"),d=require("./portalScope-BVA1-Ypu.cjs"),f=require("../components/TextField/index.cjs"),p=require("../components/FieldAffix/index.cjs"),m=require("../components/Popover/index.cjs"),h=require("./Slider-k8weRl34.cjs");let g=require("react"),_=require("react/jsx-runtime"),v=require("colord"),y=require("colord/plugins/names");y=s(y,1),(0,v.extend)([y.default]);var b={h:0,s:100,v:0,a:1};function x(e){let t=e.trim();if(!t)return null;let n=t.replace(/^#/,``),r=n.length<5?[...n].map(e=>e+e).join(``):n,i=/^(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(n)?(0,v.colord)({r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16),a:r.length===8?parseInt(r.slice(6),16)/255:1}):(0,v.colord)(t);return i.isValid()?i:null}function S(e){return(0,v.colord)(e).toHex().toUpperCase()}function C(e){return x(e)?.toHex().toUpperCase()??``}function w(e,t=b){let n=x(e);if(!n||n.toHex().toUpperCase()===S(t))return t;let{r,g:i,b:a,a:o}=n.rgba,s=Math.max(r,i,a),c=s-Math.min(r,i,a),l=c===0?t.h:s===r?(i-a)/c*60:s===i?((a-r)/c+2)*60:((r-i)/c+4)*60;l<0&&(l+=360);let u={h:l,s:s?c/s*100:0,v:s/255*100,a:o};return{...u,h:u.s===0?t.h:u.h,s:u.v===0?t.s:u.s}}function T(e){let t=e.closest(`[aria-modal='true']`)??document.body,n=d.s(t).filter(e=>!e.closest(`.ds-popover`));(n[n.map(t=>e.contains(t)).lastIndexOf(!0)+1]??n[0])?.focus({preventScroll:!0})}function E(e){return Math.max(0,Math.min(100,e))}function D({colour:e,isDisabled:t,onChange:n}){let r=(0,g.useRef)(null),i=t=>{let r=t.currentTarget.getBoundingClientRect();r.width&&r.height&&n({...e,s:E((t.clientX-r.left)/r.width*100),v:E((1-(t.clientY-r.top)/r.height)*100)})};return(0,_.jsx)(`div`,{className:`ds-colour-panel__square`,role:`slider`,tabIndex:t?-1:0,"aria-label":`Saturation and brightness`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(e.s),"aria-valuetext":`Saturation ${Math.round(e.s)}%, brightness ${Math.round(e.v)}%`,"aria-disabled":t||void 0,onKeyDown:r=>{if(t)return;let i=r.shiftKey?10:1,a={ArrowLeft:{s:E(e.s-i)},ArrowRight:{s:E(e.s+i)},ArrowDown:{v:E(e.v-i)},ArrowUp:{v:E(e.v+i)},Home:{s:0},End:{s:100}}[r.key];a&&(r.preventDefault(),n({...e,...a}))},onPointerDown:e=>{t||e.button!==0||(e.preventDefault(),e.currentTarget.focus(),r.current=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),i(e))},onPointerMove:e=>{!t&&r.current===e.pointerId&&i(e)},onPointerUp:e=>{r.current===e.pointerId&&(r.current=null,e.currentTarget.releasePointerCapture(e.pointerId))},onPointerCancel:()=>{r.current=null},onLostPointerCapture:()=>{r.current=null},children:(0,_.jsx)(`span`,{className:`ds-colour-panel__thumb`,style:{left:`${e.s}%`,top:`${100-e.v}%`}})})}function O({value:e,defaultValue:t=``,onValueChange:n}){let[r,i]=(0,g.useState)(t),a=e??r,[o,s]=(0,g.useState)(()=>({source:a,colour:w(a)})),c=o.colour;return o.source!==a&&(c=w(a,c),s({source:a,colour:c})),{current:a,colour:c,commit:t=>{let r=typeof t==`string`?C(t):S(t);s({source:r,colour:typeof t==`string`?w(t,c):t}),e===void 0&&i(r),n?.(r)}}}function k(e,t){let[n,r]=(0,g.useState)(null);return n&&n.source!==e&&n.text===e&&r({source:e,text:e}),{text:n?.source===e?n.text:t||e,type:(t,n)=>r({source:n?C(t):e,text:t}),discard:()=>r(null)}}function A(){return window.EyeDropper}var j=()=>()=>{},M=[],N=8;function P(e,t,n){let r=t%N,i=r+Math.floor((n-1-r)/N)*N;switch(e){case`Home`:return 0;case`End`:return n-1;case`ArrowRight`:return(t+1)%n;case`ArrowLeft`:return(t-1+n)%n;case`ArrowDown`:return t+N<n?t+N:r;case`ArrowUp`:return t>=N?t-N:i;default:return}}var F=(0,g.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,...r},i){let{current:a,colour:o,commit:s}=O({value:e,defaultValue:t,onValueChange:n});return(0,_.jsx)(I,{...r,ref:i,colour:o,current:a,onColourChange:s})}),I=(0,g.forwardRef)(function({colour:e,current:t,onColourChange:n,presets:r=M,showPresets:i=!0,picker:a=`custom`,isDisabled:o=!1,className:s,style:u,...d},f){let p=(0,g.useRef)(null),m=(0,g.useRef)(!0),v=(0,g.useRef)(o),[y,b]=(0,g.useState)(!1),[T,E]=(0,g.useState)(``),O=(0,g.useSyncExternalStore)(j,()=>!!A(),()=>!1),k=(0,g.useId)(),F=C(t),I=S({...e,a:1}),L=(0,g.useMemo)(()=>{let e=new Map;for(let t of r){let n=C(t);n&&!e.has(n)&&e.set(n,t)}return[...e].map(([e,t])=>({normalised:e,preset:t}))},[r]),R=L.findIndex(e=>e.normalised===F);(0,g.useEffect)(()=>{v.current=o},[o]),(0,g.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let z=async()=>{let t=A();if(!(!t||o||y)){b(!0),E(``);try{let r=await new t().open();m.current&&!v.current&&x(r.sRGBHex)&&n({...w(r.sRGBHex,e),a:e.a})}catch(e){m.current&&!(e instanceof DOMException&&e.name===`AbortError`)&&E(`Unable to pick a colour from the screen. Try again.`)}finally{m.current&&b(!1)}}};return(0,_.jsxs)(`div`,{...d,ref:f,className:[`ds-colour-panel`,s].filter(Boolean).join(` `),"data-disabled":o||void 0,style:{...u,"--colour-hue":`hsl(${e.h} 100% 50%)`,"--colour-rgb":I,"--colour-rgba":S(e)},children:[(0,_.jsxs)(`div`,{className:`ds-colour-panel__head`,children:[(0,_.jsx)(`span`,{children:`Colour`}),(0,_.jsx)(`span`,{className:`ds-colour-panel__value`,children:F||`No colour`})]}),a===`custom`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(D,{colour:e,isDisabled:o,onChange:n}),(0,_.jsxs)(`div`,{className:`ds-colour-panel__hue-row`,children:[O&&(0,_.jsx)(l.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`pipette`,"aria-label":`Pick from screen`,isDisabled:o,"aria-busy":y||void 0,onClick:()=>void z()}),(0,_.jsx)(h.n,{className:`ds-colour-panel__hue`,value:e.h,min:0,max:360,step:1,hasValueLabel:!1,"aria-label":`Hue`,"aria-valuetext":`${Math.round(e.h)} degrees`,isDisabled:o,onValueChange:t=>n({...e,h:t}),onKeyDown:t=>{if(!t.shiftKey||![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(t.key))return;t.preventDefault();let r=t.key===`ArrowRight`||t.key===`ArrowUp`?15:-15;n({...e,h:Math.max(0,Math.min(360,e.h+r))})}})]})]}):(0,_.jsxs)(`div`,{className:`ds-colour-panel__native`,children:[(0,_.jsx)(`input`,{ref:p,type:`color`,value:I,tabIndex:-1,"aria-hidden":`true`,disabled:o,onChange:t=>{x(t.target.value)&&n({...w(t.target.value,e),a:e.a})}}),(0,_.jsx)(l.Button,{variant:`neutral`,size:`sm`,iconStart:`pipette`,isDisabled:o,onClick:()=>{let e=p.current;if(e)try{e.showPicker?e.showPicker():e.click()}catch{e.click()}},children:`Custom colour…`})]}),(0,_.jsxs)(`div`,{className:`ds-colour-panel__opacity`,children:[(0,_.jsx)(`label`,{htmlFor:`${k}-opacity`,children:`Opacity`}),(0,_.jsx)(h.n,{id:`${k}-opacity`,className:`ds-colour-panel__alpha`,value:Math.round(e.a*100),min:0,max:100,step:1,suffix:`%`,isDisabled:o,onValueChange:t=>n({...e,a:t/100})})]}),i&&L.length>0&&(0,_.jsxs)(`div`,{className:`ds-colour-panel__presets`,children:[(0,_.jsx)(`span`,{id:k,className:`ds-colour-panel__presets-label`,children:`Presets`}),(0,_.jsx)(`div`,{className:`ds-colour-panel__grid`,role:`radiogroup`,"aria-labelledby":k,style:{"--colour-preset-columns":N},onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role='radio']`)),n=t.indexOf(e.target),r=n<0?void 0:P(e.key,n,t.length);r!==void 0&&(e.preventDefault(),t[r]?.focus(),t[r]?.click())},children:L.map(({normalised:e,preset:t},r)=>{let i=r===R;return(0,_.jsx)(l.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,role:`radio`,"aria-checked":i,"aria-label":t,title:t,tabIndex:r===Math.max(0,R)?0:-1,isDisabled:o,className:`ds-colour-panel__preset`,onClick:()=>n(t),children:(0,_.jsx)(`span`,{className:`ds-colour-swatch`,style:{"--colour-swatch":e},children:i&&(0,_.jsx)(c.t,{name:`check`,size:16,strokeWidth:3})})},e)})})]}),T&&(0,_.jsx)(`span`,{className:`ds-colour-panel__error`,role:`status`,children:T})]})}),L=(0,g.forwardRef)(function({value:e,defaultValue:t,onValueChange:n,onValidityChange:r,presets:i,showPresets:a,picker:o,placement:s,isDisabled:c=!1,disabled:h,readOnly:v,isInvalid:y,"aria-invalid":b,id:S,className:w,onBlur:E,onKeyDown:D,...A},j){let{current:M,colour:N,commit:P}=O({value:e,defaultValue:t,onValueChange:n}),[F,L]=(0,g.useState)(!1),R=(0,g.useRef)(null),z=(0,g.useRef)(null),B=(0,g.useRef)(null),V=(0,g.useRef)(null),H=(0,g.useId)(),U=S??`${H}-input`,W=C(M),{text:G,type:K,discard:q}=k(M,W),J=!(!G.trim()||x(G)),Y=c||h;F&&(Y||v)&&L(!1);let X=F&&!Y&&!v;(0,g.useEffect)(()=>{r?.(!J),z.current?.setCustomValidity(J?`Enter a colour, such as #0052CC or rebeccapurple.`:``)},[J,r]),(0,g.useEffect)(()=>{if(!X)return;V.current&&d.s(V.current)[0]?.focus({preventScroll:!0});let e=e=>{let t=e.target;t&&!R.current?.contains(t)&&!V.current?.contains(t)&&L(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[X]);let Z=e=>{B.current=e,L(!X)},Q=()=>{L(!1),B.current?.focus({preventScroll:!0})},$={"aria-label":X?`Close colour picker`:`Open colour picker`,"aria-haspopup":`dialog`,"aria-expanded":X,"aria-controls":X?H:void 0,isDisabled:Y||v};return(0,_.jsxs)(`div`,{className:`ds-colour-field`,ref:R,onBlur:e=>{let t=e.relatedTarget;t&&!R.current?.contains(t)&&!V.current?.contains(t)&&L(!1)},onKeyDown:e=>{if(X&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Q()),!X||e.key!==`Tab`||!V.current?.contains(e.target))return;let t=d.s(V.current);(e.shiftKey?e.target===t[0]:e.target===t.at(-1))&&(e.preventDefault(),e.stopPropagation(),L(!1),e.shiftKey?B.current?.focus({preventScroll:!0}):R.current&&T(R.current))},children:[(0,_.jsx)(p.FieldAffix,{isLeadInteractive:!0,isTrailInteractive:!0,lead:(0,_.jsx)(l.Button,{"aria-hidden":`true`,tabIndex:-1,isDisabled:$.isDisabled,variant:`simple`,size:`xs`,isIconOnly:!0,onMouseDown:e=>e.preventDefault(),onClick:()=>{B.current=z.current,X?Q():L(!0)},children:(0,_.jsx)(`span`,{className:`ds-colour-swatch ds-colour-field__swatch`,style:{"--colour-swatch":W||`transparent`}})}),trail:(0,_.jsx)(l.Button,{...$,variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`chevron-down`,onClick:e=>Z(e.currentTarget)}),children:(0,_.jsx)(f.TextField,{...A,ref:u.t(z,j),id:U,disabled:Y,readOnly:v,spellCheck:!1,autoComplete:`off`,value:G,"aria-invalid":J||y||b||void 0,"aria-haspopup":`dialog`,"aria-controls":X?H:void 0,className:[`ds-colour-field__input`,w].filter(Boolean).join(` `),onChange:e=>{let t=e.target.value,n=!t.trim()||!!x(t);K(t,n),n&&P(t)},onBlur:e=>{J||q(),E?.(e)},onKeyDown:e=>{D?.(e),!e.defaultPrevented&&(e.key===`Enter`&&!J&&(e.preventDefault(),q()),e.key===`ArrowDown`&&!Y&&!v&&(e.preventDefault(),B.current=e.currentTarget,L(!0)))}})}),(0,_.jsx)(m.Popover,{anchorRef:z,anchorId:U,isOpen:X,placement:s,panelRef:V,id:H,role:`dialog`,"aria-label":`Choose a colour`,tabIndex:-1,className:`ds-colour-field__popover`,children:(0,_.jsx)(I,{colour:N,current:W,presets:i,showPresets:a,picker:o,onColourChange:e=>{q(),P(e)}})})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return L}});
|
|
2
|
+
//# sourceMappingURL=ColourField-BQ4a5tAV.cjs.map
|