@namroodinc/liquid-editorial 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -12
- package/UPGRADING.md +106 -0
- package/dist/chunks/{Avatar-Dw7EWd_-.cjs → Avatar-BZGFSE6C.cjs} +2 -2
- package/dist/chunks/{Avatar-Dw7EWd_-.cjs.map → Avatar-BZGFSE6C.cjs.map} +1 -1
- package/dist/chunks/{Avatar-BToMaTdL.js → Avatar-C4W-g8nU.js} +2 -2
- package/dist/chunks/{Avatar-BToMaTdL.js.map → Avatar-C4W-g8nU.js.map} +1 -1
- package/dist/chunks/{Board-XeDG9nWP.js → Board-Cbi5FMW-.js} +2 -2
- package/dist/chunks/{Board-XeDG9nWP.js.map → Board-Cbi5FMW-.js.map} +1 -1
- package/dist/chunks/{Board-DeXtaWNO.cjs → Board-_agEjTy8.cjs} +2 -2
- package/dist/chunks/{Board-DeXtaWNO.cjs.map → Board-_agEjTy8.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-Dbg4d_tA.cjs → CollectionView-BfX2Lxre.cjs} +2 -2
- package/dist/chunks/{CollectionView-Dbg4d_tA.cjs.map → CollectionView-BfX2Lxre.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-C0_bTO2v.js → CollectionView-DPJGtSP5.js} +2 -2
- package/dist/chunks/{CollectionView-C0_bTO2v.js.map → CollectionView-DPJGtSP5.js.map} +1 -1
- package/dist/chunks/{ColourField-DAFzOIOq.cjs → ColourField-BVGnW8Wh.cjs} +2 -2
- package/dist/chunks/{ColourField-DAFzOIOq.cjs.map → ColourField-BVGnW8Wh.cjs.map} +1 -1
- package/dist/chunks/{ColourField-Bb8H87fg.js → ColourField-BcuARZY4.js} +6 -6
- package/dist/chunks/{ColourField-Bb8H87fg.js.map → ColourField-BcuARZY4.js.map} +1 -1
- package/dist/chunks/{DatePicker-COm1giw8.js → DatePicker-VQUsbYdo.js} +3 -3
- package/dist/chunks/{DatePicker-COm1giw8.js.map → DatePicker-VQUsbYdo.js.map} +1 -1
- package/dist/chunks/{DatePicker-DOg3iQYy.cjs → DatePicker-zA0bWVBp.cjs} +2 -2
- package/dist/chunks/{DatePicker-DOg3iQYy.cjs.map → DatePicker-zA0bWVBp.cjs.map} +1 -1
- package/dist/chunks/{Drawer-nUTJtwX_.js → Drawer-2cf0SaG4.js} +3 -3
- package/dist/chunks/{Drawer-nUTJtwX_.js.map → Drawer-2cf0SaG4.js.map} +1 -1
- package/dist/chunks/{Drawer-B2dcTh5l.cjs → Drawer-BzvSfkCL.cjs} +2 -2
- package/dist/chunks/{Drawer-B2dcTh5l.cjs.map → Drawer-BzvSfkCL.cjs.map} +1 -1
- package/dist/chunks/EntryPicker-C7EBfpaw.cjs +2 -0
- package/dist/chunks/EntryPicker-C7EBfpaw.cjs.map +1 -0
- package/dist/chunks/{EntryPicker-Ie9T47hA.js → EntryPicker-DBnDsgzi.js} +397 -397
- package/dist/chunks/EntryPicker-DBnDsgzi.js.map +1 -0
- package/dist/chunks/FormEditor-BG8bOXI8.js +35 -0
- package/dist/chunks/FormEditor-BG8bOXI8.js.map +1 -0
- package/dist/chunks/FormEditor-BJN0QuLI.cjs +2 -0
- package/dist/chunks/FormEditor-BJN0QuLI.cjs.map +1 -0
- package/dist/chunks/Icon-QLZH31JA.cjs +2 -0
- package/dist/chunks/Icon-QLZH31JA.cjs.map +1 -0
- package/dist/chunks/Icon-kLLQC54Z.js +107 -0
- package/dist/chunks/Icon-kLLQC54Z.js.map +1 -0
- package/dist/chunks/{Message-VJTPhId7.js → Message-DM6pTq7N.js} +2 -2
- package/dist/chunks/{Message-VJTPhId7.js.map → Message-DM6pTq7N.js.map} +1 -1
- package/dist/chunks/{Message-B0A5bz8V.cjs → Message-yZJDVzb8.cjs} +2 -2
- package/dist/chunks/{Message-B0A5bz8V.cjs.map → Message-yZJDVzb8.cjs.map} +1 -1
- package/dist/chunks/{NumberField-C90eJGny.js → NumberField-CVsK4l9P.js} +13 -13
- package/dist/chunks/{NumberField-C90eJGny.js.map → NumberField-CVsK4l9P.js.map} +1 -1
- package/dist/chunks/{NumberField-BrWFmPkW.cjs → NumberField-Ccjpa_1d.cjs} +2 -2
- package/dist/chunks/{NumberField-BrWFmPkW.cjs.map → NumberField-Ccjpa_1d.cjs.map} +1 -1
- package/dist/chunks/RichTextEditor-D4rNww9d.cjs +2 -0
- package/dist/chunks/RichTextEditor-D4rNww9d.cjs.map +1 -0
- package/dist/chunks/RichTextEditor-DSxiMLVd.js +2832 -0
- package/dist/chunks/RichTextEditor-DSxiMLVd.js.map +1 -0
- package/dist/chunks/dialogLabel-Dx-WEEzI.cjs +2 -0
- package/dist/chunks/dialogLabel-Dx-WEEzI.cjs.map +1 -0
- package/dist/chunks/dialogLabel-nB1gwKz0.js +157 -0
- package/dist/chunks/dialogLabel-nB1gwKz0.js.map +1 -0
- package/dist/chunks/overlayLayer-CPd3zj_u.cjs +2 -0
- package/dist/chunks/overlayLayer-CPd3zj_u.cjs.map +1 -0
- package/dist/chunks/overlayLayer-Dv1vmfaI.js +199 -0
- package/dist/chunks/overlayLayer-Dv1vmfaI.js.map +1 -0
- package/dist/chunks/{useTooltip-Du8PutGX.js → useTooltip-COyAcujL.js} +2 -2
- package/dist/chunks/{useTooltip-Du8PutGX.js.map → useTooltip-COyAcujL.js.map} +1 -1
- package/dist/chunks/{useTooltip-ekdwMJFz.cjs → useTooltip-nEDN0ObI.cjs} +2 -2
- package/dist/chunks/{useTooltip-ekdwMJFz.cjs.map → useTooltip-nEDN0ObI.cjs.map} +1 -1
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.js +1 -1
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Banner/index.cjs +1 -1
- package/dist/components/Banner/index.js +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.js +5 -5
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.js +6 -7
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/style.css +1 -1
- package/dist/components/FormEditor/README.md +205 -178
- package/dist/components/FormEditor/control.d.cts +4 -4
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts +4 -4
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/form.d.cts +3 -3
- package/dist/components/FormEditor/form.d.cts.map +1 -1
- package/dist/components/FormEditor/form.d.ts +3 -3
- package/dist/components/FormEditor/form.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.js +2 -2
- package/dist/components/FormEditor/model.d.cts +2 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +2 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/rich-text-control.d.cts +1 -2
- package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -1
- package/dist/components/FormEditor/rich-text-control.d.ts +1 -2
- package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -1
- package/dist/components/Icon/icons.d.cts +5 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +5 -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/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.js +6 -6
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.js +9 -9
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +67 -64
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RichTextEditor/block-plugins.d.cts +62 -0
- package/dist/components/RichTextEditor/block-plugins.d.cts.map +1 -0
- package/dist/components/RichTextEditor/block-plugins.d.ts +62 -0
- package/dist/components/RichTextEditor/block-plugins.d.ts.map +1 -0
- package/dist/components/RichTextEditor/content-block-frame.d.cts +32 -0
- package/dist/components/RichTextEditor/content-block-frame.d.cts.map +1 -0
- package/dist/components/RichTextEditor/content-block-frame.d.ts +32 -0
- package/dist/components/RichTextEditor/content-block-frame.d.ts.map +1 -0
- package/dist/components/RichTextEditor/content-block-view.d.cts +3 -0
- package/dist/components/RichTextEditor/content-block-view.d.cts.map +1 -0
- package/dist/components/RichTextEditor/content-block-view.d.ts +3 -0
- package/dist/components/RichTextEditor/content-block-view.d.ts.map +1 -0
- package/dist/components/RichTextEditor/content-block.d.cts +10 -0
- package/dist/components/RichTextEditor/content-block.d.cts.map +1 -0
- package/dist/components/RichTextEditor/content-block.d.ts +10 -0
- package/dist/components/RichTextEditor/content-block.d.ts.map +1 -0
- package/dist/components/RichTextEditor/document.d.cts +24 -8
- package/dist/components/RichTextEditor/document.d.cts.map +1 -1
- package/dist/components/RichTextEditor/document.d.ts +24 -8
- 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 +6 -4
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +6 -4
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/picker-block.d.cts +25 -0
- package/dist/components/RichTextEditor/picker-block.d.cts.map +1 -0
- package/dist/components/RichTextEditor/picker-block.d.ts +25 -0
- package/dist/components/RichTextEditor/picker-block.d.ts.map +1 -0
- package/dist/components/RichTextEditor/style.css +126 -49
- package/dist/components/RichTextEditor/table-actions.d.cts +11 -0
- package/dist/components/RichTextEditor/table-actions.d.cts.map +1 -0
- package/dist/components/RichTextEditor/table-actions.d.ts +11 -0
- package/dist/components/RichTextEditor/table-actions.d.ts.map +1 -0
- package/dist/components/RichTextEditor/table-bands.d.cts +19 -0
- package/dist/components/RichTextEditor/table-bands.d.cts.map +1 -0
- package/dist/components/RichTextEditor/table-bands.d.ts +19 -0
- package/dist/components/RichTextEditor/table-bands.d.ts.map +1 -0
- package/dist/components/RichTextEditor/table-view.d.cts +4 -0
- package/dist/components/RichTextEditor/table-view.d.cts.map +1 -0
- package/dist/components/RichTextEditor/table-view.d.ts +4 -0
- package/dist/components/RichTextEditor/table-view.d.ts.map +1 -0
- package/dist/components/RichTextEditor/tables.d.cts.map +1 -1
- package/dist/components/RichTextEditor/tables.d.ts.map +1 -1
- package/dist/components/RichTextEditor/use-blocks.d.cts +19 -0
- package/dist/components/RichTextEditor/use-blocks.d.cts.map +1 -0
- package/dist/components/RichTextEditor/use-blocks.d.ts +19 -0
- package/dist/components/RichTextEditor/use-blocks.d.ts.map +1 -0
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +2 -2
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.js +4 -4
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Switch/style.css +2 -6
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Time/index.cjs +1 -1
- package/dist/components/Time/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -49
- package/dist/internal/useStableValue.d.cts +8 -0
- package/dist/internal/useStableValue.d.cts.map +1 -0
- package/dist/internal/useStableValue.d.ts +8 -0
- package/dist/internal/useStableValue.d.ts.map +1 -0
- package/dist/rich-text-blocks.cjs +2 -0
- package/dist/rich-text-blocks.cjs.map +1 -0
- package/dist/rich-text-blocks.d.cts +20 -0
- package/dist/rich-text-blocks.d.cts.map +1 -0
- package/dist/rich-text-blocks.d.ts +20 -0
- package/dist/rich-text-blocks.d.ts.map +1 -0
- package/dist/rich-text-blocks.js +36 -0
- package/dist/rich-text-blocks.js.map +1 -0
- package/package.json +14 -1
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs +0 -2
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs.map +0 -1
- package/dist/chunks/EntryPicker-Ie9T47hA.js.map +0 -1
- package/dist/chunks/FormEditor-D1HUnjMI.cjs +0 -2
- package/dist/chunks/FormEditor-D1HUnjMI.cjs.map +0 -1
- package/dist/chunks/FormEditor-DgDV5aeR.js +0 -30
- package/dist/chunks/FormEditor-DgDV5aeR.js.map +0 -1
- package/dist/chunks/Icon-Bxvp1-td.js +0 -102
- package/dist/chunks/Icon-Bxvp1-td.js.map +0 -1
- package/dist/chunks/Icon-CnnTrtNb.cjs +0 -2
- package/dist/chunks/Icon-CnnTrtNb.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DPhEkDxi.js +0 -2108
- package/dist/chunks/RichTextEditor-DPhEkDxi.js.map +0 -1
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs +0 -2
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs.map +0 -1
- package/dist/chunks/dialogLabel-C153NosD.js +0 -176
- package/dist/chunks/dialogLabel-C153NosD.js.map +0 -1
- package/dist/chunks/dialogLabel-CNNQbtob.cjs +0 -2
- package/dist/chunks/dialogLabel-CNNQbtob.cjs.map +0 -1
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs +0 -2
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs.map +0 -1
- package/dist/chunks/overlayLayer-Og07sIyl.js +0 -180
- package/dist/chunks/overlayLayer-Og07sIyl.js.map +0 -1
- package/dist/components/RichTextEditor/embed-context.d.cts +0 -41
- package/dist/components/RichTextEditor/embed-context.d.cts.map +0 -1
- package/dist/components/RichTextEditor/embed-context.d.ts +0 -41
- package/dist/components/RichTextEditor/embed-context.d.ts.map +0 -1
- package/dist/components/RichTextEditor/embed-types.d.cts +0 -29
- package/dist/components/RichTextEditor/embed-types.d.cts.map +0 -1
- package/dist/components/RichTextEditor/embed-types.d.ts +0 -29
- package/dist/components/RichTextEditor/embed-types.d.ts.map +0 -1
- package/dist/components/RichTextEditor/storyblock-view.d.cts +0 -3
- package/dist/components/RichTextEditor/storyblock-view.d.cts.map +0 -1
- package/dist/components/RichTextEditor/storyblock-view.d.ts +0 -3
- package/dist/components/RichTextEditor/storyblock-view.d.ts.map +0 -1
- package/dist/components/RichTextEditor/storyblock.d.cts +0 -19
- package/dist/components/RichTextEditor/storyblock.d.cts.map +0 -1
- package/dist/components/RichTextEditor/storyblock.d.ts +0 -19
- package/dist/components/RichTextEditor/storyblock.d.ts.map +0 -1
- package/dist/components/RichTextEditor/use-embeds.d.cts +0 -31
- package/dist/components/RichTextEditor/use-embeds.d.cts.map +0 -1
- package/dist/components/RichTextEditor/use-embeds.d.ts +0 -31
- package/dist/components/RichTextEditor/use-embeds.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./Icon-
|
|
2
|
-
//# sourceMappingURL=DatePicker-
|
|
1
|
+
const e=require("./Icon-QLZH31JA.cjs"),t=require("../components/Button/index.cjs"),n=require("./overlayLayer-CPd3zj_u.cjs");;/* empty css */const r=require("../components/Popover/index.cjs"),i=require("./binding-tMjrUzkU.cjs");let a=require("react"),o=require("react/jsx-runtime");function s(e){let t=`${e.getMonth()+1}`.padStart(2,`0`),n=`${e.getDate()}`.padStart(2,`0`);return`${e.getFullYear()}-${t}-${n}`}function c(e){if(!e||!/^\d{4}-\d{2}-\d{2}$/.test(e))return null;let[t,n,r]=e.split(`-`).map(Number);if(!t||!n||!r)return null;let i=new Date(t,n-1,r);return Number.isNaN(i.getTime())||s(i)!==e?null:i}function l(e){return c(e)!==null}function u(e){let t=c(e);return t?t.toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`}):``}function d(...e){return e.filter(Boolean).join(` `)}var f=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function p(e,t,n){let r=c(e)?e:s(new Date);return t&&r<t?t:n&&r>n?n:r}function m(e){return e.toLocaleDateString(`en-GB`,{month:`long`,year:`numeric`})}function h(e){let t=new Date(e.getFullYear(),e.getMonth(),1),n=(t.getDay()+6)%7;return new Date(t.getFullYear(),t.getMonth(),1-n)}function g(e,t,n){return e?`primary`:t?`active`:n?`neutral`:`simple`}var _=(0,a.forwardRef)(function({value:e,endValue:n,onSelect:r,min:l,max:_,className:v,...y},b){let[x,S]=(0,a.useState)(()=>p(e,l,_)),[C,w]=(0,a.useState)(()=>c(x)??new Date),T=(0,a.useRef)(null),E=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(!c(e))return;let t=p(e,l,_),n=c(t)??new Date;S(t),w(new Date(n.getFullYear(),n.getMonth(),1))},[e,l,_]),(0,a.useEffect)(()=>{E.current&&(E.current=!1,T.current?.querySelector(`[data-focused]`)?.focus())},[x]);let D=Array.from({length:42},(e,t)=>{let n=h(C);return new Date(n.getFullYear(),n.getMonth(),n.getDate()+t)}),O=s(new Date),k=e=>{let t=new Date(C.getFullYear(),C.getMonth()+e,1);w(t),S(s(t))},A=e=>{let t=c(x)??new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()+e);E.current=!0,S(s(n)),w(new Date(n.getFullYear(),n.getMonth(),1))},j=e=>{let t={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7,PageUp:-28,PageDown:28}[e.key];t!==void 0&&(e.preventDefault(),A(t))};return(0,o.jsxs)(`div`,{ref:b,className:d(`ds-calendar`,`ds-field-surface`,v),...i.n(y),children:[(0,o.jsxs)(`div`,{className:`ds-calendar__head ds-field-surface`,children:[(0,o.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`chevron-left`,"aria-label":`Previous month`,onClick:()=>k(-1)}),(0,o.jsx)(`span`,{className:`ds-calendar__month`,children:m(C)}),(0,o.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`chevron-right`,"aria-label":`Next month`,onClick:()=>k(1)})]}),(0,o.jsx)(`div`,{className:`ds-calendar__weekdays`,"aria-hidden":`true`,children:f.map(e=>(0,o.jsx)(`span`,{children:e.slice(0,2)},e))}),(0,o.jsx)(`div`,{ref:T,className:`ds-calendar__grid`,role:`grid`,onKeyDown:j,children:Array.from({length:6},(i,a)=>(0,o.jsx)(`div`,{role:`row`,className:`ds-calendar__row`,children:D.slice(a*7,a*7+7).map(i=>{let a=s(i),c=i.getMonth()!==C.getMonth(),d=l&&a<l||_&&a>_,f=!!(e&&n&&a>e&&a<n),p=a===e||a===n;return(0,o.jsx)(t.Button,{variant:g(p,f,a===O),size:`sm`,isIconOnly:!0,role:`gridcell`,"aria-label":u(a),tabIndex:a===x?0:-1,isDisabled:!!d,"aria-selected":p||void 0,"data-outside":c||void 0,"data-today":a===O||void 0,"data-in-range":f||void 0,"data-focused":a===x||void 0,className:`ds-calendar__day`,onClick:()=>{S(a),r?.(a)},children:i.getDate()},a)})},a))})]})});function v({value:s,defaultValue:c=``,onValueChange:l,size:f=`md`,placeholder:p=`Pick a date`,placement:m,min:h,max:g,isDisabled:v=!1,isInvalid:y=!1,isClearable:b=!1,clearLabel:x=`Clear date`,"aria-invalid":S,id:C,className:w,...T}){let[E,D]=(0,a.useState)(c),O=s??E,[k,A]=(0,a.useState)(!1),j=n.o(k),M=(0,a.useRef)(null),N=(0,a.useRef)(null),P=(0,a.useRef)(null),F=(0,a.useId)(),I=C??F;return j&&v&&A(!1),(0,a.useEffect)(()=>{if(!j)return;let e=P.current;(e?.querySelector(`[data-focused]:not(:disabled)`)??e)?.focus();let t=e=>{let t=e.target;!M.current?.contains(t)&&!P.current?.contains(t)&&A(!1)};return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[j]),(0,o.jsxs)(`div`,{className:d(`ds-datefield`,w),ref:M,onKeyDown:e=>{j&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),A(!1),N.current?.focus())},children:[(0,o.jsxs)(t.Button,{...i.n(T),ref:N,id:I,size:f,"aria-haspopup":`dialog`,"aria-expanded":j,"aria-invalid":y||S||void 0,isDisabled:v,"data-placeholder":O?void 0:``,className:`ds-field-skin ds-datefield__control`,onClick:()=>A(e=>!e),children:[(0,o.jsx)(`span`,{className:`ds-datefield__value`,children:O?u(O):p}),(0,o.jsx)(e.t,{name:`calendar`,size:16,className:`ds-datefield__glyph`})]}),b&&O&&(0,o.jsx)(t.Button,{variant:`simple`,size:f,isIconOnly:!0,iconStart:`x`,"aria-label":x,isDisabled:v,onClick:()=>{s===void 0&&D(``),l?.(``),A(!1),N.current?.focus()}}),(0,o.jsx)(r.Popover,{anchorRef:N,placement:m,anchorId:I,isOpen:j,align:`start`,panelRef:P,className:`ds-datefield__popover`,role:`dialog`,"aria-label":`Choose a date`,tabIndex:-1,children:(0,o.jsx)(_,{value:O,min:h,max:g,onSelect:e=>{s===void 0&&D(e),l?.(e),A(!1),N.current?.focus()}})})]})}function y(e,t,n){return c(e)?t?n===`min`?e>t?e:t:e<t?e:t:e:t}function b({value:e,defaultValue:t={start:``,end:``},onValueChange:n,size:r=`md`,min:s,max:c,isDisabled:l=!1,isClearable:u=!1,startLabel:f=`Start date`,endLabel:p=`End date`,placement:m,className:h,...g}){let[_,b]=(0,a.useState)(t),x=e??_,S=t=>{e===void 0&&b(t),n?.(t)},{attributes:C}=i.r(g);return(0,o.jsxs)(`div`,{...C,className:d(`ds-daterange`,h),children:[(0,o.jsx)(v,{"aria-invalid":g[`aria-invalid`],"aria-label":f,placement:m,size:r,value:x.start,min:s,max:y(x.end,c,`max`),isDisabled:l,isClearable:u,clearLabel:`Clear ${f}`,placeholder:f,onValueChange:e=>S({...x,start:e})}),(0,o.jsx)(`span`,{className:`ds-daterange__dash`,"aria-hidden":`true`,children:`–`}),(0,o.jsx)(v,{"aria-invalid":g[`aria-invalid`],"aria-label":p,placement:m,size:r,value:x.end,min:y(x.start,s,`min`),max:c,isDisabled:l,isClearable:u,clearLabel:`Clear ${p}`,placeholder:p,onValueChange:e=>S({...x,end:e})})]})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _}});
|
|
2
|
+
//# sourceMappingURL=DatePicker-zA0bWVBp.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker-DOg3iQYy.cjs","names":["forwardRef","useState","useRef","omitRequired","Button","useOverlayOpen","useId","Icon","Popover","useGroupBinding","require_Icon","require_components_Button_index","require_overlayLayer","require_components_Popover_index","require_binding","react","react_jsx_runtime","toIso","month","date","day","fromIso","value","year","isIsoDate","formatIsoDate","cx","parts","WEEKDAYS","focusableDay","min","max","monthLabel","startOfGrid","first","weekday","dayVariant","isEdge","inRange","isToday","Calendar","rest","focused","setFocused","setMonth","gridRef","shouldFocus","next","days","start","index","today","changeMonth","delta","move","base","deltaDays","onKeyDown","event","className","rowIndex","iso","isOutside","isDisabled","endValue","onSelect","DateField","ariaInvalid","internal","setInternal","defaultValue","current","open","setOpen","isOpen","rootRef","triggerRef","panelRef","generatedId","triggerId","id","panel","onPointerDown","target","isInvalid","placeholder","isClearable","clearLabel","onValueChange","rangeBound","endpoint","bound","kind","DateRangeField","binding","commit","attributes","startLabel","endLabel"],"sources":["../../src/components/DatePicker/date.ts","../../src/components/DatePicker/index.tsx"],"sourcesContent":["/** ISO calendar date, \"YYYY-MM-DD\" — the only date shape the system passes around. */\nexport type IsoDate = string;\n\nexport function toIso(date: Date): IsoDate {\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const day = `${date.getDate()}`.padStart(2, \"0\");\n return `${date.getFullYear()}-${month}-${day}`;\n}\n\nexport function fromIso(value: string | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) {\n return null;\n }\n const [year, month, day] = value.split(\"-\").map(Number);\n if (!year || !month || !day) {\n return null;\n }\n const date = new Date(year, month - 1, day);\n return Number.isNaN(date.getTime()) || toIso(date) !== value ? null : date;\n}\n\n/** A real calendar day in \"YYYY-MM-DD\" form, checked without locale formatting. */\nexport function isIsoDate(value: string) {\n return fromIso(value) !== null;\n}\n\n/** \"12 March 2026\" — the system's one long date format. */\nexport function formatIsoDate(value: string | undefined): string {\n const date = fromIso(value);\n if (!date) {\n return \"\";\n }\n return date.toLocaleDateString(\"en-GB\", { day: \"numeric\", month: \"long\", year: \"numeric\" });\n}\n","import { useOverlayOpen } from \"../../internal/overlayLayer\";\nimport { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Popover, type PopoverPlacement } from \"../Popover\";\nimport { omitRequired, useGroupBinding } from \"../Field/binding\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { formatIsoDate, fromIso, toIso, type IsoDate } from \"./date\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport { formatIsoDate } from \"./date\";\nexport type { IsoDate } from \"./date\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst WEEKDAYS = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"];\n\n/** The selected day, or today when none is valid, moved inside the bounds so it can take focus. */\nfunction focusableDay(value: string | undefined, min?: IsoDate, max?: IsoDate): IsoDate {\n const day = fromIso(value) ? (value as IsoDate) : toIso(new Date());\n if (min && day < min) {\n return min;\n }\n return max && day > max ? max : day;\n}\n\nfunction monthLabel(date: Date) {\n return date.toLocaleDateString(\"en-GB\", { month: \"long\", year: \"numeric\" });\n}\n\nfunction startOfGrid(month: Date) {\n const first = new Date(month.getFullYear(), month.getMonth(), 1);\n const weekday = (first.getDay() + 6) % 7; // Monday-first\n return new Date(first.getFullYear(), first.getMonth(), 1 - weekday);\n}\n\nfunction dayVariant(isEdge: boolean, inRange: boolean, isToday: boolean) {\n if (isEdge) {\n return \"primary\";\n }\n if (inRange) {\n return \"active\";\n }\n return isToday ? \"neutral\" : \"simple\";\n}\n\nexport interface CalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n /** Selected day, or the start of a selected span. */\n value?: IsoDate;\n /** End of a selected span. Set it to put the calendar in range mode. */\n endValue?: IsoDate;\n onSelect?: (value: IsoDate) => void;\n min?: IsoDate;\n max?: IsoDate;\n}\n\n/**\n * A month of days, Monday first. Arrow keys walk the grid; the month follows\n * the focused day, so a whole year is reachable from the keyboard.\n */\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>(function Calendar(\n { value, endValue, onSelect, min, max, className, ...rest },\n ref,\n) {\n const [focused, setFocused] = useState<IsoDate>(() => focusableDay(value, min, max));\n const [month, setMonth] = useState(() => fromIso(focused) ?? new Date());\n const gridRef = useRef<HTMLDivElement | null>(null);\n const shouldFocus = useRef(false);\n\n useEffect(() => {\n if (!fromIso(value)) {\n return;\n }\n const day = focusableDay(value, min, max);\n const next = fromIso(day) ?? new Date();\n // Controlled changes intentionally reposition the visible and roving-focus month.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setFocused(day);\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n }, [value, min, max]);\n\n useEffect(() => {\n if (!shouldFocus.current) {\n return;\n }\n shouldFocus.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(\"[data-focused]\")?.focus();\n }, [focused]);\n\n const days = Array.from({ length: 42 }, (_, index) => {\n const start = startOfGrid(month);\n return new Date(start.getFullYear(), start.getMonth(), start.getDate() + index);\n });\n\n const today = toIso(new Date());\n\n const changeMonth = (delta: number) => {\n const next = new Date(month.getFullYear(), month.getMonth() + delta, 1);\n setMonth(next);\n setFocused(toIso(next));\n };\n\n const move = (deltaDays: number) => {\n const base = fromIso(focused) ?? new Date();\n const next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + deltaDays);\n shouldFocus.current = true;\n setFocused(toIso(next));\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n };\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n const steps: Record<string, number> = {\n ArrowLeft: -1,\n ArrowRight: 1,\n ArrowUp: -7,\n ArrowDown: 7,\n PageUp: -28,\n PageDown: 28,\n };\n const delta = steps[event.key];\n if (delta === undefined) {\n return;\n }\n event.preventDefault();\n move(delta);\n };\n\n return (\n <div\n ref={ref}\n className={cx(\"ds-calendar\", \"ds-field-surface\", className)}\n {...omitRequired(rest)}\n >\n <div className=\"ds-calendar__head ds-field-surface\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-left\"\n aria-label=\"Previous month\"\n onClick={() => changeMonth(-1)}\n />\n <span className=\"ds-calendar__month\">{monthLabel(month)}</span>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-right\"\n aria-label=\"Next month\"\n onClick={() => changeMonth(1)}\n />\n </div>\n <div\n className=\"ds-calendar__weekdays\"\n aria-hidden=\"true\"\n >\n {WEEKDAYS.map((day) => (\n <span key={day}>{day.slice(0, 2)}</span>\n ))}\n </div>\n <div\n ref={gridRef}\n className=\"ds-calendar__grid\"\n role=\"grid\"\n onKeyDown={onKeyDown}\n >\n {Array.from({ length: 6 }, (_, rowIndex) => (\n <div\n role=\"row\"\n className=\"ds-calendar__row\"\n key={rowIndex}\n >\n {days.slice(rowIndex * 7, rowIndex * 7 + 7).map((day) => {\n const iso = toIso(day);\n const isOutside = day.getMonth() !== month.getMonth();\n const isDisabled = (min && iso < min) || (max && iso > max);\n const inRange = Boolean(value && endValue && iso > value && iso < endValue);\n const isEdge = iso === value || iso === endValue;\n return (\n <Button\n key={iso}\n variant={dayVariant(isEdge, inRange, iso === today)}\n size=\"sm\"\n isIconOnly\n role=\"gridcell\"\n aria-label={formatIsoDate(iso)}\n tabIndex={iso === focused ? 0 : -1}\n isDisabled={Boolean(isDisabled)}\n aria-selected={isEdge || undefined}\n data-outside={isOutside || undefined}\n data-today={iso === today || undefined}\n data-in-range={inRange || undefined}\n data-focused={iso === focused || undefined}\n className=\"ds-calendar__day\"\n onClick={() => {\n setFocused(iso);\n onSelect?.(iso);\n }}\n >\n {day.getDate()}\n </Button>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport interface DateFieldProps extends FieldBinding {\n /** Preferred side; the shared Popover flips when space requires it. */\n placement?: PopoverPlacement;\n value?: IsoDate;\n defaultValue?: IsoDate;\n onValueChange?: (value: IsoDate) => void;\n size?: FieldSize;\n placeholder?: string;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Show a separate clear action when populated. Defaults to false. */\n isClearable?: boolean;\n clearLabel?: string;\n className?: string;\n}\n\n/** One day, picked from a calendar. The field prints the long date, never a mask. */\nexport function DateField({\n value,\n defaultValue = \"\",\n onValueChange,\n size = \"md\",\n placeholder = \"Pick a date\",\n placement,\n min,\n max,\n isDisabled = false,\n isInvalid = false,\n isClearable = false,\n clearLabel = \"Clear date\",\n \"aria-invalid\": ariaInvalid,\n id,\n className,\n ...rest\n}: DateFieldProps) {\n const [internal, setInternal] = useState<IsoDate>(defaultValue);\n const current = value ?? internal;\n const [open, setOpen] = useState(false);\n const isOpen = useOverlayOpen(open);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n if (isOpen && isDisabled) {\n setOpen(false);\n }\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n // The roving day is always in bounds; the panel takes focus only if bounds exclude every day.\n const panel = panelRef.current;\n (panel?.querySelector<HTMLButtonElement>(\"[data-focused]:not(:disabled)\") ?? panel)?.focus();\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !panelRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", onPointerDown);\n return () => document.removeEventListener(\"mousedown\", onPointerDown);\n }, [isOpen]);\n\n return (\n <div\n className={cx(\"ds-datefield\", className)}\n ref={rootRef}\n onKeyDown={(event) => {\n if (isOpen && event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n triggerRef.current?.focus();\n }\n }}\n >\n <Button\n {...omitRequired(rest)}\n ref={triggerRef}\n id={triggerId}\n size={size}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n isDisabled={isDisabled}\n data-placeholder={current ? undefined : \"\"}\n className=\"ds-field-skin ds-datefield__control\"\n onClick={() => setOpen((open) => !open)}\n >\n <span className=\"ds-datefield__value\">\n {current ? formatIsoDate(current) : placeholder}\n </span>\n <Icon\n name=\"calendar\"\n size={16}\n className=\"ds-datefield__glyph\"\n />\n </Button>\n {isClearable && current && (\n <Button\n variant=\"simple\"\n size={size}\n isIconOnly\n iconStart=\"x\"\n aria-label={clearLabel}\n isDisabled={isDisabled}\n onClick={() => {\n if (value === undefined) {\n setInternal(\"\");\n }\n onValueChange?.(\"\");\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n )}\n <Popover\n anchorRef={triggerRef}\n placement={placement}\n anchorId={triggerId}\n isOpen={isOpen}\n align=\"start\"\n panelRef={panelRef}\n className=\"ds-datefield__popover\"\n role=\"dialog\"\n aria-label=\"Choose a date\"\n // A click on the heading or padding focuses the dialog rather than the page,\n // so the field's own Escape handler still runs before an enclosing Modal's.\n tabIndex={-1}\n >\n <Calendar\n value={current}\n min={min}\n max={max}\n onSelect={(next) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n </Popover>\n </div>\n );\n}\n\nexport interface DateRangeValue {\n start: IsoDate;\n end: IsoDate;\n}\n\nexport interface DateRangeFieldProps extends FieldBinding {\n placement?: PopoverPlacement;\n value?: DateRangeValue;\n defaultValue?: DateRangeValue;\n onValueChange?: (value: DateRangeValue) => void;\n size?: FieldSize;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isClearable?: boolean;\n startLabel?: string;\n endLabel?: string;\n className?: string;\n}\n\nfunction rangeBound(endpoint: string, bound: string | undefined, kind: \"min\" | \"max\") {\n if (!fromIso(endpoint)) {\n return bound;\n }\n if (!bound) {\n return endpoint;\n }\n return kind === \"min\"\n ? endpoint > bound\n ? endpoint\n : bound\n : endpoint < bound\n ? endpoint\n : bound;\n}\n\n/** A span of days. The end field never offers a day before the start. */\nexport function DateRangeField({\n value,\n defaultValue = { start: \"\", end: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n isDisabled = false,\n isClearable = false,\n startLabel = \"Start date\",\n endLabel = \"End date\",\n placement,\n className,\n ...binding\n}: DateRangeFieldProps) {\n const [internal, setInternal] = useState<DateRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: DateRangeValue) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n const { attributes } = useGroupBinding(binding);\n\n return (\n <div\n {...attributes}\n className={cx(\"ds-daterange\", className)}\n >\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={startLabel}\n placement={placement}\n size={size}\n value={current.start}\n min={min}\n max={rangeBound(current.end, max, \"max\")}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${startLabel}`}\n placeholder={startLabel}\n onValueChange={(next) => commit({ ...current, start: next })}\n />\n <span\n className=\"ds-daterange__dash\"\n aria-hidden=\"true\"\n >\n –\n </span>\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={endLabel}\n placement={placement}\n size={size}\n value={current.end}\n min={rangeBound(current.start, min, \"min\")}\n max={max}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${endLabel}`}\n placeholder={endLabel}\n on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,IAAA,CAAC,OAAD,CACE,UAAU,qBACV,cAAY,OACb,SAAA,GAEK,CAAA,GACN,EAAAA,EAAA,IAAA,CAACkD,EAAD,CACE,eAAc4B,EAAQ,gBACtB,aAAYI,EACD,YACL,OACN,MAAO3B,EAAQ,IACf,IAAKkB,EAAWlB,EAAQ,MAAOzC,EAAK,KAAK,EACpC,MACO,aACC,cACb,WAAY,SAASoE,IACrB,YAAaA,EACb,cAAgB,GAASH,EAAO,CAAE,GAAGxB,EAAS,IAAKxB,CAAK,CAAC,CAC1D,CAAA,CACE,C,EAET,C"}
|
|
1
|
+
{"version":3,"file":"DatePicker-zA0bWVBp.cjs","names":["forwardRef","useState","useRef","omitRequired","Button","useOverlayOpen","useId","Icon","Popover","useGroupBinding","require_Icon","require_components_Button_index","require_overlayLayer","require_components_Popover_index","require_binding","react","react_jsx_runtime","toIso","month","date","day","fromIso","value","year","isIsoDate","formatIsoDate","cx","parts","WEEKDAYS","focusableDay","min","max","monthLabel","startOfGrid","first","weekday","dayVariant","isEdge","inRange","isToday","Calendar","rest","focused","setFocused","setMonth","gridRef","shouldFocus","next","days","start","index","today","changeMonth","delta","move","base","deltaDays","onKeyDown","event","className","rowIndex","iso","isOutside","isDisabled","endValue","onSelect","DateField","ariaInvalid","internal","setInternal","defaultValue","current","open","setOpen","isOpen","rootRef","triggerRef","panelRef","generatedId","triggerId","id","panel","onPointerDown","target","isInvalid","placeholder","isClearable","clearLabel","onValueChange","rangeBound","endpoint","bound","kind","DateRangeField","binding","commit","attributes","startLabel","endLabel"],"sources":["../../src/components/DatePicker/date.ts","../../src/components/DatePicker/index.tsx"],"sourcesContent":["/** ISO calendar date, \"YYYY-MM-DD\" — the only date shape the system passes around. */\nexport type IsoDate = string;\n\nexport function toIso(date: Date): IsoDate {\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const day = `${date.getDate()}`.padStart(2, \"0\");\n return `${date.getFullYear()}-${month}-${day}`;\n}\n\nexport function fromIso(value: string | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) {\n return null;\n }\n const [year, month, day] = value.split(\"-\").map(Number);\n if (!year || !month || !day) {\n return null;\n }\n const date = new Date(year, month - 1, day);\n return Number.isNaN(date.getTime()) || toIso(date) !== value ? null : date;\n}\n\n/** A real calendar day in \"YYYY-MM-DD\" form, checked without locale formatting. */\nexport function isIsoDate(value: string) {\n return fromIso(value) !== null;\n}\n\n/** \"12 March 2026\" — the system's one long date format. */\nexport function formatIsoDate(value: string | undefined): string {\n const date = fromIso(value);\n if (!date) {\n return \"\";\n }\n return date.toLocaleDateString(\"en-GB\", { day: \"numeric\", month: \"long\", year: \"numeric\" });\n}\n","import { useOverlayOpen } from \"../../internal/overlayLayer\";\nimport { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Popover, type PopoverPlacement } from \"../Popover\";\nimport { omitRequired, useGroupBinding } from \"../Field/binding\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { formatIsoDate, fromIso, toIso, type IsoDate } from \"./date\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport { formatIsoDate } from \"./date\";\nexport type { IsoDate } from \"./date\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst WEEKDAYS = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"];\n\n/** The selected day, or today when none is valid, moved inside the bounds so it can take focus. */\nfunction focusableDay(value: string | undefined, min?: IsoDate, max?: IsoDate): IsoDate {\n const day = fromIso(value) ? (value as IsoDate) : toIso(new Date());\n if (min && day < min) {\n return min;\n }\n return max && day > max ? max : day;\n}\n\nfunction monthLabel(date: Date) {\n return date.toLocaleDateString(\"en-GB\", { month: \"long\", year: \"numeric\" });\n}\n\nfunction startOfGrid(month: Date) {\n const first = new Date(month.getFullYear(), month.getMonth(), 1);\n const weekday = (first.getDay() + 6) % 7; // Monday-first\n return new Date(first.getFullYear(), first.getMonth(), 1 - weekday);\n}\n\nfunction dayVariant(isEdge: boolean, inRange: boolean, isToday: boolean) {\n if (isEdge) {\n return \"primary\";\n }\n if (inRange) {\n return \"active\";\n }\n return isToday ? \"neutral\" : \"simple\";\n}\n\nexport interface CalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n /** Selected day, or the start of a selected span. */\n value?: IsoDate;\n /** End of a selected span. Set it to put the calendar in range mode. */\n endValue?: IsoDate;\n onSelect?: (value: IsoDate) => void;\n min?: IsoDate;\n max?: IsoDate;\n}\n\n/**\n * A month of days, Monday first. Arrow keys walk the grid; the month follows\n * the focused day, so a whole year is reachable from the keyboard.\n */\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>(function Calendar(\n { value, endValue, onSelect, min, max, className, ...rest },\n ref,\n) {\n const [focused, setFocused] = useState<IsoDate>(() => focusableDay(value, min, max));\n const [month, setMonth] = useState(() => fromIso(focused) ?? new Date());\n const gridRef = useRef<HTMLDivElement | null>(null);\n const shouldFocus = useRef(false);\n\n useEffect(() => {\n if (!fromIso(value)) {\n return;\n }\n const day = focusableDay(value, min, max);\n const next = fromIso(day) ?? new Date();\n // Controlled changes intentionally reposition the visible and roving-focus month.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setFocused(day);\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n }, [value, min, max]);\n\n useEffect(() => {\n if (!shouldFocus.current) {\n return;\n }\n shouldFocus.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(\"[data-focused]\")?.focus();\n }, [focused]);\n\n const days = Array.from({ length: 42 }, (_, index) => {\n const start = startOfGrid(month);\n return new Date(start.getFullYear(), start.getMonth(), start.getDate() + index);\n });\n\n const today = toIso(new Date());\n\n const changeMonth = (delta: number) => {\n const next = new Date(month.getFullYear(), month.getMonth() + delta, 1);\n setMonth(next);\n setFocused(toIso(next));\n };\n\n const move = (deltaDays: number) => {\n const base = fromIso(focused) ?? new Date();\n const next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + deltaDays);\n shouldFocus.current = true;\n setFocused(toIso(next));\n setMonth(new Date(next.getFullYear(), next.getMonth(), 1));\n };\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n const steps: Record<string, number> = {\n ArrowLeft: -1,\n ArrowRight: 1,\n ArrowUp: -7,\n ArrowDown: 7,\n PageUp: -28,\n PageDown: 28,\n };\n const delta = steps[event.key];\n if (delta === undefined) {\n return;\n }\n event.preventDefault();\n move(delta);\n };\n\n return (\n <div\n ref={ref}\n className={cx(\"ds-calendar\", \"ds-field-surface\", className)}\n {...omitRequired(rest)}\n >\n <div className=\"ds-calendar__head ds-field-surface\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-left\"\n aria-label=\"Previous month\"\n onClick={() => changeMonth(-1)}\n />\n <span className=\"ds-calendar__month\">{monthLabel(month)}</span>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"chevron-right\"\n aria-label=\"Next month\"\n onClick={() => changeMonth(1)}\n />\n </div>\n <div\n className=\"ds-calendar__weekdays\"\n aria-hidden=\"true\"\n >\n {WEEKDAYS.map((day) => (\n <span key={day}>{day.slice(0, 2)}</span>\n ))}\n </div>\n <div\n ref={gridRef}\n className=\"ds-calendar__grid\"\n role=\"grid\"\n onKeyDown={onKeyDown}\n >\n {Array.from({ length: 6 }, (_, rowIndex) => (\n <div\n role=\"row\"\n className=\"ds-calendar__row\"\n key={rowIndex}\n >\n {days.slice(rowIndex * 7, rowIndex * 7 + 7).map((day) => {\n const iso = toIso(day);\n const isOutside = day.getMonth() !== month.getMonth();\n const isDisabled = (min && iso < min) || (max && iso > max);\n const inRange = Boolean(value && endValue && iso > value && iso < endValue);\n const isEdge = iso === value || iso === endValue;\n return (\n <Button\n key={iso}\n variant={dayVariant(isEdge, inRange, iso === today)}\n size=\"sm\"\n isIconOnly\n role=\"gridcell\"\n aria-label={formatIsoDate(iso)}\n tabIndex={iso === focused ? 0 : -1}\n isDisabled={Boolean(isDisabled)}\n aria-selected={isEdge || undefined}\n data-outside={isOutside || undefined}\n data-today={iso === today || undefined}\n data-in-range={inRange || undefined}\n data-focused={iso === focused || undefined}\n className=\"ds-calendar__day\"\n onClick={() => {\n setFocused(iso);\n onSelect?.(iso);\n }}\n >\n {day.getDate()}\n </Button>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport interface DateFieldProps extends FieldBinding {\n /** Preferred side; the shared Popover flips when space requires it. */\n placement?: PopoverPlacement;\n value?: IsoDate;\n defaultValue?: IsoDate;\n onValueChange?: (value: IsoDate) => void;\n size?: FieldSize;\n placeholder?: string;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Show a separate clear action when populated. Defaults to false. */\n isClearable?: boolean;\n clearLabel?: string;\n className?: string;\n}\n\n/** One day, picked from a calendar. The field prints the long date, never a mask. */\nexport function DateField({\n value,\n defaultValue = \"\",\n onValueChange,\n size = \"md\",\n placeholder = \"Pick a date\",\n placement,\n min,\n max,\n isDisabled = false,\n isInvalid = false,\n isClearable = false,\n clearLabel = \"Clear date\",\n \"aria-invalid\": ariaInvalid,\n id,\n className,\n ...rest\n}: DateFieldProps) {\n const [internal, setInternal] = useState<IsoDate>(defaultValue);\n const current = value ?? internal;\n const [open, setOpen] = useState(false);\n const isOpen = useOverlayOpen(open);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n if (isOpen && isDisabled) {\n setOpen(false);\n }\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n // The roving day is always in bounds; the panel takes focus only if bounds exclude every day.\n const panel = panelRef.current;\n (panel?.querySelector<HTMLButtonElement>(\"[data-focused]:not(:disabled)\") ?? panel)?.focus();\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !panelRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", onPointerDown);\n return () => document.removeEventListener(\"mousedown\", onPointerDown);\n }, [isOpen]);\n\n return (\n <div\n className={cx(\"ds-datefield\", className)}\n ref={rootRef}\n onKeyDown={(event) => {\n if (isOpen && event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n triggerRef.current?.focus();\n }\n }}\n >\n <Button\n {...omitRequired(rest)}\n ref={triggerRef}\n id={triggerId}\n size={size}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n isDisabled={isDisabled}\n data-placeholder={current ? undefined : \"\"}\n className=\"ds-field-skin ds-datefield__control\"\n onClick={() => setOpen((open) => !open)}\n >\n <span className=\"ds-datefield__value\">\n {current ? formatIsoDate(current) : placeholder}\n </span>\n <Icon\n name=\"calendar\"\n size={16}\n className=\"ds-datefield__glyph\"\n />\n </Button>\n {isClearable && current && (\n <Button\n variant=\"simple\"\n size={size}\n isIconOnly\n iconStart=\"x\"\n aria-label={clearLabel}\n isDisabled={isDisabled}\n onClick={() => {\n if (value === undefined) {\n setInternal(\"\");\n }\n onValueChange?.(\"\");\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n )}\n <Popover\n anchorRef={triggerRef}\n placement={placement}\n anchorId={triggerId}\n isOpen={isOpen}\n align=\"start\"\n panelRef={panelRef}\n className=\"ds-datefield__popover\"\n role=\"dialog\"\n aria-label=\"Choose a date\"\n // A click on the heading or padding focuses the dialog rather than the page,\n // so the field's own Escape handler still runs before an enclosing Modal's.\n tabIndex={-1}\n >\n <Calendar\n value={current}\n min={min}\n max={max}\n onSelect={(next) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n }}\n />\n </Popover>\n </div>\n );\n}\n\nexport interface DateRangeValue {\n start: IsoDate;\n end: IsoDate;\n}\n\nexport interface DateRangeFieldProps extends FieldBinding {\n placement?: PopoverPlacement;\n value?: DateRangeValue;\n defaultValue?: DateRangeValue;\n onValueChange?: (value: DateRangeValue) => void;\n size?: FieldSize;\n min?: IsoDate;\n max?: IsoDate;\n isDisabled?: boolean;\n isClearable?: boolean;\n startLabel?: string;\n endLabel?: string;\n className?: string;\n}\n\nfunction rangeBound(endpoint: string, bound: string | undefined, kind: \"min\" | \"max\") {\n if (!fromIso(endpoint)) {\n return bound;\n }\n if (!bound) {\n return endpoint;\n }\n return kind === \"min\"\n ? endpoint > bound\n ? endpoint\n : bound\n : endpoint < bound\n ? endpoint\n : bound;\n}\n\n/** A span of days. The end field never offers a day before the start. */\nexport function DateRangeField({\n value,\n defaultValue = { start: \"\", end: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n isDisabled = false,\n isClearable = false,\n startLabel = \"Start date\",\n endLabel = \"End date\",\n placement,\n className,\n ...binding\n}: DateRangeFieldProps) {\n const [internal, setInternal] = useState<DateRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: DateRangeValue) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n const { attributes } = useGroupBinding(binding);\n\n return (\n <div\n {...attributes}\n className={cx(\"ds-daterange\", className)}\n >\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={startLabel}\n placement={placement}\n size={size}\n value={current.start}\n min={min}\n max={rangeBound(current.end, max, \"max\")}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${startLabel}`}\n placeholder={startLabel}\n onValueChange={(next) => commit({ ...current, start: next })}\n />\n <span\n className=\"ds-daterange__dash\"\n aria-hidden=\"true\"\n >\n –\n </span>\n <DateField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={endLabel}\n placement={placement}\n size={size}\n value={current.end}\n min={rangeBound(current.start, min, \"min\")}\n max={max}\n isDisabled={isDisabled}\n isClearable={isClearable}\n clearLabel={`Clear ${endLabel}`}\n placeholder={endLabel}\n onValueChange={(next) => commit({ ...current, end: next })}\n />\n </div>\n );\n}\n"],"mappings":"A,ySAGA,SAAgBiB,EAAM,EAAqB,CACzC,IAAMC,EAAQ,GAAGC,EAAK,SAAS,EAAI,IAAI,SAAS,EAAG,GAAG,EAChDC,EAAM,GAAGD,EAAK,QAAQ,IAAI,SAAS,EAAG,GAAG,EAC/C,MAAO,GAAGA,EAAK,YAAY,EAAE,GAAGD,EAAM,GAAGE,GAC3C,CAEA,SAAgBC,EAAQ,EAAwC,CAC9D,GAAI,CAACC,GAAS,CAAC,sBAAsB,KAAKA,CAAK,EAC7C,OAAO,KAET,GAAM,CAACC,EAAML,EAAOE,GAAOE,EAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,EACtD,GAAI,CAACC,GAAQ,CAACL,GAAS,CAACE,EACtB,OAAO,KAET,IAAMD,EAAO,IAAI,KAAKI,EAAML,EAAQ,EAAGE,CAAG,EAC1C,OAAO,OAAO,MAAMD,EAAK,QAAQ,CAAC,GAAKF,EAAME,CAAI,IAAMG,EAAQ,KAAOH,CACxE,CAGA,SAAgBK,EAAU,EAAe,CACvC,OAAOH,EAAQC,CAAK,IAAM,IAC5B,CAGA,SAAgBG,EAAc,EAAmC,CAC/D,IAAMN,EAAOE,EAAQC,CAAK,EAI1B,OAHKH,EAGEA,EAAK,mBAAmB,QAAS,CAAE,IAAK,UAAW,MAAO,OAAQ,KAAM,SAAU,CAAC,EAFjF,EAGX,CCnBA,SAASO,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAEA,IAAMC,EAAW,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EAGjE,SAASC,EAAa,EAA2B,EAAe,EAAwB,CACtF,IAAMT,EAAMC,EAAQC,CAAK,EAAKA,EAAoBL,EAAM,IAAI,IAAM,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,GAAGxB,EAAS,MAAOxB,CAAK,CAAC,CAC5D,CAAA,GACD,EAAA/B,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,qBACV,cAAY,OACb,SAAA,GAEK,CAAA,GACN,EAAAA,EAAA,IAAA,CAACkD,EAAD,CACE,eAAc4B,EAAQ,gBACtB,aAAYI,EACD,YACL,OACN,MAAO3B,EAAQ,IACf,IAAKkB,EAAWlB,EAAQ,MAAOzC,EAAK,KAAK,EACpC,MACO,aACC,cACb,WAAY,SAASoE,IACrB,YAAaA,EACb,cAAgB,GAASH,EAAO,CAAE,GAAGxB,EAAS,IAAKxB,CAAK,CAAC,CAC1D,CAAA,CACE,C,EAET,C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Button as e } from "../components/Button/index.js";
|
|
2
2
|
import { t } from "./transitionDuration-BIBA3V7G.js";
|
|
3
3
|
import { t as n } from "./mergeRefs-C6_5pADN.js";
|
|
4
|
-
import { c as r, r as i, t as a } from "./overlayLayer-
|
|
5
|
-
import { n as o, r as s, t as c } from "./dialogLabel-
|
|
4
|
+
import { c as r, r as i, t as a } from "./overlayLayer-Dv1vmfaI.js";
|
|
5
|
+
import { n as o, r as s, t as c } from "./dialogLabel-nB1gwKz0.js";
|
|
6
6
|
import { forwardRef as l, useEffect as u, useId as d, useRef as f, useState as p } from "react";
|
|
7
7
|
import { createPortal as m } from "react-dom";
|
|
8
8
|
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
@@ -169,4 +169,4 @@ var S = l(function({ isOpen: e, isHidden: t = !1, onClose: l, title: u, descript
|
|
|
169
169
|
//#endregion
|
|
170
170
|
export { S as t };
|
|
171
171
|
|
|
172
|
-
//# sourceMappingURL=Drawer-
|
|
172
|
+
//# sourceMappingURL=Drawer-2cf0SaG4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer-nUTJtwX_.js","names":["_Fragment","mergeRefs","useInheritedPortalScope","useDialogPresence","DialogContent","useModalDialog","useDialogPortal","dialogAttributes","Fragment$1","DrawerHead","hasHeader","titleId","title","description","descriptionId","Button","closeRef","variant","closeLabel","onClose","drawerInteraction","active","isActive","isVisible","isInert","isOpen","canPress","onInactivePress","ariaHidden","DrawerContent","head","node","footer","inactivePressLabel","event","useDrawerExit","previousOpen","setPreviousOpen","useState","exiting","setExiting","useEffect","duration","transitionDurationMs","scrimRef","timeout","Drawer","forwardRef","rest","isHidden","overlayLayer","panelRef","useRef","useId","onTransitionEnd","portalContainer","portal","order","createPortal","frameInert","hasScrim","isResumed","layer","side","onScrimMouseDown","ref","panelAttributes","size","className"],"sources":["../../src/components/Drawer/head.tsx","../../src/components/Drawer/content.tsx","../../src/components/Drawer/index.tsx"],"sourcesContent":["import type { RefObject } from \"react\";\nimport { Button } from \"../Button\";\nimport type { DrawerProps } from \".\";\ntype HeadProps = Pick<\n DrawerProps,\n \"title\" | \"description\" | \"onClose\" | \"hasHeader\" | \"variant\" | \"closeLabel\"\n> & { titleId: string; descriptionId: string; closeRef: RefObject<HTMLButtonElement | null> };\nexport function DrawerHead({\n title,\n description,\n onClose,\n hasHeader,\n variant,\n closeLabel,\n titleId,\n descriptionId,\n closeRef,\n}: HeadProps) {\n return (\n <header\n className=\"ds-drawer__head\"\n hidden={!hasHeader}\n >\n <div className=\"ds-drawer__titles\">\n <h2\n id={titleId}\n className=\"ds-drawer__title\"\n >\n {title}\n </h2>\n {description && (\n <p\n id={descriptionId}\n className=\"ds-drawer__description\"\n >\n {description}\n </p>\n )}\n </div>\n <Button\n ref={closeRef}\n variant=\"simple\"\n size={variant === \"navigation\" ? \"lg\" : \"sm\"}\n isIconOnly\n iconStart=\"x\"\n className={variant === \"navigation\" ? \"ds-drawer__close\" : undefined}\n aria-label={closeLabel}\n onClick={onClose}\n />\n </header>\n );\n}\n","import type { ComponentProps } from \"react\";\nimport { Button } from \"../Button\";\nimport { DrawerHead } from \"./head\";\nimport type { DrawerProps } from \".\";\n\ntype ContentProps = ComponentProps<typeof DrawerHead> &\n Pick<DrawerProps, \"children\" | \"footer\" | \"onInactivePress\" | \"inactivePressLabel\"> & {\n isInert: boolean;\n };\n\n/** Distinguish modal participation from an application's inactive-panel action. */\nexport function drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden,\n}: {\n isOpen: boolean;\n isVisible: boolean;\n isActive: boolean;\n onInactivePress?: () => void;\n ariaHidden?: DrawerProps[\"aria-hidden\"];\n}) {\n const active = isActive && isVisible;\n const isInert = !isOpen || !active;\n const canPress = isOpen && isVisible && !isActive && Boolean(onInactivePress);\n return {\n active,\n isInert,\n canPress,\n frameInert: isInert && !canPress,\n panelAttributes: {\n \"aria-hidden\": canPress ? ariaHidden : isInert || ariaHidden,\n tabIndex: canPress ? undefined : -1,\n },\n };\n}\n\n/** Keep editors mounted inside an inert boundary, with activation outside it. */\nexport function DrawerContent({\n isInert,\n children,\n footer,\n onInactivePress,\n inactivePressLabel,\n ...head\n}: ContentProps) {\n return (\n <>\n <div\n className=\"ds-drawer__content\"\n ref={(node) => {\n if (node) {\n node.inert = isInert;\n node.toggleAttribute(\"inert\", isInert);\n }\n }}\n aria-hidden={isInert || undefined}\n >\n <DrawerHead {...head} />\n <div className=\"ds-drawer__body\">{children}</div>\n {footer && <footer className=\"ds-drawer__footer ds-field-surface\">{footer}</footer>}\n </div>\n {onInactivePress && (\n <Button\n variant=\"simple\"\n className=\"ds-drawer__inactive-press\"\n aria-label={\n inactivePressLabel ??\n (typeof head.title === \"string\" ? `Return to ${head.title}` : \"Activate drawer\")\n }\n tabIndex={-1}\n onPointerDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.stopPropagation();\n onInactivePress();\n }}\n />\n )}\n </>\n );\n}\n","import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n type TransitionEvent,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { DrawerContent, drawerInteraction } from \"./content\";\nimport { transitionDurationMs } from \"../../internal/transitionDuration\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useDialogPortal } from \"../../internal/useDialogPortal\";\nimport { useModalDialog } from \"../../internal/useModalDialog\";\nimport { dialogAttributes } from \"../../internal/dialogLabel\";\nimport { useInheritedPortalScope } from \"../../internal/portalScope\";\nimport { DialogContent, useDialogPresence } from \"../../internal/overlayLayer\";\nimport \"./style.css\";\n\nexport type DrawerSide = \"end\" | \"start\" | \"bottom\";\nexport type DrawerSize = \"md\" | \"wide\";\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /**\n * Visually suspend an open dialog while retaining its mounted children. It\n * stays laid out but invisible and inert, so scroll positions are kept.\n */\n isHidden?: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: ReactNode;\n description?: string;\n /** Which edge the panel is anchored to. */\n side?: DrawerSide;\n size?: DrawerSize;\n /** Without it the title still names the dialog; give people another way to close it. */\n hasHeader?: boolean;\n /**\n * Only the active panel traps focus and handles Escape. An inactive open\n * panel stays visible and mounted as an inert background panel.\n */\n isActive?: boolean;\n /** Activate an exposed inactive panel. Its editor stays inert; the app decides whether to activate it. */\n onInactivePress?: () => void;\n /** Accessible name for the inactive-panel action; defaults to Return to {title} for string titles. */\n inactivePressLabel?: string;\n /** Without a scrim, presses outside the panel reach the page beneath. */\n hasScrim?: boolean;\n /**\n * z-index for this panel and the dialogs and popovers opened from it.\n * Defaults to an enclosing `OverlayLayer`, then the stylesheet. Keep it below\n * the toast layer (80).\n */\n overlayLayer?: number;\n /** Navigation uses a compact panel, header and footer. Both variants slide in and out. */\n variant?: \"default\" | \"navigation\";\n /** Accessible name of the dismiss button. */\n closeLabel?: string;\n /**\n * Defaults to document.body, covering the viewport. A navigation drawer\n * portaled into a positioned element, such as an app shell, stays inside it.\n */\n portalContainer?: HTMLElement | null;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\nfunction useDrawerExit(isOpen: boolean, scrimRef: RefObject<HTMLDivElement | null>) {\n const [previousOpen, setPreviousOpen] = useState(isOpen);\n const [exiting, setExiting] = useState(false);\n\n if (previousOpen !== isOpen) {\n setPreviousOpen(isOpen);\n setExiting(!isOpen);\n }\n\n useEffect(() => {\n if (!exiting || isOpen) {\n return;\n }\n // Read the actual transition, including token overrides and reduced motion.\n const duration = transitionDurationMs(scrimRef.current!);\n const timeout = window.setTimeout(() => setExiting(false), duration);\n return () => window.clearTimeout(timeout);\n }, [exiting, isOpen, scrimRef]);\n\n const onTransitionEnd = (event: TransitionEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && event.propertyName === \"opacity\" && !isOpen) {\n setExiting(false);\n }\n };\n return [exiting, onTransitionEnd] as const;\n}\n\n/**\n * A side panel for work that belongs beside the page rather than on top of it\n * — editing one record, a filter set, a revision history. Same frame, rules\n * and footer band as `Modal`, with square corners and a full slide through\n * its anchored edge. Focus is trapped while open.\n */\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n isHidden = false,\n onClose,\n title,\n description,\n side = \"end\",\n size = \"md\",\n hasHeader = true,\n isActive = true,\n onInactivePress,\n inactivePressLabel,\n hasScrim = true,\n overlayLayer,\n variant = \"default\",\n closeLabel = \"Close\",\n portalContainer,\n footer,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const { layer, isVisible, isResumed } = useDialogPresence(isOpen, isHidden, overlayLayer);\n const { active, isInert, canPress, frameInert, panelAttributes } = drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden: rest[\"aria-hidden\"],\n });\n const panelRef = useRef<HTMLDivElement | null>(null);\n const scrimRef = useRef<HTMLDivElement | null>(null);\n const closeRef = useRef<HTMLButtonElement | null>(null);\n const titleId = useId();\n const descriptionId = useId();\n const [exiting, onTransitionEnd] = useDrawerExit(isOpen, scrimRef);\n const { onScrimMouseDown, order } = useModalDialog({\n isOpen,\n isActive: active,\n layer,\n panelRef,\n onClose,\n // A hidden header's close button can't take focus.\n initialFocus: variant === \"navigation\" && hasHeader ? () => closeRef.current : undefined,\n // Panels start off-screen; focusing them must not scroll the page with them.\n preventScroll: true,\n container: portalContainer,\n });\n const portal = useDialogPortal(order, isOpen || exiting, portalContainer);\n useInheritedPortalScope(scrimRef, isOpen, { keepDir: rest.dir !== undefined });\n\n if ((!isOpen && !exiting) || !portal) {\n return null;\n }\n\n return createPortal(\n <DialogContent\n layer={layer}\n isSuspended={isInert}\n >\n <div\n ref={(node) => {\n scrimRef.current = node;\n if (node) {\n node.inert = frameInert;\n }\n }}\n className=\"ds-drawer-scrim\"\n hidden={!isVisible}\n data-scrim={hasScrim ? undefined : \"none\"}\n data-inactive-press={canPress || undefined}\n data-resumed={isResumed || undefined}\n style={{ zIndex: layer }}\n dir={rest.dir}\n data-side={side}\n data-variant={variant}\n data-contained={portalContainer ? \"\" : undefined}\n data-state={isOpen ? \"open\" : \"closed\"}\n aria-hidden={frameInert || undefined}\n onTransitionEnd={onTransitionEnd}\n onMouseDown={onScrimMouseDown}\n >\n <div\n {...rest}\n ref={mergeRefs(panelRef, ref)}\n {...dialogAttributes(rest, titleId, descriptionId, Boolean(description), active)}\n {...panelAttributes}\n data-side={side}\n data-size={size}\n data-header={hasHeader ? undefined : \"none\"}\n data-variant={variant}\n className={[\"ds-drawer\", \"ds-field-surface\", className].filter(Boolean).join(\" \")}\n >\n <DrawerContent\n isInert={isInert}\n title={title}\n description={description}\n onClose={onClose}\n hasHeader={hasHeader}\n variant={variant}\n closeLabel={closeLabel}\n titleId={titleId}\n descriptionId={descriptionId}\n closeRef={closeRef}\n footer={footer}\n onInactivePress={canPress ? onInactivePress : undefined}\n inactivePressLabel={inactivePressLabel}\n >\n {children}\n </DrawerContent>\n </div>\n </div>\n </DialogContent>,\n portal,\n );\n});\n"],"mappings":";;;;;;;;;AAOA,SAAgBS,EAAW,EACzB,UACA,gBACA,YACA,cACA,Y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G;IAEhF,UAAA,kBAACvC,GAAD;KACW;KACF;KACM;KACJ;KACE;KACF;KACG;KACH;KACM;KACL;KACF;KACR,iBAAiBH,IAAWC,IAAkB,KAAA;KAC1B;KAEnB;IACY,CAAA;GACZ,CAAA;EACF,CAAA;CACQ,CAAA,GACf6B,CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"Drawer-2cf0SaG4.js","names":["_Fragment","mergeRefs","useInheritedPortalScope","useDialogPresence","DialogContent","useModalDialog","useDialogPortal","dialogAttributes","Fragment$1","DrawerHead","hasHeader","titleId","title","description","descriptionId","Button","closeRef","variant","closeLabel","onClose","drawerInteraction","active","isActive","isVisible","isInert","isOpen","canPress","onInactivePress","ariaHidden","DrawerContent","head","node","footer","inactivePressLabel","event","useDrawerExit","previousOpen","setPreviousOpen","useState","exiting","setExiting","useEffect","duration","transitionDurationMs","scrimRef","timeout","Drawer","forwardRef","rest","isHidden","overlayLayer","panelRef","useRef","useId","onTransitionEnd","portalContainer","portal","order","createPortal","frameInert","hasScrim","isResumed","layer","side","onScrimMouseDown","ref","panelAttributes","size","className"],"sources":["../../src/components/Drawer/head.tsx","../../src/components/Drawer/content.tsx","../../src/components/Drawer/index.tsx"],"sourcesContent":["import type { RefObject } from \"react\";\nimport { Button } from \"../Button\";\nimport type { DrawerProps } from \".\";\ntype HeadProps = Pick<\n DrawerProps,\n \"title\" | \"description\" | \"onClose\" | \"hasHeader\" | \"variant\" | \"closeLabel\"\n> & { titleId: string; descriptionId: string; closeRef: RefObject<HTMLButtonElement | null> };\nexport function DrawerHead({\n title,\n description,\n onClose,\n hasHeader,\n variant,\n closeLabel,\n titleId,\n descriptionId,\n closeRef,\n}: HeadProps) {\n return (\n <header\n className=\"ds-drawer__head\"\n hidden={!hasHeader}\n >\n <div className=\"ds-drawer__titles\">\n <h2\n id={titleId}\n className=\"ds-drawer__title\"\n >\n {title}\n </h2>\n {description && (\n <p\n id={descriptionId}\n className=\"ds-drawer__description\"\n >\n {description}\n </p>\n )}\n </div>\n <Button\n ref={closeRef}\n variant=\"simple\"\n size={variant === \"navigation\" ? \"lg\" : \"sm\"}\n isIconOnly\n iconStart=\"x\"\n className={variant === \"navigation\" ? \"ds-drawer__close\" : undefined}\n aria-label={closeLabel}\n onClick={onClose}\n />\n </header>\n );\n}\n","import type { ComponentProps } from \"react\";\nimport { Button } from \"../Button\";\nimport { DrawerHead } from \"./head\";\nimport type { DrawerProps } from \".\";\n\ntype ContentProps = ComponentProps<typeof DrawerHead> &\n Pick<DrawerProps, \"children\" | \"footer\" | \"onInactivePress\" | \"inactivePressLabel\"> & {\n isInert: boolean;\n };\n\n/** Distinguish modal participation from an application's inactive-panel action. */\nexport function drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden,\n}: {\n isOpen: boolean;\n isVisible: boolean;\n isActive: boolean;\n onInactivePress?: () => void;\n ariaHidden?: DrawerProps[\"aria-hidden\"];\n}) {\n const active = isActive && isVisible;\n const isInert = !isOpen || !active;\n const canPress = isOpen && isVisible && !isActive && Boolean(onInactivePress);\n return {\n active,\n isInert,\n canPress,\n frameInert: isInert && !canPress,\n panelAttributes: {\n \"aria-hidden\": canPress ? ariaHidden : isInert || ariaHidden,\n tabIndex: canPress ? undefined : -1,\n },\n };\n}\n\n/** Keep editors mounted inside an inert boundary, with activation outside it. */\nexport function DrawerContent({\n isInert,\n children,\n footer,\n onInactivePress,\n inactivePressLabel,\n ...head\n}: ContentProps) {\n return (\n <>\n <div\n className=\"ds-drawer__content\"\n ref={(node) => {\n if (node) {\n node.inert = isInert;\n node.toggleAttribute(\"inert\", isInert);\n }\n }}\n aria-hidden={isInert || undefined}\n >\n <DrawerHead {...head} />\n <div className=\"ds-drawer__body\">{children}</div>\n {footer && <footer className=\"ds-drawer__footer ds-field-surface\">{footer}</footer>}\n </div>\n {onInactivePress && (\n <Button\n variant=\"simple\"\n className=\"ds-drawer__inactive-press\"\n aria-label={\n inactivePressLabel ??\n (typeof head.title === \"string\" ? `Return to ${head.title}` : \"Activate drawer\")\n }\n tabIndex={-1}\n onPointerDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.stopPropagation();\n onInactivePress();\n }}\n />\n )}\n </>\n );\n}\n","import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n type TransitionEvent,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { DrawerContent, drawerInteraction } from \"./content\";\nimport { transitionDurationMs } from \"../../internal/transitionDuration\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useDialogPortal } from \"../../internal/useDialogPortal\";\nimport { useModalDialog } from \"../../internal/useModalDialog\";\nimport { dialogAttributes } from \"../../internal/dialogLabel\";\nimport { useInheritedPortalScope } from \"../../internal/portalScope\";\nimport { DialogContent, useDialogPresence } from \"../../internal/overlayLayer\";\nimport \"./style.css\";\n\nexport type DrawerSide = \"end\" | \"start\" | \"bottom\";\nexport type DrawerSize = \"md\" | \"wide\";\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /**\n * Visually suspend an open dialog while retaining its mounted children. It\n * stays laid out but invisible and inert, so scroll positions are kept.\n */\n isHidden?: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: ReactNode;\n description?: string;\n /** Which edge the panel is anchored to. */\n side?: DrawerSide;\n size?: DrawerSize;\n /** Without it the title still names the dialog; give people another way to close it. */\n hasHeader?: boolean;\n /**\n * Only the active panel traps focus and handles Escape. An inactive open\n * panel stays visible and mounted as an inert background panel.\n */\n isActive?: boolean;\n /** Activate an exposed inactive panel. Its editor stays inert; the app decides whether to activate it. */\n onInactivePress?: () => void;\n /** Accessible name for the inactive-panel action; defaults to Return to {title} for string titles. */\n inactivePressLabel?: string;\n /** Without a scrim, presses outside the panel reach the page beneath. */\n hasScrim?: boolean;\n /**\n * z-index for this panel and the dialogs and popovers opened from it.\n * Defaults to an enclosing `OverlayLayer`, then the stylesheet. Keep it below\n * the toast layer (80).\n */\n overlayLayer?: number;\n /** Navigation uses a compact panel, header and footer. Both variants slide in and out. */\n variant?: \"default\" | \"navigation\";\n /** Accessible name of the dismiss button. */\n closeLabel?: string;\n /**\n * Defaults to document.body, covering the viewport. A navigation drawer\n * portaled into a positioned element, such as an app shell, stays inside it.\n */\n portalContainer?: HTMLElement | null;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\nfunction useDrawerExit(isOpen: boolean, scrimRef: RefObject<HTMLDivElement | null>) {\n const [previousOpen, setPreviousOpen] = useState(isOpen);\n const [exiting, setExiting] = useState(false);\n\n if (previousOpen !== isOpen) {\n setPreviousOpen(isOpen);\n setExiting(!isOpen);\n }\n\n useEffect(() => {\n if (!exiting || isOpen) {\n return;\n }\n // Read the actual transition, including token overrides and reduced motion.\n const duration = transitionDurationMs(scrimRef.current!);\n const timeout = window.setTimeout(() => setExiting(false), duration);\n return () => window.clearTimeout(timeout);\n }, [exiting, isOpen, scrimRef]);\n\n const onTransitionEnd = (event: TransitionEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && event.propertyName === \"opacity\" && !isOpen) {\n setExiting(false);\n }\n };\n return [exiting, onTransitionEnd] as const;\n}\n\n/**\n * A side panel for work that belongs beside the page rather than on top of it\n * — editing one record, a filter set, a revision history. Same frame, rules\n * and footer band as `Modal`, with square corners and a full slide through\n * its anchored edge. Focus is trapped while open.\n */\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n isHidden = false,\n onClose,\n title,\n description,\n side = \"end\",\n size = \"md\",\n hasHeader = true,\n isActive = true,\n onInactivePress,\n inactivePressLabel,\n hasScrim = true,\n overlayLayer,\n variant = \"default\",\n closeLabel = \"Close\",\n portalContainer,\n footer,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const { layer, isVisible, isResumed } = useDialogPresence(isOpen, isHidden, overlayLayer);\n const { active, isInert, canPress, frameInert, panelAttributes } = drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden: rest[\"aria-hidden\"],\n });\n const panelRef = useRef<HTMLDivElement | null>(null);\n const scrimRef = useRef<HTMLDivElement | null>(null);\n const closeRef = useRef<HTMLButtonElement | null>(null);\n const titleId = useId();\n const descriptionId = useId();\n const [exiting, onTransitionEnd] = useDrawerExit(isOpen, scrimRef);\n const { onScrimMouseDown, order } = useModalDialog({\n isOpen,\n isActive: active,\n layer,\n panelRef,\n onClose,\n // A hidden header's close button can't take focus.\n initialFocus: variant === \"navigation\" && hasHeader ? () => closeRef.current : undefined,\n // Panels start off-screen; focusing them must not scroll the page with them.\n preventScroll: true,\n container: portalContainer,\n });\n const portal = useDialogPortal(order, isOpen || exiting, portalContainer);\n useInheritedPortalScope(scrimRef, isOpen, { keepDir: rest.dir !== undefined });\n\n if ((!isOpen && !exiting) || !portal) {\n return null;\n }\n\n return createPortal(\n <DialogContent\n layer={layer}\n isSuspended={isInert}\n >\n <div\n ref={(node) => {\n scrimRef.current = node;\n if (node) {\n node.inert = frameInert;\n }\n }}\n className=\"ds-drawer-scrim\"\n hidden={!isVisible}\n data-scrim={hasScrim ? undefined : \"none\"}\n data-inactive-press={canPress || undefined}\n data-resumed={isResumed || undefined}\n style={{ zIndex: layer }}\n dir={rest.dir}\n data-side={side}\n data-variant={variant}\n data-contained={portalContainer ? \"\" : undefined}\n data-state={isOpen ? \"open\" : \"closed\"}\n aria-hidden={frameInert || undefined}\n onTransitionEnd={onTransitionEnd}\n onMouseDown={onScrimMouseDown}\n >\n <div\n {...rest}\n ref={mergeRefs(panelRef, ref)}\n {...dialogAttributes(rest, titleId, descriptionId, Boolean(description), active)}\n {...panelAttributes}\n data-side={side}\n data-size={size}\n data-header={hasHeader ? undefined : \"none\"}\n data-variant={variant}\n className={[\"ds-drawer\", \"ds-field-surface\", className].filter(Boolean).join(\" \")}\n >\n <DrawerContent\n isInert={isInert}\n title={title}\n description={description}\n onClose={onClose}\n hasHeader={hasHeader}\n variant={variant}\n closeLabel={closeLabel}\n titleId={titleId}\n descriptionId={descriptionId}\n closeRef={closeRef}\n footer={footer}\n onInactivePress={canPress ? onInactivePress : undefined}\n inactivePressLabel={inactivePressLabel}\n >\n {children}\n </DrawerContent>\n </div>\n </div>\n </DialogContent>,\n portal,\n );\n});\n"],"mappings":";;;;;;;;;AAOA,SAAgBS,EAAW,EACzB,UACA,gBACA,YACA,cACA,YACA,eACA,YACA,kBACA,eACY;CACZ,OACE,kBAAC,UAAD;EACE,WAAU;EACV,QAAQ,CAACC;EAFX,UAAA,CAIE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,MAAD;IACE,IAAIC;IACJ,WAAU;IAET,UAAAC;GACC,CAAA,GACHC,KACC,kBAAC,KAAD;IACE,IAAIC;IACJ,WAAU;IAET,UAAAD;GACA,CAAA,CAEF;EACL,CAAA,GAAA,kBAACE,GAAD;GACE,KAAKC;GACL,SAAQ;GACR,MAAMC,MAAY,eAAe,OAAO;GACxC,YAAA;GACA,WAAU;GACV,WAAWA,MAAY,eAAe,qBAAqB,KAAA;GAC3D,cAAYC;GACZ,SAASC;EACV,CAAA,CACK;;AAEZ;;;ACxCA,SAAgBC,EAAkB,EAChC,WACA,cACA,aACA,oBACA,iBAOC;CACD,IAAMC,IAASC,KAAYC,GACrBC,IAAU,CAACC,KAAU,CAACJ,GACtBK,IAAWD,KAAUF,KAAa,CAACD,KAAY,EAAQK;CAC7D,OAAO;EACL;EACA;EACA;EACA,YAAYH,KAAW,CAACE;EACxB,iBAAiB;GACf,eAAeA,IAAWE,IAAaJ,KAAWI;GAClD,UAAUF,IAAW,KAAA,IAAY;EACnC;CACF;AACF;AAGA,SAAgBG,EAAc,EAC5B,YACA,aACA,WACA,oBACA,uBACA,GAAGC,KACY;CACf,OACE,kBAAA9B,GAAA,EAAA,UAAA,CACE,kBAAC,OAAD;EACE,WAAU;EACV,MAAM,MAAS;GACb,AA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C,OAAD;IACE,GAAIhB;IACJ,KAAK/C,EAAUkD,GAAUc,CAAG;IAC5B,GAAI1D,EAAiByC,GAAMrC,GAASG,GAAe,EAAQD,GAAcQ,CAAM;IAC/E,GAAI6C;IACJ,aAAWH;IACX,aAAWI;IACX,eAAazD,IAAY,KAAA,IAAY;IACrC,gBAAcO;IACd,WAAW;KAAC;KAAa;KAAoBmD;IAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;IAEhF,UAAA,kBAACvC,GAAD;KACW;KACF;KACM;KACJ;KACE;KACF;KACG;KACH;KACM;KACL;KACF;KACR,iBAAiBH,IAAWC,IAAkB,KAAA;KAC1B;KAEnB;IACY,CAAA;GACZ,CAAA;EACF,CAAA;CACQ,CAAA,GACf6B,CACF;AACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../components/Button/index.cjs"),t=require("./transitionDuration-B4UnScFc.cjs"),n=require("./mergeRefs-CZ-SArlE.cjs"),r=require("./overlayLayer-
|
|
2
|
-
//# sourceMappingURL=Drawer-
|
|
1
|
+
const e=require("../components/Button/index.cjs"),t=require("./transitionDuration-B4UnScFc.cjs"),n=require("./mergeRefs-CZ-SArlE.cjs"),r=require("./overlayLayer-CPd3zj_u.cjs"),i=require("./dialogLabel-Dx-WEEzI.cjs");let a=require("react"),o=require("react-dom"),s=require("react/jsx-runtime");function c({title:t,description:n,onClose:r,hasHeader:i,variant:a,closeLabel:o,titleId:c,descriptionId:l,closeRef:u}){return(0,s.jsxs)(`header`,{className:`ds-drawer__head`,hidden:!i,children:[(0,s.jsxs)(`div`,{className:`ds-drawer__titles`,children:[(0,s.jsx)(`h2`,{id:c,className:`ds-drawer__title`,children:t}),n&&(0,s.jsx)(`p`,{id:l,className:`ds-drawer__description`,children:n})]}),(0,s.jsx)(e.Button,{ref:u,variant:`simple`,size:a===`navigation`?`lg`:`sm`,isIconOnly:!0,iconStart:`x`,className:a===`navigation`?`ds-drawer__close`:void 0,"aria-label":o,onClick:r})]})}function l({isOpen:e,isVisible:t,isActive:n,onInactivePress:r,ariaHidden:i}){let a=n&&t,o=!e||!a,s=e&&t&&!n&&!!r;return{active:a,isInert:o,canPress:s,frameInert:o&&!s,panelAttributes:{"aria-hidden":s?i:o||i,tabIndex:s?void 0:-1}}}function u({isInert:t,children:n,footer:r,onInactivePress:i,inactivePressLabel:a,...o}){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`div`,{className:`ds-drawer__content`,ref:e=>{e&&(e.inert=t,e.toggleAttribute(`inert`,t))},"aria-hidden":t||void 0,children:[(0,s.jsx)(c,{...o}),(0,s.jsx)(`div`,{className:`ds-drawer__body`,children:n}),r&&(0,s.jsx)(`footer`,{className:`ds-drawer__footer ds-field-surface`,children:r})]}),i&&(0,s.jsx)(e.Button,{variant:`simple`,className:`ds-drawer__inactive-press`,"aria-label":a??(typeof o.title==`string`?`Return to ${o.title}`:`Activate drawer`),tabIndex:-1,onPointerDown:e=>e.preventDefault(),onClick:e=>{e.stopPropagation(),i()}})]})}function d(e,n){let[r,i]=(0,a.useState)(e),[o,s]=(0,a.useState)(!1);return r!==e&&(i(e),s(!e)),(0,a.useEffect)(()=>{if(!o||e)return;let r=t.t(n.current),i=window.setTimeout(()=>s(!1),r);return()=>window.clearTimeout(i)},[o,e,n]),[o,t=>{t.target===t.currentTarget&&t.propertyName===`opacity`&&!e&&s(!1)}]}var f=(0,a.forwardRef)(function({isOpen:e,isHidden:t=!1,onClose:c,title:f,description:p,side:m=`end`,size:h=`md`,hasHeader:g=!0,isActive:_=!0,onInactivePress:v,inactivePressLabel:y,hasScrim:b=!0,overlayLayer:x,variant:S=`default`,closeLabel:C=`Close`,portalContainer:w,footer:T,className:E,children:D,...O},k){let{layer:A,isVisible:j,isResumed:M}=r.r(e,t,x),{active:N,isInert:P,canPress:F,frameInert:I,panelAttributes:L}=l({isOpen:e,isVisible:j,isActive:_,onInactivePress:v,ariaHidden:O[`aria-hidden`]}),R=(0,a.useRef)(null),z=(0,a.useRef)(null),B=(0,a.useRef)(null),V=(0,a.useId)(),H=(0,a.useId)(),[U,W]=d(e,z),{onScrimMouseDown:G,order:K}=i.n({isOpen:e,isActive:N,layer:A,panelRef:R,onClose:c,initialFocus:S===`navigation`&&g?()=>B.current:void 0,preventScroll:!0,container:w}),q=i.r(K,e||U,w);return r.c(z,e,{keepDir:O.dir!==void 0}),!e&&!U||!q?null:(0,o.createPortal)((0,s.jsx)(r.t,{layer:A,isSuspended:P,children:(0,s.jsx)(`div`,{ref:e=>{z.current=e,e&&(e.inert=I)},className:`ds-drawer-scrim`,hidden:!j,"data-scrim":b?void 0:`none`,"data-inactive-press":F||void 0,"data-resumed":M||void 0,style:{zIndex:A},dir:O.dir,"data-side":m,"data-variant":S,"data-contained":w?``:void 0,"data-state":e?`open`:`closed`,"aria-hidden":I||void 0,onTransitionEnd:W,onMouseDown:G,children:(0,s.jsx)(`div`,{...O,ref:n.t(R,k),...i.t(O,V,H,!!p,N),...L,"data-side":m,"data-size":h,"data-header":g?void 0:`none`,"data-variant":S,className:[`ds-drawer`,`ds-field-surface`,E].filter(Boolean).join(` `),children:(0,s.jsx)(u,{isInert:P,title:f,description:p,onClose:c,hasHeader:g,variant:S,closeLabel:C,titleId:V,descriptionId:H,closeRef:B,footer:T,onInactivePress:F?v:void 0,inactivePressLabel:y,children:D})})})}),q)});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
|
|
2
|
+
//# sourceMappingURL=Drawer-BzvSfkCL.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer-B2dcTh5l.cjs","names":["Button","_Fragment","Button","useState","transitionDurationMs","forwardRef","useDialogPresence","useRef","useId","useModalDialog","useDialogPortal","createPortal","DialogContent","mergeRefs","dialogAttributes","require_components_Button_index","require_transitionDuration","require_mergeRefs","require_overlayLayer","require_dialogLabel","react","react_dom","react_jsx_runtime","DrawerHead","hasHeader","titleId","title","description","descriptionId","closeRef","variant","closeLabel","onClose","drawerInteraction","active","isActive","isVisible","isInert","isOpen","canPress","onInactivePress","ariaHidden","DrawerContent","head","node","footer","inactivePressLabel","event","useDrawerExit","previousOpen","setPreviousOpen","exiting","setExiting","duration","scrimRef","timeout","Drawer","rest","isHidden","overlayLayer","panelRef","onTransitionEnd","portalContainer","portal","order","frameInert","hasScrim","isResumed","layer","side","onScrimMouseDown","ref","panelAttributes","size","className"],"sources":["../../src/components/Drawer/head.tsx","../../src/components/Drawer/content.tsx","../../src/components/Drawer/index.tsx"],"sourcesContent":["import type { RefObject } from \"react\";\nimport { Button } from \"../Button\";\nimport type { DrawerProps } from \".\";\ntype HeadProps = Pick<\n DrawerProps,\n \"title\" | \"description\" | \"onClose\" | \"hasHeader\" | \"variant\" | \"closeLabel\"\n> & { titleId: string; descriptionId: string; closeRef: RefObject<HTMLButtonElement | null> };\nexport function DrawerHead({\n title,\n description,\n onClose,\n hasHeader,\n variant,\n closeLabel,\n titleId,\n descriptionId,\n closeRef,\n}: HeadProps) {\n return (\n <header\n className=\"ds-drawer__head\"\n hidden={!hasHeader}\n >\n <div className=\"ds-drawer__titles\">\n <h2\n id={titleId}\n className=\"ds-drawer__title\"\n >\n {title}\n </h2>\n {description && (\n <p\n id={descriptionId}\n className=\"ds-drawer__description\"\n >\n {description}\n </p>\n )}\n </div>\n <Button\n ref={closeRef}\n variant=\"simple\"\n size={variant === \"navigation\" ? \"lg\" : \"sm\"}\n isIconOnly\n iconStart=\"x\"\n className={variant === \"navigation\" ? \"ds-drawer__close\" : undefined}\n aria-label={closeLabel}\n onClick={onClose}\n />\n </header>\n );\n}\n","import type { ComponentProps } from \"react\";\nimport { Button } from \"../Button\";\nimport { DrawerHead } from \"./head\";\nimport type { DrawerProps } from \".\";\n\ntype ContentProps = ComponentProps<typeof DrawerHead> &\n Pick<DrawerProps, \"children\" | \"footer\" | \"onInactivePress\" | \"inactivePressLabel\"> & {\n isInert: boolean;\n };\n\n/** Distinguish modal participation from an application's inactive-panel action. */\nexport function drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden,\n}: {\n isOpen: boolean;\n isVisible: boolean;\n isActive: boolean;\n onInactivePress?: () => void;\n ariaHidden?: DrawerProps[\"aria-hidden\"];\n}) {\n const active = isActive && isVisible;\n const isInert = !isOpen || !active;\n const canPress = isOpen && isVisible && !isActive && Boolean(onInactivePress);\n return {\n active,\n isInert,\n canPress,\n frameInert: isInert && !canPress,\n panelAttributes: {\n \"aria-hidden\": canPress ? ariaHidden : isInert || ariaHidden,\n tabIndex: canPress ? undefined : -1,\n },\n };\n}\n\n/** Keep editors mounted inside an inert boundary, with activation outside it. */\nexport function DrawerContent({\n isInert,\n children,\n footer,\n onInactivePress,\n inactivePressLabel,\n ...head\n}: ContentProps) {\n return (\n <>\n <div\n className=\"ds-drawer__content\"\n ref={(node) => {\n if (node) {\n node.inert = isInert;\n node.toggleAttribute(\"inert\", isInert);\n }\n }}\n aria-hidden={isInert || undefined}\n >\n <DrawerHead {...head} />\n <div className=\"ds-drawer__body\">{children}</div>\n {footer && <footer className=\"ds-drawer__footer ds-field-surface\">{footer}</footer>}\n </div>\n {onInactivePress && (\n <Button\n variant=\"simple\"\n className=\"ds-drawer__inactive-press\"\n aria-label={\n inactivePressLabel ??\n (typeof head.title === \"string\" ? `Return to ${head.title}` : \"Activate drawer\")\n }\n tabIndex={-1}\n onPointerDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.stopPropagation();\n onInactivePress();\n }}\n />\n )}\n </>\n );\n}\n","import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n type TransitionEvent,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { DrawerContent, drawerInteraction } from \"./content\";\nimport { transitionDurationMs } from \"../../internal/transitionDuration\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useDialogPortal } from \"../../internal/useDialogPortal\";\nimport { useModalDialog } from \"../../internal/useModalDialog\";\nimport { dialogAttributes } from \"../../internal/dialogLabel\";\nimport { useInheritedPortalScope } from \"../../internal/portalScope\";\nimport { DialogContent, useDialogPresence } from \"../../internal/overlayLayer\";\nimport \"./style.css\";\n\nexport type DrawerSide = \"end\" | \"start\" | \"bottom\";\nexport type DrawerSize = \"md\" | \"wide\";\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /**\n * Visually suspend an open dialog while retaining its mounted children. It\n * stays laid out but invisible and inert, so scroll positions are kept.\n */\n isHidden?: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: ReactNode;\n description?: string;\n /** Which edge the panel is anchored to. */\n side?: DrawerSide;\n size?: DrawerSize;\n /** Without it the title still names the dialog; give people another way to close it. */\n hasHeader?: boolean;\n /**\n * Only the active panel traps focus and handles Escape. An inactive open\n * panel stays visible and mounted as an inert background panel.\n */\n isActive?: boolean;\n /** Activate an exposed inactive panel. Its editor stays inert; the app decides whether to activate it. */\n onInactivePress?: () => void;\n /** Accessible name for the inactive-panel action; defaults to Return to {title} for string titles. */\n inactivePressLabel?: string;\n /** Without a scrim, presses outside the panel reach the page beneath. */\n hasScrim?: boolean;\n /**\n * z-index for this panel and the dialogs and popovers opened from it.\n * Defaults to an enclosing `OverlayLayer`, then the stylesheet. Keep it below\n * the toast layer (80).\n */\n overlayLayer?: number;\n /** Navigation uses a compact panel, header and footer. Both variants slide in and out. */\n variant?: \"default\" | \"navigation\";\n /** Accessible name of the dismiss button. */\n closeLabel?: string;\n /**\n * Defaults to document.body, covering the viewport. A navigation drawer\n * portaled into a positioned element, such as an app shell, stays inside it.\n */\n portalContainer?: HTMLElement | null;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\nfunction useDrawerExit(isOpen: boolean, scrimRef: RefObject<HTMLDivElement | null>) {\n const [previousOpen, setPreviousOpen] = useState(isOpen);\n const [exiting, setExiting] = useState(false);\n\n if (previousOpen !== isOpen) {\n setPreviousOpen(isOpen);\n setExiting(!isOpen);\n }\n\n useEffect(() => {\n if (!exiting || isOpen) {\n return;\n }\n // Read the actual transition, including token overrides and reduced motion.\n const duration = transitionDurationMs(scrimRef.current!);\n const timeout = window.setTimeout(() => setExiting(false), duration);\n return () => window.clearTimeout(timeout);\n }, [exiting, isOpen, scrimRef]);\n\n const onTransitionEnd = (event: TransitionEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && event.propertyName === \"opacity\" && !isOpen) {\n setExiting(false);\n }\n };\n return [exiting, onTransitionEnd] as const;\n}\n\n/**\n * A side panel for work that belongs beside the page rather than on top of it\n * — editing one record, a filter set, a revision history. Same frame, rules\n * and footer band as `Modal`, with square corners and a full slide through\n * its anchored edge. Focus is trapped while open.\n */\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n isHidden = false,\n onClose,\n title,\n description,\n side = \"end\",\n size = \"md\",\n hasHeader = true,\n isActive = true,\n onInactivePress,\n inactivePressLabel,\n hasScrim = true,\n overlayLayer,\n variant = \"default\",\n closeLabel = \"Close\",\n portalContainer,\n footer,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const { layer, isVisible, isResumed } = useDialogPresence(isOpen, isHidden, overlayLayer);\n const { active, isInert, canPress, frameInert, panelAttributes } = drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden: rest[\"aria-hidden\"],\n });\n const panelRef = useRef<HTMLDivElement | null>(null);\n const scrimRef = useRef<HTMLDivElement | null>(null);\n const closeRef = useRef<HTMLButtonElement | null>(null);\n const titleId = useId();\n const descriptionId = useId();\n const [exiting, onTransitionEnd] = useDrawerExit(isOpen, scrimRef);\n const { onScrimMouseDown, order } = useModalDialog({\n isOpen,\n isActive: active,\n layer,\n panelRef,\n onClose,\n // A hidden header's close button can't take focus.\n initialFocus: variant === \"navigation\" && hasHeader ? () => closeRef.current : undefined,\n // Panels start off-screen; focusing them must not scroll the page with them.\n preventScroll: true,\n container: portalContainer,\n });\n const portal = useDialogPortal(order, isOpen || exiting, portalContainer);\n useInheritedPortalScope(scrimRef, isOpen, { keepDir: rest.dir !== undefined });\n\n if ((!isOpen && !exiting) || !portal) {\n return null;\n }\n\n return createPortal(\n <DialogContent\n layer={layer}\n isSuspended={isInert}\n >\n <div\n ref={(node) => {\n scrimRef.current = node;\n if (node) {\n node.inert = frameInert;\n }\n }}\n className=\"ds-drawer-scrim\"\n hidden={!isVisible}\n data-scrim={hasScrim ? undefined : \"none\"}\n data-inactive-press={canPress || undefined}\n data-resumed={isResumed || undefined}\n style={{ zIndex: layer }}\n dir={rest.dir}\n data-side={side}\n data-variant={variant}\n data-contained={portalContainer ? \"\" : undefined}\n data-state={isOpen ? \"open\" : \"closed\"}\n aria-hidden={frameInert || undefined}\n onTransitionEnd={onTransitionEnd}\n onMouseDown={onScrimMouseDown}\n >\n <div\n {...rest}\n ref={mergeRefs(panelRef, ref)}\n {...dialogAttributes(rest, titleId, descriptionId, Boolean(description), active)}\n {...panelAttributes}\n data-side={side}\n data-size={size}\n data-header={hasHeader ? undefined : \"none\"}\n data-variant={variant}\n className={[\"ds-drawer\", \"ds-field-surface\", className].filter(Boolean).join(\" \")}\n >\n <DrawerContent\n isInert={isInert}\n title={title}\n description={description}\n onClose={onClose}\n hasHeader={hasHeader}\n variant={variant}\n closeLabel={closeLabel}\n titleId={titleId}\n descriptionId={descriptionId}\n closeRef={closeRef}\n footer={footer}\n onInactivePress={canPress ? onInactivePress : undefined}\n inactivePressLabel={inactivePressLabel}\n >\n {children}\n </DrawerContent>\n </div>\n </div>\n </DialogContent>,\n portal,\n );\n});\n"],"mappings":"A,qSAOA,SAAgBuB,EAAW,CACzB,QACA,cACA,UACA,YACA,UACA,aACA,UACA,gBACA,YACY,CACZ,OACE,EAAAD,EAAA,KAAA,CAAC,SAAD,CACE,UAAU,kBACV,OAAQ,CAACE,EAFX,SAAA,EAIE,EAAAF,EAAA,KAAA,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S,OAAS,SAC9B,cAAa2B,GAAc,IAAA,GACV,kBACjB,YAAaK,EAEb,UAAA,EAAAhD,EAAA,IAAA,CAAC,MAAD,CACE,GAAImC,EACJ,IAAK5C,EAAAA,EAAU+C,EAAUW,CAAG,EAC5B,GAAIzD,EAAAA,EAAiB2C,EAAMhC,EAASG,EAAe,EAAQD,EAAcO,CAAM,EAC/E,GAAIsC,EACJ,YAAWH,EACX,YAAWI,EACX,cAAajD,EAAY,IAAA,GAAY,OACrC,eAAcM,EACd,UAAW,CAAC,YAAa,mBAAoB4C,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAEhF,UAAA,EAAApD,EAAA,IAAA,CAACoB,EAAD,CACW,UACF,QACM,cACJ,UACE,YACF,UACG,aACH,UACM,gBACL,WACF,SACR,gBAAiBH,EAAWC,EAAkB,IAAA,GAC1B,qBAEnB,UACY,CAAA,CACZ,CAAA,CACF,CAAA,CACQ,CAAA,EACfuB,CACF,CACF,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"Drawer-BzvSfkCL.cjs","names":["Button","_Fragment","Button","useState","transitionDurationMs","forwardRef","useDialogPresence","useRef","useId","useModalDialog","useDialogPortal","createPortal","DialogContent","mergeRefs","dialogAttributes","require_components_Button_index","require_transitionDuration","require_mergeRefs","require_overlayLayer","require_dialogLabel","react","react_dom","react_jsx_runtime","DrawerHead","hasHeader","titleId","title","description","descriptionId","closeRef","variant","closeLabel","onClose","drawerInteraction","active","isActive","isVisible","isInert","isOpen","canPress","onInactivePress","ariaHidden","DrawerContent","head","node","footer","inactivePressLabel","event","useDrawerExit","previousOpen","setPreviousOpen","exiting","setExiting","duration","scrimRef","timeout","Drawer","rest","isHidden","overlayLayer","panelRef","onTransitionEnd","portalContainer","portal","order","frameInert","hasScrim","isResumed","layer","side","onScrimMouseDown","ref","panelAttributes","size","className"],"sources":["../../src/components/Drawer/head.tsx","../../src/components/Drawer/content.tsx","../../src/components/Drawer/index.tsx"],"sourcesContent":["import type { RefObject } from \"react\";\nimport { Button } from \"../Button\";\nimport type { DrawerProps } from \".\";\ntype HeadProps = Pick<\n DrawerProps,\n \"title\" | \"description\" | \"onClose\" | \"hasHeader\" | \"variant\" | \"closeLabel\"\n> & { titleId: string; descriptionId: string; closeRef: RefObject<HTMLButtonElement | null> };\nexport function DrawerHead({\n title,\n description,\n onClose,\n hasHeader,\n variant,\n closeLabel,\n titleId,\n descriptionId,\n closeRef,\n}: HeadProps) {\n return (\n <header\n className=\"ds-drawer__head\"\n hidden={!hasHeader}\n >\n <div className=\"ds-drawer__titles\">\n <h2\n id={titleId}\n className=\"ds-drawer__title\"\n >\n {title}\n </h2>\n {description && (\n <p\n id={descriptionId}\n className=\"ds-drawer__description\"\n >\n {description}\n </p>\n )}\n </div>\n <Button\n ref={closeRef}\n variant=\"simple\"\n size={variant === \"navigation\" ? \"lg\" : \"sm\"}\n isIconOnly\n iconStart=\"x\"\n className={variant === \"navigation\" ? \"ds-drawer__close\" : undefined}\n aria-label={closeLabel}\n onClick={onClose}\n />\n </header>\n );\n}\n","import type { ComponentProps } from \"react\";\nimport { Button } from \"../Button\";\nimport { DrawerHead } from \"./head\";\nimport type { DrawerProps } from \".\";\n\ntype ContentProps = ComponentProps<typeof DrawerHead> &\n Pick<DrawerProps, \"children\" | \"footer\" | \"onInactivePress\" | \"inactivePressLabel\"> & {\n isInert: boolean;\n };\n\n/** Distinguish modal participation from an application's inactive-panel action. */\nexport function drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden,\n}: {\n isOpen: boolean;\n isVisible: boolean;\n isActive: boolean;\n onInactivePress?: () => void;\n ariaHidden?: DrawerProps[\"aria-hidden\"];\n}) {\n const active = isActive && isVisible;\n const isInert = !isOpen || !active;\n const canPress = isOpen && isVisible && !isActive && Boolean(onInactivePress);\n return {\n active,\n isInert,\n canPress,\n frameInert: isInert && !canPress,\n panelAttributes: {\n \"aria-hidden\": canPress ? ariaHidden : isInert || ariaHidden,\n tabIndex: canPress ? undefined : -1,\n },\n };\n}\n\n/** Keep editors mounted inside an inert boundary, with activation outside it. */\nexport function DrawerContent({\n isInert,\n children,\n footer,\n onInactivePress,\n inactivePressLabel,\n ...head\n}: ContentProps) {\n return (\n <>\n <div\n className=\"ds-drawer__content\"\n ref={(node) => {\n if (node) {\n node.inert = isInert;\n node.toggleAttribute(\"inert\", isInert);\n }\n }}\n aria-hidden={isInert || undefined}\n >\n <DrawerHead {...head} />\n <div className=\"ds-drawer__body\">{children}</div>\n {footer && <footer className=\"ds-drawer__footer ds-field-surface\">{footer}</footer>}\n </div>\n {onInactivePress && (\n <Button\n variant=\"simple\"\n className=\"ds-drawer__inactive-press\"\n aria-label={\n inactivePressLabel ??\n (typeof head.title === \"string\" ? `Return to ${head.title}` : \"Activate drawer\")\n }\n tabIndex={-1}\n onPointerDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.stopPropagation();\n onInactivePress();\n }}\n />\n )}\n </>\n );\n}\n","import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n type TransitionEvent,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { DrawerContent, drawerInteraction } from \"./content\";\nimport { transitionDurationMs } from \"../../internal/transitionDuration\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useDialogPortal } from \"../../internal/useDialogPortal\";\nimport { useModalDialog } from \"../../internal/useModalDialog\";\nimport { dialogAttributes } from \"../../internal/dialogLabel\";\nimport { useInheritedPortalScope } from \"../../internal/portalScope\";\nimport { DialogContent, useDialogPresence } from \"../../internal/overlayLayer\";\nimport \"./style.css\";\n\nexport type DrawerSide = \"end\" | \"start\" | \"bottom\";\nexport type DrawerSize = \"md\" | \"wide\";\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /**\n * Visually suspend an open dialog while retaining its mounted children. It\n * stays laid out but invisible and inert, so scroll positions are kept.\n */\n isHidden?: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: ReactNode;\n description?: string;\n /** Which edge the panel is anchored to. */\n side?: DrawerSide;\n size?: DrawerSize;\n /** Without it the title still names the dialog; give people another way to close it. */\n hasHeader?: boolean;\n /**\n * Only the active panel traps focus and handles Escape. An inactive open\n * panel stays visible and mounted as an inert background panel.\n */\n isActive?: boolean;\n /** Activate an exposed inactive panel. Its editor stays inert; the app decides whether to activate it. */\n onInactivePress?: () => void;\n /** Accessible name for the inactive-panel action; defaults to Return to {title} for string titles. */\n inactivePressLabel?: string;\n /** Without a scrim, presses outside the panel reach the page beneath. */\n hasScrim?: boolean;\n /**\n * z-index for this panel and the dialogs and popovers opened from it.\n * Defaults to an enclosing `OverlayLayer`, then the stylesheet. Keep it below\n * the toast layer (80).\n */\n overlayLayer?: number;\n /** Navigation uses a compact panel, header and footer. Both variants slide in and out. */\n variant?: \"default\" | \"navigation\";\n /** Accessible name of the dismiss button. */\n closeLabel?: string;\n /**\n * Defaults to document.body, covering the viewport. A navigation drawer\n * portaled into a positioned element, such as an app shell, stays inside it.\n */\n portalContainer?: HTMLElement | null;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\nfunction useDrawerExit(isOpen: boolean, scrimRef: RefObject<HTMLDivElement | null>) {\n const [previousOpen, setPreviousOpen] = useState(isOpen);\n const [exiting, setExiting] = useState(false);\n\n if (previousOpen !== isOpen) {\n setPreviousOpen(isOpen);\n setExiting(!isOpen);\n }\n\n useEffect(() => {\n if (!exiting || isOpen) {\n return;\n }\n // Read the actual transition, including token overrides and reduced motion.\n const duration = transitionDurationMs(scrimRef.current!);\n const timeout = window.setTimeout(() => setExiting(false), duration);\n return () => window.clearTimeout(timeout);\n }, [exiting, isOpen, scrimRef]);\n\n const onTransitionEnd = (event: TransitionEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && event.propertyName === \"opacity\" && !isOpen) {\n setExiting(false);\n }\n };\n return [exiting, onTransitionEnd] as const;\n}\n\n/**\n * A side panel for work that belongs beside the page rather than on top of it\n * — editing one record, a filter set, a revision history. Same frame, rules\n * and footer band as `Modal`, with square corners and a full slide through\n * its anchored edge. Focus is trapped while open.\n */\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n isHidden = false,\n onClose,\n title,\n description,\n side = \"end\",\n size = \"md\",\n hasHeader = true,\n isActive = true,\n onInactivePress,\n inactivePressLabel,\n hasScrim = true,\n overlayLayer,\n variant = \"default\",\n closeLabel = \"Close\",\n portalContainer,\n footer,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const { layer, isVisible, isResumed } = useDialogPresence(isOpen, isHidden, overlayLayer);\n const { active, isInert, canPress, frameInert, panelAttributes } = drawerInteraction({\n isOpen,\n isVisible,\n isActive,\n onInactivePress,\n ariaHidden: rest[\"aria-hidden\"],\n });\n const panelRef = useRef<HTMLDivElement | null>(null);\n const scrimRef = useRef<HTMLDivElement | null>(null);\n const closeRef = useRef<HTMLButtonElement | null>(null);\n const titleId = useId();\n const descriptionId = useId();\n const [exiting, onTransitionEnd] = useDrawerExit(isOpen, scrimRef);\n const { onScrimMouseDown, order } = useModalDialog({\n isOpen,\n isActive: active,\n layer,\n panelRef,\n onClose,\n // A hidden header's close button can't take focus.\n initialFocus: variant === \"navigation\" && hasHeader ? () => closeRef.current : undefined,\n // Panels start off-screen; focusing them must not scroll the page with them.\n preventScroll: true,\n container: portalContainer,\n });\n const portal = useDialogPortal(order, isOpen || exiting, portalContainer);\n useInheritedPortalScope(scrimRef, isOpen, { keepDir: rest.dir !== undefined });\n\n if ((!isOpen && !exiting) || !portal) {\n return null;\n }\n\n return createPortal(\n <DialogContent\n layer={layer}\n isSuspended={isInert}\n >\n <div\n ref={(node) => {\n scrimRef.current = node;\n if (node) {\n node.inert = frameInert;\n }\n }}\n className=\"ds-drawer-scrim\"\n hidden={!isVisible}\n data-scrim={hasScrim ? undefined : \"none\"}\n data-inactive-press={canPress || undefined}\n data-resumed={isResumed || undefined}\n style={{ zIndex: layer }}\n dir={rest.dir}\n data-side={side}\n data-variant={variant}\n data-contained={portalContainer ? \"\" : undefined}\n data-state={isOpen ? \"open\" : \"closed\"}\n aria-hidden={frameInert || undefined}\n onTransitionEnd={onTransitionEnd}\n onMouseDown={onScrimMouseDown}\n >\n <div\n {...rest}\n ref={mergeRefs(panelRef, ref)}\n {...dialogAttributes(rest, titleId, descriptionId, Boolean(description), active)}\n {...panelAttributes}\n data-side={side}\n data-size={size}\n data-header={hasHeader ? undefined : \"none\"}\n data-variant={variant}\n className={[\"ds-drawer\", \"ds-field-surface\", className].filter(Boolean).join(\" \")}\n >\n <DrawerContent\n isInert={isInert}\n title={title}\n description={description}\n onClose={onClose}\n hasHeader={hasHeader}\n variant={variant}\n closeLabel={closeLabel}\n titleId={titleId}\n descriptionId={descriptionId}\n closeRef={closeRef}\n footer={footer}\n onInactivePress={canPress ? onInactivePress : undefined}\n inactivePressLabel={inactivePressLabel}\n >\n {children}\n </DrawerContent>\n </div>\n </div>\n </DialogContent>,\n portal,\n );\n});\n"],"mappings":"A,qSAOA,SAAgBuB,EAAW,CACzB,QACA,cACA,UACA,YACA,UACA,aACA,UACA,gBACA,YACY,CACZ,OACE,EAAAD,EAAA,KAAA,CAAC,SAAD,CACE,UAAU,kBACV,OAAQ,CAACE,EAFX,SAAA,EAIE,EAAAF,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,oBAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,KAAD,CACE,GAAIG,EACJ,UAAU,mBAET,SAAAC,CACC,CAAA,EACHC,IACC,EAAAL,EAAA,IAAA,CAAC,IAAD,CACE,GAAIM,EACJ,UAAU,yBAET,SAAAD,CACA,CAAA,CAEF,CACL,CAAA,GAAA,EAAAL,EAAA,IAAA,CAACtB,EAAAA,OAAD,CACE,IAAK6B,EACL,QAAQ,SACR,KAAMC,IAAY,aAAe,KAAO,KACxC,W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BAAoB4C,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAEhF,UAAA,EAAApD,EAAA,IAAA,CAACoB,EAAD,CACW,UACF,QACM,cACJ,UACE,YACF,UACG,aACH,UACM,gBACL,WACF,SACR,gBAAiBH,EAAWC,EAAkB,IAAA,GAC1B,qBAEnB,UACY,CAAA,CACZ,CAAA,CACF,CAAA,CACQ,CAAA,EACfuB,CACF,CACF,CAAC,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./Icon-QLZH31JA.cjs"),t=require("../components/Button/index.cjs"),n=require("./overlayLayer-CPd3zj_u.cjs"),r=require("../components/Badge/index.cjs"),i=require("./limit-BNo4dlRj.cjs"),a=require("../components/LimitReading/index.cjs"),o=require("../components/Modal/index.cjs"),s=require("./style-nulIa2_8.cjs"),c=require("../components/Grid/index.cjs"),l=require("./LoadState-BXLG-SkQ.cjs"),u=require("../components/SearchField/index.cjs"),d=require("../components/Choice/index.cjs"),f=require("../components/SortableList/index.cjs");let p=require("react"),m=require("react/jsx-runtime");function h(e,t,n,r){let i=l.n(t,n,r);return t!==`error`&&i.state!==`pending`?null:(0,m.jsx)(l.r,{title:e,error:i.error,onRetry:i.retry,retryState:i.state})}function g({query:e,itemLabel:t,itemsLabel:n,canCreate:r}){let i=e.trim();return(0,m.jsxs)(`div`,{className:`ds-entry-picker__no-results`,children:[(0,m.jsx)(`p`,{children:i?`No ${n} match “${i}”`:`No ${n} yet`}),i&&(0,m.jsxs)(`p`,{children:[`Try a different search.`,r?` Or create the ${t} you need.`:``]})]})}function _(e,t){let r=e.closest(`.ds-entry-picker__scroll`)??e.parentElement,i=Array.from(r?.querySelectorAll(`.ds-entry-picker__result`)??[]);for(let e of[...i.slice(t),...i.slice(0,t).reverse()]){let t=n.b(e)[0];if(t)return t}}function v(e){let t=(0,p.useRef)(null),r=(0,p.useRef)(null),{more:i,offset:a}=e;return(0,p.useEffect)(()=>{let e=r.current,a=t.current;e!==null&&i.status!==`loading`&&(r.current=null,a&&n.h(document.activeElement)&&(i.status===`error`?n.b(a)[0]:_(a,e))?.focus())},[i.status,a]),{pagingRef:t,load:()=>{r.current=t.current?.contains(document.activeElement)?a:null,i.load()}}}function y(e,t){let r=(0,p.useRef)(t);(0,p.useEffect)(()=>{if(r.current===t)return;r.current=t;let i=e.current;i&&n.h(document.activeElement)&&(n.b(i)[0]??_(i,1/0))?.focus()},[e,t])}function b({count:e,total:n,isRemote:r,pageSize:i,remote:a,itemsLabel:o}){let{more:s}=a,{pagingRef:c,load:l}=v(a),u=h(`Couldn't load more ${o}`,s.status,s.error,l);return y(c,u?`failure`:r&&a.hasMore?`more`:`none`),n===0?null:(0,m.jsxs)(`div`,{ref:c,className:`ds-entry-picker__paging`,children:[u??(r&&a.hasMore&&(0,m.jsxs)(t.Button,{isPending:s.status===`loading`,isFocusableWhenDisabled:!0,isDisabled:!s.isAvailable,onClick:l,children:[`Load `,Math.min(i,n-a.offset),` more`]})),(0,m.jsx)(`span`,{children:e<n?`Showing ${e} of ${n}`:`All ${e} shown`})]})}function x(e,t,{isDisabled:n,searching:r,atMax:i}){if(n||r)return`inactive`;if(e.isDisabled)return`restricted`;if(!t&&i)return`full`}function S(e){return e.isDisabled?e.disabledReason:void 0}function C(e){return e.tone===`removed`}function w(e){return C(e)?void 0:S(e)}function T({item:t,reasonId:n}){let i=S(t);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`ds-entry__thumb`,children:t.imageUrl?(0,m.jsx)(`img`,{src:t.imageUrl,alt:``,loading:`lazy`}):(0,m.jsx)(e.t,{name:`file-text`,size:20})}),(0,m.jsxs)(`span`,{className:`ds-entry__body`,children:[(0,m.jsx)(`span`,{className:`ds-entry__title`,"data-unavailable":t.isUnavailable||void 0,children:t.title}),t.metadata!=null&&(0,m.jsx)(`span`,{className:`ds-entry__meta`,children:t.metadata}),i&&(0,m.jsxs)(`span`,{id:n,className:`ds-entry__reason`,children:[(0,m.jsx)(r.Badge,{shape:`tag`,size:`sm`,children:i.label}),` `,(0,m.jsx)(`span`,{children:i.description})]})]})]})}function E({item:e,reasonId:t}){return C(e)?(0,m.jsxs)(`span`,{className:`ds-entry__removed`,children:[(0,m.jsx)(`strong`,{children:e.title}),` `,e.metadata??(0,m.jsx)(`code`,{children:e.id})]}):(0,m.jsx)(T,{item:e,reasonId:t})}function D({item:e}){return C(e)?(0,m.jsx)(r.Badge,{shape:`tag`,children:e.removedLabel??`Removed on save`}):null}function O({item:e,onEdit:n,isDisabled:r}){return!n||e.isUnavailable||e.isDisabled?null:(0,m.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`pencil`,"aria-label":`Edit ${e.title}`,isDisabled:r,onClick:()=>n(e)})}function k({items:e,selected:t,block:n,onToggle:r,onEdit:i}){let a=(0,p.useId)(),o=`${a}-full`;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{id:o,hidden:!0,children:`The selection is full. Remove one to choose another.`}),(0,m.jsx)(`ul`,{className:`ds-entry-picker__results`,"data-searching":n.searching||void 0,children:e.map((e,s)=>{let c=t.includes(e.id),l=x(e,c,n),u=S(e)?`${a}-reason-${s}`:void 0;return(0,m.jsxs)(`li`,{className:`ds-entry-picker__result ds-field-surface`,"data-selected":c||void 0,"data-blocked":l?!0:void 0,onClick:t=>{let n=t.target instanceof Element?t.target.closest(`button, input, label, a, select, textarea, summary, [tabindex]`):null;(!n||!t.currentTarget.contains(n))&&r(e.id)},children:[(0,m.jsx)(d.Checkbox,{checked:c,"aria-checked":c,"aria-label":`Select ${e.title}`,"aria-describedby":l===`full`?o:u,disabled:!!l,isFocusableWhenDisabled:l!==`inactive`,onChange:()=>r(e.id)}),(0,m.jsx)(`span`,{className:`ds-entry`,children:(0,m.jsx)(T,{item:e,reasonId:u})}),(0,m.jsx)(O,{item:e,onEdit:i,isDisabled:l===`inactive`})]},e.id)})})]})}function A(){let e=(0,p.useRef)(null),[t,n]=(0,p.useState)(!1);return{ref:e,scrolled:t,toTop:()=>{n(!1),e.current&&(e.current.scrollTop=0)},onScroll:e=>{n(e.currentTarget.scrollTop>0)}}}function j(e,t){return e&&t?(0,m.jsxs)(c.Stack,{gap:`sm`,children:[e,t]}):e||t}function M({isOpen:e,onClose:n,query:r,onQuery:i,selected:s,results:c,cap:u,block:d,isRemote:f,pageSize:p,remote:_,onToggle:v,onEdit:y,confirm:x,selectionNotice:S,selectionFailure:C,isCreateDisabled:w,itemLabel:T,itemsLabel:E,addLabel:D,onCreate:O,isCreating:A,dialogTitle:M,dialogDescription:P,isDialogHidden:F}){let I=h(`Couldn't refresh ${E}`,_.refresh.status,_.refresh.error,_.refresh.retry);return(0,m.jsx)(o.Modal,{isOpen:e,isHidden:F,onClose:n,title:M??D,description:P??u.description,className:`ds-entry-picker__dialog`,footer:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`span`,{className:`ds-entry-picker__selection`,role:`status`,children:[u.reading?(0,m.jsx)(a.LimitReading,{...u.reading,size:`lg`}):`${s.length} selected`,S&&`. ${S}`]}),(0,m.jsx)(t.Button,{variant:`primary`,isDisabled:x?.isDisabled,onClick:x?.onClick??n,children:x?.label??`Done`})]}),children:(0,m.jsx)(N,{query:r,onQuery:i,itemsLabel:E,isSearching:_.loading,action:O&&(0,m.jsx)(t.Button,{variant:`primary`,isPending:A,isFocusableWhenDisabled:!0,iconStart:`plus`,isDisabled:d.isDisabled||u.atMax||w,onClick:O,children:`New ${T}`}),banner:j(I,C),isBusy:_.loading||_.more.status===`loading`||_.refresh.status===`loading`,children:(0,m.jsxs)(l.t,{status:_.status,errorTitle:`Couldn't load ${E}`,error:_.error,onRetry:_.retry,children:[(0,m.jsx)(k,{items:c,selected:s,block:d,onToggle:v,onEdit:y}),!_.searching&&c.length===0&&(0,m.jsx)(g,{query:r,itemLabel:T,itemsLabel:E,canCreate:!!O}),(0,m.jsx)(b,{count:c.length,total:f?_.total:c.length,isRemote:f,pageSize:p,remote:_,itemsLabel:E})]})})})}function N({query:e,onQuery:t,itemsLabel:n,isSearching:r,action:i,banner:a,isBusy:o,children:s}){let{ref:c,scrolled:l,onScroll:d,toTop:f}=A(),p=e=>{f(),t(e)};return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`ds-entry-picker__search ds-field-surface`,"data-scrolled":l||void 0,children:[(0,m.jsx)(u.SearchField,{"aria-label":`Search ${n}`,value:e,isBusy:r,placeholder:`Search ${n}`,onChange:e=>p(e.target.value),onClear:()=>p(``)}),i]}),a&&(0,m.jsx)(`div`,{className:`ds-entry-picker__refresh`,children:a}),(0,m.jsx)(`div`,{className:`ds-entry-picker__scroll`,ref:c,onScroll:d,"aria-busy":o,children:s})]})}function P({items:e,selected:n,onChange:r,onEdit:i,isDisabled:a,canReorder:o,emptyLabel:s}){let c=(0,p.useId)(),l=(e,t)=>w(e)?`${c}-reason-${t}`:void 0,u=(e,o)=>(0,m.jsxs)(`span`,{className:`ds-entry-picker__item-actions`,children:[(0,m.jsx)(D,{item:e}),(0,m.jsx)(O,{item:e,onEdit:e.tone===`removed`?void 0:i,isDisabled:a}),(0,m.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`x`,"aria-label":`Remove ${e.title}`,"aria-describedby":o,isDisabled:a,onClick:()=>r(n.filter(t=>t!==e.id))})]});return e.length===0?(0,m.jsx)(`p`,{className:`ds-entry-picker__empty`,children:s}):o?(0,m.jsx)(f.SortableList,{items:n,onReorder:r,isDisabled:a,children:e.map((e,t)=>(0,m.jsx)(f.SortableListItem,{id:e.id,label:e.title,"data-tone":e.tone,handleDescribedBy:l(e,t),action:u(e,l(e,t)),children:(0,m.jsx)(`div`,{className:`ds-entry`,children:(0,m.jsx)(E,{item:e,reasonId:l(e,t)})})},e.id))}):(0,m.jsx)(`ul`,{className:`ds-entry-picker__list`,children:e.map((e,t)=>(0,m.jsxs)(`li`,{className:`ds-entry-picker__row ds-field-surface`,"data-tone":e.tone,children:[(0,m.jsx)(`div`,{className:`ds-entry`,children:(0,m.jsx)(E,{item:e,reasonId:l(e,t)})}),u(e,l(e,t))]},e.id))})}function F(e,t,n){return{id:e,title:t,metadata:n,isUnavailable:!0}}function I({selected:e,items:t,pageItems:n,known:r,failures:i,hasResolver:a,itemLabel:o}){let s=new Map(t.map(e=>[e.id,e])),c=new Map(n.map(e=>[e.id,e]));return e.map(e=>(s.get(e)??(r.has(e)?r.get(e):c.get(e)))||(r.has(e)?F(e,`${`${o.charAt(0).toUpperCase()}${o.slice(1)}`} no longer available`,`Replace or clear this selection.`):a?F(e,i.has(e)?`Couldn't load ${o}`:`Loading…`):{id:e,title:e}))}function L(e,t){return e===`single`||t===1}function R(e,t,n){return L(e,n)?{count:t,max:1,tone:`neutral`}:e===`multiple`&&n!==void 0?{count:t,max:n}:void 0}function z(e,t,n){return L(e,n)?void 0:t}function B(e,t,n,{itemLabel:r,itemsLabel:a}){let o=R(e,t,n),s=e===`multiple`&&o&&Number.isFinite(o.max)?o.max:void 0,c=`Choose as many ${a} as you need.`;return e===`single`||s===1?c=`Choose one ${r}.`:s!==void 0&&(c=`Choose up to ${s} ${a}.`),{limit:o,atMax:s!==void 0&&t>=s,description:c,reading:e===`multiple`&&i.r(o)?o:void 0}}function V(e){return e instanceof Error?e:null}function H(e,t){if(!t.some(t=>e.has(t)))return e;let n=new Map(e);for(let e of t)n.delete(e);return n}function U(e,t,n){let r=n?t.flatMap(t=>{let r=n(t);return r?.item.id===t&&e.seeds.get(t)!==r?[r]:[]}):[];if(r.length===0)return e;let i=r.filter(t=>Object.is(t.revision,e.refreshKey)),a=r.filter(t=>!Object.is(t.revision,e.refreshKey)&&!e.known.has(t.item.id)&&!e.stale.has(t.item.id)),o=e=>e.map(e=>[e.item.id,e.item]);return{...e,seeds:new Map([...e.seeds,...r.map(e=>[e.item.id,e])]),known:i.length?new Map([...e.known,...o(i)]):e.known,stale:a.length?new Map([...e.stale,...o(a)]):e.stale,failures:H(e.failures,i.map(e=>e.item.id))}}function W(e,t){return e!==t&&(e.length!==t.length||t.some(t=>!e.includes(t)))}function G(e,t,n,r){let i=e;if(Object.is(i.refreshKey,n)||(i={...i,refreshKey:n,known:new Map,stale:new Map([...i.stale,...i.known]),failures:new Map}),W(i.selected,t)){let e=i.selected.filter(e=>!t.includes(e));i={...i,selected:t,known:H(i.known,e),stale:H(i.stale,e),failures:H(i.failures,e),seeds:H(i.seeds,e)}}return U(i,t,r)}function K(e,t,r,i,a){let o=n.u(r),s=n.u(e),[c,l]=(0,p.useState)(()=>U({refreshKey:i,selected:e,known:new Map,stale:new Map,failures:new Map,seeds:new Map},e,a)),u=G(c,e,i,a);u!==c&&l(u);let{known:d,stale:f,failures:m}=u,h=(0,p.useMemo)(()=>f.size===0?d:new Map([...f,...d]),[f,d]),g=(e,t,n=s.current)=>{let r=e.filter(e=>e!==void 0&&n.includes(e.id)).map(e=>[e.id,e]);r.length!==0&&l(e=>{if(Object.is(e.refreshKey,t))return{...e,known:new Map([...e.known,...r])};let n=r.filter(([t])=>!e.known.has(t)&&!e.stale.has(t));return n.length===0?e:{...e,stale:new Map([...e.stale,...n])}})},_=new Set(t.map(e=>e.id)),v=r?e.filter(e=>!_.has(e)&&!d.has(e)&&!m.has(e)):[],y=JSON.stringify(v),b=(0,p.useRef)({refreshKey:i,tokens:new Map});(0,p.useEffect)(()=>{let e=o.current;if(!e)return;let t=JSON.parse(y);Object.is(b.current.refreshKey,i)||(b.current={refreshKey:i,tokens:new Map});let{tokens:n}=b.current;for(let e of n.keys())t.includes(e)||n.delete(e);for(let r of t.filter(e=>!n.has(e))){let t=Symbol(r);n.set(r,t);let a=e=>{b.current.tokens.get(r)===t&&(b.current.tokens.delete(r),l(t=>Object.is(t.refreshKey,i)&&t.selected.includes(r)?e(t):t))};Promise.resolve().then(()=>e(r)).then(e=>a(t=>t.known.has(r)?t:{...t,known:new Map(t.known).set(r,e??null)}),e=>a(t=>({...t,failures:new Map(t.failures).set(r,V(e))})))}},[y,i,o]);let x=e.filter(e=>m.has(e)&&!d.has(e));return{known:h,current:d,failures:m,remember:g,status:v.length>0?`loading`:x.length>0?`error`:`ready`,error:x.length>0?m.get(x[0])??null:null,retry:()=>l(e=>({...e,failures:H(e.failures,x)}))}}var q=250;function J(e){return Array.from(new Map(e.map(e=>[e.id,e])).values())}var Y={items:[],offset:0,total:0},X={...Y,key:null,revision:void 0,status:`ready`,error:null};function Z(e,t){let n=e?.status===`error`&&t;return{status:e?.status===`loading`?`loading`:n?`error`:`ready`,error:n?e.error??null:null,isAvailable:t}}function Q(e,t){return{items:J([...e.items,...t.items]),offset:e.offset+t.items.length,total:t.items.length===0?Math.min(t.total,e.offset):t.total}}function ee(e,t,n,r){return e.key!==t||e.offset!==n?e:{...e,...Q(e,r)}}async function te(e,t,n,r,i){let a=Math.max(1,Math.ceil(r/n)),o=await Promise.all(Array.from({length:a},(r,i)=>e({offset:i*n,limit:n},{query:t}))),s=Y;for(let[e,t]of o.entries()){if(s.offset!==e*n)break;s=Q(s,t)}for(;s.offset<r&&s.offset<s.total&&i();)s=Q(s,await e({offset:s.offset,limit:n},{query:t}));return s}function ne(e,t,n,r){let i=e!==null&&t.key===e,a=i&&Object.is(t.revision,n),o=e!==null&&!a&&(!i||t.status===`error`),s=o&&t.key!==null&&t.status===`ready`,c=o&&!s?`loading`:t.status===`error`?`error`:`ready`,l=t.status===`ready`&&t.offset<t.total,u=i&&!a&&t.status===`ready`,d=u&&r?.key===e&&Object.is(r.revision,n);return{loading:o,searching:s,status:c,hasMore:l,refresh:u?d?`error`:`loading`:`ready`,refreshFailed:d}}function re(e,t,r,i,a,o){let s=n.u(e),c=n.u(a),l=n.u(o),[u,d]=(0,p.useState)(0),[f,m]=(0,p.useState)(X),[h,g]=(0,p.useState)(null),[_,v]=(0,p.useState)(null),[y,b]=(0,p.useState)(i);y!==i&&(b(i),i||(m(X),g(null),v(null),d(e=>e+1)));let x=r.trim(),S=e&&i?JSON.stringify([x,t,u]):null,C=n.u(f),w=(0,p.useRef)(null),T=(0,p.useRef)(x),{loading:E,searching:D,status:O,hasMore:k,refresh:A,refreshFailed:j}=ne(S,f,o,_),M=!E&&A===`ready`,N=E?`load`:A===`loading`?`refresh`:null;(0,p.useEffect)(()=>{if(S===null)return;let e=N===`load`&&x!==T.current?q:0;if(T.current=x,N===null)return;let n=N===`refresh`?C.current.offset+(w.current?t:0):0,r=!0,i=window.setTimeout(()=>{let e=s.current;e&&te(e,x,t,n,()=>r).then(e=>{r&&(w.current=null,m({...e,key:S,revision:o,status:`ready`,error:null}),g(null),v(null),c.current?.(e.items,o))},e=>{r&&(N===`refresh`?v({key:S,revision:o,error:V(e)}):(w.current=null,m({...X,key:S,revision:o,status:`error`,error:V(e)}),g(null)))})},e);return()=>{r=!1,window.clearTimeout(i)}},[S,N,o,x,t,s,c,C]);let P=()=>{let e=s.current,n=f.key,{offset:r}=f;if(!e||n===null||!M||!k||w.current)return;let i=Symbol(`load more`),a=o;w.current=i,g({token:i,status:`loading`,error:null});let u=()=>w.current===i&&C.current.key===n&&C.current.offset===r&&Object.is(l.current,a),d=e=>{w.current===i&&(w.current=null),g(t=>t?.token===i?e:t)};Promise.resolve().then(()=>e({offset:r,limit:t},{query:x})).then(e=>{u()&&(m(t=>ee(t,n,r,e)),c.current?.(e.items,a)),d(null)},e=>d(u()?{token:i,status:`error`,error:V(e)}:null))};return{items:f.items,total:f.total,offset:f.offset,hasMore:k,pageRevision:f.revision,loading:E,searching:D,status:O,error:f.error,retry:()=>d(e=>e+1),more:{...Z(h,M),load:P},refresh:{status:A,error:j?_?.error??null:null,retry:()=>v(null)}}}var $=[];function ie(e,t){return!!(e.isDisabled||t?.(e))}function ae(e,t){return t?e.map(e=>{let n=e.isDisabled?void 0:t(e);return n?{...e,isDisabled:!0,disabledReason:n}:e}):e}function oe(e,t,n,{isOpen:r,isDisabled:i,itemLabel:a,itemsLabel:o,close:s,recheckSelection:c,restrict:l}){let[u,d]=(0,p.useState)(``),{resolveItem:f,refreshKey:m,loadPage:h,pageSize:g=10,mode:_=`multiple`,max:v,onEditItem:y}=n,b=!!h,S=c&&b&&!!f,C=K(e,S?$:t,f,m),w=re(h,g,u,r,S?(e,t)=>C.remember(e.filter(e=>ie(e,l)),t):C.remember,m),T=(0,p.useMemo)(()=>{let e=u.trim().toLowerCase();return b?$:t.filter(t=>!e||[t.title,...t.keywords??[]].join(` `).toLowerCase().includes(e))},[b,t,u]),E=b?w.items:T,D=(0,p.useMemo)(()=>ae(E,l),[E,l]),O=B(_,e.length,v,{itemLabel:a,itemsLabel:o}),k={isDisabled:i,searching:w.searching,atMax:O.atMax},A=y?e=>{y(e)===!1&&s()}:void 0;return{selection:C,remote:w,isRemote:b,results:D,cap:O,block:k,editItem:A,revision:b?w.pageRevision:m,choice:t=>{let n=D.find(e=>e.id===t);return n&&!x(n,e.includes(t),k)?n:void 0},dialog:{query:u,onQuery:d,selected:e,results:D,cap:O,block:k,isRemote:b,pageSize:g,remote:w,onEdit:A,itemLabel:a,itemsLabel:o}}}var se=[];function ce({items:e=se,value:n,defaultValue:r=[],onValueChange:i,mode:a=`multiple`,max:o,label:c=`Entries`,emptyLabel:l=`Nothing selected yet.`,addLabel:u=`Choose entries`,itemLabel:d=`entry`,itemsLabel:f=`entries`,isReorderable:g=!0,isDisabled:_=!1,loadPage:v,pageSize:y=10,resolveItem:b,onEditItem:x,onCreate:S,isCreating:C=!1,refreshKey:w,dialogTitle:T,dialogDescription:E,isDialogHidden:D=!1,className:O,...k}){let[A,j]=(0,p.useState)(r),N=n??A,[F,L]=(0,p.useState)(!1),R=oe(N,e,{resolveItem:b,refreshKey:w,loadPage:v,pageSize:y,mode:a,max:o,onEditItem:x},{isOpen:F,isDisabled:_,itemLabel:d,itemsLabel:f,close:()=>L(!1)}),{selection:B,remote:V,cap:H,editItem:U}=R,W=h(`Couldn't load selected ${f}`,B.status,B.error,B.retry),G=e=>{_||(n===void 0&&j(e),i?.(e))},K=(e,t)=>{B.remember([t],R.revision,e),G(e)},q=e=>{let t=R.choice(e);t&&(a===`single`?(K(N[0]===e?[]:[e],t),L(!1)):N.includes(e)?G(N.filter(t=>t!==e)):K([...N,e],t))},{known:J,failures:Y}=B,X=!!b,Z=(0,p.useMemo)(()=>I({selected:N,items:e,pageItems:V.items,known:J,failures:Y,hasResolver:X,itemLabel:d}),[N,e,V.items,J,Y,X,d]);return(0,m.jsxs)(s.t,{...k,className:[`ds-entry-picker`,O].filter(Boolean).join(` `),label:c,count:z(a,N.length,o),limit:k.limit===void 0?H.limit:k.limit,children:[(0,m.jsx)(P,{items:Z,selected:N,onChange:G,onEdit:U,isDisabled:_,canReorder:g&&a===`multiple`&&Z.length>1,emptyLabel:l}),W,(0,m.jsxs)(`div`,{className:`ds-entry-picker__actions`,children:[(0,m.jsx)(t.Button,{variant:`neutral`,size:`sm`,iconStart:`plus`,isDisabled:_,onClick:()=>L(!0),children:u}),N.length>0&&(0,m.jsx)(t.Button,{variant:`simple`,size:`sm`,isDisabled:_,onClick:()=>G([]),children:`Clear`})]}),(0,m.jsx)(M,{...R.dialog,isOpen:F,onClose:()=>L(!1),onToggle:q,addLabel:u,onCreate:S,isCreating:C,dialogTitle:T,dialogDescription:E,isDialogHidden:D})]})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return ce}});
|
|
2
|
+
//# sourceMappingURL=EntryPicker-C7EBfpaw.cjs.map
|