@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,204 +1,221 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Icon as
|
|
3
|
-
import { useClientLayoutEffect as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
2
|
+
import { Icon as tt } from "../../foundations/Icon/Icon.js";
|
|
3
|
+
import { useClientLayoutEffect as W } from "../../foundations/client-layout-effect.js";
|
|
4
|
+
import { LoadingDots as et } from "../LoadingDots/LoadingDots.js";
|
|
5
|
+
import { Button as nt } from "../Button/Button.js";
|
|
6
|
+
import { deepActiveElement as ot } from "../../foundations/focus.js";
|
|
7
|
+
import { IconButton as rt } from "../IconButton/IconButton.js";
|
|
8
|
+
import { transitionTime as st } from "../../foundations/motion.js";
|
|
9
|
+
import { close as it } from "../../icons/close.js";
|
|
10
|
+
import { ToastHostContext as ct } from "../../overlay/toast-host.js";
|
|
11
|
+
import { useDrag as at } from "../../foundations/drag.js";
|
|
12
|
+
import { space as ut } from "../../foundations/layout.js";
|
|
13
|
+
import { TONE_ICONS as lt } from "../../foundations/tone-icons.js";
|
|
14
|
+
import { createContext as dt, useCallback as L, useContext as mt, useEffect as k, useId as ft, useMemo as V, useRef as A, useState as g } from "react";
|
|
15
|
+
import { Fragment as vt, jsx as v, jsxs as H } from "react/jsx-runtime";
|
|
16
|
+
import { createPortal as pt } from "react-dom";
|
|
17
|
+
var gt = {
|
|
14
18
|
region: "Notifications",
|
|
15
19
|
dismiss: "Dismiss"
|
|
16
|
-
},
|
|
17
|
-
function
|
|
18
|
-
const { block:
|
|
19
|
-
return
|
|
20
|
+
}, yt = 64, U = (n) => /^(\d|10)$/.test(n) ? ut(n) : n;
|
|
21
|
+
function ht(n) {
|
|
22
|
+
const { block: d, inline: y } = typeof n == "object" ? n : { block: n }, h = {};
|
|
23
|
+
return d && (h["--_offset-block"] = U(d)), y && (h["--_offset-inline"] = U(y)), h;
|
|
20
24
|
}
|
|
21
|
-
var
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
-
return
|
|
25
|
+
var G = dt(null);
|
|
26
|
+
function $t() {
|
|
27
|
+
const n = mt(G);
|
|
28
|
+
if (!n) throw new Error("useToast() needs a <Toaster> around it.");
|
|
29
|
+
return n;
|
|
26
30
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
...
|
|
30
|
-
...
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
}, []), $ =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
function Bt({ position: n = "bottom-end", max: d = 3, offset: y, labels: h, className: b, style: I, children: D }) {
|
|
32
|
+
const c = {
|
|
33
|
+
...gt,
|
|
34
|
+
...h
|
|
35
|
+
}, C = ft(), F = A(0), [T, x] = g([]), u = A([]), a = L((t) => {
|
|
36
|
+
u.current = t, x(t);
|
|
37
|
+
}, []), [N, m] = g(!1), [o, s] = g(!1), [_, w] = g(!1), E = A(null), P = A(/* @__PURE__ */ new Map()), [e, i] = g([]), $ = V(() => ({ register: (t) => (i((f) => [...f, t]), () => i((f) => f.filter((l) => l !== t))) }), []), B = e.at(-1) ?? null, J = L((t) => {
|
|
38
|
+
P.current.delete(t), a(u.current.filter((f) => f.id !== t));
|
|
39
|
+
}, [a]), M = L((t, f) => {
|
|
40
|
+
const l = u.current.filter((r) => !r.leaving && (t === void 0 || r.id === t));
|
|
41
|
+
if (l.length === 0) return;
|
|
42
|
+
const S = ot(E.current?.ownerDocument), p = S?.closest(".cy-toast");
|
|
43
|
+
if (p && E.current?.contains(p) && (t === void 0 || p.dataset.id === t)) {
|
|
44
|
+
const r = [...E.current.querySelectorAll(".cy-toast:not([data-collapsed]):not([data-leaving])")], O = t === void 0 ? void 0 : r.find((Z) => Z !== p), R = O ? [...O.querySelectorAll("button")].at(-1) : void 0;
|
|
45
|
+
R ? R.focus() : (S.blur(), s(!1));
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
...
|
|
47
|
+
a(u.current.map((r) => l.includes(r) ? {
|
|
48
|
+
...r,
|
|
41
49
|
leaving: !0
|
|
42
|
-
} :
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
50
|
+
} : r));
|
|
51
|
+
for (const r of l) r.onDismiss?.(r.id, f);
|
|
52
|
+
}, [a]), j = L((t) => M(t, "programmatic"), [M]), z = L(({ id: t, ...f }) => {
|
|
53
|
+
const l = t === void 0 ? void 0 : u.current.find((p) => p.id === t);
|
|
54
|
+
if (l) {
|
|
55
|
+
const p = {
|
|
56
|
+
...f,
|
|
57
|
+
id: l.id,
|
|
58
|
+
version: l.version + 1
|
|
59
|
+
};
|
|
60
|
+
return a(u.current.map((r) => r === l ? p : r)), l.id;
|
|
61
|
+
}
|
|
62
|
+
F.current += 1;
|
|
63
|
+
const S = t ?? `${C}-${F.current}`;
|
|
64
|
+
return a([...u.current, {
|
|
65
|
+
...f,
|
|
66
|
+
id: S,
|
|
67
|
+
version: 0
|
|
68
|
+
}]), S;
|
|
69
|
+
}, [C, a]), K = V(() => ({
|
|
70
|
+
toast: z,
|
|
71
|
+
dismiss: j
|
|
72
|
+
}), [z, j]);
|
|
73
|
+
W(() => {
|
|
74
|
+
const t = E.current;
|
|
56
75
|
return t?.showPopover?.(), () => {
|
|
57
76
|
t?.matches(":popover-open") && t.hidePopover?.();
|
|
58
77
|
};
|
|
59
|
-
}, [
|
|
60
|
-
const t = () =>
|
|
78
|
+
}, [B]), k(() => {
|
|
79
|
+
const t = () => w(document.visibilityState === "hidden");
|
|
61
80
|
return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
|
|
62
|
-
}, []),
|
|
63
|
-
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
66
|
-
ref:
|
|
67
|
-
"aria-label":
|
|
81
|
+
}, []), k(() => {
|
|
82
|
+
o && !T.some((t) => !t.leaving) && s(!1);
|
|
83
|
+
}, [o, T]);
|
|
84
|
+
const Q = T.filter((t) => !t.leaving), X = new Set(Q.slice(-d).map((t) => t.id)), Y = N || o || _, q = /* @__PURE__ */ v("section", {
|
|
85
|
+
ref: E,
|
|
86
|
+
"aria-label": c.region,
|
|
68
87
|
popover: "manual",
|
|
69
|
-
className:
|
|
70
|
-
"data-position":
|
|
88
|
+
className: b ? `cy-toaster ${b}` : "cy-toaster",
|
|
89
|
+
"data-position": n,
|
|
71
90
|
style: {
|
|
72
|
-
...
|
|
91
|
+
...ht(y),
|
|
73
92
|
...I
|
|
74
93
|
},
|
|
75
|
-
onPointerEnter: () =>
|
|
76
|
-
onPointerLeave: () =>
|
|
94
|
+
onPointerEnter: () => m(!0),
|
|
95
|
+
onPointerLeave: () => m(!1),
|
|
77
96
|
onFocus: () => s(!0),
|
|
78
97
|
onBlur: (t) => {
|
|
79
98
|
t.currentTarget.contains(t.relatedTarget) || s(!1);
|
|
80
99
|
},
|
|
81
|
-
children:
|
|
100
|
+
children: T.map((t) => /* @__PURE__ */ v(bt, {
|
|
82
101
|
item: t,
|
|
83
|
-
collapsed: !t.leaving && !
|
|
84
|
-
paused:
|
|
85
|
-
dismissLabel:
|
|
86
|
-
onDismiss:
|
|
87
|
-
onRemoved:
|
|
88
|
-
memory:
|
|
102
|
+
collapsed: !t.leaving && !X.has(t.id),
|
|
103
|
+
paused: Y,
|
|
104
|
+
dismissLabel: c.dismiss,
|
|
105
|
+
onDismiss: M,
|
|
106
|
+
onRemoved: J,
|
|
107
|
+
memory: P.current
|
|
89
108
|
}, t.id))
|
|
90
109
|
});
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
-
value:
|
|
93
|
-
children: [/* @__PURE__ */
|
|
94
|
-
value:
|
|
95
|
-
children:
|
|
96
|
-
}),
|
|
110
|
+
return /* @__PURE__ */ H(G.Provider, {
|
|
111
|
+
value: K,
|
|
112
|
+
children: [/* @__PURE__ */ v(ct.Provider, {
|
|
113
|
+
value: $,
|
|
114
|
+
children: D
|
|
115
|
+
}), B ? pt(q, B) : q]
|
|
97
116
|
});
|
|
98
117
|
}
|
|
99
|
-
function
|
|
100
|
-
const { id:
|
|
101
|
-
const e =
|
|
102
|
-
return
|
|
103
|
-
}), [
|
|
104
|
-
|
|
105
|
-
if (
|
|
118
|
+
function bt({ item: n, collapsed: d, paused: y, dismissLabel: h, onDismiss: b, onRemoved: I, memory: D }) {
|
|
119
|
+
const { id: c, version: C, title: F, description: T, tone: x = "neutral", action: u, duration: a = 5e3, loading: N = !1, leaving: m = !1 } = n, o = A(null), [s] = g(() => {
|
|
120
|
+
const e = D.get(c) ?? { announced: !1 };
|
|
121
|
+
return D.set(c, e), e;
|
|
122
|
+
}), [_] = g(s.announced), [w, E] = g(s.announced);
|
|
123
|
+
k(() => {
|
|
124
|
+
if (w) return;
|
|
106
125
|
const e = setTimeout(() => {
|
|
107
|
-
s.announced = !0,
|
|
126
|
+
s.announced = !0, E(!0);
|
|
108
127
|
}, 50);
|
|
109
128
|
return () => clearTimeout(e);
|
|
110
|
-
}, [
|
|
111
|
-
|
|
112
|
-
}, [
|
|
113
|
-
if (
|
|
114
|
-
const e = Date.now(),
|
|
129
|
+
}, [w, s]), W(() => {
|
|
130
|
+
o.current && (o.current.inert = d || m);
|
|
131
|
+
}, [d, m]), k(() => {
|
|
132
|
+
if (y || d || m || N || !Number.isFinite(a) || a <= 0) return;
|
|
133
|
+
const e = Date.now(), i = s.remaining?.version === C ? s.remaining.ms : a, $ = setTimeout(() => b(c, "timeout"), Math.max(i, 0));
|
|
115
134
|
return () => {
|
|
116
|
-
clearTimeout(
|
|
135
|
+
clearTimeout($), s.remaining = {
|
|
136
|
+
version: C,
|
|
137
|
+
ms: i - (Date.now() - e)
|
|
138
|
+
};
|
|
117
139
|
};
|
|
118
140
|
}, [
|
|
119
|
-
|
|
141
|
+
y,
|
|
142
|
+
d,
|
|
143
|
+
m,
|
|
144
|
+
N,
|
|
120
145
|
a,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
h,
|
|
146
|
+
C,
|
|
147
|
+
c,
|
|
148
|
+
b,
|
|
125
149
|
s
|
|
126
|
-
]),
|
|
127
|
-
if (!
|
|
128
|
-
const e =
|
|
129
|
-
return () => clearTimeout(
|
|
150
|
+
]), k(() => {
|
|
151
|
+
if (!m) return;
|
|
152
|
+
const e = o.current, i = setTimeout(() => I(c), e ? st(getComputedStyle(e)) : 0);
|
|
153
|
+
return () => clearTimeout(i);
|
|
130
154
|
}, [
|
|
131
|
-
|
|
132
|
-
|
|
155
|
+
m,
|
|
156
|
+
c,
|
|
133
157
|
I
|
|
134
|
-
])
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
158
|
+
]), at(o, {
|
|
159
|
+
touchAction: "css",
|
|
160
|
+
onStart: (e) => e.pointerType === "touch" && !e.path.some((i) => i instanceof Element && i.matches("button, a") && o.current?.contains(i)),
|
|
161
|
+
onMove: (e) => {
|
|
162
|
+
o.current?.setAttribute("data-swiping", ""), o.current?.style.setProperty("--_dx", `${e.delta.x}px`);
|
|
163
|
+
},
|
|
164
|
+
onEnd: (e, i) => {
|
|
165
|
+
o.current?.removeAttribute("data-swiping"), !i && Math.abs(e.delta.x) >= yt ? b(c, "user") : o.current?.style.removeProperty("--_dx");
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const P = lt[x];
|
|
169
|
+
return /* @__PURE__ */ H("div", {
|
|
170
|
+
ref: o,
|
|
171
|
+
role: x === "danger" && !_ ? "alert" : "status",
|
|
145
172
|
"aria-atomic": "true",
|
|
146
173
|
className: "cy-toast",
|
|
147
|
-
"data-id":
|
|
148
|
-
"data-tone":
|
|
149
|
-
"data-collapsed":
|
|
150
|
-
"data-leaving":
|
|
151
|
-
onPointerDown: (e) => {
|
|
152
|
-
e.pointerType === "touch" && (b.current = {
|
|
153
|
-
x: e.clientX,
|
|
154
|
-
pointer: e.pointerId
|
|
155
|
-
});
|
|
156
|
-
},
|
|
157
|
-
onPointerMove: (e) => {
|
|
158
|
-
const n = b.current;
|
|
159
|
-
!n || n.pointer !== e.pointerId || (e.currentTarget.dataset.swiping = "", e.currentTarget.style.setProperty("--_dx", `${e.clientX - n.x}px`));
|
|
160
|
-
},
|
|
161
|
-
onPointerUp: _,
|
|
162
|
-
onPointerCancel: (e) => {
|
|
163
|
-
b.current = null, delete e.currentTarget.dataset.swiping, e.currentTarget.style.removeProperty("--_dx");
|
|
164
|
-
},
|
|
174
|
+
"data-id": c,
|
|
175
|
+
"data-tone": x,
|
|
176
|
+
"data-collapsed": d || void 0,
|
|
177
|
+
"data-leaving": m || void 0,
|
|
165
178
|
children: [
|
|
166
|
-
|
|
167
|
-
|
|
179
|
+
N ? /* @__PURE__ */ v(et, {
|
|
180
|
+
variant: "spinner",
|
|
181
|
+
size: "md",
|
|
182
|
+
className: "cy-toast-icon"
|
|
183
|
+
}) : P && /* @__PURE__ */ v(tt, {
|
|
184
|
+
icon: P,
|
|
168
185
|
className: "cy-toast-icon"
|
|
169
186
|
}),
|
|
170
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ v("div", {
|
|
171
188
|
className: "cy-toast-text cy-reset",
|
|
172
|
-
children:
|
|
189
|
+
children: w && /* @__PURE__ */ H(vt, { children: [/* @__PURE__ */ v("span", {
|
|
173
190
|
className: "cy-toast-title cy-reset",
|
|
174
|
-
children:
|
|
175
|
-
}),
|
|
191
|
+
children: F
|
|
192
|
+
}), T && /* @__PURE__ */ v("span", {
|
|
176
193
|
className: "cy-toast-description cy-reset",
|
|
177
|
-
children:
|
|
194
|
+
children: T
|
|
178
195
|
})] })
|
|
179
196
|
}),
|
|
180
|
-
|
|
197
|
+
u && /* @__PURE__ */ v(nt, {
|
|
181
198
|
size: "sm",
|
|
182
199
|
variant: "soft",
|
|
183
|
-
tone:
|
|
200
|
+
tone: x === "neutral" ? "accent" : x,
|
|
184
201
|
className: "cy-toast-action",
|
|
185
|
-
onClick:
|
|
186
|
-
children:
|
|
202
|
+
onClick: u.onClick,
|
|
203
|
+
children: u.label
|
|
187
204
|
}),
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
icon:
|
|
190
|
-
label:
|
|
205
|
+
/* @__PURE__ */ v(rt, {
|
|
206
|
+
icon: it,
|
|
207
|
+
label: h,
|
|
191
208
|
variant: "ghost",
|
|
192
209
|
size: "sm",
|
|
193
210
|
wrapperClassName: "cy-toast-dismiss",
|
|
194
|
-
onClick: () =>
|
|
211
|
+
onClick: () => b(c, "user")
|
|
195
212
|
})
|
|
196
213
|
]
|
|
197
214
|
});
|
|
198
215
|
}
|
|
199
216
|
export {
|
|
200
|
-
|
|
201
|
-
|
|
217
|
+
Bt as Toaster,
|
|
218
|
+
$t as useToast
|
|
202
219
|
};
|
|
203
220
|
|
|
204
221
|
//# sourceMappingURL=Toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","names":["_Fragment","closeIcon","Icon","useClientLayoutEffect","Button","IconButton","close","ToastHostContext","space","TONE_ICONS","createContext","useCallback","useContext","useEffect","useId","useMemo","useRef","useState","Fragment$1","jsx","jsxs","createPortal","DEFAULT_LABELS","SWIPE","length","value","offsetVars","offset","block","inline","vars","ToastContext","useToast","api","Toaster","position","max","labels","className","style","children","text","prefix","count","items","setItems","hovered","setHovered","focused","setFocused","hidden","setHidden","region","memory","hosts","setHosts","registry","el","list","h","host","remove","id","t","dismiss","active","holder","others","next","button","toast","options","onVisibility","live","shown","paused","regionEl","e","item","ToastItem","collapsed","dismissLabel","onDismiss","onRemoved","title","description","tone","action","duration","leaving","mem","found","announcedBefore","drag","ready","setReady","started","left","node","ms","endSwipe","event","start","icon"],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import {\n type CSSProperties,\n createContext,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { TONE_ICONS } from \"../../foundations/tone-icons.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { ToastHostContext, type ToastHostRegistry } from \"../../overlay/toast-host.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { Button } from \"../Button/Button.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { type Space, space } from \"../Stack/space.js\";\n\nexport interface ToastTokens {\n width: string;\n radius: string;\n padding: string;\n gap: string;\n /** Extra distance between the toasts and the top or bottom edge they sit on (a fixed tab bar or header). */\n offsetBlock: string;\n /** Extra distance between the toasts and the side they sit on (a fixed side rail). */\n offsetInline: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n toast: ToastTokens;\n }\n}\n\nexport type ToastTone = Extract<Tone, \"neutral\" | \"success\" | \"danger\" | \"warning\" | \"info\">;\n\nexport interface ToastOptions {\n title: string;\n description?: string;\n /** Colour and icon. `danger` is announced assertively (`role=\"alert\"`); the others politely. */\n tone?: ToastTone;\n /** One button in the toast. It does not close the toast unless `onClick` dismisses it. */\n action?: { label: string; onClick: () => void };\n /** Milliseconds before it closes itself (default 5000). `Infinity` keeps it until dismissed. */\n duration?: number;\n}\n\nexport interface ToastApi {\n /** Shows a toast and returns its id. */\n toast: (options: ToastOptions) => string;\n /** Closes one toast, or all of them without an id. */\n dismiss: (id?: string) => void;\n}\n\nexport type ToastPosition =\n | \"top-start\"\n | \"top-center\"\n | \"top-end\"\n | \"bottom-start\"\n | \"bottom-center\"\n | \"bottom-end\";\n\n/** A distance: a step of the space scale (`\"6\"` is `--cy-space-6`) or any CSS length (`\"72px\"`, `\"calc(56px + 1rem)\"`). */\nexport type ToastOffsetLength = Space | (string & {});\n\n/** How far in from their edges the toasts sit, for each axis. */\nexport interface ToastOffset {\n /** From the top or bottom edge, whichever `position` names. */\n block?: ToastOffsetLength | undefined;\n /** From the side `position` names (both sides for `center`). Follows the reading direction. */\n inline?: ToastOffsetLength | undefined;\n}\n\nexport interface ToastLabels {\n /** Name of the notifications region. */\n region: string;\n /** Accessible name of each toast's close button. */\n dismiss: string;\n}\n\nexport interface ToasterProps {\n /** Where toasts stack. `start`/`end` follow the reading direction. */\n position?: ToastPosition;\n /** How many show at once; older ones collapse until newer ones close. */\n max?: number;\n /**\n * Keeps the toasts clear of fixed parts of the app, such as a bottom tab bar: extra distance from the edge they sit\n * on, added to the usual margin and the device's safe area. A step of the space scale (`\"8\"`) or a CSS length\n * (`\"72px\"`) moves them in from the top or bottom edge; `{ block, inline }` sets that and the distance from the\n * side. To set it from CSS instead (only below a breakpoint, say) use the `--cy-toast-offset-block` and\n * `--cy-toast-offset-inline` tokens; this prop wins over them. Default: none.\n */\n offset?: ToastOffsetLength | ToastOffset | undefined;\n /** Replace the built-in English text: the region's name and the close button's name. */\n labels?: Partial<ToastLabels>;\n /** Added to the notifications region, for layout. */\n className?: string;\n /** Layout only, applied to the region. Restyle through --cy-toast-* tokens. */\n style?: CSSProperties;\n /** The part of the app that can call `useToast()`. */\n children?: ReactNode;\n}\n\ninterface Item extends ToastOptions {\n id: string;\n leaving?: boolean;\n}\n\nconst DEFAULT_LABELS: ToastLabels = { region: \"Notifications\", dismiss: \"Dismiss\" };\n/** Horizontal distance a touch has to travel to swipe a toast away. */\nconst SWIPE = 64;\n\nconst length = (value: ToastOffsetLength) => (/^(\\d|10)$/.test(value) ? space(value as Space) : value);\n/** The private custom properties toast.css reads the `offset` prop from; an axis that is not set is left to the token. */\nfunction offsetVars(offset: ToasterProps[\"offset\"]) {\n const { block, inline }: ToastOffset = typeof offset === \"object\" ? offset : { block: offset };\n const vars: Record<string, string> = {};\n if (block) vars[\"--_offset-block\"] = length(block);\n if (inline) vars[\"--_offset-inline\"] = length(inline);\n return vars;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/** `toast()` and `dismiss()` for the nearest `<Toaster>`. */\nexport function useToast(): ToastApi {\n const api = useContext(ToastContext);\n if (!api) throw new Error(\"useToast() needs a <Toaster> around it.\");\n return api;\n}\n\ntype RegionEl = HTMLElement & { showPopover?: () => void; hidePopover?: () => void };\n\n/** What a toast keeps when its element is re-created (the region moved into or out of a Dialog). */\ninterface Memory {\n announced: boolean;\n remaining?: number;\n}\ntype MemoryMap = Map<string, Memory>;\n\n/**\n * Hosts toasts for everything inside it: a region in the top layer, a store per Toaster (no globals), timers that pause\n * while the pointer or focus is on a toast, and polite or assertive announcements.\n */\nexport function Toaster({\n position = \"bottom-end\",\n max = 3,\n offset,\n labels,\n className,\n style,\n children,\n}: ToasterProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const prefix = useId();\n const count = useRef(0);\n const [items, setItems] = useState<Item[]>([]);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [hidden, setHidden] = useState(false);\n const region = useRef<RegionEl>(null);\n const memory = useRef<MemoryMap>(new Map());\n // Containers lent by open modal Dialogs; the latest one hosts the region.\n const [hosts, setHosts] = useState<HTMLElement[]>([]);\n const registry = useMemo<ToastHostRegistry>(\n () => ({\n register: (el) => {\n setHosts((list) => [...list, el]);\n return () => setHosts((list) => list.filter((h) => h !== el));\n },\n }),\n [],\n );\n const host = hosts.at(-1) ?? null;\n\n const remove = useCallback((id: string) => {\n memory.current.delete(id);\n setItems((list) => list.filter((t) => t.id !== id));\n }, []);\n const dismiss = useCallback((id?: string) => {\n // Closing the toast that holds focus (its close button, from the keyboard): hand focus to the next toast's close\n // button, or let the region stop pausing if there is none.\n const active = region.current?.ownerDocument.activeElement;\n const holder = active?.closest<HTMLElement>(\".cy-toast\");\n if (holder && region.current?.contains(holder) && (id === undefined || holder.dataset.id === id)) {\n const others = [\n ...region.current.querySelectorAll<HTMLElement>(\n \".cy-toast:not([data-collapsed]):not([data-leaving])\",\n ),\n ];\n const next = id === undefined ? undefined : others.find((t) => t !== holder);\n const button = next ? [...next.querySelectorAll<HTMLElement>(\"button\")].at(-1) : undefined;\n if (button) button.focus();\n else {\n (active as HTMLElement).blur();\n setFocused(false);\n }\n }\n setItems((list) => list.map((t) => (id === undefined || t.id === id ? { ...t, leaving: true } : t)));\n }, []);\n const toast = useCallback(\n (options: ToastOptions) => {\n count.current += 1;\n const id = `${prefix}-${count.current}`;\n setItems((list) => [...list, { ...options, id }]);\n return id;\n },\n [prefix],\n );\n const api = useMemo<ToastApi>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // The region lives in the top layer for as long as the Toaster is mounted, so live regions exist before content.\n // It is re-created when it moves into or out of a Dialog; showing it again puts it on top of that dialog.\n useClientLayoutEffect(() => {\n const el = region.current;\n el?.showPopover?.();\n return () => {\n if (el?.matches(\":popover-open\")) el.hidePopover?.();\n };\n }, [host]);\n useEffect(() => {\n const onVisibility = () => setHidden(document.visibilityState === \"hidden\");\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => document.removeEventListener(\"visibilitychange\", onVisibility);\n }, []);\n // Focus left the region entirely (a toast closing with focus inside also counts).\n useEffect(() => {\n if (focused && !items.some((t) => !t.leaving)) setFocused(false);\n }, [focused, items]);\n\n const live = items.filter((t) => !t.leaving);\n const shown = new Set(live.slice(-max).map((t) => t.id));\n const paused = hovered || focused || hidden;\n\n const regionEl = (\n <section\n ref={region}\n aria-label={text.region}\n {...{ popover: \"manual\" }}\n className={className ? `cy-toaster ${className}` : \"cy-toaster\"}\n data-position={position}\n style={{ ...offsetVars(offset), ...style }}\n onPointerEnter={() => setHovered(true)}\n onPointerLeave={() => setHovered(false)}\n onFocus={() => setFocused(true)}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n }}\n >\n {items.map((item) => (\n <ToastItem\n key={item.id}\n item={item}\n collapsed={!item.leaving && !shown.has(item.id)}\n paused={paused}\n dismissLabel={text.dismiss}\n onDismiss={dismiss}\n onRemoved={remove}\n memory={memory.current}\n />\n ))}\n </section>\n );\n\n return (\n <ToastContext.Provider value={api}>\n <ToastHostContext.Provider value={registry}>{children}</ToastHostContext.Provider>\n {host ? createPortal(regionEl, host) : regionEl}\n </ToastContext.Provider>\n );\n}\n\ninterface ToastItemProps {\n item: Item;\n collapsed: boolean;\n paused: boolean;\n dismissLabel: string;\n onDismiss: (id: string) => void;\n onRemoved: (id: string) => void;\n memory: MemoryMap;\n}\n\nfunction ToastItem({ item, collapsed, paused, dismissLabel, onDismiss, onRemoved, memory }: ToastItemProps) {\n const { id, title, description, tone = \"neutral\", action, duration = 5000, leaving = false } = item;\n const el = useRef<HTMLDivElement>(null);\n // Survives the element being re-created (region moved into or out of a Dialog).\n const [mem] = useState<Memory>(() => {\n const found = memory.get(id) ?? { announced: false };\n memory.set(id, found);\n return found;\n });\n const [announcedBefore] = useState(mem.announced);\n const drag = useRef<{ x: number; pointer: number } | null>(null);\n // The live element exists (empty) first and its text arrives a moment later: screen readers announce text added to\n // a live region, and the text is added once, so the toast is announced once.\n // Already announced (re-created after a move): show the text at once, so nothing is inserted to announce again.\n const [ready, setReady] = useState(mem.announced);\n useEffect(() => {\n if (ready) return;\n const t = setTimeout(() => {\n mem.announced = true;\n setReady(true);\n }, 50);\n return () => clearTimeout(t);\n }, [ready, mem]);\n\n // Collapsed and leaving toasts cannot be focused or clicked. Set as a property: React 18 drops `inert={true}`.\n useClientLayoutEffect(() => {\n if (el.current) el.current.inert = collapsed || leaving;\n }, [collapsed, leaving]);\n\n // Auto-dismiss, keeping the time already spent across pauses and moves. The time left lives in `mem`, read when the\n // timer starts: a re-created toast's effects run after the old one has saved it.\n useEffect(() => {\n if (paused || collapsed || leaving || !Number.isFinite(duration) || duration <= 0) return;\n const started = Date.now();\n const left = mem.remaining ?? duration;\n const t = setTimeout(() => onDismiss(id), Math.max(left, 0));\n return () => {\n clearTimeout(t);\n mem.remaining = left - (Date.now() - started);\n };\n }, [paused, collapsed, leaving, duration, id, onDismiss, mem]);\n\n // Leaving: play the exit transition (none under reduced motion), then drop it from the store.\n useEffect(() => {\n if (!leaving) return;\n const node = el.current;\n const ms = node ? Number.parseFloat(getComputedStyle(node).transitionDuration) * 1000 || 0 : 0;\n const t = setTimeout(() => onRemoved(id), ms);\n return () => clearTimeout(t);\n }, [leaving, id, onRemoved]);\n\n const endSwipe = (event: PointerEvent<HTMLDivElement>) => {\n const start = drag.current;\n if (!start || start.pointer !== event.pointerId) return;\n drag.current = null;\n const node = event.currentTarget;\n delete node.dataset.swiping;\n if (Math.abs(event.clientX - start.x) >= SWIPE) onDismiss(id);\n else node.style.removeProperty(\"--_dx\");\n };\n\n const icon = TONE_ICONS[tone];\n return (\n <div\n ref={el}\n // An alert announces whenever it appears; one already announced comes back as a status.\n role={tone === \"danger\" && !announcedBefore ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n className=\"cy-toast\"\n data-id={id}\n data-tone={tone}\n data-collapsed={collapsed || undefined}\n data-leaving={leaving || undefined}\n onPointerDown={(event) => {\n if (event.pointerType !== \"touch\") return;\n drag.current = { x: event.clientX, pointer: event.pointerId };\n }}\n onPointerMove={(event) => {\n const start = drag.current;\n if (!start || start.pointer !== event.pointerId) return;\n event.currentTarget.dataset.swiping = \"\";\n event.currentTarget.style.setProperty(\"--_dx\", `${event.clientX - start.x}px`);\n }}\n onPointerUp={endSwipe}\n onPointerCancel={(event) => {\n // The browser took the gesture (a scroll): spring back, never dismiss.\n drag.current = null;\n delete event.currentTarget.dataset.swiping;\n event.currentTarget.style.removeProperty(\"--_dx\");\n }}\n >\n {icon && <Icon icon={icon} className=\"cy-toast-icon\" />}\n <div className=\"cy-toast-text cy-reset\">\n {ready && (\n <>\n <span className=\"cy-toast-title cy-reset\">{title}</span>\n {description && <span className=\"cy-toast-description cy-reset\">{description}</span>}\n </>\n )}\n </div>\n {action && (\n <Button\n size=\"sm\"\n variant=\"soft\"\n tone={tone === \"neutral\" ? \"accent\" : tone}\n className=\"cy-toast-action\"\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n )}\n <IconButton\n icon={closeIcon}\n label={dismissLabel}\n variant=\"ghost\"\n size=\"sm\"\n wrapperClassName=\"cy-toast-dismiss\"\n onClick={() => onDismiss(id)}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAmHA,IAAMsB,KAA8B;AAAA,EAAE,QAAQ;AAAA,EAAiB,SAAS;AAAU,GAE5EC,KAAQ,IAERC,IAAA,CAAUC,MAA8B,YAAY,KAAKA,CAAK,IAAIjB,GAAMiB,CAAc,IAAIA;AAEhG,SAASC,GAAWC,GAAgC;AAClD,QAAM,EAAE,OAAAC,GAAO,QAAAC,EAAA,IAAwB,OAAOF,KAAW,WAAWA,IAAS,EAAE,OAAOA,EAAO,GACvFG,IAA+B,CAAC;AACtC,SAAIF,MAAOE,EAAK,iBAAA,IAAqBN,EAAOI,CAAK,IAC7CC,MAAQC,EAAK,kBAAA,IAAsBN,EAAOK,CAAM,IAC7CC;AACT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AS,YAAY,WAAWA;AAAA,QACtC,WAAU;AAAA,QACV,SAASC,EAAO;AAAA,QAEf,UAAAA,EAAO;AAAA,MACF,CAAA;AAAA,MAEV,gBAAApE,EAACd,GAAD;AAAA,QACE,MAAMJ;AAAAA,QACN,OAAOgF;AAAA,QACP,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,kBAAiB;AAAA,QACjB,SAAA,MAAeC,EAAUpB,CAAE;AAAA,MAC5B,CAAA;AAAA,IACE;AAAA,E;AAET"}
|
|
1
|
+
{"version":3,"file":"Toast.js","names":["_Fragment","closeIcon","Icon","useClientLayoutEffect","LoadingDots","Button","deepActiveElement","IconButton","transitionTime","close","ToastHostContext","useDrag","space","TONE_ICONS","createContext","useCallback","useContext","useEffect","useId","useMemo","useRef","useState","Fragment$1","jsx","jsxs","createPortal","DEFAULT_LABELS","SWIPE","length","value","offsetVars","offset","block","inline","vars","ToastContext","useToast","api","Toaster","position","max","labels","className","style","children","text","prefix","count","items","setItems","store","commit","next","hovered","setHovered","focused","setFocused","hidden","setHidden","region","memory","hosts","setHosts","registry","el","list","h","host","remove","id","t","reason","ending","active","holder","others","button","dismiss","toast","wanted","options","current","onVisibility","live","shown","paused","regionEl","e","item","ToastItem","collapsed","dismissLabel","onDismiss","onRemoved","version","title","description","tone","action","duration","loading","leaving","mem","found","announcedBefore","ready","setReady","started","left","node","session","n","cancelled","icon"],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import {\n type CSSProperties,\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { deepActiveElement } from \"../../foundations/focus.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { type Space, space } from \"../../foundations/layout.js\";\nimport { transitionTime } from \"../../foundations/motion.js\";\nimport { TONE_ICONS } from \"../../foundations/tone-icons.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { ToastHostContext, type ToastHostRegistry } from \"../../overlay/toast-host.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { Button } from \"../Button/Button.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { LoadingDots } from \"../LoadingDots/LoadingDots.js\";\n\nexport interface ToastTokens {\n width: string;\n radius: string;\n padding: string;\n gap: string;\n /** Extra distance between the toasts and the top or bottom edge they sit on (a fixed tab bar or header). */\n offsetBlock: string;\n /** Extra distance between the toasts and the side they sit on (a fixed side rail). */\n offsetInline: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n toast: ToastTokens;\n }\n}\n\nexport type ToastTone = Extract<Tone, \"neutral\" | \"success\" | \"danger\" | \"warning\" | \"info\">;\n\n/** Why a toast closed: its timer ran out, the user closed it (close button or swipe), or `dismiss()` was called. */\nexport type ToastDismissReason = \"timeout\" | \"user\" | \"programmatic\";\n\nexport interface ToastOptions {\n /**\n * Names the toast. Calling `toast()` again with the id of a toast that is still showing updates that toast in place\n * (a loading toast becoming done) instead of adding another; its timer starts again with the new `duration`.\n * Default: a new id for every call.\n */\n id?: string;\n title: string;\n description?: string;\n /** Colour and icon. `danger` is announced assertively (`role=\"alert\"`); the others politely. */\n tone?: ToastTone;\n /** One button in the toast. It does not close the toast unless `onClick` dismisses it. */\n action?: { label: string; onClick: () => void };\n /** Milliseconds before it closes itself (default 5000). `Infinity` keeps it until dismissed. */\n duration?: number;\n /**\n * Work in progress: a spinner in place of the tone's icon, and no timer until the toast is updated (`toast()` with\n * the same `id`) or dismissed.\n */\n loading?: boolean;\n /** Called once when the toast starts to close, with its id and why it closed. */\n onDismiss?: (id: string, reason: ToastDismissReason) => void;\n}\n\nexport interface ToastApi {\n /** Shows a toast and returns its id; with the `id` of a toast that is showing, updates that toast instead. */\n toast: (options: ToastOptions) => string;\n /** Closes one toast, or all of them without an id. */\n dismiss: (id?: string) => void;\n}\n\nexport type ToastPosition =\n | \"top-start\"\n | \"top-center\"\n | \"top-end\"\n | \"bottom-start\"\n | \"bottom-center\"\n | \"bottom-end\";\n\n/** A distance: a step of the space scale (`\"6\"` is `--cy-space-6`) or any CSS length (`\"72px\"`, `\"calc(56px + 1rem)\"`). */\nexport type ToastOffsetLength = Space | (string & {});\n\n/** How far in from their edges the toasts sit, for each axis. */\nexport interface ToastOffset {\n /** From the top or bottom edge, whichever `position` names. */\n block?: ToastOffsetLength | undefined;\n /** From the side `position` names (both sides for `center`). Follows the reading direction. */\n inline?: ToastOffsetLength | undefined;\n}\n\nexport interface ToastLabels {\n /** Name of the notifications region. */\n region: string;\n /** Accessible name of each toast's close button. */\n dismiss: string;\n}\n\nexport interface ToasterProps {\n /** Where toasts stack. `start`/`end` follow the reading direction. */\n position?: ToastPosition;\n /** How many show at once; older ones collapse until newer ones close. */\n max?: number;\n /**\n * Keeps the toasts clear of fixed parts of the app, such as a bottom tab bar: extra distance from the edge they sit\n * on, added to the usual margin and the device's safe area. A step of the space scale (`\"8\"`) or a CSS length\n * (`\"72px\"`) moves them in from the top or bottom edge; `{ block, inline }` sets that and the distance from the\n * side. To set it from CSS instead (only below a breakpoint, say) use the `--cy-toast-offset-block` and\n * `--cy-toast-offset-inline` tokens; this prop wins over them. Default: none.\n */\n offset?: ToastOffsetLength | ToastOffset | undefined;\n /** Replace the built-in English text: the region's name and the close button's name. */\n labels?: Partial<ToastLabels>;\n /** Added to the notifications region, for layout. */\n className?: string;\n /** Layout only, applied to the region. Restyle through --cy-toast-* tokens. */\n style?: CSSProperties;\n /** The part of the app that can call `useToast()`. */\n children?: ReactNode;\n}\n\ninterface Item extends ToastOptions {\n id: string;\n /** Counts updates, so an update restarts the timer even when its duration is unchanged. */\n version: number;\n leaving?: boolean;\n}\n\nconst DEFAULT_LABELS: ToastLabels = { region: \"Notifications\", dismiss: \"Dismiss\" };\n/** Horizontal distance a touch has to travel to swipe a toast away. */\nconst SWIPE = 64;\n\nconst length = (value: ToastOffsetLength) => (/^(\\d|10)$/.test(value) ? space(value as Space) : value);\n/** The private custom properties toast.css reads the `offset` prop from; an axis that is not set is left to the token. */\nfunction offsetVars(offset: ToasterProps[\"offset\"]) {\n const { block, inline }: ToastOffset = typeof offset === \"object\" ? offset : { block: offset };\n const vars: Record<string, string> = {};\n if (block) vars[\"--_offset-block\"] = length(block);\n if (inline) vars[\"--_offset-inline\"] = length(inline);\n return vars;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/** `toast()` and `dismiss()` for the nearest `<Toaster>`. */\nexport function useToast(): ToastApi {\n const api = useContext(ToastContext);\n if (!api) throw new Error(\"useToast() needs a <Toaster> around it.\");\n return api;\n}\n\ntype RegionEl = HTMLElement & { showPopover?: () => void; hidePopover?: () => void };\n\n/** What a toast keeps when its element is re-created (the region moved into or out of a Dialog). */\ninterface Memory {\n announced: boolean;\n /** Time left on the timer of one version of the toast; an update starts a timer of its own. */\n remaining?: { version: number; ms: number };\n}\ntype MemoryMap = Map<string, Memory>;\n\n/**\n * Hosts toasts for everything inside it: a region in the top layer, a store per Toaster (no globals), timers that pause\n * while the pointer or focus is on a toast, and polite or assertive announcements.\n */\nexport function Toaster({\n position = \"bottom-end\",\n max = 3,\n offset,\n labels,\n className,\n style,\n children,\n}: ToasterProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const prefix = useId();\n const count = useRef(0);\n const [items, setItems] = useState<Item[]>([]);\n // The store as of the last change, read synchronously by toast() and dismiss() (two calls in one handler see each\n // other), so updates find their toast and onDismiss is called outside a state updater, exactly once.\n const store = useRef<Item[]>([]);\n const commit = useCallback((next: Item[]) => {\n store.current = next;\n setItems(next);\n }, []);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [hidden, setHidden] = useState(false);\n const region = useRef<RegionEl>(null);\n const memory = useRef<MemoryMap>(new Map());\n // Containers lent by open modal Dialogs; the latest one hosts the region.\n const [hosts, setHosts] = useState<HTMLElement[]>([]);\n const registry = useMemo<ToastHostRegistry>(\n () => ({\n register: (el) => {\n setHosts((list) => [...list, el]);\n return () => setHosts((list) => list.filter((h) => h !== el));\n },\n }),\n [],\n );\n const host = hosts.at(-1) ?? null;\n\n const remove = useCallback(\n (id: string) => {\n memory.current.delete(id);\n commit(store.current.filter((t) => t.id !== id));\n },\n [commit],\n );\n const close = useCallback(\n (id: string | undefined, reason: ToastDismissReason) => {\n const ending = store.current.filter((t) => !t.leaving && (id === undefined || t.id === id));\n if (ending.length === 0) return;\n // Closing the toast that holds focus (its close button, from the keyboard): hand focus to the next toast's close\n // button, or let the region stop pausing if there is none.\n const active = deepActiveElement(region.current?.ownerDocument);\n const holder = active?.closest<HTMLElement>(\".cy-toast\");\n if (holder && region.current?.contains(holder) && (id === undefined || holder.dataset.id === id)) {\n const others = [\n ...region.current.querySelectorAll<HTMLElement>(\n \".cy-toast:not([data-collapsed]):not([data-leaving])\",\n ),\n ];\n const next = id === undefined ? undefined : others.find((t) => t !== holder);\n const button = next ? [...next.querySelectorAll<HTMLElement>(\"button\")].at(-1) : undefined;\n if (button) button.focus();\n else {\n (active as HTMLElement).blur();\n setFocused(false);\n }\n }\n commit(store.current.map((t) => (ending.includes(t) ? { ...t, leaving: true } : t)));\n for (const t of ending) t.onDismiss?.(t.id, reason);\n },\n [commit],\n );\n const dismiss = useCallback((id?: string) => close(id, \"programmatic\"), [close]);\n const toast = useCallback(\n ({ id: wanted, ...options }: ToastOptions) => {\n // The id of a toast still in the store: update it in place (one that was closing comes back).\n const current = wanted === undefined ? undefined : store.current.find((t) => t.id === wanted);\n if (current) {\n const next: Item = { ...options, id: current.id, version: current.version + 1 };\n commit(store.current.map((t) => (t === current ? next : t)));\n return current.id;\n }\n count.current += 1;\n const id = wanted ?? `${prefix}-${count.current}`;\n commit([...store.current, { ...options, id, version: 0 }]);\n return id;\n },\n [prefix, commit],\n );\n const api = useMemo<ToastApi>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // The region lives in the top layer for as long as the Toaster is mounted, so live regions exist before content.\n // It is re-created when it moves into or out of a Dialog; showing it again puts it on top of that dialog.\n useClientLayoutEffect(() => {\n const el = region.current;\n el?.showPopover?.();\n return () => {\n if (el?.matches(\":popover-open\")) el.hidePopover?.();\n };\n }, [host]);\n useEffect(() => {\n const onVisibility = () => setHidden(document.visibilityState === \"hidden\");\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => document.removeEventListener(\"visibilitychange\", onVisibility);\n }, []);\n // Focus left the region entirely (a toast closing with focus inside also counts).\n useEffect(() => {\n if (focused && !items.some((t) => !t.leaving)) setFocused(false);\n }, [focused, items]);\n\n const live = items.filter((t) => !t.leaving);\n const shown = new Set(live.slice(-max).map((t) => t.id));\n const paused = hovered || focused || hidden;\n\n const regionEl = (\n <section\n ref={region}\n aria-label={text.region}\n {...{ popover: \"manual\" }}\n className={className ? `cy-toaster ${className}` : \"cy-toaster\"}\n data-position={position}\n style={{ ...offsetVars(offset), ...style }}\n onPointerEnter={() => setHovered(true)}\n onPointerLeave={() => setHovered(false)}\n onFocus={() => setFocused(true)}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n }}\n >\n {items.map((item) => (\n <ToastItem\n key={item.id}\n item={item}\n collapsed={!item.leaving && !shown.has(item.id)}\n paused={paused}\n dismissLabel={text.dismiss}\n onDismiss={close}\n onRemoved={remove}\n memory={memory.current}\n />\n ))}\n </section>\n );\n\n return (\n <ToastContext.Provider value={api}>\n <ToastHostContext.Provider value={registry}>{children}</ToastHostContext.Provider>\n {host ? createPortal(regionEl, host) : regionEl}\n </ToastContext.Provider>\n );\n}\n\ninterface ToastItemProps {\n item: Item;\n collapsed: boolean;\n paused: boolean;\n dismissLabel: string;\n onDismiss: (id: string, reason: ToastDismissReason) => void;\n onRemoved: (id: string) => void;\n memory: MemoryMap;\n}\n\nfunction ToastItem({ item, collapsed, paused, dismissLabel, onDismiss, onRemoved, memory }: ToastItemProps) {\n const {\n id,\n version,\n title,\n description,\n tone = \"neutral\",\n action,\n duration = 5000,\n loading = false,\n leaving = false,\n } = item;\n const el = useRef<HTMLDivElement>(null);\n // Survives the element being re-created (region moved into or out of a Dialog).\n const [mem] = useState<Memory>(() => {\n const found = memory.get(id) ?? { announced: false };\n memory.set(id, found);\n return found;\n });\n const [announcedBefore] = useState(mem.announced);\n // The live element exists (empty) first and its text arrives a moment later: screen readers announce text added to\n // a live region, and the text is added once, so the toast is announced once.\n // Already announced (re-created after a move): show the text at once, so nothing is inserted to announce again.\n const [ready, setReady] = useState(mem.announced);\n useEffect(() => {\n if (ready) return;\n const t = setTimeout(() => {\n mem.announced = true;\n setReady(true);\n }, 50);\n return () => clearTimeout(t);\n }, [ready, mem]);\n\n // Collapsed and leaving toasts cannot be focused or clicked. Set as a property: React 18 drops `inert={true}`.\n useClientLayoutEffect(() => {\n if (el.current) el.current.inert = collapsed || leaving;\n }, [collapsed, leaving]);\n\n // Auto-dismiss, keeping the time already spent across pauses and moves. The time left lives in `mem`, read when the\n // timer starts: a re-created toast's effects run after the old one has saved it. An update (a new version) starts a\n // fresh timer; a loading toast has none until it is updated.\n useEffect(() => {\n if (paused || collapsed || leaving || loading || !Number.isFinite(duration) || duration <= 0) return;\n const started = Date.now();\n const left = mem.remaining?.version === version ? mem.remaining.ms : duration;\n const t = setTimeout(() => onDismiss(id, \"timeout\"), Math.max(left, 0));\n return () => {\n clearTimeout(t);\n mem.remaining = { version, ms: left - (Date.now() - started) };\n };\n }, [paused, collapsed, leaving, loading, duration, version, id, onDismiss, mem]);\n\n // Leaving: play the exit transition (none under reduced motion), then drop it from the store.\n useEffect(() => {\n if (!leaving) return;\n const node = el.current;\n const t = setTimeout(() => onRemoved(id), node ? transitionTime(getComputedStyle(node)) : 0);\n return () => clearTimeout(t);\n }, [leaving, id, onRemoved]);\n\n // A finger swipes the toast away sideways. A press on its buttons stays a tap; a vertical swipe scrolls (the\n // stylesheet's pan-y) and, like Escape, puts it back.\n useDrag(el, {\n touchAction: \"css\",\n onStart: (session) =>\n session.pointerType === \"touch\" &&\n !session.path.some((n) => n instanceof Element && n.matches(\"button, a\") && el.current?.contains(n)),\n onMove: (session) => {\n el.current?.setAttribute(\"data-swiping\", \"\");\n el.current?.style.setProperty(\"--_dx\", `${session.delta.x}px`);\n },\n onEnd: (session, cancelled) => {\n el.current?.removeAttribute(\"data-swiping\");\n if (!cancelled && Math.abs(session.delta.x) >= SWIPE) onDismiss(id, \"user\");\n else el.current?.style.removeProperty(\"--_dx\");\n },\n });\n\n const icon = TONE_ICONS[tone];\n return (\n <div\n ref={el}\n // An alert announces whenever it appears; one already announced comes back as a status.\n role={tone === \"danger\" && !announcedBefore ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n className=\"cy-toast\"\n data-id={id}\n data-tone={tone}\n data-collapsed={collapsed || undefined}\n data-leaving={leaving || undefined}\n >\n {loading ? (\n <LoadingDots variant=\"spinner\" size=\"md\" className=\"cy-toast-icon\" />\n ) : (\n icon && <Icon icon={icon} className=\"cy-toast-icon\" />\n )}\n <div className=\"cy-toast-text cy-reset\">\n {ready && (\n <>\n <span className=\"cy-toast-title cy-reset\">{title}</span>\n {description && <span className=\"cy-toast-description cy-reset\">{description}</span>}\n </>\n )}\n </div>\n {action && (\n <Button\n size=\"sm\"\n variant=\"soft\"\n tone={tone === \"neutral\" ? \"accent\" : tone}\n className=\"cy-toast-action\"\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n )}\n <IconButton\n icon={closeIcon}\n label={dismissLabel}\n variant=\"ghost\"\n size=\"sm\"\n wrapperClassName=\"cy-toast-dismiss\"\n onClick={() => onDismiss(id, \"user\")}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwIA,IAAM0B,KAA8B;AAAA,EAAE,QAAQ;AAAA,EAAiB,SAAS;AAAU,GAE5EC,KAAQ,IAERC,IAAA,CAAUC,MAA8B,YAAY,KAAKA,CAAK,IAAIjB,GAAMiB,CAAc,IAA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,OAAO0F;AAAA,QACP,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,kBAAiB;AAAA,QACjB,SAAA,MAAeC,EAAUvB,GAAI,MAAM;AAAA,MACpC,CAAA;AAAA,IACE;AAAA,E;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type ToastApi, Toaster, type ToasterProps, type ToastLabels, type ToastOffset, type ToastOffsetLength, type ToastOptions, type ToastPosition, type ToastTokens, type ToastTone, useToast, } from "./Toast.js";
|
|
1
|
+
export { type ToastApi, type ToastDismissReason, Toaster, type ToasterProps, type ToastLabels, type ToastOffset, type ToastOffsetLength, type ToastOptions, type ToastPosition, type ToastTokens, type ToastTone, useToast, } from "./Toast.js";
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useRef as
|
|
2
|
+
import { TOOLBAR_ITEMS as u, useRovingFocus as c } from "../../foundations/roving-focus.js";
|
|
3
|
+
import { useRef as s } from "react";
|
|
4
4
|
import { jsx as f } from "react/jsx-runtime";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return u(t, {
|
|
5
|
+
function R({ label: e, orientation: o = "horizontal", loop: l = !0, className: r, style: a, children: i, ...n }) {
|
|
6
|
+
const t = s(null);
|
|
7
|
+
return c(t, {
|
|
9
8
|
orientation: o,
|
|
10
|
-
loop:
|
|
11
|
-
selector:
|
|
9
|
+
loop: l,
|
|
10
|
+
selector: u
|
|
12
11
|
}), /* @__PURE__ */ f("div", {
|
|
13
12
|
ref: t,
|
|
14
|
-
...
|
|
13
|
+
...n,
|
|
15
14
|
role: "toolbar",
|
|
16
15
|
"aria-label": e,
|
|
17
16
|
"aria-orientation": o,
|
|
18
17
|
className: r ? `cy-toolbar ${r}` : "cy-toolbar",
|
|
19
|
-
style:
|
|
20
|
-
children:
|
|
18
|
+
style: a,
|
|
19
|
+
children: i
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
export {
|
|
24
|
-
|
|
23
|
+
R as Toolbar
|
|
25
24
|
};
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=Toolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.js","names":["useRovingFocus","useRef","jsx","
|
|
1
|
+
{"version":3,"file":"Toolbar.js","names":["TOOLBAR_ITEMS","useRovingFocus","useRef","jsx","Toolbar","label","orientation","loop","className","style","children","rest","ref"],"sources":["../../../src/components/Toolbar/Toolbar.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useRef } from \"react\";\nimport { TOOLBAR_ITEMS, useRovingFocus } from \"../../foundations/roving-focus.js\";\n\nexport interface ToolbarProps {\n /** Accessible name (required: a toolbar must be named). */\n label: string;\n /** Direction of the toolbar: Left/Right move between controls, or Up/Down when vertical. Default \"horizontal\". */\n orientation?: \"horizontal\" | \"vertical\";\n /** Arrow keys wrap from the last item to the first. */\n loop?: boolean;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n /** Buttons, IconButtons, SegmentedControls, fields. */\n children?: ReactNode;\n /** Test id, set on the toolbar element. */\n \"data-testid\"?: string;\n}\n\n/** APG toolbar: one Tab stop; arrow keys move between controls (RTL aware), Home and End jump. */\nexport function Toolbar({\n label,\n orientation = \"horizontal\",\n loop = true,\n className,\n style,\n children,\n ...rest\n}: ToolbarProps) {\n const ref = useRef<HTMLDivElement>(null);\n useRovingFocus(ref, { orientation, loop, selector: TOOLBAR_ITEMS });\n return (\n <div\n ref={ref}\n {...rest}\n role=\"toolbar\"\n aria-label={label}\n aria-orientation={orientation}\n className={className ? `cy-toolbar ${className}` : \"cy-toolbar\"}\n style={style}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;AAqBA,SAAgBI,EAAQ,EACtB,OAAAC,GACA,aAAAC,IAAc,cACd,MAAAC,IAAO,IACP,WAAAC,GACA,OAAAC,GACA,UAAAC,GACA,GAAGC,EAAA,GACY;AACf,QAAMC,IAAMV,EAAuB,IAAI;AACvC,SAAAD,EAAeW,GAAK;AAAA,IAAE,aAAAN;AAAA,IAAa,MAAAC;AAAA,IAAM,UAAUP;AAAA,EAAc,CAAC,GAEhE,gBAAAG,EAAC,OAAD;AAAA,IACO,KAAAS;AAAA,IACL,GAAID;AAAA,IACJ,MAAK;AAAA,IACL,cAAYN;AAAA,IACZ,oBAAkBC;AAAA,IAClB,WAAWE,IAAY,cAAcA,CAAA,KAAc;AAAA,IAC5C,OAAAC;AAAA,IAEN,UAAAC;AAAA,EACE,CAAA;AAET"}
|
|
@@ -25,9 +25,26 @@ export interface TooltipProps {
|
|
|
25
25
|
* `flex`, margins.
|
|
26
26
|
*/
|
|
27
27
|
className?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Turn the tooltip off without remounting the trigger: no tip, no description, hover and focus do nothing. For a
|
|
30
|
+
* tooltip that only matters sometimes, such as the full text of a label while it is cut short.
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* `false` when the tip only repeats text the trigger's name already holds, such as a label cut short with an
|
|
35
|
+
* ellipsis: it is shown but hidden from assistive technology, and does not describe the trigger. Default true.
|
|
36
|
+
*/
|
|
37
|
+
describe?: boolean | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Show the tip only while text is cut short (it overflows its box, as with an ellipsis), for the full text of a
|
|
40
|
+
* label: `true` measures the trigger, a function picks the element inside it that holds the text. It is measured
|
|
41
|
+
* after every render and whenever the element is resized, and the tip repeats the trigger's name, so it implies
|
|
42
|
+
* `describe={false}`.
|
|
43
|
+
*/
|
|
44
|
+
whenTruncated?: boolean | ((trigger: HTMLElement) => HTMLElement | null) | undefined;
|
|
28
45
|
}
|
|
29
46
|
/**
|
|
30
47
|
* Tooltip in the top layer (Popover API), positioned against its trigger. Opens on hover after `delay` and on
|
|
31
48
|
* keyboard focus; dismissible with Escape; hoverable; never opens on touch (WCAG 1.4.13).
|
|
32
49
|
*/
|
|
33
|
-
export declare function Tooltip({ content, children, placement, delay, className }: TooltipProps): import("react").JSX.Element;
|
|
50
|
+
export declare function Tooltip({ content, children, placement, delay, className, disabled: off, describe: describes, whenTruncated, }: TooltipProps): import("react").JSX.Element;
|