@namroodinc/liquid-editorial 0.7.0 → 0.8.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 +53 -5
- package/UPGRADING.md +372 -0
- package/dist/chunks/{Avatar-DdFEOumt.js → Avatar-6t78C9Np.js} +2 -2
- package/dist/chunks/{Avatar-DdFEOumt.js.map → Avatar-6t78C9Np.js.map} +1 -1
- package/dist/chunks/{Avatar-B_2lI7fS.cjs → Avatar-Cvj_DqG0.cjs} +2 -2
- package/dist/chunks/{Avatar-B_2lI7fS.cjs.map → Avatar-Cvj_DqG0.cjs.map} +1 -1
- package/dist/chunks/CollectionView-B18Ihv7X.cjs +2 -0
- package/dist/chunks/CollectionView-B18Ihv7X.cjs.map +1 -0
- package/dist/chunks/{CollectionView-Cr12UFWa.js → CollectionView-C-SwkPWC.js} +28 -29
- package/dist/chunks/CollectionView-C-SwkPWC.js.map +1 -0
- package/dist/chunks/ColourField-Dohdx7eW.cjs +2 -0
- package/dist/chunks/ColourField-Dohdx7eW.cjs.map +1 -0
- package/dist/chunks/{ColourField-B-tjjBfA.js → ColourField-DzZ--mQZ.js} +122 -122
- package/dist/chunks/ColourField-DzZ--mQZ.js.map +1 -0
- package/dist/chunks/DatePicker-Bjc4D8Kg.cjs +2 -0
- package/dist/chunks/DatePicker-Bjc4D8Kg.cjs.map +1 -0
- package/dist/chunks/DatePicker-DZVOtzoU.js +298 -0
- package/dist/chunks/DatePicker-DZVOtzoU.js.map +1 -0
- package/dist/chunks/Drawer-CcVF_p4b.cjs +2 -0
- package/dist/chunks/Drawer-CcVF_p4b.cjs.map +1 -0
- package/dist/chunks/Drawer-uhJvy3s9.js +172 -0
- package/dist/chunks/Drawer-uhJvy3s9.js.map +1 -0
- package/dist/chunks/EntryPicker-CBquan7o.js +685 -0
- package/dist/chunks/EntryPicker-CBquan7o.js.map +1 -0
- package/dist/chunks/EntryPicker-Dq72wjTt.cjs +2 -0
- package/dist/chunks/EntryPicker-Dq72wjTt.cjs.map +1 -0
- package/dist/chunks/FormEditor-CTcnpR51.cjs +2 -0
- package/dist/chunks/FormEditor-CTcnpR51.cjs.map +1 -0
- package/dist/chunks/{FormEditor-ucTbDyQt.js → FormEditor-D0J3JN-H.js} +177 -160
- package/dist/chunks/FormEditor-D0J3JN-H.js.map +1 -0
- package/dist/chunks/{LoadState-B7GTDlWv.js → LoadState-B056EPu7.js} +20 -19
- package/dist/chunks/LoadState-B056EPu7.js.map +1 -0
- package/dist/chunks/LoadState-BXLG-SkQ.cjs +2 -0
- package/dist/chunks/LoadState-BXLG-SkQ.cjs.map +1 -0
- package/dist/chunks/NumberField-CVsK4l9P.js +178 -0
- package/dist/chunks/NumberField-CVsK4l9P.js.map +1 -0
- package/dist/chunks/NumberField-Ccjpa_1d.cjs +2 -0
- package/dist/chunks/NumberField-Ccjpa_1d.cjs.map +1 -0
- package/dist/chunks/{RichTextEditor-CNkwWist.js → RichTextEditor-B6H6_3wk.js} +28 -28
- package/dist/chunks/{RichTextEditor-CNkwWist.js.map → RichTextEditor-B6H6_3wk.js.map} +1 -1
- package/dist/chunks/RichTextEditor-BIopdEDA.cjs +2 -0
- package/dist/chunks/RichTextEditor-BIopdEDA.cjs.map +1 -0
- package/dist/chunks/dialogLabel-3EeaH1Zl.cjs +2 -0
- package/dist/chunks/dialogLabel-3EeaH1Zl.cjs.map +1 -0
- package/dist/chunks/dialogLabel-BjtTix5C.js +176 -0
- package/dist/chunks/dialogLabel-BjtTix5C.js.map +1 -0
- package/dist/chunks/frame-BtIh7K-M.cjs +2 -0
- package/dist/chunks/frame-BtIh7K-M.cjs.map +1 -0
- package/dist/chunks/frame-CycTDnzE.js +164 -0
- package/dist/chunks/frame-CycTDnzE.js.map +1 -0
- package/dist/chunks/{group-C6EOgTgM.js → group-67F_I1yw.js} +3 -3
- package/dist/chunks/{group-C6EOgTgM.js.map → group-67F_I1yw.js.map} +1 -1
- package/dist/chunks/{group-QSnlx4jX.cjs → group-BSJHLagi.cjs} +2 -2
- package/dist/chunks/{group-QSnlx4jX.cjs.map → group-BSJHLagi.cjs.map} +1 -1
- package/dist/chunks/limit-BBnpe9o9.cjs +2 -0
- package/dist/chunks/limit-BBnpe9o9.cjs.map +1 -0
- package/dist/chunks/limit-BHHST_0G.js +15 -0
- package/dist/chunks/limit-BHHST_0G.js.map +1 -0
- package/dist/chunks/overlayLayer-BgnMskpk.js +158 -0
- package/dist/chunks/overlayLayer-BgnMskpk.js.map +1 -0
- package/dist/chunks/overlayLayer-YVudmo27.cjs +2 -0
- package/dist/chunks/overlayLayer-YVudmo27.cjs.map +1 -0
- package/dist/chunks/{useLimit-BOmHKdJE.js → useLimit-C471qZ4H.js} +2 -2
- package/dist/chunks/useLimit-C471qZ4H.js.map +1 -0
- package/dist/chunks/{useLimit-DXe_VmYl.cjs → useLimit-WWWDacob.cjs} +2 -2
- package/dist/chunks/useLimit-WWWDacob.cjs.map +1 -0
- package/dist/chunks/useTooltip-DajWQyNL.js +75 -0
- package/dist/chunks/useTooltip-DajWQyNL.js.map +1 -0
- package/dist/chunks/useTooltip-DtrE7QYu.cjs +2 -0
- package/dist/chunks/useTooltip-DtrE7QYu.cjs.map +1 -0
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.cjs.map +1 -1
- package/dist/components/AppShell/index.js +4 -4
- package/dist/components/AppShell/index.js.map +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Badge/index.cjs +1 -1
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.cts +3 -0
- package/dist/components/Badge/index.d.cts.map +1 -1
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +11 -10
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/style.css +25 -2
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.cts +4 -2
- package/dist/components/Button/index.d.cts.map +1 -1
- package/dist/components/Button/index.d.ts +4 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.js +1 -1
- package/dist/components/CollectionView/filters.d.cts.map +1 -1
- package/dist/components/CollectionView/filters.d.ts.map +1 -1
- 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.d.cts.map +1 -1
- package/dist/components/ColourField/index.d.ts.map +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/content.d.cts +27 -0
- package/dist/components/Drawer/content.d.cts.map +1 -0
- package/dist/components/Drawer/content.d.ts +27 -0
- package/dist/components/Drawer/content.d.ts.map +1 -0
- package/dist/components/Drawer/head.d.cts +10 -0
- package/dist/components/Drawer/head.d.cts.map +1 -0
- package/dist/components/Drawer/head.d.ts +10 -0
- package/dist/components/Drawer/head.d.ts.map +1 -0
- package/dist/components/Drawer/index.cjs +1 -2
- package/dist/components/Drawer/index.d.cts +21 -0
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts +21 -0
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +1 -102
- package/dist/components/Drawer/style.css +67 -0
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.js +10 -10
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/chosen.d.cts +16 -0
- package/dist/components/EntryPicker/chosen.d.cts.map +1 -0
- package/dist/components/EntryPicker/chosen.d.ts +16 -0
- package/dist/components/EntryPicker/chosen.d.ts.map +1 -0
- package/dist/components/EntryPicker/dialog.d.cts +22 -0
- package/dist/components/EntryPicker/dialog.d.cts.map +1 -0
- package/dist/components/EntryPicker/dialog.d.ts +22 -0
- package/dist/components/EntryPicker/dialog.d.ts.map +1 -0
- package/dist/components/EntryPicker/feedback.d.cts +20 -0
- package/dist/components/EntryPicker/feedback.d.cts.map +1 -0
- package/dist/components/EntryPicker/feedback.d.ts +20 -0
- package/dist/components/EntryPicker/feedback.d.ts.map +1 -0
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.d.cts +4 -38
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts +4 -38
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/item.d.cts +10 -0
- package/dist/components/EntryPicker/item.d.cts.map +1 -0
- package/dist/components/EntryPicker/item.d.ts +10 -0
- package/dist/components/EntryPicker/item.d.ts.map +1 -0
- package/dist/components/EntryPicker/results.d.cts +11 -0
- package/dist/components/EntryPicker/results.d.cts.map +1 -0
- package/dist/components/EntryPicker/results.d.ts +11 -0
- package/dist/components/EntryPicker/results.d.ts.map +1 -0
- package/dist/components/EntryPicker/selected-items.d.cts +11 -0
- package/dist/components/EntryPicker/selected-items.d.cts.map +1 -0
- package/dist/components/EntryPicker/selected-items.d.ts +11 -0
- package/dist/components/EntryPicker/selected-items.d.ts.map +1 -0
- package/dist/components/EntryPicker/style.css +129 -14
- package/dist/components/EntryPicker/types.d.cts +61 -0
- package/dist/components/EntryPicker/types.d.cts.map +1 -0
- package/dist/components/EntryPicker/types.d.ts +61 -0
- package/dist/components/EntryPicker/types.d.ts.map +1 -0
- package/dist/components/EntryPicker/use-picker-data.d.cts +40 -0
- package/dist/components/EntryPicker/use-picker-data.d.cts.map +1 -0
- package/dist/components/EntryPicker/use-picker-data.d.ts +40 -0
- package/dist/components/EntryPicker/use-picker-data.d.ts.map +1 -0
- package/dist/components/EntryPicker/use-selected-items.d.cts +21 -0
- package/dist/components/EntryPicker/use-selected-items.d.cts.map +1 -0
- package/dist/components/EntryPicker/use-selected-items.d.ts +21 -0
- package/dist/components/EntryPicker/use-selected-items.d.ts.map +1 -0
- package/dist/components/Field/frame.d.cts.map +1 -1
- package/dist/components/Field/frame.d.ts.map +1 -1
- package/dist/components/Field/index.cjs +1 -1
- package/dist/components/Field/index.js +1 -1
- package/dist/components/Field/{limit-reading.d.cts → limit-announcer.d.cts} +1 -4
- package/dist/components/Field/limit-announcer.d.cts.map +1 -0
- package/dist/components/Field/{limit-reading.d.ts → limit-announcer.d.ts} +1 -4
- package/dist/components/Field/limit-announcer.d.ts.map +1 -0
- package/dist/components/Field/limit.d.cts +1 -5
- package/dist/components/Field/limit.d.cts.map +1 -1
- package/dist/components/Field/limit.d.ts +1 -5
- package/dist/components/Field/limit.d.ts.map +1 -1
- package/dist/components/Field/style.css +0 -39
- package/dist/components/Field/types.d.cts +7 -3
- package/dist/components/Field/types.d.cts.map +1 -1
- package/dist/components/Field/types.d.ts +7 -3
- package/dist/components/Field/types.d.ts.map +1 -1
- package/dist/components/Field/useLimit.d.cts +1 -1
- package/dist/components/Field/useLimit.d.cts.map +1 -1
- package/dist/components/Field/useLimit.d.ts +1 -1
- package/dist/components/Field/useLimit.d.ts.map +1 -1
- package/dist/components/FormEditor/README.md +103 -10
- package/dist/components/FormEditor/control.d.cts +3 -2
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts +3 -2
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts +3 -2
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts +3 -2
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +14 -6
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +14 -6
- package/dist/components/FormEditor/model.d.ts.map +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/LimitReading/index.cjs +2 -0
- package/dist/components/LimitReading/index.cjs.map +1 -0
- package/dist/components/LimitReading/index.d.cts +5 -0
- package/dist/components/LimitReading/index.d.cts.map +1 -0
- package/dist/components/LimitReading/index.d.ts +5 -0
- package/dist/components/LimitReading/index.d.ts.map +1 -0
- package/dist/components/LimitReading/index.js +66 -0
- package/dist/components/LimitReading/index.js.map +1 -0
- package/dist/components/LimitReading/limit.d.cts +9 -0
- package/dist/components/LimitReading/limit.d.cts.map +1 -0
- package/dist/components/LimitReading/limit.d.ts +9 -0
- package/dist/components/LimitReading/limit.d.ts.map +1 -0
- package/dist/components/LimitReading/style.css +69 -0
- package/dist/components/LimitReading/types.d.cts +14 -0
- package/dist/components/LimitReading/types.d.cts.map +1 -0
- package/dist/components/LimitReading/types.d.ts +14 -0
- package/dist/components/LimitReading/types.d.ts.map +1 -0
- package/dist/components/LoadState/error.d.cts +3 -1
- package/dist/components/LoadState/error.d.cts.map +1 -1
- package/dist/components/LoadState/error.d.ts +3 -1
- package/dist/components/LoadState/error.d.ts.map +1 -1
- package/dist/components/LoadState/index.cjs +1 -1
- package/dist/components/LoadState/index.d.cts +3 -1
- package/dist/components/LoadState/index.d.cts.map +1 -1
- package/dist/components/LoadState/index.d.ts +3 -1
- package/dist/components/LoadState/index.d.ts.map +1 -1
- package/dist/components/LoadState/index.js +1 -1
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +50 -49
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts +9 -0
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +71 -64
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +16 -0
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.d.cts +1 -1
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts +1 -1
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/NumberField/style.css +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 +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +57 -55
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Popover/style.css +6 -0
- package/dist/components/Popover/useTooltip.d.cts +2 -1
- package/dist/components/Popover/useTooltip.d.cts.map +1 -1
- package/dist/components/Popover/useTooltip.d.ts +2 -1
- package/dist/components/Popover/useTooltip.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.cjs.map +1 -1
- package/dist/components/SearchField/index.d.cts +6 -1
- package/dist/components/SearchField/index.d.cts.map +1 -1
- package/dist/components/SearchField/index.d.ts +6 -1
- package/dist/components/SearchField/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.js +32 -26
- package/dist/components/SearchField/index.js.map +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.cts.map +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +73 -72
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.js +1 -1
- package/dist/components/Table/style.css +6 -1
- package/dist/components/TagsInput/index.cjs +1 -1
- package/dist/components/TagsInput/index.js +1 -1
- package/dist/components/TextField/index.cjs +1 -1
- package/dist/components/TextField/index.js +1 -1
- package/dist/components/Time/index.cjs +1 -1
- package/dist/components/Time/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -48
- package/dist/internal/dialogFocus.d.cts +2 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +2 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/dist/internal/dialogLabel.d.cts +10 -0
- package/dist/internal/dialogLabel.d.cts.map +1 -0
- package/dist/internal/dialogLabel.d.ts +10 -0
- package/dist/internal/dialogLabel.d.ts.map +1 -0
- package/dist/internal/dialogStack.d.cts +11 -3
- package/dist/internal/dialogStack.d.cts.map +1 -1
- package/dist/internal/dialogStack.d.ts +11 -3
- package/dist/internal/dialogStack.d.ts.map +1 -1
- package/dist/internal/movableHost.d.cts +9 -5
- package/dist/internal/movableHost.d.cts.map +1 -1
- package/dist/internal/movableHost.d.ts +9 -5
- package/dist/internal/movableHost.d.ts.map +1 -1
- package/dist/internal/overlayLayer.d.cts +33 -0
- package/dist/internal/overlayLayer.d.cts.map +1 -0
- package/dist/internal/overlayLayer.d.ts +33 -0
- package/dist/internal/overlayLayer.d.ts.map +1 -0
- package/dist/internal/portalScope.d.cts.map +1 -1
- package/dist/internal/portalScope.d.ts.map +1 -1
- package/dist/internal/useDialogPortal.d.cts +9 -0
- package/dist/internal/useDialogPortal.d.cts.map +1 -0
- package/dist/internal/useDialogPortal.d.ts +9 -0
- package/dist/internal/useDialogPortal.d.ts.map +1 -0
- package/dist/internal/useLatest.d.cts +7 -0
- package/dist/internal/useLatest.d.cts.map +1 -0
- package/dist/internal/useLatest.d.ts +7 -0
- package/dist/internal/useLatest.d.ts.map +1 -0
- package/dist/internal/useModalDialog.d.cts +5 -1
- package/dist/internal/useModalDialog.d.cts.map +1 -1
- package/dist/internal/useModalDialog.d.ts +5 -1
- package/dist/internal/useModalDialog.d.ts.map +1 -1
- package/dist/styles.css +1 -0
- package/dist/tokens.css +1 -2
- package/package.json +1 -1
- package/dist/chunks/CollectionView-BIuOL917.cjs +0 -2
- package/dist/chunks/CollectionView-BIuOL917.cjs.map +0 -1
- package/dist/chunks/CollectionView-Cr12UFWa.js.map +0 -1
- package/dist/chunks/ColourField-B-tjjBfA.js.map +0 -1
- package/dist/chunks/ColourField-ynUP1pfN.cjs +0 -2
- package/dist/chunks/ColourField-ynUP1pfN.cjs.map +0 -1
- package/dist/chunks/DatePicker-01sor8iD.cjs +0 -2
- package/dist/chunks/DatePicker-01sor8iD.cjs.map +0 -1
- package/dist/chunks/DatePicker-DJAqXUDJ.js +0 -297
- package/dist/chunks/DatePicker-DJAqXUDJ.js.map +0 -1
- package/dist/chunks/EntryPicker-B88N69zH.js +0 -180
- package/dist/chunks/EntryPicker-B88N69zH.js.map +0 -1
- package/dist/chunks/EntryPicker-daSkD4aR.cjs +0 -2
- package/dist/chunks/EntryPicker-daSkD4aR.cjs.map +0 -1
- package/dist/chunks/FormEditor-C_4JbAnS.cjs +0 -2
- package/dist/chunks/FormEditor-C_4JbAnS.cjs.map +0 -1
- package/dist/chunks/FormEditor-ucTbDyQt.js.map +0 -1
- package/dist/chunks/LoadState-B7GTDlWv.js.map +0 -1
- package/dist/chunks/LoadState-C7tQ6fIP.cjs +0 -2
- package/dist/chunks/LoadState-C7tQ6fIP.cjs.map +0 -1
- package/dist/chunks/NumberField-1EYJdwDY.cjs +0 -2
- package/dist/chunks/NumberField-1EYJdwDY.cjs.map +0 -1
- package/dist/chunks/NumberField-DizR4NJv.js +0 -178
- package/dist/chunks/NumberField-DizR4NJv.js.map +0 -1
- package/dist/chunks/RichTextEditor-DAnjElUO.cjs +0 -2
- package/dist/chunks/RichTextEditor-DAnjElUO.cjs.map +0 -1
- package/dist/chunks/frame-C8TwdWBC.cjs +0 -2
- package/dist/chunks/frame-C8TwdWBC.cjs.map +0 -1
- package/dist/chunks/frame-DaC03_n-.js +0 -203
- package/dist/chunks/frame-DaC03_n-.js.map +0 -1
- package/dist/chunks/limit-BX6-o1a2.cjs +0 -2
- package/dist/chunks/limit-BX6-o1a2.cjs.map +0 -1
- package/dist/chunks/limit-ChteDN4T.js +0 -18
- package/dist/chunks/limit-ChteDN4T.js.map +0 -1
- package/dist/chunks/movableHost-CajG9_5Z.cjs +0 -2
- package/dist/chunks/movableHost-CajG9_5Z.cjs.map +0 -1
- package/dist/chunks/movableHost-NJj_FsAu.js +0 -23
- package/dist/chunks/movableHost-NJj_FsAu.js.map +0 -1
- package/dist/chunks/portalScope-AzzPM54i.js +0 -105
- package/dist/chunks/portalScope-AzzPM54i.js.map +0 -1
- package/dist/chunks/portalScope-BVA1-Ypu.cjs +0 -2
- package/dist/chunks/portalScope-BVA1-Ypu.cjs.map +0 -1
- package/dist/chunks/useLimit-BOmHKdJE.js.map +0 -1
- package/dist/chunks/useLimit-DXe_VmYl.cjs.map +0 -1
- package/dist/chunks/useModalDialog-Cgus9408.cjs +0 -2
- package/dist/chunks/useModalDialog-Cgus9408.cjs.map +0 -1
- package/dist/chunks/useModalDialog-Dh-_6A0j.js +0 -85
- package/dist/chunks/useModalDialog-Dh-_6A0j.js.map +0 -1
- package/dist/chunks/useTooltip-C5gvEoYk.js +0 -74
- package/dist/chunks/useTooltip-C5gvEoYk.js.map +0 -1
- package/dist/chunks/useTooltip-bTE_a2Xn.cjs +0 -2
- package/dist/chunks/useTooltip-bTE_a2Xn.cjs.map +0 -1
- package/dist/components/Drawer/index.cjs.map +0 -1
- package/dist/components/Drawer/index.js.map +0 -1
- package/dist/components/Field/limit-reading.d.cts.map +0 -1
- package/dist/components/Field/limit-reading.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frame-DaC03_n-.js","names":["_Fragment","FieldFrameContext","visibleLimit","limitTone","usableLimit","limitDescription","Fragment$1","FieldHeader","Label","isGroup","support","hasLabelHint","labelHintId","labelHint","children","contents","label","count","Badge","isRequired","labelElement","labelId","id","hasHeader","LimitReading","ratio","max","style","limitDisplay","showLimitRing","levels","LimitAnnouncer","limit","tone","level","announcement","setAnnouncement","useState","FieldFrame","useId","message","fieldMessage","hint","error","Children","child","limitId","Wrapper","reportedCount","reportCount","reports","setReports","hasExplicitLimit","frame","useMemo","withReport","current","key","next","shownCount","reportedLimit","currentLimit","shownLimit","limitVisibility","describedBy","reading","activeLimit","groupAttributes","groupBinding","className","binding","limitLabelId","description","invalid"],"sources":["../../src/components/Field/header.tsx","../../src/components/Field/limit-reading.tsx","../../src/components/Field/frame.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Badge } from \"../Badge\";\nimport type { FieldProps } from \"./types\";\n\ninterface FieldHeaderProps extends Pick<\n FieldProps,\n \"label\" | \"labelHint\" | \"count\" | \"isRequired\" | \"isGroup\"\n> {\n id: string;\n labelId: string;\n hasHeader: boolean;\n hasLabelHint: boolean;\n labelHintId: string;\n children: ReactNode;\n}\n\n/** Keep the usage reading outside the label's name and the legend directly in its fieldset. */\nexport function FieldHeader({\n label,\n count,\n isRequired,\n isGroup,\n id,\n labelId,\n hasHeader,\n labelHint,\n hasLabelHint,\n labelHintId,\n children,\n}: FieldHeaderProps) {\n const Label = isGroup ? \"legend\" : \"label\";\n const support = hasLabelHint ? (\n <span className=\"ds-field__support\">\n <span\n id={labelHintId}\n className=\"ds-field__label-hint\"\n >\n {labelHint}\n </span>\n {children}\n </span>\n ) : (\n children\n );\n const contents = (\n <>\n {label}\n {count !== undefined && (\n <Badge\n className=\"ds-field__count\"\n shape=\"count\"\n isCountExact\n aria-hidden=\"true\"\n >\n {count}\n </Badge>\n )}\n {isRequired && (\n <span\n className=\"ds-field__required\"\n aria-hidden=\"true\"\n >\n *\n </span>\n )}\n </>\n );\n const labelElement = (\n <Label\n id={labelId}\n className=\"ds-field__label\"\n htmlFor={isGroup ? undefined : id}\n >\n {contents}\n </Label>\n );\n if (!hasHeader) {\n return labelElement;\n }\n if (isGroup) {\n return (\n <legend className=\"ds-field__header\">\n <span\n id={labelId}\n className=\"ds-field__label\"\n >\n {contents}\n </span>\n {support}\n </legend>\n );\n }\n return (\n <div className=\"ds-field__header\">\n {labelElement}\n {support}\n </div>\n );\n}\n","import { useState, type CSSProperties } from \"react\";\nimport { limitDescription, limitTone } from \"./limit\";\nimport type { FieldLimit, FieldLimitOptions } from \"./types\";\n\nexport function LimitReading({\n count,\n max,\n id,\n limitDisplay = \"used\",\n showLimitRing = true,\n}: FieldLimit & FieldLimitOptions & { id: string }) {\n const ratio = Math.min(1, count / max);\n const progress = ratio <= 0.6 ? ratio / 0.6 : (ratio - 0.6) / 0.4;\n const style = {\n \"--limit-mix\": `${progress * 100}%`,\n \"--limit-from\": ratio <= 0.6 ? \"var(--color-success)\" : \"var(--color-warning)\",\n \"--limit-to\": ratio <= 0.6 ? \"var(--color-warning)\" : \"var(--color-danger)\",\n } as CSSProperties;\n return (\n <span\n className=\"ds-field__limit\"\n data-tone={limitTone({ count, max })}\n style={style}\n >\n <span aria-hidden=\"true\">\n {limitDisplay === \"remaining\" ? `${max - count} left` : `${count}/${max}`}\n </span>\n <span\n id={id}\n className=\"ds-field__limit-description\"\n >\n {limitDescription({ count, max }, limitDisplay)}\n </span>\n {showLimitRing && (\n <svg\n className=\"ds-field__limit-ring\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n aria-hidden=\"true\"\n >\n <circle\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n />\n <circle\n className=\"ds-field__limit-progress\"\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n pathLength=\"1\"\n // A continuous stroke avoids a dash seam at the circle's closing point.\n strokeDasharray={ratio >= 1 ? \"none\" : `${ratio} 1`}\n />\n </svg>\n )}\n </span>\n );\n}\n\nconst levels = { warning: 1, danger: 2 } as const;\n\n/**\n * A polite region that exists for as long as the limit does, so it is already\n * registered when usage first crosses into warning or danger. It speaks only on\n * those crossings, not on every keystroke, and falls silent below them so a\n * later crossing is announced again. Loaded values are described, not announced.\n */\nexport function LimitAnnouncer({\n limitDisplay,\n ...limit\n}: FieldLimit & Pick<FieldLimitOptions, \"limitDisplay\">) {\n const tone = limitTone(limit);\n const level = tone ? levels[tone] : 0;\n const [announcement, setAnnouncement] = useState({ level, text: \"\" });\n if (announcement.level !== level) {\n setAnnouncement({\n level,\n text: level > announcement.level ? limitDescription(limit, limitDisplay) : \"\",\n });\n }\n return (\n <span\n className=\"ds-field__limit-announcement\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {announcement.text}\n </span>\n );\n}\n","import { Children, useId, useMemo, useState } from \"react\";\nimport { FieldFrameContext, type FieldFrameContextValue } from \"./context\";\nimport { FieldHeader } from \"./header\";\nimport { LimitAnnouncer, LimitReading } from \"./limit-reading\";\nimport { usableLimit, visibleLimit } from \"./limit\";\nimport type { FieldBinding, FieldLimit, FieldProps } from \"./types\";\nimport \"./style.css\";\n\ninterface FieldFrameProps extends FieldProps {\n className?: string;\n groupBinding?: FieldBinding;\n}\n\ntype LimitReports = ReadonlyMap<string, FieldLimit>;\n\n/**\n * Shared label/legend, count, required marker and messages, including standalone\n * groups. A group's fieldset carries the description; bound controls don't repeat it.\n */\nexport function FieldFrame({\n label,\n labelHint,\n hint,\n error,\n isRequired,\n count,\n limit,\n limitDisplay,\n limitVisibility,\n showLimitRing,\n isGroup = false,\n children,\n className,\n groupBinding,\n}: FieldFrameProps) {\n const id = useId();\n const message = fieldMessage(hint, error, id);\n const labelId = `${id}-label`;\n const labelHintId = `${id}-label-hint`;\n const hasLabelHint = Children.toArray(labelHint).some((child) => child !== \"\");\n const limitId = `${id}-limit`;\n const Wrapper = isGroup ? \"fieldset\" : \"div\";\n const [reportedCount, reportCount] = useState<number>();\n const [reports, setReports] = useState<LimitReports>(() => new Map());\n const hasExplicitLimit = limit !== undefined;\n const frame = useMemo<FieldFrameContextValue>(\n () => ({\n labelId,\n isGroup,\n reportCount,\n reportLimit: hasExplicitLimit\n ? undefined\n : (key, next) => setReports((current) => withReport(current, key, next)),\n }),\n [labelId, isGroup, hasExplicitLimit],\n );\n const shownCount = count ?? reportedCount;\n // The first bound control to report keeps the reading while others come and go.\n const [reportedLimit] = reports.values();\n const currentLimit = limit ?? reportedLimit;\n const shownLimit = visibleLimit(currentLimit, limitVisibility);\n const describedBy =\n [message?.id, hasLabelHint ? labelHintId : undefined, shownLimit ? limitId : undefined]\n .filter(Boolean)\n .join(\" \") || undefined;\n const reading = shownLimit && (\n <LimitReading\n {...shownLimit}\n id={limitId}\n limitDisplay={limitDisplay}\n showLimitRing={showLimitRing}\n />\n );\n const activeLimit = usableLimit(currentLimit) ? currentLimit : undefined;\n const hasHeader = activeLimit !== undefined || hasLabelHint;\n return (\n <Wrapper\n {...(isGroup\n ? groupAttributes(\n groupBinding,\n describedBy,\n Boolean(error),\n hasHeader ? labelId : undefined,\n )\n : undefined)}\n className={[\"ds-field\", className].filter(Boolean).join(\" \")}\n >\n <FieldHeader\n label={label}\n count={shownCount}\n isRequired={isRequired}\n isGroup={isGroup}\n id={id}\n labelId={labelId}\n hasHeader={hasHeader}\n labelHint={labelHint}\n hasLabelHint={hasLabelHint}\n labelHintId={labelHintId}\n >\n {reading}\n </FieldHeader>\n {activeLimit && (\n <LimitAnnouncer\n {...activeLimit}\n limitDisplay={limitDisplay}\n />\n )}\n <FieldFrameContext.Provider value={frame}>\n {children({\n id,\n \"aria-describedby\": describedBy,\n \"aria-labelledby\": labelId,\n \"aria-invalid\": error ? true : undefined,\n required: isRequired,\n })}\n </FieldFrameContext.Provider>\n {message && <span {...message} />}\n </Wrapper>\n );\n}\n\n/** Updates keep a report's position, so one control never displaces another. */\nfunction withReport(reports: LimitReports, key: string, limit: FieldLimit | undefined) {\n const current = reports.get(key);\n if (limit ? current?.count === limit.count && current.max === limit.max : !current) {\n return reports;\n }\n const next = new Map(reports);\n if (limit) {\n next.set(key, limit);\n } else {\n next.delete(key);\n }\n return next;\n}\n\nfunction fieldMessage(hint: FieldProps[\"hint\"], error: FieldProps[\"error\"], id: string) {\n if (error) {\n return { id: `${id}-error`, className: \"ds-field__error\", children: error };\n }\n if (hint) {\n return { id: `${id}-hint`, className: \"ds-field__hint\", children: hint };\n }\n}\n\n/**\n * A limited legend also holds the counter, so `limitLabelId` names the group by\n * its label text alone. A consumer's own name for the group always wins.\n */\nfunction groupAttributes(\n binding: FieldBinding | undefined,\n description: string | undefined,\n invalid: boolean,\n limitLabelId: string | undefined,\n) {\n return {\n ...binding,\n \"aria-labelledby\":\n binding?.[\"aria-labelledby\"] || (binding?.[\"aria-label\"] ? undefined : limitLabelId),\n \"aria-describedby\":\n [binding?.[\"aria-describedby\"], description].filter(Boolean).join(\" \") || undefined,\n \"aria-invalid\": invalid || binding?.[\"aria-invalid\"],\n };\n}\n"],"mappings":";;;;;;;AAiBA,SAAgBO,EAAY,EAC1B,UACA,UACA,eACA,YACA,OACA,YACA,cACA,cACA,iBACA,gBACA,eACmB;CACnB,IAAMC,IAAQC,IAAU,WAAW,SAC7BC,IAAUC,IACd,kBAAC,QAAD;EAAM,WAAU;EAAhB,UAAA,CACE,kBAAC,QAAD;GACE,IAAIC;GACJ,WAAU;GAET,UAAAC;EACG,CAAA,GACLC,CACG;CAEN,CAAA,IAAAA,GAEIC,IACJ,kBAAAf,GAAA,EAAA,UAAA;EACGgB;EACAC,MAAU,KAAA,KACT,kBAACC,GAAD;GACE,WAAU;GACV,OAAM;GACN,cAAA;GACA,eAAY;GAEX,UAAAD;EACI,CAAA;EAERE,KACC,kBAAC,QAAD;GACE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,GAAKzB,CAAK,IAEnB0B,EAAK,OAAOD,CAAG,GAEVC;AACT;AAEA,SAASjB,EAAa,GAA0B,GAA4B,GAAY;CACtF,IAAIE,GACF,OAAO;EAAE,IAAI,GAAGrB,EAAG;EAAS,WAAW;EAAmB,UAAUqB;CAAM;CAE5E,IAAID,GACF,OAAO;EAAE,IAAI,GAAGpB,EAAG;EAAQ,WAAW;EAAkB,UAAUoB;CAAK;AAE3E;AAMA,SAASyB,EACP,GACA,GACA,GACA,GACA;CACA,OAAO;EACL,GAAGG;EACH,mBACEA,IAAU,uBAAuBA,IAAU,gBAAgB,KAAA,IAAYC;EACzE,oBACE,CAACD,IAAU,qBAAqBE,CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;EAC5E,gBAAgBC,KAAWH,IAAU;CACvC;AACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function e(e){return!!(e&&Number.isFinite(e.max)&&e.max>0&&Number.isFinite(e.count)&&e.count>=0)}function t(t,n){return e(t)&&(n!==`nearLimit`||t.count/t.max>=.8)?t:void 0}function n({count:e,max:t}){let n=e/t;return n>=1?`danger`:n>=.85?`warning`:void 0}function r({count:e,max:t},n){return n===`remaining`?`${t-e} remaining`:`${e} of ${t} used`}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
2
|
-
//# sourceMappingURL=limit-BX6-o1a2.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"limit-BX6-o1a2.cjs","names":["usableLimit","limit","visibleLimit","visibility","limitTone","ratio","count","max","limitDescription","display"],"sources":["../../src/components/Field/limit.ts"],"sourcesContent":["import type { FieldLimit, FieldLimitOptions } from \"./types\";\n\n/** Keep invalid limits out of the presentation without changing input enforcement. */\nexport function usableLimit(limit: FieldLimit | undefined): limit is FieldLimit {\n return Boolean(\n limit &&\n Number.isFinite(limit.max) &&\n limit.max > 0 &&\n Number.isFinite(limit.count) &&\n limit.count >= 0,\n );\n}\n\nexport function visibleLimit(\n limit: FieldLimit | undefined,\n visibility: FieldLimitOptions[\"limitVisibility\"],\n) {\n return usableLimit(limit) && (visibility !== \"nearLimit\" || limit.count / limit.max >= 0.8)\n ? limit\n : undefined;\n}\n\n/** Warning from 85% usage, danger at and above the limit. */\nexport function limitTone({ count, max }: FieldLimit) {\n const ratio = count / max;\n return ratio >= 1 ? \"danger\" : ratio >= 0.85 ? \"warning\" : undefined;\n}\n\nexport function limitDescription(\n { count, max }: FieldLimit,\n display: FieldLimitOptions[\"limitDisplay\"],\n) {\n return display === \"remaining\" ? `${max - count} remaining` : `${count} of ${max} used`;\n}\n"],"mappings":"AAGA,SAAgBA,EAAY,EAAoD,CAC9E,MAAO,GACLC,GACA,OAAO,SAASA,EAAM,GAAG,GACzBA,EAAM,IAAM,GACZ,OAAO,SAASA,EAAM,KAAK,GAC3BA,EAAM,OAAS,EAEnB,CAEA,SAAgBC,EACd,EACA,EACA,CACA,OAAOF,EAAYC,CAAK,IAAME,IAAe,aAAeF,EAAM,MAAQA,EAAM,KAAO,IACnFA,EACA,IAAA,EACN,CAGA,SAAgBG,EAAU,CAAE,QAAO,OAAmB,CACpD,IAAMC,EAAQC,EAAQC,EACtB,OAAOF,GAAS,EAAI,SAAWA,GAAS,IAAO,UAAY,IAAA,EAC7D,CAEA,SAAgBG,EACd,CAAE,QAAO,OACT,EACA,CACA,OAAOC,IAAY,YAAc,GAAGF,EAAMD,EAAM,YAAc,GAAGA,EAAM,MAAMC,EAAI,MACnF,C"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region src/components/Field/limit.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
return !!(e && Number.isFinite(e.max) && e.max > 0 && Number.isFinite(e.count) && e.count >= 0);
|
|
4
|
-
}
|
|
5
|
-
function t(t, n) {
|
|
6
|
-
return e(t) && (n !== "nearLimit" || t.count / t.max >= .8) ? t : void 0;
|
|
7
|
-
}
|
|
8
|
-
function n({ count: e, max: t }) {
|
|
9
|
-
let n = e / t;
|
|
10
|
-
return n >= 1 ? "danger" : n >= .85 ? "warning" : void 0;
|
|
11
|
-
}
|
|
12
|
-
function r({ count: e, max: t }, n) {
|
|
13
|
-
return n === "remaining" ? `${t - e} remaining` : `${e} of ${t} used`;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { t as i, n, e as r, r as t };
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=limit-ChteDN4T.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"limit-ChteDN4T.js","names":["usableLimit","limit","visibleLimit","visibility","limitTone","ratio","count","max","limitDescription","display"],"sources":["../../src/components/Field/limit.ts"],"sourcesContent":["import type { FieldLimit, FieldLimitOptions } from \"./types\";\n\n/** Keep invalid limits out of the presentation without changing input enforcement. */\nexport function usableLimit(limit: FieldLimit | undefined): limit is FieldLimit {\n return Boolean(\n limit &&\n Number.isFinite(limit.max) &&\n limit.max > 0 &&\n Number.isFinite(limit.count) &&\n limit.count >= 0,\n );\n}\n\nexport function visibleLimit(\n limit: FieldLimit | undefined,\n visibility: FieldLimitOptions[\"limitVisibility\"],\n) {\n return usableLimit(limit) && (visibility !== \"nearLimit\" || limit.count / limit.max >= 0.8)\n ? limit\n : undefined;\n}\n\n/** Warning from 85% usage, danger at and above the limit. */\nexport function limitTone({ count, max }: FieldLimit) {\n const ratio = count / max;\n return ratio >= 1 ? \"danger\" : ratio >= 0.85 ? \"warning\" : undefined;\n}\n\nexport function limitDescription(\n { count, max }: FieldLimit,\n display: FieldLimitOptions[\"limitDisplay\"],\n) {\n return display === \"remaining\" ? `${max - count} remaining` : `${count} of ${max} used`;\n}\n"],"mappings":";AAGA,SAAgBA,EAAY,GAAoD;CAC9E,OAAO,GACLC,KACA,OAAO,SAASA,EAAM,GAAG,KACzBA,EAAM,MAAM,KACZ,OAAO,SAASA,EAAM,KAAK,KAC3BA,EAAM,SAAS;AAEnB;AAEA,SAAgBC,EACd,GACA,GACA;CACA,OAAOF,EAAYC,CAAK,MAAME,MAAe,eAAeF,EAAM,QAAQA,EAAM,OAAO,MACnFA,IACA,KAAA;AACN;AAGA,SAAgBG,EAAU,EAAE,UAAO,UAAmB;CACpD,IAAMC,IAAQC,IAAQC;CACtB,OAAOF,KAAS,IAAI,WAAWA,KAAS,MAAO,YAAY,KAAA;AAC7D;AAEA,SAAgBG,EACd,EAAE,UAAO,UACT,GACA;CACA,OAAOC,MAAY,cAAc,GAAGF,IAAMD,EAAM,cAAc,GAAGA,EAAM,MAAMC,EAAI;AACnF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./portalScope-BVA1-Ypu.cjs");let t=require("react");function n(e){if(typeof document>`u`)return null;let t=document.createElement(`div`);return t.className=e,t}var r=()=>()=>{};function i(e){let[i]=(0,t.useState)(()=>n(e)),a=(0,t.useSyncExternalStore)(r,()=>!0,()=>!1);return(0,t.useEffect)(()=>()=>i?.remove(),[i]),a?i:null}function a(t,n,r=null){if(!n)return t.remove(),!1;if(t.parentNode===n)return!1;let i=document.activeElement,a=i&&t.contains(i)?i:r,o=a instanceof HTMLElement&&t.contains(a)&&(a===i||e.i(i));return n.append(t),o&&a.focus({preventScroll:!0}),!0}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
|
2
|
-
//# sourceMappingURL=movableHost-CajG9_5Z.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"movableHost-CajG9_5Z.cjs","names":["useState","useSyncExternalStore","cannotHoldFocus","require_portalScope","react","createMovableHost","host","className","subscribe","useMovableHost","hydrated","moveHost","slot","active","focused","lastFocused","refocus"],"sources":["../../src/internal/movableHost.ts"],"sourcesContent":["import { useEffect, useState, useSyncExternalStore } from \"react\";\nimport { cannotHoldFocus } from \"./dialogFocus\";\n\n/**\n * A detached element for portal content that moves between slots, so the tree\n * rendered into it never remounts. Null on the server.\n */\nexport function createMovableHost(className: string) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n return host;\n}\n\nconst subscribe = () => () => {};\n\n/**\n * A movable host for content that is also server rendered. It is null on the\n * server and while hydrating, so the first client render can match inline\n * server markup; client-only renders get the host on their first render.\n */\nexport function useMovableHost(className: string) {\n const [host] = useState(() => createMovableHost(className));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n useEffect(() => () => host?.remove(), [host]);\n return hydrated ? host : null;\n}\n\n/**\n * Moves `host` into `slot`, or detaches it when there is no slot. A host already\n * in place is left alone: re-inserting it would reset scroll positions and drop\n * focus and the text selection. Moving drops focus, so the element inside the\n * host that had it (or `lastFocused`, when an earlier removal already dropped\n * it) gets it back. Returns whether the host moved.\n */\nexport function moveHost(\n host: HTMLElement,\n slot: Element | null,\n lastFocused: Element | null = null,\n) {\n if (!slot) {\n host.remove();\n return false;\n }\n if (host.parentNode === slot) {\n return false;\n }\n const active = document.activeElement;\n const focused = active && host.contains(active) ? active : lastFocused;\n const refocus =\n focused instanceof HTMLElement &&\n host.contains(focused) &&\n (focused === active || cannotHoldFocus(active));\n slot.append(host);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n return true;\n}\n"],"mappings":"A,qEAOA,SAAgBK,EAAkB,EAAmB,CACnD,GAAI,OAAO,SAAa,IACtB,OAAO,KAET,IAAMC,EAAO,SAAS,cAAc,KAAK,EAEzC,MADA,GAAK,UAAYC,EACVD,CACT,CAEA,IAAME,UAAwB,CAAC,EAO/B,SAAgBC,EAAe,EAAmB,CAChD,GAAM,CAACH,IAAA,EAAQN,EAAAA,SAAAA,KAAeK,EAAkBE,CAAS,CAAC,EACpDG,GAAA,EAAWT,EAAAA,qBAAAA,CACfO,MACM,OACA,EACR,EAEA,OADA,EAAAJ,EAAA,UAAA,SAAsBE,GAAM,OAAO,EAAG,CAACA,CAAI,CAAC,EACrCI,EAAWJ,EAAO,IAC3B,CASA,SAAgBK,EACd,EACA,EACA,EAA8B,KAC9B,CACA,GAAI,CAACC,EAEH,OADAN,EAAK,OAAO,EACL,GAET,GAAIA,EAAK,aAAeM,EACtB,MAAO,GAET,IAAMC,EAAS,SAAS,cAClBC,EAAUD,GAAUP,EAAK,SAASO,CAAM,EAAIA,EAASE,EACrDC,EACJF,aAAmB,aACnBR,EAAK,SAASQ,CAAO,IACpBA,IAAYD,GAAUX,EAAAA,EAAgBW,CAAM,GAK/C,OAJAD,EAAK,OAAON,CAAI,EACZU,GACFF,EAAQ,MAAM,CAAE,cAAe,EAAK,CAAC,EAEhC,EACT,C"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { i as e } from "./portalScope-AzzPM54i.js";
|
|
2
|
-
import { useEffect as t, useState as n, useSyncExternalStore as r } from "react";
|
|
3
|
-
//#region src/internal/movableHost.ts
|
|
4
|
-
function i(e) {
|
|
5
|
-
if (typeof document > "u") return null;
|
|
6
|
-
let t = document.createElement("div");
|
|
7
|
-
return t.className = e, t;
|
|
8
|
-
}
|
|
9
|
-
var a = () => () => {};
|
|
10
|
-
function o(e) {
|
|
11
|
-
let [o] = n(() => i(e)), s = r(a, () => !0, () => !1);
|
|
12
|
-
return t(() => () => o?.remove(), [o]), s ? o : null;
|
|
13
|
-
}
|
|
14
|
-
function s(t, n, r = null) {
|
|
15
|
-
if (!n) return t.remove(), !1;
|
|
16
|
-
if (t.parentNode === n) return !1;
|
|
17
|
-
let i = document.activeElement, a = i && t.contains(i) ? i : r, o = a instanceof HTMLElement && t.contains(a) && (a === i || e(i));
|
|
18
|
-
return n.append(t), o && a.focus({ preventScroll: !0 }), !0;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { s as n, o as r, i as t };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=movableHost-NJj_FsAu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"movableHost-NJj_FsAu.js","names":["cannotHoldFocus","createMovableHost","host","className","subscribe","useMovableHost","useState","hydrated","useSyncExternalStore","useEffect","moveHost","slot","active","focused","lastFocused","refocus"],"sources":["../../src/internal/movableHost.ts"],"sourcesContent":["import { useEffect, useState, useSyncExternalStore } from \"react\";\nimport { cannotHoldFocus } from \"./dialogFocus\";\n\n/**\n * A detached element for portal content that moves between slots, so the tree\n * rendered into it never remounts. Null on the server.\n */\nexport function createMovableHost(className: string) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n return host;\n}\n\nconst subscribe = () => () => {};\n\n/**\n * A movable host for content that is also server rendered. It is null on the\n * server and while hydrating, so the first client render can match inline\n * server markup; client-only renders get the host on their first render.\n */\nexport function useMovableHost(className: string) {\n const [host] = useState(() => createMovableHost(className));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n useEffect(() => () => host?.remove(), [host]);\n return hydrated ? host : null;\n}\n\n/**\n * Moves `host` into `slot`, or detaches it when there is no slot. A host already\n * in place is left alone: re-inserting it would reset scroll positions and drop\n * focus and the text selection. Moving drops focus, so the element inside the\n * host that had it (or `lastFocused`, when an earlier removal already dropped\n * it) gets it back. Returns whether the host moved.\n */\nexport function moveHost(\n host: HTMLElement,\n slot: Element | null,\n lastFocused: Element | null = null,\n) {\n if (!slot) {\n host.remove();\n return false;\n }\n if (host.parentNode === slot) {\n return false;\n }\n const active = document.activeElement;\n const focused = active && host.contains(active) ? active : lastFocused;\n const refocus =\n focused instanceof HTMLElement &&\n host.contains(focused) &&\n (focused === active || cannotHoldFocus(active));\n slot.append(host);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n return true;\n}\n"],"mappings":";;;AAOA,SAAgBC,EAAkB,GAAmB;CACnD,IAAI,OAAO,WAAa,KACtB,OAAO;CAET,IAAMC,IAAO,SAAS,cAAc,KAAK;CAEzC,OADA,EAAK,YAAYC,GACVD;AACT;AAEA,IAAME,gBAAwB,CAAC;AAO/B,SAAgBC,EAAe,GAAmB;CAChD,IAAM,CAACH,KAAQI,QAAeL,EAAkBE,CAAS,CAAC,GACpDI,IAAWC,EACfJ,SACM,UACA,EACR;CAEA,OADAK,cAAsBP,GAAM,OAAO,GAAG,CAACA,CAAI,CAAC,GACrCK,IAAWL,IAAO;AAC3B;AASA,SAAgBQ,EACd,GACA,GACA,IAA8B,MAC9B;CACA,IAAI,CAACC,GAEH,OADAT,EAAK,OAAO,GACL;CAET,IAAIA,EAAK,eAAeS,GACtB,OAAO;CAET,IAAMC,IAAS,SAAS,eAClBC,IAAUD,KAAUV,EAAK,SAASU,CAAM,IAAIA,IAASE,GACrDC,IACJF,aAAmB,eACnBX,EAAK,SAASW,CAAO,MACpBA,MAAYD,KAAUZ,EAAgBY,CAAM;CAK/C,OAJAD,EAAK,OAAOT,CAAI,GACZa,KACFF,EAAQ,MAAM,EAAE,eAAe,GAAK,CAAC,GAEhC;AACT"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { createContext as e, useContext as t, useEffect as n, useLayoutEffect as r, useRef as i } from "react";
|
|
2
|
-
//#region src/internal/dialogFocus.ts
|
|
3
|
-
var a = ":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])";
|
|
4
|
-
function o(e) {
|
|
5
|
-
let t = e.closest("[contenteditable]");
|
|
6
|
-
return !(e.matches("a[href]") && t && t !== e && t.getAttribute("contenteditable") !== "false" && !e.hasAttribute("tabindex")) && (e.checkVisibility?.() ?? !e.closest("[hidden]")) && !e.closest("[inert]");
|
|
7
|
-
}
|
|
8
|
-
function s(e) {
|
|
9
|
-
return !e || e === e.ownerDocument.body || !e.isConnected || e.closest("[aria-hidden='true'], [inert]") !== null;
|
|
10
|
-
}
|
|
11
|
-
function c(e, t) {
|
|
12
|
-
let n = e;
|
|
13
|
-
for (; n;) {
|
|
14
|
-
if (n instanceof HTMLElement && !s(n) && (n.focus(t), n.getRootNode().activeElement === n)) return !0;
|
|
15
|
-
n = n.parentElement?.closest("[tabindex]") ?? null;
|
|
16
|
-
}
|
|
17
|
-
return !1;
|
|
18
|
-
}
|
|
19
|
-
function l(e) {
|
|
20
|
-
return e instanceof HTMLInputElement && e.type === "radio";
|
|
21
|
-
}
|
|
22
|
-
function u(e, t) {
|
|
23
|
-
return e === t || l(e) && l(t) && e.name !== "" && e.name === t.name && e.form === t.form;
|
|
24
|
-
}
|
|
25
|
-
function d(e) {
|
|
26
|
-
let t = Array.from(e.querySelectorAll(a)).filter(o);
|
|
27
|
-
return t.filter((e) => !l(e) || e.checked || !t.some((t) => l(t) && t.checked && u(t, e)));
|
|
28
|
-
}
|
|
29
|
-
var f = /* @__PURE__ */ new WeakMap();
|
|
30
|
-
function p(e, t) {
|
|
31
|
-
return f.set(e, t), () => {
|
|
32
|
-
f.delete(e);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function m(e) {
|
|
36
|
-
let t = e instanceof Element ? e : e.parentElement;
|
|
37
|
-
for (; t && !f.has(t);) t = t.parentElement;
|
|
38
|
-
return t;
|
|
39
|
-
}
|
|
40
|
-
function h(e, t) {
|
|
41
|
-
let n = /* @__PURE__ */ new Set(), r = m(t);
|
|
42
|
-
for (; r && !n.has(r);) {
|
|
43
|
-
n.add(r);
|
|
44
|
-
let t = f.get(r);
|
|
45
|
-
if (e.contains(t)) return !0;
|
|
46
|
-
r = m(t);
|
|
47
|
-
}
|
|
48
|
-
return !1;
|
|
49
|
-
}
|
|
50
|
-
function g(e, t) {
|
|
51
|
-
return !!(t.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
52
|
-
}
|
|
53
|
-
function _(e, t) {
|
|
54
|
-
if (e.key !== "Tab" || e.defaultPrevented || !t) return;
|
|
55
|
-
let n = d(t), r = n[0], i = n.at(-1);
|
|
56
|
-
if (!r || !i) return;
|
|
57
|
-
let a = t.getRootNode().activeElement ?? document.activeElement, o = a !== null && t.contains(a);
|
|
58
|
-
!o && a && h(t, a) || (!o || (e.shiftKey ? u(a, r) || g(a, r) : u(a, i) || g(i, a))) && (e.preventDefault(), (e.shiftKey ? i : r).focus());
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/internal/portalScope.ts
|
|
62
|
-
var v = typeof document > "u" ? n : r, y = e(null), b = [
|
|
63
|
-
"data-theme",
|
|
64
|
-
"lang",
|
|
65
|
-
"dir"
|
|
66
|
-
];
|
|
67
|
-
function x(e) {
|
|
68
|
-
let t = e.closest("[dir]") ? getComputedStyle(e).direction || e.closest("[dir]").getAttribute("dir") : null;
|
|
69
|
-
return {
|
|
70
|
-
"data-theme": e.closest("[data-theme]")?.getAttribute("data-theme") ?? null,
|
|
71
|
-
lang: e.closest("[lang]")?.getAttribute("lang") ?? null,
|
|
72
|
-
dir: t
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function S(e, t, n, { keepDir: r = !1 } = {}) {
|
|
76
|
-
let a = i(n);
|
|
77
|
-
v(() => {
|
|
78
|
-
a.current = n;
|
|
79
|
-
}), v(() => {
|
|
80
|
-
let n = e.current, i = a.current?.();
|
|
81
|
-
if (!t || !n || !i) return;
|
|
82
|
-
let o = () => {
|
|
83
|
-
for (let [e, t] of Object.entries(x(i))) e === "dir" && r || (t === null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t));
|
|
84
|
-
};
|
|
85
|
-
o();
|
|
86
|
-
let s = new MutationObserver(o);
|
|
87
|
-
for (let e = i; e; e = e.parentElement) s.observe(e, {
|
|
88
|
-
attributes: !0,
|
|
89
|
-
attributeFilter: b
|
|
90
|
-
});
|
|
91
|
-
return () => s.disconnect();
|
|
92
|
-
}, [
|
|
93
|
-
e,
|
|
94
|
-
t,
|
|
95
|
-
r
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
98
|
-
function C(e, n, r) {
|
|
99
|
-
let i = t(y);
|
|
100
|
-
S(e, n, i && (() => i.current), r);
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
export { c as a, _ as c, s as i, C as n, p as o, S as r, d as s, y as t };
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=portalScope-AzzPM54i.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portalScope-AzzPM54i.js","names":["focusableSelector","canTakeFocus","editingHost","element","cannotHoldFocus","focusNearest","candidate","options","isRadio","sameStop","a","b","tabbableControls","controls","container","control","other","popupAnchors","registerPopup","popup","anchor","popupAround","node","inOwnedPopup","visited","panel","precedes","trapTabFocus","event","first","last","active","inside","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","PortalScopeContext","createContext","scopeAttributes","scopeOf","direction","usePortalScope","latest","useRef","getAnchor","root","rootRef","isOpen","sync","name","value","keepDir","observer","useInheritedPortalScope","useContext"],"sources":["../../src/internal/dialogFocus.ts","../../src/internal/portalScope.ts"],"sourcesContent":["const focusableSelector =\n \":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])\";\n\n// Unrendered controls (display: none, [hidden], closed <details>) and inert\n// subtrees cannot take focus. Environments without checkVisibility fall back\n// to the hidden attribute.\nfunction canTakeFocus(element: HTMLElement) {\n const editingHost = element.closest(\"[contenteditable]\");\n // A link being edited is document content, not a native Tab stop. Explicit\n // tabindex and links inside noneditable widgets still participate normally.\n const writingLink =\n element.matches(\"a[href]\") &&\n editingHost &&\n editingHost !== element &&\n editingHost.getAttribute(\"contenteditable\") !== \"false\" &&\n !element.hasAttribute(\"tabindex\");\n return (\n !writingLink &&\n (element.checkVisibility?.() ?? !element.closest(\"[hidden]\")) &&\n !element.closest(\"[inert]\")\n );\n}\n\n/** Removed, hidden and inert elements can't keep focus, and neither can the page. */\nexport function cannotHoldFocus(element: Element | null) {\n return (\n !element ||\n element === element.ownerDocument.body ||\n !element.isConnected ||\n element.closest(\"[aria-hidden='true'], [inert]\") !== null\n );\n}\n\n/**\n * Focuses `element`, or, when it can no longer take focus (disabled, or no\n * longer editable), its nearest ancestor with a tabindex, such as an enclosing\n * dialog panel. Returns whether anything took focus.\n */\nexport function focusNearest(element: Element | null, options?: FocusOptions) {\n let candidate = element;\n while (candidate) {\n if (candidate instanceof HTMLElement && !cannotHoldFocus(candidate)) {\n candidate.focus(options);\n if ((candidate.getRootNode() as Document | ShadowRoot).activeElement === candidate) {\n return true;\n }\n }\n candidate = candidate.parentElement?.closest(\"[tabindex]\") ?? null;\n }\n return false;\n}\n\nfunction isRadio(element: Element | null): element is HTMLInputElement {\n return element instanceof HTMLInputElement && element.type === \"radio\";\n}\n\n/** Radios sharing a name and form are one Tab stop. */\nfunction sameStop(a: Element, b: Element) {\n return (\n a === b || (isRadio(a) && isRadio(b) && a.name !== \"\" && a.name === b.name && a.form === b.form)\n );\n}\n\n/**\n * The controls Tab visits inside `container`, in document order. A radio group\n * contributes only its checked radio, or every radio while none is checked.\n */\nexport function tabbableControls(container: HTMLElement) {\n const controls = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector)).filter(\n canTakeFocus,\n );\n return controls.filter(\n (control) =>\n !isRadio(control) ||\n control.checked ||\n !controls.some((other) => isRadio(other) && other.checked && sameStop(other, control)),\n );\n}\n\nconst popupAnchors = new WeakMap<Element, Element>();\n\n/**\n * Popups portal outside the dialog that opened them. Registering one with its\n * anchor lets that dialog's Tab trap treat the popup as its own.\n */\nexport function registerPopup(popup: Element, anchor: Element) {\n popupAnchors.set(popup, anchor);\n return () => {\n popupAnchors.delete(popup);\n };\n}\n\nfunction popupAround(node: Node) {\n let element = node instanceof Element ? node : node.parentElement;\n while (element && !popupAnchors.has(element)) {\n element = element.parentElement;\n }\n return element;\n}\n\n/** Inside a popup anchored in the panel, directly or through other popups. */\nfunction inOwnedPopup(panel: HTMLElement, node: Node) {\n const visited = new Set<Element>();\n let popup = popupAround(node);\n while (popup && !visited.has(popup)) {\n visited.add(popup);\n const anchor = popupAnchors.get(popup)!;\n if (panel.contains(anchor)) {\n return true;\n }\n popup = popupAround(anchor);\n }\n return false;\n}\n\n/** `a` comes before `b` in document order, including as its ancestor. */\nfunction precedes(a: Node, b: Node) {\n return Boolean(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\n/**\n * Keeps Tab inside an aria-modal panel. Call only for the topmost dialog.\n * Focus that left the panel returns to its first control (last with Shift);\n * Tab inside a popup the panel owns is left to the popup and the browser.\n */\nexport function trapTabFocus(event: KeyboardEvent, panel: HTMLElement | null) {\n if (event.key !== \"Tab\" || event.defaultPrevented || !panel) {\n return;\n }\n const controls = tabbableControls(panel);\n const first = controls[0];\n const last = controls.at(-1);\n if (!first || !last) {\n return;\n }\n // document.activeElement stops at the host of a shadow root holding the panel.\n const active =\n (panel.getRootNode() as Document | ShadowRoot).activeElement ?? document.activeElement;\n const inside = active !== null && panel.contains(active);\n if (!inside && active && inOwnedPopup(panel, active)) {\n return;\n }\n // Focus on the panel itself, or on another untabbable element beyond the\n // first or last control, would otherwise leave the panel.\n const wraps =\n !inside ||\n (event.shiftKey\n ? sameStop(active, first) || precedes(active, first)\n : sameStop(active, last) || precedes(last, active));\n if (wraps) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n}\n","import {\n createContext,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n type RefObject,\n} from \"react\";\n\nconst useIsomorphicLayoutEffect = typeof document === \"undefined\" ? useEffect : useLayoutEffect;\n\n/**\n * The inline element whose theme, direction and language body-mounted overlays\n * opened from inside it carry: RichTextEditor's frame, or a Popover's anchor.\n * Nested overlays inherit the same inline anchor rather than their parent's\n * panel, so they never depend on the order in which overlays mount.\n */\nexport const PortalScopeContext = createContext<RefObject<Element | null> | null>(null);\n\nconst scopeAttributes = [\"data-theme\", \"lang\", \"dir\"];\n\nfunction scopeOf(anchor: Element) {\n const direction = anchor.closest(\"[dir]\")\n ? getComputedStyle(anchor).direction || anchor.closest(\"[dir]\")!.getAttribute(\"dir\")\n : null;\n return {\n \"data-theme\": anchor.closest(\"[data-theme]\")?.getAttribute(\"data-theme\") ?? null,\n lang: anchor.closest(\"[lang]\")?.getAttribute(\"lang\") ?? null,\n dir: direction,\n };\n}\n\n/**\n * Copies the anchor's `data-theme`, `lang` and `dir` onto an overlay root while\n * it is open, and follows later changes to those attributes on the anchor's\n * ancestors. Attributes rather than resolved values, so the theme's whole\n * stylesheet keeps applying, including `color-scheme` and media queries.\n * Without an anchor the overlay inherits from the document root, as before.\n */\nexport function usePortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n getAnchor: (() => Element | null | undefined) | null,\n { keepDir = false }: { keepDir?: boolean } = {},\n) {\n const latest = useRef(getAnchor);\n useIsomorphicLayoutEffect(() => {\n latest.current = getAnchor;\n });\n\n useIsomorphicLayoutEffect(() => {\n const root = rootRef.current;\n const anchor = latest.current?.();\n if (!isOpen || !root || !anchor) {\n return;\n }\n const sync = () => {\n for (const [name, value] of Object.entries(scopeOf(anchor))) {\n if (name === \"dir\" && keepDir) {\n continue;\n }\n if (value === null) {\n root.removeAttribute(name);\n } else if (root.getAttribute(name) !== value) {\n root.setAttribute(name, value);\n }\n }\n };\n sync();\n // Only scoping attributes: class and style churn on ancestors never re-applies.\n const observer = new MutationObserver(sync);\n for (let node: Element | null = anchor; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: scopeAttributes });\n }\n return () => observer.disconnect();\n }, [rootRef, isOpen, keepDir]);\n}\n\n/** Applies the scope of the inline anchor an enclosing editor or popover provides, if any. */\nexport function useInheritedPortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n options?: { keepDir?: boolean },\n) {\n const anchor = useContext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AM,iBAAiBgB;EAAgB,CAAC;EAE/E,aAAac,EAAS,WAAW;CACnC,GAAG;EAACN;EAASC;EAAQI;CAAO,CAAC;AAC/B;AAGA,SAAgBE,EACd,GACA,GACA,GACA;CACA,IAAMjC,IAASkC,EAAWlB,CAAkB;CAC5C,EAAeU,GAASC,GAAQ3B,YAAiBA,EAAO,UAAUb,CAAO;AAC3E"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let e=require("react");var t=`:is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])`;function n(e){let t=e.closest(`[contenteditable]`);return!(e.matches(`a[href]`)&&t&&t!==e&&t.getAttribute(`contenteditable`)!==`false`&&!e.hasAttribute(`tabindex`))&&(e.checkVisibility?.()??!e.closest(`[hidden]`))&&!e.closest(`[inert]`)}function r(e){return!e||e===e.ownerDocument.body||!e.isConnected||e.closest(`[aria-hidden='true'], [inert]`)!==null}function i(e,t){let n=e;for(;n;){if(n instanceof HTMLElement&&!r(n)&&(n.focus(t),n.getRootNode().activeElement===n))return!0;n=n.parentElement?.closest(`[tabindex]`)??null}return!1}function a(e){return e instanceof HTMLInputElement&&e.type===`radio`}function o(e,t){return e===t||a(e)&&a(t)&&e.name!==``&&e.name===t.name&&e.form===t.form}function s(e){let r=Array.from(e.querySelectorAll(t)).filter(n);return r.filter(e=>!a(e)||e.checked||!r.some(t=>a(t)&&t.checked&&o(t,e)))}var c=new WeakMap;function l(e,t){return c.set(e,t),()=>{c.delete(e)}}function u(e){let t=e instanceof Element?e:e.parentElement;for(;t&&!c.has(t);)t=t.parentElement;return t}function d(e,t){let n=new Set,r=u(t);for(;r&&!n.has(r);){n.add(r);let t=c.get(r);if(e.contains(t))return!0;r=u(t)}return!1}function f(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function p(e,t){if(e.key!==`Tab`||e.defaultPrevented||!t)return;let n=s(t),r=n[0],i=n.at(-1);if(!r||!i)return;let a=t.getRootNode().activeElement??document.activeElement,c=a!==null&&t.contains(a);!c&&a&&d(t,a)||(!c||(e.shiftKey?o(a,r)||f(a,r):o(a,i)||f(i,a)))&&(e.preventDefault(),(e.shiftKey?i:r).focus())}var m=typeof document>`u`?e.useEffect:e.useLayoutEffect,h=(0,e.createContext)(null),g=[`data-theme`,`lang`,`dir`];function _(e){let t=e.closest(`[dir]`)?getComputedStyle(e).direction||e.closest(`[dir]`).getAttribute(`dir`):null;return{"data-theme":e.closest(`[data-theme]`)?.getAttribute(`data-theme`)??null,lang:e.closest(`[lang]`)?.getAttribute(`lang`)??null,dir:t}}function v(t,n,r,{keepDir:i=!1}={}){let a=(0,e.useRef)(r);m(()=>{a.current=r}),m(()=>{let e=t.current,r=a.current?.();if(!n||!e||!r)return;let o=()=>{for(let[t,n]of Object.entries(_(r)))t===`dir`&&i||(n===null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n))};o();let s=new MutationObserver(o);for(let e=r;e;e=e.parentElement)s.observe(e,{attributes:!0,attributeFilter:g});return()=>s.disconnect()},[t,n,i])}function y(t,n,r){let i=(0,e.useContext)(h);v(t,n,i&&(()=>i.current),r)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|
|
2
|
-
//# sourceMappingURL=portalScope-BVA1-Ypu.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portalScope-BVA1-Ypu.cjs","names":["useEffect","useLayoutEffect","createContext","useRef","useContext","react","focusableSelector","canTakeFocus","editingHost","element","cannotHoldFocus","focusNearest","candidate","options","isRadio","sameStop","a","b","tabbableControls","controls","container","control","other","popupAnchors","registerPopup","popup","anchor","popupAround","node","inOwnedPopup","visited","panel","precedes","trapTabFocus","event","first","last","active","inside","useIsomorphicLayoutEffect","PortalScopeContext","scopeAttributes","scopeOf","direction","usePortalScope","latest","getAnchor","root","rootRef","isOpen","sync","name","value","keepDir","observer","useInheritedPortalScope"],"sources":["../../src/internal/dialogFocus.ts","../../src/internal/portalScope.ts"],"sourcesContent":["const focusableSelector =\n \":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])\";\n\n// Unrendered controls (display: none, [hidden], closed <details>) and inert\n// subtrees cannot take focus. Environments without checkVisibility fall back\n// to the hidden attribute.\nfunction canTakeFocus(element: HTMLElement) {\n const editingHost = element.closest(\"[contenteditable]\");\n // A link being edited is document content, not a native Tab stop. Explicit\n // tabindex and links inside noneditable widgets still participate normally.\n const writingLink =\n element.matches(\"a[href]\") &&\n editingHost &&\n editingHost !== element &&\n editingHost.getAttribute(\"contenteditable\") !== \"false\" &&\n !element.hasAttribute(\"tabindex\");\n return (\n !writingLink &&\n (element.checkVisibility?.() ?? !element.closest(\"[hidden]\")) &&\n !element.closest(\"[inert]\")\n );\n}\n\n/** Removed, hidden and inert elements can't keep focus, and neither can the page. */\nexport function cannotHoldFocus(element: Element | null) {\n return (\n !element ||\n element === element.ownerDocument.body ||\n !element.isConnected ||\n element.closest(\"[aria-hidden='true'], [inert]\") !== null\n );\n}\n\n/**\n * Focuses `element`, or, when it can no longer take focus (disabled, or no\n * longer editable), its nearest ancestor with a tabindex, such as an enclosing\n * dialog panel. Returns whether anything took focus.\n */\nexport function focusNearest(element: Element | null, options?: FocusOptions) {\n let candidate = element;\n while (candidate) {\n if (candidate instanceof HTMLElement && !cannotHoldFocus(candidate)) {\n candidate.focus(options);\n if ((candidate.getRootNode() as Document | ShadowRoot).activeElement === candidate) {\n return true;\n }\n }\n candidate = candidate.parentElement?.closest(\"[tabindex]\") ?? null;\n }\n return false;\n}\n\nfunction isRadio(element: Element | null): element is HTMLInputElement {\n return element instanceof HTMLInputElement && element.type === \"radio\";\n}\n\n/** Radios sharing a name and form are one Tab stop. */\nfunction sameStop(a: Element, b: Element) {\n return (\n a === b || (isRadio(a) && isRadio(b) && a.name !== \"\" && a.name === b.name && a.form === b.form)\n );\n}\n\n/**\n * The controls Tab visits inside `container`, in document order. A radio group\n * contributes only its checked radio, or every radio while none is checked.\n */\nexport function tabbableControls(container: HTMLElement) {\n const controls = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector)).filter(\n canTakeFocus,\n );\n return controls.filter(\n (control) =>\n !isRadio(control) ||\n control.checked ||\n !controls.some((other) => isRadio(other) && other.checked && sameStop(other, control)),\n );\n}\n\nconst popupAnchors = new WeakMap<Element, Element>();\n\n/**\n * Popups portal outside the dialog that opened them. Registering one with its\n * anchor lets that dialog's Tab trap treat the popup as its own.\n */\nexport function registerPopup(popup: Element, anchor: Element) {\n popupAnchors.set(popup, anchor);\n return () => {\n popupAnchors.delete(popup);\n };\n}\n\nfunction popupAround(node: Node) {\n let element = node instanceof Element ? node : node.parentElement;\n while (element && !popupAnchors.has(element)) {\n element = element.parentElement;\n }\n return element;\n}\n\n/** Inside a popup anchored in the panel, directly or through other popups. */\nfunction inOwnedPopup(panel: HTMLElement, node: Node) {\n const visited = new Set<Element>();\n let popup = popupAround(node);\n while (popup && !visited.has(popup)) {\n visited.add(popup);\n const anchor = popupAnchors.get(popup)!;\n if (panel.contains(anchor)) {\n return true;\n }\n popup = popupAround(anchor);\n }\n return false;\n}\n\n/** `a` comes before `b` in document order, including as its ancestor. */\nfunction precedes(a: Node, b: Node) {\n return Boolean(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\n/**\n * Keeps Tab inside an aria-modal panel. Call only for the topmost dialog.\n * Focus that left the panel returns to its first control (last with Shift);\n * Tab inside a popup the panel owns is left to the popup and the browser.\n */\nexport function trapTabFocus(event: KeyboardEvent, panel: HTMLElement | null) {\n if (event.key !== \"Tab\" || event.defaultPrevented || !panel) {\n return;\n }\n const controls = tabbableControls(panel);\n const first = controls[0];\n const last = controls.at(-1);\n if (!first || !last) {\n return;\n }\n // document.activeElement stops at the host of a shadow root holding the panel.\n const active =\n (panel.getRootNode() as Document | ShadowRoot).activeElement ?? document.activeElement;\n const inside = active !== null && panel.contains(active);\n if (!inside && active && inOwnedPopup(panel, active)) {\n return;\n }\n // Focus on the panel itself, or on another untabbable element beyond the\n // first or last control, would otherwise leave the panel.\n const wraps =\n !inside ||\n (event.shiftKey\n ? sameStop(active, first) || precedes(active, first)\n : sameStop(active, last) || precedes(last, active));\n if (wraps) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n}\n","import {\n createContext,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n type RefObject,\n} from \"react\";\n\nconst useIsomorphicLayoutEffect = typeof document === \"undefined\" ? useEffect : useLayoutEffect;\n\n/**\n * The inline element whose theme, direction and language body-mounted overlays\n * opened from inside it carry: RichTextEditor's frame, or a Popover's anchor.\n * Nested overlays inherit the same inline anchor rather than their parent's\n * panel, so they never depend on the order in which overlays mount.\n */\nexport const PortalScopeContext = createContext<RefObject<Element | null> | null>(null);\n\nconst scopeAttributes = [\"data-theme\", \"lang\", \"dir\"];\n\nfunction scopeOf(anchor: Element) {\n const direction = anchor.closest(\"[dir]\")\n ? getComputedStyle(anchor).direction || anchor.closest(\"[dir]\")!.getAttribute(\"dir\")\n : null;\n return {\n \"data-theme\": anchor.closest(\"[data-theme]\")?.getAttribute(\"data-theme\") ?? null,\n lang: anchor.closest(\"[lang]\")?.getAttribute(\"lang\") ?? null,\n dir: direction,\n };\n}\n\n/**\n * Copies the anchor's `data-theme`, `lang` and `dir` onto an overlay root while\n * it is open, and follows later changes to those attributes on the anchor's\n * ancestors. Attributes rather than resolved values, so the theme's whole\n * stylesheet keeps applying, including `color-scheme` and media queries.\n * Without an anchor the overlay inherits from the document root, as before.\n */\nexport function usePortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n getAnchor: (() => Element | null | undefined) | null,\n { keepDir = false }: { keepDir?: boolean } = {},\n) {\n const latest = useRef(getAnchor);\n useIsomorphicLayoutEffect(() => {\n latest.current = getAnchor;\n });\n\n useIsomorphicLayoutEffect(() => {\n const root = rootRef.current;\n const anchor = latest.current?.();\n if (!isOpen || !root || !anchor) {\n return;\n }\n const sync = () => {\n for (const [name, value] of Object.entries(scopeOf(anchor))) {\n if (name === \"dir\" && keepDir) {\n continue;\n }\n if (value === null) {\n root.removeAttribute(name);\n } else if (root.getAttribute(name) !== value) {\n root.setAttribute(name, value);\n }\n }\n };\n sync();\n // Only scoping attributes: class and style churn on ancestors never re-applies.\n const observer = new MutationObserver(sync);\n for (let node: Element | null = anchor; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: scopeAttributes });\n }\n return () => observer.disconnect();\n }, [rootRef, isOpen, keepDir]);\n}\n\n/** Applies the scope of the inline anchor an enclosing editor or popover provides, if any. */\nexport function useInheritedPortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n options?: { keepDir?: boolean },\n) {\n const anchor = useContext(PortalScopeContext);\n usePortalScope(rootRef, isOpen, anchor && (() => anchor.current), options);\n}\n"],"mappings":"A,uBAAA,IAAMM,EACJ,gMAKF,SAASC,EAAa,EAAsB,CAC1C,IAAMC,EAAcC,EAAQ,QAAQ,mBAAmB,EASvD,MACE,EANAA,EAAQ,QAAQ,SAAS,GACzBD,GACAA,IAAgBC,GAChBD,EAAY,aAAa,iBAAiB,IAAM,SAChD,CAACC,EAAQ,aAAa,UAAU,KAG/BA,EAAQ,kBAAkB,GAAK,CAACA,EAAQ,QAAQ,UAAU,IAC3D,CAACA,EAAQ,QAAQ,SAAS,CAE9B,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","usableLimit","useLimitReport","frame","useContext","key","useId","reportLimit","binding","report","useMemo","limit","useEffect","useReportedLimit","count","max","useTextLimit","controlledLength","value","input","inputRef","maxLength","observeText","defaultValue","timer","onReset","event","read","owner","restoreValue","interceptValueWrites","own","accessor","get","set","isActive","wrapper","next","onWrite"],"sources":["../../src/components/Field/useLimit.ts"],"sourcesContent":["import { useContext, useEffect, useId, useMemo, type RefObject } from \"react\";\nimport { FieldFrameContext } from \"./context\";\nimport { usableLimit } from \"./limit\";\nimport type { FieldBinding, FieldLimit } from \"./types\";\n\ntype ReportLimit = (limit: FieldLimit | undefined) => void;\ntype TextControl = HTMLInputElement | HTMLTextAreaElement;\n\n/**\n * A control reports only to the Field it is explicitly bound to, and only while\n * that Field has no explicit limit. Each control owns one keyed report, removed\n * on unmount or rebinding without disturbing another control's report.\n */\nfunction useLimitReport(binding: FieldBinding): ReportLimit | undefined {\n const frame = useContext(FieldFrameContext);\n const key = useId();\n const reportLimit =\n frame && binding[\"aria-labelledby\"] === frame.labelId ? frame.reportLimit : undefined;\n const report = useMemo<ReportLimit | undefined>(\n () => reportLimit && ((limit) => reportLimit(key, usableLimit(limit) ? limit : undefined)),\n [reportLimit, key],\n );\n useEffect(() => () => report?.(undefined), [report]);\n return report;\n}\n\n/** Report a limit derived during render, such as committed tags or selected entries. */\nexport function useReportedLimit(binding: FieldBinding, limit: FieldLimit | undefined) {\n const report = useLimitReport(binding);\n const count = limit?.count;\n const max = limit?.max;\n useEffect(() => {\n report?.(count === undefined || max === undefined ? undefined : { count, max });\n }, [report, count, max]);\n}\n\ninterface TextLimitProps extends FieldBinding {\n maxLength?: number;\n value?: string | number | readonly string[] | null;\n defaultValue?: string | number | readonly string[] | null;\n}\n\n/**\n * Count a native text control for its bound Field. A controlled value is counted\n * from props; null is uncontrolled, as in React. An uncontrolled control is\n * observed only while a Field can show its count.\n */\nexport function useTextLimit(\n inputRef: RefObject<TextControl | null>,\n { value, defaultValue, maxLength, ...binding }: TextLimitProps,\n) {\n const report = useLimitReport(binding);\n const controlledLength = value == null ? undefined : String(value).length;\n // A new default changes an unedited control's value without any event.\n const defaultText = defaultValue == null ? \"\" : String(defaultValue);\n useEffect(() => {\n const input = inputRef.current;\n if (!report || !input) {\n return;\n }\n if (maxLength === undefined) {\n report(undefined);\n } else if (controlledLength !== undefined) {\n report({ count: controlledLength, max: maxLength });\n } else {\n return observeText(input, () => report({ count: input.value.length, max: maxLength }));\n }\n }, [inputRef, report, maxLength, controlledLength, defaultText]);\n}\n\n/**\n * Follow typing, autofill, programmatic writes and native resets without\n * replacing React's handlers or its value tracker.\n */\nfunction observeText(input: TextControl, read: () => void) {\n let timer: ReturnType<typeof setTimeout> | undefined;\n // The reset event precedes the browser restoring the form's controls, and a\n // later listener may still cancel it, so read once the reset task completes.\n // The form owner is checked at event time so `form` attribute changes apply.\n const onReset = (event: Event) => {\n if (event.target === input.form) {\n clearTimeout(timer);\n timer = setTimeout(read);\n }\n };\n const owner = input.ownerDocument;\n const restoreValue = interceptValueWrites(input, read);\n input.addEventListener(\"input\", read);\n input.addEventListener(\"change\", read);\n owner.addEventListener(\"reset\", onReset, true);\n read();\n return () => {\n clearTimeout(timer);\n restoreValue();\n input.removeEventListener(\"input\", read);\n input.removeEventListener(\"change\", read);\n owner.removeEventListener(\"reset\", onReset, true);\n };\n}\n\n/**\n * Programmatic `value` writes (form libraries' setValue/reset) fire no events.\n * Wrap the instance accessor, chaining to whatever defines it now (React's\n * tracker), and restore that accessor when observation ends.\n */\nfunction interceptValueWrites(input: TextControl, onWrite: () => void) {\n const own = Object.getOwnPropertyDescriptor(input, \"value\");\n const accessor = own ?? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), \"value\");\n const get = accessor?.get;\n const set = accessor?.set;\n if (!get || !set || own?.configurable === false) {\n return () => {};\n }\n let isActive = true;\n const wrapper: PropertyDescriptor = {\n configurable: true,\n enumerable: accessor.enumerable,\n get(this: TextControl) {\n return get.call(this);\n },\n set(this: TextControl, next: string) {\n set.call(this, next);\n if (isActive) {\n onWrite();\n }\n },\n };\n Object.defineProperty(input, \"value\", wrapper);\n return () => {\n isActive = false;\n // Leave a later wrapper in place; it still chains through this inert one.\n if (Object.getOwnPropertyDescriptor(input, \"value\")?.set !== wrapper.set) {\n return;\n }\n if (own) {\n Object.defineProperty(input, \"value\", own);\n } else {\n Reflect.deleteProperty(input, \"value\");\n }\n };\n}\n"],"mappings":";;;;AAaA,SAASE,EAAe,GAAgD;CACtE,IAAMC,IAAQC,EAAWJ,CAAiB,GACpCK,IAAMC,EAAM,GACZC,IACJJ,KAASK,EAAQ,uBAAuBL,EAAM,UAAUA,EAAM,cAAc,KAAA,GACxEM,IAASC,QACPH,OAAiB,MAAUA,EAAYF,GAAKJ,EAAYU,CAAK,IAAIA,IAAQ,KAAA,CAAS,IACxF,CAACJ,GAAaF,CAAG,CACnB;CAEA,OADAO,cAAsBH,IAAS,KAAA,CAAS,GAAG,CAACA,CAAM,CAAC,GAC5CA;AACT;AAGA,SAAgBI,EAAiB,GAAuB,GAA+B;CACrF,IAAMJ,IAASP,EAAeM,CAAO,GAC/BM,IAAQH,GAAO,OACfI,IAAMJ,GAAO;CACnB,QAAgB;EACd,IAASG,MAAU,KAAA,KAAaC,MAAQ,KAAA,IAAY,KAAA,IAAY;GAAE;GAAO;EAAI,CAAC;CAChF,GAAG;EAACN;EAAQK;EAAOC;CAAG,CAAC;AACzB;AAaA,SAAgBC,EACd,GACA,EAAE,UAAO,iBAAc,cAAW,GAAGR,KACrC;CACA,IAAMC,IAASP,EAAeM,CAAO,GAC/BS,IAAmBC,KAAS,OAAO,KAAA,IAAY,OAAOA,CAAK,CAAC,CAAC;CAGnE,QAAgB;EACd,IAAMC,IAAQC,EAAS;EACvB,IAAKX,KAAWU,GAGhB;OAAIE,MAAc,KAAA,GAChB,EAAO,KAAA,CAAS;QACX,IAAIJ,MAAqB,KAAA,GAC9B,EAAO;IAAE,OAAOA;IAAkB,KAAKI;GAAU,CAAC;QAElD,OAAOC,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AAyBjB,GAAO,OAAO,CAAC,EAAE,QAAQiB,EAAQ,QAGjEL,IACF,OAAO,eAAeZ,GAAO,SAASY,CAAG,IAEzC,QAAQ,eAAeZ,GAAO,OAAO;CAEzC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLimit-DXe_VmYl.cjs","names":["useContext","FieldFrameContext","useId","useMemo","usableLimit","require_context","require_limit","react","useLimitReport","frame","key","reportLimit","binding","report","limit","useReportedLimit","count","max","useTextLimit","controlledLength","value","input","inputRef","maxLength","observeText","defaultValue","timer","onReset","event","read","owner","restoreValue","interceptValueWrites","own","accessor","get","set","isActive","wrapper","next","onWrite"],"sources":["../../src/components/Field/useLimit.ts"],"sourcesContent":["import { useContext, useEffect, useId, useMemo, type RefObject } from \"react\";\nimport { FieldFrameContext } from \"./context\";\nimport { usableLimit } from \"./limit\";\nimport type { FieldBinding, FieldLimit } from \"./types\";\n\ntype ReportLimit = (limit: FieldLimit | undefined) => void;\ntype TextControl = HTMLInputElement | HTMLTextAreaElement;\n\n/**\n * A control reports only to the Field it is explicitly bound to, and only while\n * that Field has no explicit limit. Each control owns one keyed report, removed\n * on unmount or rebinding without disturbing another control's report.\n */\nfunction useLimitReport(binding: FieldBinding): ReportLimit | undefined {\n const frame = useContext(FieldFrameContext);\n const key = useId();\n const reportLimit =\n frame && binding[\"aria-labelledby\"] === frame.labelId ? frame.reportLimit : undefined;\n const report = useMemo<ReportLimit | undefined>(\n () => reportLimit && ((limit) => reportLimit(key, usableLimit(limit) ? limit : undefined)),\n [reportLimit, key],\n );\n useEffect(() => () => report?.(undefined), [report]);\n return report;\n}\n\n/** Report a limit derived during render, such as committed tags or selected entries. */\nexport function useReportedLimit(binding: FieldBinding, limit: FieldLimit | undefined) {\n const report = useLimitReport(binding);\n const count = limit?.count;\n const max = limit?.max;\n useEffect(() => {\n report?.(count === undefined || max === undefined ? undefined : { count, max });\n }, [report, count, max]);\n}\n\ninterface TextLimitProps extends FieldBinding {\n maxLength?: number;\n value?: string | number | readonly string[] | null;\n defaultValue?: string | number | readonly string[] | null;\n}\n\n/**\n * Count a native text control for its bound Field. A controlled value is counted\n * from props; null is uncontrolled, as in React. An uncontrolled control is\n * observed only while a Field can show its count.\n */\nexport function useTextLimit(\n inputRef: RefObject<TextControl | null>,\n { value, defaultValue, maxLength, ...binding }: TextLimitProps,\n) {\n const report = useLimitReport(binding);\n const controlledLength = value == null ? undefined : String(value).length;\n // A new default changes an unedited control's value without any event.\n const defaultText = defaultValue == null ? \"\" : String(defaultValue);\n useEffect(() => {\n const input = inputRef.current;\n if (!report || !input) {\n return;\n }\n if (maxLength === undefined) {\n report(undefined);\n } else if (controlledLength !== undefined) {\n report({ count: controlledLength, max: maxLength });\n } else {\n return observeText(input, () => report({ count: input.value.length, max: maxLength }));\n }\n }, [inputRef, report, maxLength, controlledLength, defaultText]);\n}\n\n/**\n * Follow typing, autofill, programmatic writes and native resets without\n * replacing React's handlers or its value tracker.\n */\nfunction observeText(input: TextControl, read: () => void) {\n let timer: ReturnType<typeof setTimeout> | undefined;\n // The reset event precedes the browser restoring the form's controls, and a\n // later listener may still cancel it, so read once the reset task completes.\n // The form owner is checked at event time so `form` attribute changes apply.\n const onReset = (event: Event) => {\n if (event.target === input.form) {\n clearTimeout(timer);\n timer = setTimeout(read);\n }\n };\n const owner = input.ownerDocument;\n const restoreValue = interceptValueWrites(input, read);\n input.addEventListener(\"input\", read);\n input.addEventListener(\"change\", read);\n owner.addEventListener(\"reset\", onReset, true);\n read();\n return () => {\n clearTimeout(timer);\n restoreValue();\n input.removeEventListener(\"input\", read);\n input.removeEventListener(\"change\", read);\n owner.removeEventListener(\"reset\", onReset, true);\n };\n}\n\n/**\n * Programmatic `value` writes (form libraries' setValue/reset) fire no events.\n * Wrap the instance accessor, chaining to whatever defines it now (React's\n * tracker), and restore that accessor when observation ends.\n */\nfunction interceptValueWrites(input: TextControl, onWrite: () => void) {\n const own = Object.getOwnPropertyDescriptor(input, \"value\");\n const accessor = own ?? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), \"value\");\n const get = accessor?.get;\n const set = accessor?.set;\n if (!get || !set || own?.configurable === false) {\n return () => {};\n }\n let isActive = true;\n const wrapper: PropertyDescriptor = {\n configurable: true,\n enumerable: accessor.enumerable,\n get(this: TextControl) {\n return get.call(this);\n },\n set(this: TextControl, next: string) {\n set.call(this, next);\n if (isActive) {\n onWrite();\n }\n },\n };\n Object.defineProperty(input, \"value\", wrapper);\n return () => {\n isActive = false;\n // Leave a later wrapper in place; it still chains through this inert one.\n if (Object.getOwnPropertyDescriptor(input, \"value\")?.set !== wrapper.set) {\n return;\n }\n if (own) {\n Object.defineProperty(input, \"value\", own);\n } else {\n Reflect.deleteProperty(input, \"value\");\n }\n };\n}\n"],"mappings":"A,mGAaA,SAASQ,EAAe,EAAgD,CACtE,IAAMC,GAAA,EAAQT,EAAAA,WAAAA,CAAWC,EAAAA,CAAiB,EACpCS,GAAA,EAAMR,EAAAA,MAAAA,CAAM,EACZS,EACJF,GAASG,EAAQ,qBAAuBH,EAAM,QAAUA,EAAM,YAAc,IAAA,GACxEI,GAAA,EAASV,EAAAA,QAAAA,KACPQ,IAAiB,GAAUA,EAAYD,EAAKN,EAAAA,EAAYU,CAAK,EAAIA,EAAQ,IAAA,EAAS,GACxF,CAACH,EAAaD,CAAG,CACnB,EAEA,OADA,EAAAH,EAAA,UAAA,SAAsBM,IAAS,IAAA,EAAS,EAAG,CAACA,CAAM,CAAC,EAC5CA,CACT,CAGA,SAAgBE,EAAiB,EAAuB,EAA+B,CACrF,IAAMF,EAASL,EAAeI,CAAO,EAC/BI,EAAQF,GAAO,MACfG,EAAMH,GAAO,KACnB,EAAAP,EAAA,UAAA,KAAgB,CACdM,IAASG,IAAU,IAAA,IAAaC,IAAQ,IAAA,GAAY,IAAA,GAAY,CAAE,QAAO,KAAI,CAAC,CAChF,EAAG,CAACJ,EAAQG,EAAOC,CAAG,CAAC,CACzB,CAaA,SAAgBC,EACd,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IACtB,GAAI,CAACC,GAAO,CAACC,GAAOH,GAAK,eAAiB,GACxC,UAAa,CAAC,EAEhB,IAAII,EAAW,GACTC,EAA8B,CAClC,aAAc,GACd,WAAYJ,EAAS,WACrB,KAAuB,CACrB,OAAOC,EAAI,KAAK,IAAI,CACtB,EACA,IAAuB,EAAc,CACnCC,EAAI,KAAK,KAAMG,CAAI,EACfF,GACFG,EAAQ,CAEZ,CACF,EAEA,OADA,OAAO,eAAenB,EAAO,QAASiB,CAAO,MAChC,CACX,EAAW,GAEP,OAAO,yBAAyBjB,EAAO,OAAO,CAAC,EAAE,MAAQiB,EAAQ,MAGjEL,EACF,OAAO,eAAeZ,EAAO,QAASY,CAAG,EAEzC,QAAQ,eAAeZ,EAAO,OAAO,EAEzC,CACF,C"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./portalScope-BVA1-Ypu.cjs"),t=require("./isComposing-BrBcAANm.cjs");let n=require("react");var r=[];function i(){let e={};return r.push(e),{isTopmost:()=>r.at(-1)===e,close:()=>{let t=r.indexOf(e);t!==-1&&r.splice(t,1)}}}var a=0,o={overflow:``,paddingRight:``};function s(){let{body:e,documentElement:t}=document;if(a===0){o={overflow:e.style.overflow,paddingRight:e.style.paddingRight};let n=t.clientWidth;e.style.overflow=`hidden`;let r=t.clientWidth-n;if(r>0){let t=parseFloat(getComputedStyle(e).paddingRight)||0;e.style.paddingRight=`${t+r}px`}}a+=1;let n=!1;return()=>{n||(n=!0,--a,!(a>0)&&(e.style.overflow=o.overflow,e.style.paddingRight=o.paddingRight))}}function c({isOpen:r,panelRef:a,onClose:o,initialFocus:c,preventScroll:l=!1,container:u}){let d=(0,n.useRef)({onClose:o,initialFocus:c}),[f,p]=(0,n.useState)(null),[m,h]=(0,n.useState)(!1);return m!==r&&(h(r),p(r&&typeof document<`u`?document.activeElement:null)),(0,n.useEffect)(()=>{d.current={onClose:o,initialFocus:c}}),(0,n.useEffect)(()=>{if(!r)return;let n={preventScroll:l},o=a.current;o&&!o.contains(document.activeElement)&&(d.current.initialFocus?.()??e.s(o)[0]??o).focus(n);let c=i(),u=n=>{if(c.isTopmost()){if(n.key===`Escape`){if(n.defaultPrevented||t.t(n))return;n.preventDefault(),d.current.onClose()}else e.c(n,a.current)}};window.addEventListener(`keydown`,u);let p=s();return()=>{window.removeEventListener(`keydown`,u),c.close(),p(),e.i(document.activeElement)&&e.a(f,n)}},[r,f,a,l,u]),{onScrimMouseDown:e=>{r&&e.target===e.currentTarget&&(e.preventDefault(),d.current.onClose())}}}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
|
2
|
-
//# sourceMappingURL=useModalDialog-Cgus9408.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useModalDialog-Cgus9408.cjs","names":["useRef","useState","tabbableControls","isComposing","cannotHoldFocus","require_portalScope","require_isComposing","react","stack","openDialog","entry","index","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","useModalDialog","latest","opener","setOpener","wasOpen","setWasOpen","isOpen","focusOptions","panel","panelRef","dialog","onKeyDown","event","unlockScroll","preventScroll","container"],"sources":["../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts"],"sourcesContent":["const stack: object[] = [];\n\n/**\n * Register an open modal dialog. When dialogs nest (a picker over a drawer, a\n * drawer over a modal), only the most recently opened one handles keys.\n */\nexport function openDialog() {\n const entry = {};\n stack.push(entry);\n return {\n isTopmost: () => stack.at(-1) === entry,\n close: () => {\n const index = stack.indexOf(entry);\n if (index !== -1) {\n stack.splice(index, 1);\n }\n },\n };\n}\n","let locks = 0;\nlet previous = { overflow: \"\", paddingRight: \"\" };\n\n/**\n * Nested dialogs may unmount in either order; restore scrolling after the last.\n * Hiding a classic scrollbar widens the page, so the body is padded by the\n * width it gave back and layouts that measure themselves keep their mode.\n */\nexport function lockBodyScroll() {\n const { body, documentElement } = document;\n if (locks === 0) {\n previous = { overflow: body.style.overflow, paddingRight: body.style.paddingRight };\n const width = documentElement.clientWidth;\n body.style.overflow = \"hidden\";\n const scrollbar = documentElement.clientWidth - width;\n if (scrollbar > 0) {\n const padding = parseFloat(getComputedStyle(body).paddingRight) || 0;\n body.style.paddingRight = `${padding + scrollbar}px`;\n }\n }\n locks += 1;\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n locks -= 1;\n if (locks > 0) {\n return;\n }\n body.style.overflow = previous.overflow;\n body.style.paddingRight = previous.paddingRight;\n };\n}\n","import { useEffect, useRef, useState, type MouseEvent, type RefObject } from \"react\";\nimport { openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport { cannotHoldFocus, focusNearest, tabbableControls, trapTabFocus } from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n panelRef: RefObject<HTMLElement | null>;\n /** Escape and a direct scrim press call this. Read when called, so it may change every render. */\n onClose: () => void;\n /** First focus when focus isn't already inside the panel. Defaults to the first tabbable control, then the panel. */\n initialFocus?: () => HTMLElement | null | undefined;\n /** Panels that slide in from off-screen must not scroll the page when focused. */\n preventScroll?: boolean;\n /** Registration restarts when this changes while open, such as a new portal container. */\n container?: unknown;\n}\n\n/**\n * Behaviour every modal overlay shares: one dialog-stack entry, a body scroll\n * lock, Escape and a Tab trap while topmost, initial focus, and focus returned\n * to the opener (or its nearest focusable container) when closing dropped it.\n */\nexport function useModalDialog({\n isOpen,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useRef({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus inside it.\n const [opener, setOpener] = useState<Element | null>(null);\n const [wasOpen, setWasOpen] = useState(false);\n if (wasOpen !== isOpen) {\n setWasOpen(isOpen);\n setOpener(isOpen && typeof document !== \"undefined\" ? document.activeElement : null);\n }\n\n useEffect(() => {\n latest.current = { onClose, initialFocus };\n });\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n // Leave focus that autoFocus or the caller already placed inside the panel.\n if (panel && !panel.contains(document.activeElement)) {\n (latest.current.initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(focusOptions);\n }\n\n const dialog = openDialog();\n const onKeyDown = (event: KeyboardEvent) => {\n // A nested picker, drawer or modal handles keys until it closes.\n if (!dialog.isTopmost()) {\n return;\n }\n if (event.key === \"Escape\") {\n // A popup inside the panel (Menu, Select, DateField) claims its Escape first.\n if (event.defaultPrevented || isComposing(event)) {\n return;\n }\n event.preventDefault();\n latest.current.onClose();\n return;\n }\n trapTabFocus(event, panelRef.current);\n };\n // On window, so popup handlers on the document and inside the panel run first.\n window.addEventListener(\"keydown\", onKeyDown);\n const unlockScroll = lockBodyScroll();\n\n return () => {\n window.removeEventListener(\"keydown\", onKeyDown);\n dialog.close();\n unlockScroll();\n // Restore focus only when closing dropped it; the caller may already have placed it.\n if (cannotHoldFocus(document.activeElement)) {\n focusNearest(opener, focusOptions);\n }\n };\n }, [isOpen, opener, panelRef, preventScroll, container]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown };\n}\n"],"mappings":"A,6GAAA,IAAMQ,EAAkB,CAAC,EAMzB,SAAgBC,GAAa,CAC3B,IAAMC,EAAQ,CAAC,EAEf,OADAF,EAAM,KAAKE,CAAK,EACT,CACL,cAAiBF,EAAM,GAAG,EAAE,IAAME,EAClC,UAAa,CACX,IAAMC,EAAQH,EAAM,QAAQE,CAAK,EAC7BC,IAAU,IACZH,EAAM,OAAOG,EAAO,CAAC,CAEzB,CACF,CACF,CClBA,IAAIC,EAAQ,EACRC,EAAW,CAAE,SAAU,GAAI,aAAc,EAAG,EAOhD,SAAgBC,GAAiB,CAC/B,GAAM,CAAE,OAA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AAyB,CAE1C,GAAKD,EAAO,UAAU,EAGtB,IAAIE,EAAM,MAAQ,SAAU,CAE1B,GAAIA,EAAM,kBAAoB9B,EAAAA,EAAY8B,CAAK,EAC7C,OAEFA,EAAM,eAAe,EACrBX,EAAO,QAAQ,QAAQ,CAEzB,MACAjB,EAAA,EAAa4B,EAAOH,EAAS,OAAO,CADpC,CAEF,EAEA,OAAO,iBAAiB,UAAWE,CAAS,EAC5C,IAAME,EAAepB,EAAe,EAEpC,UAAa,CACX,OAAO,oBAAoB,UAAWkB,CAAS,EAC/CD,EAAO,MAAM,EACbG,EAAa,EAET9B,EAAAA,EAAgB,SAAS,aAAa,GACxCC,EAAA,EAAakB,EAAQK,CAAY,CAErC,CACF,EAAG,CAACD,EAAQJ,EAAQO,EAAUK,EAAeC,CAAS,CAAC,EAShD,CAAE,iBANiB,GAAsB,CAC1CT,GAAUM,EAAM,SAAWA,EAAM,gBACnCA,EAAM,eAAe,EACrBX,EAAO,QAAQ,QAAQ,EAE3B,CAC0B,CAC5B,C"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, s as r } from "./portalScope-AzzPM54i.js";
|
|
2
|
-
import { t as i } from "./isComposing-8bRWyiLF.js";
|
|
3
|
-
import { useEffect as a, useRef as o, useState as s } from "react";
|
|
4
|
-
//#region src/internal/dialogStack.ts
|
|
5
|
-
var c = [];
|
|
6
|
-
function l() {
|
|
7
|
-
let e = {};
|
|
8
|
-
return c.push(e), {
|
|
9
|
-
isTopmost: () => c.at(-1) === e,
|
|
10
|
-
close: () => {
|
|
11
|
-
let t = c.indexOf(e);
|
|
12
|
-
t !== -1 && c.splice(t, 1);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/internal/lockBodyScroll.ts
|
|
18
|
-
var u = 0, d = {
|
|
19
|
-
overflow: "",
|
|
20
|
-
paddingRight: ""
|
|
21
|
-
};
|
|
22
|
-
function f() {
|
|
23
|
-
let { body: e, documentElement: t } = document;
|
|
24
|
-
if (u === 0) {
|
|
25
|
-
d = {
|
|
26
|
-
overflow: e.style.overflow,
|
|
27
|
-
paddingRight: e.style.paddingRight
|
|
28
|
-
};
|
|
29
|
-
let n = t.clientWidth;
|
|
30
|
-
e.style.overflow = "hidden";
|
|
31
|
-
let r = t.clientWidth - n;
|
|
32
|
-
if (r > 0) {
|
|
33
|
-
let t = parseFloat(getComputedStyle(e).paddingRight) || 0;
|
|
34
|
-
e.style.paddingRight = `${t + r}px`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
u += 1;
|
|
38
|
-
let n = !1;
|
|
39
|
-
return () => {
|
|
40
|
-
n || (n = !0, --u, !(u > 0) && (e.style.overflow = d.overflow, e.style.paddingRight = d.paddingRight));
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/internal/useModalDialog.ts
|
|
45
|
-
function p({ isOpen: c, panelRef: u, onClose: d, initialFocus: p, preventScroll: m = !1, container: h }) {
|
|
46
|
-
let g = o({
|
|
47
|
-
onClose: d,
|
|
48
|
-
initialFocus: p
|
|
49
|
-
}), [_, v] = s(null), [y, b] = s(!1);
|
|
50
|
-
return y !== c && (b(c), v(c && typeof document < "u" ? document.activeElement : null)), a(() => {
|
|
51
|
-
g.current = {
|
|
52
|
-
onClose: d,
|
|
53
|
-
initialFocus: p
|
|
54
|
-
};
|
|
55
|
-
}), a(() => {
|
|
56
|
-
if (!c) return;
|
|
57
|
-
let a = { preventScroll: m }, o = u.current;
|
|
58
|
-
o && !o.contains(document.activeElement) && (g.current.initialFocus?.() ?? r(o)[0] ?? o).focus(a);
|
|
59
|
-
let s = l(), d = (e) => {
|
|
60
|
-
if (s.isTopmost()) {
|
|
61
|
-
if (e.key === "Escape") {
|
|
62
|
-
if (e.defaultPrevented || i(e)) return;
|
|
63
|
-
e.preventDefault(), g.current.onClose();
|
|
64
|
-
} else t(e, u.current);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
window.addEventListener("keydown", d);
|
|
68
|
-
let p = f();
|
|
69
|
-
return () => {
|
|
70
|
-
window.removeEventListener("keydown", d), s.close(), p(), n(document.activeElement) && e(_, a);
|
|
71
|
-
};
|
|
72
|
-
}, [
|
|
73
|
-
c,
|
|
74
|
-
_,
|
|
75
|
-
u,
|
|
76
|
-
m,
|
|
77
|
-
h
|
|
78
|
-
]), { onScrimMouseDown: (e) => {
|
|
79
|
-
c && e.target === e.currentTarget && (e.preventDefault(), g.current.onClose());
|
|
80
|
-
} };
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
83
|
-
export { p as t };
|
|
84
|
-
|
|
85
|
-
//# sourceMappingURL=useModalDialog-Dh-_6A0j.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useModalDialog-Dh-_6A0j.js","names":["focusNearest","trapTabFocus","cannotHoldFocus","tabbableControls","isComposing","stack","openDialog","entry","index","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","useModalDialog","latest","useRef","opener","setOpener","useState","wasOpen","setWasOpen","isOpen","useEffect","focusOptions","panel","panelRef","dialog","onKeyDown","event","unlockScroll","preventScroll","container"],"sources":["../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts"],"sourcesContent":["const stack: object[] = [];\n\n/**\n * Register an open modal dialog. When dialogs nest (a picker over a drawer, a\n * drawer over a modal), only the most recently opened one handles keys.\n */\nexport function openDialog() {\n const entry = {};\n stack.push(entry);\n return {\n isTopmost: () => stack.at(-1) === entry,\n close: () => {\n const index = stack.indexOf(entry);\n if (index !== -1) {\n stack.splice(index, 1);\n }\n },\n };\n}\n","let locks = 0;\nlet previous = { overflow: \"\", paddingRight: \"\" };\n\n/**\n * Nested dialogs may unmount in either order; restore scrolling after the last.\n * Hiding a classic scrollbar widens the page, so the body is padded by the\n * width it gave back and layouts that measure themselves keep their mode.\n */\nexport function lockBodyScroll() {\n const { body, documentElement } = document;\n if (locks === 0) {\n previous = { overflow: body.style.overflow, paddingRight: body.style.paddingRight };\n const width = documentElement.clientWidth;\n body.style.overflow = \"hidden\";\n const scrollbar = documentElement.clientWidth - width;\n if (scrollbar > 0) {\n const padding = parseFloat(getComputedStyle(body).paddingRight) || 0;\n body.style.paddingRight = `${padding + scrollbar}px`;\n }\n }\n locks += 1;\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n locks -= 1;\n if (locks > 0) {\n return;\n }\n body.style.overflow = previous.overflow;\n body.style.paddingRight = previous.paddingRight;\n };\n}\n","import { useEffect, useRef, useState, type MouseEvent, type RefObject } from \"react\";\nimport { openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport { cannotHoldFocus, focusNearest, tabbableControls, trapTabFocus } from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n panelRef: RefObject<HTMLElement | null>;\n /** Escape and a direct scrim press call this. Read when called, so it may change every render. */\n onClose: () => void;\n /** First focus when focus isn't already inside the panel. Defaults to the first tabbable control, then the panel. */\n initialFocus?: () => HTMLElement | null | undefined;\n /** Panels that slide in from off-screen must not scroll the page when focused. */\n preventScroll?: boolean;\n /** Registration restarts when this changes while open, such as a new portal container. */\n container?: unknown;\n}\n\n/**\n * Behaviour every modal overlay shares: one dialog-stack entry, a body scroll\n * lock, Escape and a Tab trap while topmost, initial focus, and focus returned\n * to the opener (or its nearest focusable container) when closing dropped it.\n */\nexport function useModalDialog({\n isOpen,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useRef({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus inside it.\n const [opener, setOpener] = useState<Element | null>(null);\n const [wasOpen, setWasOpen] = useState(false);\n if (wasOpen !== isOpen) {\n setWasOpen(isOpen);\n setOpener(isOpen && typeof document !== \"undefined\" ? document.activeElement : null);\n }\n\n useEffect(() => {\n latest.current = { onClose, initialFocus };\n });\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n // Leave focus that autoFocus or the caller already placed inside the panel.\n if (panel && !panel.contains(document.activeElement)) {\n (latest.current.initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(focusOptions);\n }\n\n const dialog = openDialog();\n const onKeyDown = (event: KeyboardEvent) => {\n // A nested picker, drawer or modal handles keys until it closes.\n if (!dialog.isTopmost()) {\n return;\n }\n if (event.key === \"Escape\") {\n // A popup inside the panel (Menu, Select, DateField) claims its Escape first.\n if (event.defaultPrevented || isComposing(event)) {\n return;\n }\n event.preventDefault();\n latest.current.onClose();\n return;\n }\n trapTabFocus(event, panelRef.current);\n };\n // On window, so popup handlers on the document and inside the panel run first.\n window.addEventListener(\"keydown\", onKeyDown);\n const unlockScroll = lockBodyScroll();\n\n return () => {\n window.removeEventListener(\"keydown\", onKeyDown);\n dialog.close();\n unlockScroll();\n // Restore focus only when closing dropped it; the caller may already have placed it.\n if (cannotHoldFocus(document.activeElement)) {\n focusNearest(opener, focusOptions);\n }\n };\n }, [isOpen, opener, panelRef, preventScroll, container]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown };\n}\n"],"mappings":";;;;AAAA,IAAMK,IAAkB,CAAC;AAMzB,SAAgBC,IAAa;CAC3B,IAAMC,IAAQ,CAAC;CAEf,OADAF,EAAM,KAAKE,CAAK,GACT;EACL,iBAAiBF,EAAM,GAAG,EAAE,MAAME;EAClC,aAAa;GACX,IAAMC,IAAQH,EAAM,QAAQE,CAAK;GACjC,AAAIC,MAAU,MACZH,EAAM,OAAOG,GAAO,CAAC;EAEzB;CACF;AACF;;;AClBA,IAAIC,IAAQ,GACRC,IAAW;CAAE,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AAO,UAAU,GAGtB;QAAIE,EAAM,QAAQ,UAAU;KAE1B,IAAIA,EAAM,oBAAoB7B,EAAY6B,CAAK,GAC7C;KAGF,AADAA,EAAM,eAAe,GACrBd,EAAO,QAAQ,QAAQ;IAEzB,OACA,EAAac,GAAOH,EAAS,OAAO;GADpC;EAEF;EAEA,OAAO,iBAAiB,WAAWE,CAAS;EAC5C,IAAME,IAAevB,EAAe;EAEpC,aAAa;GAKX,AAJA,OAAO,oBAAoB,WAAWqB,CAAS,GAC/CD,EAAO,MAAM,GACbG,EAAa,GAEThC,EAAgB,SAAS,aAAa,KACxCF,EAAaqB,GAAQO,CAAY;EAErC;CACF,GAAG;EAACF;EAAQL;EAAQS;EAAUK;EAAeC;CAAS,CAAC,GAShD,EAAE,mBANiB,MAAsB;EAC9C,AAAIV,KAAUO,EAAM,WAAWA,EAAM,kBACnCA,EAAM,eAAe,GACrBd,EAAO,QAAQ,QAAQ;CAE3B,EAC0B;AAC5B"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./isComposing-8bRWyiLF.js";
|
|
2
|
-
import { Popover as t } from "../components/Popover/index.js";
|
|
3
|
-
import { useEffect as n, useId as r, useRef as i, useState as a } from "react";
|
|
4
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
5
|
-
//#region src/components/Popover/useTooltip.tsx
|
|
6
|
-
var s = 100;
|
|
7
|
-
function c(e, t) {
|
|
8
|
-
return (n) => {
|
|
9
|
-
e?.(n), n.defaultPrevented || t(n);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function l(e) {
|
|
13
|
-
let t = typeof document > "u" ? null : document.activeElement;
|
|
14
|
-
if (!e || !t || !e.contains(t)) return !1;
|
|
15
|
-
try {
|
|
16
|
-
return t.matches(":focus-visible");
|
|
17
|
-
} catch {
|
|
18
|
-
return !0;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function u(u, { placement: d, className: f } = {}) {
|
|
22
|
-
let p = u !== !1 && u != null && u !== "", m = i(null), h = r(), [g, _] = a(!1), [v, y] = a(!1), b = i(!1), x = i(void 0);
|
|
23
|
-
!p && g && _(!1), n(() => () => clearTimeout(x.current), []), n(() => {
|
|
24
|
-
if (!g) return;
|
|
25
|
-
let t = (t) => {
|
|
26
|
-
t.key !== "Escape" || t.defaultPrevented || e(t) || (t.preventDefault(), _(!1));
|
|
27
|
-
};
|
|
28
|
-
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
29
|
-
}, [g]);
|
|
30
|
-
let S = () => {
|
|
31
|
-
clearTimeout(x.current), p && (_(!0), y(!0));
|
|
32
|
-
}, C = () => {
|
|
33
|
-
clearTimeout(x.current), x.current = setTimeout(() => {
|
|
34
|
-
!b.current && !l(m.current) && _(!1);
|
|
35
|
-
}, s);
|
|
36
|
-
}, w = () => {
|
|
37
|
-
b.current = !0, S();
|
|
38
|
-
}, T = () => {
|
|
39
|
-
b.current = !1, C();
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
anchorRef: m,
|
|
43
|
-
description: p && g ? h : void 0,
|
|
44
|
-
triggerProps: (e = {}) => ({
|
|
45
|
-
onMouseEnter: c(e.onMouseEnter, w),
|
|
46
|
-
onMouseLeave: c(e.onMouseLeave, T),
|
|
47
|
-
onFocus: c(e.onFocus, S),
|
|
48
|
-
onBlur: c(e.onBlur, C)
|
|
49
|
-
}),
|
|
50
|
-
panel: p && v ? /* @__PURE__ */ o(t, {
|
|
51
|
-
anchorRef: m,
|
|
52
|
-
isOpen: g,
|
|
53
|
-
id: h,
|
|
54
|
-
role: "tooltip",
|
|
55
|
-
placement: d,
|
|
56
|
-
className: [
|
|
57
|
-
"ds-surface-raised",
|
|
58
|
-
"ds-field-surface",
|
|
59
|
-
"ds-tooltip",
|
|
60
|
-
f
|
|
61
|
-
].filter(Boolean).join(" "),
|
|
62
|
-
children: /* @__PURE__ */ o("span", {
|
|
63
|
-
className: "ds-tooltip__content",
|
|
64
|
-
onMouseEnter: w,
|
|
65
|
-
onMouseLeave: T,
|
|
66
|
-
children: u
|
|
67
|
-
})
|
|
68
|
-
}) : null
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
export { u as t };
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=useTooltip-C5gvEoYk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltip-C5gvEoYk.js","names":["isComposing","CLOSE_DELAY","compose","theirs","event","ours","holdsKeyboardFocus","active","anchor","useTooltip","isEnabled","content","anchorRef","useRef","id","useId","isOpen","setIsOpen","useState","hasOpened","setHasOpened","hovered","timer","useEffect","dismiss","show","hide","enter","leave","handlers","Popover","className"],"sources":["../../src/components/Popover/useTooltip.tsx"],"sourcesContent":["import {\n useEffect,\n useId,\n useRef,\n useState,\n type FocusEventHandler,\n type MouseEventHandler,\n type ReactNode,\n type SyntheticEvent,\n} from \"react\";\nimport { isComposing } from \"../../internal/isComposing\";\nimport { Popover, type PopoverPlacement } from \".\";\n\n/** Grace period for moving the pointer from the anchor onto the tooltip text. */\nconst CLOSE_DELAY = 100;\n\ninterface TooltipTriggerHandlers<T extends Element> {\n onMouseEnter?: MouseEventHandler<T>;\n onMouseLeave?: MouseEventHandler<T>;\n onFocus?: FocusEventHandler<T>;\n onBlur?: FocusEventHandler<T>;\n}\n\ninterface TooltipOptions {\n placement?: PopoverPlacement;\n /** Added beside the shared tooltip surface classes. */\n className?: string;\n}\n\n/** The caller's handler runs first; preventing its default skips the tooltip's response. */\nfunction compose<E extends SyntheticEvent>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n) {\n return (event: E) => {\n theirs?.(event);\n if (!event.defaultPrevented) {\n ours(event);\n }\n };\n}\n\n/**\n * Keyboard focus inside the anchor holds a tooltip open after the pointer leaves;\n * the focus a pointer press leaves behind does not. Checked when closing, after\n * the focus event has settled.\n */\nfunction holdsKeyboardFocus(anchor: Element | null) {\n const active = typeof document === \"undefined\" ? null : document.activeElement;\n if (!anchor || !active || !anchor.contains(active)) {\n return false;\n }\n try {\n return active.matches(\":focus-visible\");\n } catch {\n // Engines without :focus-visible keep the earlier behaviour: any focus holds it.\n return true;\n }\n}\n\n/**\n * Hover and focus tooltip shared by Avatar and Time. It survives a short pointer\n * move onto its text, stays while keyboard focus remains, and closes on Escape\n * anywhere. `false`, `null` or empty content disables it.\n */\nexport function useTooltip<T extends HTMLElement>(\n content: ReactNode,\n { placement, className }: TooltipOptions = {},\n) {\n const isEnabled =\n content !== false && content !== null && content !== undefined && content !== \"\";\n const anchorRef = useRef<T | null>(null);\n const id = useId();\n const [isOpen, setIsOpen] = useState(false);\n // Idle anchors, such as avatars in a long table, mount no Popover until first shown.\n const [hasOpened, setHasOpened] = useState(false);\n const hovered = useRef(false);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n if (!isEnabled && isOpen) {\n // Disabling closes it, so re-enabling later cannot reopen it unprompted.\n setIsOpen(false);\n }\n\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n const dismiss = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || event.defaultPrevented || isComposing(event)) {\n return;\n }\n // Claim it as other popups do: a surrounding dialog skips a prevented Escape,\n // while window listeners still receive the event.\n event.preventDefault();\n setIsOpen(false);\n };\n document.addEventListener(\"keydown\", dismiss);\n return () => document.removeEventListener(\"keydown\", dismiss);\n }, [isOpen]);\n\n const show = () => {\n clearTimeout(timer.current);\n if (isEnabled) {\n setIsOpen(true);\n setHasOpened(true);\n }\n };\n const hide = () => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n if (!hovered.current && !holdsKeyboardFocus(anchorRef.current)) {\n setIsOpen(false);\n }\n }, CLOSE_DELAY);\n };\n const enter = () => {\n hovered.current = true;\n show();\n };\n const leave = () => {\n hovered.current = false;\n hide();\n };\n\n return {\n anchorRef,\n /** Add to the trigger's `aria-describedby` alongside any caller description. */\n description: isEnabled && isOpen ? id : undefined,\n /** The trigger's hover and focus handlers, composed with the caller's. */\n triggerProps: (handlers: TooltipTriggerHandlers<T> = {}) => ({\n onMouseEnter: compose(handlers.onMouseEnter, enter),\n onMouseLeave: compose(handlers.onMouseLeave, leave),\n onFocus: compose(handlers.onFocus, show),\n onBlur: compose(handlers.onBlur, hide),\n }),\n panel:\n isEnabled && hasOpened ? (\n <Popover\n anchorRef={anchorRef}\n isOpen={isOpen}\n id={id}\n role=\"tooltip\"\n placement={placement}\n className={[\"ds-surface-raised\", \"ds-field-surface\", \"ds-tooltip\", className]\n .filter(Boolean)\n .join(\" \")}\n >\n <span\n className=\"ds-tooltip__content\"\n onMouseEnter={enter}\n onMouseLeave={leave}\n >\n {content}\n </span>\n </Popover>\n ) : null,\n };\n}\n"],"mappings":";;;;;AAcA,IAAMC,IAAc;AAgBpB,SAASC,EACP,GACA,GACA;CACA,QAAQ,MAAa;EAEnB,AADAC,IAASC,CAAK,GACTA,EAAM,oBACTC,EAAKD,CAAK;CAEd;AACF;AAOA,SAASE,EAAmB,GAAwB;CAClD,IAAMC,IAAS,OAAO,WAAa,MAAc,OAAO,SAAS;CACjE,IAAI,CAACC,KAAU,CAACD,KAAU,CAACC,EAAO,SAASD,CAAM,GAC/C,OAAO;CAET,IAAI;EACF,OAAOA,EAAO,QAAQ,gBAAgB;CACxC,QAAQ;EAEN,OAAO;CACT;AACF;AAOA,SAAgBE,EACd,GACA,EAAE,cAAW,iBAA8B,CAAC,GAC5C;CACA,IAAMC,IACJC,MAAY,MAASA,KAAY,QAAiCA,MAAY,IAC1EC,IAAYC,EAAiB,IAAI,GACjCC,IAAKC,EAAM,GACX,CAACC,GAAQC,KAAaC,EAAS,EAAK,GAEpC,CAACC,GAAWC,KAAgBF,EAAS,EAAK,GAC1CG,IAAUR,EAAO,EAAK,GACtBS,IAAQT,EAAkD,KAAA,CAAS;CAQzE,AAPI,CAACH,KAAaM,KAEhBC,EAAU,EAAK,GAGjBM,cAA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AA,IACP;CACR;AACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./isComposing-BrBcAANm.cjs"),t=require("../components/Popover/index.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=100;function a(e,t){return n=>{e?.(n),n.defaultPrevented||t(n)}}function o(e){let t=typeof document>`u`?null:document.activeElement;if(!e||!t||!e.contains(t))return!1;try{return t.matches(`:focus-visible`)}catch{return!0}}function s(s,{placement:c,className:l}={}){let u=s!==!1&&s!=null&&s!==``,d=(0,n.useRef)(null),f=(0,n.useId)(),[p,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(!1),_=(0,n.useRef)(!1),v=(0,n.useRef)(void 0);!u&&p&&m(!1),(0,n.useEffect)(()=>()=>clearTimeout(v.current),[]),(0,n.useEffect)(()=>{if(!p)return;let t=t=>{t.key!==`Escape`||t.defaultPrevented||e.t(t)||(t.preventDefault(),m(!1))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[p]);let y=()=>{clearTimeout(v.current),u&&(m(!0),g(!0))},b=()=>{clearTimeout(v.current),v.current=setTimeout(()=>{!_.current&&!o(d.current)&&m(!1)},i)},x=()=>{_.current=!0,y()},S=()=>{_.current=!1,b()};return{anchorRef:d,description:u&&p?f:void 0,triggerProps:(e={})=>({onMouseEnter:a(e.onMouseEnter,x),onMouseLeave:a(e.onMouseLeave,S),onFocus:a(e.onFocus,y),onBlur:a(e.onBlur,b)}),panel:u&&h?(0,r.jsx)(t.Popover,{anchorRef:d,isOpen:p,id:f,role:`tooltip`,placement:c,className:[`ds-surface-raised`,`ds-field-surface`,`ds-tooltip`,l].filter(Boolean).join(` `),children:(0,r.jsx)(`span`,{className:`ds-tooltip__content`,onMouseEnter:x,onMouseLeave:S,children:s})}):null}}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
2
|
-
//# sourceMappingURL=useTooltip-bTE_a2Xn.cjs.map
|