@namroodinc/liquid-editorial 0.1.11 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.md +59 -16
- package/UPGRADING.md +108 -0
- package/dist/chunks/{Board-BLhB5_xx.cjs → Board-BUJ5CinL.cjs} +2 -2
- package/dist/chunks/Board-BUJ5CinL.cjs.map +1 -0
- package/dist/chunks/{Board-BTFSzn6c.js → Board-Cyrda2qG.js} +2 -2
- package/dist/chunks/Board-Cyrda2qG.js.map +1 -0
- package/dist/chunks/FormEditor-8bz3pOdP.cjs +2 -0
- package/dist/chunks/FormEditor-8bz3pOdP.cjs.map +1 -0
- package/dist/chunks/FormEditor-DuW8x78Y.js +330 -0
- package/dist/chunks/FormEditor-DuW8x78Y.js.map +1 -0
- package/dist/chunks/Icon-ByUB0L1a.js +78 -0
- package/dist/chunks/Icon-ByUB0L1a.js.map +1 -0
- package/dist/chunks/Icon-CW6qJcDy.cjs +2 -0
- package/dist/chunks/Icon-CW6qJcDy.cjs.map +1 -0
- package/dist/chunks/RichTextEditor-BxtlbjXj.cjs.map +1 -1
- package/dist/chunks/RichTextEditor-Dnx4i7bQ.js.map +1 -1
- package/dist/chunks/dialogStack-6yv3NXFD.js +43 -0
- package/dist/chunks/dialogStack-6yv3NXFD.js.map +1 -0
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs +2 -0
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs.map +1 -0
- package/dist/chunks/observeElementWidth-BCJM2FAw.cjs +2 -0
- package/dist/chunks/observeElementWidth-BCJM2FAw.cjs.map +1 -0
- package/dist/chunks/observeElementWidth-BlQOlW2t.js +12 -0
- package/dist/chunks/observeElementWidth-BlQOlW2t.js.map +1 -0
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.cjs.map +1 -1
- package/dist/components/AppShell/index.d.cts +5 -1
- package/dist/components/AppShell/index.d.cts.map +1 -1
- package/dist/components/AppShell/index.d.ts +5 -1
- package/dist/components/AppShell/index.d.ts.map +1 -1
- package/dist/components/AppShell/index.js +53 -60
- package/dist/components/AppShell/index.js.map +1 -1
- package/dist/components/AppShell/style.css +48 -6
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.cjs.map +1 -1
- package/dist/components/AssetCard/index.d.cts +1 -1
- package/dist/components/AssetCard/index.d.cts.map +1 -1
- package/dist/components/AssetCard/index.d.ts +1 -1
- package/dist/components/AssetCard/index.d.ts.map +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetCard/index.js.map +1 -1
- package/dist/components/AssetCard/style.css +20 -9
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.cjs.map +1 -1
- package/dist/components/AssetGrid/index.d.cts +1 -1
- package/dist/components/AssetGrid/index.d.cts.map +1 -1
- package/dist/components/AssetGrid/index.d.ts +1 -1
- package/dist/components/AssetGrid/index.d.ts.map +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/AssetGrid/index.js.map +1 -1
- package/dist/components/Avatar/index.cjs.map +1 -1
- package/dist/components/Avatar/index.d.cts.map +1 -1
- package/dist/components/Avatar/index.d.ts.map +1 -1
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.cts.map +1 -1
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/style.css +2 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.d.cts.map +1 -1
- package/dist/components/Board/index.d.ts.map +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Board/keyboard.d.cts.map +1 -1
- package/dist/components/Board/keyboard.d.ts.map +1 -1
- package/dist/components/Board/moves.d.cts.map +1 -1
- package/dist/components/Board/moves.d.ts.map +1 -1
- package/dist/components/Board/style.css +12 -7
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.cts.map +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/style.css +1 -1
- package/dist/components/ButtonGroup/index.cjs.map +1 -1
- package/dist/components/ButtonGroup/index.d.cts.map +1 -1
- package/dist/components/ButtonGroup/index.d.ts.map +1 -1
- package/dist/components/ButtonGroup/index.js.map +1 -1
- package/dist/components/ButtonGroup/style.css +1 -0
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.d.cts.map +1 -1
- package/dist/components/Choice/index.d.ts.map +1 -1
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/Choice/style.css +1 -1
- package/dist/components/Container/style.css +1 -0
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.cjs.map +1 -1
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/DatePicker/style.css +3 -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 +72 -70
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +7 -2
- package/dist/components/EditLayout/index.cjs +2 -0
- package/dist/components/EditLayout/index.cjs.map +1 -0
- package/dist/components/EditLayout/index.d.cts +25 -0
- package/dist/components/EditLayout/index.d.cts.map +1 -0
- package/dist/components/EditLayout/index.d.ts +25 -0
- package/dist/components/EditLayout/index.d.ts.map +1 -0
- package/dist/components/EditLayout/index.js +239 -0
- package/dist/components/EditLayout/index.js.map +1 -0
- package/dist/components/EditLayout/style.css +226 -0
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts +3 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts +3 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +46 -44
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/Field/index.cjs.map +1 -1
- package/dist/components/Field/index.d.cts.map +1 -1
- package/dist/components/Field/index.d.ts.map +1 -1
- package/dist/components/Field/index.js.map +1 -1
- package/dist/components/Field/style.css +1 -1
- package/dist/components/FieldAffix/index.cjs.map +1 -1
- package/dist/components/FieldAffix/index.d.cts.map +1 -1
- package/dist/components/FieldAffix/index.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.js.map +1 -1
- package/dist/components/FormEditor/control.d.cts +15 -0
- package/dist/components/FormEditor/control.d.cts.map +1 -0
- package/dist/components/FormEditor/control.d.ts +15 -0
- package/dist/components/FormEditor/control.d.ts.map +1 -0
- package/dist/components/FormEditor/index.cjs +1 -0
- package/dist/components/FormEditor/index.d.cts +28 -0
- package/dist/components/FormEditor/index.d.cts.map +1 -0
- package/dist/components/FormEditor/index.d.ts +28 -0
- package/dist/components/FormEditor/index.d.ts.map +1 -0
- package/dist/components/FormEditor/index.js +2 -0
- package/dist/components/FormEditor/model.d.cts +86 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -0
- package/dist/components/FormEditor/model.d.ts +86 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -0
- package/dist/components/FormEditor/style.css +27 -0
- package/dist/components/Icon/icons.d.cts +1 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +1 -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/Icon/style.css +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.d.cts +1 -1
- package/dist/components/ImageCropper/index.d.cts.map +1 -1
- package/dist/components/ImageCropper/index.d.ts +1 -1
- package/dist/components/ImageCropper/index.d.ts.map +1 -1
- package/dist/components/ImageCropper/index.js.map +1 -1
- package/dist/components/ImageCropper/style.css +28 -5
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/style.css +0 -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.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +47 -46
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +2 -2
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.d.cts +3 -0
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts +3 -0
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +20 -20
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/NumberField/style.css +4 -6
- package/dist/components/Pagination/index.cjs.map +1 -1
- package/dist/components/Pagination/index.d.cts.map +1 -1
- package/dist/components/Pagination/index.d.ts.map +1 -1
- package/dist/components/Pagination/index.js.map +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.map +1 -1
- package/dist/components/RichTextEditor/document.d.cts.map +1 -1
- package/dist/components/RichTextEditor/document.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +0 -1
- package/dist/components/RichTextEditor/style.css +2 -2
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.cjs.map +1 -1
- package/dist/components/SearchField/index.d.cts.map +1 -1
- package/dist/components/SearchField/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/SearchField/index.js.map +1 -1
- package/dist/components/SearchField/style.css +0 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.cts.map +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.d.cts +1 -1
- package/dist/components/SelectionCard/index.d.cts.map +1 -1
- package/dist/components/SelectionCard/index.d.ts +1 -1
- package/dist/components/SelectionCard/index.d.ts.map +1 -1
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/SelectionCard/style.css +1 -5
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.cjs.map +1 -1
- package/dist/components/SideNav/index.d.cts.map +1 -1
- package/dist/components/SideNav/index.d.ts.map +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SideNav/index.js.map +1 -1
- package/dist/components/SideNav/style.css +7 -2
- package/dist/components/Skeleton/index.cjs.map +1 -1
- package/dist/components/Skeleton/index.d.cts.map +1 -1
- package/dist/components/Skeleton/index.d.ts.map +1 -1
- package/dist/components/Skeleton/index.js.map +1 -1
- package/dist/components/Skeleton/style.css +2 -2
- package/dist/components/Slider/index.cjs.map +1 -1
- package/dist/components/Slider/index.d.cts.map +1 -1
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/style.css +5 -16
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SortableList/style.css +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.cjs.map +1 -1
- package/dist/components/Stepper/index.d.cts.map +1 -1
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/Stepper/style.css +2 -2
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.cjs.map +1 -1
- package/dist/components/SubNav/index.d.cts.map +1 -1
- package/dist/components/SubNav/index.d.ts.map +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/SubNav/index.js.map +1 -1
- package/dist/components/Switch/index.cjs.map +1 -1
- package/dist/components/Switch/index.d.cts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/style.css +2 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.cjs.map +1 -1
- package/dist/components/Table/index.d.cts.map +1 -1
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/style.css +1 -0
- package/dist/components/TagsInput/index.cjs.map +1 -1
- package/dist/components/TagsInput/index.d.cts.map +1 -1
- package/dist/components/TagsInput/index.d.ts.map +1 -1
- package/dist/components/TagsInput/index.js.map +1 -1
- package/dist/components/TagsInput/style.css +2 -1
- package/dist/components/TextField/index.cjs.map +1 -1
- package/dist/components/TextField/index.d.cts.map +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/index.js.map +1 -1
- package/dist/components/Time/index.cjs.map +1 -1
- package/dist/components/Time/index.d.cts.map +1 -1
- package/dist/components/Time/index.d.ts.map +1 -1
- package/dist/components/Time/index.js.map +1 -1
- package/dist/components/Time/style.css +1 -2
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.cjs.map +1 -1
- package/dist/components/Toast/index.d.cts.map +1 -1
- package/dist/components/Toast/index.d.ts.map +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/Toast/style.css +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.cjs.map +1 -1
- package/dist/components/TopNav/index.d.cts.map +1 -1
- package/dist/components/TopNav/index.d.ts.map +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/components/TopNav/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -21
- package/dist/internal/dialogStack.d.cts +9 -0
- package/dist/internal/dialogStack.d.cts.map +1 -0
- package/dist/internal/dialogStack.d.ts +9 -0
- package/dist/internal/dialogStack.d.ts.map +1 -0
- package/dist/internal/lockBodyScroll.d.cts +7 -0
- package/dist/internal/lockBodyScroll.d.cts.map +1 -0
- package/dist/internal/lockBodyScroll.d.ts +7 -0
- package/dist/internal/lockBodyScroll.d.ts.map +1 -0
- package/dist/internal/observeElementWidth.d.cts +3 -0
- package/dist/internal/observeElementWidth.d.cts.map +1 -0
- package/dist/internal/observeElementWidth.d.ts +3 -0
- package/dist/internal/observeElementWidth.d.ts.map +1 -0
- package/dist/reset.css +29 -4
- package/dist/styles.css +20 -16
- package/dist/test/dragEvent.d.cts.map +1 -1
- package/dist/test/dragEvent.d.ts.map +1 -1
- package/dist/tokens.css +77 -40
- package/package.json +9 -2
- package/dist/chunks/Board-BLhB5_xx.cjs.map +0 -1
- package/dist/chunks/Board-BTFSzn6c.js.map +0 -1
- package/dist/chunks/EntryEditor-CcyYtH74.js +0 -191
- package/dist/chunks/EntryEditor-CcyYtH74.js.map +0 -1
- package/dist/chunks/EntryEditor-DIpc1iPF.cjs +0 -2
- package/dist/chunks/EntryEditor-DIpc1iPF.cjs.map +0 -1
- package/dist/chunks/Icon-CGY1FNXT.js +0 -77
- package/dist/chunks/Icon-CGY1FNXT.js.map +0 -1
- package/dist/chunks/Icon-CWsA1W83.cjs +0 -2
- package/dist/chunks/Icon-CWsA1W83.cjs.map +0 -1
- package/dist/components/EntryEditor/index.cjs +0 -1
- package/dist/components/EntryEditor/index.d.cts +0 -21
- package/dist/components/EntryEditor/index.d.cts.map +0 -1
- package/dist/components/EntryEditor/index.d.ts +0 -21
- package/dist/components/EntryEditor/index.d.ts.map +0 -1
- package/dist/components/EntryEditor/index.js +0 -6
- package/dist/components/EntryEditor/model.d.cts +0 -33
- package/dist/components/EntryEditor/model.d.cts.map +0 -1
- package/dist/components/EntryEditor/model.d.ts +0 -33
- package/dist/components/EntryEditor/model.d.ts.map +0 -1
- package/dist/components/EntryEditor/style.css +0 -8
package/AGENTS.md
CHANGED
|
@@ -8,7 +8,7 @@ End every completed change handoff with a suggested Git commit subject and descr
|
|
|
8
8
|
|
|
9
9
|
Render button controls through the shared `Button` component, including controls inside other components and examples. Native button markup belongs only in `src/components/Button` (isolated test fixtures may use native controls). Use Button's standard variants, sizes, icons, focus, and disabled styling instead of copying them into a component stylesheet. Specialized widgets may retain their semantic layout, shared Field skin, or switch track/knob geometry.
|
|
10
10
|
|
|
11
|
-
Every releasable change set must update the `Unreleased` section in `UPGRADING.md` with changes, adoption steps, compatibility notes, and verification steps for agents in consuming projects. Related edits share that section. Leave version increments to `.github/workflows/release.yml`: every push to `main` automatically bumps the patch
|
|
11
|
+
Every releasable change set must update the `Unreleased` section in `UPGRADING.md` with changes, adoption steps, compatibility notes, and verification steps for agents in consuming projects. A change set that removes or renames public API also lists it under a `### Breaking changes` heading there. Related edits share that section. Leave version increments to `.github/workflows/release.yml`: every push to `main` automatically bumps the version (patch, or minor below 1.0 and major from 1.0 when `Unreleased` has `### Breaking changes`), versions the upgrade notes, validates, commits the release files, and publishes to npm. Keep the manifest and lockfile versions aligned and include this file and `UPGRADING.md` in the package.
|
|
12
12
|
|
|
13
13
|
## Using the installed package
|
|
14
14
|
|
package/README.md
CHANGED
|
@@ -55,20 +55,20 @@ If an application only needs the design tokens, import `@namroodinc/liquid-edito
|
|
|
55
55
|
|
|
56
56
|
Use `appearance="outline"` (the default) on board and selection cards, `appearance="soft"` in dense tables and toolbar counts, and `appearance="solid"` for the one state a row or tile emphasizes, such as a Cover asset badge. Soft badges have no visible stroke. Tags inside sentences also display uppercase, including path labels such as `/news`.
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Forms and content models
|
|
59
59
|
|
|
60
|
-
`
|
|
60
|
+
`FormEditor` renders standard fields in schema order. Applications own state, choice loading, permissions, submission, and persistence:
|
|
61
61
|
|
|
62
62
|
```tsx
|
|
63
63
|
import { useState } from "react";
|
|
64
64
|
import {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
type
|
|
68
|
-
type
|
|
65
|
+
FormEditor,
|
|
66
|
+
validateFormValues,
|
|
67
|
+
type FormSchema,
|
|
68
|
+
type FormValues,
|
|
69
69
|
} from "@namroodinc/liquid-editorial";
|
|
70
70
|
|
|
71
|
-
const
|
|
71
|
+
const schema: FormSchema = {
|
|
72
72
|
fields: [
|
|
73
73
|
{ id: "title", type: "shortText", label: "Title", required: true },
|
|
74
74
|
{ id: "gallery", type: "asset", label: "Gallery", multiple: true },
|
|
@@ -76,10 +76,10 @@ const model: ContentModel = {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export function ContentEditor() {
|
|
79
|
-
const [value, setValue] = useState<
|
|
79
|
+
const [value, setValue] = useState<FormValues>({});
|
|
80
80
|
return (
|
|
81
|
-
<
|
|
82
|
-
|
|
81
|
+
<FormEditor
|
|
82
|
+
schema={schema}
|
|
83
83
|
value={value}
|
|
84
84
|
onValueChange={setValue}
|
|
85
85
|
pickerItems={{ gallery: [{ id: "image-1", title: "Cover.jpg" }] }}
|
|
@@ -87,12 +87,18 @@ export function ContentEditor() {
|
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// Before saving:
|
|
90
|
+
// Before saving: validateFormValues(schema, value) returns errors keyed by field ID.
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
Supported types are `shortText`, `longText`, `richText`, `number`, `boolean`, `dateTime`, `asset`, and `
|
|
93
|
+
Supported types are `shortText`, `longText`, `richText`, `number`, `boolean`, `dateTime`, `asset`, `reference`, and string-valued `select`. Rich text stores a TipTap JSON document rooted at `doc`, using the editor's existing StarterKit and Link schema. Dates are edited in UTC and emitted as ISO-8601 strings ending in `Z`. Assets store `{ assetId }`; references store `{ entryId }`. Set `multiple: true` for an ordered array of these objects.
|
|
94
94
|
|
|
95
|
-
Use `defaultValue` for an uncontrolled editor, `errors` for app-specific messages, `showAllErrors` after a submit attempt, and `isDisabled` to disable editing. Required errors appear after a field changes; `false` and `0` are populated values. Missing keys render empty controls without emitting changes. Clearing a number, date, or single selection removes its key; empty text, rich-text documents, and lists keep their typed values. Unrelated entry keys are preserved.
|
|
95
|
+
Use `defaultValue` for an uncontrolled editor, `errors` for app-specific messages, `showAllErrors` after a submit attempt, and `isDisabled` to disable editing. Required and format errors appear after a field changes; an out-of-range number shows its message straight away, because the control already reads invalid. `false` and `0` are populated values. Missing keys render empty controls without emitting changes. Clearing a number, date, select, or single selection removes its key; empty text, rich-text documents, and lists keep their typed values. Unrelated entry keys are preserved. Validation runs per field and is reused until that field or its value changes, so define schemas outside render or memoize them.
|
|
96
|
+
|
|
97
|
+
General forms can use select fields with `options: [{ value, label }]`, per-field `isDisabled`, and React-node hints. Optional selects lead with an empty choice, labelled with the field's `placeholder` or "None", that clears the value. Pass `options: []` while choices load; a stored value stays valid until they arrive. Text fields support `maxLength` and `readOnly`; short text also supports `inputType: "email"`, long text supports `rows`, and numeric fields support `min`, `max`, `step`, and `hasSteppers`. Steppers are named after their field, such as "Increase Width". `validateFormValues` enforces `maxLength`, numeric limits, and `picker.max`. `autoFocus` applies to text, number, select, boolean, and date fields.
|
|
98
|
+
|
|
99
|
+
`columns` sets the most columns and defaults to one. The form drops a column whenever a field would be narrower than `minColumnWidth` (default `16rem`), measured against the form's own width, so it steps down inside drawers and modals. Use `columns="auto"` to fit as many columns as the width allows. FormEditor is not a size container, so it keeps its content width in flex rows and popovers.
|
|
100
|
+
|
|
101
|
+
Changes emit `onValueChange(nextValues, { fieldId })`. Use the changed field ID when adapting to APIs that accept patches, generated IDs, or dependent values. Runtime form schemas can hold JSX and live choices, so keep them separate from persisted content definitions. Picker field options such as `picker: { itemLabel: "image", itemsLabel: "images" }` provide contextual search and selection copy without putting data access in the library. Omitted or `undefined` options keep the asset or entry wording.
|
|
96
102
|
|
|
97
103
|
`RichTextEditor` also supports `format="json"` with `value`/`defaultValue` and an `onChange` callback receiving the document. HTML remains its default format. Unsupported JSON content produces an error and cannot be edited until corrected.
|
|
98
104
|
|
|
@@ -132,12 +138,45 @@ The optional `actions` render function receives `"topnav"` or `"drawer"`. Return
|
|
|
132
138
|
|
|
133
139
|
The drawer traps focus and locks body scroll. Escape, Close, the scrim, and navigation links dismiss it and return focus to the hamburger. A popup inside it, such as a Menu in the actions footer, closes first on Escape. Modifier-key clicks that open a link elsewhere leave the drawer open. Widening the shell to desktop closes it and moves focus to the active desktop link when focus was inside the drawer. Reduced motion skips the transition.
|
|
134
140
|
|
|
135
|
-
|
|
141
|
+
With `scrollMode="document"` the window scrolls instead of `main`, the desktop navigation stays pinned below the top bar, and the drawer portals to `document.body` like Modal. It keeps the shell's `dir`; set themes on the document root as usual. `contentPadding="none"` lets a full-width page such as `EditLayout` own its spacing.
|
|
142
|
+
|
|
143
|
+
All `Drawer` variants have square corners and slide fully in and out through their anchored edge, with a fading scrim. Use `side="end"` (the default) for the right edge in LTR, `side="start"` for the left, and `side="bottom"` for a bottom sheet. Start and end mirror in RTL, including when passing `dir="rtl"` directly to Drawer. Motion uses `--duration-panel` and `--ease-panel`; reduced motion skips the transition. Closing immediately makes the exiting panel inert and accessibility-hidden, restores focus, releases its body-scroll lock, and removes the panel when the transition finishes. Nested drawers and modals keep scrolling locked until the last dialog closes, and only the most recently opened one handles Escape and Tab. While scrolling is locked, the body is padded by the width of the scrollbar it hid, so layouts that measure their own width keep their breakpoints. Tests checking actual DOM removal should await it rather than expect immediate unmounting. Keep Drawer mounted while changing `isOpen` so it can animate its exit.
|
|
136
144
|
|
|
137
145
|
Side drawers have one outer border facing the page: the left border for a panel entering from the right, or the right border for one entering from the left. They have no outer top or bottom border. This applies to both variants and mirrors in RTL. Internal header/footer separators remain.
|
|
138
146
|
|
|
139
147
|
AppShell uses the shared `Drawer` with `variant="navigation"` and `side="end"`. For other navigation compositions, use the same variant for a compact width, header and footer. Drawer supports a React-node `title` and `closeLabel`; supply `aria-label` for a dialog name independent of its visual brand. By default the drawer portals to `document.body` and covers the viewport; for a navigation drawer, pass a positioned element as `portalContainer` to keep it inside that element. Default drawers retain their standard widths, shadow, and header/footer spacing. Both variants use the same slide, exit handling, and focus protection.
|
|
140
148
|
|
|
149
|
+
## Edit pages
|
|
150
|
+
|
|
151
|
+
`EditLayout` composes a sticky action bar, a centred unframed body and a Details
|
|
152
|
+
rail. Supply `backLabel`, `onBack`, `actions`, `rail` and body children. The layout
|
|
153
|
+
does not fetch, save, intercept navigation or persist preferences. Compose it
|
|
154
|
+
inside the existing main landmark; with AppShell, use `scrollMode="document"`
|
|
155
|
+
and `contentPadding="none"` so the window scrolls and navigation stays pinned.
|
|
156
|
+
Those AppShell options are opt-in; existing container scrolling/padding remain
|
|
157
|
+
the defaults.
|
|
158
|
+
|
|
159
|
+
`saveState` is `clean`, `dirty`, `saving`, `saved`, `error` or `offline`;
|
|
160
|
+
`savedAgo` optionally supplies the relative time. Control leave confirmation
|
|
161
|
+
with `confirmLeave`, `onKeepEditing` and `onLeave`. The consumer's router guard
|
|
162
|
+
decides when that confirmation appears.
|
|
163
|
+
|
|
164
|
+
Use `railOpen`/`onRailToggle` for controlled expansion or `defaultRailOpen` for
|
|
165
|
+
local state. `railCollapsed(expand)` can render alternative collapsed controls.
|
|
166
|
+
The `rail` slot accepts a React node or a render function receiving a callback
|
|
167
|
+
that closes the Details sheet before another dialog opens. Below 600px of the
|
|
168
|
+
layout's own width, Details opens from the action bar; at 600–899px it opens
|
|
169
|
+
from a collapsed rail; from 900px the rail follows preference. The layout
|
|
170
|
+
measures itself before its first paint. Only deliberate toggles animate. RTL
|
|
171
|
+
and reduced motion are supported. Override `--edit-sticky-top` if the
|
|
172
|
+
surrounding sticky header differs from `--topnav-height`.
|
|
173
|
+
|
|
174
|
+
Rail content mounts once and stays mounted while the rail collapses or moves
|
|
175
|
+
into the sheet, so uncontrolled fields keep what was typed. It renders on the
|
|
176
|
+
client, after hydration. When a breakpoint, a collapse or a closing sheet
|
|
177
|
+
removes the focused control, focus moves to the Details toggle that replaced
|
|
178
|
+
it.
|
|
179
|
+
|
|
141
180
|
## Image cropping
|
|
142
181
|
|
|
143
182
|
`ImageCropper` uses the library's custom engine with a fixed crop frame, diagonal background, shared `Slider` with a `Field` label/hint, and optional quarter-turn controls. Shared `Stack` components put the rotate/Reset buttons to the right of the zoom slider and wrap them below on narrow layouts. Supply one positive, finite `aspect` (width / height): `1` for an avatar, `16 / 9` for a cover, or `4 / 5` for a portrait.
|
|
@@ -249,14 +288,18 @@ npm run storybook
|
|
|
249
288
|
npm test
|
|
250
289
|
npm run test:coverage
|
|
251
290
|
npm run build
|
|
291
|
+
npm run lint
|
|
292
|
+
npm run format
|
|
252
293
|
npm run validate
|
|
253
294
|
```
|
|
254
295
|
|
|
296
|
+
`npm run lint` runs ESLint, Stylelint (`stylelint-config-standard` with the library's BEM class pattern) and a Prettier check. `npm run format` rewrites TypeScript, scripts and CSS to match. Prettier wraps at 100 characters and puts each JSX attribute on its own line once an element has more than one. Stylesheets use one declaration per line and nest an element's state variants under its block. The aggregate `src/styles.css` lists each component after the components it imports or overrides; a test enforces that order.
|
|
297
|
+
|
|
255
298
|
Storybook is the component catalogue and documentation surface. Stories and tests live beside each component in `src/components/<Family>/`.
|
|
256
299
|
|
|
257
300
|
## Publishing
|
|
258
301
|
|
|
259
|
-
Merge a PR into `main` to publish a release. Every push to `main` runs [the release workflow](.github/workflows/release.yml), which installs dependencies, bumps the
|
|
302
|
+
Merge a PR into `main` to publish a release. Every push to `main` runs [the release workflow](.github/workflows/release.yml), which installs dependencies, bumps the version, moves the `Unreleased` upgrade notes under that version, and runs `npm run validate`. It then commits the version files and guide back to `main` and publishes `@namroodinc/liquid-editorial` to npm under `latest`. All commands run in GitHub Actions; contributors do not run local release commands or create GitHub Releases or tags. Other branches and pull requests do not publish.
|
|
260
303
|
|
|
261
304
|
### One-time npm setup
|
|
262
305
|
|
|
@@ -278,7 +321,7 @@ npm requires two-factor verification for this setup. The workflow subsequently a
|
|
|
278
321
|
|
|
279
322
|
### Release a change
|
|
280
323
|
|
|
281
|
-
Add the change's adoption, compatibility, and verification notes under `Unreleased` in `UPGRADING.md`, then merge the PR to `main`. The workflow handles the version bump; for example, `0.1.4` becomes `0.1.5`. Pull the generated version commit before continuing local work.
|
|
324
|
+
Add the change's adoption, compatibility, and verification notes under `Unreleased` in `UPGRADING.md`, then merge the PR to `main`. The workflow handles the version bump; for example, `0.1.4` becomes `0.1.5`. When a change removes or renames public API, add a `### Breaking changes` section under `Unreleased` that lists it. The workflow then bumps the minor version below 1.0 (`0.1.11` becomes `0.2.0`) and the major version from 1.0, so caret ranges do not pick it up. Pull the generated version commit before continuing local work.
|
|
282
325
|
|
|
283
326
|
Follow **Publish to npm** in GitHub Actions to check the result. Runs are serialized, and the bot's version commit uses `GITHUB_TOKEN`, which does not trigger another workflow run.
|
|
284
327
|
|
package/UPGRADING.md
CHANGED
|
@@ -2,6 +2,114 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.2.1
|
|
6
|
+
|
|
7
|
+
### Edit layouts
|
|
8
|
+
|
|
9
|
+
Added the `external-link` icon for native links to original files.
|
|
10
|
+
|
|
11
|
+
Added `EditLayout`, `EditLayoutProps` and `EditSaveState` at the package root and
|
|
12
|
+
`components/EditLayout`. It composes a sticky action bar, unframed content and a
|
|
13
|
+
responsive Details rail. The consumer owns draft persistence, permissions,
|
|
14
|
+
navigation guards, shortcuts and stored rail preference. Use `railOpen` with
|
|
15
|
+
`onRailToggle` for controlled expansion, or `defaultRailOpen` for local state.
|
|
16
|
+
The optional `railCollapsed` render slot receives an expand callback; the `rail`
|
|
17
|
+
render slot receives a close callback for handing the Details sheet to another
|
|
18
|
+
dialog before opening it. Plain React-node rail content remains supported.
|
|
19
|
+
|
|
20
|
+
Supply `saveState` (`clean`, `dirty`, `saving`, `saved`, `error`, `offline`) and
|
|
21
|
+
optionally `savedAgo`. Leave confirmation is controlled with `confirmLeave`,
|
|
22
|
+
`onKeepEditing` and `onLeave`; the component does not intercept navigation.
|
|
23
|
+
At component widths below 600px, Details moves to an end drawer, at most 17rem
|
|
24
|
+
or 88% of the viewport wide; at 600–899px the rail is collapsed and opens that
|
|
25
|
+
drawer; from 900px it follows preference. The layout measures itself before its
|
|
26
|
+
first paint and re-renders only when it crosses one of these widths. Only
|
|
27
|
+
deliberate toggles animate. Below 360px, action-bar gaps and outer padding
|
|
28
|
+
contract to keep standard buttons within the editing column. Set
|
|
29
|
+
`--edit-sticky-top` on EditLayout when the surrounding sticky header differs
|
|
30
|
+
from `--topnav-height`.
|
|
31
|
+
|
|
32
|
+
Rail content mounts once and stays mounted across collapse, breakpoints and the
|
|
33
|
+
sheet, so uncontrolled fields keep their values. It renders on the client after
|
|
34
|
+
hydration, not in server HTML. When a resize, collapse or closing sheet removes
|
|
35
|
+
the focused control, focus moves to the Details toggle. EditLayout forwards
|
|
36
|
+
`onFocus` to the consumer.
|
|
37
|
+
|
|
38
|
+
AppShell adds `scrollMode="document"` and `contentPadding="none"`. Defaults
|
|
39
|
+
remain container scrolling and normal padding. Document mode makes navigation
|
|
40
|
+
sticky below the top bar and portals mobile navigation to the viewport with the
|
|
41
|
+
shell's `dir`. Pair the new options with EditLayout; preserve normal containers
|
|
42
|
+
for collection pages. The shell retains its 768px navigation breakpoint.
|
|
43
|
+
|
|
44
|
+
### Dialogs
|
|
45
|
+
|
|
46
|
+
Only the most recently opened Drawer or Modal handles Escape and Tab. A Modal or
|
|
47
|
+
Drawer opened above a Modal now closes on its own, where one Escape used to
|
|
48
|
+
close both. Closed dialog markup elsewhere on the page no longer blocks a
|
|
49
|
+
Drawer's keys. Drawer and Modal share scroll locking, so unmounting a nested
|
|
50
|
+
picker and its parent together restores the original body overflow in either
|
|
51
|
+
order.
|
|
52
|
+
|
|
53
|
+
While scrolling is locked, the body also gets `padding-right` equal to the width
|
|
54
|
+
of the classic scrollbar it hides (overlay scrollbars add nothing), and the
|
|
55
|
+
original padding returns on unlock. This keeps width-measuring layouts such as
|
|
56
|
+
AppShell and EditLayout from switching modes when a dialog opens. Give
|
|
57
|
+
right-anchored fixed elements the same compensation if they shift.
|
|
58
|
+
|
|
59
|
+
### Stylesheet order
|
|
60
|
+
|
|
61
|
+
The aggregate `styles.css` now lists each component after the components it
|
|
62
|
+
imports or overrides, instead of alphabetically, so composite rules win ties as
|
|
63
|
+
they already did with per-component imports. As a result, AppShell's desktop
|
|
64
|
+
navigation scrolls when it is taller than the viewport, and the navigation hides
|
|
65
|
+
below 768px without help. Remove consumer overrides that did either. Enabled
|
|
66
|
+
Board drag handles show `grab`; disabled and pending ones keep Button's cursor.
|
|
67
|
+
|
|
68
|
+
Shipped component CSS is reformatted, and the AppShell and EditLayout
|
|
69
|
+
stylesheets use native CSS nesting (Chrome 112, Safari 16.5 and Firefox 117 or
|
|
70
|
+
later, within the existing `:dir()` and `@starting-style` support). Bundlers
|
|
71
|
+
that lower nesting need no changes. No other rule changed.
|
|
72
|
+
|
|
73
|
+
### Verification
|
|
74
|
+
|
|
75
|
+
No runtime dependencies or removed APIs; Prettier and Stylelint are
|
|
76
|
+
development-only. Validate the packed package in consumers:
|
|
77
|
+
check responsive boundaries, document scrolling, save/error/offline status,
|
|
78
|
+
keyboard/focus handling, drawer handoffs, nested dialog Escape, RTL and reduced
|
|
79
|
+
motion. Check that pages using `styles.css` render as before and that no
|
|
80
|
+
right-anchored fixed elements shift when a dialog opens. Run library validation
|
|
81
|
+
and React 18/19 package smoke checks before publishing.
|
|
82
|
+
|
|
83
|
+
## 0.2.0
|
|
84
|
+
|
|
85
|
+
### Changes
|
|
86
|
+
|
|
87
|
+
- Replaced EntryEditor with FormEditor for content and general forms. Added select fields, per-field disabled state, read-only text, autofocus, email inputs, text limits, textarea rows, numeric limits/steps/steppers, React-node hints, responsive columns, and contextual asset/image picker wording.
|
|
88
|
+
- FormEditor reports each edit as `onValueChange(values, { fieldId })`. Asset/reference value shapes and existing scalar/rich-text/date behavior are unchanged. Persistence, choice loading, permissions, and dependent-field rules remain in the consuming application.
|
|
89
|
+
- Optional selects lead with an empty choice (the field's `placeholder`, or "None") that removes the key. Required selects set `aria-required`. Number steppers are named after their field, such as "Increase Width", and out-of-range numbers show their message on load.
|
|
90
|
+
- `validateFormValues` enforces text `maxLength` and multiple-picker `picker.max`. A non-string select value reports "Choose an available option.", and a select with an empty `options` array keeps its stored value valid while choices load. A select field without an `options` array throws a schema error.
|
|
91
|
+
- NumberField accepts `decreaseLabel` and `increaseLabel` for its stepper names. The defaults remain "Decrease" and "Increase".
|
|
92
|
+
|
|
93
|
+
### Breaking changes
|
|
94
|
+
|
|
95
|
+
- Removed `EntryEditor`, `EntryEditorProps`, `ContentModel`, `ContentField`, `EntryFieldValue`, `EntryValues`, `EntryErrors`, and `validateEntryValues` from the package root, and the `components/EntryEditor` subpath. There are no aliases.
|
|
96
|
+
- The editor's `model` prop is now `schema`, and its CSS hook is `.ds-form-editor` instead of `.ds-entry-editor`.
|
|
97
|
+
- This release is published as 0.2.0, so `^0.1.x` ranges do not install it automatically.
|
|
98
|
+
|
|
99
|
+
### Adoption
|
|
100
|
+
|
|
101
|
+
Import `FormEditor`, `FormEditorProps`, `FormSchema`, `FormField`, `FormFieldValue`, `FormValues`, `FormErrors`, `FormChange`, and `validateFormValues` from the package root or `components/FormEditor`. Replace EntryEditor, ContentModel, ContentField, EntryFieldValue, EntryValues, EntryErrors, and validateEntryValues accordingly. Change the component's `model` prop to `schema` and CSS hooks from `.ds-entry-editor` to `.ds-form-editor`. `columns` sets the most columns, defaulting to one; the form drops a column whenever a field would be narrower than `minColumnWidth` (default `16rem`). Use `columns="auto"` to fit as many as the width allows. Existing one-argument callbacks may continue to ignore change metadata; use `fieldId` when only edited fields should be sent to an API.
|
|
102
|
+
|
|
103
|
+
For selects, use `{ type: "select", options: [{ value, label }] }` and store strings. Pass `options: []` while choices load, and a placeholder such as "Loading roles…". Field definitions accept `isDisabled`; short/long text support `readOnly` and `maxLength`; short text supports `inputType: "email"`; long text supports `rows`; numbers support `min`, `max`, `step`, and `hasSteppers`. `autoFocus` applies to text, number, select, boolean, and date fields. Pass asset/reference choices through `pickerItems` and picker copy through the field's `picker` options (`itemLabel`, `itemsLabel`, `label`, `addLabel`, `emptyLabel`); omitted or `undefined` options keep the asset or entry wording. Rich hints and loading messages are React values, so keep runtime form schemas separate from persisted content-model DTOs. Schema definitions do not fetch data. Define schemas outside render, or memoize them, so per-field validation is reused between keystrokes.
|
|
104
|
+
|
|
105
|
+
### Compatibility
|
|
106
|
+
|
|
107
|
+
AssetValue and ReferenceValue remain available. Select fields are UI configuration; consuming CMS APIs do not automatically gain new content field types. FormEditor is not a Grid: it carries no `ds-grid*` classes or container query and sizes its columns against its own width, so it also keeps its content width in flex rows and popovers. `autoFocus` is a type error on rich-text, asset, and reference fields. Loaded text over `maxLength` or lists over `picker.max` now fail `validateFormValues`. No dependencies are added. The release workflow owns the version increment; a `### Breaking changes` section makes it a minor bump below 1.0.
|
|
108
|
+
|
|
109
|
+
### Verification
|
|
110
|
+
|
|
111
|
+
Run consuming-project typechecks, tests, and builds against the packed build. Check every migrated form's save rules, read-only access, explicit clears, generated IDs, dependent fields, and nested pickers. Confirm touched-field patches use change metadata and do not overwrite concurrent changes. Check labels/hints/errors, select keyboard controls and clearing, single/multiple asset selection, numeric bounds and stepper names, rich text and UTC dates, columns in drawers and narrow containers, and disabled/read-only controls. Re-run pre-save validation against stored data for text and picker limits. Update tests that query FormEditor steppers as "Increase" or "Decrease". The FormEditor stories demonstrate entry and general forms. Run library validation and package checks for React 18 and 19 before publishing.
|
|
112
|
+
|
|
5
113
|
## 0.1.11
|
|
6
114
|
|
|
7
115
|
### Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./Icon-
|
|
2
|
-
//# sourceMappingURL=Board-
|
|
1
|
+
const e=require("./Icon-CW6qJcDy.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-BUJ5CinL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Board-BUJ5CinL.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) return;\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)) return;\n return { columnId: String(active.id), toIndex };\n}\n\nexport function cardMove({ active, over }: DragEndEvent): BoardMove | undefined {\n if (!over) return;\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) return;\n if (fromColumnId === toColumnId && String(active.id) === String(over.id)) return;\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) return undefined;\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) return undefined;\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) return closestCorners(scoped);\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) return;\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) onColumnMove?.(move);\n } else {\n const move = cardMove(event);\n if (move) onMove?.(move);\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,EAAM,OACX,IAAMC,EAAOD,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,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,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./Icon-
|
|
1
|
+
import { t as e } from "./Icon-ByUB0L1a.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-Cyrda2qG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Board-Cyrda2qG.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) return;\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)) return;\n return { columnId: String(active.id), toIndex };\n}\n\nexport function cardMove({ active, over }: DragEndEvent): BoardMove | undefined {\n if (!over) return;\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) return;\n if (fromColumnId === toColumnId && String(active.id) === String(over.id)) return;\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) return undefined;\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) return undefined;\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) return closestCorners(scoped);\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) return;\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) onColumnMove?.(move);\n } else {\n const move = cardMove(event);\n if (move) onMove?.(move);\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,GAAM;CACX,IAAMC,IAAOD,EAAK,KAAK,WAAW,CAAC,GA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BlB,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAChE,iBAAemB,KAAc,KAAA;EAC7B,aAAW3C,KAAYA,MAAaR,IAAK,KAAK,KAAA;EAC9C,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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../components/Field/index.cjs"),t=require("../components/TextField/index.cjs"),n=require("./RichTextEditor-BxtlbjXj.cjs"),r=require("../components/EntryPicker/index.cjs"),i=require("../components/NumberField/index.cjs"),a=require("../components/Select/index.cjs"),o=require("../components/Switch/index.cjs");let s=require("react"),c=require("react/jsx-runtime");var l=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`,`select`]);function u(e){let t=new Set;for(let n of e.fields){if(!n.id?.trim()||t.has(n.id))throw Error(`Form field IDs must be nonempty and unique.`);if(!l.has(n.type))throw Error(`Unsupported form field type: ${n.type}`);if(n.type===`select`&&!Array.isArray(n.options))throw Error(`Select field ${n.id} needs an options array.`);t.add(n.id)}}var d={asset:{key:`assetId`,label:`Assets`,itemLabel:`asset`,itemsLabel:`assets`},reference:{key:`entryId`,label:`Entries`,itemLabel:`entry`,itemsLabel:`entries`}};function f(e){let t=d[e.type],{label:n=t.label,addLabel:r=`Choose ${e.label}`,itemLabel:i=t.itemLabel,itemsLabel:a=t.itemsLabel,...o}=e.picker??{};return{...o,label:n,addLabel:r,itemLabel:i,itemsLabel:a}}function p(e){if(typeof e!=`string`)return;let t=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);if(!t)return;let n=`${t[1]}:${t[2]??`00`}.${(t[3]??``).padEnd(3,`0`)}Z`,r=new Date(n);if(Number.isFinite(r.getTime())&&r.toISOString()===n)return n}function m(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function h(e){return!!e.text?.trim()||e.type===`horizontalRule`||!!e.content?.some(h)}function g(e){return`${e.label} is required.`}function _(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return g(e);if((e.type===`shortText`||e.type===`longText`)&&e.maxLength!==void 0&&t.length>e.maxLength)return`Enter no more than ${e.maxLength} characters.`}function v(e,t){let r=n.n(t);if(r)return r;if(e.required&&!h(t))return g(e)}function y(e,t){if(typeof t!=`string`)return`Choose an available option.`;if(t===``)return e.required?g(e):void 0;if(e.type===`select`&&e.options.length>0&&!e.options.some(e=>e.value===t))return`Choose an available option.`}function b(e,t){if(e.type!==`asset`&&e.type!==`reference`)return;let{key:n,itemLabel:r,itemsLabel:i}=d[e.type];if(!e.multiple)return m(t,n)?void 0:`Choose an ${r}.`;if(!Array.isArray(t)||!t.every(e=>m(e,n)))return`Choose a list of ${i}.`;if(e.required&&t.length===0)return g(e);let a=e.picker?.max;if(a!==void 0&&t.length>a)return`Choose no more than ${a} ${f(e).itemsLabel}.`}var x={shortText:_,longText:_,richText:v,number:(e,t)=>{if(typeof t!=`number`||!Number.isFinite(t))return`Enter a finite number.`;if(e.type===`number`){if(e.min!==void 0&&t<e.min)return`Enter a number of at least ${e.min}.`;if(e.max!==void 0&&t>e.max)return`Enter a number no greater than ${e.max}.`}},boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>p(t)?void 0:`Enter a valid UTC date and time.`,select:y,asset:b,reference:b};function S(e,t){return t===void 0?e.required?g(e):void 0:x[e.type](e,t)}function C(e,t){return u(e),Object.fromEntries(e.fields.flatMap(e=>{let n=S(e,Object.hasOwn(t,e.id)?t[e.id]:void 0);return n?[[e.id,n]]:[]}))}function w(e,t){let n=e.type===`asset`?`assetId`:`entryId`;return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>{if(!e||typeof e!=`object`||!(n in e))return[];let t=e[n];return typeof t==`string`?[t]:[]})}function T(e,t){if(e.type===`asset`){let n=t.map(e=>({assetId:e}));return e.multiple?n:n[0]}let n=t.map(e=>({entryId:e}));return e.multiple?n:n[0]}function E({field:e,stored:t,isDisabled:n,required:r,accessibility:a,onChange:o}){return(0,c.jsx)(i.NumberField,{...a,required:r,isDisabled:n,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step??`any`,hasSteppers:e.hasSteppers??!1,autoFocus:e.autoFocus,decreaseLabel:`Decrease ${e.label}`,increaseLabel:`Increase ${e.label}`,value:typeof t==`number`&&Number.isFinite(t)?t:``,onValueChange:e=>{(e===``||Number.isFinite(e))&&o(e===``?void 0:e)}})}function D({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:o}){let s=!r&&!e.options.some(e=>e.value===``);return(0,c.jsx)(a.Select,{...i,"aria-required":r||void 0,isDisabled:n,isInvalid:i[`aria-invalid`],options:s?[{value:``,label:e.placeholder??`None`},...e.options]:e.options,placeholder:e.placeholder,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onValueChange:e=>o(e===``?void 0:e)})}function O({field:e,stored:t,items:n,isDisabled:i,accessibility:a,onChange:o}){return(0,c.jsx)(`div`,{...a,role:`group`,children:(0,c.jsx)(r.EntryPicker,{items:n,value:w(e,t),...f(e),mode:e.multiple?`multiple`:`single`,isDisabled:i,onValueChange:t=>o(T(e,t))})})}function k({field:e,stored:r,items:i,isDisabled:a,accessibility:{required:s,...l},onChange:u}){let d={stored:r,isDisabled:a,required:s,accessibility:l,onChange:u};switch(e.type){case`shortText`:return(0,c.jsx)(t.TextField,{...l,required:s,disabled:a,placeholder:e.placeholder,type:e.inputType,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:typeof r==`string`?r:``,onChange:e=>u(e.target.value)});case`longText`:return(0,c.jsx)(t.TextArea,{...l,required:s,disabled:a,placeholder:e.placeholder,rows:e.rows,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:typeof r==`string`?r:``,onChange:e=>u(e.target.value)});case`number`:return(0,c.jsx)(E,{field:e,...d});case`boolean`:return(0,c.jsx)(o.Switch,{...l,isDisabled:a,autoFocus:e.autoFocus,isSelected:r===!0,onSelectedChange:u});case`dateTime`:return(0,c.jsx)(t.TextField,{...l,required:s,disabled:a,type:`datetime-local`,step:`0.001`,autoFocus:e.autoFocus,value:p(r)?.slice(0,-1)??``,onChange:e=>u(p(`${e.target.value}Z`))});case`richText`:return(0,c.jsx)(n.t,{...l,label:e.label,isRequired:s,isDisabled:a,placeholder:e.placeholder,format:`json`,value:r===void 0?n.r:r,onChange:u});case`select`:return(0,c.jsx)(D,{field:e,...d});case`asset`:case`reference`:return(0,c.jsx)(O,{field:e,items:i,...d})}}function A({field:t,stored:n,items:r,isDisabled:i,error:a,isErrorVisible:o,onChange:l}){let u=(0,s.useMemo)(()=>a===void 0&&o?S(t,n):void 0,[a,o,t,n]),d=t.type===`dateTime`?`${t.label} (UTC)`:t.label;return(0,c.jsx)(e.Field,{label:d,hint:t.hint,error:a??u,isRequired:t.required,isGroup:t.type===`asset`||t.type===`reference`,children:e=>(0,c.jsx)(k,{field:t,stored:n,items:r,isDisabled:i,accessibility:e,onChange:l})})}function j({schema:e,value:t,defaultValue:n={},onValueChange:r,pickerItems:i={},errors:a={},isDisabled:o=!1,showAllErrors:l=!1,columns:d=1,minColumnWidth:f=`16rem`,className:p,style:m,...h}){let[g,_]=(0,s.useState)(n),[v,y]=(0,s.useState)(()=>new Set),b=t??g;(0,s.useMemo)(()=>u(e),[e]);let x=(e,n)=>{let i={...b};n===void 0?delete i[e]:i[e]=n,t===void 0&&_(i),y(t=>new Set(t).add(e)),r?.(i,{fieldId:e})},S=d===`auto`?{"--form-editor-min-column":f}:{"--form-editor-columns":d,"--form-editor-min-column":f};return(0,c.jsx)(`div`,{className:[`ds-form-editor`,d===`auto`&&`ds-form-editor--auto`,p].filter(Boolean).join(` `),style:{...S,...m},...h,children:e.fields.map(e=>{let t=Object.hasOwn(b,e.id)?b[e.id]:void 0,n=o||!!e.isDisabled,r=n||`readOnly`in e&&!!e.readOnly,s=l||v.has(e.id)||e.type===`number`&&typeof t==`number`;return(0,c.jsx)(A,{field:e,stored:t,items:i[e.id]??[],isDisabled:n,error:a[e.id],isErrorVisible:s,onChange:t=>{r||x(e.id,t)}},e.id)})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return j}});
|
|
2
|
+
//# sourceMappingURL=FormEditor-8bz3pOdP.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormEditor-8bz3pOdP.cjs","names":["documentError","NumberField","Select","EntryPicker","TextField","TextArea","Switch","RichTextEditor","emptyDocument","useMemo","Field","useState","require_components_Field_index","require_components_TextField_index","require_RichTextEditor","require_components_EntryPicker_index","require_components_NumberField_index","require_components_Select_index","require_components_Switch_index","react","react_jsx_runtime","fieldTypes","assertModel","ids","field","model","linkCopy","pickerCopy","defaults","rest","parseUtcDateTime","value","match","canonical","date","isLink","key","hasRichText","node","requiredError","textError","richTextError","error","choiceError","option","linkError","itemLabel","item","itemsLabel","max","validators","fieldError","validateFormValues","values","selectedIds","link","id","pickerValue","links","NumberControl","accessibility","stored","next","onChange","SelectControl","isClearable","required","PickerControl","FormControl","shared","isDisabled","event","FormEditorField","validation","isErrorVisible","label","FormEditor","internal","setInternal","defaultValue","changed","setChanged","current","schema","commit","fieldId","previous","onValueChange","layout","columns","minColumnWidth","className","style","fieldDisabled","isLocked","showAllErrors","pickerItems","errors"],"sources":["../../src/components/FormEditor/model.ts","../../src/components/FormEditor/control.tsx","../../src/components/FormEditor/index.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { SelectOption } from \"../Select\";\nimport type { EntryPickerProps } from \"../EntryPicker\";\nimport type { JSONContent } from \"@tiptap/react\";\nimport { documentError } from \"../RichTextEditor/document\";\nimport type { RichTextDocument } from \"../RichTextEditor\";\n\ninterface FormFieldBase {\n id: string;\n label: string;\n hint?: ReactNode;\n placeholder?: string;\n required?: boolean;\n isDisabled?: boolean;\n}\n\nexport type FormField = FormFieldBase &\n (\n | {\n type: \"shortText\";\n inputType?: \"text\" | \"email\";\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n }\n | {\n type: \"longText\";\n rows?: number;\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n }\n | { type: \"boolean\" | \"dateTime\"; autoFocus?: boolean; multiple?: never }\n | { type: \"richText\"; autoFocus?: never; multiple?: never }\n | {\n type: \"number\";\n min?: number;\n max?: number;\n step?: number | \"any\";\n hasSteppers?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n }\n | { type: \"select\"; options: SelectOption[]; autoFocus?: boolean; multiple?: never }\n | {\n type: \"asset\" | \"reference\";\n multiple?: boolean;\n autoFocus?: never;\n picker?: Pick<\n EntryPickerProps,\n \"label\" | \"addLabel\" | \"emptyLabel\" | \"itemLabel\" | \"itemsLabel\" | \"max\" | \"isReorderable\"\n >;\n }\n );\n\nexport type FieldOf<T extends FormField[\"type\"]> = Extract<FormField, { type: T }>;\n\nexport interface FormSchema {\n fields: readonly FormField[];\n}\n\nexport interface AssetValue {\n assetId: string;\n}\nexport interface ReferenceValue {\n entryId: string;\n}\nexport type FormFieldValue =\n | string\n | number\n | boolean\n | RichTextDocument\n | AssetValue\n | ReferenceValue\n | AssetValue[]\n | ReferenceValue[];\nexport type FormValues = Record<string, FormFieldValue | undefined>;\nexport type FormErrors = Partial<Record<string, string>>;\n\nconst fieldTypes = new Set([\n \"shortText\",\n \"longText\",\n \"richText\",\n \"number\",\n \"boolean\",\n \"dateTime\",\n \"asset\",\n \"reference\",\n \"select\",\n]);\n\nexport function assertModel(model: FormSchema) {\n const ids = new Set<string>();\n for (const field of model.fields) {\n if (!field.id?.trim() || ids.has(field.id))\n throw new Error(\"Form field IDs must be nonempty and unique.\");\n if (!fieldTypes.has(field.type)) throw new Error(`Unsupported form field type: ${field.type}`);\n if (field.type === \"select\" && !Array.isArray(field.options))\n throw new Error(`Select field ${field.id} needs an options array.`);\n ids.add(field.id);\n }\n}\n\nconst linkCopy = {\n asset: { key: \"assetId\", label: \"Assets\", itemLabel: \"asset\", itemsLabel: \"assets\" },\n reference: { key: \"entryId\", label: \"Entries\", itemLabel: \"entry\", itemsLabel: \"entries\" },\n} as const;\n\n/** Picker copy, with asset or entry wording for any option the field leaves out or sets to undefined. */\nexport function pickerCopy(field: FieldOf<\"asset\" | \"reference\">) {\n const defaults = linkCopy[field.type];\n const {\n label = defaults.label,\n addLabel = `Choose ${field.label}`,\n itemLabel = defaults.itemLabel,\n itemsLabel = defaults.itemsLabel,\n ...rest\n } = field.picker ?? {};\n return { ...rest, label, addLabel, itemLabel, itemsLabel };\n}\n\n/** Accept UTC ISO strings without rolling invalid dates into the next month. */\nexport function parseUtcDateTime(value: unknown): string | undefined {\n if (typeof value !== \"string\") return;\n const match = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?(?:Z|\\+00:00)$/.exec(\n value,\n );\n if (!match) return;\n const canonical = `${match[1]}:${match[2] ?? \"00\"}.${(match[3] ?? \"\").padEnd(3, \"0\")}Z`;\n const date = new Date(canonical);\n if (Number.isFinite(date.getTime()) && date.toISOString() === canonical) return canonical;\n}\n\nfunction isLink(value: unknown, key: \"assetId\" | \"entryId\"): boolean {\n return (\n !!value &&\n typeof value === \"object\" &&\n key in value &&\n typeof (value as Record<string, unknown>)[key] === \"string\" &&\n (value as Record<string, string>)[key].trim().length > 0\n );\n}\n\nfunction hasRichText(node: JSONContent): boolean {\n return !!node.text?.trim() || node.type === \"horizontalRule\" || !!node.content?.some(hasRichText);\n}\n\nfunction requiredError(field: FormField): string {\n return `${field.label} is required.`;\n}\n\nfunction textError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") return \"Enter text.\";\n if (field.required && !value.trim()) return requiredError(field);\n if (\n (field.type === \"shortText\" || field.type === \"longText\") &&\n field.maxLength !== undefined &&\n value.length > field.maxLength\n ) {\n return `Enter no more than ${field.maxLength} characters.`;\n }\n}\n\nfunction richTextError(field: FormField, value: unknown): string | undefined {\n const error = documentError(value);\n if (error) return error;\n if (field.required && !hasRichText(value as RichTextDocument)) return requiredError(field);\n}\n\nfunction choiceError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") return \"Choose an available option.\";\n if (value === \"\") return field.required ? requiredError(field) : undefined;\n // An empty list means the choices are still loading, so a stored value stays valid until they arrive.\n if (\n field.type === \"select\" &&\n field.options.length > 0 &&\n !field.options.some((option) => option.value === value)\n ) {\n return \"Choose an available option.\";\n }\n}\n\nfunction linkError(field: FormField, value: unknown): string | undefined {\n if (field.type !== \"asset\" && field.type !== \"reference\") return;\n const { key, itemLabel, itemsLabel } = linkCopy[field.type];\n if (!field.multiple) return isLink(value, key) ? undefined : `Choose an ${itemLabel}.`;\n if (!Array.isArray(value) || !value.every((item) => isLink(item, key)))\n return `Choose a list of ${itemsLabel}.`;\n if (field.required && value.length === 0) return requiredError(field);\n const max = field.picker?.max;\n if (max !== undefined && value.length > max)\n return `Choose no more than ${max} ${pickerCopy(field).itemsLabel}.`;\n}\n\nconst validators: Record<\n FormField[\"type\"],\n (field: FormField, value: unknown) => string | undefined\n> = {\n shortText: textError,\n longText: textError,\n richText: richTextError,\n number: (field, value) => {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return \"Enter a finite number.\";\n if (field.type !== \"number\") return;\n if (field.min !== undefined && value < field.min)\n return `Enter a number of at least ${field.min}.`;\n if (field.max !== undefined && value > field.max)\n return `Enter a number no greater than ${field.max}.`;\n },\n boolean: (_field, value) => (typeof value === \"boolean\" ? undefined : \"Choose a boolean value.\"),\n dateTime: (_field, value) =>\n parseUtcDateTime(value) ? undefined : \"Enter a valid UTC date and time.\",\n select: choiceError,\n asset: linkError,\n reference: linkError,\n};\n\nexport function fieldError(field: FormField, value: unknown): string | undefined {\n if (value === undefined) return field.required ? requiredError(field) : undefined;\n return validators[field.type](field, value);\n}\n\n/** Validate data loaded from JSON as well as values emitted by FormEditor. */\nexport function validateFormValues(model: FormSchema, values: Record<string, unknown>): FormErrors {\n assertModel(model);\n return Object.fromEntries(\n model.fields.flatMap((field): [string, string][] => {\n const error = fieldError(\n field,\n Object.hasOwn(values, field.id) ? values[field.id] : undefined,\n );\n return error ? [[field.id, error]] : [];\n }),\n );\n}\n","import { EntryPicker, type EntryItem } from \"../EntryPicker\";\nimport type { FieldProps } from \"../Field\";\nimport { NumberField } from \"../NumberField\";\nimport { RichTextEditor, type RichTextDocument } from \"../RichTextEditor\";\nimport { emptyDocument } from \"../RichTextEditor/document\";\nimport { Select } from \"../Select\";\nimport { Switch } from \"../Switch\";\nimport { TextArea, TextField } from \"../TextField\";\nimport {\n parseUtcDateTime,\n pickerCopy,\n type FieldOf,\n type FormField,\n type FormFieldValue,\n} from \"./model\";\n\nfunction selectedIds(field: FormField, value: FormFieldValue | undefined): string[] {\n const key = field.type === \"asset\" ? \"assetId\" : \"entryId\";\n const links = Array.isArray(value) ? value : value === undefined ? [] : [value];\n return links.flatMap((link) => {\n if (!link || typeof link !== \"object\" || !(key in link)) return [];\n const id = (link as unknown as Record<string, unknown>)[key];\n return typeof id === \"string\" ? [id] : [];\n });\n}\n\nfunction pickerValue(field: FormField, ids: string[]): FormFieldValue | undefined {\n if (field.type === \"asset\") {\n const links = ids.map((assetId) => ({ assetId }));\n return field.multiple ? links : links[0];\n }\n const links = ids.map((entryId) => ({ entryId }));\n return field.multiple ? links : links[0];\n}\n\ntype Accessibility = Parameters<FieldProps[\"children\"]>[0];\n\ninterface ControlProps<F extends FormField> {\n field: F;\n stored: FormFieldValue | undefined;\n isDisabled: boolean;\n required: boolean | undefined;\n accessibility: Omit<Accessibility, \"required\">;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nfunction NumberControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"number\">>) {\n return (\n <NumberField\n {...accessibility}\n required={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n step={field.step ?? \"any\"}\n hasSteppers={field.hasSteppers ?? false}\n autoFocus={field.autoFocus}\n decreaseLabel={`Decrease ${field.label}`}\n increaseLabel={`Increase ${field.label}`}\n value={typeof stored === \"number\" && Number.isFinite(stored) ? stored : \"\"}\n onValueChange={(next) => {\n if (next === \"\" || Number.isFinite(next)) onChange(next === \"\" ? undefined : next);\n }}\n />\n );\n}\n\nfunction SelectControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"select\">>) {\n // Optional selects lead with an empty choice; picking it removes the key.\n const isClearable = !required && !field.options.some((option) => option.value === \"\");\n return (\n <Select\n {...accessibility}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n isInvalid={accessibility[\"aria-invalid\"]}\n options={\n isClearable\n ? [{ value: \"\", label: field.placeholder ?? \"None\" }, ...field.options]\n : field.options\n }\n placeholder={field.placeholder}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n}\n\nfunction PickerControl({\n field,\n stored,\n items,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"asset\" | \"reference\">> & { items: EntryItem[] }) {\n return (\n <div\n {...accessibility}\n role=\"group\"\n >\n <EntryPicker\n items={items}\n value={selectedIds(field, stored)}\n {...pickerCopy(field)}\n mode={field.multiple ? \"multiple\" : \"single\"}\n isDisabled={isDisabled}\n onValueChange={(ids) => onChange(pickerValue(field, ids))}\n />\n </div>\n );\n}\n\ninterface FormControlProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n accessibility: Accessibility;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nexport function FormControl({\n field,\n stored,\n items,\n isDisabled,\n accessibility: { required, ...accessibility },\n onChange,\n}: FormControlProps) {\n const shared = { stored, isDisabled, required, accessibility, onChange };\n switch (field.type) {\n case \"shortText\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n type={field.inputType}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"longText\":\n return (\n <TextArea\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n rows={field.rows}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"number\":\n return (\n <NumberControl\n field={field}\n {...shared}\n />\n );\n case \"boolean\":\n return (\n <Switch\n {...accessibility}\n isDisabled={isDisabled}\n autoFocus={field.autoFocus}\n isSelected={stored === true}\n onSelectedChange={onChange}\n />\n );\n case \"dateTime\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n type=\"datetime-local\"\n step=\"0.001\"\n autoFocus={field.autoFocus}\n value={parseUtcDateTime(stored)?.slice(0, -1) ?? \"\"}\n onChange={(event) => onChange(parseUtcDateTime(`${event.target.value}Z`))}\n />\n );\n case \"richText\":\n return (\n <RichTextEditor\n {...accessibility}\n label={field.label}\n isRequired={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n format=\"json\"\n value={stored === undefined ? emptyDocument : (stored as RichTextDocument)}\n onChange={onChange}\n />\n );\n case \"select\":\n return (\n <SelectControl\n field={field}\n {...shared}\n />\n );\n case \"asset\":\n case \"reference\":\n return (\n <PickerControl\n field={field}\n items={items}\n {...shared}\n />\n );\n }\n}\n","import { useMemo, useState, type CSSProperties, type HTMLAttributes } from \"react\";\nimport type { EntryItem } from \"../EntryPicker\";\nimport { Field } from \"../Field\";\nimport type { GridColumns } from \"../Grid\";\nimport { FormControl } from \"./control\";\nimport {\n assertModel,\n fieldError,\n type FormField,\n type FormSchema,\n type FormErrors,\n type FormFieldValue,\n type FormValues,\n} from \"./model\";\nimport \"./style.css\";\n\nexport { validateFormValues } from \"./model\";\nexport type {\n AssetValue,\n FormField,\n FormSchema,\n FormErrors,\n FormFieldValue,\n FormValues,\n ReferenceValue,\n} from \"./model\";\n\nexport interface FormChange {\n fieldId: string;\n}\n\nexport interface FormEditorProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"defaultValue\" | \"onChange\"\n> {\n schema: FormSchema;\n value?: FormValues;\n defaultValue?: FormValues;\n onValueChange?: (values: FormValues, change: FormChange) => void;\n /** Available assets or entries, keyed by field ID. Loading belongs to the app. */\n pickerItems?: Record<string, EntryItem[]>;\n /** App-provided messages take precedence over built-in validation. */\n errors?: FormErrors;\n isDisabled?: boolean;\n showAllErrors?: boolean;\n /** Columns at the widest. The form drops one whenever a field would be narrower than `minColumnWidth`. */\n columns?: GridColumns;\n /** Narrowest a field may get before the form drops a column. */\n minColumnWidth?: string;\n}\n\ninterface FormEditorFieldProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n error: string | undefined;\n isErrorVisible: boolean;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\n/** Validates only when its message can show, and only when its own field or value changes. */\nfunction FormEditorField({\n field,\n stored,\n items,\n isDisabled,\n error,\n isErrorVisible,\n onChange,\n}: FormEditorFieldProps) {\n const validation = useMemo(\n () => (error === undefined && isErrorVisible ? fieldError(field, stored) : undefined),\n [error, isErrorVisible, field, stored],\n );\n const label = field.type === \"dateTime\" ? `${field.label} (UTC)` : field.label;\n return (\n <Field\n label={label}\n hint={field.hint}\n error={error ?? validation}\n isRequired={field.required}\n isGroup={field.type === \"asset\" || field.type === \"reference\"}\n >\n {(accessibility) => (\n <FormControl\n field={field}\n stored={stored}\n items={items}\n isDisabled={isDisabled}\n accessibility={accessibility}\n onChange={onChange}\n />\n )}\n </Field>\n );\n}\n\n/** Ordered form controls. Loading, submission, and persistence belong to the app. */\nexport function FormEditor({\n schema,\n value,\n defaultValue = {},\n onValueChange,\n pickerItems = {},\n errors = {},\n isDisabled = false,\n showAllErrors = false,\n columns = 1,\n minColumnWidth = \"16rem\",\n className,\n style,\n ...rest\n}: FormEditorProps) {\n const [internal, setInternal] = useState<FormValues>(defaultValue);\n const [changed, setChanged] = useState<Set<string>>(() => new Set());\n const current = value ?? internal;\n useMemo(() => assertModel(schema), [schema]);\n\n const commit = (fieldId: string, next: FormFieldValue | undefined) => {\n const values = { ...current };\n if (next === undefined) delete values[fieldId];\n else values[fieldId] = next;\n if (value === undefined) setInternal(values);\n setChanged((previous) => new Set(previous).add(fieldId));\n onValueChange?.(values, { fieldId });\n };\n\n const layout =\n columns === \"auto\"\n ? { \"--form-editor-min-column\": minColumnWidth }\n : { \"--form-editor-columns\": columns, \"--form-editor-min-column\": minColumnWidth };\n\n return (\n <div\n className={[\"ds-form-editor\", columns === \"auto\" && \"ds-form-editor--auto\", className]\n .filter(Boolean)\n .join(\" \")}\n style={{ ...layout, ...style } as CSSProperties}\n {...rest}\n >\n {schema.fields.map((field) => {\n const stored = Object.hasOwn(current, field.id) ? current[field.id] : undefined;\n const fieldDisabled = isDisabled || Boolean(field.isDisabled);\n const isLocked = fieldDisabled || (\"readOnly\" in field && Boolean(field.readOnly));\n // NumberField marks an out-of-range number invalid itself, so its message shows straight away.\n const isErrorVisible =\n showAllErrors ||\n changed.has(field.id) ||\n (field.type === \"number\" && typeof stored === \"number\");\n return (\n <FormEditorField\n key={field.id}\n field={field}\n stored={stored}\n items={pickerItems[field.id] ?? []}\n isDisabled={fieldDisabled}\n error={errors[field.id]}\n isErrorVis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