@arshad-shah/cynosure 0.3.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 +53 -0
- package/dist/adapters/astro/index.js +27 -0
- package/dist/adapters/astro/index.js.map +1 -0
- package/dist/adapters/vite/index.d.ts +11 -0
- package/dist/adapters/vite/index.js +33 -12
- package/dist/adapters/vite/index.js.map +1 -1
- package/dist/brands/googleplay.d.ts +2 -0
- package/dist/brands/googleplay.js +17 -0
- package/dist/brands/googleplay.js.map +1 -0
- package/dist/brands/index.d.ts +1 -0
- package/dist/brands/index.js +132 -130
- 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 +32 -34
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.js +41 -41
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Avatar/Avatar.js +20 -20
- package/dist/components/Avatar/Avatar.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 +30 -6
- package/dist/components/Button/Button.js +50 -42
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.js +158 -161
- 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 +22 -2
- 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/Checkbox/Checkbox.d.ts +4 -4
- package/dist/components/Checkbox/Checkbox.js +33 -8
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checklist/Checklist.js +21 -21
- package/dist/components/Checklist/Checklist.js.map +1 -1
- package/dist/components/Choice/Choice.d.ts +73 -0
- package/dist/components/Choice/Choice.js +41 -0
- package/dist/components/Choice/Choice.js.map +1 -0
- package/dist/components/Choice/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 +202 -212
- 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 +118 -129
- 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 +2 -2
- package/dist/components/Container/Container.js +17 -13
- 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 +41 -41
- 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/DeviceFrame/DeviceFrame.d.ts +63 -0
- package/dist/components/DeviceFrame/DeviceFrame.js +54 -0
- package/dist/components/DeviceFrame/DeviceFrame.js.map +1 -0
- package/dist/components/DeviceFrame/index.d.ts +1 -0
- package/dist/components/Dialog/Dialog.d.ts +10 -1
- package/dist/components/Dialog/Dialog.js +82 -81
- 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/EmptyState/EmptyState.d.ts +5 -2
- package/dist/components/EmptyState/EmptyState.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 +48 -42
- 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 +150 -99
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.js +80 -77
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +32 -11
- package/dist/components/Grid/Grid.js +78 -48
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/index.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +4 -2
- package/dist/components/Heading/Heading.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.d.ts +16 -1
- package/dist/components/IconButton/IconButton.js +20 -15
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/IconTile/IconTile.d.ts +45 -0
- package/dist/components/IconTile/IconTile.js +25 -0
- package/dist/components/IconTile/IconTile.js.map +1 -0
- package/dist/components/IconTile/index.d.ts +1 -0
- package/dist/components/Image/Image.js.map +1 -1
- package/dist/components/Inline/Inline.d.ts +3 -3
- package/dist/components/Inline/Inline.js +12 -22
- 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/KeyValueEditor.js +37 -36
- package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
- package/dist/components/KeyValueEditor/bulk.js +3 -4
- package/dist/components/KeyValueEditor/bulk.js.map +1 -1
- package/dist/components/Link/Link.d.ts +9 -1
- package/dist/components/Link/Link.js +20 -18
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/List/List.d.ts +73 -0
- package/dist/components/List/List.js +64 -0
- package/dist/components/List/List.js.map +1 -0
- package/dist/components/List/index.d.ts +1 -0
- 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 -27
- 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 +102 -0
- package/dist/components/OptionList/OptionList.js +98 -0
- package/dist/components/OptionList/OptionList.js.map +1 -0
- package/dist/components/OptionList/index.d.ts +1 -0
- 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/PageHeader/PageHeader.d.ts +6 -0
- package/dist/components/PageHeader/PageHeader.js +27 -27
- package/dist/components/PageHeader/PageHeader.js.map +1 -1
- package/dist/components/Pagination/Pagination.js +31 -30
- package/dist/components/Pagination/Pagination.js.map +1 -1
- 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/QRCode/QRCode.d.ts +56 -0
- package/dist/components/QRCode/QRCode.js +48 -0
- package/dist/components/QRCode/QRCode.js.map +1 -0
- package/dist/components/QRCode/index.d.ts +1 -0
- package/dist/components/RadioGroup/RadioGroup.js +32 -24
- package/dist/components/RadioGroup/RadioGroup.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 +57 -0
- package/dist/components/Section/Section.js +27 -0
- package/dist/components/Section/Section.js.map +1 -0
- package/dist/components/Section/index.d.ts +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +6 -3
- package/dist/components/SegmentedControl/SegmentedControl.js +24 -20
- 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 -156
- 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/Sheet/Sheet.js +12 -7
- package/dist/components/Sheet/Sheet.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +13 -1
- package/dist/components/SideNav/SideNav.js +100 -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/SiteFooter/SiteFooter.d.ts +66 -0
- package/dist/components/SiteFooter/SiteFooter.js +80 -0
- package/dist/components/SiteFooter/SiteFooter.js.map +1 -0
- package/dist/components/SiteFooter/index.d.ts +1 -0
- package/dist/components/SiteHeader/SiteHeader.d.ts +78 -0
- package/dist/components/SiteHeader/SiteHeader.js +114 -0
- package/dist/components/SiteHeader/SiteHeader.js.map +1 -0
- package/dist/components/SiteHeader/index.d.ts +1 -0
- package/dist/components/SkipLink/SkipLink.d.ts +42 -0
- package/dist/components/SkipLink/SkipLink.js +43 -0
- package/dist/components/SkipLink/SkipLink.js.map +1 -0
- package/dist/components/SkipLink/index.d.ts +1 -0
- 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 +146 -120
- 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 +16 -7
- package/dist/components/Stack/Stack.js +32 -18
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -1
- package/dist/components/Stat/Stat.d.ts +88 -0
- package/dist/components/Stat/Stat.js +105 -0
- package/dist/components/Stat/Stat.js.map +1 -0
- package/dist/components/Stat/index.d.ts +1 -0
- 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/Steps/Steps.d.ts +10 -4
- package/dist/components/Steps/Steps.js +31 -30
- package/dist/components/Steps/Steps.js.map +1 -1
- package/dist/components/Switch/Switch.d.ts +4 -4
- package/dist/components/Switch/Switch.js +18 -7
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Table/Table.d.ts +6 -6
- package/dist/components/Table/Table.js +73 -102
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +55 -6
- package/dist/components/Tabs/Tabs.js +288 -169
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.d.ts +10 -2
- package/dist/components/TagInput/TagInput.js +137 -148
- 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 +22 -6
- package/dist/components/TextField/TextField.js +59 -53
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +7 -1
- package/dist/components/ThemeToggle/ThemeToggle.js +33 -30
- package/dist/components/ThemeToggle/ThemeToggle.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 +166 -147
- 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 +23 -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/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +17 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/components/VisuallyHidden/index.d.ts +1 -0
- 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/HiddenValue/HiddenValue.js +5 -5
- package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
- package/dist/foundations/Icon/Icon.d.ts +6 -1
- package/dist/foundations/Icon/Icon.js +15 -14
- package/dist/foundations/Icon/Icon.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/image-outcome.d.ts +8 -3
- package/dist/foundations/image-outcome.js +12 -8
- package/dist/foundations/image-outcome.js.map +1 -1
- package/dist/foundations/keys.js +12 -13
- package/dist/foundations/keys.js.map +1 -1
- package/dist/foundations/layout.d.ts +81 -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/printing.d.ts +6 -0
- package/dist/foundations/printing.js +17 -0
- package/dist/foundations/printing.js.map +1 -0
- package/dist/foundations/qr.d.ts +42 -0
- package/dist/foundations/qr.js +245 -0
- package/dist/foundations/qr.js.map +1 -0
- 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/book-marked.d.ts +2 -0
- package/dist/icons/book-marked.js +14 -0
- package/dist/icons/book-marked.js.map +1 -0
- 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/calendar-days.d.ts +2 -0
- package/dist/icons/calendar-days.js +24 -0
- package/dist/icons/calendar-days.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/check-square.d.ts +2 -0
- package/dist/icons/check-square.js +14 -0
- package/dist/icons/check-square.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/crescent.d.ts +2 -0
- package/dist/icons/crescent.js +14 -0
- package/dist/icons/crescent.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 -240
- package/dist/icons/index.js +546 -478
- package/dist/icons/kaaba.d.ts +2 -0
- package/dist/icons/kaaba.js +14 -0
- package/dist/icons/kaaba.js.map +1 -0
- package/dist/icons/keywords.d.ts +35 -1
- package/dist/icons/keywords.js +274 -1
- 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/list-tree.d.ts +2 -0
- package/dist/icons/list-tree.js +14 -0
- package/dist/icons/list-tree.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/mosque.d.ts +2 -0
- package/dist/icons/mosque.js +14 -0
- package/dist/icons/mosque.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/prayer-beads.d.ts +2 -0
- package/dist/icons/prayer-beads.js +67 -0
- package/dist/icons/prayer-beads.js.map +1 -0
- package/dist/icons/qr-code.d.ts +2 -0
- package/dist/icons/qr-code.js +38 -0
- package/dist/icons/qr-code.js.map +1 -0
- package/dist/icons/refresh-cw.d.ts +2 -0
- package/dist/icons/refresh-cw.js +14 -0
- package/dist/icons/refresh-cw.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/types.d.ts +1 -1
- package/dist/icons/types.js +2 -1
- package/dist/icons/types.js.map +1 -1
- 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 +38 -9
- package/dist/index.js +326 -249
- 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/announcer.css +1 -1
- package/dist/styles/app-shell.css +1 -1
- package/dist/styles/avatar.css +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/checkbox.css +1 -1
- package/dist/styles/choice-base.css +1 -0
- package/dist/styles/choice.css +1 -1
- package/dist/styles/code-block.css +1 -1
- package/dist/styles/color-field.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +1 -1
- package/dist/styles/copy-button.css +1 -1
- package/dist/styles/data-grid.css +1 -0
- package/dist/styles/date-field.css +1 -1
- package/dist/styles/device-frame.css +1 -0
- package/dist/styles/dialog.css +1 -1
- 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/floating-toolbar.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/grid.css +1 -1
- package/dist/styles/heading.css +1 -1
- package/dist/styles/highlighted-text.css +1 -0
- package/dist/styles/hotkey-field.css +1 -0
- package/dist/styles/icon-tile.css +1 -0
- package/dist/styles/icon.css +1 -1
- package/dist/styles/inline.css +1 -0
- package/dist/styles/key-value-editor.css +1 -1
- package/dist/styles/link.css +1 -1
- package/dist/styles/list-row.css +1 -0
- package/dist/styles/list.css +1 -0
- package/dist/styles/loading-dots.css +1 -1
- package/dist/styles/manifest.json +852 -0
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -0
- package/dist/styles/notice.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/option-list.css +1 -0
- package/dist/styles/overlay-frame.css +1 -0
- package/dist/styles/pagination.css +1 -1
- 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/qr-code.css +1 -0
- package/dist/styles/radio-group.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 -1
- package/dist/styles/section.css +1 -0
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sheet.css +1 -1
- package/dist/styles/side-nav.css +1 -1
- package/dist/styles/site-footer.css +1 -0
- package/dist/styles/site-header.css +1 -0
- package/dist/styles/skip-link.css +1 -0
- package/dist/styles/sort-button.css +1 -0
- package/dist/styles/sortable-list.css +1 -1
- package/dist/styles/split-pane.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/stat.css +1 -0
- package/dist/styles/status-bar.css +1 -0
- package/dist/styles/steps.css +1 -1
- package/dist/styles/switch.css +1 -0
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/tag-input.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/time-field.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/visually-hidden.css +1 -0
- 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 +194 -125
- 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 +15 -6
- package/dist/components/Checkbox/ChoiceRow.d.ts +0 -39
- package/dist/components/Checkbox/ChoiceRow.js +0 -58
- package/dist/components/Checkbox/ChoiceRow.js.map +0 -1
- package/dist/components/Stack/space.d.ts +0 -18
- package/dist/components/Stack/space.js +0 -12
- package/dist/components/Stack/space.js.map +0 -1
- package/dist/styles/hidden-value.css +0 -1
- package/dist/styles/iconbutton.css +0 -1
|
@@ -1,181 +1,225 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useControllableState as
|
|
2
|
+
import { useControllableState as Q } from "../../foundations/controllable.js";
|
|
3
3
|
import { Icon as T } from "../../foundations/Icon/Icon.js";
|
|
4
|
-
import { useClientLayoutEffect as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
4
|
+
import { useClientLayoutEffect as _ } from "../../foundations/client-layout-effect.js";
|
|
5
|
+
import { deepActiveElement as J } from "../../foundations/focus.js";
|
|
6
|
+
import { useDismiss as V } from "../../overlay/dismiss.js";
|
|
7
|
+
import { DialogBase as W } from "../../foundations/DialogBase/DialogBase.js";
|
|
8
|
+
import { Badge as X } from "../Badge/Badge.js";
|
|
9
|
+
import { useHotkey as Y } from "../../foundations/hotkey.js";
|
|
10
|
+
import { useActiveOption as Z } from "../../foundations/listbox.js";
|
|
11
|
+
import { Kbd as ee } from "../Kbd/Kbd.js";
|
|
12
|
+
import { isComposing as te } from "../../foundations/keys.js";
|
|
13
|
+
import { InputBase as oe } from "../../foundations/InputBase/InputBase.js";
|
|
14
|
+
import { textMatchAt as re, textMatches as se } from "../../foundations/text-match.js";
|
|
15
|
+
import { HighlightedText as ae } from "../HighlightedText/HighlightedText.js";
|
|
16
|
+
import { search as ne } from "../../icons/search.js";
|
|
17
|
+
import { Fragment as ie, useId as le, useMemo as j, useRef as w, useState as F } from "react";
|
|
18
|
+
import { jsx as i, jsxs as b } from "react/jsx-runtime";
|
|
19
|
+
function ce(s, d, f) {
|
|
20
|
+
const l = [], c = /* @__PURE__ */ new Map();
|
|
21
|
+
for (const o of s) {
|
|
22
|
+
const a = f(o, d);
|
|
23
|
+
if (!a) continue;
|
|
24
|
+
const m = a === !0 ? {} : a;
|
|
25
|
+
l.push({
|
|
26
|
+
command: o,
|
|
27
|
+
score: m.score ?? 0
|
|
28
|
+
}), c.set(o.id, m.positions ?? []);
|
|
29
|
+
}
|
|
30
|
+
return l.sort((o, a) => o.score - a.score), {
|
|
31
|
+
found: l.map((o) => o.command),
|
|
32
|
+
positions: c
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var pe = {
|
|
15
36
|
title: "Command palette",
|
|
16
37
|
placeholder: "Search commands",
|
|
17
38
|
empty: "No commands found",
|
|
18
39
|
recent: "Recent"
|
|
19
|
-
};
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const C = (r) => [r.label, ...r.keywords ?? []].join(" ").toLowerCase(), b = d.filter((r) => p.every((k) => C(r).includes(k))), v = p[0];
|
|
24
|
-
return [...b.filter((r) => r.label.toLowerCase().startsWith(v)), ...b.filter((r) => !r.label.toLowerCase().startsWith(v))];
|
|
40
|
+
}, de = (s) => s.split(/\s+/).filter(Boolean);
|
|
41
|
+
function me(s, d) {
|
|
42
|
+
const f = (o) => [o.label, ...o.keywords ?? []].join(" "), l = s.filter((o) => d.every((a) => se(f(o), a))), c = (o) => re(o.label, d[0]) === 0;
|
|
43
|
+
return [...l.filter(c), ...l.filter((o) => !c(o))];
|
|
25
44
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const e =
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
function Be({ commands: s, onRun: d, open: f, defaultOpen: l = !1, onOpenChange: c, shortcut: o = "mod+k", filter: a, recentLimit: m = 5, labels: K, className: $, style: R }) {
|
|
46
|
+
const p = {
|
|
47
|
+
...pe,
|
|
48
|
+
...K
|
|
49
|
+
}, y = le().replace(/:/g, ""), [u, h] = Q(f, l, c), [g, A] = F(""), [I, q] = F([]), N = w(null), M = w(null), B = w(null), E = w(null);
|
|
50
|
+
Y(o, () => h(!u));
|
|
51
|
+
const v = j(() => de(g), [g]), { sections: O, positions: z } = j(() => {
|
|
52
|
+
const e = [];
|
|
53
|
+
if (v.length) {
|
|
54
|
+
const { found: t, positions: r } = a ? ce(s, g.trim(), a) : {
|
|
55
|
+
found: me(s, v),
|
|
56
|
+
positions: void 0
|
|
57
|
+
};
|
|
58
|
+
return e.push({
|
|
59
|
+
name: void 0,
|
|
60
|
+
items: t,
|
|
61
|
+
tagged: !0
|
|
62
|
+
}), {
|
|
63
|
+
sections: e,
|
|
64
|
+
positions: r
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (m > 0) {
|
|
68
|
+
const t = I.map((r) => s.find((D) => D.id === r)).filter((r) => !!r).slice(0, m);
|
|
69
|
+
t.length && e.push({
|
|
70
|
+
name: p.recent,
|
|
71
|
+
items: t,
|
|
72
|
+
tagged: !0
|
|
39
73
|
});
|
|
40
74
|
}
|
|
41
|
-
const
|
|
42
|
-
for (const
|
|
43
|
-
for (const [
|
|
44
|
-
name:
|
|
45
|
-
items:
|
|
75
|
+
const n = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const t of s) n.set(t.group, [...n.get(t.group) ?? [], t]);
|
|
77
|
+
for (const [t, r] of n) e.push({
|
|
78
|
+
name: t,
|
|
79
|
+
items: r,
|
|
80
|
+
tagged: !1
|
|
46
81
|
});
|
|
47
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
sections: e,
|
|
84
|
+
positions: void 0
|
|
85
|
+
};
|
|
48
86
|
}, [
|
|
49
|
-
|
|
87
|
+
s,
|
|
50
88
|
g,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
89
|
+
v,
|
|
90
|
+
a,
|
|
91
|
+
I,
|
|
92
|
+
m,
|
|
93
|
+
p.recent
|
|
94
|
+
]), x = O.flatMap((e) => e.items.map((n) => ({
|
|
95
|
+
command: n,
|
|
56
96
|
section: e.name
|
|
57
|
-
}))),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const e = document.activeElement;
|
|
61
|
-
R.current = e?.shadowRoot?.activeElement instanceof HTMLElement ? e.shadowRoot.activeElement : e, L(""), y(0), I.current?.focus();
|
|
62
|
-
}, [u]), j(() => {
|
|
63
|
-
m.includes(n) || y(m[0] ?? -1);
|
|
64
|
-
}), j(() => {
|
|
65
|
-
M.current?.querySelector(`#${s}-${n}`)?.scrollIntoView?.({ block: "nearest" });
|
|
66
|
-
}, [n, s]), W({
|
|
97
|
+
}))), { active: k, activeId: H, optionId: L, setActive: C, move: U } = Z({
|
|
98
|
+
id: y,
|
|
99
|
+
list: B,
|
|
67
100
|
open: u,
|
|
68
|
-
|
|
101
|
+
count: x.length,
|
|
102
|
+
usable: (e) => !x[e]?.command.disabled,
|
|
103
|
+
wrap: !0
|
|
104
|
+
});
|
|
105
|
+
_(() => {
|
|
106
|
+
u && (E.current = J(), A(""), C(0), M.current?.focus());
|
|
107
|
+
}, [u]), V({
|
|
108
|
+
open: u,
|
|
109
|
+
onClose: () => h(!1),
|
|
69
110
|
inside: [N],
|
|
70
|
-
returnFocus:
|
|
111
|
+
returnFocus: E,
|
|
71
112
|
outside: (e) => e.composedPath()[0] === N.current
|
|
72
113
|
});
|
|
73
|
-
const
|
|
74
|
-
!e || e.disabled || (
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
const o = m.indexOf(n);
|
|
78
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
79
|
-
e.preventDefault();
|
|
80
|
-
const t = e.key === "ArrowDown" ? 1 : -1;
|
|
81
|
-
y(m[(o + t + m.length) % m.length] ?? -1);
|
|
82
|
-
} else e.key === "Enter" && (e.preventDefault(), B(x[n]?.command));
|
|
114
|
+
const P = (e) => {
|
|
115
|
+
!e || e.disabled || (q((n) => [e.id, ...n.filter((t) => t !== e.id)].slice(0, 20)), h(!1), d(e.id));
|
|
116
|
+
}, G = (e) => {
|
|
117
|
+
te(e) || (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), U(e.key === "ArrowDown" ? 1 : -1)) : e.key === "Enter" && (e.preventDefault(), P(x[k]?.command)));
|
|
83
118
|
};
|
|
84
|
-
let
|
|
85
|
-
return /* @__PURE__ */
|
|
119
|
+
let S = -1;
|
|
120
|
+
return /* @__PURE__ */ i(W, {
|
|
86
121
|
ref: N,
|
|
87
122
|
open: u,
|
|
88
|
-
onCancel: () =>
|
|
89
|
-
onClose: () =>
|
|
123
|
+
onCancel: () => h(!1),
|
|
124
|
+
onClose: () => h(!1),
|
|
90
125
|
className: "cy-command-palette",
|
|
91
|
-
"aria-label":
|
|
92
|
-
children: /* @__PURE__ */
|
|
93
|
-
className:
|
|
94
|
-
style:
|
|
95
|
-
children: [/* @__PURE__ */
|
|
126
|
+
"aria-label": p.title,
|
|
127
|
+
children: /* @__PURE__ */ b("div", {
|
|
128
|
+
className: $ ? `cy-command-palette-panel cy-reset ${$}` : "cy-command-palette-panel cy-reset",
|
|
129
|
+
style: R,
|
|
130
|
+
children: [/* @__PURE__ */ b("div", {
|
|
96
131
|
className: "cy-command-palette-search cy-reset",
|
|
97
|
-
children: [/* @__PURE__ */
|
|
98
|
-
icon:
|
|
132
|
+
children: [/* @__PURE__ */ i(T, {
|
|
133
|
+
icon: ne,
|
|
99
134
|
className: "cy-command-palette-search-icon"
|
|
100
|
-
}), /* @__PURE__ */
|
|
101
|
-
ref:
|
|
135
|
+
}), /* @__PURE__ */ i(oe, {
|
|
136
|
+
ref: M,
|
|
102
137
|
className: "cy-command-palette-input",
|
|
103
138
|
role: "combobox",
|
|
104
|
-
"aria-label":
|
|
139
|
+
"aria-label": p.title,
|
|
105
140
|
"aria-expanded": "true",
|
|
106
|
-
"aria-controls": `${
|
|
141
|
+
"aria-controls": `${y}-list`,
|
|
107
142
|
"aria-autocomplete": "list",
|
|
108
|
-
"aria-activedescendant":
|
|
143
|
+
"aria-activedescendant": H,
|
|
109
144
|
autoComplete: "off",
|
|
110
145
|
spellCheck: !1,
|
|
111
|
-
placeholder:
|
|
146
|
+
placeholder: p.placeholder,
|
|
112
147
|
value: g,
|
|
113
148
|
onChange: (e) => {
|
|
114
|
-
|
|
149
|
+
A(e.currentTarget.value), C(0);
|
|
115
150
|
},
|
|
116
|
-
onKeyDown:
|
|
151
|
+
onKeyDown: G
|
|
117
152
|
})]
|
|
118
|
-
}), /* @__PURE__ */
|
|
119
|
-
ref:
|
|
120
|
-
id: `${
|
|
153
|
+
}), /* @__PURE__ */ b("div", {
|
|
154
|
+
ref: B,
|
|
155
|
+
id: `${y}-list`,
|
|
121
156
|
role: "listbox",
|
|
122
|
-
"aria-label":
|
|
157
|
+
"aria-label": p.title,
|
|
123
158
|
className: "cy-command-palette-list cy-reset",
|
|
124
|
-
children: [x.length === 0 && /* @__PURE__ */
|
|
159
|
+
children: [x.length === 0 && /* @__PURE__ */ i("div", {
|
|
125
160
|
role: "option",
|
|
126
161
|
"aria-disabled": "true",
|
|
127
162
|
"aria-selected": "false",
|
|
128
163
|
tabIndex: -1,
|
|
129
164
|
className: "cy-command-palette-empty cy-reset",
|
|
130
|
-
children:
|
|
131
|
-
}),
|
|
165
|
+
children: p.empty
|
|
166
|
+
}), O.map((e, n) => /* @__PURE__ */ b("div", {
|
|
132
167
|
role: "group",
|
|
133
|
-
"aria-labelledby": e.name ? `${
|
|
168
|
+
"aria-labelledby": e.name ? `${y}-g${n}` : void 0,
|
|
134
169
|
className: "cy-command-palette-group cy-reset",
|
|
135
|
-
children: [e.name && /* @__PURE__ */
|
|
136
|
-
id: `${
|
|
170
|
+
children: [e.name && /* @__PURE__ */ i("div", {
|
|
171
|
+
id: `${y}-g${n}`,
|
|
137
172
|
className: "cy-command-palette-heading cy-reset",
|
|
138
173
|
role: "presentation",
|
|
139
174
|
children: e.name
|
|
140
175
|
}), e.items.map((t) => {
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
return /* @__PURE__ */
|
|
144
|
-
id:
|
|
176
|
+
S++;
|
|
177
|
+
const r = S;
|
|
178
|
+
return /* @__PURE__ */ i(ie, { children: /* @__PURE__ */ b("div", {
|
|
179
|
+
id: L(r),
|
|
145
180
|
role: "option",
|
|
146
181
|
tabIndex: -1,
|
|
147
|
-
"aria-selected":
|
|
182
|
+
"aria-selected": r === k,
|
|
148
183
|
"aria-disabled": t.disabled || void 0,
|
|
149
|
-
"data-active":
|
|
184
|
+
"data-active": r === k || void 0,
|
|
150
185
|
className: "cy-command-palette-item cy-reset",
|
|
151
|
-
onPointerMove: () => !t.disabled &&
|
|
152
|
-
onPointerDown: (
|
|
153
|
-
onClick: () =>
|
|
186
|
+
onPointerMove: () => !t.disabled && C(r),
|
|
187
|
+
onPointerDown: (D) => D.preventDefault(),
|
|
188
|
+
onClick: () => P(t),
|
|
154
189
|
onKeyDown: () => {
|
|
155
190
|
},
|
|
156
191
|
children: [
|
|
157
|
-
t.icon && /* @__PURE__ */
|
|
192
|
+
t.icon && /* @__PURE__ */ i(T, {
|
|
158
193
|
icon: t.icon,
|
|
159
194
|
className: "cy-command-palette-icon"
|
|
160
195
|
}),
|
|
161
|
-
/* @__PURE__ */
|
|
196
|
+
/* @__PURE__ */ i("span", {
|
|
162
197
|
className: "cy-command-palette-label cy-reset",
|
|
163
|
-
children:
|
|
198
|
+
children: /* @__PURE__ */ i(ae, {
|
|
199
|
+
text: t.label,
|
|
200
|
+
query: v,
|
|
201
|
+
positions: z?.get(t.id)
|
|
202
|
+
})
|
|
203
|
+
}),
|
|
204
|
+
e.tagged && t.group && /* @__PURE__ */ i(X, {
|
|
205
|
+
size: "sm",
|
|
206
|
+
className: "cy-command-palette-tag",
|
|
207
|
+
children: t.group
|
|
164
208
|
}),
|
|
165
|
-
t.shortcut && /* @__PURE__ */
|
|
209
|
+
t.shortcut && /* @__PURE__ */ i(ee, {
|
|
166
210
|
keys: t.shortcut,
|
|
167
211
|
size: "sm"
|
|
168
212
|
})
|
|
169
213
|
]
|
|
170
214
|
}) }, `${e.name}-${t.id}`);
|
|
171
215
|
})]
|
|
172
|
-
}, `${
|
|
216
|
+
}, `${n}-${e.name}`))]
|
|
173
217
|
})]
|
|
174
218
|
})
|
|
175
219
|
});
|
|
176
220
|
}
|
|
177
221
|
export {
|
|
178
|
-
|
|
222
|
+
Be as CommandPalette
|
|
179
223
|
};
|
|
180
224
|
|
|
181
225
|
//# sourceMappingURL=CommandPalette.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandPalette.js","names":["useControllableState","Icon","useClientLayoutEffect","useDismiss","DialogBase","useHotkey","Kbd","isComposing","InputBase","search","Fragment","useEffect","useId","useMemo","useRef","useState","jsx","jsxs","DEFAULT_LABELS","rank","commands","query","words","hay","c","found","w","first","CommandPalette","onRun","open","defaultOpen","onOpenChange","shortcut","recentLimit","labels","className","style","text","id","isOpen","setOpen","setQuery","recent","setRecent","active","setActive","dialog","input","list","returnTo","sections","matches","out","recents","r","byGroup","name","items","rows","s","runnable","i","event","run","command","x","onKeyDown","at","step","index","section","e"],"sources":["../../../src/components/CommandPalette/CommandPalette.tsx"],"sourcesContent":["import {\n type CSSProperties,\n Fragment,\n type KeyboardEvent,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { DialogBase } from \"../../foundations/DialogBase/DialogBase.js\";\nimport { useHotkey } from \"../../foundations/hotkey.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { InputBase } from \"../../foundations/InputBase/InputBase.js\";\nimport { isComposing } from \"../../foundations/keys.js\";\nimport { search } from \"../../icons/search.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { Kbd } from \"../Kbd/Kbd.js\";\n\nexport interface CommandPaletteTokens {\n width: string;\n offset: string;\n listMaxHeight: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n commandPalette: CommandPaletteTokens;\n }\n}\n\nexport interface Command {\n id: string;\n label: string;\n /** Heading the command is listed under. */\n group?: string;\n /** Keys shown at the end of the row: [\"Ctrl\", \"S\"], or \"mod+s\" for this platform's names. Display only: bind them yourself. */\n shortcut?: string[] | string;\n icon?: IconData;\n /** More words that find it (\"save\" also finds \"Write to disk\"). */\n keywords?: string[];\n disabled?: boolean;\n}\n\nexport interface CommandPaletteLabels {\n /** Accessible name of the palette. */\n title: string;\n placeholder: string;\n empty: string;\n /** Heading of the recently run commands, shown before you type. */\n recent: string;\n}\n\nexport interface CommandPaletteProps {\n /** The commands to search and run. */\n commands: Command[];\n /** Called with the chosen command's id; the palette then closes. */\n onRun: (id: string) => void;\n /** Controlled: whether the palette is open. */\n open?: boolean;\n /** Open at first, when uncontrolled. */\n defaultOpen?: boolean;\n /**\n * Called when the palette opens or closes (shortcut, Escape, a press outside, running a command), with the new\n * state.\n */\n onOpenChange?: (open: boolean) => void;\n /** Global shortcut that toggles the palette (`mod` is Command on Apple platforms, else Control). `false`: none. */\n shortcut?: string | false;\n /** How many recently run commands to list before you type (default 5, 0 for none). */\n recentLimit?: number;\n /** Replace the built-in English text: the palette's name, the placeholder, the empty note and the recent heading. */\n labels?: Partial<CommandPaletteLabels>;\n /** Added to the panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: CommandPaletteLabels = {\n title: \"Command palette\",\n placeholder: \"Search commands\",\n empty: \"No commands found\",\n recent: \"Recent\",\n};\n\n/** Every word of the query must appear in the label or keywords; label prefix matches rank first. */\nfunction rank(commands: Command[], query: string): Command[] {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (!words.length) return commands;\n const hay = (c: Command) => [c.label, ...(c.keywords ?? [])].join(\" \").toLowerCase();\n const found = commands.filter((c) => words.every((w) => hay(c).includes(w)));\n const first = words[0] as string;\n return [\n ...found.filter((c) => c.label.toLowerCase().startsWith(first)),\n ...found.filter((c) => !c.label.toLowerCase().startsWith(first)),\n ];\n}\n\n/** Search-and-run list of commands in a modal dialog, opened by a global shortcut (Ctrl or Command + K). */\nexport function CommandPalette({\n commands,\n onRun,\n open,\n defaultOpen = false,\n onOpenChange,\n shortcut = \"mod+k\",\n recentLimit = 5,\n labels,\n className,\n style,\n}: CommandPaletteProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const id = useId().replace(/:/g, \"\");\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const [query, setQuery] = useState(\"\");\n const [recent, setRecent] = useState<string[]>([]);\n const [active, setActive] = useState(0);\n const dialog = useRef<HTMLDialogElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const list = useRef<HTMLDivElement>(null);\n const returnTo = useRef<HTMLElement | null>(null);\n\n useHotkey(shortcut, () => setOpen(!isOpen));\n\n // Rows: recent commands first while the query is empty, then the matches grouped by `group` in first-seen order.\n const sections = useMemo(() => {\n const matches = rank(commands, query);\n const out: { name: string | undefined; items: Command[] }[] = [];\n if (!query && recentLimit > 0) {\n const recents = recent\n .map((r) => commands.find((c) => c.id === r))\n .filter((c): c is Command => !!c)\n .slice(0, recentLimit);\n if (recents.length) out.push({ name: text.recent, items: recents });\n }\n const byGroup = new Map<string | undefined, Command[]>();\n for (const c of matches) byGroup.set(c.group, [...(byGroup.get(c.group) ?? []), c]);\n for (const [name, items] of byGroup) out.push({ name, items });\n return out;\n }, [commands, query, recent, recentLimit, text.recent]);\n const rows = sections.flatMap((s) => s.items.map((c) => ({ command: c, section: s.name })));\n const runnable = rows.map((r, i) => (r.command.disabled ? -1 : i)).filter((i) => i >= 0);\n\n // Opening: remember where focus was, start fresh, and focus the search field.\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n const active = document.activeElement as HTMLElement | null;\n returnTo.current =\n active?.shadowRoot?.activeElement instanceof HTMLElement ? active.shadowRoot.activeElement : active;\n setQuery(\"\");\n setActive(0);\n input.current?.focus();\n }, [isOpen]);\n useEffect(() => {\n if (!runnable.includes(active)) setActive(runnable[0] ?? -1);\n });\n useEffect(() => {\n list.current?.querySelector(`#${id}-${active}`)?.scrollIntoView?.({ block: \"nearest\" });\n }, [active, id]);\n useDismiss({\n open: isOpen,\n onClose: () => setOpen(false),\n inside: [dialog],\n returnFocus: returnTo,\n outside: (event) => event.composedPath()[0] === dialog.current,\n });\n\n const run = (command: Command | undefined) => {\n if (!command || command.disabled) return;\n setRecent((r) => [command.id, ...r.filter((x) => x !== command.id)].slice(0, 20));\n setOpen(false);\n onRun(command.id);\n };\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (isComposing(event)) return;\n const at = runnable.indexOf(active);\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n // Arrows wrap around, so the last command is one key away.\n const step = event.key === \"ArrowDown\" ? 1 : -1;\n setActive(runnable[(at + step + runnable.length) % runnable.length] ?? -1);\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n run(rows[active]?.command);\n }\n };\n\n let index = -1;\n return (\n <DialogBase\n ref={dialog}\n open={isOpen}\n onCancel={() => setOpen(false)}\n onClose={() => setOpen(false)}\n className=\"cy-command-palette\"\n aria-label={text.title}\n >\n <div\n className={\n className ? `cy-command-palette-panel cy-reset ${className}` : \"cy-command-palette-panel cy-reset\"\n }\n style={style}\n >\n <div className=\"cy-command-palette-search cy-reset\">\n <Icon icon={search} className=\"cy-command-palette-search-icon\" />\n <InputBase\n ref={input}\n className=\"cy-command-palette-input\"\n role=\"combobox\"\n aria-label={text.title}\n aria-expanded=\"true\"\n aria-controls={`${id}-list`}\n aria-autocomplete=\"list\"\n aria-activedescendant={active >= 0 ? `${id}-${active}` : undefined}\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={text.placeholder}\n value={query}\n onChange={(e) => {\n setQuery(e.currentTarget.value);\n setActive(0);\n }}\n onKeyDown={onKeyDown}\n />\n </div>\n <div\n ref={list}\n id={`${id}-list`}\n role=\"listbox\"\n aria-label={text.title}\n className=\"cy-command-palette-list cy-reset\"\n >\n {rows.length === 0 && (\n // A listbox may only hold options: the empty message is a disabled one.\n <div\n role=\"option\"\n aria-disabled=\"true\"\n aria-selected=\"false\"\n tabIndex={-1}\n className=\"cy-command-palette-empty cy-reset\"\n >\n {text.empty}\n </div>\n )}\n {sections.map((section, s) => (\n // biome-ignore lint/a11y/useSemanticElements: a listbox may only hold options and role=\"group\" (no fieldset)\n <div\n key={`${s}-${section.name}`}\n role=\"group\"\n aria-labelledby={section.name ? `${id}-g${s}` : undefined}\n className=\"cy-command-palette-group cy-reset\"\n >\n {section.name && (\n <div id={`${id}-g${s}`} className=\"cy-command-palette-heading cy-reset\" role=\"presentation\">\n {section.name}\n </div>\n )}\n {section.items.map((command) => {\n index++;\n const i = index;\n return (\n <Fragment key={`${section.name}-${command.id}`}>\n <div\n id={`${id}-${i}`}\n role=\"option\"\n tabIndex={-1}\n aria-selected={i === active}\n aria-disabled={command.disabled || undefined}\n data-active={i === active || undefined}\n className=\"cy-command-palette-item cy-reset\"\n onPointerMove={() => !command.disabled && setActive(i)}\n onPointerDown={(e) => e.preventDefault()}\n onClick={() => run(command)}\n onKeyDown={() => {}}\n >\n {command.icon && <Icon icon={command.icon} className=\"cy-command-palette-icon\" />}\n <span className=\"cy-command-palette-label cy-reset\">{command.label}</span>\n {command.shortcut && <Kbd keys={command.shortcut} size=\"sm\" />}\n </div>\n </Fragment>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n </DialogBase>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkFA,IAAMkB,KAAuC;AAAA,EAC3C,OAAO;AAAA,EACP,aAAa;AAAA,EACb,OAAO;AAAA,EACP,QAAQ;AACV;AAGA,SAASC,GAAKC,GAAqBC,GAA0B;AAC3D,QAAMC,IAAQD,EAAM,YAAY,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO;AAC7D,MAAI,CAACC,EAAM,OAAQ,QAAOF;AAC1B,QAAMG,IAAA,CAAOC,MAAe,CAACA,EAAE,OAAO,GAAIA,EAAE,YAAY,CAAC,CAAE,EAAE,KAAK,GAAG,EAAE,YAAY,GAC7EC,IAAQL,EAAS,OAAA,CAAQI,MAAMF,EAAM,MAAA,CAAOI,MAAMH,EAAIC,CAAC,EAAE,SAASE,CAAC,CAAC,CAAC,GACrEC,IAAQL,EAAM,CAAA;AACpB,SAAO,CACL,GAAGG,EAAM,OAAA,CAAQD,MAAMA,EAAE,MAAM,YAAY,EAAE,WAAWG,CAAK,CAAC,GAC9D,GAAGF,EAAM,OAAA,CAAQD,MAAM,CAACA,EAAE,MAAM,YAAY,EAAE,WAAWG,CAAK,CAAC,CACjE;AACF;AAGA,SAAgBC,GAAe,EAC7B,UAAAR,GACA,OAAAS,GACA,MAAAC,GACA,aAAAC,IAAc,IACd,cAAAC,GACA,UAAAC,IA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,IAAI,GAAGsB,CAAA,IAAMuB,CAAA;AAAA,cACb,MAAK;AAAA,cACL,UAAU;AAAA,cACV,iBAAeA,MAAMjB;AAAA,cACrB,iBAAeoB,EAAQ,YAAY;AAAA,cACnC,eAAaH,MAAMjB,KAAU;AAAA,cAC7B,WAAU;AAAA,cACV,eAAA,MAAqB,CAACoB,EAAQ,YAAYnB,EAAUgB,CAAC;AAAA,cACrD,eAAA,CAAgBU,MAAMA,EAAE,eAAe;AAAA,cACvC,SAAA,MAAeR,EAAIC,CAAO;AAAA,cAC1B,WAAA,MAAiB;AAAA,cAAC;AAAA,cAXpB,UAAA;AAAA,gBAaGA,EAAQ,QAAQ,gBAAAjD,EAACf,GAAD;AAAA,kBAAM,MAAMgE,EAAQ;AAAA,kBAAM,WAAU;AAAA,gBAA2B,CAAA;AAAA,gBAChF,gBAAAjD,EAAC,QAAD;AAAA,kBAAM,WAAU;AAAA,kBAAqC,UAAAiD,EAAQ;AAAA,gBAAY,CAAA;AAAA,gBACxEA,EAAQ,YAAY,gBAAAjD,EAACV,GAAD;AAAA,kBAAK,MAAM2D,EAAQ;AAAA,kBAAU,MAAK;AAAA,gBAAM,CAAA;AAAA,cAC1D;AAAA,YACG,CAAA,EAAA,GAlBK,GAAGM,EAAQ,IAAA,IAAQN,EAAQ,EAAA,EAkBhC;AAAA,UAEd,CAAC,CACE;AAAA,QAnCE,GAAA,GAAGL,CAAA,IAAKW,EAAQ,IAAA,EAmClB,CACN,CACE;AAAA,MACF,CAAA,CAAA;AAAA,I;A,EACK,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"CommandPalette.js","names":["useControllableState","Icon","useClientLayoutEffect","deepActiveElement","useDismiss","DialogBase","Badge","useHotkey","useActiveOption","Kbd","isComposing","InputBase","textMatchAt","textMatches","HighlightedText","search","Fragment","useId","useMemo","useRef","useState","jsx","jsxs","filtered","commands","query","filter","kept","positions","command","match","found","a","b","k","DEFAULT_LABELS","wordsOf","rank","words","hay","c","w","prefixed","CommandPalette","onRun","open","defaultOpen","onOpenChange","shortcut","recentLimit","labels","className","style","text","id","isOpen","setOpen","setQuery","recent","setRecent","dialog","input","list","returnTo","sections","out","recents","byGroup","name","items","rows","s","active","activeId","optionId","setActive","move","i","event","run","r","x","onKeyDown","index","section","e"],"sources":["../../../src/components/CommandPalette/CommandPalette.tsx"],"sourcesContent":["import { type CSSProperties, Fragment, type KeyboardEvent, useId, useMemo, 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 { useHotkey } from \"../../foundations/hotkey.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { InputBase } from \"../../foundations/InputBase/InputBase.js\";\nimport { isComposing } from \"../../foundations/keys.js\";\nimport { useActiveOption } from \"../../foundations/listbox.js\";\nimport { textMatchAt, textMatches } from \"../../foundations/text-match.js\";\nimport { search } from \"../../icons/search.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { Badge } from \"../Badge/Badge.js\";\nimport { HighlightedText } from \"../HighlightedText/HighlightedText.js\";\nimport { Kbd } from \"../Kbd/Kbd.js\";\n\nexport interface CommandPaletteTokens {\n width: string;\n offset: string;\n listMaxHeight: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n commandPalette: CommandPaletteTokens;\n }\n}\n\nexport interface Command {\n id: string;\n label: string;\n /** Heading the command is listed under. */\n group?: string;\n /** Keys shown at the end of the row: [\"Ctrl\", \"S\"], or \"mod+s\" for this platform's names. Display only: bind them yourself. */\n shortcut?: string[] | string;\n icon?: IconData;\n /** More words that find it (\"save\" also finds \"Write to disk\"). */\n keywords?: string[];\n disabled?: boolean;\n}\n\n/** What a `filter` says about a command that matches: how well, and which letters of its label. */\nexport interface CommandMatch {\n /** Lower ranks first, as fuzzy matchers score. Matches without a score count as 0; ties keep `commands`' order. */\n score?: number | undefined;\n /** Indices of the matched characters in the label: they are marked (HighlightedText `positions`). */\n positions?: readonly number[] | undefined;\n}\n\nexport interface CommandPaletteLabels {\n /** Accessible name of the palette. */\n title: string;\n placeholder: string;\n empty: string;\n /** Heading of the recently run commands, shown before you type. */\n recent: string;\n}\n\n/** The commands a custom filter keeps, lowest score first (a stable sort), with the positions it marked. */\nfunction filtered(\n commands: Command[],\n query: string,\n filter: (command: Command, query: string) => CommandMatch | boolean | null | undefined,\n): { found: Command[]; positions: Map<string, readonly number[]> } {\n const kept: { command: Command; score: number }[] = [];\n const positions = new Map<string, readonly number[]>();\n for (const command of commands) {\n const match = filter(command, query);\n if (!match) continue;\n const found: CommandMatch = match === true ? {} : match;\n kept.push({ command, score: found.score ?? 0 });\n positions.set(command.id, found.positions ?? []);\n }\n kept.sort((a, b) => a.score - b.score);\n return { found: kept.map((k) => k.command), positions };\n}\n\nexport interface CommandPaletteProps {\n /** The commands to search and run. */\n commands: Command[];\n /** Called with the chosen command's id; the palette then closes. */\n onRun: (id: string) => void;\n /** Controlled: whether the palette is open. */\n open?: boolean;\n /** Open at first, when uncontrolled. */\n defaultOpen?: boolean;\n /**\n * Called when the palette opens or closes (shortcut, Escape, a press outside, running a command), with the new\n * state.\n */\n onOpenChange?: (open: boolean) => void;\n /** Global shortcut that toggles the palette (`mod` is Command on Apple platforms, else Control). `false`: none. */\n shortcut?: string | false;\n /**\n * Your own search, called for each command while there is a query: return a `CommandMatch` (`{ score, positions }`,\n * as fuzzy matchers return it), `true` to keep the command unmarked, or `null`/`false` to leave it out. Default:\n * every word of the query in the label or keywords, label prefixes first, the words marked.\n */\n filter?: ((command: Command, query: string) => CommandMatch | boolean | null | undefined) | undefined;\n /** How many recently run commands to list before you type (default 5, 0 for none). */\n recentLimit?: number;\n /** Replace the built-in English text: the palette's name, the placeholder, the empty note and the recent heading. */\n labels?: Partial<CommandPaletteLabels>;\n /** Added to the panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: CommandPaletteLabels = {\n title: \"Command palette\",\n placeholder: \"Search commands\",\n empty: \"No commands found\",\n recent: \"Recent\",\n};\n\n/** The words of a query. */\nconst wordsOf = (query: string) => query.split(/\\s+/).filter(Boolean);\n\n/** Every word of the query must appear in the label or keywords; label prefix matches rank first. */\nfunction rank(commands: Command[], words: string[]): Command[] {\n const hay = (c: Command) => [c.label, ...(c.keywords ?? [])].join(\" \");\n const found = commands.filter((c) => words.every((w) => textMatches(hay(c), w)));\n const prefixed = (c: Command) => textMatchAt(c.label, words[0] as string) === 0;\n return [...found.filter(prefixed), ...found.filter((c) => !prefixed(c))];\n}\n\n/** Search-and-run list of commands in a modal dialog, opened by a global shortcut (Ctrl or Command + K). */\nexport function CommandPalette({\n commands,\n onRun,\n open,\n defaultOpen = false,\n onOpenChange,\n shortcut = \"mod+k\",\n filter,\n recentLimit = 5,\n labels,\n className,\n style,\n}: CommandPaletteProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const id = useId().replace(/:/g, \"\");\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const [query, setQuery] = useState(\"\");\n const [recent, setRecent] = useState<string[]>([]);\n const dialog = useRef<HTMLDialogElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const list = useRef<HTMLDivElement>(null);\n const returnTo = useRef<HTMLElement | null>(null);\n\n useHotkey(shortcut, () => setOpen(!isOpen));\n\n // Each typed word is marked where it appears in a label (unless a custom filter gives the positions).\n const words = useMemo(() => wordsOf(query), [query]);\n // Rows. Browsing (no query): recent commands first, then every command under its group's heading, in first-seen\n // order. Searching: one flat list in rank order. `tagged` sections show each command's group as a tag.\n const { sections, positions } = useMemo(() => {\n const out: { name: string | undefined; items: Command[]; tagged: boolean }[] = [];\n if (words.length) {\n const { found, positions } = filter\n ? filtered(commands, query.trim(), filter)\n : { found: rank(commands, words), positions: undefined };\n out.push({ name: undefined, items: found, tagged: true });\n return { sections: out, positions };\n }\n if (recentLimit > 0) {\n const recents = recent\n .map((r) => commands.find((c) => c.id === r))\n .filter((c): c is Command => !!c)\n .slice(0, recentLimit);\n if (recents.length) out.push({ name: text.recent, items: recents, tagged: true });\n }\n const byGroup = new Map<string | undefined, Command[]>();\n for (const c of commands) byGroup.set(c.group, [...(byGroup.get(c.group) ?? []), c]);\n for (const [name, items] of byGroup) out.push({ name, items, tagged: false });\n return { sections: out, positions: undefined };\n }, [commands, query, words, filter, recent, recentLimit, text.recent]);\n const rows = sections.flatMap((s) => s.items.map((c) => ({ command: c, section: s.name })));\n // Arrows wrap around, so the last command is one key away.\n const { active, activeId, optionId, setActive, move } = useActiveOption({\n id,\n list,\n open: isOpen,\n count: rows.length,\n usable: (i) => !rows[i]?.command.disabled,\n wrap: true,\n });\n\n // Opening: remember where focus was, start fresh, and focus the search field.\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n returnTo.current = deepActiveElement();\n setQuery(\"\");\n setActive(0);\n input.current?.focus();\n }, [isOpen]);\n useDismiss({\n open: isOpen,\n onClose: () => setOpen(false),\n inside: [dialog],\n returnFocus: returnTo,\n outside: (event) => event.composedPath()[0] === dialog.current,\n });\n\n const run = (command: Command | undefined) => {\n if (!command || command.disabled) return;\n setRecent((r) => [command.id, ...r.filter((x) => x !== command.id)].slice(0, 20));\n setOpen(false);\n onRun(command.id);\n };\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (isComposing(event)) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n move(event.key === \"ArrowDown\" ? 1 : -1);\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n run(rows[active]?.command);\n }\n };\n\n let index = -1;\n return (\n <DialogBase\n ref={dialog}\n open={isOpen}\n onCancel={() => setOpen(false)}\n onClose={() => setOpen(false)}\n className=\"cy-command-palette\"\n aria-label={text.title}\n >\n <div\n className={\n className ? `cy-command-palette-panel cy-reset ${className}` : \"cy-command-palette-panel cy-reset\"\n }\n style={style}\n >\n <div className=\"cy-command-palette-search cy-reset\">\n <Icon icon={search} className=\"cy-command-palette-search-icon\" />\n <InputBase\n ref={input}\n className=\"cy-command-palette-input\"\n role=\"combobox\"\n aria-label={text.title}\n aria-expanded=\"true\"\n aria-controls={`${id}-list`}\n aria-autocomplete=\"list\"\n aria-activedescendant={activeId}\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={text.placeholder}\n value={query}\n onChange={(e) => {\n setQuery(e.currentTarget.value);\n setActive(0);\n }}\n onKeyDown={onKeyDown}\n />\n </div>\n <div\n ref={list}\n id={`${id}-list`}\n role=\"listbox\"\n aria-label={text.title}\n className=\"cy-command-palette-list cy-reset\"\n >\n {rows.length === 0 && (\n // A listbox may only hold options: the empty message is a disabled one.\n <div\n role=\"option\"\n aria-disabled=\"true\"\n aria-selected=\"false\"\n tabIndex={-1}\n className=\"cy-command-palette-empty cy-reset\"\n >\n {text.empty}\n </div>\n )}\n {sections.map((section, s) => (\n // biome-ignore lint/a11y/useSemanticElements: a listbox may only hold options and role=\"group\" (no fieldset)\n <div\n key={`${s}-${section.name}`}\n role=\"group\"\n aria-labelledby={section.name ? `${id}-g${s}` : undefined}\n className=\"cy-command-palette-group cy-reset\"\n >\n {section.name && (\n <div id={`${id}-g${s}`} className=\"cy-command-palette-heading cy-reset\" role=\"presentation\">\n {section.name}\n </div>\n )}\n {section.items.map((command) => {\n index++;\n const i = index;\n return (\n <Fragment key={`${section.name}-${command.id}`}>\n <div\n id={optionId(i)}\n role=\"option\"\n tabIndex={-1}\n aria-selected={i === active}\n aria-disabled={command.disabled || undefined}\n data-active={i === active || undefined}\n className=\"cy-command-palette-item cy-reset\"\n onPointerMove={() => !command.disabled && setActive(i)}\n onPointerDown={(e) => e.preventDefault()}\n onClick={() => run(command)}\n onKeyDown={() => {}}\n >\n {command.icon && <Icon icon={command.icon} className=\"cy-command-palette-icon\" />}\n <span className=\"cy-command-palette-label cy-reset\">\n <HighlightedText\n text={command.label}\n query={words}\n positions={positions?.get(command.id)}\n />\n </span>\n {section.tagged && command.group && (\n <Badge size=\"sm\" className=\"cy-command-palette-tag\">\n {command.group}\n </Badge>\n )}\n {command.shortcut && <Kbd keys={command.shortcut} size=\"sm\" />}\n </div>\n </Fragment>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n </DialogBase>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6DA,SAASuB,GACPC,GACAC,GACAC,GACiE;AACjE,QAAMC,IAA8C,CAAC,GAC/CC,IAAY,oBAAI,IAA+B;AACrD,aAAWC,KAAWL,GAAU;AAC9B,UAAMM,IAAQJ,EAAOG,GAASJ,CAAK;AACnC,QAAI,CAACK,EAAO;AACZ,UAAMC,IAAsBD,MAAU,KAAO,CAAC,IAAIA;AAClD,IAAAH,EAAK,KAAK;AAAA,MAAE,SAAAE;AAAA,MAAS,OAAOE,EAAM,SAAS;AAAA,IAAE,CAAC,GAC9CH,EAAU,IAAIC,EAAQ,IAAIE,EAAM,aAAa,CAAC,CAAC;AAAA,EACjD;AACA,SAAAJ,EAAK,KAAA,CAAMK,GAAGC,MAAMD,EAAE,QAAQC,EAAE,KAAK,GAC9B;AAAA,IAAE,OAAON,EAAK,IAAA,CAAKO,MAAMA,EAAE,OAAO;AAAA,IAAG,WAAAN;AAAA,EAAU;AACxD;AAkCA,IAAMO,KAAuC;AAAA,EAC3C,OAAO;AAAA,EACP,aAAa;AAAA,EACb,OAAO;AAAA,EACP,QAAQ;AACV,GAGMC,KAAA,CAAWX,MAAkBA,EAAM,MAAM,KAAK,EAAE,OAAO,OAAO;AAGpE,SAASY,GAAKb,GAAqBc,GAA4B;AAC7D,QAAMC,IAAA,CAAOC,MAAe,CAACA,EAAE,OAAO,GAAIA,EAAE,YAAY,CAAC,CAAE,EAAE,KAAK,GAAG,GAC/DT,IAAQP,EAAS,OAAA,CAAQgB,MAAMF,EAAM,MAAA,CAAOG,M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A,kBAAO,MAAK;AAAA,kBAAK,WAAU;AAAA,kBACxB,UAAAuB,EAAQ;AAAA,gBACJ,CAAA;AAAA,gBAERA,EAAQ,YAAY,gBAAAR,EAACZ,IAAD;AAAA,kBAAK,MAAMoB,EAAQ;AAAA,kBAAU,MAAK;AAAA,gBAAM,CAAA;AAAA,cAC1D;AAAA,YACG,CAAA,EAAA,GA7BK,GAAGuD,EAAQ,IAAA,IAAQvD,EAAQ,EAAA,EA6BhC;AAAA,UAEd,CAAC,CACE;AAAA,QA9CE,GAAA,GAAG0C,CAAA,IAAKa,EAAQ,IAAA,EA8ClB,CACN,CACE;AAAA,MACF,CAAA,CAAA;AAAA,I;A,EACK,CAAA;AAEhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type Command, CommandPalette, type CommandPaletteLabels, type CommandPaletteProps, type CommandPaletteTokens, } from "./CommandPalette.js";
|
|
1
|
+
export { type Command, type CommandMatch, CommandPalette, type CommandPaletteLabels, type CommandPaletteProps, type CommandPaletteTokens, } from "./CommandPalette.js";
|
|
@@ -4,7 +4,7 @@ import { clamp as f } from "../../foundations/math.js";
|
|
|
4
4
|
import { stepKey as F } from "../../foundations/keys.js";
|
|
5
5
|
import { useDrag as $ } from "../../foundations/drag.js";
|
|
6
6
|
import { useRef as c } from "react";
|
|
7
|
-
import { Fragment as B, jsx as
|
|
7
|
+
import { Fragment as B, jsx as a, jsxs as y } from "react/jsx-runtime";
|
|
8
8
|
var E = {
|
|
9
9
|
divider: "Comparison",
|
|
10
10
|
position: (n) => `${n}% before`,
|
|
@@ -15,60 +15,60 @@ function z({ before: n, after: v, value: h, defaultValue: x = 50, onChange: b, s
|
|
|
15
15
|
const o = {
|
|
16
16
|
...E,
|
|
17
17
|
...w
|
|
18
|
-
}, s = c(null), l = c(null), [S, A] = D(h, x, b),
|
|
18
|
+
}, s = c(null), l = c(null), [S, A] = D(h, x, b), t = f(S, 0, 100), i = (e) => {
|
|
19
19
|
const r = Math.round(f(e, 0, 100) * 10) / 10;
|
|
20
|
-
A(r);
|
|
20
|
+
r !== t && A(r);
|
|
21
21
|
}, m = (e) => {
|
|
22
22
|
const r = s.current.getBoundingClientRect();
|
|
23
23
|
return (e - r.left) / r.width * 100;
|
|
24
|
-
}, p = c(
|
|
24
|
+
}, p = c(t);
|
|
25
25
|
$(s, {
|
|
26
26
|
touchAction: "css",
|
|
27
27
|
onStart: ({ point: e }) => {
|
|
28
|
-
p.current =
|
|
28
|
+
p.current = t, l.current?.focus({ preventScroll: !0 }), i(m(e.x));
|
|
29
29
|
},
|
|
30
30
|
onMove: ({ point: e }) => i(m(e.x)),
|
|
31
31
|
onEnd: (e, r) => r && i(p.current)
|
|
32
32
|
});
|
|
33
33
|
const C = (e) => {
|
|
34
34
|
const r = F(e, {
|
|
35
|
-
value:
|
|
35
|
+
value: t,
|
|
36
36
|
min: 0,
|
|
37
37
|
max: 100,
|
|
38
38
|
step: 1
|
|
39
39
|
});
|
|
40
40
|
r !== void 0 && (e.preventDefault(), i(r));
|
|
41
|
-
}, u = Math.round(
|
|
41
|
+
}, u = Math.round(t);
|
|
42
42
|
return /* @__PURE__ */ y("div", {
|
|
43
43
|
ref: s,
|
|
44
44
|
className: d ? `cy-compare-slider ${d}` : "cy-compare-slider",
|
|
45
45
|
style: {
|
|
46
|
-
"--_pos": `${
|
|
46
|
+
"--_pos": `${t}%`,
|
|
47
47
|
...N
|
|
48
48
|
},
|
|
49
49
|
children: [
|
|
50
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ a("div", {
|
|
51
51
|
className: "cy-compare-slider-layer cy-reset",
|
|
52
52
|
"data-side": "after",
|
|
53
53
|
children: v
|
|
54
54
|
}),
|
|
55
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ a("div", {
|
|
56
56
|
className: "cy-compare-slider-layer cy-reset",
|
|
57
57
|
"data-side": "before",
|
|
58
58
|
children: n
|
|
59
59
|
}),
|
|
60
|
-
g && /* @__PURE__ */ y(B, { children: [/* @__PURE__ */
|
|
60
|
+
g && /* @__PURE__ */ y(B, { children: [/* @__PURE__ */ a("span", {
|
|
61
61
|
className: "cy-compare-slider-tag cy-reset",
|
|
62
62
|
"data-side": "before",
|
|
63
63
|
"aria-hidden": "true",
|
|
64
64
|
children: o.before
|
|
65
|
-
}), /* @__PURE__ */
|
|
65
|
+
}), /* @__PURE__ */ a("span", {
|
|
66
66
|
className: "cy-compare-slider-tag cy-reset",
|
|
67
67
|
"data-side": "after",
|
|
68
68
|
"aria-hidden": "true",
|
|
69
69
|
children: o.after
|
|
70
70
|
})] }),
|
|
71
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ a("div", {
|
|
72
72
|
ref: l,
|
|
73
73
|
role: "slider",
|
|
74
74
|
tabIndex: 0,
|
|
@@ -80,7 +80,7 @@ function z({ before: n, after: v, value: h, defaultValue: x = 50, onChange: b, s
|
|
|
80
80
|
"aria-valuetext": o.position(u),
|
|
81
81
|
className: "cy-compare-slider-divider cy-reset",
|
|
82
82
|
onKeyDown: C,
|
|
83
|
-
children: /* @__PURE__ */
|
|
83
|
+
children: /* @__PURE__ */ a("span", {
|
|
84
84
|
className: "cy-compare-slider-grip cy-reset",
|
|
85
85
|
"aria-hidden": "true"
|
|
86
86
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompareSlider.js","names":["_Fragment","useControllableState","clamp","stepKey","useDrag","useRef","Fragment$1","jsx","jsxs","DEFAULT_LABELS","p","CompareSlider","before","after","value","defaultValue","onChange","showTags","labels","className","style","text","area","divider","own","setOwn","position","set","next","v","fromX","x","box","dragFrom","point","_","cancelled","onKeyDown","event","shown"],"sources":["../../../src/components/CompareSlider/CompareSlider.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, useRef } from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { stepKey } from \"../../foundations/keys.js\";\nimport { clamp } from \"../../foundations/math.js\";\n\nexport interface CompareSliderTokens {\n /** Colour of the divider line and grip. */\n divider: string;\n /** Size of the grip on the divider. */\n gripSize: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n compareSlider: CompareSliderTokens;\n }\n}\n\nexport interface CompareSliderLabels {\n /** Name of the divider. Default: \"Comparison\". */\n divider: string;\n /** Spoken position. Default: \"40% before\". */\n position: (percent: number) => string;\n /** Tags shown on the two sides. Defaults: \"Before\", \"After\". */\n before: string;\n after: string;\n}\n\nexport interface CompareSliderProps {\n /** Shown on the start side of the divider (e.g. the original image). */\n before: ReactNode;\n /** Shown on the other side (e.g. the edited image). Both should be the same size. */\n after: ReactNode;\n /** Divider position: percent of the width showing `before`. */\n value?: number | undefined;\n /** The divider's starting position when uncontrolled, 0 to 100. Default 50. */\n defaultValue?: number;\n /** Called as the divider moves (drag, click or keys), with the new position, 0 to 100. */\n onChange?: ((value: number) => void) | undefined;\n /** Show the Before and After tags. Default true. */\n showTags?: boolean;\n /** Replace the built-in English text: the divider's name, its spoken position and the two tags. */\n labels?: Partial<CompareSliderLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-compare-slider-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: CompareSliderLabels = {\n divider: \"Comparison\",\n position: (p) => `${p}% before`,\n before: \"Before\",\n after: \"After\",\n};\n\n/**\n * Before and after, one over the other, split by a divider people move: drag anywhere (mouse, pen or a held finger),\n * click to jump, or focus the divider and use the arrow keys. An APG slider.\n */\nexport function CompareSlider({\n before,\n after,\n value,\n defaultValue = 50,\n onChange,\n showTags = true,\n labels,\n className,\n style,\n}: CompareSliderProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const area = useRef<HTMLDivElement>(null);\n const divider = useRef<HTMLDivElement>(null);\n const [own, setOwn] = useControllableState(value, defaultValue, onChange);\n const position = clamp(own, 0, 100);\n const set = (next: number) => {\n const v = Math.round(clamp(next, 0, 100) * 10) / 10;\n setOwn(v);\n };\n const fromX = (x: number) => {\n const box = (area.current as HTMLDivElement).getBoundingClientRect();\n return ((x - box.left) / box.width) * 100;\n };\n\n // Dragging through detent: the press jumps the divider there and a drag follows. The picture keeps touch-action\n // pan-y, so a sideways finger drags at once and an upward swipe still scrolls the page (the browser then cancels the\n // drag, which puts the divider back, as Escape does).\n const dragFrom = useRef(position);\n useDrag(area, {\n touchAction: \"css\",\n onStart: ({ point }) => {\n dragFrom.current = position;\n divider.current?.focus({ preventScroll: true });\n set(fromX(point.x));\n },\n onMove: ({ point }) => set(fromX(point.x)),\n onEnd: (_, cancelled) => cancelled && set(dragFrom.current),\n });\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // The pictures do not mirror in RTL, so neither do the keys.\n const next = stepKey(event, { value: position, min: 0, max: 100, step: 1 });\n if (next === undefined) return;\n event.preventDefault();\n set(next);\n };\n\n const shown = Math.round(position);\n return (\n <div\n ref={area}\n className={className ? `cy-compare-slider ${className}` : \"cy-compare-slider\"}\n style={{ \"--_pos\": `${position}%`, ...style } as CSSProperties}\n >\n <div className=\"cy-compare-slider-layer cy-reset\" data-side=\"after\">\n {after}\n </div>\n <div className=\"cy-compare-slider-layer cy-reset\" data-side=\"before\">\n {before}\n </div>\n {showTags && (\n <>\n <span className=\"cy-compare-slider-tag cy-reset\" data-side=\"before\" aria-hidden=\"true\">\n {text.before}\n </span>\n <span className=\"cy-compare-slider-tag cy-reset\" data-side=\"after\" aria-hidden=\"true\">\n {text.after}\n </span>\n </>\n )}\n <div\n ref={divider}\n role=\"slider\"\n tabIndex={0}\n aria-label={text.divider}\n aria-orientation=\"horizontal\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={shown}\n aria-valuetext={text.position(shown)}\n className=\"cy-compare-slider-divider cy-reset\"\n onKeyDown={onKeyDown}\n >\n <span className=\"cy-compare-slider-grip cy-reset\" aria-hidden=\"true\" />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AAkDA,IAAMS,IAAsC;AAAA,EAC1C,SAAS;AAAA,EACT,UAAA,CAAWC,MAAM,GAAGA,CAAA;AAAA,EACpB,QAAQ;AAAA,EACR,OAAO;AACT;AAMA,SAAgBC,EAAc,EAC5B,QAAAC,GACA,OAAAC,GACA,OAAAC,GACA,cAAAC,IAAe,IACf,UAAAC,GACA,UAAAC,IAAW,IACX,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACqB;AACrB,QAAMC,IAAO;AAAA,IAAE,GAAGZ;AAAA,IAAgB,GAAGS;AAAA,EAAO,GACtCI,IAAOjB,EAAuB,IAAI,GAClCkB,IAAUlB,EAAuB,IAAI,GACrC,CAACmB,GAAKC,CAAA,IAAUxB,EAAqBa,GAAOC,GAAcC,CAAQ,GAClEU,IAAWxB,EAAMsB,GAAK,GAAG,GAAG,GAC5BG,IAAA,CAAOC,MAAiB;AAC5B,UAAMC,IAAI,KAAK,MAAM3B,EAAM0B,GAAM,GAAG,GAAG,IAAI,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"CompareSlider.js","names":["_Fragment","useControllableState","clamp","stepKey","useDrag","useRef","Fragment$1","jsx","jsxs","DEFAULT_LABELS","p","CompareSlider","before","after","value","defaultValue","onChange","showTags","labels","className","style","text","area","divider","own","setOwn","position","set","next","v","fromX","x","box","dragFrom","point","_","cancelled","onKeyDown","event","shown"],"sources":["../../../src/components/CompareSlider/CompareSlider.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, useRef } from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { stepKey } from \"../../foundations/keys.js\";\nimport { clamp } from \"../../foundations/math.js\";\n\nexport interface CompareSliderTokens {\n /** Colour of the divider line and grip. */\n divider: string;\n /** Size of the grip on the divider. */\n gripSize: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n compareSlider: CompareSliderTokens;\n }\n}\n\nexport interface CompareSliderLabels {\n /** Name of the divider. Default: \"Comparison\". */\n divider: string;\n /** Spoken position. Default: \"40% before\". */\n position: (percent: number) => string;\n /** Tags shown on the two sides. Defaults: \"Before\", \"After\". */\n before: string;\n after: string;\n}\n\nexport interface CompareSliderProps {\n /** Shown on the start side of the divider (e.g. the original image). */\n before: ReactNode;\n /** Shown on the other side (e.g. the edited image). Both should be the same size. */\n after: ReactNode;\n /** Divider position: percent of the width showing `before`. */\n value?: number | undefined;\n /** The divider's starting position when uncontrolled, 0 to 100. Default 50. */\n defaultValue?: number;\n /** Called as the divider moves (drag, click or keys), with the new position, 0 to 100. */\n onChange?: ((value: number) => void) | undefined;\n /** Show the Before and After tags. Default true. */\n showTags?: boolean;\n /** Replace the built-in English text: the divider's name, its spoken position and the two tags. */\n labels?: Partial<CompareSliderLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-compare-slider-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: CompareSliderLabels = {\n divider: \"Comparison\",\n position: (p) => `${p}% before`,\n before: \"Before\",\n after: \"After\",\n};\n\n/**\n * Before and after, one over the other, split by a divider people move: drag anywhere (mouse, pen or a held finger),\n * click to jump, or focus the divider and use the arrow keys. An APG slider.\n */\nexport function CompareSlider({\n before,\n after,\n value,\n defaultValue = 50,\n onChange,\n showTags = true,\n labels,\n className,\n style,\n}: CompareSliderProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const area = useRef<HTMLDivElement>(null);\n const divider = useRef<HTMLDivElement>(null);\n const [own, setOwn] = useControllableState(value, defaultValue, onChange);\n const position = clamp(own, 0, 100);\n const set = (next: number) => {\n const v = Math.round(clamp(next, 0, 100) * 10) / 10;\n // Only a real move is a change: a key at an end, or a pointer resting on one spot, tells nobody.\n if (v !== position) setOwn(v);\n };\n const fromX = (x: number) => {\n const box = (area.current as HTMLDivElement).getBoundingClientRect();\n return ((x - box.left) / box.width) * 100;\n };\n\n // Dragging through detent: the press jumps the divider there and a drag follows. The picture keeps touch-action\n // pan-y, so a sideways finger drags at once and an upward swipe still scrolls the page (the browser then cancels the\n // drag, which puts the divider back, as Escape does).\n const dragFrom = useRef(position);\n useDrag(area, {\n touchAction: \"css\",\n onStart: ({ point }) => {\n dragFrom.current = position;\n divider.current?.focus({ preventScroll: true });\n set(fromX(point.x));\n },\n onMove: ({ point }) => set(fromX(point.x)),\n onEnd: (_, cancelled) => cancelled && set(dragFrom.current),\n });\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // The pictures do not mirror in RTL, so neither do the keys.\n const next = stepKey(event, { value: position, min: 0, max: 100, step: 1 });\n if (next === undefined) return;\n event.preventDefault();\n set(next);\n };\n\n const shown = Math.round(position);\n return (\n <div\n ref={area}\n className={className ? `cy-compare-slider ${className}` : \"cy-compare-slider\"}\n style={{ \"--_pos\": `${position}%`, ...style } as CSSProperties}\n >\n <div className=\"cy-compare-slider-layer cy-reset\" data-side=\"after\">\n {after}\n </div>\n <div className=\"cy-compare-slider-layer cy-reset\" data-side=\"before\">\n {before}\n </div>\n {showTags && (\n <>\n <span className=\"cy-compare-slider-tag cy-reset\" data-side=\"before\" aria-hidden=\"true\">\n {text.before}\n </span>\n <span className=\"cy-compare-slider-tag cy-reset\" data-side=\"after\" aria-hidden=\"true\">\n {text.after}\n </span>\n </>\n )}\n <div\n ref={divider}\n role=\"slider\"\n tabIndex={0}\n aria-label={text.divider}\n aria-orientation=\"horizontal\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={shown}\n aria-valuetext={text.position(shown)}\n className=\"cy-compare-slider-divider cy-reset\"\n onKeyDown={onKeyDown}\n >\n <span className=\"cy-compare-slider-grip cy-reset\" aria-hidden=\"true\" />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AAkDA,IAAMS,IAAsC;AAAA,EAC1C,SAAS;AAAA,EACT,UAAA,CAAWC,MAAM,GAAGA,CAAA;AAAA,EACpB,QAAQ;AAAA,EACR,OAAO;A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A,MACnE,CAAA;AAAA,IACF;AAAA,E;AAET"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
-
import { type Space } from "
|
|
2
|
+
import { type LayoutAttributes, type Space, type VisibilityProps } from "../../foundations/layout.js";
|
|
3
3
|
export interface ContainerTokens {
|
|
4
4
|
/** Widest a `size="sm"` container gets, gutters included. */
|
|
5
5
|
sizeSm: string;
|
|
@@ -17,7 +17,7 @@ declare module "../../tokens/schema.js" {
|
|
|
17
17
|
container: ContainerTokens;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export interface ContainerProps {
|
|
20
|
+
export interface ContainerProps extends VisibilityProps, LayoutAttributes {
|
|
21
21
|
/** Widest the column gets, gutters included; `full` has no limit. Default "lg". */
|
|
22
22
|
size?: "sm" | "md" | "lg" | "xl" | "full";
|
|
23
23
|
/**
|