@namroodinc/liquid-editorial 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -7
- package/UPGRADING.md +142 -0
- package/dist/chunks/{Avatar-6t78C9Np.js → Avatar-BK8IdL5W.js} +2 -2
- package/dist/chunks/{Avatar-6t78C9Np.js.map → Avatar-BK8IdL5W.js.map} +1 -1
- package/dist/chunks/{Avatar-Cvj_DqG0.cjs → Avatar-DPnrvkwd.cjs} +2 -2
- package/dist/chunks/{Avatar-Cvj_DqG0.cjs.map → Avatar-DPnrvkwd.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-B18Ihv7X.cjs → CollectionView-BNYx29b1.cjs} +2 -2
- package/dist/chunks/{CollectionView-B18Ihv7X.cjs.map → CollectionView-BNYx29b1.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-C-SwkPWC.js → CollectionView-Vj84E26b.js} +2 -2
- package/dist/chunks/{CollectionView-C-SwkPWC.js.map → CollectionView-Vj84E26b.js.map} +1 -1
- package/dist/chunks/{ColourField-Dohdx7eW.cjs → ColourField-C1qjpIfB.cjs} +2 -2
- package/dist/chunks/{ColourField-Dohdx7eW.cjs.map → ColourField-C1qjpIfB.cjs.map} +1 -1
- package/dist/chunks/{ColourField-DzZ--mQZ.js → ColourField-Ce2oaVcd.js} +2 -2
- package/dist/chunks/{ColourField-DzZ--mQZ.js.map → ColourField-Ce2oaVcd.js.map} +1 -1
- package/dist/chunks/{DatePicker-Bjc4D8Kg.cjs → DatePicker-BCnzFJFF.cjs} +2 -2
- package/dist/chunks/{DatePicker-Bjc4D8Kg.cjs.map → DatePicker-BCnzFJFF.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-DZVOtzoU.js → DatePicker-CnVmsCwO.js} +2 -2
- package/dist/chunks/{DatePicker-DZVOtzoU.js.map → DatePicker-CnVmsCwO.js.map} +1 -1
- package/dist/chunks/{Drawer-CcVF_p4b.cjs → Drawer-BDX9_qHA.cjs} +2 -2
- package/dist/chunks/Drawer-BDX9_qHA.cjs.map +1 -0
- package/dist/chunks/{Drawer-uhJvy3s9.js → Drawer-DTtgAZO2.js} +3 -3
- package/dist/chunks/Drawer-DTtgAZO2.js.map +1 -0
- package/dist/chunks/EntryPicker-Baqn0SQM.cjs +2 -0
- package/dist/chunks/EntryPicker-Baqn0SQM.cjs.map +1 -0
- package/dist/chunks/EntryPicker-DIYjKmBf.js +803 -0
- package/dist/chunks/EntryPicker-DIYjKmBf.js.map +1 -0
- package/dist/chunks/FormEditor-B7Pm_ZzT.cjs +2 -0
- package/dist/chunks/FormEditor-B7Pm_ZzT.cjs.map +1 -0
- package/dist/chunks/{FormEditor-D0J3JN-H.js → FormEditor-HqqFmu7s.js} +156 -150
- package/dist/chunks/FormEditor-HqqFmu7s.js.map +1 -0
- package/dist/chunks/{RichTextEditor-B6H6_3wk.js → RichTextEditor-CuZnjiy2.js} +86 -86
- package/dist/chunks/RichTextEditor-CuZnjiy2.js.map +1 -0
- package/dist/chunks/RichTextEditor-DcbLho2Q.cjs +2 -0
- package/dist/chunks/RichTextEditor-DcbLho2Q.cjs.map +1 -0
- package/dist/chunks/{dialogLabel-3EeaH1Zl.cjs → dialogLabel-2HRYMHbF.cjs} +2 -2
- package/dist/chunks/{dialogLabel-3EeaH1Zl.cjs.map → dialogLabel-2HRYMHbF.cjs.map} +1 -1
- package/dist/chunks/{dialogLabel-BjtTix5C.js → dialogLabel-D18maX-p.js} +2 -2
- package/dist/chunks/{dialogLabel-BjtTix5C.js.map → dialogLabel-D18maX-p.js.map} +1 -1
- package/dist/chunks/{frame-CycTDnzE.js → frame-CzadNYgy.js} +3 -3
- package/dist/chunks/{frame-CycTDnzE.js.map → frame-CzadNYgy.js.map} +1 -1
- package/dist/chunks/{frame-BtIh7K-M.cjs → frame-Mh99nmhR.cjs} +2 -2
- package/dist/chunks/{frame-BtIh7K-M.cjs.map → frame-Mh99nmhR.cjs.map} +1 -1
- package/dist/chunks/group-CJA3-3s5.js +35 -0
- package/dist/chunks/group-CJA3-3s5.js.map +1 -0
- package/dist/chunks/group-DRSLOsXu.cjs +2 -0
- package/dist/chunks/group-DRSLOsXu.cjs.map +1 -0
- package/dist/chunks/limit-BNo4dlRj.cjs +2 -0
- package/dist/chunks/limit-BNo4dlRj.cjs.map +1 -0
- package/dist/chunks/{limit-BHHST_0G.js → limit-s9zfxIMC.js} +5 -4
- package/dist/chunks/limit-s9zfxIMC.js.map +1 -0
- package/dist/chunks/overlayLayer-IuoPVwTO.js +158 -0
- package/dist/chunks/overlayLayer-IuoPVwTO.js.map +1 -0
- package/dist/chunks/overlayLayer-seJG-EFn.cjs +2 -0
- package/dist/chunks/overlayLayer-seJG-EFn.cjs.map +1 -0
- package/dist/chunks/useIsomorphicLayoutEffect-Bc9hxFMc.js +7 -0
- package/dist/chunks/useIsomorphicLayoutEffect-Bc9hxFMc.js.map +1 -0
- package/dist/chunks/useIsomorphicLayoutEffect-XM4Ot6x5.cjs +2 -0
- package/dist/chunks/useIsomorphicLayoutEffect-XM4Ot6x5.cjs.map +1 -0
- package/dist/chunks/{useLimit-WWWDacob.cjs → useLimit-CCv6sAUS.cjs} +2 -2
- package/dist/chunks/{useLimit-WWWDacob.cjs.map → useLimit-CCv6sAUS.cjs.map} +1 -1
- package/dist/chunks/{useLimit-C471qZ4H.js → useLimit-DZOKm4S_.js} +2 -2
- package/dist/chunks/{useLimit-C471qZ4H.js.map → useLimit-DZOKm4S_.js.map} +1 -1
- package/dist/chunks/{useTooltip-DtrE7QYu.cjs → useTooltip-BXAvQwt4.cjs} +2 -2
- package/dist/chunks/{useTooltip-DtrE7QYu.cjs.map → useTooltip-BXAvQwt4.cjs.map} +1 -1
- package/dist/chunks/{useTooltip-DajWQyNL.js → useTooltip-BrC7FdeH.js} +2 -2
- package/dist/chunks/{useTooltip-DajWQyNL.js.map → useTooltip-BrC7FdeH.js.map} +1 -1
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.js +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Badge/style.css +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.d.cts +13 -2
- package/dist/components/Choice/index.d.cts.map +1 -1
- package/dist/components/Choice/index.d.ts +13 -2
- package/dist/components/Choice/index.d.ts.map +1 -1
- package/dist/components/Choice/index.js +55 -35
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/Choice/style.css +7 -2
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.d.cts +4 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts +4 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/Drawer/style.css +4 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +62 -61
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EditLayout/style.css +12 -5
- package/dist/components/EntryPicker/blocked.d.cts +21 -0
- package/dist/components/EntryPicker/blocked.d.cts.map +1 -0
- package/dist/components/EntryPicker/blocked.d.ts +21 -0
- package/dist/components/EntryPicker/blocked.d.ts.map +1 -0
- package/dist/components/EntryPicker/dialog.d.cts +7 -3
- package/dist/components/EntryPicker/dialog.d.cts.map +1 -1
- package/dist/components/EntryPicker/dialog.d.ts +7 -3
- package/dist/components/EntryPicker/dialog.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- 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 +25 -1
- package/dist/components/EntryPicker/item.d.cts.map +1 -1
- package/dist/components/EntryPicker/item.d.ts +25 -1
- package/dist/components/EntryPicker/item.d.ts.map +1 -1
- package/dist/components/EntryPicker/limit.d.cts +25 -2
- package/dist/components/EntryPicker/limit.d.cts.map +1 -1
- package/dist/components/EntryPicker/limit.d.ts +25 -2
- package/dist/components/EntryPicker/limit.d.ts.map +1 -1
- package/dist/components/EntryPicker/results.d.cts +3 -4
- package/dist/components/EntryPicker/results.d.cts.map +1 -1
- package/dist/components/EntryPicker/results.d.ts +3 -4
- package/dist/components/EntryPicker/results.d.ts.map +1 -1
- package/dist/components/EntryPicker/selected-items.d.cts.map +1 -1
- package/dist/components/EntryPicker/selected-items.d.ts.map +1 -1
- package/dist/components/EntryPicker/style.css +79 -12
- package/dist/components/EntryPicker/types.d.cts +8 -0
- package/dist/components/EntryPicker/types.d.cts.map +1 -1
- package/dist/components/EntryPicker/types.d.ts +8 -0
- package/dist/components/EntryPicker/types.d.ts.map +1 -1
- package/dist/components/EntryPicker/use-picker-scroll.d.cts +14 -0
- package/dist/components/EntryPicker/use-picker-scroll.d.cts.map +1 -0
- package/dist/components/EntryPicker/use-picker-scroll.d.ts +14 -0
- package/dist/components/EntryPicker/use-picker-scroll.d.ts.map +1 -0
- package/dist/components/Field/group.d.cts +1 -1
- package/dist/components/Field/group.d.cts.map +1 -1
- package/dist/components/Field/group.d.ts +1 -1
- package/dist/components/Field/group.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/types.d.cts +3 -1
- package/dist/components/Field/types.d.cts.map +1 -1
- package/dist/components/Field/types.d.ts +3 -1
- package/dist/components/Field/types.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.cjs +1 -1
- package/dist/components/FieldAffix/index.cjs.map +1 -1
- package/dist/components/FieldAffix/index.d.cts.map +1 -1
- package/dist/components/FieldAffix/index.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.js +2 -1
- package/dist/components/FieldAffix/index.js.map +1 -1
- package/dist/components/FormEditor/README.md +31 -10
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +9 -2
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +9 -2
- 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.d.cts.map +1 -1
- package/dist/components/ImageCropper/index.d.ts.map +1 -1
- package/dist/components/ImageCropper/index.js +30 -29
- package/dist/components/ImageCropper/index.js.map +1 -1
- package/dist/components/LimitReading/index.cjs +1 -1
- package/dist/components/LimitReading/index.cjs.map +1 -1
- package/dist/components/LimitReading/index.d.cts +1 -1
- package/dist/components/LimitReading/index.d.cts.map +1 -1
- package/dist/components/LimitReading/index.d.ts +1 -1
- package/dist/components/LimitReading/index.d.ts.map +1 -1
- package/dist/components/LimitReading/index.js +19 -14
- package/dist/components/LimitReading/index.js.map +1 -1
- package/dist/components/LimitReading/limit.d.cts +3 -3
- package/dist/components/LimitReading/limit.d.cts.map +1 -1
- package/dist/components/LimitReading/limit.d.ts +3 -3
- package/dist/components/LimitReading/limit.d.ts.map +1 -1
- package/dist/components/LimitReading/types.d.cts +8 -0
- package/dist/components/LimitReading/types.d.cts.map +1 -1
- package/dist/components/LimitReading/types.d.ts +8 -0
- package/dist/components/LimitReading/types.d.ts.map +1 -1
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts +4 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts +4 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +5 -3
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +4 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.js +1 -1
- package/dist/components/RichTextEditor/expansion.d.cts.map +1 -1
- package/dist/components/RichTextEditor/expansion.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.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts +2 -0
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts +2 -0
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +14 -13
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.cjs.map +1 -1
- package/dist/components/SubNav/index.d.cts.map +1 -1
- package/dist/components/SubNav/index.d.ts.map +1 -1
- package/dist/components/SubNav/index.js +40 -31
- package/dist/components/SubNav/index.js.map +1 -1
- package/dist/components/SubNav/style.css +0 -14
- 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 +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/internal/portalScope.d.cts.map +1 -1
- package/dist/internal/portalScope.d.ts.map +1 -1
- package/dist/internal/useIsomorphicLayoutEffect.d.cts +7 -0
- package/dist/internal/useIsomorphicLayoutEffect.d.cts.map +1 -0
- package/dist/internal/useIsomorphicLayoutEffect.d.ts +7 -0
- package/dist/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/dist/internal/useLatest.d.cts.map +1 -1
- package/dist/internal/useLatest.d.ts.map +1 -1
- package/dist/internal/useModalDialog.d.cts.map +1 -1
- package/dist/internal/useModalDialog.d.ts.map +1 -1
- package/dist/tokens.css +1 -0
- package/package.json +1 -1
- package/dist/chunks/Drawer-CcVF_p4b.cjs.map +0 -1
- package/dist/chunks/Drawer-uhJvy3s9.js.map +0 -1
- package/dist/chunks/EntryPicker-CBquan7o.js +0 -685
- package/dist/chunks/EntryPicker-CBquan7o.js.map +0 -1
- package/dist/chunks/EntryPicker-Dq72wjTt.cjs +0 -2
- package/dist/chunks/EntryPicker-Dq72wjTt.cjs.map +0 -1
- package/dist/chunks/FormEditor-CTcnpR51.cjs +0 -2
- package/dist/chunks/FormEditor-CTcnpR51.cjs.map +0 -1
- package/dist/chunks/FormEditor-D0J3JN-H.js.map +0 -1
- package/dist/chunks/RichTextEditor-B6H6_3wk.js.map +0 -1
- package/dist/chunks/RichTextEditor-BIopdEDA.cjs +0 -2
- package/dist/chunks/RichTextEditor-BIopdEDA.cjs.map +0 -1
- package/dist/chunks/group-67F_I1yw.js +0 -34
- package/dist/chunks/group-67F_I1yw.js.map +0 -1
- package/dist/chunks/group-BSJHLagi.cjs +0 -2
- package/dist/chunks/group-BSJHLagi.cjs.map +0 -1
- package/dist/chunks/limit-BBnpe9o9.cjs +0 -2
- package/dist/chunks/limit-BBnpe9o9.cjs.map +0 -1
- package/dist/chunks/limit-BHHST_0G.js.map +0 -1
- package/dist/chunks/overlayLayer-BgnMskpk.js +0 -158
- package/dist/chunks/overlayLayer-BgnMskpk.js.map +0 -1
- package/dist/chunks/overlayLayer-YVudmo27.cjs +0 -2
- package/dist/chunks/overlayLayer-YVudmo27.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextEditor-CuZnjiy2.js","names":["_jsx","_Fragment","cannotHoldFocus","focusNearest","PortalScopeContext","useIsomorphicLayoutEffect","Fragment$1","revealCaretInContent","content","host","caret","editor","view","useEditorExpansion","useMovableHost","expanded","setExpanded","useState","inlineHeight","setInlineHeight","inlineSlotRef","useRef","expandedSlotRef","toggleRef","restoreToggle","shownExpanded","dialogId","useId","disabled","collapse","useCallback","moveHost","frameRef","toggleLabel","jsx","Button","event","createPortal","surface","Modal","label","expandedWidth","invalid","labelledBy","emptyDocument","richTextExtensions","StarterKit","Link","schema","getSchema","normalizeDocument","document","documentError","value","check","type","node","key","mark","markType","LinkDialog","href","setHref","selection","error","setError","formId","onTransaction","onClose","canEdit","save","url","chain","Field","TextField","field","GROUPS","EditorToolbar","ButtonGroup","i","group","tool","state","openLink","toolbarExtra","expandControl","EditorFrame","forwardRef","scopeRef","className","expansion","isFocused","contentError","errorId","children","releaseUnboundEscape","handle","RichTextEditor","ariaLabel","describedBy","ariaInvalid","props","mergedRef","useMemo","mergeRefs","ref","setIsFocused","linkSelection","setLinkSelection","closeLink","initialValue","isInvalid","isDisabled","range","position","getMarkRange","link","attributes","id","isRequired","required","editorProps","anchor","useEditor","Placeholder","e","useEffect","next","createDocument","useEditorState","size","EditorContent"],"sources":["../../src/components/RichTextEditor/expansion.tsx","../../src/components/RichTextEditor/document.ts","../../src/components/RichTextEditor/index.tsx"],"sourcesContent":["import {\n useCallback,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { Editor } from \"@tiptap/react\";\nimport { cannotHoldFocus, focusNearest } from \"../../internal/dialogFocus\";\nimport { moveHost, useMovableHost } from \"../../internal/movableHost\";\nimport { useIsomorphicLayoutEffect } from \"../../internal/useIsomorphicLayoutEffect\";\nimport { Button } from \"../Button\";\nimport { Modal } from \"../Modal\";\nimport type { RichTextEditorExpandedWidth } from \"./expanded-width\";\n\nexport type { RichTextEditorExpandedWidth } from \"./expanded-width\";\n\n/**\n * Moving the host resets the content's scroll position, so bring the caret\n * back into the content's own view. This scrolls only the content and needs no\n * DOM selection, so it also works when focus returns to the toggle.\n */\nfunction revealCaretInContent(editor: Editor, host: HTMLElement) {\n const content = host.querySelector<HTMLElement>(\".ds-rte__content\");\n if (!content) {\n return;\n }\n const caret = editor.view.coordsAtPos(editor.state.selection.head);\n const view = content.getBoundingClientRect();\n if (caret.top < view.top || caret.bottom > view.bottom) {\n content.scrollTop += caret.top - view.top - view.height / 2;\n }\n}\n\ninterface EditorExpansionOptions {\n editor: Editor | null;\n disabled: boolean;\n invalid: boolean;\n label: string;\n labelledBy?: string;\n expandedWidth: RichTextEditorExpandedWidth;\n frameRef: RefObject<HTMLDivElement | null>;\n}\n\n/**\n * The expanded writing view is a headerless Modal. The editor's surface renders\n * once into a movable host that sits in the inline frame or in the Modal's\n * body, so the same toolbar, content, editor instance and selection survive\n * every toggle. Modal owns the scrim, frame, dialog stack, focus trap, scroll\n * lock and Escape.\n */\nexport function useEditorExpansion({\n editor,\n disabled,\n invalid,\n label,\n labelledBy,\n expandedWidth,\n frameRef,\n}: EditorExpansionOptions) {\n const host = useMovableHost(\"ds-rte__host\");\n const [expanded, setExpanded] = useState(false);\n const [inlineHeight, setInlineHeight] = useState(0);\n const inlineSlotRef = useRef<HTMLDivElement | null>(null);\n const expandedSlotRef = useRef<HTMLDivElement | null>(null);\n const toggleRef = useRef<HTMLButtonElement | null>(null);\n const restoreToggle = useRef(false);\n const shownExpanded = useRef(false);\n const dialogId = useId();\n\n if (expanded && disabled) {\n setExpanded(false);\n }\n\n const collapse = useCallback(() => {\n restoreToggle.current = document.activeElement === toggleRef.current;\n setExpanded(false);\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n if (!host) {\n return;\n }\n moveHost(host, expanded ? expandedSlotRef.current : inlineSlotRef.current);\n // Only a change of mode hands focus and the caret across; other updates,\n // such as disabling while saving, leave the editor exactly where it is.\n if (shownExpanded.current === expanded) {\n return;\n }\n shownExpanded.current = expanded;\n // A disabled editor can't take focus. Keep it near the editor instead, in the\n // nearest focusable container such as an enclosing Drawer, not on the page.\n if (disabled || !editor) {\n if (cannotHoldFocus(document.activeElement)) {\n focusNearest(frameRef.current, { preventScroll: true });\n }\n return;\n }\n revealCaretInContent(editor, host);\n if (!expanded && restoreToggle.current) {\n // Focus decides what stays visible: the toggle, where the person left it.\n toggleRef.current?.focus();\n } else {\n // The writing surface takes focus, and the page or an enclosing panel\n // scrolls to its caret, which a growing inline editor needs on collapse.\n editor.view.focus();\n editor.commands.scrollIntoView();\n }\n restoreToggle.current = false;\n }, [host, expanded, editor, disabled, frameRef]);\n\n const toggleLabel = expanded ? \"Collapse editor\" : \"Expand editor\";\n const toggle = (\n <Button\n ref={toggleRef}\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"minimize-2\" : \"maximize-2\"}\n className=\"ds-rte__expand\"\n aria-label={toggleLabel}\n title={toggleLabel}\n aria-expanded={expanded}\n aria-controls={expanded ? dialogId : undefined}\n isDisabled={disabled || !editor || !host}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n if (expanded) {\n collapse();\n return;\n }\n setInlineHeight(frameRef.current!.getBoundingClientRect().height);\n setExpanded(true);\n }}\n />\n );\n\n /** The inline place for the surface: the host after hydration, inline markup before it. */\n const surfaceSlot = (surface: ReactNode) => (\n <div\n ref={inlineSlotRef}\n className=\"ds-rte__slot\"\n >\n {host ? createPortal(surface, host) : surface}\n </div>\n );\n\n const dialog = (\n <Modal\n id={dialogId}\n isOpen={expanded}\n onClose={collapse}\n title={label}\n hasHeader={false}\n size={expandedWidth === \"full\" ? \"full\" : \"wide\"}\n className=\"ds-rte__modal\"\n data-invalid={invalid || undefined}\n aria-labelledby={labelledBy}\n >\n <div\n ref={expandedSlotRef}\n className=\"ds-rte__expanded-slot\"\n />\n </Modal>\n );\n\n /** The inline frame keeps its measured height while the surface is away. */\n const frameStyle: CSSProperties | undefined = expanded\n ? { minBlockSize: inlineHeight }\n : undefined;\n\n return { expanded, toggle, surfaceSlot, dialog, frameStyle };\n}\n","import { getSchema, type JSONContent } from \"@tiptap/react\";\nimport { StarterKit } from \"@tiptap/starter-kit\";\nimport { Link } from \"@tiptap/extension-link\";\n\nexport type RichTextDocument = JSONContent & { type: \"doc\" };\n\nexport const emptyDocument: RichTextDocument = { type: \"doc\", content: [{ type: \"paragraph\" }] };\n\nexport function richTextExtensions() {\n return [\n StarterKit.configure({ link: false }),\n Link.configure({ openOnClick: false, autolink: true }),\n ];\n}\n\nconst schema = getSchema(richTextExtensions());\n\n/** ProseMirror represents an empty writing surface with one empty paragraph. */\nexport function normalizeDocument(document: RichTextDocument): RichTextDocument {\n return !document.content?.length ? { ...document, content: emptyDocument.content } : document;\n}\n\nexport function documentError(value: unknown): string | undefined {\n try {\n if (!value || typeof value !== \"object\" || !(\"type\" in value) || value.type !== \"doc\") {\n throw new Error();\n }\n const check = (node: JSONContent) => {\n const type = schema.nodes[node.type ?? \"\"];\n if (\n !type ||\n Object.keys(node).some(\n (key) => ![\"type\", \"attrs\", \"content\", \"marks\", \"text\"].includes(key),\n ) ||\n (node.text !== undefined && node.type !== \"text\") ||\n (node.attrs &&\n Object.keys(node.attrs).some((key) => !Object.hasOwn(type.spec.attrs ?? {}, key)))\n ) {\n throw new Error();\n }\n for (const mark of node.marks ?? []) {\n const markType = schema.marks[mark.type];\n if (\n !markType ||\n Object.keys(mark).some((key) => ![\"type\", \"attrs\"].includes(key)) ||\n Object.keys(mark.attrs ?? {}).some(\n (key) => !Object.hasOwn(markType.spec.attrs ?? {}, key),\n )\n ) {\n throw new Error();\n }\n }\n node.content?.forEach(check);\n };\n const document = value as RichTextDocument;\n check(document);\n schema.nodeFromJSON(normalizeDocument(document)).check();\n } catch {\n return \"Unsupported or invalid rich-text document.\";\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport {\n createDocument,\n EditorContent,\n getMarkRange,\n useEditor,\n useEditorState,\n type Editor,\n type EditorOptions,\n} from \"@tiptap/react\";\nimport { Placeholder } from \"@tiptap/extension-placeholder\";\nimport { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { Field } from \"../Field\";\nimport { Modal } from \"../Modal\";\nimport { TextField } from \"../TextField\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { PortalScopeContext } from \"../../internal/portalScope\";\nimport { useEditorExpansion, type RichTextEditorExpandedWidth } from \"./expansion\";\nimport {\n documentError,\n emptyDocument,\n normalizeDocument,\n richTextExtensions,\n type RichTextDocument,\n} from \"./document\";\nimport \"../Field/style.css\";\nimport type { FieldBinding } from \"../Field\";\nimport \"./style.css\";\n\nexport type RichTextEditorSize = \"sm\" | \"md\" | \"lg\";\n\nexport type { RichTextDocument } from \"./document\";\nexport type { RichTextEditorExpandedWidth } from \"./expansion\";\n\ninterface RichTextEditorCommonProps extends FieldBinding {\n placeholder?: string;\n size?: RichTextEditorSize;\n /** Expanded writing measure. `wide` caps at the shared 920px Modal width; `full` fills the viewport. */\n expandedWidth?: RichTextEditorExpandedWidth;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Accessible name for the editing surface. */\n label?: string;\n className?: string;\n /** Extra controls appended to the toolbar, e.g. a word count. */\n toolbarExtra?: ReactNode;\n isRequired?: boolean;\n}\n\nexport type RichTextEditorProps = RichTextEditorCommonProps &\n (\n | { format?: \"html\"; value?: string; defaultValue?: string; onChange?: (html: string) => void }\n | {\n format: \"json\";\n value?: RichTextDocument;\n defaultValue?: RichTextDocument;\n onChange?: (document: RichTextDocument) => void;\n }\n );\n\ninterface ToolItem {\n id: string;\n icon: IconName;\n label: string;\n run: (editor: Editor) => void;\n active?: (editor: Editor) => boolean;\n}\n\ninterface LinkSelection {\n from: number;\n to: number;\n href: string;\n isEditing: boolean;\n document: Editor[\"state\"][\"doc\"];\n}\n\nfunction LinkDialog({\n editor,\n selection,\n onClose,\n}: {\n editor: Editor;\n selection: LinkSelection;\n onClose: () => void;\n}) {\n const [href, setHref] = useState(selection.href);\n const [error, setError] = useState<string>();\n const formId = useId();\n\n useEffect(() => {\n const onTransaction = () => {\n if (!editor.state.doc.eq(selection.document)) {\n onClose();\n }\n };\n editor.on(\"transaction\", onTransaction);\n return () => {\n editor.off(\"transaction\", onTransaction);\n };\n }, [editor, selection, onClose]);\n\n const canEdit = () =>\n !editor.isDestroyed && editor.isEditable && editor.state.doc.eq(selection.document);\n const save = () => {\n if (!canEdit()) {\n onClose();\n return;\n }\n const url = href.trim();\n if (!url || !editor.can().setLink({ href: url })) {\n setError(url ? \"Enter a valid link URL.\" : \"Enter a link URL.\");\n return;\n }\n const chain = editor\n .chain()\n .focus()\n .setTextSelection({ from: selection.from, to: selection.to });\n if (selection.from === selection.to && !selection.isEditing) {\n chain\n .setLink({ href: url })\n .insertContent({ type: \"text\", text: url, marks: [{ type: \"link\", attrs: { href: url } }] })\n .run();\n } else {\n chain.setLink({ href: url }).run();\n }\n onClose();\n };\n\n return (\n <Modal\n isOpen\n title={selection.isEditing ? \"Edit link\" : \"Add link\"}\n size=\"dialog\"\n onClose={onClose}\n footer={\n <>\n {selection.isEditing && (\n <Button\n variant=\"danger\"\n onClick={() => {\n if (canEdit()) {\n editor\n .chain()\n .focus()\n .setTextSelection({ from: selection.from, to: selection.to })\n .unsetLink()\n .run();\n }\n onClose();\n }}\n >\n Remove link\n </Button>\n )}\n <Button onClick={onClose}>Cancel</Button>\n <Button\n variant=\"primary\"\n type=\"submit\"\n form={formId}\n >\n Save\n </Button>\n </>\n }\n >\n <form\n id={formId}\n noValidate\n onSubmit={(event) => {\n event.preventDefault();\n event.stopPropagation();\n save();\n }}\n >\n <Field\n label=\"URL\"\n isRequired\n error={error}\n >\n {(field) => (\n <TextField\n {...field}\n value={href}\n inputMode=\"url\"\n autoComplete=\"url\"\n placeholder=\"https://example.com\"\n onChange={(event) => {\n setHref(event.target.value);\n setError(undefined);\n }}\n />\n )}\n </Field>\n </form>\n </Modal>\n );\n}\n\nconst GROUPS: ToolItem[][] = [\n [\n {\n id: \"bold\",\n icon: \"bold\",\n label: \"Bold\",\n run: (e) => e.chain().focus().toggleBold().run(),\n active: (e) => e.isActive(\"bold\"),\n },\n {\n id: \"italic\",\n icon: \"italic\",\n label: \"Italic\",\n run: (e) => e.chain().focus().toggleItalic().run(),\n active: (e) => e.isActive(\"italic\"),\n },\n {\n id: \"strike\",\n icon: \"strikethrough\",\n label: \"Strikethrough\",\n run: (e) => e.chain().focus().toggleStrike().run(),\n active: (e) => e.isActive(\"strike\"),\n },\n {\n id: \"code\",\n icon: \"code\",\n label: \"Inline code\",\n run: (e) => e.chain().focus().toggleCode().run(),\n active: (e) => e.isActive(\"code\"),\n },\n ],\n [\n {\n id: \"h2\",\n icon: \"heading-2\",\n label: \"Heading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 2 }),\n },\n {\n id: \"h3\",\n icon: \"heading-3\",\n label: \"Subheading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 3 }),\n },\n {\n id: \"quote\",\n icon: \"quote\",\n label: \"Quote\",\n run: (e) => e.chain().focus().toggleBlockquote().run(),\n active: (e) => e.isActive(\"blockquote\"),\n },\n ],\n [\n {\n id: \"ul\",\n icon: \"list\",\n label: \"Bulleted list\",\n run: (e) => e.chain().focus().toggleBulletList().run(),\n active: (e) => e.isActive(\"bulletList\"),\n },\n {\n id: \"ol\",\n icon: \"list-ordered\",\n label: \"Numbered list\",\n run: (e) => e.chain().focus().toggleOrderedList().run(),\n active: (e) => e.isActive(\"orderedList\"),\n },\n ],\n [\n {\n id: \"undo\",\n icon: \"undo\",\n label: \"Undo\",\n run: (e) => e.chain().focus().undo().run(),\n },\n {\n id: \"redo\",\n icon: \"redo\",\n label: \"Redo\",\n run: (e) => e.chain().focus().redo().run(),\n },\n ],\n];\n\ninterface ToolbarState {\n active: Record<string, boolean>;\n linkActive: boolean;\n}\n\nfunction EditorToolbar({\n editor,\n state,\n disabled,\n label,\n toolbarExtra,\n openLink,\n expandControl,\n}: {\n editor: Editor | null;\n state: ToolbarState | null;\n disabled: boolean;\n label: string;\n toolbarExtra: ReactNode;\n openLink: (state: Editor[\"state\"], position?: number) => void;\n expandControl: ReactNode;\n}) {\n return (\n <div\n className=\"ds-rte__toolbar\"\n role=\"toolbar\"\n aria-label={`${label} formatting`}\n >\n {GROUPS.map((group, i) => (\n <ButtonGroup\n key={i}\n aria-label={`Formatting ${i + 1}`}\n >\n {group.map((tool) => (\n <Button\n key={tool.id}\n size=\"sm\"\n isIconOnly\n iconStart={tool.icon}\n aria-label={tool.label}\n title={tool.label}\n aria-pressed={tool.active ? state?.active[tool.id] : undefined}\n variant={state?.active[tool.id] ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={() => editor && tool.run(editor)}\n />\n ))}\n </ButtonGroup>\n ))}\n <ButtonGroup aria-label=\"Link\">\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"link\"\n aria-label={state?.linkActive ? \"Edit link\" : \"Add link\"}\n title={state?.linkActive ? \"Edit link\" : \"Add link\"}\n variant={state?.linkActive ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={() =>\n editor &&\n openLink(\n editor.state,\n editor.isActive(\"link\") ? editor.state.selection.from : undefined,\n )\n }\n />\n </ButtonGroup>\n {toolbarExtra}\n {expandControl}\n </div>\n );\n}\n\n/**\n * The editorial writing surface. Rich text plus links — the same field skin,\n * radius and states as `TextField`, with the toolbar inside the frame.\n */\ninterface EditorFrameProps {\n scopeRef: RefObject<HTMLDivElement | null>;\n className?: string;\n expansion: ReturnType<typeof useEditorExpansion>;\n isFocused: boolean;\n disabled: boolean;\n invalid: boolean;\n contentError?: string;\n errorId: string;\n /** Toolbar and content: rendered once, inline or in the expanded Modal. */\n surface: ReactNode;\n /** Overlays such as the link dialog. */\n children?: ReactNode;\n}\n\n/**\n * The inline frame stays the outermost element, so `className` and layout apply\n * to it. It keeps its place and height while the surface is expanded, and\n * overlays opened from the editor carry its theme, direction and language.\n */\nconst EditorFrame = forwardRef<HTMLDivElement, EditorFrameProps>(function EditorFrame(\n {\n scopeRef,\n className,\n expansion,\n isFocused,\n disabled,\n invalid,\n contentError,\n errorId,\n surface,\n children,\n },\n ref,\n) {\n return (\n <PortalScopeContext.Provider value={scopeRef}>\n <div\n ref={ref}\n className={[\"ds-rte\", className].filter(Boolean).join(\" \")}\n style={expansion.frameStyle}\n data-expanded={expansion.expanded || undefined}\n data-focused={(isFocused && !expansion.expanded) || undefined}\n data-disabled={disabled || undefined}\n aria-invalid={invalid || undefined}\n >\n {contentError && (\n <p\n id={errorId}\n role=\"alert\"\n className=\"ds-field__error\"\n >\n {contentError}\n </p>\n )}\n {expansion.expanded && (\n <p className=\"ds-rte__placeholder\">Editing in expanded view. Press Esc to return.</p>\n )}\n {expansion.surfaceSlot(\n <div\n className=\"ds-rte__surface\"\n hidden={!!contentError}\n data-invalid={invalid || undefined}\n >\n {surface}\n </div>,\n )}\n {expansion.dialog}\n {children}\n </div>\n </PortalScopeContext.Provider>\n );\n});\n\n/**\n * ProseMirror cancels every Escape, bound or not, so an enclosing Modal or\n * Drawer would never close from the writing surface. Run the editor's own key\n * bindings and leave an unbound Escape to the page. Escape that ends an IME\n * composition stays with ProseMirror.\n */\nfunction releaseUnboundEscape(view: Editor[\"view\"], event: KeyboardEvent) {\n if (event.key !== \"Escape\" || event.isComposing) {\n return false;\n }\n if (view.someProp(\"handleKeyDown\", (handle) => handle(view, event))) {\n event.preventDefault();\n }\n return true;\n}\n\nexport const RichTextEditor = forwardRef<HTMLDivElement, RichTextEditorProps>(\n function RichTextEditor(props, ref) {\n const {\n placeholder = \"Write something…\",\n size = \"md\",\n expandedWidth = \"wide\",\n isDisabled = false,\n isInvalid = false,\n label = \"Rich text editor\",\n className,\n toolbarExtra,\n id,\n isRequired,\n required,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n \"aria-invalid\": ariaInvalid,\n } = props;\n const frameRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(frameRef, ref), [ref]);\n const [isFocused, setIsFocused] = useState(false);\n const [linkSelection, setLinkSelection] = useState<LinkSelection | null>(null);\n const closeLink = useCallback(() => setLinkSelection(null), []);\n const [initialValue] = useState(\n () => props.defaultValue ?? (props.format === \"json\" ? emptyDocument : \"\"),\n );\n const content = props.value !== undefined ? props.value : initialValue;\n const contentError = useMemo(\n () => (props.format === \"json\" ? documentError(content) : undefined),\n [props.format, content],\n );\n const errorId = useId();\n const invalid = isInvalid || !!contentError || ariaInvalid;\n const disabled = isDisabled || !!contentError;\n if (disabled && linkSelection) {\n setLinkSelection(null);\n }\n const openLink = useCallback(\n (state: Editor[\"state\"], position?: number) => {\n if (disabled) {\n return;\n }\n const range =\n position === undefined\n ? undefined\n : getMarkRange(state.doc.resolve(position), state.schema.marks.link);\n const link =\n range &&\n state.doc.nodeAt(range.from)?.marks.find((mark) => mark.type === state.schema.marks.link);\n setLinkSelection({\n from: range?.from ?? state.selection.from,\n to: range?.to ?? state.selection.to,\n href: link?.attrs.href ?? \"\",\n isEditing: !!link,\n document: state.doc,\n });\n },\n [disabled],\n );\n const attributes = useMemo(\n () => ({\n role: \"textbox\",\n ...(!labelledBy ? { \"aria-label\": ariaLabel ?? label } : {}),\n \"aria-multiline\": \"true\",\n ...(id ? { id } : {}),\n ...(labelledBy ? { \"aria-labelledby\": labelledBy } : {}),\n ...(describedBy ? { \"aria-describedby\": describedBy } : {}),\n ...(invalid ? { \"aria-invalid\": String(invalid) } : {}),\n ...(isRequired || required ? { \"aria-required\": \"true\" } : {}),\n }),\n [label, ariaLabel, id, labelledBy, describedBy, invalid, isRequired, required],\n );\n const editorProps = useMemo<EditorOptions[\"editorProps\"]>(\n () => ({\n attributes,\n handleDOMEvents: {\n keydown: releaseUnboundEscape,\n click: (view, event) => {\n const anchor = event.target instanceof Element ? event.target.closest(\"a\") : null;\n if (!anchor || !view.dom.contains(anchor)) {\n return false;\n }\n event.preventDefault();\n if (view.editable) {\n openLink(view.state, view.posAtDOM(anchor, 0));\n }\n return true;\n },\n },\n }),\n [attributes, openLink],\n );\n\n const editor = useEditor({\n immediatelyRender: false,\n editable: !disabled,\n content: contentError\n ? emptyDocument\n : typeof content === \"string\"\n ? content\n : normalizeDocument(content),\n extensions: [...richTextExtensions(), Placeholder.configure({ placeholder })],\n editorProps,\n onFocus: () => setIsFocused(true),\n onBlur: () => setIsFocused(false),\n onUpdate: ({ editor: e }) => {\n if (disabled) {\n return;\n }\n if (props.format === \"json\") {\n props.onChange?.(e.getJSON() as RichTextDocument);\n } else {\n props.onChange?.(e.getHTML());\n }\n },\n });\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n editor.setEditable(!disabled, false);\n editor.setOptions({ editorProps });\n }, [editor, disabled, editorProps]);\n\n useEffect(() => {\n if (!editor || props.value === undefined || contentError) {\n return;\n }\n const next =\n typeof props.value === \"string\"\n ? createDocument(props.value, editor.schema)\n : editor.schema.nodeFromJSON(normalizeDocument(props.value));\n // Parent echoes should preserve the current selection and undo history.\n if (!next.eq(editor.state.doc)) {\n editor.commands.setContent(next, { emitUpdate: false });\n }\n }, [editor, props.value, contentError]);\n\n const state = useEditorState({\n editor,\n selector: ({ editor: e }) =>\n e\n ? {\n active: Object.fromEntries(GROUPS.flat().map((t) => [t.id, t.active?.(e) ?? false])),\n linkActive: e.isActive(\"link\"),\n }\n : null,\n });\n\n const expansion = useEditorExpansion({\n editor,\n disabled,\n invalid: !!invalid,\n label: ariaLabel ?? label,\n labelledBy,\n expandedWidth,\n frameRef,\n });\n\n return (\n <EditorFrame\n ref={mergedRef}\n scopeRef={frameRef}\n className={className}\n expansion={expansion}\n isFocused={isFocused}\n disabled={disabled}\n invalid={!!invalid}\n contentError={contentError}\n errorId={errorId}\n surface={\n <>\n <EditorToolbar\n editor={editor}\n state={state}\n disabled={disabled}\n label={label}\n toolbarExtra={toolbarExtra}\n openLink={openLink}\n expandControl={expansion.toggle}\n />\n <div\n className=\"ds-rte__content\"\n data-size={size}\n >\n <EditorContent editor={editor} />\n </div>\n </>\n }\n >\n {editor && linkSelection && !disabled && (\n <LinkDialog\n editor={editor}\n selection={linkSelection}\n onClose={closeLink}\n />\n )}\n </EditorFrame>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,SAASO,EAAqB,GAAgB,GAAmB;CAC/D,IAAMC,IAAUC,EAAK,cAA2B,kBAAkB;CAClE,IAAI,CAACD,GACH;CAEF,IAAME,IAAQC,EAAO,KAAK,YAAYA,EAAO,MAAM,UAAU,IAAI,GAC3DC,IAAOJ,EAAQ,sBAAsB;CAC3C,CAAIE,EAAM,MAAME,EAAK,OAAOF,EAAM,SAASE,EAAK,YAC9C,EAAQ,aAAaF,EAAM,MAAME,EAAK,MAAMA,EAAK,SAAS;AAE9D;AAmBA,SAAgBC,EAAmB,EACjC,WACA,aACA,YACA,UACA,eACA,kBACA,eACyB;CACzB,IAAMJ,IAAOK,EAAe,cAAc,GACpC,CAACC,GAAUC,KAAeC,EAAS,EAAK,GACxC,CAACC,GAAcC,KAAmBF,EAAS,CAAC,GAC5CG,IAAgBC,EAA8B,IAAI,GAClDC,IAAkBD,EAA8B,IAAI,GACpDE,IAAYF,EAAiC,IAAI,GACjDG,IAAgBH,EAAO,EAAK,GAC5BI,IAAgBJ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C;EACA;EACA,SAAS,CAAC,CAAC6B;EACX,OAAOwD,KAAa1D;EACpB;EACA;EACA;CACF,CAAC;CAED,OACE,kBAAC8C,IAAD;EACE,KAAKgB;EACL,UAAUtE;EACC;EACA;EACA;EACD;EACV,SAAS,CAAC,CAACU;EACG;EACL;EACT,SACE,kBAAAzC,GAAA,EAAA,UAAA,CACE,kBAAC4E,IAAD;GACU;GACD;GACG;GACH;GACO;GACJ;GACV,eAAea,EAAU;EAC1B,CAAA,GACD,kBAAC,OAAD;GACE,WAAU;GACV,aAAWwC;GAEX,UAAA,kBAACC,GAAD,EAAuB,UAAS,CAAA;EAC7B,CAAA,CACL,EAAA,CAAA;EAGH,UAAAxH,KAAUgG,KAAiB,CAAC/E,KAC3B,kBAACgC,GAAD;GACU;GACR,WAAW+C;GACX,SAASE;EACV,CAAA;CAEQ,CAAA;AAEjB,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../components/Button/index.cjs"),t=require("./mergeRefs-CZ-SArlE.cjs"),n=require("./overlayLayer-seJG-EFn.cjs"),r=require("./dialogLabel-2HRYMHbF.cjs"),i=require("./useIsomorphicLayoutEffect-XM4Ot6x5.cjs"),a=require("../components/ButtonGroup/index.cjs");;/* empty css */const o=require("../components/Field/index.cjs"),s=require("../components/Modal/index.cjs"),c=require("../components/TextField/index.cjs");let l=require("react"),u=require("react-dom"),d=require("react/jsx-runtime"),f=require("@tiptap/react"),p=require("@tiptap/extension-placeholder"),m=require("@tiptap/starter-kit"),h=require("@tiptap/extension-link");function g(e,t){let n=t.querySelector(`.ds-rte__content`);if(!n)return;let r=e.view.coordsAtPos(e.state.selection.head),i=n.getBoundingClientRect();(r.top<i.top||r.bottom>i.bottom)&&(n.scrollTop+=r.top-i.top-i.height/2)}function _({editor:t,disabled:a,invalid:o,label:c,labelledBy:f,expandedWidth:p,frameRef:m}){let h=r.o(`ds-rte__host`),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(0),x=(0,l.useRef)(null),S=(0,l.useRef)(null),C=(0,l.useRef)(null),w=(0,l.useRef)(!1),T=(0,l.useRef)(!1),E=(0,l.useId)();_&&a&&v(!1);let D=(0,l.useCallback)(()=>{w.current=document.activeElement===C.current,v(!1)},[]);i.t(()=>{h&&(r.a(h,_?S.current:x.current),T.current!==_&&(T.current=_,a||!t?n.d(document.activeElement)&&n.f(m.current,{preventScroll:!0}):(g(t,h),!_&&w.current?C.current?.focus():(t.view.focus(),t.commands.scrollIntoView()),w.current=!1)))},[h,_,t,a,m]);let O=_?`Collapse editor`:`Expand editor`;return{expanded:_,toggle:(0,d.jsx)(e.Button,{ref:C,size:`sm`,isIconOnly:!0,iconStart:_?`minimize-2`:`maximize-2`,className:`ds-rte__expand`,"aria-label":O,title:O,"aria-expanded":_,"aria-controls":_?E:void 0,isDisabled:a||!t||!h,onMouseDown:e=>e.preventDefault(),onClick:()=>{_?D():(b(m.current.getBoundingClientRect().height),v(!0))}}),surfaceSlot:e=>(0,d.jsx)(`div`,{ref:x,className:`ds-rte__slot`,children:h?(0,u.createPortal)(e,h):e}),dialog:(0,d.jsx)(s.Modal,{id:E,isOpen:_,onClose:D,title:c,hasHeader:!1,size:p===`full`?`full`:`wide`,className:`ds-rte__modal`,"data-invalid":o||void 0,"aria-labelledby":f,children:(0,d.jsx)(`div`,{ref:S,className:`ds-rte__expanded-slot`})}),frameStyle:_?{minBlockSize:y}:void 0}}var v={type:`doc`,content:[{type:`paragraph`}]};function y(){return[m.StarterKit.configure({link:!1}),h.Link.configure({openOnClick:!1,autolink:!0})]}var b=(0,f.getSchema)(y());function x(e){return e.content?.length?e:{...e,content:v.content}}function S(e){try{if(!e||typeof e!=`object`||!(`type`in e)||e.type!==`doc`)throw Error();let t=e=>{let n=b.nodes[e.type??``];if(!n||Object.keys(e).some(e=>![`type`,`attrs`,`content`,`marks`,`text`].includes(e))||e.text!==void 0&&e.type!==`text`||e.attrs&&Object.keys(e.attrs).some(e=>!Object.hasOwn(n.spec.attrs??{},e)))throw Error();for(let t of e.marks??[]){let e=b.marks[t.type];if(!e||Object.keys(t).some(e=>![`type`,`attrs`].includes(e))||Object.keys(t.attrs??{}).some(t=>!Object.hasOwn(e.spec.attrs??{},t)))throw Error()}e.content?.forEach(t)},n=e;t(n),b.nodeFromJSON(x(n)).check()}catch{return`Unsupported or invalid rich-text document.`}}function C({editor:t,selection:n,onClose:r}){let[i,a]=(0,l.useState)(n.href),[u,f]=(0,l.useState)(),p=(0,l.useId)();(0,l.useEffect)(()=>{let e=()=>{t.state.doc.eq(n.document)||r()};return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}},[t,n,r]);let m=()=>!t.isDestroyed&&t.isEditable&&t.state.doc.eq(n.document),h=()=>{if(!m()){r();return}let e=i.trim();if(!e||!t.can().setLink({href:e})){f(e?`Enter a valid link URL.`:`Enter a link URL.`);return}let a=t.chain().focus().setTextSelection({from:n.from,to:n.to});n.from===n.to&&!n.isEditing?a.setLink({href:e}).insertContent({type:`text`,text:e,marks:[{type:`link`,attrs:{href:e}}]}).run():a.setLink({href:e}).run(),r()};return(0,d.jsx)(s.Modal,{isOpen:!0,title:n.isEditing?`Edit link`:`Add link`,size:`dialog`,onClose:r,footer:(0,d.jsxs)(d.Fragment,{children:[n.isEditing&&(0,d.jsx)(e.Button,{variant:`danger`,onClick:()=>{m()&&t.chain().focus().setTextSelection({from:n.from,to:n.to}).unsetLink().run(),r()},children:`Remove link`}),(0,d.jsx)(e.Button,{onClick:r,children:`Cancel`}),(0,d.jsx)(e.Button,{variant:`primary`,type:`submit`,form:p,children:`Save`})]}),children:(0,d.jsx)(`form`,{id:p,noValidate:!0,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),h()},children:(0,d.jsx)(o.Field,{label:`URL`,isRequired:!0,error:u,children:e=>(0,d.jsx)(c.TextField,{...e,value:i,inputMode:`url`,autoComplete:`url`,placeholder:`https://example.com`,onChange:e=>{a(e.target.value),f(void 0)}})})})})}var w=[[{id:`bold`,icon:`bold`,label:`Bold`,run:e=>e.chain().focus().toggleBold().run(),active:e=>e.isActive(`bold`)},{id:`italic`,icon:`italic`,label:`Italic`,run:e=>e.chain().focus().toggleItalic().run(),active:e=>e.isActive(`italic`)},{id:`strike`,icon:`strikethrough`,label:`Strikethrough`,run:e=>e.chain().focus().toggleStrike().run(),active:e=>e.isActive(`strike`)},{id:`code`,icon:`code`,label:`Inline code`,run:e=>e.chain().focus().toggleCode().run(),active:e=>e.isActive(`code`)}],[{id:`h2`,icon:`heading-2`,label:`Heading`,run:e=>e.chain().focus().toggleHeading({level:2}).run(),active:e=>e.isActive(`heading`,{level:2})},{id:`h3`,icon:`heading-3`,label:`Subheading`,run:e=>e.chain().focus().toggleHeading({level:3}).run(),active:e=>e.isActive(`heading`,{level:3})},{id:`quote`,icon:`quote`,label:`Quote`,run:e=>e.chain().focus().toggleBlockquote().run(),active:e=>e.isActive(`blockquote`)}],[{id:`ul`,icon:`list`,label:`Bulleted list`,run:e=>e.chain().focus().toggleBulletList().run(),active:e=>e.isActive(`bulletList`)},{id:`ol`,icon:`list-ordered`,label:`Numbered list`,run:e=>e.chain().focus().toggleOrderedList().run(),active:e=>e.isActive(`orderedList`)}],[{id:`undo`,icon:`undo`,label:`Undo`,run:e=>e.chain().focus().undo().run()},{id:`redo`,icon:`redo`,label:`Redo`,run:e=>e.chain().focus().redo().run()}]];function T({editor:t,state:n,disabled:r,label:i,toolbarExtra:o,openLink:s,expandControl:c}){return(0,d.jsxs)(`div`,{className:`ds-rte__toolbar`,role:`toolbar`,"aria-label":`${i} formatting`,children:[w.map((i,o)=>(0,d.jsx)(a.ButtonGroup,{"aria-label":`Formatting ${o+1}`,children:i.map(i=>(0,d.jsx)(e.Button,{size:`sm`,isIconOnly:!0,iconStart:i.icon,"aria-label":i.label,title:i.label,"aria-pressed":i.active?n?.active[i.id]:void 0,variant:n?.active[i.id]?`active`:`neutral`,isDisabled:r||!t,onClick:()=>t&&i.run(t)},i.id))},o)),(0,d.jsx)(a.ButtonGroup,{"aria-label":`Link`,children:(0,d.jsx)(e.Button,{size:`sm`,isIconOnly:!0,iconStart:`link`,"aria-label":n?.linkActive?`Edit link`:`Add link`,title:n?.linkActive?`Edit link`:`Add link`,variant:n?.linkActive?`active`:`neutral`,isDisabled:r||!t,onClick:()=>t&&s(t.state,t.isActive(`link`)?t.state.selection.from:void 0)})}),o,c]})}var E=(0,l.forwardRef)(function({scopeRef:e,className:t,expansion:r,isFocused:i,disabled:a,invalid:o,contentError:s,errorId:c,surface:l,children:u},f){return(0,d.jsx)(n.s.Provider,{value:e,children:(0,d.jsxs)(`div`,{ref:f,className:[`ds-rte`,t].filter(Boolean).join(` `),style:r.frameStyle,"data-expanded":r.expanded||void 0,"data-focused":i&&!r.expanded||void 0,"data-disabled":a||void 0,"aria-invalid":o||void 0,children:[s&&(0,d.jsx)(`p`,{id:c,role:`alert`,className:`ds-field__error`,children:s}),r.expanded&&(0,d.jsx)(`p`,{className:`ds-rte__placeholder`,children:`Editing in expanded view. Press Esc to return.`}),r.surfaceSlot((0,d.jsx)(`div`,{className:`ds-rte__surface`,hidden:!!s,"data-invalid":o||void 0,children:l})),r.dialog,u]})})});function D(e,t){return t.key!==`Escape`||t.isComposing?!1:(e.someProp(`handleKeyDown`,n=>n(e,t))&&t.preventDefault(),!0)}var O=(0,l.forwardRef)(function(e,n){let{placeholder:r=`Write something…`,size:i=`md`,expandedWidth:a=`wide`,isDisabled:o=!1,isInvalid:s=!1,label:c=`Rich text editor`,className:u,toolbarExtra:m,id:h,isRequired:g,required:b,"aria-label":O,"aria-labelledby":k,"aria-describedby":A,"aria-invalid":j}=e,M=(0,l.useRef)(null),N=(0,l.useMemo)(()=>t.t(M,n),[n]),[P,F]=(0,l.useState)(!1),[I,L]=(0,l.useState)(null),R=(0,l.useCallback)(()=>L(null),[]),[z]=(0,l.useState)(()=>e.defaultValue??(e.format===`json`?v:``)),B=e.value===void 0?z:e.value,V=(0,l.useMemo)(()=>e.format===`json`?S(B):void 0,[e.format,B]),H=(0,l.useId)(),U=s||!!V||j,W=o||!!V;W&&I&&L(null);let G=(0,l.useCallback)((e,t)=>{if(W)return;let n=t===void 0?void 0:(0,f.getMarkRange)(e.doc.resolve(t),e.schema.marks.link),r=n&&e.doc.nodeAt(n.from)?.marks.find(t=>t.type===e.schema.marks.link);L({from:n?.from??e.selection.from,to:n?.to??e.selection.to,href:r?.attrs.href??``,isEditing:!!r,document:e.doc})},[W]),K=(0,l.useMemo)(()=>({role:`textbox`,...k?{}:{"aria-label":O??c},"aria-multiline":`true`,...h?{id:h}:{},...k?{"aria-labelledby":k}:{},...A?{"aria-describedby":A}:{},...U?{"aria-invalid":String(U)}:{},...g||b?{"aria-required":`true`}:{}}),[c,O,h,k,A,U,g,b]),q=(0,l.useMemo)(()=>({attributes:K,handleDOMEvents:{keydown:D,click:(e,t)=>{let n=t.target instanceof Element?t.target.closest(`a`):null;return!n||!e.dom.contains(n)?!1:(t.preventDefault(),e.editable&&G(e.state,e.posAtDOM(n,0)),!0)}}}),[K,G]),J=(0,f.useEditor)({immediatelyRender:!1,editable:!W,content:V?v:typeof B==`string`?B:x(B),extensions:[...y(),p.Placeholder.configure({placeholder:r})],editorProps:q,onFocus:()=>F(!0),onBlur:()=>F(!1),onUpdate:({editor:t})=>{W||(e.format===`json`?e.onChange?.(t.getJSON()):e.onChange?.(t.getHTML()))}});(0,l.useEffect)(()=>{J&&(J.setEditable(!W,!1),J.setOptions({editorProps:q}))},[J,W,q]),(0,l.useEffect)(()=>{if(!J||e.value===void 0||V)return;let t=typeof e.value==`string`?(0,f.createDocument)(e.value,J.schema):J.schema.nodeFromJSON(x(e.value));t.eq(J.state.doc)||J.commands.setContent(t,{emitUpdate:!1})},[J,e.value,V]);let Y=(0,f.useEditorState)({editor:J,selector:({editor:e})=>e?{active:Object.fromEntries(w.flat().map(t=>[t.id,t.active?.(e)??!1])),linkActive:e.isActive(`link`)}:null}),X=_({editor:J,disabled:W,invalid:!!U,label:O??c,labelledBy:k,expandedWidth:a,frameRef:M});return(0,d.jsx)(E,{ref:N,scopeRef:M,className:u,expansion:X,isFocused:P,disabled:W,invalid:!!U,contentError:V,errorId:H,surface:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(T,{editor:J,state:Y,disabled:W,label:c,toolbarExtra:m,openLink:G,expandControl:X.toggle}),(0,d.jsx)(`div`,{className:`ds-rte__content`,"data-size":i,children:(0,d.jsx)(f.EditorContent,{editor:J})})]}),children:J&&I&&!W&&(0,d.jsx)(C,{editor:J,selection:I,onClose:R})})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return O}});
|
|
2
|
+
//# sourceMappingURL=RichTextEditor-DcbLho2Q.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextEditor-DcbLho2Q.cjs","names":["useMovableHost","useState","useRef","useId","useCallback","cannotHoldFocus","Button","createPortal","_jsx","Modal","StarterKit","Link","getSchema","useState","useId","Modal","_Fragment","Button","Field","TextField","ButtonGroup","forwardRef","PortalScopeContext","useRef","useMemo","mergeRefs","useCallback","getMarkRange","useEditor","Placeholder","createDocument","useEditorState","EditorContent","require_components_Button_index","require_mergeRefs","require_overlayLayer","require_dialogLabel","require_useIsomorphicLayoutEffect","require_components_ButtonGroup_index","require_components_Field_index","require_components_Modal_index","require_components_TextField_index","react","react_dom","react_jsx_runtime","_tiptap_react","_tiptap_extension_placeholder","_tiptap_starter_kit","_tiptap_extension_link","revealCaretInContent","content","host","caret","editor","view","useEditorExpansion","expanded","setExpanded","inlineHeight","setInlineHeight","inlineSlotRef","expandedSlotRef","toggleRef","restoreToggle","shownExpanded","dialogId","disabled","collapse","frameRef","toggleLabel","event","surface","label","expandedWidth","invalid","labelledBy","emptyDocument","richTextExtensions","schema","normalizeDocument","document","documentError","value","check","type","node","key","mark","markType","LinkDialog","href","setHref","selection","error","setError","formId","onTransaction","onClose","canEdit","save","url","chain","field","GROUPS","EditorToolbar","i","group","tool","state","openLink","toolbarExtra","expandControl","EditorFrame","scopeRef","className","expansion","isFocused","contentError","errorId","children","releaseUnboundEscape","handle","RichTextEditor","ariaLabel","describedBy","ariaInvalid","props","mergedRef","ref","setIsFocused","linkSelection","setLinkSelection","closeLink","initialValue","isInvalid","isDisabled","range","position","link","attributes","id","isRequired","required","editorProps","anchor","e","next","size"],"sources":["../../src/components/RichTextEditor/expansion.tsx","../../src/components/RichTextEditor/document.ts","../../src/components/RichTextEditor/index.tsx"],"sourcesContent":["import {\n useCallback,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { Editor } from \"@tiptap/react\";\nimport { cannotHoldFocus, focusNearest } from \"../../internal/dialogFocus\";\nimport { moveHost, useMovableHost } from \"../../internal/movableHost\";\nimport { useIsomorphicLayoutEffect } from \"../../internal/useIsomorphicLayoutEffect\";\nimport { Button } from \"../Button\";\nimport { Modal } from \"../Modal\";\nimport type { RichTextEditorExpandedWidth } from \"./expanded-width\";\n\nexport type { RichTextEditorExpandedWidth } from \"./expanded-width\";\n\n/**\n * Moving the host resets the content's scroll position, so bring the caret\n * back into the content's own view. This scrolls only the content and needs no\n * DOM selection, so it also works when focus returns to the toggle.\n */\nfunction revealCaretInContent(editor: Editor, host: HTMLElement) {\n const content = host.querySelector<HTMLElement>(\".ds-rte__content\");\n if (!content) {\n return;\n }\n const caret = editor.view.coordsAtPos(editor.state.selection.head);\n const view = content.getBoundingClientRect();\n if (caret.top < view.top || caret.bottom > view.bottom) {\n content.scrollTop += caret.top - view.top - view.height / 2;\n }\n}\n\ninterface EditorExpansionOptions {\n editor: Editor | null;\n disabled: boolean;\n invalid: boolean;\n label: string;\n labelledBy?: string;\n expandedWidth: RichTextEditorExpandedWidth;\n frameRef: RefObject<HTMLDivElement | null>;\n}\n\n/**\n * The expanded writing view is a headerless Modal. The editor's surface renders\n * once into a movable host that sits in the inline frame or in the Modal's\n * body, so the same toolbar, content, editor instance and selection survive\n * every toggle. Modal owns the scrim, frame, dialog stack, focus trap, scroll\n * lock and Escape.\n */\nexport function useEditorExpansion({\n editor,\n disabled,\n invalid,\n label,\n labelledBy,\n expandedWidth,\n frameRef,\n}: EditorExpansionOptions) {\n const host = useMovableHost(\"ds-rte__host\");\n const [expanded, setExpanded] = useState(false);\n const [inlineHeight, setInlineHeight] = useState(0);\n const inlineSlotRef = useRef<HTMLDivElement | null>(null);\n const expandedSlotRef = useRef<HTMLDivElement | null>(null);\n const toggleRef = useRef<HTMLButtonElement | null>(null);\n const restoreToggle = useRef(false);\n const shownExpanded = useRef(false);\n const dialogId = useId();\n\n if (expanded && disabled) {\n setExpanded(false);\n }\n\n const collapse = useCallback(() => {\n restoreToggle.current = document.activeElement === toggleRef.current;\n setExpanded(false);\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n if (!host) {\n return;\n }\n moveHost(host, expanded ? expandedSlotRef.current : inlineSlotRef.current);\n // Only a change of mode hands focus and the caret across; other updates,\n // such as disabling while saving, leave the editor exactly where it is.\n if (shownExpanded.current === expanded) {\n return;\n }\n shownExpanded.current = expanded;\n // A disabled editor can't take focus. Keep it near the editor instead, in the\n // nearest focusable container such as an enclosing Drawer, not on the page.\n if (disabled || !editor) {\n if (cannotHoldFocus(document.activeElement)) {\n focusNearest(frameRef.current, { preventScroll: true });\n }\n return;\n }\n revealCaretInContent(editor, host);\n if (!expanded && restoreToggle.current) {\n // Focus decides what stays visible: the toggle, where the person left it.\n toggleRef.current?.focus();\n } else {\n // The writing surface takes focus, and the page or an enclosing panel\n // scrolls to its caret, which a growing inline editor needs on collapse.\n editor.view.focus();\n editor.commands.scrollIntoView();\n }\n restoreToggle.current = false;\n }, [host, expanded, editor, disabled, frameRef]);\n\n const toggleLabel = expanded ? \"Collapse editor\" : \"Expand editor\";\n const toggle = (\n <Button\n ref={toggleRef}\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"minimize-2\" : \"maximize-2\"}\n className=\"ds-rte__expand\"\n aria-label={toggleLabel}\n title={toggleLabel}\n aria-expanded={expanded}\n aria-controls={expanded ? dialogId : undefined}\n isDisabled={disabled || !editor || !host}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n if (expanded) {\n collapse();\n return;\n }\n setInlineHeight(frameRef.current!.getBoundingClientRect().height);\n setExpanded(true);\n }}\n />\n );\n\n /** The inline place for the surface: the host after hydration, inline markup before it. */\n const surfaceSlot = (surface: ReactNode) => (\n <div\n ref={inlineSlotRef}\n className=\"ds-rte__slot\"\n >\n {host ? createPortal(surface, host) : surface}\n </div>\n );\n\n const dialog = (\n <Modal\n id={dialogId}\n isOpen={expanded}\n onClose={collapse}\n title={label}\n hasHeader={false}\n size={expandedWidth === \"full\" ? \"full\" : \"wide\"}\n className=\"ds-rte__modal\"\n data-invalid={invalid || undefined}\n aria-labelledby={labelledBy}\n >\n <div\n ref={expandedSlotRef}\n className=\"ds-rte__expanded-slot\"\n />\n </Modal>\n );\n\n /** The inline frame keeps its measured height while the surface is away. */\n const frameStyle: CSSProperties | undefined = expanded\n ? { minBlockSize: inlineHeight }\n : undefined;\n\n return { expanded, toggle, surfaceSlot, dialog, frameStyle };\n}\n","import { getSchema, type JSONContent } from \"@tiptap/react\";\nimport { StarterKit } from \"@tiptap/starter-kit\";\nimport { Link } from \"@tiptap/extension-link\";\n\nexport type RichTextDocument = JSONContent & { type: \"doc\" };\n\nexport const emptyDocument: RichTextDocument = { type: \"doc\", content: [{ type: \"paragraph\" }] };\n\nexport function richTextExtensions() {\n return [\n StarterKit.configure({ link: false }),\n Link.configure({ openOnClick: false, autolink: true }),\n ];\n}\n\nconst schema = getSchema(richTextExtensions());\n\n/** ProseMirror represents an empty writing surface with one empty paragraph. */\nexport function normalizeDocument(document: RichTextDocument): RichTextDocument {\n return !document.content?.length ? { ...document, content: emptyDocument.content } : document;\n}\n\nexport function documentError(value: unknown): string | undefined {\n try {\n if (!value || typeof value !== \"object\" || !(\"type\" in value) || value.type !== \"doc\") {\n throw new Error();\n }\n const check = (node: JSONContent) => {\n const type = schema.nodes[node.type ?? \"\"];\n if (\n !type ||\n Object.keys(node).some(\n (key) => ![\"type\", \"attrs\", \"content\", \"marks\", \"text\"].includes(key),\n ) ||\n (node.text !== undefined && node.type !== \"text\") ||\n (node.attrs &&\n Object.keys(node.attrs).some((key) => !Object.hasOwn(type.spec.attrs ?? {}, key)))\n ) {\n throw new Error();\n }\n for (const mark of node.marks ?? []) {\n const markType = schema.marks[mark.type];\n if (\n !markType ||\n Object.keys(mark).some((key) => ![\"type\", \"attrs\"].includes(key)) ||\n Object.keys(mark.attrs ?? {}).some(\n (key) => !Object.hasOwn(markType.spec.attrs ?? {}, key),\n )\n ) {\n throw new Error();\n }\n }\n node.content?.forEach(check);\n };\n const document = value as RichTextDocument;\n check(document);\n schema.nodeFromJSON(normalizeDocument(document)).check();\n } catch {\n return \"Unsupported or invalid rich-text document.\";\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport {\n createDocument,\n EditorContent,\n getMarkRange,\n useEditor,\n useEditorState,\n type Editor,\n type EditorOptions,\n} from \"@tiptap/react\";\nimport { Placeholder } from \"@tiptap/extension-placeholder\";\nimport { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { Field } from \"../Field\";\nimport { Modal } from \"../Modal\";\nimport { TextField } from \"../TextField\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { PortalScopeContext } from \"../../internal/portalScope\";\nimport { useEditorExpansion, type RichTextEditorExpandedWidth } from \"./expansion\";\nimport {\n documentError,\n emptyDocument,\n normalizeDocument,\n richTextExtensions,\n type RichTextDocument,\n} from \"./document\";\nimport \"../Field/style.css\";\nimport type { FieldBinding } from \"../Field\";\nimport \"./style.css\";\n\nexport type RichTextEditorSize = \"sm\" | \"md\" | \"lg\";\n\nexport type { RichTextDocument } from \"./document\";\nexport type { RichTextEditorExpandedWidth } from \"./expansion\";\n\ninterface RichTextEditorCommonProps extends FieldBinding {\n placeholder?: string;\n size?: RichTextEditorSize;\n /** Expanded writing measure. `wide` caps at the shared 920px Modal width; `full` fills the viewport. */\n expandedWidth?: RichTextEditorExpandedWidth;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Accessible name for the editing surface. */\n label?: string;\n className?: string;\n /** Extra controls appended to the toolbar, e.g. a word count. */\n toolbarExtra?: ReactNode;\n isRequired?: boolean;\n}\n\nexport type RichTextEditorProps = RichTextEditorCommonProps &\n (\n | { format?: \"html\"; value?: string; defaultValue?: string; onChange?: (html: string) => void }\n | {\n format: \"json\";\n value?: RichTextDocument;\n defaultValue?: RichTextDocument;\n onChange?: (document: RichTextDocument) => void;\n }\n );\n\ninterface ToolItem {\n id: string;\n icon: IconName;\n label: string;\n run: (editor: Editor) => void;\n active?: (editor: Editor) => boolean;\n}\n\ninterface LinkSelection {\n from: number;\n to: number;\n href: string;\n isEditing: boolean;\n document: Editor[\"state\"][\"doc\"];\n}\n\nfunction LinkDialog({\n editor,\n selection,\n onClose,\n}: {\n editor: Editor;\n selection: LinkSelection;\n onClose: () => void;\n}) {\n const [href, setHref] = useState(selection.href);\n const [error, setError] = useState<string>();\n const formId = useId();\n\n useEffect(() => {\n const onTransaction = () => {\n if (!editor.state.doc.eq(selection.document)) {\n onClose();\n }\n };\n editor.on(\"transaction\", onTransaction);\n return () => {\n editor.off(\"transaction\", onTransaction);\n };\n }, [editor, selection, onClose]);\n\n const canEdit = () =>\n !editor.isDestroyed && editor.isEditable && editor.state.doc.eq(selection.document);\n const save = () => {\n if (!canEdit()) {\n onClose();\n return;\n }\n const url = href.trim();\n if (!url || !editor.can().setLink({ href: url })) {\n setError(url ? \"Enter a valid link URL.\" : \"Enter a link URL.\");\n return;\n }\n const chain = editor\n .chain()\n .focus()\n .setTextSelection({ from: selection.from, to: selection.to });\n if (selection.from === selection.to && !selection.isEditing) {\n chain\n .setLink({ href: url })\n .insertContent({ type: \"text\", text: url, marks: [{ type: \"link\", attrs: { href: url } }] })\n .run();\n } else {\n chain.setLink({ href: url }).run();\n }\n onClose();\n };\n\n return (\n <Modal\n isOpen\n title={selection.isEditing ? \"Edit link\" : \"Add link\"}\n size=\"dialog\"\n onClose={onClose}\n footer={\n <>\n {selection.isEditing && (\n <Button\n variant=\"danger\"\n onClick={() => {\n if (canEdit()) {\n editor\n .chain()\n .focus()\n .setTextSelection({ from: selection.from, to: selection.to })\n .unsetLink()\n .run();\n }\n onClose();\n }}\n >\n Remove link\n </Button>\n )}\n <Button onClick={onClose}>Cancel</Button>\n <Button\n variant=\"primary\"\n type=\"submit\"\n form={formId}\n >\n Save\n </Button>\n </>\n }\n >\n <form\n id={formId}\n noValidate\n onSubmit={(event) => {\n event.preventDefault();\n event.stopPropagation();\n save();\n }}\n >\n <Field\n label=\"URL\"\n isRequired\n error={error}\n >\n {(field) => (\n <TextField\n {...field}\n value={href}\n inputMode=\"url\"\n autoComplete=\"url\"\n placeholder=\"https://example.com\"\n onChange={(event) => {\n setHref(event.target.value);\n setError(undefined);\n }}\n />\n )}\n </Field>\n </form>\n </Modal>\n );\n}\n\nconst GROUPS: ToolItem[][] = [\n [\n {\n id: \"bold\",\n icon: \"bold\",\n label: \"Bold\",\n run: (e) => e.chain().focus().toggleBold().run(),\n active: (e) => e.isActive(\"bold\"),\n },\n {\n id: \"italic\",\n icon: \"italic\",\n label: \"Italic\",\n run: (e) => e.chain().focus().toggleItalic().run(),\n active: (e) => e.isActive(\"italic\"),\n },\n {\n id: \"strike\",\n icon: \"strikethrough\",\n label: \"Strikethrough\",\n run: (e) => e.chain().focus().toggleStrike().run(),\n active: (e) => e.isActive(\"strike\"),\n },\n {\n id: \"code\",\n icon: \"code\",\n label: \"Inline code\",\n run: (e) => e.chain().focus().toggleCode().run(),\n active: (e) => e.isActive(\"code\"),\n },\n ],\n [\n {\n id: \"h2\",\n icon: \"heading-2\",\n label: \"Heading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 2 }),\n },\n {\n id: \"h3\",\n icon: \"heading-3\",\n label: \"Subheading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 3 }),\n },\n {\n id: \"quote\",\n icon: \"quote\",\n label: \"Quote\",\n run: (e) => e.chain().focus().toggleBlockquote().run(),\n active: (e) => e.isActive(\"blockquote\"),\n },\n ],\n [\n {\n id: \"ul\",\n icon: \"list\",\n label: \"Bulleted list\",\n run: (e) => e.chain().focus().toggleBulletList().run(),\n active: (e) => e.isActive(\"bulletList\"),\n },\n {\n id: \"ol\",\n icon: \"list-ordered\",\n label: \"Numbered list\",\n run: (e) => e.chain().focus().toggleOrderedList().run(),\n active: (e) => e.isActive(\"orderedList\"),\n },\n ],\n [\n {\n id: \"undo\",\n icon: \"undo\",\n label: \"Undo\",\n run: (e) => e.chain().focus().undo().run(),\n },\n {\n id: \"redo\",\n icon: \"redo\",\n label: \"Redo\",\n run: (e) => e.chain().focus().redo().run(),\n },\n ],\n];\n\ninterface ToolbarState {\n active: Record<string, boolean>;\n linkActive: boolean;\n}\n\nfunction EditorToolbar({\n editor,\n state,\n disabled,\n label,\n toolbarExtra,\n openLink,\n expandControl,\n}: {\n editor: Editor | null;\n state: ToolbarState | null;\n disabled: boolean;\n label: string;\n toolbarExtra: ReactNode;\n openLink: (state: Editor[\"state\"], position?: number) => void;\n expandControl: ReactNode;\n}) {\n return (\n <div\n className=\"ds-rte__toolbar\"\n role=\"toolbar\"\n aria-label={`${label} formatting`}\n >\n {GROUPS.map((group, i) => (\n <ButtonGroup\n key={i}\n aria-label={`Formatting ${i + 1}`}\n >\n {group.map((tool) => (\n <Button\n key={tool.id}\n size=\"sm\"\n isIconOnly\n iconStart={tool.icon}\n aria-label={tool.label}\n title={tool.label}\n aria-pressed={tool.active ? state?.active[tool.id] : undefined}\n variant={state?.active[tool.id] ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={() => editor && tool.run(editor)}\n />\n ))}\n </ButtonGroup>\n ))}\n <ButtonGroup aria-label=\"Link\">\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"link\"\n aria-label={state?.linkActive ? \"Edit link\" : \"Add link\"}\n title={state?.linkActive ? \"Edit link\" : \"Add link\"}\n variant={state?.linkActive ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={() =>\n editor &&\n openLink(\n editor.state,\n editor.isActive(\"link\") ? editor.state.selection.from : undefined,\n )\n }\n />\n </ButtonGroup>\n {toolbarExtra}\n {expandControl}\n </div>\n );\n}\n\n/**\n * The editorial writing surface. Rich text plus links — the same field skin,\n * radius and states as `TextField`, with the toolbar inside the frame.\n */\ninterface EditorFrameProps {\n scopeRef: RefObject<HTMLDivElement | null>;\n className?: string;\n expansion: ReturnType<typeof useEditorExpansion>;\n isFocused: boolean;\n disabled: boolean;\n invalid: boolean;\n contentError?: string;\n errorId: string;\n /** Toolbar and content: rendered once, inline or in the expanded Modal. */\n surface: ReactNode;\n /** Overlays such as the link dialog. */\n children?: ReactNode;\n}\n\n/**\n * The inline frame stays the outermost element, so `className` and layout apply\n * to it. It keeps its place and height while the surface is expanded, and\n * overlays opened from the editor carry its theme, direction and language.\n */\nconst EditorFrame = forwardRef<HTMLDivElement, EditorFrameProps>(function EditorFrame(\n {\n scopeRef,\n className,\n expansion,\n isFocused,\n disabled,\n invalid,\n contentError,\n errorId,\n surface,\n children,\n },\n ref,\n) {\n return (\n <PortalScopeContext.Provider value={scopeRef}>\n <div\n ref={ref}\n className={[\"ds-rte\", className].filter(Boolean).join(\" \")}\n style={expansion.frameStyle}\n data-expanded={expansion.expanded || undefined}\n data-focused={(isFocused && !expansion.expanded) || undefined}\n data-disabled={disabled || undefined}\n aria-invalid={invalid || undefined}\n >\n {contentError && (\n <p\n id={errorId}\n role=\"alert\"\n className=\"ds-field__error\"\n >\n {contentError}\n </p>\n )}\n {expansion.expanded && (\n <p className=\"ds-rte__placeholder\">Editing in expanded view. Press Esc to return.</p>\n )}\n {expansion.surfaceSlot(\n <div\n className=\"ds-rte__surface\"\n hidden={!!contentError}\n data-invalid={invalid || undefined}\n >\n {surface}\n </div>,\n )}\n {expansion.dialog}\n {children}\n </div>\n </PortalScopeContext.Provider>\n );\n});\n\n/**\n * ProseMirror cancels every Escape, bound or not, so an enclosing Modal or\n * Drawer would never close from the writing surface. Run the editor's own key\n * bindings and leave an unbound Escape to the page. Escape that ends an IME\n * composition stays with ProseMirror.\n */\nfunction releaseUnboundEscape(view: Editor[\"view\"], event: KeyboardEvent) {\n if (event.key !== \"Escape\" || event.isComposing) {\n return false;\n }\n if (view.someProp(\"handleKeyDown\", (handle) => handle(view, event))) {\n event.preventDefault();\n }\n return true;\n}\n\nexport const RichTextEditor = forwardRef<HTMLDivElement, RichTextEditorProps>(\n function RichTextEditor(props, ref) {\n const {\n placeholder = \"Write something…\",\n size = \"md\",\n expandedWidth = \"wide\",\n isDisabled = false,\n isInvalid = false,\n label = \"Rich text editor\",\n className,\n toolbarExtra,\n id,\n isRequired,\n required,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n \"aria-invalid\": ariaInvalid,\n } = props;\n const frameRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(frameRef, ref), [ref]);\n const [isFocused, setIsFocused] = useState(false);\n const [linkSelection, setLinkSelection] = useState<LinkSelection | null>(null);\n const closeLink = useCallback(() => setLinkSelection(null), []);\n const [initialValue] = useState(\n () => props.defaultValue ?? (props.format === \"json\" ? emptyDocument : \"\"),\n );\n const content = props.value !== undefined ? props.value : initialValue;\n const contentError = useMemo(\n () => (props.format === \"json\" ? documentError(content) : undefined),\n [props.format, content],\n );\n const errorId = useId();\n const invalid = isInvalid || !!contentError || ariaInvalid;\n const disabled = isDisabled || !!contentError;\n if (disabled && linkSelection) {\n setLinkSelection(null);\n }\n const openLink = useCallback(\n (state: Editor[\"state\"], position?: number) => {\n if (disabled) {\n return;\n }\n const range =\n position === undefined\n ? undefined\n : getMarkRange(state.doc.resolve(position), state.schema.marks.link);\n const link =\n range &&\n state.doc.nodeAt(range.from)?.marks.find((mark) => mark.type === state.schema.marks.link);\n setLinkSelection({\n from: range?.from ?? state.selection.from,\n to: range?.to ?? state.selection.to,\n href: link?.attrs.href ?? \"\",\n isEditing: !!link,\n document: state.doc,\n });\n },\n [disabled],\n );\n const attributes = useMemo(\n () => ({\n role: \"textbox\",\n ...(!labelledBy ? { \"aria-label\": ariaLabel ?? label } : {}),\n \"aria-multiline\": \"true\",\n ...(id ? { id } : {}),\n ...(labelledBy ? { \"aria-labelledby\": labelledBy } : {}),\n ...(describedBy ? { \"aria-describedby\": describedBy } : {}),\n ...(invalid ? { \"aria-invalid\": String(invalid) } : {}),\n ...(isRequired || required ? { \"aria-required\": \"true\" } : {}),\n }),\n [label, ariaLabel, id, labelledBy, describedBy, invalid, isRequired, required],\n );\n const editorProps = useMemo<EditorOptions[\"editorProps\"]>(\n () => ({\n attributes,\n handleDOMEvents: {\n keydown: releaseUnboundEscape,\n click: (view, event) => {\n const anchor = event.target instanceof Element ? event.target.closest(\"a\") : null;\n if (!anchor || !view.dom.contains(anchor)) {\n return false;\n }\n event.preventDefault();\n if (view.editable) {\n openLink(view.state, view.posAtDOM(anchor, 0));\n }\n return true;\n },\n },\n }),\n [attributes, openLink],\n );\n\n const editor = useEditor({\n immediatelyRender: false,\n editable: !disabled,\n content: contentError\n ? emptyDocument\n : typeof content === \"string\"\n ? content\n : normalizeDocument(content),\n extensions: [...richTextExtensions(), Placeholder.configure({ placeholder })],\n editorProps,\n onFocus: () => setIsFocused(true),\n onBlur: () => setIsFocused(false),\n onUpdate: ({ editor: e }) => {\n if (disabled) {\n return;\n }\n if (props.format === \"json\") {\n props.onChange?.(e.getJSON() as RichTextDocument);\n } else {\n props.onChange?.(e.getHTML());\n }\n },\n });\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n editor.setEditable(!disabled, false);\n editor.setOptions({ editorProps });\n }, [editor, disabled, editorProps]);\n\n useEffect(() => {\n if (!editor || props.value === undefined || contentError) {\n return;\n }\n const next =\n typeof props.value === \"string\"\n ? createDocument(props.value, editor.schema)\n : editor.schema.nodeFromJSON(normalizeDocument(props.value));\n // Parent echoes should preserve the current selection and undo history.\n if (!next.eq(editor.state.doc)) {\n editor.commands.setContent(next, { emitUpdate: false });\n }\n }, [editor, props.value, contentError]);\n\n const state = useEditorState({\n editor,\n selector: ({ editor: e }) =>\n e\n ? {\n active: Object.fromEntries(GROUPS.flat().map((t) => [t.id, t.active?.(e) ?? false])),\n linkActive: e.isActive(\"link\"),\n }\n : null,\n });\n\n const expansion = useEditorExpansion({\n editor,\n disabled,\n invalid: !!invalid,\n label: ariaLabel ?? label,\n labelledBy,\n expandedWidth,\n frameRef,\n });\n\n return (\n <EditorFrame\n ref={mergedRef}\n scopeRef={frameRef}\n className={className}\n expansion={expansion}\n isFocused={isFocused}\n disabled={disabled}\n invalid={!!invalid}\n contentError={contentError}\n errorId={errorId}\n surface={\n <>\n <EditorToolbar\n editor={editor}\n state={state}\n disabled={disabled}\n label={label}\n toolbarExtra={toolbarExtra}\n openLink={openLink}\n expandControl={expansion.toggle}\n />\n <div\n className=\"ds-rte__content\"\n data-size={size}\n >\n <EditorContent editor={editor} />\n </div>\n </>\n }\n >\n {editor && linkSelection && !disabled && (\n <LinkDialog\n editor={editor}\n selection={linkSelection}\n onClose={closeLink}\n />\n )}\n </EditorFrame>\n );\n },\n);\n"],"mappings":"A,mpBAyBA,SAASiD,EAAqB,EAAgB,EAAmB,CAC/D,IAAMC,EAAUC,EAAK,cAA2B,kBAAkB,EAClE,GAAI,CAACD,EACH,OAEF,IAAME,EAAQC,EAAO,KAAK,YAAYA,EAAO,MAAM,UAAU,IAAI,EAC3DC,EAAOJ,EAA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EFn.cjs"),t=require("./isComposing-BrBcAANm.cjs");let n=require("react");function r(e,t={}){if(typeof document>`u`)return null;let n=document.createElement(`div`);return n.className=e,Object.assign(n.style,t),n}var i=()=>()=>{};function a(e,t){let[a]=(0,n.useState)(()=>r(e,t)),o=(0,n.useSyncExternalStore)(i,()=>!0,()=>!1);return(0,n.useInsertionEffect)(()=>()=>a?.remove(),[a]),o?a:null}function o(e,t,n=null){return t?e.parentNode!==t&&(s(e,t,null,n),!0):(e.remove(),!1)}function s(t,n,r,i=null){let a=document.activeElement,o=a&&t.contains(a)?a:i,s=o instanceof HTMLElement&&t.contains(o)&&(o===a||e.d(a));n.insertBefore(t,r),s&&o.focus({preventScroll:!0})}var c=new WeakMap;function l(e,t,n){let r=Array.from(t.children).filter(t=>t!==e&&c.has(t)),i=e=>(c.get(e)??0)>n;return{inPlace:e.parentNode===t&&r.every(t=>i(t)===!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)),before:r.find(i)??null}}function u(e,t,r){let[i,o]=(0,n.useState)(e??0);e!==void 0&&e!==i&&o(e);let u=a(`ds-dialog-host`,{display:`contents`});return(0,n.useInsertionEffect)(()=>{if(!u)return;if(!t){u.remove();return}c.set(u,i);let e=r??document.body,{inPlace:n,before:a}=l(u,e,i);n||s(u,e,a)},[u,i,t,r]),u}var d=new Set,f=0;function p(){return f+=1,f}function m(e,t){let n={layer:e,order:t};return d.add(n),{isTopmost:()=>{for(let n of d)if(n.layer>e||n.layer===e&&n.order>t)return!1;return d.has(n)},close:()=>{d.delete(n)}}}var h=0,g={overflow:``,paddingRight:``};function _(){let{body:e,documentElement:t}=document;if(h===0){g={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`}}h+=1;let n=!1;return()=>{n||(n=!0,--h,!(h>0)&&(e.style.overflow=g.overflow,e.style.paddingRight=g.paddingRight))}}function v(e,t){for(let n=t.parentElement;n&&e.contains(n);n=n.parentElement)if(n.scrollHeight>n.clientHeight){let e=n.getBoundingClientRect(),r=t.getBoundingClientRect();r.top<e.top?n.scrollTop-=e.top-r.top:r.bottom>e.bottom&&(n.scrollTop+=Math.min(r.bottom-e.bottom,r.top-e.top))}}function y(t,n,r,i){n&&t.contains(n)&&!e.d(n)&&n.focus({preventScroll:!0}),n&&document.activeElement===n?v(t,n):e.p(t,document.activeElement)||(r?.()??e.h(t)[0]??t).focus(i)}function b({isOpen:r,isActive:i=!0,layer:a=60,panelRef:o,onClose:s,initialFocus:c,preventScroll:l=!1,container:u}){let d=e.u({onClose:s,initialFocus:c}),[f,h]=(0,n.useState)(null),g=(0,n.useRef)(null);return f!==null!==r&&h(r?{opener:typeof document>`u`?null:document.activeElement,order:p()}:null),(0,n.useEffect)(()=>{if(!r||!i||!f)return;let n={preventScroll:l},s=o.current,c=m(a,f.order),u=e=>{e instanceof HTMLElement&&(g.current={order:f.order,element:e})},p=({target:e})=>u(e);s?.addEventListener(`focusin`,p);let h=document.activeElement;if(c.isTopmost()&&s&&!e.p(s,h)){let e=g.current;y(s,e?.order===f.order?e.element:void 0,d.current.initialFocus,n)}else s?.contains(h)&&u(h);let v=n=>{if(c.isTopmost()){if(n.key===`Escape`){if(n.defaultPrevented||t.t(n))return;n.preventDefault(),d.current.onClose()}else e.g(n,o.current)}};window.addEventListener(`keydown`,v);let b=_();return()=>{s?.removeEventListener(`focusin`,p),window.removeEventListener(`keydown`,v),c.close(),b(),e.d(document.activeElement)&&e.f(f.opener,n)}},[r,i,a,f,o,l,u,d]),{onScrimMouseDown:e=>{r&&i&&e.target===e.currentTarget&&(e.preventDefault(),d.current.onClose())},order:f?.order}}function x(e,t,n,r,i){return{role:`dialog`,"aria-modal":i||void 0,"aria-hidden":!i||e[`aria-hidden`],"aria-labelledby":e[`aria-label`]?void 0:e[`aria-labelledby`]??t,"aria-describedby":r?n:e[`aria-describedby`]}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
|
|
2
|
+
//# sourceMappingURL=dialogLabel-2HRYMHbF.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialogLabel-3EeaH1Zl.cjs","names":["useState","useSyncExternalStore","cannotHoldFocus","useState","cannotHoldFocus","panelHoldsFocus","tabbableControls","useLatest","useState","useRef","isComposing","require_overlayLayer","require_isComposing","react","createMovableHost","host","className","style","subscribe","useMovableHost","hydrated","moveHost","slot","insertHost","lastFocused","active","focused","refocus","before","ranks","placement","others","parent","child","isLater","other","rank","useDialogPortal","setRank","order","isPresent","container","inPlace","stack","openings","nextDialogOrder","openDialog","entry","layer","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","revealInPanel","area","control","panel","view","box","focusPanel","initialFocus","options","useModalDialog","latest","opening","setOpening","isOpen","isActive","focusOptions","panelRef","dialog","remember","element","rememberFocus","target","onKeyDown","event","unlockScroll","preventScroll","dialogAttributes","props","titleId","hasDescription","descriptionId"],"sources":["../../src/internal/movableHost.ts","../../src/internal/useDialogPortal.ts","../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts","../../src/internal/dialogLabel.ts"],"sourcesContent":["import { useInsertionEffect, 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, style: Partial<CSSStyleDeclaration> = {}) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n Object.assign(host.style, style);\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, style?: Partial<CSSStyleDeclaration>) {\n const [host] = useState(() => createMovableHost(className, style));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n // An insertion effect, which Strict Mode never replays: replaying a passive\n // cleanup would detach a host that an insertion effect placed.\n useInsertionEffect(() => () => 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. 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 insertHost(host, slot, null, lastFocused);\n return true;\n}\n\n/**\n * Inserts `host` into `slot` before `before`, or at its end. Moving drops focus,\n * so the element inside the host that had it (or `lastFocused`, when an earlier\n * removal already dropped it) gets it back.\n */\nexport function insertHost(\n host: HTMLElement,\n slot: Element,\n before: Node | null,\n lastFocused: Element | null = null,\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.insertBefore(host, before);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n}\n","import { useInsertionEffect, useState } from \"react\";\nimport { insertHost, useMovableHost } from \"./movableHost\";\n\n/** The opening order of each dialog's portal host. */\nconst ranks = new WeakMap<Element, number>();\n\n/**\n * Where `host` belongs among the other dialog hosts in `parent`: before the\n * first one opened later. It is in place when every host opened earlier comes\n * before it and every one opened later after it, whatever else lies between.\n */\nfunction placement(host: Element, parent: Element, rank: number) {\n const others = Array.from(parent.children).filter((child) => child !== host && ranks.has(child));\n const isLater = (other: Element) => (ranks.get(other) ?? 0) > rank;\n const inPlace =\n host.parentNode === parent &&\n others.every(\n (other) =>\n isLater(other) ===\n Boolean(host.compareDocumentPosition(other) & Node.DOCUMENT_POSITION_FOLLOWING),\n );\n return { inPlace, before: others.find(isLater) ?? null };\n}\n\n/**\n * A portal host that paints dialogs in opening order, as the dialog stack ranks\n * them, including a nested dialog that opens in the same commit as its parent\n * (React inserts that one's portal first). The host moves only when its order\n * is wrong, keeping focus, so a reopened dialog keeps its scroll and focus.\n * Null on the server and while hydrating.\n */\nexport function useDialogPortal(\n order: number | undefined,\n isPresent: boolean,\n container?: HTMLElement | null,\n) {\n // Kept through a closing transition, when the dialog no longer has an order.\n const [rank, setRank] = useState(order ?? 0);\n if (order !== undefined && order !== rank) {\n setRank(order);\n }\n // Contents only, so a contained drawer's container lays out the frame itself.\n const host = useMovableHost(\"ds-dialog-host\", { display: \"contents\" });\n // Before layout effects, so content measures and focuses inside the document.\n useInsertionEffect(() => {\n if (!host) {\n return;\n }\n if (!isPresent) {\n host.remove();\n return;\n }\n ranks.set(host, rank);\n const parent = container ?? document.body;\n const { inPlace, before } = placement(host, parent, rank);\n if (!inPlace) {\n insertHost(host, parent, before);\n }\n }, [host, rank, isPresent, container]);\n return host;\n}\n","interface Entry {\n layer: number;\n order: number;\n}\nconst stack = new Set<Entry>();\nlet openings = 0;\n\n/**\n * A dialog's place among those on its layer, taken as it opens and kept while\n * it is suspended. Taken during render, where a dialog renders before the ones\n * nested in it, so nested dialogs that open with it still come after it.\n */\nexport function nextDialogOrder() {\n openings += 1;\n return openings;\n}\n\n/**\n * Register an open modal dialog; only the topmost one handles keys. A higher\n * layer wins, then the later opening, matching paint order: portals append as\n * dialogs open. A dialog resuming from suspension keeps its opening order, so\n * it never jumps above dialogs opened while it was suspended.\n */\nexport function openDialog(layer: number, order: number) {\n const entry: Entry = { layer, order };\n stack.add(entry);\n return {\n isTopmost: () => {\n for (const other of stack) {\n if (other.layer > layer || (other.layer === layer && other.order > order)) {\n return false;\n }\n }\n return stack.has(entry);\n },\n close: () => {\n stack.delete(entry);\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 { nextDialogOrder, openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport {\n cannotHoldFocus,\n focusNearest,\n panelHoldsFocus,\n tabbableControls,\n trapTabFocus,\n} from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\nimport { useLatest } from \"./useLatest\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n /** An inactive open dialog stays mounted but leaves keys, focus and scrim presses to others. */\n isActive?: boolean;\n layer?: number;\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\ninterface Opening {\n opener: Element | null;\n order: number;\n}\n\n/** Scroll the panel's own scroll areas, never the page or the panel's host, until `control` shows. */\nfunction revealInPanel(panel: HTMLElement, control: HTMLElement) {\n for (let area = control.parentElement; area && panel.contains(area); area = area.parentElement) {\n if (area.scrollHeight > area.clientHeight) {\n const view = area.getBoundingClientRect();\n const box = control.getBoundingClientRect();\n if (box.top < view.top) {\n area.scrollTop -= view.top - box.top;\n } else if (box.bottom > view.bottom) {\n area.scrollTop += Math.min(box.bottom - view.bottom, box.top - view.top);\n }\n }\n }\n}\n\n/**\n * Return to the control focused last in this opening, else to the initial\n * focus. Hiding a panel resets its scroll, so a restored control is brought\n * into view within the panel, leaving the page where it is.\n */\nfunction focusPanel(\n panel: HTMLElement,\n previous: HTMLElement | undefined,\n initialFocus: ModalDialogOptions[\"initialFocus\"],\n options: FocusOptions,\n) {\n if (previous && panel.contains(previous) && !cannotHoldFocus(previous)) {\n previous.focus({ preventScroll: true });\n }\n if (previous && document.activeElement === previous) {\n revealInPanel(panel, previous);\n } else if (!panelHoldsFocus(panel, document.activeElement)) {\n (initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(options);\n }\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 isActive = true,\n layer = 60,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useLatest({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus\n // inside it, and before the dialogs nested in it render.\n const [opening, setOpening] = useState<Opening | null>(null);\n const lastFocused = useRef<{ order: number; element: HTMLElement } | null>(null);\n if ((opening !== null) !== isOpen) {\n setOpening(\n isOpen\n ? {\n opener: typeof document === \"undefined\" ? null : document.activeElement,\n order: nextDialogOrder(),\n }\n : null,\n );\n }\n\n useEffect(() => {\n if (!isOpen || !isActive || !opening) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n const dialog = openDialog(layer, opening.order);\n // Remembered per opening, so a new opening starts from its initial focus.\n const remember = (element: EventTarget | null) => {\n if (element instanceof HTMLElement) {\n lastFocused.current = { order: opening.order, element };\n }\n };\n const rememberFocus = ({ target }: FocusEvent) => remember(target);\n panel?.addEventListener(\"focusin\", rememberFocus);\n const active = document.activeElement;\n // Leave focus that autoFocus, the caller, or a popup resuming inside the\n // panel (its effects run first) already placed there.\n if (dialog.isTopmost() && panel && !panelHoldsFocus(panel, active)) {\n const previous = lastFocused.current;\n focusPanel(\n panel,\n previous?.order === opening.order ? previous.element : undefined,\n latest.current.initialFocus,\n focusOptions,\n );\n } else if (panel?.contains(active)) {\n // Focus placed before the listener was attached.\n remember(active);\n }\n\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 panel?.removeEventListener(\"focusin\", rememberFocus);\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(opening.opener, focusOptions);\n }\n };\n }, [isOpen, isActive, layer, opening, panelRef, preventScroll, container, latest]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && isActive && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown, order: opening?.order };\n}\n","import type { AriaAttributes } from \"react\";\n\n/** Keep naming and visibility consistent across dialog frames, including suspended panels. */\nexport function dialogAttributes(\n props: AriaAttributes,\n titleId: string,\n descriptionId: string,\n hasDescription: boolean,\n active: boolean,\n) {\n return {\n role: \"dialog\" as const,\n \"aria-modal\": active || undefined,\n \"aria-hidden\": active ? props[\"aria-hidden\"] : true,\n \"aria-labelledby\": props[\"aria-label\"] ? undefined : (props[\"aria-labelledby\"] ?? titleId),\n \"aria-describedby\": hasDescription ? descriptionId : props[\"aria-describedby\"],\n };\n}\n"],"mappings":"A,8GAOA,SAAgBc,EAAkB,EAAmB,EAAsC,CAAC,EAAG,CAC7F,GAAI,OAAO,SAAa,IACtB,OAAO,KAET,IAAMC,EAAO,SAAS,cAAc,KAAK,EAGzC,MAFA,GAAK,UAAYC,EACjB,OAAO,OAAOD,EAAK,MAAOE,CAAK,EACxBF,CACT,CAEA,IAAMG,UAAwB,CAAC,EAO/B,SAAgBC,EAAe,EAAmB,EAAsC,CACtF,GAAM,CAACJ,IAAA,EAAQf,EAAAA,SAAAA,KAAec,EAAkBE,EAAWC,CAAK,CAAC,EAC3DG,GAAA,EAAWnB,EAAAA,qBAAAA,CACfiB,MACM,OACA,EACR,EAIA,OADA,EAAAL,EAAA,mBAAA,SAA+BE,GAAM,OAAO,EAAG,CAACA,CAAI,CAAC,EAC9CK,EAAWL,EAAO,IAC3B,CAOA,SAAgBM,EACd,EACA,EACA,EAA8B,KAC9B,CASA,OARKC,EAIDP,EAAK,aAAeO,IAGxBC,EAAWR,EAAMO,EAAM,KAAME,CAAW,EACjC,KAPLT,EAAK,OAAO,EACL,GAOX,CAOA,SAAgBQ,EACd,EACA,EACA,EACA,EAA8B,KAC9B,CACA,IAAME,EAAS,SAAS,cAClBC,EAAUD,GAAUV,EAAK,SAASU,CAAM,EAAIA,EAASD,EACrDG,EACJD,aAAmB,aACnBX,EAAK,SAASW,CAAO,IACpBA,IAAYD,GAAUvB,EAAAA,EAAgBuB,CAAM,GAC/CH,EAAK,aAAaP,EAAMa,C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HoldFocus","useState","cannotHoldFocus","panelHoldsFocus","tabbableControls","useLatest","useState","useRef","isComposing","require_overlayLayer","require_isComposing","react","createMovableHost","host","className","style","subscribe","useMovableHost","hydrated","moveHost","slot","insertHost","lastFocused","active","focused","refocus","before","ranks","placement","others","parent","child","isLater","other","rank","useDialogPortal","setRank","order","isPresent","container","inPlace","stack","openings","nextDialogOrder","openDialog","entry","layer","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","revealInPanel","area","control","panel","view","box","focusPanel","initialFocus","options","useModalDialog","latest","opening","setOpening","isOpen","isActive","focusOptions","panelRef","dialog","remember","element","rememberFocus","target","onKeyDown","event","unlockScroll","preventScroll","dialogAttributes","props","titleId","hasDescription","descriptionId"],"sources":["../../src/internal/movableHost.ts","../../src/internal/useDialogPortal.ts","../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts","../../src/internal/dialogLabel.ts"],"sourcesContent":["import { useInsertionEffect, 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, style: Partial<CSSStyleDeclaration> = {}) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n Object.assign(host.style, style);\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, style?: Partial<CSSStyleDeclaration>) {\n const [host] = useState(() => createMovableHost(className, style));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n // An insertion effect, which Strict Mode never replays: replaying a passive\n // cleanup would detach a host that an insertion effect placed.\n useInsertionEffect(() => () => 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. 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 insertHost(host, slot, null, lastFocused);\n return true;\n}\n\n/**\n * Inserts `host` into `slot` before `before`, or at its end. Moving drops focus,\n * so the element inside the host that had it (or `lastFocused`, when an earlier\n * removal already dropped it) gets it back.\n */\nexport function insertHost(\n host: HTMLElement,\n slot: Element,\n before: Node | null,\n lastFocused: Element | null = null,\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.insertBefore(host, before);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n}\n","import { useInsertionEffect, useState } from \"react\";\nimport { insertHost, useMovableHost } from \"./movableHost\";\n\n/** The opening order of each dialog's portal host. */\nconst ranks = new WeakMap<Element, number>();\n\n/**\n * Where `host` belongs among the other dialog hosts in `parent`: before the\n * first one opened later. It is in place when every host opened earlier comes\n * before it and every one opened later after it, whatever else lies between.\n */\nfunction placement(host: Element, parent: Element, rank: number) {\n const others = Array.from(parent.children).filter((child) => child !== host && ranks.has(child));\n const isLater = (other: Element) => (ranks.get(other) ?? 0) > rank;\n const inPlace =\n host.parentNode === parent &&\n others.every(\n (other) =>\n isLater(other) ===\n Boolean(host.compareDocumentPosition(other) & Node.DOCUMENT_POSITION_FOLLOWING),\n );\n return { inPlace, before: others.find(isLater) ?? null };\n}\n\n/**\n * A portal host that paints dialogs in opening order, as the dialog stack ranks\n * them, including a nested dialog that opens in the same commit as its parent\n * (React inserts that one's portal first). The host moves only when its order\n * is wrong, keeping focus, so a reopened dialog keeps its scroll and focus.\n * Null on the server and while hydrating.\n */\nexport function useDialogPortal(\n order: number | undefined,\n isPresent: boolean,\n container?: HTMLElement | null,\n) {\n // Kept through a closing transition, when the dialog no longer has an order.\n const [rank, setRank] = useState(order ?? 0);\n if (order !== undefined && order !== rank) {\n setRank(order);\n }\n // Contents only, so a contained drawer's container lays out the frame itself.\n const host = useMovableHost(\"ds-dialog-host\", { display: \"contents\" });\n // Before layout effects, so content measures and focuses inside the document.\n useInsertionEffect(() => {\n if (!host) {\n return;\n }\n if (!isPresent) {\n host.remove();\n return;\n }\n ranks.set(host, rank);\n const parent = container ?? document.body;\n const { inPlace, before } = placement(host, parent, rank);\n if (!inPlace) {\n insertHost(host, parent, before);\n }\n }, [host, rank, isPresent, container]);\n return host;\n}\n","interface Entry {\n layer: number;\n order: number;\n}\nconst stack = new Set<Entry>();\nlet openings = 0;\n\n/**\n * A dialog's place among those on its layer, taken as it opens and kept while\n * it is suspended. Taken during render, where a dialog renders before the ones\n * nested in it, so nested dialogs that open with it still come after it.\n */\nexport function nextDialogOrder() {\n openings += 1;\n return openings;\n}\n\n/**\n * Register an open modal dialog; only the topmost one handles keys. A higher\n * layer wins, then the later opening, matching paint order: portals append as\n * dialogs open. A dialog resuming from suspension keeps its opening order, so\n * it never jumps above dialogs opened while it was suspended.\n */\nexport function openDialog(layer: number, order: number) {\n const entry: Entry = { layer, order };\n stack.add(entry);\n return {\n isTopmost: () => {\n for (const other of stack) {\n if (other.layer > layer || (other.layer === layer && other.order > order)) {\n return false;\n }\n }\n return stack.has(entry);\n },\n close: () => {\n stack.delete(entry);\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 { nextDialogOrder, openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport {\n cannotHoldFocus,\n focusNearest,\n panelHoldsFocus,\n tabbableControls,\n trapTabFocus,\n} from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\nimport { useLatest } from \"./useLatest\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n /** An inactive open dialog stays mounted but leaves keys, focus and scrim presses to others. */\n isActive?: boolean;\n layer?: number;\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\ninterface Opening {\n opener: Element | null;\n order: number;\n}\n\n/** Scroll the panel's own scroll areas, never the page or the panel's host, until `control` shows. */\nfunction revealInPanel(panel: HTMLElement, control: HTMLElement) {\n for (let area = control.parentElement; area && panel.contains(area); area = area.parentElement) {\n if (area.scrollHeight > area.clientHeight) {\n const view = area.getBoundingClientRect();\n const box = control.getBoundingClientRect();\n if (box.top < view.top) {\n area.scrollTop -= view.top - box.top;\n } else if (box.bottom > view.bottom) {\n area.scrollTop += Math.min(box.bottom - view.bottom, box.top - view.top);\n }\n }\n }\n}\n\n/**\n * Return to the control focused last in this opening, else to the initial\n * focus. A suspended panel stays laid out, so its scroll areas keep their\n * positions; a restored control is still brought into view within the panel,\n * in case its content moved, leaving the page where it is.\n */\nfunction focusPanel(\n panel: HTMLElement,\n previous: HTMLElement | undefined,\n initialFocus: ModalDialogOptions[\"initialFocus\"],\n options: FocusOptions,\n) {\n if (previous && panel.contains(previous) && !cannotHoldFocus(previous)) {\n previous.focus({ preventScroll: true });\n }\n if (previous && document.activeElement === previous) {\n revealInPanel(panel, previous);\n } else if (!panelHoldsFocus(panel, document.activeElement)) {\n (initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(options);\n }\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 isActive = true,\n layer = 60,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useLatest({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus\n // inside it, and before the dialogs nested in it render.\n const [opening, setOpening] = useState<Opening | null>(null);\n const lastFocused = useRef<{ order: number; element: HTMLElement } | null>(null);\n if ((opening !== null) !== isOpen) {\n setOpening(\n isOpen\n ? {\n opener: typeof document === \"undefined\" ? null : document.activeElement,\n order: nextDialogOrder(),\n }\n : null,\n );\n }\n\n useEffect(() => {\n if (!isOpen || !isActive || !opening) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n const dialog = openDialog(layer, opening.order);\n // Remembered per opening, so a new opening starts from its initial focus.\n const remember = (element: EventTarget | null) => {\n if (element instanceof HTMLElement) {\n lastFocused.current = { order: opening.order, element };\n }\n };\n const rememberFocus = ({ target }: FocusEvent) => remember(target);\n panel?.addEventListener(\"focusin\", rememberFocus);\n const active = document.activeElement;\n // Leave focus that autoFocus, the caller, or a popup resuming inside the\n // panel (its effects run first) already placed there.\n if (dialog.isTopmost() && panel && !panelHoldsFocus(panel, active)) {\n const previous = lastFocused.current;\n focusPanel(\n panel,\n previous?.order === opening.order ? previous.element : undefined,\n latest.current.initialFocus,\n focusOptions,\n );\n } else if (panel?.contains(active)) {\n // Focus placed before the listener was attached.\n remember(active);\n }\n\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 panel?.removeEventListener(\"focusin\", rememberFocus);\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(opening.opener, focusOptions);\n }\n };\n }, [isOpen, isActive, layer, opening, panelRef, preventScroll, container, latest]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && isActive && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown, order: opening?.order };\n}\n","import type { AriaAttributes } from \"react\";\n\n/** Keep naming and visibility consistent across dialog frames, including suspended panels. */\nexport function dialogAttributes(\n props: AriaAttributes,\n titleId: string,\n descriptionId: string,\n hasDescription: boolean,\n active: boolean,\n) {\n return {\n role: \"dialog\" as const,\n \"aria-modal\": active || undefined,\n \"aria-hidden\": active ? props[\"aria-hidden\"] : true,\n \"aria-labelledby\": props[\"aria-label\"] ? undefined : (props[\"aria-labelledby\"] ?? titleId),\n \"aria-describedby\": hasDescription ? descriptionId : props[\"aria-describedby\"],\n };\n}\n"],"mappings":"A,8GAOA,SAAgBc,EAAkB,EAAmB,EAAsC,CAAC,EAAG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,MACAzD,EAAA,EAAasE,EAAOP,EAAS,OAAO,CADpC,CAEF,EAEA,OAAO,iBAAiB,UAAWM,CAAS,EAC5C,IAAME,EAAe/B,EAAe,EAEpC,UAAa,CACXU,GAAO,oBAAoB,UAAWiB,CAAa,EACnD,OAAO,oBAAoB,UAAWE,CAAS,EAC/CL,EAAO,MAAM,EACbO,EAAa,EAET9E,EAAAA,EAAgB,SAAS,aAAa,GACxCO,EAAA,EAAa0D,EAAQ,OAAQI,CAAY,CAE7C,CACF,EAAG,CAACF,EAAQC,EAAUxB,EAAOqB,EAASK,EAAUS,EAAe1C,EAAW2B,CAAM,CAAC,EAS1E,CAAE,iBANiB,GAAsB,CAC1CG,GAAUC,GAAYS,EAAM,SAAWA,EAAM,gBAC/CA,EAAM,eAAe,EACrBb,EAAO,QAAQ,QAAQ,EAE3B,EAC2B,MAAOC,GAAS,KAAM,CACnD,CC1KA,SAAgBe,EACd,EACA,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,KAAM,SACN,aAAc3D,GAAU,IAAA,GACxB,cAAe,IAAS4D,EAAM,eAC9B,kBAAmBA,EAAM,cAAgB,IAAA,GAAaA,EAAM,oBAAsBC,EAClF,mBAAoBC,EAAiBC,EAAgBH,EAAM,mBAC7D,CACF,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as e, f as t, g as n, h as r, p as i, u as a } from "./overlayLayer-
|
|
1
|
+
import { d as e, f as t, g as n, h as r, p as i, u as a } from "./overlayLayer-IuoPVwTO.js";
|
|
2
2
|
import { t as o } from "./isComposing-8bRWyiLF.js";
|
|
3
3
|
import { useEffect as s, useInsertionEffect as c, useRef as l, useState as u, useSyncExternalStore as d } from "react";
|
|
4
4
|
//#region src/internal/movableHost.ts
|
|
@@ -173,4 +173,4 @@ function A(e, t, n, r, i) {
|
|
|
173
173
|
//#endregion
|
|
174
174
|
export { h as a, f as i, k as n, m as o, y as r, A as t };
|
|
175
175
|
|
|
176
|
-
//# sourceMappingURL=dialogLabel-
|
|
176
|
+
//# sourceMappingURL=dialogLabel-D18maX-p.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialogLabel-BjtTix5C.js","names":["cannotHoldFocus","focusNearest","trapTabFocus","tabbableControls","panelHoldsFocus","useLatest","isComposing","createMovableHost","host","className","style","subscribe","useMovableHost","useState","hydrated","useSyncExternalStore","useInsertionEffect","moveHost","slot","insertHost","lastFocused","active","focused","refocus","before","ranks","placement","others","parent","child","isLater","other","rank","useDialogPortal","setRank","order","isPresent","container","inPlace","stack","openings","nextDialogOrder","openDialog","entry","layer","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","revealInPanel","area","control","panel","view","box","focusPanel","initialFocus","options","useModalDialog","latest","opening","setOpening","useRef","isOpen","useEffect","isActive","focusOptions","panelRef","dialog","remember","element","rememberFocus","target","onKeyDown","event","unlockScroll","preventScroll","dialogAttributes","props","titleId","hasDescription","descriptionId"],"sources":["../../src/internal/movableHost.ts","../../src/internal/useDialogPortal.ts","../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts","../../src/internal/dialogLabel.ts"],"sourcesContent":["import { useInsertionEffect, 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, style: Partial<CSSStyleDeclaration> = {}) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n Object.assign(host.style, style);\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, style?: Partial<CSSStyleDeclaration>) {\n const [host] = useState(() => createMovableHost(className, style));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n // An insertion effect, which Strict Mode never replays: replaying a passive\n // cleanup would detach a host that an insertion effect placed.\n useInsertionEffect(() => () => 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. 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 insertHost(host, slot, null, lastFocused);\n return true;\n}\n\n/**\n * Inserts `host` into `slot` before `before`, or at its end. Moving drops focus,\n * so the element inside the host that had it (or `lastFocused`, when an earlier\n * removal already dropped it) gets it back.\n */\nexport function insertHost(\n host: HTMLElement,\n slot: Element,\n before: Node | null,\n lastFocused: Element | null = null,\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.insertBefore(host, before);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n}\n","import { useInsertionEffect, useState } from \"react\";\nimport { insertHost, useMovableHost } from \"./movableHost\";\n\n/** The opening order of each dialog's portal host. */\nconst ranks = new WeakMap<Element, number>();\n\n/**\n * Where `host` belongs among the other dialog hosts in `parent`: before the\n * first one opened later. It is in place when every host opened earlier comes\n * before it and every one opened later after it, whatever else lies between.\n */\nfunction placement(host: Element, parent: Element, rank: number) {\n const others = Array.from(parent.children).filter((child) => child !== host && ranks.has(child));\n const isLater = (other: Element) => (ranks.get(other) ?? 0) > rank;\n const inPlace =\n host.parentNode === parent &&\n others.every(\n (other) =>\n isLater(other) ===\n Boolean(host.compareDocumentPosition(other) & Node.DOCUMENT_POSITION_FOLLOWING),\n );\n return { inPlace, before: others.find(isLater) ?? null };\n}\n\n/**\n * A portal host that paints dialogs in opening order, as the dialog stack ranks\n * them, including a nested dialog that opens in the same commit as its parent\n * (React inserts that one's portal first). The host moves only when its order\n * is wrong, keeping focus, so a reopened dialog keeps its scroll and focus.\n * Null on the server and while hydrating.\n */\nexport function useDialogPortal(\n order: number | undefined,\n isPresent: boolean,\n container?: HTMLElement | null,\n) {\n // Kept through a closing transition, when the dialog no longer has an order.\n const [rank, setRank] = useState(order ?? 0);\n if (order !== undefined && order !== rank) {\n setRank(order);\n }\n // Contents only, so a contained drawer's container lays out the frame itself.\n const host = useMovableHost(\"ds-dialog-host\", { display: \"contents\" });\n // Before layout effects, so content measures and focuses inside the document.\n useInsertionEffect(() => {\n if (!host) {\n return;\n }\n if (!isPresent) {\n host.remove();\n return;\n }\n ranks.set(host, rank);\n const parent = container ?? document.body;\n const { inPlace, before } = placement(host, parent, rank);\n if (!inPlace) {\n insertHost(host, parent, before);\n }\n }, [host, rank, isPresent, container]);\n return host;\n}\n","interface Entry {\n layer: number;\n order: number;\n}\nconst stack = new Set<Entry>();\nlet openings = 0;\n\n/**\n * A dialog's place among those on its layer, taken as it opens and kept while\n * it is suspended. Taken during render, where a dialog renders before the ones\n * nested in it, so nested dialogs that open with it still come after it.\n */\nexport function nextDialogOrder() {\n openings += 1;\n return openings;\n}\n\n/**\n * Register an open modal dialog; only the topmost one handles keys. A higher\n * layer wins, then the later opening, matching paint order: portals append as\n * dialogs open. A dialog resuming from suspension keeps its opening order, so\n * it never jumps above dialogs opened while it was suspended.\n */\nexport function openDialog(layer: number, order: number) {\n const entry: Entry = { layer, order };\n stack.add(entry);\n return {\n isTopmost: () => {\n for (const other of stack) {\n if (other.layer > layer || (other.layer === layer && other.order > order)) {\n return false;\n }\n }\n return stack.has(entry);\n },\n close: () => {\n stack.delete(entry);\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 { nextDialogOrder, openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport {\n cannotHoldFocus,\n focusNearest,\n panelHoldsFocus,\n tabbableControls,\n trapTabFocus,\n} from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\nimport { useLatest } from \"./useLatest\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n /** An inactive open dialog stays mounted but leaves keys, focus and scrim presses to others. */\n isActive?: boolean;\n layer?: number;\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\ninterface Opening {\n opener: Element | null;\n order: number;\n}\n\n/** Scroll the panel's own scroll areas, never the page or the panel's host, until `control` shows. */\nfunction revealInPanel(panel: HTMLElement, control: HTMLElement) {\n for (let area = control.parentElement; area && panel.contains(area); area = area.parentElement) {\n if (area.scrollHeight > area.clientHeight) {\n const view = area.getBoundingClientRect();\n const box = control.getBoundingClientRect();\n if (box.top < view.top) {\n area.scrollTop -= view.top - box.top;\n } else if (box.bottom > view.bottom) {\n area.scrollTop += Math.min(box.bottom - view.bottom, box.top - view.top);\n }\n }\n }\n}\n\n/**\n * Return to the control focused last in this opening, else to the initial\n * focus. Hiding a panel resets its scroll, so a restored control is brought\n * into view within the panel, leaving the page where it is.\n */\nfunction focusPanel(\n panel: HTMLElement,\n previous: HTMLElement | undefined,\n initialFocus: ModalDialogOptions[\"initialFocus\"],\n options: FocusOptions,\n) {\n if (previous && panel.contains(previous) && !cannotHoldFocus(previous)) {\n previous.focus({ preventScroll: true });\n }\n if (previous && document.activeElement === previous) {\n revealInPanel(panel, previous);\n } else if (!panelHoldsFocus(panel, document.activeElement)) {\n (initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(options);\n }\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 isActive = true,\n layer = 60,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useLatest({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus\n // inside it, and before the dialogs nested in it render.\n const [opening, setOpening] = useState<Opening | null>(null);\n const lastFocused = useRef<{ order: number; element: HTMLElement } | null>(null);\n if ((opening !== null) !== isOpen) {\n setOpening(\n isOpen\n ? {\n opener: typeof document === \"undefined\" ? null : document.activeElement,\n order: nextDialogOrder(),\n }\n : null,\n );\n }\n\n useEffect(() => {\n if (!isOpen || !isActive || !opening) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n const dialog = openDialog(layer, opening.order);\n // Remembered per opening, so a new opening starts from its initial focus.\n const remember = (element: EventTarget | null) => {\n if (element instanceof HTMLElement) {\n lastFocused.current = { order: opening.order, element };\n }\n };\n const rememberFocus = ({ target }: FocusEvent) => remember(target);\n panel?.addEventListener(\"focusin\", rememberFocus);\n const active = document.activeElement;\n // Leave focus that autoFocus, the caller, or a popup resuming inside the\n // panel (its effects run first) already placed there.\n if (dialog.isTopmost() && panel && !panelHoldsFocus(panel, active)) {\n const previous = lastFocused.current;\n focusPanel(\n panel,\n previous?.order === opening.order ? previous.element : undefined,\n latest.current.initialFocus,\n focusOptions,\n );\n } else if (panel?.contains(active)) {\n // Focus placed before the listener was attached.\n remember(active);\n }\n\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 panel?.removeEventListener(\"focusin\", rememberFocus);\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(opening.opener, focusOptions);\n }\n };\n }, [isOpen, isActive, layer, opening, panelRef, preventScroll, container, latest]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && isActive && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown, order: opening?.order };\n}\n","import type { AriaAttributes } from \"react\";\n\n/** Keep naming and visibility consistent across dialog frames, including suspended panels. */\nexport function dialogAttributes(\n props: AriaAttributes,\n titleId: string,\n descriptionId: string,\n hasDescription: boolean,\n active: boolean,\n) {\n return {\n role: \"dialog\" as const,\n \"aria-modal\": active || undefined,\n \"aria-hidden\": active ? props[\"aria-hidden\"] : true,\n \"aria-labelledby\": props[\"aria-label\"] ? undefined : (props[\"aria-labelledby\"] ?? titleId),\n \"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P,EAAS,OAAO;GADpC;EAEF;EAEA,OAAO,iBAAiB,WAAWM,CAAS;EAC5C,IAAME,IAAejC,EAAe;EAEpC,aAAa;GAMX,AALAU,GAAO,oBAAoB,WAAWmB,CAAa,GACnD,OAAO,oBAAoB,WAAWE,CAAS,GAC/CL,EAAO,MAAM,GACbO,EAAa,GAEThF,EAAgB,SAAS,aAAa,KACxCC,EAAagE,EAAQ,QAAQM,CAAY;EAE7C;CACF,GAAG;EAACH;EAAQE;EAAU1B;EAAOqB;EAASO;EAAUS;EAAe5C;EAAW2B;CAAM,CAAC,GAS1E;EAAE,mBANiB,MAAsB;GAC9C,AAAII,KAAUE,KAAYS,EAAM,WAAWA,EAAM,kBAC/CA,EAAM,eAAe,GACrBf,EAAO,QAAQ,QAAQ;EAE3B;EAC2B,OAAOC,GAAS;CAAM;AACnD;;;ACzKA,SAAgBiB,EACd,GACA,GACA,GACA,GACA,GACA;CACA,OAAO;EACL,MAAM;EACN,cAAc7D,KAAU,KAAA;EACxB,eAAe,MAAS8D,EAAM;EAC9B,mBAAmBA,EAAM,gBAAgB,KAAA,IAAaA,EAAM,sBAAsBC;EAClF,oBAAoBC,IAAiBC,IAAgBH,EAAM;CAC7D;AACF"}
|
|
1
|
+
{"version":3,"file":"dialogLabel-D18maX-p.js","names":["cannotHoldFocus","focusNearest","trapTabFocus","tabbableControls","panelHoldsFocus","useLatest","isComposing","createMovableHost","host","className","style","subscribe","useMovableHost","useState","hydrated","useSyncExternalStore","useInsertionEffect","moveHost","slot","insertHost","lastFocused","active","focused","refocus","before","ranks","placement","others","parent","child","isLater","other","rank","useDialogPortal","setRank","order","isPresent","container","inPlace","stack","openings","nextDialogOrder","openDialog","entry","layer","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","revealInPanel","area","control","panel","view","box","focusPanel","initialFocus","options","useModalDialog","latest","opening","setOpening","useRef","isOpen","useEffect","isActive","focusOptions","panelRef","dialog","remember","element","rememberFocus","target","onKeyDown","event","unlockScroll","preventScroll","dialogAttributes","props","titleId","hasDescription","descriptionId"],"sources":["../../src/internal/movableHost.ts","../../src/internal/useDialogPortal.ts","../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts","../../src/internal/dialogLabel.ts"],"sourcesContent":["import { useInsertionEffect, 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, style: Partial<CSSStyleDeclaration> = {}) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n Object.assign(host.style, style);\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, style?: Partial<CSSStyleDeclaration>) {\n const [host] = useState(() => createMovableHost(className, style));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n // An insertion effect, which Strict Mode never replays: replaying a passive\n // cleanup would detach a host that an insertion effect placed.\n useInsertionEffect(() => () => 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. 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 insertHost(host, slot, null, lastFocused);\n return true;\n}\n\n/**\n * Inserts `host` into `slot` before `before`, or at its end. Moving drops focus,\n * so the element inside the host that had it (or `lastFocused`, when an earlier\n * removal already dropped it) gets it back.\n */\nexport function insertHost(\n host: HTMLElement,\n slot: Element,\n before: Node | null,\n lastFocused: Element | null = null,\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.insertBefore(host, before);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n}\n","import { useInsertionEffect, useState } from \"react\";\nimport { insertHost, useMovableHost } from \"./movableHost\";\n\n/** The opening order of each dialog's portal host. */\nconst ranks = new WeakMap<Element, number>();\n\n/**\n * Where `host` belongs among the other dialog hosts in `parent`: before the\n * first one opened later. It is in place when every host opened earlier comes\n * before it and every one opened later after it, whatever else lies between.\n */\nfunction placement(host: Element, parent: Element, rank: number) {\n const others = Array.from(parent.children).filter((child) => child !== host && ranks.has(child));\n const isLater = (other: Element) => (ranks.get(other) ?? 0) > rank;\n const inPlace =\n host.parentNode === parent &&\n others.every(\n (other) =>\n isLater(other) ===\n Boolean(host.compareDocumentPosition(other) & Node.DOCUMENT_POSITION_FOLLOWING),\n );\n return { inPlace, before: others.find(isLater) ?? null };\n}\n\n/**\n * A portal host that paints dialogs in opening order, as the dialog stack ranks\n * them, including a nested dialog that opens in the same commit as its parent\n * (React inserts that one's portal first). The host moves only when its order\n * is wrong, keeping focus, so a reopened dialog keeps its scroll and focus.\n * Null on the server and while hydrating.\n */\nexport function useDialogPortal(\n order: number | undefined,\n isPresent: boolean,\n container?: HTMLElement | null,\n) {\n // Kept through a closing transition, when the dialog no longer has an order.\n const [rank, setRank] = useState(order ?? 0);\n if (order !== undefined && order !== rank) {\n setRank(order);\n }\n // Contents only, so a contained drawer's container lays out the frame itself.\n const host = useMovableHost(\"ds-dialog-host\", { display: \"contents\" });\n // Before layout effects, so content measures and focuses inside the document.\n useInsertionEffect(() => {\n if (!host) {\n return;\n }\n if (!isPresent) {\n host.remove();\n return;\n }\n ranks.set(host, rank);\n const parent = container ?? document.body;\n const { inPlace, before } = placement(host, parent, rank);\n if (!inPlace) {\n insertHost(host, parent, before);\n }\n }, [host, rank, isPresent, container]);\n return host;\n}\n","interface Entry {\n layer: number;\n order: number;\n}\nconst stack = new Set<Entry>();\nlet openings = 0;\n\n/**\n * A dialog's place among those on its layer, taken as it opens and kept while\n * it is suspended. Taken during render, where a dialog renders before the ones\n * nested in it, so nested dialogs that open with it still come after it.\n */\nexport function nextDialogOrder() {\n openings += 1;\n return openings;\n}\n\n/**\n * Register an open modal dialog; only the topmost one handles keys. A higher\n * layer wins, then the later opening, matching paint order: portals append as\n * dialogs open. A dialog resuming from suspension keeps its opening order, so\n * it never jumps above dialogs opened while it was suspended.\n */\nexport function openDialog(layer: number, order: number) {\n const entry: Entry = { layer, order };\n stack.add(entry);\n return {\n isTopmost: () => {\n for (const other of stack) {\n if (other.layer > layer || (other.layer === layer && other.order > order)) {\n return false;\n }\n }\n return stack.has(entry);\n },\n close: () => {\n stack.delete(entry);\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 { nextDialogOrder, openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport {\n cannotHoldFocus,\n focusNearest,\n panelHoldsFocus,\n tabbableControls,\n trapTabFocus,\n} from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\nimport { useLatest } from \"./useLatest\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n /** An inactive open dialog stays mounted but leaves keys, focus and scrim presses to others. */\n isActive?: boolean;\n layer?: number;\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\ninterface Opening {\n opener: Element | null;\n order: number;\n}\n\n/** Scroll the panel's own scroll areas, never the page or the panel's host, until `control` shows. */\nfunction revealInPanel(panel: HTMLElement, control: HTMLElement) {\n for (let area = control.parentElement; area && panel.contains(area); area = area.parentElement) {\n if (area.scrollHeight > area.clientHeight) {\n const view = area.getBoundingClientRect();\n const box = control.getBoundingClientRect();\n if (box.top < view.top) {\n area.scrollTop -= view.top - box.top;\n } else if (box.bottom > view.bottom) {\n area.scrollTop += Math.min(box.bottom - view.bottom, box.top - view.top);\n }\n }\n }\n}\n\n/**\n * Return to the control focused last in this opening, else to the initial\n * focus. A suspended panel stays laid out, so its scroll areas keep their\n * positions; a restored control is still brought into view within the panel,\n * in case its content moved, leaving the page where it is.\n */\nfunction focusPanel(\n panel: HTMLElement,\n previous: HTMLElement | undefined,\n initialFocus: ModalDialogOptions[\"initialFocus\"],\n options: FocusOptions,\n) {\n if (previous && panel.contains(previous) && !cannotHoldFocus(previous)) {\n previous.focus({ preventScroll: true });\n }\n if (previous && document.activeElement === previous) {\n revealInPanel(panel, previous);\n } else if (!panelHoldsFocus(panel, document.activeElement)) {\n (initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(options);\n }\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 isActive = true,\n layer = 60,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useLatest({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus\n // inside it, and before the dialogs nested in it render.\n const [opening, setOpening] = useState<Opening | null>(null);\n const lastFocused = useRef<{ order: number; element: HTMLElement } | null>(null);\n if ((opening !== null) !== isOpen) {\n setOpening(\n isOpen\n ? {\n opener: typeof document === \"undefined\" ? null : document.activeElement,\n order: nextDialogOrder(),\n }\n : null,\n );\n }\n\n useEffect(() => {\n if (!isOpen || !isActive || !opening) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n const dialog = openDialog(layer, opening.order);\n // Remembered per opening, so a new opening starts from its initial focus.\n const remember = (element: EventTarget | null) => {\n if (element instanceof HTMLElement) {\n lastFocused.current = { order: opening.order, element };\n }\n };\n const rememberFocus = ({ target }: FocusEvent) => remember(target);\n panel?.addEventListener(\"focusin\", rememberFocus);\n const active = document.activeElement;\n // Leave focus that autoFocus, the caller, or a popup resuming inside the\n // panel (its effects run first) already placed there.\n if (dialog.isTopmost() && panel && !panelHoldsFocus(panel, active)) {\n const previous = lastFocused.current;\n focusPanel(\n panel,\n previous?.order === opening.order ? previous.element : undefined,\n latest.current.initialFocus,\n focusOptions,\n );\n } else if (panel?.contains(active)) {\n // Focus placed before the listener was attached.\n remember(active);\n }\n\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 panel?.removeEventListener(\"focusin\", rememberFocus);\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(opening.opener, focusOptions);\n }\n };\n }, [isOpen, isActive, layer, opening, panelRef, preventScroll, container, latest]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && isActive && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown, order: opening?.order };\n}\n","import type { AriaAttributes } from \"react\";\n\n/** Keep naming and visibility consistent across dialog frames, including suspended panels. */\nexport function dialogAttributes(\n props: AriaAttributes,\n titleId: string,\n descriptionId: string,\n hasDescription: boolean,\n active: boolean,\n) {\n return {\n role: \"dialog\" as const,\n \"aria-modal\": active || undefined,\n \"aria-hidden\": active ? props[\"aria-hidden\"] : true,\n \"aria-labelledby\": props[\"aria-label\"] ? undefined : (props[\"aria-labelledby\"] ?? titleId),\n \"aria-describedby\": hasDescription ? descriptionId : props[\"aria-describedby\"],\n };\n}\n"],"mappings":";;;;AAOA,SAAgBO,EAAkB,GAAmB,IAAsC,CAAC,GAAG;CAC7F,IAAI,OAAO,WAAa,KACtB,OAAO;CAET,IAAMC,IAAO,SAAS,cAAc,KAAK;CAGzC,OAFA,EAAK,YAAYC,GACjB,OAAO,OAAOD,EAAK,OAAOE,CAAK,GACxBF;AACT;AAEA,IAAMG,gBAAwB,CAAC;AAO/B,SAAgBC,EAAe,GAAmB,GAAsC;CACtF,IAAM,CAACJ,KAAQK,QAAeN,EAAkBE,GAAWC,CAAK,CAAC,GAC3DI,IAAWC,EACfJ,SACM,UACA,EACR;CAIA,OADAK,cAA+BR,GAAM,OAAO,GAAG,CAACA,CAAI,CAAC,GAC9CM,IAAWN,IAAO;AAC3B;AAOA,SAAgBS,EAC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1KA,SAAgBiB,EACd,GACA,GACA,GACA,GACA,GACA;CACA,OAAO;EACL,MAAM;EACN,cAAc7D,KAAU,KAAA;EACxB,eAAe,MAAS8D,EAAM;EAC9B,mBAAmBA,EAAM,gBAAgB,KAAA,IAAaA,EAAM,sBAAsBC;EAClF,oBAAoBC,IAAiBC,IAAgBH,EAAM;CAC7D;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./context-CXvOl4Kt.js";
|
|
2
2
|
import { Badge as t } from "../components/Badge/index.js";
|
|
3
|
-
import { n, r, t as i } from "./limit-
|
|
3
|
+
import { n, r, t as i } from "./limit-s9zfxIMC.js";
|
|
4
4
|
import { LimitReading as a } from "../components/LimitReading/index.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
import { Children as o, useId as s, useMemo as c, useState as l } from "react";
|
|
@@ -134,7 +134,7 @@ function v(e, t) {
|
|
|
134
134
|
}
|
|
135
135
|
function y(e, t, n) {
|
|
136
136
|
let r = e.get(t);
|
|
137
|
-
if (n ? r?.count === n.count && r.max === n.max : !r) return e;
|
|
137
|
+
if (n ? r?.count === n.count && r.max === n.max && r.tone === n.tone : !r) return e;
|
|
138
138
|
let i = new Map(e);
|
|
139
139
|
return n ? i.set(t, n) : i.delete(t), i;
|
|
140
140
|
}
|
|
@@ -161,4 +161,4 @@ function x(e, t, n, r) {
|
|
|
161
161
|
//#endregion
|
|
162
162
|
export { _ as t };
|
|
163
163
|
|
|
164
|
-
//# sourceMappingURL=frame-
|
|
164
|
+
//# sourceMappingURL=frame-CzadNYgy.js.map
|