@arshad-shah/cynosure 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/adapters/astro/index.d.ts +2 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Accordion/Accordion.js +26 -26
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Announcer/Announcer.d.ts +2 -1
- package/dist/components/Announcer/Announcer.js +31 -33
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.js +44 -41
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Badge/Badge.d.ts +19 -5
- package/dist/components/Badge/Badge.js +19 -13
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Button/Button.d.ts +13 -3
- package/dist/components/Button/Button.js +34 -33
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.js +155 -158
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Calendar/dates.js +42 -38
- package/dist/components/Calendar/dates.js.map +1 -1
- package/dist/components/Card/Card.d.ts +14 -1
- package/dist/components/Card/Card.js +60 -52
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/ChatMessage/ChatMessage.d.ts +55 -0
- package/dist/components/ChatMessage/ChatMessage.js +50 -0
- package/dist/components/ChatMessage/ChatMessage.js.map +1 -0
- package/dist/components/ChatMessage/index.d.ts +1 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +6 -1
- package/dist/components/CodeBlock/CodeBlock.js +40 -37
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/ColorField/ColorField.d.ts +3 -2
- package/dist/components/ColorField/ColorField.js +138 -139
- package/dist/components/ColorField/ColorField.js.map +1 -1
- package/dist/components/ColorField/read-color.js +5 -6
- package/dist/components/ColorField/read-color.js.map +1 -1
- package/dist/components/ColorSwatches/ColorSwatches.js +42 -33
- package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts +13 -2
- package/dist/components/Combobox/Combobox.js +113 -95
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.d.ts +14 -1
- package/dist/components/CommandPalette/CommandPalette.js +153 -109
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/components/CommandPalette/index.d.ts +1 -1
- package/dist/components/CompareSlider/CompareSlider.js +14 -14
- package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
- package/dist/components/Container/Container.d.ts +1 -1
- package/dist/components/Container/Container.js +1 -1
- package/dist/components/Container/Container.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.d.ts +27 -13
- package/dist/components/ContextMenu/ContextMenu.js +64 -46
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.js +38 -39
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DataGrid/DataGrid.d.ts +135 -0
- package/dist/components/DataGrid/DataGrid.js +385 -0
- package/dist/components/DataGrid/DataGrid.js.map +1 -0
- package/dist/components/DataGrid/index.d.ts +1 -0
- package/dist/components/DateField/DateField.d.ts +4 -3
- package/dist/components/DateField/DateField.js +70 -59
- package/dist/components/DateField/DateField.js.map +1 -1
- package/dist/components/Dialog/Dialog.js +76 -80
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Disclosure/Disclosure.d.ts +15 -1
- package/dist/components/Disclosure/Disclosure.js +37 -30
- package/dist/components/Disclosure/Disclosure.js.map +1 -1
- package/dist/components/DocumentViewport/DocumentViewport.js +54 -57
- package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
- package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +59 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js +53 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js.map +1 -0
- package/dist/components/ErrorBoundary/index.d.ts +1 -0
- package/dist/components/Field/Field.d.ts +38 -5
- package/dist/components/Field/Field.js +47 -39
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/Field/index.d.ts +1 -1
- package/dist/components/FileDrop/FileDrop.d.ts +26 -1
- package/dist/components/FileDrop/FileDrop.js +149 -98
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.js +83 -81
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +3 -3
- package/dist/components/Grid/Grid.js +55 -47
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/HighlightedText/HighlightedText.d.ts +40 -0
- package/dist/components/HighlightedText/HighlightedText.js +36 -0
- package/dist/components/HighlightedText/HighlightedText.js.map +1 -0
- package/dist/components/HighlightedText/index.d.ts +2 -0
- package/dist/components/HotkeyField/HotkeyField.d.ts +84 -0
- package/dist/components/HotkeyField/HotkeyField.js +161 -0
- package/dist/components/HotkeyField/HotkeyField.js.map +1 -0
- package/dist/components/HotkeyField/index.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.js +6 -6
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/IconButton/IconButton.js +16 -15
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Inline/Inline.d.ts +2 -2
- package/dist/components/Inline/Inline.js.map +1 -1
- package/dist/components/Kbd/Kbd.d.ts +0 -2
- package/dist/components/Kbd/Kbd.js +16 -22
- package/dist/components/Kbd/Kbd.js.map +1 -1
- package/dist/components/KeyValueEditor/bulk.js +3 -4
- package/dist/components/KeyValueEditor/bulk.js.map +1 -1
- package/dist/components/ListRow/ListRow.d.ts +105 -0
- package/dist/components/ListRow/ListRow.js +164 -0
- package/dist/components/ListRow/ListRow.js.map +1 -0
- package/dist/components/ListRow/index.d.ts +1 -0
- package/dist/components/LoadingDots/LoadingDots.d.ts +7 -2
- package/dist/components/LoadingDots/LoadingDots.js +28 -18
- package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts +29 -11
- package/dist/components/Menu/Menu.js +204 -111
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Menubar/Menubar.d.ts +40 -0
- package/dist/components/Menubar/Menubar.js +82 -0
- package/dist/components/Menubar/Menubar.js.map +1 -0
- package/dist/components/Menubar/index.d.ts +1 -0
- package/dist/components/Notice/Notice.d.ts +11 -2
- package/dist/components/Notice/Notice.js +31 -28
- package/dist/components/Notice/Notice.js.map +1 -1
- package/dist/components/NumberField/NumberField.d.ts +8 -3
- package/dist/components/NumberField/NumberField.js +151 -100
- package/dist/components/NumberField/NumberField.js.map +1 -1
- package/dist/components/OptionList/OptionList.d.ts +36 -3
- package/dist/components/OptionList/OptionList.js +65 -42
- package/dist/components/OptionList/OptionList.js.map +1 -1
- package/dist/components/OptionList/index.d.ts +1 -1
- package/dist/components/OverlayFrame/OverlayFrame.d.ts +33 -0
- package/dist/components/OverlayFrame/OverlayFrame.js +20 -0
- package/dist/components/OverlayFrame/OverlayFrame.js.map +1 -0
- package/dist/components/OverlayFrame/index.d.ts +1 -0
- package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +71 -4
- package/dist/components/PanZoomCanvas/PanZoomCanvas.js +197 -141
- package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
- package/dist/components/PanZoomCanvas/index.d.ts +1 -1
- package/dist/components/PathField/PathField.d.ts +68 -0
- package/dist/components/PathField/PathField.js +67 -0
- package/dist/components/PathField/PathField.js.map +1 -0
- package/dist/components/PathField/index.d.ts +1 -0
- package/dist/components/Popover/Popover.d.ts +16 -3
- package/dist/components/Popover/Popover.js +51 -42
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +4 -3
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/RowActions/RowActions.d.ts +35 -0
- package/dist/components/RowActions/RowActions.js +38 -0
- package/dist/components/RowActions/RowActions.js.map +1 -0
- package/dist/components/RowActions/index.d.ts +1 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +55 -0
- package/dist/components/ScrollArea/ScrollArea.js +55 -0
- package/dist/components/ScrollArea/ScrollArea.js.map +1 -0
- package/dist/components/ScrollArea/index.d.ts +1 -0
- package/dist/components/SearchField/SearchField.d.ts +17 -0
- package/dist/components/SearchField/SearchField.js +31 -17
- package/dist/components/SearchField/SearchField.js.map +1 -1
- package/dist/components/SearchField/index.d.ts +1 -1
- package/dist/components/Section/Section.d.ts +1 -1
- package/dist/components/Section/Section.js +1 -1
- package/dist/components/Section/Section.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +6 -3
- package/dist/components/SegmentedControl/SegmentedControl.js +23 -19
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.d.ts +22 -6
- package/dist/components/Select/Select.js +155 -129
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/SelectionFrame/frame-math.js +19 -20
- package/dist/components/SelectionFrame/frame-math.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +13 -1
- package/dist/components/SideNav/SideNav.js +98 -91
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.js +63 -62
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/SignaturePad/ink.js +0 -1
- package/dist/components/SignaturePad/ink.js.map +1 -1
- package/dist/components/Slider/Slider.js +88 -91
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/SortButton/SortButton.d.ts +36 -0
- package/dist/components/SortButton/SortButton.js +35 -0
- package/dist/components/SortButton/SortButton.js.map +1 -0
- package/dist/components/SortButton/index.d.ts +1 -0
- package/dist/components/SortableList/SortableList.js +145 -119
- package/dist/components/SortableList/SortableList.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +32 -12
- package/dist/components/SplitPane/SplitPane.js +105 -59
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +2 -2
- package/dist/components/Stack/Stack.js +24 -17
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -1
- package/dist/components/Stat/Stat.js +6 -6
- package/dist/components/Stat/Stat.js.map +1 -1
- package/dist/components/StatusBar/StatusBar.d.ts +95 -0
- package/dist/components/StatusBar/StatusBar.js +110 -0
- package/dist/components/StatusBar/StatusBar.js.map +1 -0
- package/dist/components/StatusBar/index.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +6 -6
- package/dist/components/Table/Table.js +71 -99
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +51 -5
- package/dist/components/Tabs/Tabs.js +289 -171
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.d.ts +10 -2
- package/dist/components/TagInput/TagInput.js +121 -111
- package/dist/components/TagInput/TagInput.js.map +1 -1
- package/dist/components/Text/Text.d.ts +6 -0
- package/dist/components/Text/Text.js +18 -17
- package/dist/components/Text/Text.js.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +37 -6
- package/dist/components/TextArea/TextArea.js +200 -72
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/TextField/TextField.d.ts +18 -6
- package/dist/components/TextField/TextField.js +59 -54
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TimeField/TimeField.d.ts +4 -3
- package/dist/components/TimeField/TimeField.js +197 -183
- package/dist/components/TimeField/TimeField.js.map +1 -1
- package/dist/components/TitleBar/TitleBar.d.ts +91 -0
- package/dist/components/TitleBar/TitleBar.js +80 -0
- package/dist/components/TitleBar/TitleBar.js.map +1 -0
- package/dist/components/TitleBar/index.d.ts +1 -0
- package/dist/components/Toast/Toast.d.ts +17 -2
- package/dist/components/Toast/Toast.js +162 -145
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/Toolbar/Toolbar.js +11 -12
- package/dist/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +18 -1
- package/dist/components/Tooltip/Tooltip.js +50 -31
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +92 -11
- package/dist/components/Tree/Tree.js +332 -164
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.d.ts +27 -4
- package/dist/components/VirtualList/VirtualList.js +179 -145
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualList/index.d.ts +1 -1
- package/dist/components/ZoomControls/ZoomControls.d.ts +6 -2
- package/dist/components/ZoomControls/ZoomControls.js +37 -37
- package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
- package/dist/entries/tokens.js +22 -16
- package/dist/foundations/ChoiceBase/ChoiceBase.js +15 -13
- package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
- package/dist/foundations/LiveRegion/LiveRegion.d.ts +33 -0
- package/dist/foundations/LiveRegion/LiveRegion.js +29 -0
- package/dist/foundations/LiveRegion/LiveRegion.js.map +1 -0
- package/dist/foundations/LiveRegion/index.d.ts +1 -0
- package/dist/foundations/canvas-size.d.ts +14 -0
- package/dist/foundations/canvas-size.js +32 -0
- package/dist/foundations/canvas-size.js.map +1 -0
- package/dist/foundations/dir.js +0 -1
- package/dist/foundations/dir.js.map +1 -1
- package/dist/foundations/draft.d.ts +14 -0
- package/dist/foundations/draft.js +22 -0
- package/dist/foundations/draft.js.map +1 -0
- package/dist/foundations/edge.d.ts +20 -0
- package/dist/foundations/edge.js +26 -0
- package/dist/foundations/edge.js.map +1 -0
- package/dist/foundations/focus.d.ts +5 -0
- package/dist/foundations/focus.js +10 -0
- package/dist/foundations/focus.js.map +1 -0
- package/dist/foundations/hotkey.d.ts +23 -1
- package/dist/foundations/hotkey.js +48 -26
- package/dist/foundations/hotkey.js.map +1 -1
- package/dist/foundations/icon-size.d.ts +7 -0
- package/dist/foundations/icon-size.js +6 -0
- package/dist/foundations/icon-size.js.map +1 -0
- package/dist/foundations/keys.js +12 -13
- package/dist/foundations/keys.js.map +1 -1
- package/dist/{components/Stack/space.d.ts → foundations/layout.d.ts} +34 -0
- package/dist/foundations/layout.js +29 -0
- package/dist/foundations/layout.js.map +1 -0
- package/dist/foundations/listbox.d.ts +47 -2
- package/dist/foundations/listbox.js +56 -25
- package/dist/foundations/listbox.js.map +1 -1
- package/dist/foundations/math.d.ts +25 -0
- package/dist/foundations/math.js +14 -3
- package/dist/foundations/math.js.map +1 -1
- package/dist/foundations/media-query.d.ts +5 -0
- package/dist/foundations/media-query.js +14 -0
- package/dist/foundations/media-query.js.map +1 -0
- package/dist/foundations/motion.d.ts +12 -0
- package/dist/foundations/motion.js +21 -0
- package/dist/foundations/motion.js.map +1 -0
- package/dist/foundations/option-icon.d.ts +3 -1
- package/dist/foundations/option-icon.js +6 -6
- package/dist/foundations/option-icon.js.map +1 -1
- package/dist/foundations/qr.js +0 -1
- package/dist/foundations/qr.js.map +1 -1
- package/dist/foundations/refs.d.ts +8 -0
- package/dist/foundations/refs.js +14 -0
- package/dist/foundations/refs.js.map +1 -0
- package/dist/foundations/reorder.js +5 -6
- package/dist/foundations/reorder.js.map +1 -1
- package/dist/foundations/roving-focus.d.ts +10 -0
- package/dist/foundations/roving-focus.js +34 -31
- package/dist/foundations/roving-focus.js.map +1 -1
- package/dist/foundations/scroll-align.d.ts +11 -0
- package/dist/foundations/scroll-align.js +8 -0
- package/dist/foundations/scroll-align.js.map +1 -0
- package/dist/foundations/sort.d.ts +13 -0
- package/dist/foundations/sort.js +26 -0
- package/dist/foundations/sort.js.map +1 -0
- package/dist/foundations/text-match.d.ts +11 -0
- package/dist/foundations/text-match.js +20 -0
- package/dist/foundations/text-match.js.map +1 -0
- package/dist/foundations/tone-icons.js +4 -5
- package/dist/foundations/tone-icons.js.map +1 -1
- package/dist/foundations/use-follow.d.ts +29 -0
- package/dist/foundations/use-follow.js +51 -0
- package/dist/foundations/use-follow.js.map +1 -0
- package/dist/foundations/virtual-window.d.ts +22 -5
- package/dist/foundations/virtual-window.js +58 -54
- package/dist/foundations/virtual-window.js.map +1 -1
- package/dist/foundations/zoom-gestures.d.ts +23 -1
- package/dist/foundations/zoom-gestures.js +123 -84
- package/dist/foundations/zoom-gestures.js.map +1 -1
- package/dist/foundations/zoom.d.ts +10 -4
- package/dist/foundations/zoom.js +16 -17
- package/dist/foundations/zoom.js.map +1 -1
- package/dist/icons/boxes.d.ts +2 -0
- package/dist/icons/boxes.js +34 -0
- package/dist/icons/boxes.js.map +1 -0
- package/dist/icons/by-name.d.ts +11 -0
- package/dist/icons/by-name.js +11 -0
- package/dist/icons/by-name.js.map +1 -0
- package/dist/icons/cable.d.ts +2 -0
- package/dist/icons/cable.js +14 -0
- package/dist/icons/cable.js.map +1 -0
- package/dist/icons/check-check.d.ts +2 -0
- package/dist/icons/check-check.js +17 -0
- package/dist/icons/check-check.js.map +1 -0
- package/dist/icons/clipboard-paste.d.ts +2 -0
- package/dist/icons/clipboard-paste.js +30 -0
- package/dist/icons/clipboard-paste.js.map +1 -0
- package/dist/icons/facet.d.ts +274 -0
- package/dist/icons/facet.js +830 -0
- package/dist/icons/facet.js.map +1 -0
- package/dist/icons/file-plus.d.ts +2 -0
- package/dist/icons/file-plus.js +14 -0
- package/dist/icons/file-plus.js.map +1 -0
- package/dist/icons/file-question.d.ts +2 -0
- package/dist/icons/file-question.js +14 -0
- package/dist/icons/file-question.js.map +1 -0
- package/dist/icons/file-search.d.ts +2 -0
- package/dist/icons/file-search.js +24 -0
- package/dist/icons/file-search.js.map +1 -0
- package/dist/icons/function.d.ts +2 -0
- package/dist/icons/function.js +20 -0
- package/dist/icons/function.js.map +1 -0
- package/dist/icons/gauge.d.ts +2 -0
- package/dist/icons/gauge.js +14 -0
- package/dist/icons/gauge.js.map +1 -0
- package/dist/icons/hourglass.d.ts +2 -0
- package/dist/icons/hourglass.js +14 -0
- package/dist/icons/hourglass.js.map +1 -0
- package/dist/icons/index.d.ts +1 -250
- package/dist/icons/index.js +548 -500
- package/dist/icons/keywords.d.ts +24 -0
- package/dist/icons/keywords.js +185 -0
- package/dist/icons/keywords.js.map +1 -1
- package/dist/icons/languages.d.ts +2 -0
- package/dist/icons/languages.js +14 -0
- package/dist/icons/languages.js.map +1 -0
- package/dist/icons/loader.d.ts +2 -0
- package/dist/icons/loader.js +14 -0
- package/dist/icons/loader.js.map +1 -0
- package/dist/icons/monitor-down.d.ts +2 -0
- package/dist/icons/monitor-down.js +24 -0
- package/dist/icons/monitor-down.js.map +1 -0
- package/dist/icons/panel-right.d.ts +2 -0
- package/dist/icons/panel-right.js +20 -0
- package/dist/icons/panel-right.js.map +1 -0
- package/dist/icons/party-popper.d.ts +2 -0
- package/dist/icons/party-popper.js +14 -0
- package/dist/icons/party-popper.js.map +1 -0
- package/dist/icons/power-off.d.ts +2 -0
- package/dist/icons/power-off.js +14 -0
- package/dist/icons/power-off.js.map +1 -0
- package/dist/icons/rocket.d.ts +2 -0
- package/dist/icons/rocket.js +21 -0
- package/dist/icons/rocket.js.map +1 -0
- package/dist/icons/rows.d.ts +2 -0
- package/dist/icons/rows.js +20 -0
- package/dist/icons/rows.js.map +1 -0
- package/dist/icons/scissors.d.ts +2 -0
- package/dist/icons/scissors.js +26 -0
- package/dist/icons/scissors.js.map +1 -0
- package/dist/icons/shield-question.d.ts +2 -0
- package/dist/icons/shield-question.js +14 -0
- package/dist/icons/shield-question.js.map +1 -0
- package/dist/icons/square-plus.d.ts +2 -0
- package/dist/icons/square-plus.js +20 -0
- package/dist/icons/square-plus.js.map +1 -0
- package/dist/icons/text-select.d.ts +2 -0
- package/dist/icons/text-select.js +14 -0
- package/dist/icons/text-select.js.map +1 -0
- package/dist/icons/window-maximize.d.ts +2 -0
- package/dist/icons/window-maximize.js +14 -0
- package/dist/icons/window-maximize.js.map +1 -0
- package/dist/icons/window-restore.d.ts +2 -0
- package/dist/icons/window-restore.js +20 -0
- package/dist/icons/window-restore.js.map +1 -0
- package/dist/index.d.ts +24 -9
- package/dist/index.js +326 -282
- package/dist/overlay/dismiss.js +15 -13
- package/dist/overlay/dismiss.js.map +1 -1
- package/dist/overlay/floating.d.ts +7 -2
- package/dist/overlay/floating.js +29 -21
- package/dist/overlay/floating.js.map +1 -1
- package/dist/overlay/listbox-layer.d.ts +3 -2
- package/dist/overlay/listbox-layer.js.map +1 -1
- package/dist/overlay/position.d.ts +5 -2
- package/dist/overlay/position.js +19 -19
- package/dist/overlay/position.js.map +1 -1
- package/dist/overlay/toast-host.js +3 -2
- package/dist/overlay/toast-host.js.map +1 -1
- package/dist/overlay/use-anchored-position.d.ts +2 -2
- package/dist/overlay/use-anchored-position.js +25 -25
- package/dist/overlay/use-anchored-position.js.map +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/chat-message.css +1 -0
- package/dist/styles/code-block.css +1 -1
- package/dist/styles/command-palette.css +1 -1
- package/dist/styles/data-grid.css +1 -0
- package/dist/styles/disclosure.css +1 -1
- package/dist/styles/error-boundary.css +1 -0
- package/dist/styles/field.css +1 -1
- package/dist/styles/file-drop.css +1 -1
- package/dist/styles/generated-css.d.ts +1 -1
- package/dist/styles/generated-css.js +3 -3
- package/dist/styles/generated-css.js.map +1 -1
- package/dist/styles/highlighted-text.css +1 -0
- package/dist/styles/hotkey-field.css +1 -0
- package/dist/styles/list-row.css +1 -0
- package/dist/styles/loading-dots.css +1 -1
- package/dist/styles/manifest.json +149 -12
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -0
- package/dist/styles/notice.css +1 -1
- package/dist/styles/option-list.css +1 -1
- package/dist/styles/overlay-frame.css +1 -0
- package/dist/styles/pan-zoom-canvas.css +1 -1
- package/dist/styles/path-field.css +1 -0
- package/dist/styles/popover.css +1 -1
- package/dist/styles/progress-bar.css +1 -1
- package/dist/styles/row-actions.css +1 -0
- package/dist/styles/scroll-area.css +1 -0
- package/dist/styles/search-field.css +1 -0
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/side-nav.css +1 -1
- package/dist/styles/sort-button.css +1 -0
- package/dist/styles/split-pane.css +1 -1
- package/dist/styles/status-bar.css +1 -0
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-area.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/text.css +1 -1
- package/dist/styles/title-bar.css +1 -0
- package/dist/styles/toast.css +1 -1
- package/dist/styles/tokens.css +3 -3
- package/dist/styles/tree.css +1 -1
- package/dist/styles/virtual-list.css +1 -1
- package/dist/styles.css +3 -3
- package/dist/theme/CynosureTheme.d.ts +7 -3
- package/dist/theme/CynosureTheme.js +47 -31
- package/dist/theme/CynosureTheme.js.map +1 -1
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/theme-context.d.ts +9 -0
- package/dist/theme/theme-context.js +8 -0
- package/dist/theme/theme-context.js.map +1 -0
- package/dist/theme/theme-init-script.js +0 -1
- package/dist/theme/theme-init-script.js.map +1 -1
- package/dist/theme/use-color-mode.d.ts +3 -2
- package/dist/theme/use-color-mode.js +35 -38
- package/dist/theme/use-color-mode.js.map +1 -1
- package/dist/theme/use-cynosure-theme.d.ts +18 -0
- package/dist/theme/use-cynosure-theme.js +23 -0
- package/dist/theme/use-cynosure-theme.js.map +1 -0
- package/dist/tokens/chart-themes.d.ts +38 -0
- package/dist/tokens/chart-themes.js +35 -0
- package/dist/tokens/chart-themes.js.map +1 -0
- package/dist/tokens/create-theme.d.ts +11 -1
- package/dist/tokens/create-theme.js +161 -121
- package/dist/tokens/create-theme.js.map +1 -1
- package/dist/tokens/defaults.d.ts +3 -3
- package/dist/tokens/defaults.js +1 -0
- package/dist/tokens/defaults.js.map +1 -1
- package/dist/tokens/editor-themes.d.ts +9 -2
- package/dist/tokens/editor-themes.js +43 -42
- package/dist/tokens/editor-themes.js.map +1 -1
- package/dist/tokens/index.d.ts +3 -1
- package/dist/tokens/named-themes.d.ts +41 -0
- package/dist/tokens/named-themes.js +118 -0
- package/dist/tokens/named-themes.js.map +1 -0
- package/dist/tokens/schema.d.ts +24 -1
- package/dist/tokens/schema.js +13 -0
- package/dist/tokens/schema.js.map +1 -0
- package/dist/tokens/to-css.js +34 -31
- package/dist/tokens/to-css.js.map +1 -1
- package/package.json +10 -6
- package/dist/components/Stack/space.js +0 -23
- package/dist/components/Stack/space.js.map +0 -1
|
@@ -1,99 +1,102 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useControllableState as
|
|
3
|
-
import { IconButton as
|
|
4
|
-
import { Popover as
|
|
5
|
-
import { addDays as
|
|
6
|
-
import { Calendar as
|
|
7
|
-
import { TextField as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
2
|
+
import { useControllableState as V } from "../../foundations/controllable.js";
|
|
3
|
+
import { IconButton as W } from "../IconButton/IconButton.js";
|
|
4
|
+
import { Popover as X } from "../Popover/Popover.js";
|
|
5
|
+
import { addDays as Z, addMonths as ee, isISODate as b } from "../Calendar/dates.js";
|
|
6
|
+
import { Calendar as oe } from "../Calendar/Calendar.js";
|
|
7
|
+
import { TextField as te } from "../TextField/TextField.js";
|
|
8
|
+
import { HiddenValue as re } from "../../foundations/HiddenValue/HiddenValue.js";
|
|
9
|
+
import { useDraft as ne } from "../../foundations/draft.js";
|
|
10
|
+
import { calendar as le } from "../../icons/calendar.js";
|
|
11
|
+
import { useEffect as ae, useRef as z, useState as se } from "react";
|
|
12
|
+
import { Fragment as ie, jsx as a, jsxs as ue } from "react/jsx-runtime";
|
|
13
|
+
var ce = {
|
|
12
14
|
open: "Choose a date",
|
|
13
15
|
invalid: "Enter a date as YYYY-MM-DD",
|
|
14
16
|
unavailable: "This date is not available",
|
|
15
17
|
previous: "Previous month",
|
|
16
18
|
next: "Next month"
|
|
17
|
-
},
|
|
19
|
+
}, s = (c) => {
|
|
18
20
|
const t = /^\s*(\d{4})[-/.](\d{1,2})[-/.](\d{1,2})\s*$/.exec(c);
|
|
19
21
|
return t ? `${t[1]}-${t[2].padStart(2, "0")}-${t[3].padStart(2, "0")}` : c.trim();
|
|
20
22
|
};
|
|
21
|
-
function
|
|
23
|
+
function xe({ label: c, labelHidden: t, layout: L, width: N, description: g, error: y, value: P, defaultValue: C = null, onChange: T, min: i, max: u, isDateDisabled: x, locale: U, weekStartsOn: j, today: I, name: K, form: Y, required: R, disabled: m = !1, readOnly: d = !1, size: q = "md", labels: O, className: S, style: w }) {
|
|
22
24
|
const n = {
|
|
23
|
-
...
|
|
24
|
-
...
|
|
25
|
-
},
|
|
25
|
+
...ce,
|
|
26
|
+
...O
|
|
27
|
+
}, [r, p, _] = V(P, C, T), [v, E] = se(!1), h = z(null), M = z(null), G = (e) => !(i !== void 0 && e < i) && !(u !== void 0 && e > u) && !x?.(e), $ = (e) => e === "" ? null : b(e) ? G(e) ? null : n.unavailable : n.invalid, { draft: o, setDraft: H, problem: k, setProblem: J, settle: f } = ne(h, (e) => $(s(e))), A = () => {
|
|
26
28
|
if (o === null) return;
|
|
27
|
-
const e =
|
|
29
|
+
const e = s(o);
|
|
28
30
|
if (e === "") {
|
|
29
|
-
f(
|
|
31
|
+
f(), r !== null && p(null);
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
f(
|
|
35
|
-
},
|
|
36
|
-
f(
|
|
37
|
-
},
|
|
34
|
+
const l = $(e);
|
|
35
|
+
if (l) return J(l);
|
|
36
|
+
f(), e !== r && p(e);
|
|
37
|
+
}, F = (e) => {
|
|
38
|
+
f(), e !== r && p(e);
|
|
39
|
+
}, Q = (e) => {
|
|
38
40
|
if (e.key === "Enter" && A(), e.key !== "ArrowUp" && e.key !== "ArrowDown" || d) return;
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
+
const l = o === null ? r : b(s(o)) ? s(o) : null;
|
|
42
|
+
if (!l) return;
|
|
41
43
|
e.preventDefault();
|
|
42
|
-
const B = e.key === "ArrowUp" ? 1 : -1,
|
|
43
|
-
|
|
44
|
+
const B = e.key === "ArrowUp" ? 1 : -1, D = e.shiftKey ? ee(l, B) : Z(l, B);
|
|
45
|
+
i !== void 0 && D < i || u !== void 0 && D > u || F(D);
|
|
44
46
|
};
|
|
45
|
-
return
|
|
46
|
-
v &&
|
|
47
|
-
}, [v
|
|
48
|
-
ref:
|
|
47
|
+
return ae(() => {
|
|
48
|
+
v && M.current?.querySelector('[data-date][tabindex="0"]')?.focus();
|
|
49
|
+
}, [v]), /* @__PURE__ */ ue(ie, { children: [/* @__PURE__ */ a(te, {
|
|
50
|
+
ref: h,
|
|
49
51
|
label: c,
|
|
50
52
|
...t ? { labelHidden: t } : {},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
layout: L,
|
|
54
|
+
width: N,
|
|
55
|
+
...g !== void 0 ? { description: g } : {},
|
|
56
|
+
...(y ?? k) != null ? { error: y ?? k } : {},
|
|
53
57
|
value: o ?? r ?? "",
|
|
54
|
-
onChange:
|
|
58
|
+
onChange: H,
|
|
55
59
|
onBlur: A,
|
|
56
|
-
onKeyDown:
|
|
60
|
+
onKeyDown: Q,
|
|
57
61
|
placeholder: "YYYY-MM-DD",
|
|
58
62
|
inputMode: "numeric",
|
|
59
63
|
autoComplete: "off",
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
disabled: E,
|
|
64
|
+
form: Y,
|
|
65
|
+
required: R,
|
|
66
|
+
disabled: m,
|
|
64
67
|
readOnly: d,
|
|
65
|
-
size:
|
|
68
|
+
size: q,
|
|
66
69
|
className: S ? `cy-date-field ${S}` : "cy-date-field",
|
|
67
|
-
|
|
68
|
-
addonEnd: !d && /* @__PURE__ */
|
|
70
|
+
...w ? { style: w } : {},
|
|
71
|
+
addonEnd: !d && /* @__PURE__ */ a(X, {
|
|
69
72
|
label: n.open,
|
|
70
73
|
open: v,
|
|
71
|
-
onOpenChange:
|
|
74
|
+
onOpenChange: E,
|
|
72
75
|
placement: "bottom",
|
|
73
76
|
size: "sm",
|
|
74
|
-
trigger: (e) => /* @__PURE__ */
|
|
77
|
+
trigger: (e) => /* @__PURE__ */ a(W, {
|
|
75
78
|
...e,
|
|
76
|
-
icon:
|
|
79
|
+
icon: le,
|
|
77
80
|
label: n.open,
|
|
78
81
|
variant: "ghost",
|
|
79
82
|
size: "sm",
|
|
80
|
-
disabled:
|
|
83
|
+
disabled: m,
|
|
81
84
|
className: "cy-date-field-open"
|
|
82
85
|
}),
|
|
83
|
-
children: /* @__PURE__ */
|
|
84
|
-
|
|
86
|
+
children: /* @__PURE__ */ a("div", {
|
|
87
|
+
ref: M,
|
|
85
88
|
className: "cy-date-field-calendar",
|
|
86
|
-
children: /* @__PURE__ */
|
|
87
|
-
value: o !== null && b(
|
|
89
|
+
children: /* @__PURE__ */ a(oe, {
|
|
90
|
+
value: o !== null && b(s(o)) ? s(o) : r,
|
|
88
91
|
onChange: (e) => {
|
|
89
|
-
|
|
92
|
+
F(e), E(!1), h.current?.focus();
|
|
90
93
|
},
|
|
91
|
-
min:
|
|
92
|
-
max:
|
|
93
|
-
isDateDisabled:
|
|
94
|
-
locale:
|
|
95
|
-
weekStartsOn:
|
|
96
|
-
today:
|
|
94
|
+
min: i,
|
|
95
|
+
max: u,
|
|
96
|
+
isDateDisabled: x,
|
|
97
|
+
locale: U,
|
|
98
|
+
weekStartsOn: j,
|
|
99
|
+
today: I,
|
|
97
100
|
size: "sm",
|
|
98
101
|
labels: {
|
|
99
102
|
previous: n.previous,
|
|
@@ -102,10 +105,18 @@ function de({ label: c, labelHidden: t, description: C, error: Y, value: I, defa
|
|
|
102
105
|
})
|
|
103
106
|
})
|
|
104
107
|
})
|
|
105
|
-
})
|
|
108
|
+
}), /* @__PURE__ */ a(re, {
|
|
109
|
+
name: K,
|
|
110
|
+
form: Y,
|
|
111
|
+
value: r ?? "",
|
|
112
|
+
disabled: m,
|
|
113
|
+
onReset: () => {
|
|
114
|
+
f(), _(C);
|
|
115
|
+
}
|
|
116
|
+
})] });
|
|
106
117
|
}
|
|
107
118
|
export {
|
|
108
|
-
|
|
119
|
+
xe as DateField
|
|
109
120
|
};
|
|
110
121
|
|
|
111
122
|
//# sourceMappingURL=DateField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.js","names":["useControllableState","IconButton","Popover","addDays","addMonths","isISODate","Calendar","TextField","calendar","useEffect","useId","useRef","useState","jsx","DEFAULT_LABELS","normalise","text","m","DateField","label","labelHidden","description","error","value","defaultValue","onChange","min","max","isDateDisabled","locale","weekStartsOn","today","name","form","required","disabled","readOnly","size","labels","className","style","id","current","setCurrent","draft","setDraft","problem","setProblem","open","setOpen","input","available","date","commit","typed","choose","onKeyDown","event","from","by","next","props"],"sources":["../../../src/components/DateField/DateField.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { calendar } from \"../../icons/calendar.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { Calendar } from \"../Calendar/Calendar.js\";\nimport { addDays, addMonths, isISODate } from \"../Calendar/dates.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Popover } from \"../Popover/Popover.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface DateFieldLabels {\n /** The button that opens the calendar. Default \"Choose a date\". */\n open: string;\n /** Shown when the text is not a date. Default \"Enter a date as YYYY-MM-DD\". */\n invalid: string;\n /** Shown when the date is outside `min` and `max`, or not available. Default \"This date is not available\". */\n unavailable: string;\n /** The calendar's month buttons. */\n previous: string;\n next: string;\n}\n\nexport interface DateFieldProps {\n /** Visible label; it names the field. */\n label: ReactNode;\n /** Visually hide the label (it still names the field). Prefer visible labels. */\n labelHidden?: boolean;\n /** Help text shown below the field. */\n description?: ReactNode;\n /** Your own error; it replaces the field's own messages. */\n error?: ReactNode;\n /** `YYYY-MM-DD`, or null when empty. */\n value?: string | null;\n /** Starting date when uncontrolled, as `YYYY-MM-DD`. */\n defaultValue?: string | null;\n /** A valid, available date (or null when cleared), when typing is finished or a day is picked. */\n onChange?: (date: string | null) => void;\n /** Earliest date that can be typed or picked, as `YYYY-MM-DD`. */\n min?: string | undefined;\n /** Latest date that can be typed or picked, as `YYYY-MM-DD`. */\n max?: string | undefined;\n /** Return true for dates that cannot be chosen (fully booked, weekends). */\n isDateDisabled?: ((date: string) => boolean) | undefined;\n /** The calendar's locale and first day of the week. */\n locale?: string | undefined;\n /** 0 Sunday to 6 Saturday. Default: the locale's first day, else Monday. */\n weekStartsOn?: number | undefined;\n /** What the calendar counts as today, as `YYYY-MM-DD`. Default: the device's date. */\n today?: string | undefined;\n /** Name the field's text is submitted under in a form. */\n name?: string | undefined;\n /** Id of the form it belongs to, when it is not inside that form. */\n form?: string | undefined;\n /** Marks the field as required for form validation. */\n required?: boolean | undefined;\n /** Turns off the field and the calendar button. */\n disabled?: boolean | undefined;\n /** The date can be read but not changed; the calendar button is hidden. */\n readOnly?: boolean | undefined;\n /** Size of the field. Default \"md\". */\n size?: Size;\n /** Replace the built-in English text: the calendar button, the two error messages and the month buttons. */\n labels?: Partial<DateFieldLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: DateFieldLabels = {\n open: \"Choose a date\",\n invalid: \"Enter a date as YYYY-MM-DD\",\n unavailable: \"This date is not available\",\n previous: \"Previous month\",\n next: \"Next month\",\n};\n\n/** `2026-1-5`, `2026/01/05` and `2026.1.5` all read as `2026-01-05`; anything else is left as it was typed. */\nconst normalise = (text: string) => {\n const m = /^\\s*(\\d{4})[-/.](\\d{1,2})[-/.](\\d{1,2})\\s*$/.exec(text);\n return m\n ? `${m[1]}-${(m[2] as string).padStart(2, \"0\")}-${(m[3] as string).padStart(2, \"0\")}`\n : text.trim();\n};\n\n/**\n * A date in a form: type it as `YYYY-MM-DD`, step it with the arrows, or pick it from a Calendar in a popover. The\n * value is a plain date string (no time, no time zone) and is only reported once it is a real, available date.\n */\nexport function DateField({\n label,\n labelHidden,\n description,\n error,\n value,\n defaultValue = null,\n onChange,\n min,\n max,\n isDateDisabled,\n locale,\n weekStartsOn,\n today,\n name,\n form,\n required,\n disabled = false,\n readOnly = false,\n size = \"md\",\n labels,\n className,\n style,\n}: DateFieldProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const id = useId();\n const [current, setCurrent] = useControllableState<string | null>(value, defaultValue, onChange);\n const [draft, setDraft] = useState<string | null>(null);\n const [problem, setProblem] = useState<string | null>(null);\n const [open, setOpen] = useState(false);\n const input = useRef<HTMLInputElement>(null);\n\n const available = (date: string) =>\n !(min !== undefined && date < min) && !(max !== undefined && date > max) && !isDateDisabled?.(date);\n /** Takes what was typed: a real, available date is kept; anything else is explained and left for correcting. */\n const commit = () => {\n if (draft === null) return;\n const typed = normalise(draft);\n if (typed === \"\") {\n setDraft(null);\n setProblem(null);\n if (current !== null) setCurrent(null);\n return;\n }\n if (!isISODate(typed)) return setProblem(text.invalid);\n if (!available(typed)) return setProblem(text.unavailable);\n setDraft(null);\n setProblem(null);\n if (typed !== current) setCurrent(typed);\n };\n const choose = (date: string) => {\n setDraft(null);\n setProblem(null);\n if (date !== current) setCurrent(date);\n };\n\n // Up and Down step the date by a day (Shift: a month), skipping nothing: limits stop it.\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\") commit();\n if ((event.key !== \"ArrowUp\" && event.key !== \"ArrowDown\") || readOnly) return;\n const from = draft === null ? current : isISODate(normalise(draft)) ? normalise(draft) : null;\n if (!from) return;\n event.preventDefault();\n const by = event.key === \"ArrowUp\" ? 1 : -1;\n const next = event.shiftKey ? addMonths(from, by) : addDays(from, by);\n if ((min !== undefined && next < min) || (max !== undefined && next > max)) return;\n choose(next);\n };\n\n // The picker opens on the chosen day (the APG date picker), not on its first button.\n useEffect(() => {\n if (!open) return;\n document\n .getElementById(`${id}-calendar`)\n ?.querySelector<HTMLElement>('[data-date][tabindex=\"0\"]')\n ?.focus();\n }, [open, id]);\n\n return (\n <TextField\n ref={input}\n label={label}\n {...(labelHidden ? { labelHidden } : {})}\n {...(description !== undefined ? { description } : {})}\n {...((error ?? problem) != null ? { error: error ?? problem } : {})}\n value={draft ?? current ?? \"\"}\n onChange={setDraft}\n onBlur={commit}\n onKeyDown={onKeyDown}\n placeholder=\"YYYY-MM-DD\"\n inputMode=\"numeric\"\n autoComplete=\"off\"\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n size={size}\n className={className ? `cy-date-field ${className}` : \"cy-date-field\"}\n {...(style ? { style } : {})}\n addonEnd={\n !readOnly && (\n <Popover\n label={text.open}\n open={open}\n onOpenChange={setOpen}\n placement=\"bottom\"\n size=\"sm\"\n trigger={(props) => (\n <IconButton\n {...props}\n icon={calendar}\n label={text.open}\n variant=\"ghost\"\n size=\"sm\"\n disabled={disabled}\n className=\"cy-date-field-open\"\n />\n )}\n >\n <div id={`${id}-calendar`} className=\"cy-date-field-calendar\">\n <Calendar\n value={draft !== null && isISODate(normalise(draft)) ? normalise(draft) : current}\n onChange={(date) => {\n choose(date);\n setOpen(false);\n input.current?.focus();\n }}\n min={min}\n max={max}\n isDateDisabled={isDateDisabled}\n locale={locale}\n weekStartsOn={weekStartsOn}\n today={today}\n size=\"sm\"\n labels={{ previous: text.previous, next: text.next }}\n />\n </div>\n </Popover>\n )\n }\n />\n );\n}\n"],"mappings":";;;;;;;;;;AA6EA,IAAMc,KAAkC;AAAA,EACtC,MAAM;AAAA,EACN,SAA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K;AAAA,UACL,QAAQ;AAAA,YAAE,UAAUf,EAAK;AAAA,YAAU,MAAMA,EAAK;AAAA,UAAK;AAAA,QACpD,CAAA;AAAA,MACE,CAAA;AAAA,IACE,CAAA;AAAA,EAGd,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"DateField.js","names":["_Fragment","useControllableState","IconButton","Popover","addDays","addMonths","isISODate","Calendar","TextField","HiddenValue","useDraft","calendar","useEffect","useRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","normalise","text","m","DateField","label","labelHidden","layout","width","description","error","value","defaultValue","onChange","min","max","isDateDisabled","locale","weekStartsOn","today","name","form","required","disabled","readOnly","size","labels","className","style","current","setCurrent","resetCurrent","open","setOpen","input","calendarBox","available","date","check","typed","draft","setDraft","problem","setProblem","settle","commit","wrong","choose","onKeyDown","event","from","by","next","props"],"sources":["../../../src/components/DateField/DateField.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDraft } from \"../../foundations/draft.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { calendar } from \"../../icons/calendar.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { Calendar } from \"../Calendar/Calendar.js\";\nimport { addDays, addMonths, isISODate } from \"../Calendar/dates.js\";\nimport type { FieldLayoutProps } from \"../Field/Field.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Popover } from \"../Popover/Popover.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface DateFieldLabels {\n /** The button that opens the calendar. Default \"Choose a date\". */\n open: string;\n /** Shown when the text is not a date. Default \"Enter a date as YYYY-MM-DD\". */\n invalid: string;\n /** Shown when the date is outside `min` and `max`, or not available. Default \"This date is not available\". */\n unavailable: string;\n /** The calendar's month buttons. */\n previous: string;\n next: string;\n}\n\nexport interface DateFieldProps extends FieldLayoutProps {\n /** Visible label; it names the field. */\n label: ReactNode;\n /** Visually hide the label (it still names the field). Prefer visible labels. */\n labelHidden?: boolean;\n /** Help text shown below the field. */\n description?: ReactNode;\n /** Your own error; it replaces the field's own messages. */\n error?: ReactNode;\n /** `YYYY-MM-DD`, or null when empty. */\n value?: string | null;\n /** Starting date when uncontrolled, as `YYYY-MM-DD`. */\n defaultValue?: string | null;\n /** A valid, available date (or null when cleared), when typing is finished or a day is picked. */\n onChange?: (date: string | null) => void;\n /** Earliest date that can be typed or picked, as `YYYY-MM-DD`. */\n min?: string | undefined;\n /** Latest date that can be typed or picked, as `YYYY-MM-DD`. */\n max?: string | undefined;\n /** Return true for dates that cannot be chosen (fully booked, weekends). */\n isDateDisabled?: ((date: string) => boolean) | undefined;\n /** The calendar's locale and first day of the week. */\n locale?: string | undefined;\n /** 0 Sunday to 6 Saturday. Default: the locale's first day, else Monday. */\n weekStartsOn?: number | undefined;\n /** What the calendar counts as today, as `YYYY-MM-DD`. Default: the device's date. */\n today?: string | undefined;\n /** Name the date (`YYYY-MM-DD`, or empty) is submitted under in a form; text being typed is never submitted. */\n name?: string | undefined;\n /** Id of the form it belongs to, when it is not inside that form. */\n form?: string | undefined;\n /** Marks the field as required for form validation. */\n required?: boolean | undefined;\n /** Turns off the field and the calendar button. */\n disabled?: boolean | undefined;\n /** The date can be read but not changed; the calendar button is hidden. */\n readOnly?: boolean | undefined;\n /** Size of the field. Default \"md\". */\n size?: Size;\n /** Replace the built-in English text: the calendar button, the two error messages and the month buttons. */\n labels?: Partial<DateFieldLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: DateFieldLabels = {\n open: \"Choose a date\",\n invalid: \"Enter a date as YYYY-MM-DD\",\n unavailable: \"This date is not available\",\n previous: \"Previous month\",\n next: \"Next month\",\n};\n\n/** `2026-1-5`, `2026/01/05` and `2026.1.5` all read as `2026-01-05`; anything else is left as it was typed. */\nconst normalise = (text: string) => {\n const m = /^\\s*(\\d{4})[-/.](\\d{1,2})[-/.](\\d{1,2})\\s*$/.exec(text);\n return m\n ? `${m[1]}-${(m[2] as string).padStart(2, \"0\")}-${(m[3] as string).padStart(2, \"0\")}`\n : text.trim();\n};\n\n/**\n * A date in a form: type it as `YYYY-MM-DD`, step it with the arrows, or pick it from a Calendar in a popover. The\n * value is a plain date string (no time, no time zone) and is only reported once it is a real, available date.\n */\nexport function DateField({\n label,\n labelHidden,\n layout,\n width,\n description,\n error,\n value,\n defaultValue = null,\n onChange,\n min,\n max,\n isDateDisabled,\n locale,\n weekStartsOn,\n today,\n name,\n form,\n required,\n disabled = false,\n readOnly = false,\n size = \"md\",\n labels,\n className,\n style,\n}: DateFieldProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [current, setCurrent, resetCurrent] = useControllableState<string | null>(\n value,\n defaultValue,\n onChange,\n );\n const [open, setOpen] = useState(false);\n const input = useRef<HTMLInputElement>(null);\n const calendarBox = useRef<HTMLDivElement>(null);\n\n const available = (date: string) =>\n !(min !== undefined && date < min) && !(max !== undefined && date > max) && !isDateDisabled?.(date);\n /** What is wrong with typed text (already normalised), or null when it is empty or a real, available date. */\n const check = (typed: string) =>\n typed === \"\" ? null : !isISODate(typed) ? text.invalid : !available(typed) ? text.unavailable : null;\n // A form will not submit while the text is not a date it can take (the value it would submit is the last good one).\n const { draft, setDraft, problem, setProblem, settle } = useDraft(input, (typed) =>\n check(normalise(typed)),\n );\n /** Takes what was typed: a real, available date is kept; anything else is explained and left for correcting. */\n const commit = () => {\n if (draft === null) return;\n const typed = normalise(draft);\n if (typed === \"\") {\n settle();\n if (current !== null) setCurrent(null);\n return;\n }\n const wrong = check(typed);\n if (wrong) return setProblem(wrong);\n settle();\n if (typed !== current) setCurrent(typed);\n };\n const choose = (date: string) => {\n settle();\n if (date !== current) setCurrent(date);\n };\n\n // Up and Down step the date by a day (Shift: a month), skipping nothing: limits stop it.\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\") commit();\n if ((event.key !== \"ArrowUp\" && event.key !== \"ArrowDown\") || readOnly) return;\n const from = draft === null ? current : isISODate(normalise(draft)) ? normalise(draft) : null;\n if (!from) return;\n event.preventDefault();\n const by = event.key === \"ArrowUp\" ? 1 : -1;\n const next = event.shiftKey ? addMonths(from, by) : addDays(from, by);\n if ((min !== undefined && next < min) || (max !== undefined && next > max)) return;\n choose(next);\n };\n\n // The picker opens on the chosen day (the APG date picker), not on its first button. A ref, not an id lookup, so it\n // works inside a shadow root.\n useEffect(() => {\n if (!open) return;\n calendarBox.current?.querySelector<HTMLElement>('[data-date][tabindex=\"0\"]')?.focus();\n }, [open]);\n\n return (\n <>\n <TextField\n ref={input}\n label={label}\n {...(labelHidden ? { labelHidden } : {})}\n layout={layout}\n width={width}\n {...(description !== undefined ? { description } : {})}\n {...((error ?? problem) != null ? { error: error ?? problem } : {})}\n value={draft ?? current ?? \"\"}\n onChange={setDraft}\n onBlur={commit}\n onKeyDown={onKeyDown}\n placeholder=\"YYYY-MM-DD\"\n inputMode=\"numeric\"\n autoComplete=\"off\"\n form={form}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n size={size}\n className={className ? `cy-date-field ${className}` : \"cy-date-field\"}\n {...(style ? { style } : {})}\n addonEnd={\n !readOnly && (\n <Popover\n label={text.open}\n open={open}\n onOpenChange={setOpen}\n placement=\"bottom\"\n size=\"sm\"\n trigger={(props) => (\n <IconButton\n {...props}\n icon={calendar}\n label={text.open}\n variant=\"ghost\"\n size=\"sm\"\n disabled={disabled}\n className=\"cy-date-field-open\"\n />\n )}\n >\n <div ref={calendarBox} className=\"cy-date-field-calendar\">\n <Calendar\n value={draft !== null && isISODate(normalise(draft)) ? normalise(draft) : current}\n onChange={(date) => {\n choose(date);\n setOpen(false);\n input.current?.focus();\n }}\n min={min}\n max={max}\n isDateDisabled={isDateDisabled}\n locale={locale}\n weekStartsOn={weekStartsOn}\n today={today}\n size=\"sm\"\n labels={{ previous: text.previous, next: text.next }}\n />\n </div>\n </Popover>\n )\n }\n />\n <HiddenValue\n name={name}\n form={form}\n value={current ?? \"\"}\n disabled={disabled}\n onReset={() => {\n settle();\n resetCurrent(defaultValue);\n }}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAwEA,IAAMkB,KAAkC;AAAA,EACtC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AAAA,EACV,MAAM;AACR,GAGMC,IAAA,CAAaC,MAAiB;AAClC,QAAMC,IAAI,8CAA8C,KAAKD,CAAI;AACjE,SAAOC,IACH,GAAGA,EAAE,CAAA,CAAA,IAAOA,EAAE,CAAA,EAAc,SAAS,GAAG,GAAG,CAAA,IAAMA,EAAE,CAAA,EAAc,SAAS,GAAG,GAAG,CAAA,KAChFD,EAAK,KAAK;AAChB;AAMA,SAAgBE,GAAU,EACxB,OAAAC,GACA,aAAAC,GACA,QAAAC,GACA,OAAAC,GACA,aAAAC,GACA,OAAAC,GACA,OAAAC,GACA,cAAAC,IAAe,MACf,UAAAC,GACA,KAAAC,GACA,KAAAC,GACA,gBAAAC,GACA,QAAAC,GACA,cAAAC,GACA,OAAAC,GACA,MAAAC,GACA,MAAAC,GACA,UAAAC,GACA,UAAAC,IAAW,IACX,UAAAC,IAAW,IACX,MAAAC,IAAO,MACP,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACiB;AACjB,QAAM1B,IAAO;AAAA,IAAE,GAAGF;AAAA,IAAgB,GAAG0B;AAAA,EAAO,GACtC,CAACG,GAASC,GAAYC,CAAA,IAAgBhD,EAC1C4B,GACAC,GACAC,CACF,GACM,CAACmB,GAAMC,CAAA,IAAWrC,GAAS,EAAK,GAChCsC,IAAQvC,EAAyB,IAAI,GACrCwC,IAAcxC,EAAuB,IAAI,GAEzCyC,IAAA,CAAaC,MACjB,EAAEvB,MAAQ,UAAauB,IAAOvB,MAAQ,EAAEC,MAAQ,UAAasB,IAAOtB,MAAQ,CAACC,I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UACE,OAAOmD,MAAU,QAAQpD,EAAUa,EAAUuC,CAAK,CAAC,IAAIvC,EAAUuC,CAAK,IAAIX;AAAA,UAC1E,UAAA,CAAWQ,MAAS;AAClB,YAAAU,EAAOV,CAAI,GACXJ,EAAQ,EAAK,GACbC,EAAM,SAAS,MAAM;AAAA,UACvB;AAAA,UACK,KAAApB;AAAA,UACA,KAAAC;AAAA,UACW,gBAAAC;AAAA,UACR,QAAAC;AAAA,UACM,cAAAC;AAAA,UACP,OAAAC;AAAA,UACP,MAAK;AAAA,UACL,QAAQ;AAAA,YAAE,UAAUjB,EAAK;AAAA,YAAU,MAAMA,EAAK;AAAA,UAAK;AAAA,QACpD,CAAA;AAAA,MACE,CAAA;AAAA,IACE,CAAA;AAAA,EAGd,CAAA,GACD,gBAAAJ,EAACP,IAAD;AAAA,IACQ,MAAA6B;AAAA,IACA,MAAAC;AAAA,IACN,OAAOQ,KAAW;AAAA,IACR,UAAAN;AAAA,IACV,SAAA,MAAe;AACb,MAAAqB,EAAO,GACPb,EAAanB,CAAY;AAAA,IAC3B;AAAA,EACD,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -1,92 +1,88 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useControllableState as
|
|
3
|
-
import { useClientLayoutEffect as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { useControllableState as R } from "../../foundations/controllable.js";
|
|
3
|
+
import { useClientLayoutEffect as b } from "../../foundations/client-layout-effect.js";
|
|
4
|
+
import { deepActiveElement as U } from "../../foundations/focus.js";
|
|
5
|
+
import { useDismiss as V } from "../../overlay/dismiss.js";
|
|
6
|
+
import { IconButton as _ } from "../IconButton/IconButton.js";
|
|
7
|
+
import { DialogBase as G } from "../../foundations/DialogBase/DialogBase.js";
|
|
8
|
+
import { transitionTime as J } from "../../foundations/motion.js";
|
|
7
9
|
import { close as K } from "../../icons/close.js";
|
|
8
|
-
import { ToastHostContext as
|
|
9
|
-
import { useContext as
|
|
10
|
-
import { jsx as
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
import { ToastHostContext as M } from "../../overlay/toast-host.js";
|
|
11
|
+
import { useContext as Q, useEffect as W, useId as X, useRef as s, useState as Y } from "react";
|
|
12
|
+
import { jsx as r, jsxs as v } from "react/jsx-runtime";
|
|
13
|
+
var Z = { close: "Close" }, D = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]):not([aria-hidden="true"]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
14
|
+
function ee(t) {
|
|
15
|
+
if (!t) return null;
|
|
16
|
+
const n = t.closest("[popover][id]");
|
|
17
|
+
if (!(n ? !n.matches(":popover-open") : t.checkVisibility?.() === !1)) return t;
|
|
18
|
+
const f = t.getRootNode();
|
|
19
|
+
return (n && f.querySelector(`[aria-controls="${CSS.escape(n.id)}"]`)) ?? t;
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const w = () => {
|
|
32
|
-
x && y(!1);
|
|
33
|
-
}, [u, D] = Z(t);
|
|
34
|
-
t && !u && D(!0), X(() => {
|
|
35
|
-
if (t || !u) return;
|
|
36
|
-
const o = a.current, L = () => D(!1), $ = getComputedStyle(o), F = (v) => Math.max(...v.split(",").map((V) => Number.parseFloat(V))), B = (F($.transitionDuration) + F($.transitionDelay)) * 1e3, T = (v) => {
|
|
37
|
-
v.target === o && L();
|
|
21
|
+
function te({ open: t, defaultOpen: n = !1, onOpenChange: f, title: F, description: p, actions: h, size: w = "md", dismissible: C = !0, keepMounted: A = !1, labels: I, side: O, parts: i, className: j, style: k, children: q }) {
|
|
22
|
+
const a = X(), P = {
|
|
23
|
+
...Z,
|
|
24
|
+
...I
|
|
25
|
+
}, [e, y] = R(t, n, f), c = s(null), l = Q(M), g = s(null), S = s(null), x = s(null), d = s(null), N = s(!1);
|
|
26
|
+
e && !N.current && (d.current = U()), N.current = e;
|
|
27
|
+
const E = () => {
|
|
28
|
+
C && y(!1);
|
|
29
|
+
}, [u, L] = Y(e);
|
|
30
|
+
e && !u && L(!0), W(() => {
|
|
31
|
+
if (e || !u) return;
|
|
32
|
+
const o = c.current, $ = () => L(!1), T = J(getComputedStyle(o)), B = (H) => {
|
|
33
|
+
H.target === o && $();
|
|
38
34
|
};
|
|
39
|
-
o.addEventListener("transitionend",
|
|
40
|
-
const
|
|
35
|
+
o.addEventListener("transitionend", B);
|
|
36
|
+
const z = setTimeout($, T && T + 100);
|
|
41
37
|
return () => {
|
|
42
|
-
o.removeEventListener("transitionend",
|
|
38
|
+
o.removeEventListener("transitionend", B), clearTimeout(z);
|
|
43
39
|
};
|
|
44
|
-
}, [
|
|
45
|
-
const m =
|
|
46
|
-
return
|
|
47
|
-
if (!(!
|
|
40
|
+
}, [e, u]);
|
|
41
|
+
const m = e || u || A;
|
|
42
|
+
return b(() => {
|
|
43
|
+
if (!(!e || !l || !g.current))
|
|
48
44
|
return l.register(g.current);
|
|
49
|
-
}, [
|
|
50
|
-
if (
|
|
45
|
+
}, [e, l]), b(() => {
|
|
46
|
+
if (e)
|
|
51
47
|
return () => {
|
|
52
|
-
d.current =
|
|
48
|
+
d.current = ee(d.current);
|
|
53
49
|
};
|
|
54
|
-
}, [
|
|
55
|
-
|
|
56
|
-
}, [
|
|
57
|
-
open:
|
|
58
|
-
onClose:
|
|
59
|
-
inside: [
|
|
50
|
+
}, [e]), b(() => {
|
|
51
|
+
e && (S.current?.querySelector(D) ?? x.current?.querySelector(D) ?? c.current)?.focus({ preventScroll: !0 });
|
|
52
|
+
}, [e]), V({
|
|
53
|
+
open: e,
|
|
54
|
+
onClose: E,
|
|
55
|
+
inside: [c],
|
|
60
56
|
returnFocus: d,
|
|
61
|
-
outside: (o) => o.composedPath()[0] ===
|
|
62
|
-
}), /* @__PURE__ */
|
|
63
|
-
ref:
|
|
64
|
-
open:
|
|
65
|
-
onCancel:
|
|
57
|
+
outside: (o) => o.composedPath()[0] === c.current
|
|
58
|
+
}), /* @__PURE__ */ v(G, {
|
|
59
|
+
ref: c,
|
|
60
|
+
open: e,
|
|
61
|
+
onCancel: E,
|
|
66
62
|
onClose: () => y(!1),
|
|
67
63
|
className: i ? `cy-dialog ${i.root}` : "cy-dialog",
|
|
68
64
|
tabIndex: -1,
|
|
69
|
-
"data-size":
|
|
70
|
-
"data-side":
|
|
71
|
-
"aria-labelledby": m ? `${
|
|
72
|
-
"aria-describedby": m && p ? `${
|
|
73
|
-
children: [m && /* @__PURE__ */
|
|
65
|
+
"data-size": w,
|
|
66
|
+
"data-side": O,
|
|
67
|
+
"aria-labelledby": m ? `${a}-title` : void 0,
|
|
68
|
+
"aria-describedby": m && p ? `${a}-description` : void 0,
|
|
69
|
+
children: [m && /* @__PURE__ */ v("div", {
|
|
74
70
|
className: [
|
|
75
71
|
"cy-dialog-panel cy-reset",
|
|
76
72
|
i?.panel,
|
|
77
|
-
|
|
73
|
+
j
|
|
78
74
|
].filter(Boolean).join(" "),
|
|
79
|
-
style:
|
|
75
|
+
style: k,
|
|
80
76
|
children: [
|
|
81
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ v("div", {
|
|
82
78
|
className: "cy-dialog-header cy-reset",
|
|
83
|
-
children: [/* @__PURE__ */
|
|
84
|
-
id: `${
|
|
79
|
+
children: [/* @__PURE__ */ r("h2", {
|
|
80
|
+
id: `${a}-title`,
|
|
85
81
|
className: "cy-dialog-title cy-reset",
|
|
86
|
-
children:
|
|
87
|
-
}),
|
|
82
|
+
children: F
|
|
83
|
+
}), C && /* @__PURE__ */ r(_, {
|
|
88
84
|
icon: K,
|
|
89
|
-
label:
|
|
85
|
+
label: P.close,
|
|
90
86
|
variant: "ghost",
|
|
91
87
|
size: "sm",
|
|
92
88
|
tooltipPlacement: "bottom",
|
|
@@ -94,35 +90,35 @@ function ne({ open: e, defaultOpen: r = !1, onOpenChange: f, title: I, descripti
|
|
|
94
90
|
onClick: () => y(!1)
|
|
95
91
|
})]
|
|
96
92
|
}),
|
|
97
|
-
p && /* @__PURE__ */
|
|
98
|
-
id: `${
|
|
93
|
+
p && /* @__PURE__ */ r("p", {
|
|
94
|
+
id: `${a}-description`,
|
|
99
95
|
className: "cy-dialog-description cy-reset",
|
|
100
96
|
children: p
|
|
101
97
|
}),
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
ref:
|
|
98
|
+
/* @__PURE__ */ r("div", {
|
|
99
|
+
ref: S,
|
|
104
100
|
className: "cy-dialog-body cy-reset",
|
|
105
101
|
onFocus: (o) => o.target.scrollIntoView({ block: "nearest" }),
|
|
106
|
-
children:
|
|
102
|
+
children: q
|
|
107
103
|
}),
|
|
108
|
-
|
|
109
|
-
ref:
|
|
104
|
+
h && /* @__PURE__ */ r("div", {
|
|
105
|
+
ref: x,
|
|
110
106
|
className: i ? `cy-dialog-actions cy-reset ${i.actions}` : "cy-dialog-actions cy-reset",
|
|
111
|
-
children:
|
|
107
|
+
children: h
|
|
112
108
|
})
|
|
113
109
|
]
|
|
114
|
-
}), l && m && /* @__PURE__ */
|
|
110
|
+
}), l && m && /* @__PURE__ */ r("div", {
|
|
115
111
|
ref: g,
|
|
116
112
|
className: "cy-dialog-toasts"
|
|
117
113
|
})]
|
|
118
114
|
});
|
|
119
115
|
}
|
|
120
|
-
function fe(
|
|
121
|
-
return /* @__PURE__ */
|
|
116
|
+
function fe(t) {
|
|
117
|
+
return /* @__PURE__ */ r(te, { ...t });
|
|
122
118
|
}
|
|
123
119
|
export {
|
|
124
120
|
fe as Dialog,
|
|
125
|
-
|
|
121
|
+
te as DialogFrame
|
|
126
122
|
};
|
|
127
123
|
|
|
128
124
|
//# sourceMappingURL=Dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["closeIcon","useControllableState","useClientLayoutEffect","useDismiss","IconButton","DialogBase","close","ToastHostContext","useContext","useEffect","useId","useRef","useState","jsx","jsxs","DEFAULT_LABELS","FOCUSABLE","deepActive","active","reachable","el","popover","root","DialogFrame","open","defaultOpen","onOpenChange","title","description","actions","size","dismissible","keepMounted","labels","side","parts","className","style","children","id","text","isOpen","setOpen","dialog","toastHost","toasts","body","footer","returnTo","wasOpen","dismiss","present","setPresent","unmount","longest","times","time","wait","ended","event","timer","mounted","Dialog","props"],"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useContext, useEffect, useId, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { DialogBase } from \"../../foundations/DialogBase/DialogBase.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { ToastHostContext } from \"../../overlay/toast-host.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface DialogTokens {\n radius: string;\n padding: string;\n widthSm: string;\n widthMd: string;\n widthLg: string;\n scrim: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n dialog: DialogTokens;\n }\n}\n\nexport interface DialogLabels {\n /** Accessible name of the close button. */\n close: string;\n}\n\nexport interface DialogProps {\n /** Whether the dialog is open, when you control it. */\n open?: boolean;\n /** Open on first render when uncontrolled. */\n defaultOpen?: boolean;\n /** Called with `false` when the dialog closes itself: Escape, the backdrop or the close button. */\n onOpenChange?: (open: boolean) => void;\n /** Heading of the dialog; also its accessible name. */\n title: ReactNode;\n /** One or two sentences under the title; also its accessible description. */\n description?: ReactNode;\n /** Buttons along the bottom, outside the scrolling content (Cancel first, then the main action). */\n actions?: ReactNode;\n /** Width preset (the panel never grows wider than its container). */\n size?: Size;\n /** Escape, the backdrop and the close button close it (default). `false` leaves only your actions. */\n dismissible?: boolean;\n /**\n * Keep the content in the DOM while the dialog is closed. By default a closed dialog renders nothing inside it: the\n * content mounts when it opens and unmounts once the closing transition has ended, so every opening starts fresh.\n * Set it for content whose state must survive closing (a half-filled form) or that is expensive to rebuild.\n * Default false.\n */\n keepMounted?: boolean;\n /** Replace the built-in English text: the close button's name. */\n labels?: Partial<DialogLabels>;\n /** Added to the panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. Restyle through --cy-dialog-* tokens. */\n style?: CSSProperties;\n /** The content; it scrolls when it is taller than the dialog. */\n children?: ReactNode;\n}\n\n/** Internal: a Sheet is the same dialog docked to an edge. */\nexport interface DialogFrameProps extends DialogProps {\n side?: \"bottom\" | \"end\" | \"start\";\n /**\n * Classes of the component built on the frame (Sheet), added to the dialog, the panel and the actions, so that\n * component draws its own look in its own stylesheet.\n */\n parts?: { root: string; panel: string; actions: string };\n}\n\nconst DEFAULT_LABELS: DialogLabels = { close: \"Close\" };\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** The focused element, looking inside shadow roots (document.activeElement stops at the host). */\nfunction deepActive(): HTMLElement | null {\n if (typeof document === \"undefined\") return null; // server render\n let active = document.activeElement;\n while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n return active as HTMLElement | null;\n}\n\n/**\n * Where focus can actually go back to. A Dialog opened from a Menu item remembers that item, but the menu has closed\n * (hidden, still in the DOM): fall back to the button that controls the hidden popover.\n */\nfunction reachable(el: HTMLElement | null): HTMLElement | null {\n if (!el) return null;\n // A closed popover can still be fading out (displayed), so ask the popover, not only the layout.\n const popover = el.closest<HTMLElement>(\"[popover][id]\");\n const closed = popover ? !popover.matches(\":popover-open\") : el.checkVisibility?.() === false;\n if (!closed) return el;\n const root = el.getRootNode() as Document | ShadowRoot;\n return (popover && root.querySelector<HTMLElement>(`[aria-controls=\"${CSS.escape(popover.id)}\"]`)) ?? el;\n}\n\nexport function DialogFrame({\n open,\n defaultOpen = false,\n onOpenChange,\n title,\n description,\n actions,\n size = \"md\",\n dismissible = true,\n keepMounted = false,\n labels,\n side,\n parts,\n className,\n style,\n children,\n}: DialogFrameProps) {\n const id = useId();\n const text = { ...DEFAULT_LABELS, ...labels };\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const dialog = useRef<HTMLDialogElement>(null);\n const toastHost = useContext(ToastHostContext);\n const toasts = useRef<HTMLDivElement>(null);\n const body = useRef<HTMLDivElement>(null);\n const footer = useRef<HTMLDivElement>(null);\n const returnTo = useRef<HTMLElement | null>(null);\n const wasOpen = useRef(false);\n // Where focus was before opening: read while rendering, because DialogBase's showModal moves it first.\n if (isOpen && !wasOpen.current) returnTo.current = deepActive();\n wasOpen.current = isOpen;\n const dismiss = () => {\n if (dismissible) setOpen(false);\n };\n\n // The content is rendered while open, and after closing until the closing transition has ended. `present` goes true\n // in the render that opens the dialog, so the content is there before DialogBase shows it (no empty first frame).\n const [present, setPresent] = useState(isOpen);\n if (isOpen && !present) setPresent(true);\n useEffect(() => {\n if (isOpen || !present) return;\n const el = dialog.current as HTMLDialogElement;\n const unmount = () => setPresent(false);\n // Unmount when the dialog's own closing transition ends. The timer covers a transition that never reports back\n // (interrupted, or the dialog is not rendered) and is the whole wait when there is none: reduced motion, or no\n // stylesheet.\n const style = getComputedStyle(el);\n const longest = (times: string) => Math.max(...times.split(\",\").map((time) => Number.parseFloat(time)));\n const wait = (longest(style.transitionDuration) + longest(style.transitionDelay)) * 1000;\n const ended = (event: Event) => {\n if (event.target === el) unmount();\n };\n el.addEventListener(\"transitionend\", ended);\n const timer = setTimeout(unmount, wait && wait + 100);\n return () => {\n el.removeEventListener(\"transitionend\", ended);\n clearTimeout(timer);\n };\n }, [isOpen, present]);\n const mounted = isOpen || present || keepMounted;\n\n // On close, before useDismiss returns focus: make sure the remembered element can still take it.\n // Inside a Toaster, lend it a container while open: toasts raised now show above this dialog instead of under its\n // scrim, where the modal would make them inert. Runs after DialogBase has called showModal.\n useClientLayoutEffect(() => {\n if (!isOpen || !toastHost || !toasts.current) return;\n return toastHost.register(toasts.current);\n }, [isOpen, toastHost]);\n\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n return () => {\n returnTo.current = reachable(returnTo.current);\n };\n }, [isOpen]);\n\n // DialogBase has opened it; move focus to the first control in the content, else the first action, else the\n // dialog itself (so the close button's tooltip does not pop up on open).\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n const first =\n body.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n footer.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n dialog.current;\n first?.focus({ preventScroll: true });\n }, [isOpen]);\n\n useDismiss({\n open: isOpen,\n onClose: dismiss,\n inside: [dialog],\n returnFocus: returnTo,\n // The dialog fills its container; a pointer down on the dialog itself (not the panel) is on the backdrop.\n outside: (event) => event.composedPath()[0] === dialog.current,\n });\n\n return (\n <DialogBase\n ref={dialog}\n open={isOpen}\n onCancel={dismiss}\n onClose={() => setOpen(false)}\n className={parts ? `cy-dialog ${parts.root}` : \"cy-dialog\"}\n tabIndex={-1}\n data-size={size}\n data-side={side}\n aria-labelledby={mounted ? `${id}-title` : undefined}\n aria-describedby={mounted && description ? `${id}-description` : undefined}\n >\n {mounted && (\n <div\n className={[\"cy-dialog-panel cy-reset\", parts?.panel, className].filter(Boolean).join(\" \")}\n style={style}\n >\n <div className=\"cy-dialog-header cy-reset\">\n <h2 id={`${id}-title`} className=\"cy-dialog-title cy-reset\">\n {title}\n </h2>\n {dismissible && (\n <IconButton\n icon={closeIcon}\n label={text.close}\n variant=\"ghost\"\n size=\"sm\"\n tooltipPlacement=\"bottom\"\n wrapperClassName=\"cy-dialog-close\"\n onClick={() => setOpen(false)}\n />\n )}\n </div>\n {description && (\n <p id={`${id}-description`} className=\"cy-dialog-description cy-reset\">\n {description}\n </p>\n )}\n {/* biome-ignore lint/a11y/noStaticElementInteractions: delegated focus listener for the controls inside */}\n <div\n ref={body}\n className=\"cy-dialog-body cy-reset\"\n // A focused field low in the content (Tab, or the on-screen keyboard opening) is brought fully into view.\n onFocus={(event) => event.target.scrollIntoView({ block: \"nearest\" })}\n >\n {children}\n </div>\n {actions && (\n <div\n ref={footer}\n className={parts ? `cy-dialog-actions cy-reset ${parts.actions}` : \"cy-dialog-actions cy-reset\"}\n >\n {actions}\n </div>\n )}\n </div>\n )}\n {toastHost && mounted && <div ref={toasts} className=\"cy-dialog-toasts\" />}\n </DialogBase>\n );\n}\n\n/**\n * Modal dialog in the top layer: focus moves in, stays in and comes back; Escape, the backdrop and the close button\n * dismiss it. In a container narrower than about 36rem it becomes a bottom sheet. Its content is mounted only while\n * it is open (and while it closes), unless `keepMounted`.\n */\nexport function Dialog(props: DialogProps) {\n return <DialogFrame {...props} />;\n}\n"],"mappings":";;;;;;;;;;AA0EA,IAAMe,KAA+B,EAAE,OAAO,QAAQ,GAChDC,IACJ;AAGF,SAASC,KAAiC;AACxC,MAAI,OAAO,WAAa,IAAa,QAAO;AAC5C,MAAIC,IAAS,SAAS;AACtB,SAAOA,GAAQ,YAAY,gBAAe,CAAAA,IAASA,EAAO,WAAW;AACrE,SAAOA;AACT;AAMA,SAASC,GAAUC,GAA4C;AAC7D,MAAI,CAACA,EAAI,QAAO;AAEhB,QAAMC,IAAUD,EAAG,QAAqB,eAAe;AAEvD,MAAI,EADWC,IAAU,CAACA,EAAQ,QAAQ,eAAe,IAAID,EAAG,kBAAkB,MAAM,IAC3E,QAAOA;AACpB,QAAME,IAAOF,EAAG,YAAY;AAC5B,UAAQC,KAAWC,EAAK,cAA2B,mBAAmB,IAAI,OAAOD,EAAQ,EAAE,CAAA,IAAK,MAAMD;AACxG;AAEA,SAAgBG,GAAY,EAC1B,MAAAC,GACA,aAAAC,IAAc,IACd,cAAAC,GACA,OAAAC,GACA,aAAAC,GAC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CAC/D;AAAA,E;AAEhB;AAOA,SAAgBiB,GAAOC,GAAoB;AACzC,SAAO,gBAAAlD,EAACU,IAAD,EAAa,GAAIwC,EAAQ,CAAA;AAClC"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["closeIcon","useControllableState","useClientLayoutEffect","deepActiveElement","useDismiss","IconButton","DialogBase","transitionTime","close","ToastHostContext","useContext","useEffect","useId","useRef","useState","jsx","jsxs","DEFAULT_LABELS","FOCUSABLE","reachable","el","popover","root","DialogFrame","open","defaultOpen","onOpenChange","title","description","actions","size","dismissible","keepMounted","labels","side","parts","className","style","children","id","text","isOpen","setOpen","dialog","toastHost","toasts","body","footer","returnTo","wasOpen","dismiss","present","setPresent","unmount","wait","ended","event","timer","mounted","Dialog","props"],"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useContext, useEffect, useId, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { DialogBase } from \"../../foundations/DialogBase/DialogBase.js\";\nimport { deepActiveElement } from \"../../foundations/focus.js\";\nimport { transitionTime } from \"../../foundations/motion.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { ToastHostContext } from \"../../overlay/toast-host.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface DialogTokens {\n radius: string;\n padding: string;\n widthSm: string;\n widthMd: string;\n widthLg: string;\n scrim: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n dialog: DialogTokens;\n }\n}\n\nexport interface DialogLabels {\n /** Accessible name of the close button. */\n close: string;\n}\n\nexport interface DialogProps {\n /** Whether the dialog is open, when you control it. */\n open?: boolean;\n /** Open on first render when uncontrolled. */\n defaultOpen?: boolean;\n /** Called with `false` when the dialog closes itself: Escape, the backdrop or the close button. */\n onOpenChange?: (open: boolean) => void;\n /** Heading of the dialog; also its accessible name. */\n title: ReactNode;\n /** One or two sentences under the title; also its accessible description. */\n description?: ReactNode;\n /** Buttons along the bottom, outside the scrolling content (Cancel first, then the main action). */\n actions?: ReactNode;\n /** Width preset (the panel never grows wider than its container). */\n size?: Size;\n /** Escape, the backdrop and the close button close it (default). `false` leaves only your actions. */\n dismissible?: boolean;\n /**\n * Keep the content in the DOM while the dialog is closed. By default a closed dialog renders nothing inside it: the\n * content mounts when it opens and unmounts once the closing transition has ended, so every opening starts fresh.\n * Set it for content whose state must survive closing (a half-filled form) or that is expensive to rebuild.\n * Default false.\n */\n keepMounted?: boolean;\n /** Replace the built-in English text: the close button's name. */\n labels?: Partial<DialogLabels>;\n /** Added to the panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. Restyle through --cy-dialog-* tokens. */\n style?: CSSProperties;\n /** The content; it scrolls when it is taller than the dialog. */\n children?: ReactNode;\n}\n\n/** Internal: a Sheet is the same dialog docked to an edge. */\nexport interface DialogFrameProps extends DialogProps {\n side?: \"bottom\" | \"end\" | \"start\";\n /**\n * Classes of the component built on the frame (Sheet), added to the dialog, the panel and the actions, so that\n * component draws its own look in its own stylesheet.\n */\n parts?: { root: string; panel: string; actions: string };\n}\n\nconst DEFAULT_LABELS: DialogLabels = { close: \"Close\" };\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Where focus can actually go back to. A Dialog opened from a Menu item remembers that item, but the menu has closed\n * (hidden, still in the DOM): fall back to the button that controls the hidden popover.\n */\nfunction reachable(el: HTMLElement | null): HTMLElement | null {\n if (!el) return null;\n // A closed popover can still be fading out (displayed), so ask the popover, not only the layout.\n const popover = el.closest<HTMLElement>(\"[popover][id]\");\n const closed = popover ? !popover.matches(\":popover-open\") : el.checkVisibility?.() === false;\n if (!closed) return el;\n const root = el.getRootNode() as Document | ShadowRoot;\n return (popover && root.querySelector<HTMLElement>(`[aria-controls=\"${CSS.escape(popover.id)}\"]`)) ?? el;\n}\n\nexport function DialogFrame({\n open,\n defaultOpen = false,\n onOpenChange,\n title,\n description,\n actions,\n size = \"md\",\n dismissible = true,\n keepMounted = false,\n labels,\n side,\n parts,\n className,\n style,\n children,\n}: DialogFrameProps) {\n const id = useId();\n const text = { ...DEFAULT_LABELS, ...labels };\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const dialog = useRef<HTMLDialogElement>(null);\n const toastHost = useContext(ToastHostContext);\n const toasts = useRef<HTMLDivElement>(null);\n const body = useRef<HTMLDivElement>(null);\n const footer = useRef<HTMLDivElement>(null);\n const returnTo = useRef<HTMLElement | null>(null);\n const wasOpen = useRef(false);\n // Where focus was before opening: read while rendering, because DialogBase's showModal moves it first.\n if (isOpen && !wasOpen.current) returnTo.current = deepActiveElement();\n wasOpen.current = isOpen;\n const dismiss = () => {\n if (dismissible) setOpen(false);\n };\n\n // The content is rendered while open, and after closing until the closing transition has ended. `present` goes true\n // in the render that opens the dialog, so the content is there before DialogBase shows it (no empty first frame).\n const [present, setPresent] = useState(isOpen);\n if (isOpen && !present) setPresent(true);\n useEffect(() => {\n if (isOpen || !present) return;\n const el = dialog.current as HTMLDialogElement;\n const unmount = () => setPresent(false);\n // Unmount when the dialog's own closing transition ends. The timer covers a transition that never reports back\n // (interrupted, or the dialog is not rendered) and is the whole wait when there is none: reduced motion, or no\n // stylesheet.\n const wait = transitionTime(getComputedStyle(el));\n const ended = (event: Event) => {\n if (event.target === el) unmount();\n };\n el.addEventListener(\"transitionend\", ended);\n const timer = setTimeout(unmount, wait && wait + 100);\n return () => {\n el.removeEventListener(\"transitionend\", ended);\n clearTimeout(timer);\n };\n }, [isOpen, present]);\n const mounted = isOpen || present || keepMounted;\n\n // On close, before useDismiss returns focus: make sure the remembered element can still take it.\n // Inside a Toaster, lend it a container while open: toasts raised now show above this dialog instead of under its\n // scrim, where the modal would make them inert. Runs after DialogBase has called showModal.\n useClientLayoutEffect(() => {\n if (!isOpen || !toastHost || !toasts.current) return;\n return toastHost.register(toasts.current);\n }, [isOpen, toastHost]);\n\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n return () => {\n returnTo.current = reachable(returnTo.current);\n };\n }, [isOpen]);\n\n // DialogBase has opened it; move focus to the first control in the content, else the first action, else the\n // dialog itself (so the close button's tooltip does not pop up on open).\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n const first =\n body.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n footer.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n dialog.current;\n first?.focus({ preventScroll: true });\n }, [isOpen]);\n\n useDismiss({\n open: isOpen,\n onClose: dismiss,\n inside: [dialog],\n returnFocus: returnTo,\n // The dialog fills its container; a pointer down on the dialog itself (not the panel) is on the backdrop.\n outside: (event) => event.composedPath()[0] === dialog.current,\n });\n\n return (\n <DialogBase\n ref={dialog}\n open={isOpen}\n onCancel={dismiss}\n onClose={() => setOpen(false)}\n className={parts ? `cy-dialog ${parts.root}` : \"cy-dialog\"}\n tabIndex={-1}\n data-size={size}\n data-side={side}\n aria-labelledby={mounted ? `${id}-title` : undefined}\n aria-describedby={mounted && description ? `${id}-description` : undefined}\n >\n {mounted && (\n <div\n className={[\"cy-dialog-panel cy-reset\", parts?.panel, className].filter(Boolean).join(\" \")}\n style={style}\n >\n <div className=\"cy-dialog-header cy-reset\">\n <h2 id={`${id}-title`} className=\"cy-dialog-title cy-reset\">\n {title}\n </h2>\n {dismissible && (\n <IconButton\n icon={closeIcon}\n label={text.close}\n variant=\"ghost\"\n size=\"sm\"\n tooltipPlacement=\"bottom\"\n wrapperClassName=\"cy-dialog-close\"\n onClick={() => setOpen(false)}\n />\n )}\n </div>\n {description && (\n <p id={`${id}-description`} className=\"cy-dialog-description cy-reset\">\n {description}\n </p>\n )}\n {/* biome-ignore lint/a11y/noStaticElementInteractions: delegated focus listener for the controls inside */}\n <div\n ref={body}\n className=\"cy-dialog-body cy-reset\"\n // A focused field low in the content (Tab, or the on-screen keyboard opening) is brought fully into view.\n onFocus={(event) => event.target.scrollIntoView({ block: \"nearest\" })}\n >\n {children}\n </div>\n {actions && (\n <div\n ref={footer}\n className={parts ? `cy-dialog-actions cy-reset ${parts.actions}` : \"cy-dialog-actions cy-reset\"}\n >\n {actions}\n </div>\n )}\n </div>\n )}\n {toastHost && mounted && <div ref={toasts} className=\"cy-dialog-toasts\" />}\n </DialogBase>\n );\n}\n\n/**\n * Modal dialog in the top layer: focus moves in, stays in and comes back; Escape, the backdrop and the close button\n * dismiss it. In a container narrower than about 36rem it becomes a bottom sheet. Its content is mounted only while\n * it is open (and while it closes), unless `keepMounted`.\n */\nexport function Dialog(props: DialogProps) {\n return <DialogFrame {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;AA4EA,IAAMiB,IAA+B,EAAE,OAAO,QAAQ,GAChDC,IACJ;AAMF,SAASC,GAAUC,GAA4C;AAC7D,MAAI,CAACA,EAAI,QAAO;AAEhB,QAAMC,IAAUD,EAAG,QAAqB,eAAe;AAEvD,MAAI,EADWC,IAAU,CAACA,EAAQ,QAAQ,eAAe,IAAID,EAAG,kBAAkB,MAAM,IAC3E,QAAOA;AACpB,QAAME,IAAOF,EAAG,YAAY;AAC5B,UAAQC,KAAWC,EAAK,cAA2B,mBAAmB,IAAI,OAAOD,EAAQ,EAAE,CAAA,IAAK,MAAMD;AACxG;AAEA,SAAgBG,GAAY,EAC1B,MAAAC,GACA,aAAAC,IAAc,IACd,cAAAC,GACA,OAAAC,GACA,aAAAC,GACA,SAAAC,GACA,MAAAC,IAAO,MACP,aAAAC,IAAc,IACd,aAAAC,IAAc,IACd,QAAAC,GACA,MAAAC,GACA,OAAAC,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACmB;AACnB,QAAMC,IAAK3B,EAAM,GACX4B,IAAO;AAAA,IAAE,GAAGvB;AAAA,IAAg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AAAA,UACC,CAAA,GACHI,KACC,gBAAAhB,EAACV,GAAD;AAAA,YACE,MAAML;AAAAA,YACN,OAAOwC,EAAK;AAAA,YACZ,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,kBAAiB;AAAA,YACjB,kBAAiB;AAAA,YACjB,SAAA,MAAeE,EAAQ,EAAK;AAAA,UAC7B,CAAA,CAEA;AAAA,Q;A,QACJd,KACC,gBAAAb,EAAC,KAAD;AAAA,UAAG,IAAI,GAAGwB,CAAA;AAAA,UAAkB,WAAU;AAAA,UACnC,UAAAX;AAAA,QACA,CAAA;AAAA,QAGL,gBAAAb,EAAC,OAAD;AAAA,UACE,KAAK+B;AAAA,UACL,WAAU;AAAA,UAEV,SAAA,CAAUU,MAAUA,EAAM,OAAO,eAAe,EAAE,OAAO,UAAU,CAAC;AAAA,UAEnE,UAAAlB;AAAA,QACE,CAAA;AAAA,QACJT,KACC,gBAAAd,EAAC,OAAD;AAAA,UACE,KAAKgC;AAAA,UACL,WAAWZ,IAAQ,8BAA8BA,EAAM,OAAA,KAAY;AAAA,UAElE,UAAAN;AAAA,QACE,CAAA;AAAA,MAEJ;AAAA,IAEN,CAAA,GAAAe,KAAac,KAAW,gBAAA3C,EAAC,OAAD;AAAA,MAAK,KAAK8B;AAAA,MAAQ,WAAU;AAAA,IAAoB,CAAA,CAC/D;AAAA,E;AAEhB;AAOA,SAAgBc,GAAOC,GAAoB;AACzC,SAAO,gBAAA7C,EAACQ,IAAD,EAAa,GAAIqC,EAAQ,CAAA;AAClC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type CSSProperties, type KeyboardEvent, type ReactNode } from "react";
|
|
2
|
+
import { type Edge } from "../../foundations/edge.js";
|
|
2
3
|
import type { Size } from "../../tokens/schema.js";
|
|
3
4
|
export interface DisclosureTokens {
|
|
5
|
+
/** Thickness of the `edge`. Default 4px, as Card's. */
|
|
6
|
+
edgeWidth: string;
|
|
4
7
|
gap: string;
|
|
5
8
|
radius: string;
|
|
6
9
|
paddingInline: string;
|
|
@@ -21,6 +24,17 @@ export interface DisclosureProps {
|
|
|
21
24
|
onOpenChange?: (open: boolean) => void;
|
|
22
25
|
/** `plain` no chrome, `line` bottom divider, `card` bordered surface. */
|
|
23
26
|
variant?: "plain" | "line" | "card";
|
|
27
|
+
/**
|
|
28
|
+
* A coloured edge on the inline-start side, as Card's `edge`: a tone name uses that tone's colour, any other string
|
|
29
|
+
* is a CSS colour (a log entry's level, a tool call's status). Say the same thing in words too. Default: no edge.
|
|
30
|
+
*/
|
|
31
|
+
edge?: Edge;
|
|
32
|
+
/**
|
|
33
|
+
* Content at the end of the summary row, before the chevron and outside the trigger button: a Badge with a count or
|
|
34
|
+
* a status, or a Button of its own. Its text is not part of the trigger's name. Pressing a Badge or text there
|
|
35
|
+
* toggles the section; a control there is its own target.
|
|
36
|
+
*/
|
|
37
|
+
trailing?: ReactNode;
|
|
24
38
|
/** Height of the trigger and size of the text. Default "md". */
|
|
25
39
|
size?: Size;
|
|
26
40
|
/** Wrap the trigger in a heading of this level (accordion sections in a document outline). */
|
|
@@ -41,4 +55,4 @@ export interface DisclosureProps {
|
|
|
41
55
|
"data-testid"?: string;
|
|
42
56
|
}
|
|
43
57
|
/** Show and hide a section behind a button. Replaces native <details> with an animated, themeable version. */
|
|
44
|
-
export declare function Disclosure({ summary, open, defaultOpen, onOpenChange, variant, size, headingLevel, region, locked, onTriggerKeyDown, className, style, children, ...rest }: DisclosureProps): import("react").JSX.Element;
|
|
58
|
+
export declare function Disclosure({ summary, open, defaultOpen, onOpenChange, variant, edge, trailing, size, headingLevel, region, locked, onTriggerKeyDown, className, style, children, ...rest }: DisclosureProps): import("react").JSX.Element;
|