@arshad-shah/cynosure 0.2.0 → 0.4.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 +5 -5
- package/dist/adapters/astro/index.d.ts +52 -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 +14 -0
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Announcer/Announcer.d.ts +1 -0
- package/dist/components/Announcer/Announcer.js +5 -5
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.d.ts +22 -1
- package/dist/components/AppShell/AppShell.js +92 -83
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/AppShell/index.d.ts +1 -1
- package/dist/components/AspectRatio/AspectRatio.d.ts +29 -0
- package/dist/components/AspectRatio/AspectRatio.js +21 -0
- package/dist/components/AspectRatio/AspectRatio.js.map +1 -0
- package/dist/components/AspectRatio/index.d.ts +1 -0
- package/dist/components/Avatar/Avatar.d.ts +96 -0
- package/dist/components/Avatar/Avatar.js +90 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Badge/Badge.d.ts +6 -0
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +55 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +85 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/dist/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +27 -2
- package/dist/components/Button/Button.js +62 -53
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +65 -7
- package/dist/components/Calendar/Calendar.js +209 -97
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Calendar/dates.d.ts +4 -0
- package/dist/components/Calendar/dates.js +41 -27
- package/dist/components/Calendar/dates.js.map +1 -1
- package/dist/components/Calendar/index.d.ts +1 -1
- package/dist/components/Card/Card.d.ts +35 -1
- package/dist/components/Card/Card.js +48 -36
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/index.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +11 -4
- package/dist/components/Checkbox/Checkbox.js +33 -7
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checklist/Checklist.d.ts +65 -0
- package/dist/components/Checklist/Checklist.js +163 -0
- package/dist/components/Checklist/Checklist.js.map +1 -0
- package/dist/components/Checklist/index.d.ts +1 -0
- 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 +5 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/ColorField/ColorField.d.ts +12 -0
- package/dist/components/ColorField/ColorField.js +199 -208
- package/dist/components/ColorField/ColorField.js.map +1 -1
- package/dist/components/ColorSwatches/ColorSwatches.d.ts +5 -0
- package/dist/components/ColorSwatches/ColorSwatches.js +6 -6
- package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts +20 -1
- package/dist/components/Combobox/Combobox.js +86 -111
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.d.ts +9 -0
- package/dist/components/CommandPalette/CommandPalette.js +10 -10
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/components/CompareSlider/CompareSlider.d.ts +4 -0
- package/dist/components/CompareSlider/CompareSlider.js +4 -4
- package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
- package/dist/components/Container/Container.d.ts +44 -0
- package/dist/components/Container/Container.js +28 -0
- package/dist/components/Container/Container.js.map +1 -0
- package/dist/components/Container/index.d.ts +1 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +8 -0
- package/dist/components/CopyButton/CopyButton.js +29 -28
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DateField/DateField.d.ts +17 -0
- package/dist/components/DateField/DateField.js +6 -6
- package/dist/components/DateField/DateField.js.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.d.ts +3 -0
- package/dist/components/DescriptionList/DescriptionList.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 +25 -2
- package/dist/components/Dialog/Dialog.js +89 -72
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Disclosure/Disclosure.d.ts +7 -0
- package/dist/components/Disclosure/Disclosure.js.map +1 -1
- package/dist/components/Divider/Divider.d.ts +59 -0
- package/dist/components/Divider/Divider.js +32 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/DocumentViewport/DocumentViewport.d.ts +8 -0
- package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +8 -2
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/Field/Field.d.ts +6 -0
- package/dist/components/Field/Field.js +31 -33
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/FileDrop/FileDrop.d.ts +8 -0
- package/dist/components/FileDrop/FileDrop.js +14 -14
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +4 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.js +11 -10
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +57 -10
- package/dist/components/Grid/Grid.js +71 -28
- 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 +59 -0
- package/dist/components/Heading/Heading.js +33 -0
- package/dist/components/Heading/Heading.js.map +1 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +17 -1
- package/dist/components/IconButton/IconButton.js +14 -10
- 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.d.ts +62 -0
- package/dist/components/Image/Image.js +75 -0
- package/dist/components/Image/Image.js.map +1 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Inline/Inline.d.ts +8 -4
- package/dist/components/Inline/Inline.js +12 -16
- package/dist/components/Inline/Inline.js.map +1 -1
- package/dist/components/Kbd/Kbd.d.ts +2 -0
- package/dist/components/Kbd/Kbd.js.map +1 -1
- package/dist/components/KeyValueEditor/KeyValueEditor.d.ts +7 -0
- package/dist/components/KeyValueEditor/KeyValueEditor.js +43 -42
- package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
- package/dist/components/Link/Link.d.ts +16 -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/LoadingDots/LoadingDots.d.ts +2 -0
- package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts +13 -1
- package/dist/components/Menu/Menu.js +37 -35
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Notice/Notice.d.ts +5 -0
- package/dist/components/Notice/Notice.js +12 -11
- package/dist/components/Notice/Notice.js.map +1 -1
- package/dist/components/NumberField/NumberField.d.ts +17 -0
- package/dist/components/NumberField/NumberField.js +8 -8
- package/dist/components/NumberField/NumberField.js.map +1 -1
- package/dist/components/OptionList/OptionList.d.ts +69 -0
- package/dist/components/OptionList/OptionList.js +75 -0
- package/dist/components/OptionList/OptionList.js.map +1 -0
- package/dist/components/OptionList/index.d.ts +1 -0
- package/dist/components/PageHeader/PageHeader.d.ts +67 -0
- package/dist/components/PageHeader/PageHeader.js +63 -0
- package/dist/components/PageHeader/PageHeader.js.map +1 -0
- package/dist/components/PageHeader/index.d.ts +1 -0
- package/dist/components/Pagination/Pagination.d.ts +77 -0
- package/dist/components/Pagination/Pagination.js +121 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +4 -0
- package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
- package/dist/components/Popover/Popover.d.ts +10 -0
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +5 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/ProgressOverlay/ProgressOverlay.d.ts +3 -0
- package/dist/components/ProgressOverlay/ProgressOverlay.js.map +1 -1
- package/dist/components/Prose/Prose.d.ts +1 -0
- package/dist/components/Prose/Prose.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.d.ts +13 -0
- package/dist/components/RadioGroup/RadioGroup.js +32 -24
- package/dist/components/RadioGroup/RadioGroup.js.map +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 +9 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +12 -12
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.d.ts +18 -1
- package/dist/components/Select/Select.js +107 -125
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/SelectionFrame/SelectionFrame.d.ts +6 -0
- package/dist/components/SelectionFrame/SelectionFrame.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 +37 -1
- package/dist/components/SideNav/SideNav.js +103 -74
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SideNav/index.d.ts +1 -1
- package/dist/components/SignaturePad/SignaturePad.d.ts +3 -0
- package/dist/components/SignaturePad/SignaturePad.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/Skeleton/Skeleton.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- 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.d.ts +11 -0
- package/dist/components/Slider/Slider.js +6 -6
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/SortableList/SortableList.d.ts +6 -0
- package/dist/components/SortableList/SortableList.js +13 -13
- package/dist/components/SortableList/SortableList.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +5 -0
- package/dist/components/SplitPane/SplitPane.js +4 -4
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +19 -6
- package/dist/components/Stack/Stack.js +26 -13
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -0
- package/dist/components/Stack/space.d.ts +47 -0
- package/dist/components/Stack/space.js +23 -0
- package/dist/components/Stack/space.js.map +1 -0
- 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/Steps/Steps.d.ts +14 -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 +12 -0
- package/dist/components/Table/Table.js +11 -12
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +18 -1
- package/dist/components/Tabs/Tabs.js +74 -73
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.d.ts +18 -0
- package/dist/components/TagInput/TagInput.js +79 -100
- package/dist/components/TagInput/TagInput.js.map +1 -1
- package/dist/components/Text/Text.d.ts +72 -0
- package/dist/components/Text/Text.js +30 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Text/index.d.ts +1 -0
- package/dist/components/TextArea/TextArea.d.ts +10 -0
- package/dist/components/TextArea/TextArea.js +4 -4
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +17 -0
- package/dist/components/TextField/TextField.js +28 -27
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +11 -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 +62 -8
- package/dist/components/TimeField/TimeField.js +308 -72
- package/dist/components/TimeField/TimeField.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts +25 -1
- package/dist/components/Toast/Toast.js +137 -126
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/Toolbar/Toolbar.d.ts +3 -0
- package/dist/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +7 -1
- package/dist/components/Tooltip/Tooltip.js +19 -19
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +8 -0
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.d.ts +8 -0
- package/dist/components/VirtualList/VirtualList.js +4 -4
- package/dist/components/VirtualList/VirtualList.js.map +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 +4 -0
- package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
- package/dist/foundations/ChoiceBase/ChoiceBase.d.ts +1 -0
- package/dist/foundations/ChoiceBase/ChoiceBase.js +8 -8
- package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
- package/dist/foundations/HiddenValue/HiddenValue.d.ts +3 -0
- package/dist/foundations/HiddenValue/HiddenValue.js +5 -5
- package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
- package/dist/foundations/Icon/Icon.d.ts +9 -1
- package/dist/foundations/Icon/Icon.js +15 -14
- package/dist/foundations/Icon/Icon.js.map +1 -1
- package/dist/foundations/image-outcome.d.ts +20 -0
- package/dist/foundations/image-outcome.js +43 -0
- package/dist/foundations/image-outcome.js.map +1 -0
- package/dist/foundations/option-icon.d.ts +26 -0
- package/dist/foundations/option-icon.js +16 -0
- package/dist/foundations/option-icon.js.map +1 -0
- 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 +246 -0
- package/dist/foundations/qr.js.map +1 -0
- 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/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-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/crescent.d.ts +2 -0
- package/dist/icons/crescent.js +14 -0
- package/dist/icons/crescent.js.map +1 -0
- package/dist/icons/index.d.ts +11 -0
- package/dist/icons/index.js +502 -480
- 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 +259 -0
- package/dist/icons/keywords.js +1816 -0
- package/dist/icons/keywords.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/mosque.d.ts +2 -0
- package/dist/icons/mosque.js +14 -0
- package/dist/icons/mosque.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/types.d.ts +1 -1
- package/dist/icons/types.js +2 -1
- package/dist/icons/types.js.map +1 -1
- package/dist/index.d.ts +35 -10
- package/dist/index.js +280 -220
- package/dist/styles/announcer.css +1 -1
- package/dist/styles/app-shell.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -0
- package/dist/styles/avatar.css +1 -0
- package/dist/styles/base.css +1 -1
- package/dist/styles/breadcrumbs.css +1 -0
- package/dist/styles/button.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/checklist.css +1 -0
- package/dist/styles/choice-base.css +1 -0
- package/dist/styles/choice.css +1 -1
- package/dist/styles/color-field.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/container.css +1 -0
- package/dist/styles/copy-button.css +1 -1
- 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/divider.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 +1 -1
- package/dist/styles/generated-css.js.map +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heading.css +1 -0
- package/dist/styles/icon-tile.css +1 -0
- package/dist/styles/icon.css +1 -1
- package/dist/styles/image.css +1 -0
- 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.css +1 -0
- package/dist/styles/manifest.json +715 -0
- package/dist/styles/menu.css +1 -1
- 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/page-header.css +1 -0
- package/dist/styles/pagination.css +1 -0
- package/dist/styles/qr-code.css +1 -0
- package/dist/styles/radio-group.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/sortable-list.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/stat.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-field.css +1 -1
- package/dist/styles/text.css +1 -0
- package/dist/styles/time-field.css +1 -1
- package/dist/styles/toast.css +1 -1
- package/dist/styles/visually-hidden.css +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme/CynosureTheme.d.ts +4 -0
- package/dist/theme/CynosureTheme.js.map +1 -1
- package/dist/tokens/create-theme.js +137 -108
- package/dist/tokens/create-theme.js.map +1 -1
- package/dist/tokens/to-css.js +12 -12
- package/dist/tokens/to-css.js.map +1 -1
- package/package.json +8 -3
- package/dist/components/Checkbox/ChoiceRow.d.ts +0 -23
- package/dist/components/Checkbox/ChoiceRow.js +0 -57
- package/dist/components/Checkbox/ChoiceRow.js.map +0 -1
- package/dist/styles/hidden-value.css +0 -1
- package/dist/styles/iconbutton.css +0 -1
- package/dist/styles/search-field.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorSwatches.js","names":["ButtonBase","Icon","
|
|
1
|
+
{"version":3,"file":"ColorSwatches.js","names":["ButtonBase","Icon","useRovingFocus","check","luminance","readColor","useRef","jsx","key","text","c","n","lightness","ColorSwatches","label","swatches","value","onChange","disabled","size","className","style","group","chosen","items","s","item","on"],"sources":["../../../src/components/ColorSwatches/ColorSwatches.tsx"],"sourcesContent":["import { type CSSProperties, useRef } from \"react\";\nimport { ButtonBase } from \"../../foundations/ButtonBase/ButtonBase.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { useRovingFocus } from \"../../foundations/roving-focus.js\";\nimport { check } from \"../../icons/check.js\";\nimport { luminance } from \"../../tokens/color.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { readColor } from \"../ColorField/read-color.js\";\n\nexport interface ColorSwatchesTokens {\n /** Swatch size at `md`. */\n size: string;\n /** Corner radius of a swatch. */\n radius: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n colorSwatches: ColorSwatchesTokens;\n }\n}\n\nexport interface ColorSwatch {\n /** Any CSS colour. */\n value: string;\n /** Spoken name, e.g. \"Brand red\". Default: the value. */\n label?: string;\n}\n\nexport interface ColorSwatchesProps {\n /** Accessible name of the group, e.g. \"Recent colours\". */\n label: string;\n /** The colours to offer: a CSS colour, or `{ value, label }` to give it a spoken name. */\n swatches: (ColorSwatch | string)[];\n /** The chosen colour, matched by colour (so \"#FFF\" and \"white\" are the same swatch). */\n value?: string | undefined;\n /** Called when a swatch is chosen (pressed, or reached with the arrow keys), with that swatch's `value`. */\n onChange: (value: string) => void;\n /** No swatch can be chosen. */\n disabled?: boolean;\n /** Size of each swatch. Default \"md\". */\n size?: Size;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-color-swatches-* tokens. */\n style?: CSSProperties;\n}\n\n/** A colour's identity for matching: its rgb and alpha rounded, whatever syntax it was written in. */\nconst key = (text: string | undefined) => {\n const c = text ? readColor(text) : null;\n return c ? `${c.rgb.map((n) => Math.round(n * 255)).join(\",\")}/${Math.round(c.a * 100)}` : text;\n};\n/** Relative luminance (sRGB), to pick a tick that shows on the swatch. */\nconst lightness = (text: string) => {\n const c = readColor(text);\n return c ? luminance(c.rgb) : 1;\n};\n\n/**\n * A palette to pick a colour from: brand colours, recent colours, presets. An APG radio group: one tab stop, arrow keys\n * move and choose. Each swatch is named, and the chosen one shows a tick that contrasts with it.\n */\nexport function ColorSwatches({\n label,\n swatches,\n value,\n onChange,\n disabled = false,\n size = \"md\",\n className,\n style,\n}: ColorSwatchesProps) {\n const group = useRef<HTMLDivElement>(null);\n useRovingFocus(group, { orientation: \"both\", selector: '[role=\"radio\"]' });\n const chosen = key(value);\n const items = swatches.map((s) => (typeof s === \"string\" ? { value: s } : s));\n return (\n <div\n ref={group}\n role=\"radiogroup\"\n aria-label={label}\n aria-disabled={disabled || undefined}\n className={className ? `cy-color-swatches ${className}` : \"cy-color-swatches\"}\n data-size={size}\n style={style}\n >\n {items.map((item) => {\n const on = chosen !== undefined && key(item.value) === chosen;\n return (\n <ButtonBase\n key={item.value}\n role=\"radio\"\n aria-checked={on}\n aria-label={item.label ?? item.value}\n disabled={disabled}\n data-roving=\"\"\n className=\"cy-color-swatches-swatch cy-reset\"\n data-light={lightness(item.value) > 0.4 ? \"\" : undefined}\n style={{ \"--_swatch\": item.value } as CSSProperties}\n onClick={() => onChange(item.value)}\n // Arrow keys move focus (roving); in a radio group the focused swatch is chosen too, once one is.\n onFocus={() => chosen !== undefined && !on && onChange(item.value)}\n >\n {on && <Icon icon={check} size=\"sm\" />}\n </ButtonBase>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAiDA,IAAMQ,IAAA,CAAOC,MAA6B;AACxC,QAAMC,IAAID,IAAOJ,EAAUI,CAAI,IAAI;AACnC,SAAOC,IAAI,GAAGA,EAAE,IAAI,IAAA,CAAKC,MAAM,KAA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AElC,SAAA,MAAeH,MAAW,UAAa,CAACI,KAAMV,EAASS,EAAK,KAAK;AAAA,QAEhE,UAAAC,KAAM,gBAAApB,EAACN,GAAD;AAAA,UAAM,MAAME;AAAA,UAAO,MAAK;AAAA,QAAM,CAAA;AAAA,MAC3B,GAdLuB,EAAK,KAcA;AAAA,IAEhB,CAAC;AAAA,EACE,CAAA;AAET"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type OptionIconColor } from "../../foundations/option-icon.js";
|
|
2
3
|
import type { IconData } from "../../icons/types.js";
|
|
3
4
|
import type { Size } from "../../tokens/schema.js";
|
|
4
5
|
export interface ComboboxTokens {
|
|
@@ -11,11 +12,12 @@ declare module "../../tokens/schema.js" {
|
|
|
11
12
|
combobox: ComboboxTokens;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
export interface ComboboxOption {
|
|
15
|
+
export interface ComboboxOption extends OptionIconColor {
|
|
15
16
|
value: string;
|
|
16
17
|
label: string;
|
|
17
18
|
description?: string;
|
|
18
19
|
disabled?: boolean;
|
|
20
|
+
/** Icon before the label in the list. Colour it with `iconTone` or `iconColor`. */
|
|
19
21
|
icon?: IconData;
|
|
20
22
|
}
|
|
21
23
|
export interface ComboboxLabels {
|
|
@@ -27,17 +29,25 @@ export interface ComboboxLabels {
|
|
|
27
29
|
required: string;
|
|
28
30
|
}
|
|
29
31
|
export interface ComboboxProps {
|
|
32
|
+
/** The field's label. It also names the list when it is a string. */
|
|
30
33
|
label: ReactNode;
|
|
34
|
+
/** Visually hide the label (it still names the control). Prefer visible labels. */
|
|
31
35
|
labelHidden?: boolean;
|
|
36
|
+
/** Help text shown below the control and read with it. */
|
|
32
37
|
description?: ReactNode;
|
|
38
|
+
/** Your own error; it replaces the field's own messages. */
|
|
33
39
|
error?: ReactNode;
|
|
40
|
+
/** The options to choose from. */
|
|
34
41
|
options: ComboboxOption[];
|
|
35
42
|
/** The chosen option's value (or the typed text, with `allowCustom`). */
|
|
36
43
|
value?: string;
|
|
44
|
+
/** The value chosen at first, when uncontrolled. */
|
|
37
45
|
defaultValue?: string;
|
|
46
|
+
/** Called when the value changes, with the chosen option's value, or an empty string when it is cleared. */
|
|
38
47
|
onChange?: (value: string) => void;
|
|
39
48
|
/** The text in the input. Control it to load options as people type. */
|
|
40
49
|
inputValue?: string;
|
|
50
|
+
/** Called when the text in the input changes (typed, or filled in by a choice), with the text. */
|
|
41
51
|
onInputChange?: (text: string) => void;
|
|
42
52
|
/** Which options match the text. Default: label contains the text, ignoring case. `false`: show `options` as given. */
|
|
43
53
|
filter?: ((option: ComboboxOption, text: string) => boolean) | false;
|
|
@@ -45,14 +55,23 @@ export interface ComboboxProps {
|
|
|
45
55
|
allowCustom?: boolean;
|
|
46
56
|
/** Options are being fetched: the list says so and is `aria-busy`. */
|
|
47
57
|
loading?: boolean;
|
|
58
|
+
/** Hint shown in the input while it is empty. */
|
|
48
59
|
placeholder?: string;
|
|
60
|
+
/** Name the value is submitted under in a form. */
|
|
49
61
|
name?: string;
|
|
62
|
+
/** A value must be chosen: submitting the form without one is blocked and shows an error. */
|
|
50
63
|
required?: boolean;
|
|
64
|
+
/** Turns off the input; the value is not submitted with a form. */
|
|
51
65
|
disabled?: boolean;
|
|
66
|
+
/** Size of the field. Default "md". */
|
|
52
67
|
size?: Size;
|
|
68
|
+
/** `outline` or `soft` (tinted, borderless until focus). Default "outline". */
|
|
53
69
|
variant?: "outline" | "soft";
|
|
70
|
+
/** Icon at the start of the input. */
|
|
54
71
|
iconStart?: IconData;
|
|
72
|
+
/** Replace the built-in English text: the empty and loading notes and the required error. */
|
|
55
73
|
labels?: Partial<ComboboxLabels>;
|
|
74
|
+
/** Added to the root element, for layout. */
|
|
56
75
|
className?: string;
|
|
57
76
|
/** Layout only. */
|
|
58
77
|
style?: CSSProperties;
|
|
@@ -1,171 +1,146 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useControllableState as
|
|
3
|
-
import {
|
|
4
|
-
import { HiddenValue as fe } from "../../foundations/HiddenValue/HiddenValue.js";
|
|
2
|
+
import { useControllableState as R } from "../../foundations/controllable.js";
|
|
3
|
+
import { OptionIcon as ue } from "../../foundations/option-icon.js";
|
|
5
4
|
import { isComposing as de } from "../../foundations/keys.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
5
|
+
import { TextField as me } from "../TextField/TextField.js";
|
|
6
|
+
import { HiddenValue as pe } from "../../foundations/HiddenValue/HiddenValue.js";
|
|
7
|
+
import { useListboxLayer as be } from "../../overlay/listbox-layer.js";
|
|
8
|
+
import { OptionList as ve, OptionListItem as xe, OptionListNote as U } from "../OptionList/OptionList.js";
|
|
9
|
+
import { useEffect as V, useId as ye, useLayoutEffect as he, useRef as A, useState as g } from "react";
|
|
10
|
+
import { jsx as c, jsxs as H } from "react/jsx-runtime";
|
|
11
|
+
var ge = {
|
|
11
12
|
empty: "No matches",
|
|
12
13
|
loading: "Loading…",
|
|
13
14
|
required: "Please choose a value."
|
|
14
|
-
},
|
|
15
|
-
function
|
|
15
|
+
}, Le = (f, L) => f.label.toLowerCase().includes(L.trim().toLowerCase());
|
|
16
|
+
function Ae({ label: f, labelHidden: L, description: _, error: z, options: C, value: G, defaultValue: m = "", onChange: J, inputValue: Q, onInputChange: W, filter: M, allowCustom: D = !1, loading: I = !1, placeholder: X, name: Y, required: q, disabled: S, size: Z = "md", variant: ee = "outline", iconStart: te, labels: se, className: N, style: le }) {
|
|
16
17
|
const p = {
|
|
17
|
-
...
|
|
18
|
-
...
|
|
19
|
-
}, n = `cy-combobox-${
|
|
20
|
-
e !==
|
|
18
|
+
...ge,
|
|
19
|
+
...se
|
|
20
|
+
}, n = `cy-combobox-${ye().replace(/:/g, "")}`, [r, re, oe] = R(G, m, J), b = (e) => C.find((t) => t.value === e)?.label ?? (D ? e : ""), [a, v, ne] = R(Q, () => b(m), W), [s, l] = g(!1), [ae, u] = g(!1), [$, x] = g(null), [ie, j] = g(!1), w = A(null), B = A(null), T = A(null), E = M === !1 ? null : M ?? Le, d = E && ae ? C.filter((e) => E(e, a)) : C, i = d.filter((e) => !e.disabled), o = d.findIndex((e) => e.value === $), y = (e) => {
|
|
21
|
+
e !== r && (j(!1), re(e));
|
|
21
22
|
}, F = (e) => {
|
|
22
|
-
e.disabled || (
|
|
23
|
-
},
|
|
24
|
-
const t =
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
23
|
+
e.disabled || (y(e.value), v(e.label), u(!1), l(!1));
|
|
24
|
+
}, O = (e) => {
|
|
25
|
+
const t = i, h = t.find((fe) => fe.value === r), k = e === "selected" ? h ?? t[0] : e === "first" ? t[0] : t[t.length - 1];
|
|
26
|
+
x(k?.value ?? null), l(!0);
|
|
27
|
+
}, K = () => {
|
|
28
|
+
l(!1), u(!1), D ? y(a) : a.trim() === "" ? y("") : a !== b(r) && v(b(r));
|
|
28
29
|
};
|
|
29
30
|
V(() => {
|
|
30
|
-
|
|
31
|
-
}),
|
|
32
|
-
B.current =
|
|
33
|
-
}),
|
|
31
|
+
s && (i.some((e) => e.value === $) || x(i[0]?.value ?? null));
|
|
32
|
+
}), he(() => {
|
|
33
|
+
B.current = w.current.closest(".cy-text-field");
|
|
34
|
+
}), be({
|
|
34
35
|
anchor: B,
|
|
35
36
|
list: T,
|
|
36
|
-
open:
|
|
37
|
-
onClose: () =>
|
|
37
|
+
open: s,
|
|
38
|
+
onClose: () => l(!1)
|
|
38
39
|
}), V(() => {
|
|
39
|
-
|
|
40
|
+
s && o >= 0 && T.current?.querySelector(`#${n}-${o}`)?.scrollIntoView?.({ block: "nearest" });
|
|
40
41
|
}, [
|
|
42
|
+
s,
|
|
41
43
|
o,
|
|
42
|
-
l,
|
|
43
44
|
n
|
|
44
45
|
]);
|
|
45
|
-
const
|
|
46
|
-
const t =
|
|
47
|
-
|
|
48
|
-
},
|
|
46
|
+
const P = (e) => {
|
|
47
|
+
const t = i.findIndex((k) => k.value === $), h = i[Math.min(Math.max(t + e, 0), i.length - 1)];
|
|
48
|
+
h && x(h.value);
|
|
49
|
+
}, ce = (e) => {
|
|
49
50
|
if (!de(e))
|
|
50
51
|
switch (e.key) {
|
|
51
52
|
case "ArrowDown":
|
|
52
|
-
e.preventDefault(),
|
|
53
|
+
e.preventDefault(), s ? P(1) : O(e.altKey ? "selected" : "first");
|
|
53
54
|
return;
|
|
54
55
|
case "ArrowUp":
|
|
55
|
-
e.preventDefault(),
|
|
56
|
+
e.preventDefault(), s ? P(-1) : O("last");
|
|
56
57
|
return;
|
|
57
58
|
case "Enter": {
|
|
58
|
-
const t =
|
|
59
|
-
|
|
59
|
+
const t = d[o];
|
|
60
|
+
s && t ? (e.preventDefault(), F(t)) : D && K();
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
case "Escape":
|
|
63
|
-
|
|
64
|
+
s ? (e.preventDefault(), l(!1)) : a && (e.preventDefault(), v(""), u(!1), y(""));
|
|
64
65
|
return;
|
|
65
66
|
case "Tab":
|
|
66
|
-
|
|
67
|
+
s && l(!1);
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
|
-
return /* @__PURE__ */
|
|
71
|
-
className:
|
|
72
|
-
style:
|
|
71
|
+
return /* @__PURE__ */ H("div", {
|
|
72
|
+
className: N ? `cy-combobox ${N}` : "cy-combobox",
|
|
73
|
+
style: le,
|
|
73
74
|
children: [
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
ref:
|
|
75
|
+
/* @__PURE__ */ c(me, {
|
|
76
|
+
ref: w,
|
|
76
77
|
label: f,
|
|
77
|
-
labelHidden:
|
|
78
|
-
description:
|
|
79
|
-
error:
|
|
80
|
-
size:
|
|
81
|
-
variant:
|
|
82
|
-
iconStart:
|
|
83
|
-
placeholder:
|
|
84
|
-
disabled:
|
|
85
|
-
required:
|
|
78
|
+
labelHidden: L,
|
|
79
|
+
description: _,
|
|
80
|
+
error: z ?? (ie && !r ? p.required : void 0),
|
|
81
|
+
size: Z,
|
|
82
|
+
variant: ee,
|
|
83
|
+
iconStart: te,
|
|
84
|
+
placeholder: X,
|
|
85
|
+
disabled: S,
|
|
86
|
+
required: q,
|
|
86
87
|
autoComplete: "off",
|
|
87
88
|
role: "combobox",
|
|
88
89
|
"aria-autocomplete": E ? "list" : "none",
|
|
89
|
-
"aria-expanded":
|
|
90
|
+
"aria-expanded": s,
|
|
90
91
|
"aria-controls": n,
|
|
91
|
-
"aria-activedescendant":
|
|
92
|
-
value:
|
|
92
|
+
"aria-activedescendant": s && o >= 0 ? `${n}-${o}` : void 0,
|
|
93
|
+
value: a,
|
|
93
94
|
onChange: (e) => {
|
|
94
|
-
|
|
95
|
+
v(e), u(!0), s || l(!0);
|
|
95
96
|
},
|
|
96
|
-
onKeyDown:
|
|
97
|
-
onClick: () => !
|
|
98
|
-
onBlur:
|
|
97
|
+
onKeyDown: ce,
|
|
98
|
+
onClick: () => !s && O("selected"),
|
|
99
|
+
onBlur: K
|
|
99
100
|
}),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ H(ve, {
|
|
101
102
|
ref: T,
|
|
102
103
|
id: n,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"aria-busy": L || void 0,
|
|
106
|
-
className: "cy-combobox-list",
|
|
107
|
-
popover: "manual",
|
|
104
|
+
label: typeof f == "string" ? f : void 0,
|
|
105
|
+
busy: I,
|
|
108
106
|
children: [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"aria-selected": "false",
|
|
113
|
-
tabIndex: -1,
|
|
114
|
-
className: "cy-combobox-note",
|
|
115
|
-
children: p.loading
|
|
116
|
-
}),
|
|
117
|
-
!L && m.length === 0 && /* @__PURE__ */ r("div", {
|
|
118
|
-
role: "option",
|
|
119
|
-
"aria-disabled": "true",
|
|
120
|
-
"aria-selected": "false",
|
|
121
|
-
tabIndex: -1,
|
|
122
|
-
className: "cy-combobox-note",
|
|
123
|
-
children: p.empty
|
|
124
|
-
}),
|
|
125
|
-
m.map((e, t) => /* @__PURE__ */ D("div", {
|
|
107
|
+
I && /* @__PURE__ */ c(U, { children: p.loading }),
|
|
108
|
+
!I && d.length === 0 && /* @__PURE__ */ c(U, { children: p.empty }),
|
|
109
|
+
d.map((e, t) => /* @__PURE__ */ c(xe, {
|
|
126
110
|
id: `${n}-${t}`,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
className: "cy-combobox-option-text",
|
|
140
|
-
children: [/* @__PURE__ */ r("span", {
|
|
141
|
-
className: "cy-combobox-option-label",
|
|
142
|
-
children: e.label
|
|
143
|
-
}), e.description && /* @__PURE__ */ r("span", {
|
|
144
|
-
className: "cy-combobox-option-description",
|
|
145
|
-
children: e.description
|
|
146
|
-
})]
|
|
147
|
-
})]
|
|
111
|
+
label: e.label,
|
|
112
|
+
description: e.description,
|
|
113
|
+
icon: /* @__PURE__ */ c(ue, {
|
|
114
|
+
option: e,
|
|
115
|
+
plain: e.disabled,
|
|
116
|
+
className: "cy-combobox-icon"
|
|
117
|
+
}),
|
|
118
|
+
selected: e.value === r,
|
|
119
|
+
disabled: e.disabled,
|
|
120
|
+
active: t === o,
|
|
121
|
+
onPointerMove: () => !e.disabled && x(e.value),
|
|
122
|
+
onClick: () => F(e)
|
|
148
123
|
}, e.value))
|
|
149
124
|
]
|
|
150
125
|
}),
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
name:
|
|
153
|
-
value:
|
|
154
|
-
required:
|
|
155
|
-
disabled:
|
|
126
|
+
/* @__PURE__ */ c(pe, {
|
|
127
|
+
name: Y,
|
|
128
|
+
value: r,
|
|
129
|
+
required: q,
|
|
130
|
+
disabled: S,
|
|
156
131
|
requiredMessage: p.required,
|
|
157
132
|
onInvalid: (e) => {
|
|
158
|
-
e.preventDefault(), j(!0),
|
|
133
|
+
e.preventDefault(), j(!0), w.current?.focus();
|
|
159
134
|
},
|
|
160
135
|
onReset: () => {
|
|
161
|
-
|
|
136
|
+
oe(m), ne(b(m)), u(!1), l(!1);
|
|
162
137
|
}
|
|
163
138
|
})
|
|
164
139
|
]
|
|
165
140
|
});
|
|
166
141
|
}
|
|
167
142
|
export {
|
|
168
|
-
|
|
143
|
+
Ae as Combobox
|
|
169
144
|
};
|
|
170
145
|
|
|
171
146
|
//# sourceMappingURL=Combobox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.js","names":["useControllableState","Icon","HiddenValue","isComposing","useListboxLayer","TextField","useEffect","useId","useLayoutEffect","useRef","useState","jsx","jsxs","DEFAULT_LABELS","contains","option","text","Combobox","label","labelHidden","description","error","options","value","defaultValue","onChange","inputValue","onInputChange","filter","allowCustom","loading","placeholder","name","required","disabled","size","variant","iconStart","labels","className","style","listId","current","setCurrent","resetCurrent","labelOf","v","o","typedText","setText","resetText","open","setOpen","typing","setTyping","activeValue","setActiveValue","missing","setMissing","input","anchor","list","match","visible","enabled","activeIndex","setValue","next","choose","show","at","pool","selected","pick","settle","move","delta","onKeyDown","event","index","e"],"sources":["../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { isComposing } from \"../../foundations/keys.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { useListboxLayer } from \"../../overlay/listbox-layer.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface ComboboxTokens {\n listMaxHeight: string;\n listBg: string;\n optionActiveBg: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n combobox: ComboboxTokens;\n }\n}\n\nexport interface ComboboxOption {\n value: string;\n label: string;\n description?: string;\n disabled?: boolean;\n icon?: IconData;\n}\n\nexport interface ComboboxLabels {\n /** Shown when nothing matches. */\n empty: string;\n /** Shown while `loading`. */\n loading: string;\n /** Error after a blocked submit when `required` and nothing is chosen. */\n required: string;\n}\n\nexport interface ComboboxProps {\n label: ReactNode;\n labelHidden?: boolean;\n description?: ReactNode;\n error?: ReactNode;\n options: ComboboxOption[];\n /** The chosen option's value (or the typed text, with `allowCustom`). */\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** The text in the input. Control it to load options as people type. */\n inputValue?: string;\n onInputChange?: (text: string) => void;\n /** Which options match the text. Default: label contains the text, ignoring case. `false`: show `options` as given. */\n filter?: ((option: ComboboxOption, text: string) => boolean) | false;\n /** Accept text that matches no option as the value. */\n allowCustom?: boolean;\n /** Options are being fetched: the list says so and is `aria-busy`. */\n loading?: boolean;\n placeholder?: string;\n name?: string;\n required?: boolean;\n disabled?: boolean;\n size?: Size;\n variant?: \"outline\" | \"soft\";\n iconStart?: IconData;\n labels?: Partial<ComboboxLabels>;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: ComboboxLabels = {\n empty: \"No matches\",\n loading: \"Loading…\",\n required: \"Please choose a value.\",\n};\nconst contains = (option: ComboboxOption, text: string) =>\n option.label.toLowerCase().includes(text.trim().toLowerCase());\n\n/** Editable combobox with a list popup (WAI-ARIA APG): type to filter, arrows to choose, async options, forms. */\nexport function Combobox({\n label,\n labelHidden,\n description,\n error,\n options,\n value,\n defaultValue = \"\",\n onChange,\n inputValue,\n onInputChange,\n filter,\n allowCustom = false,\n loading = false,\n placeholder,\n name,\n required,\n disabled,\n size = \"md\",\n variant = \"outline\",\n iconStart,\n labels,\n className,\n style,\n}: ComboboxProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const listId = `cy-combobox-${useId().replace(/:/g, \"\")}`;\n const [current, setCurrent, resetCurrent] = useControllableState(value, defaultValue, onChange);\n const labelOf = (v: string) => options.find((o) => o.value === v)?.label ?? (allowCustom ? v : \"\");\n const [typedText, setText, resetText] = useControllableState(\n inputValue,\n () => labelOf(defaultValue),\n onInputChange,\n );\n const [open, setOpen] = useState(false);\n // True once the person has typed since the last choice: only then does the text filter the list.\n const [typing, setTyping] = useState(false);\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const [missing, setMissing] = useState(false);\n const input = useRef<HTMLInputElement>(null);\n const anchor = useRef<HTMLElement | null>(null);\n const list = useRef<HTMLDivElement>(null);\n\n const match = filter === false ? null : (filter ?? contains);\n const visible = match && typing ? options.filter((o) => match(o, typedText)) : options;\n const enabled = visible.filter((o) => !o.disabled);\n const activeIndex = visible.findIndex((o) => o.value === activeValue);\n\n const setValue = (next: string) => {\n if (next === current) return;\n setMissing(false);\n setCurrent(next);\n };\n const choose = (option: ComboboxOption) => {\n if (option.disabled) return;\n setValue(option.value);\n setText(option.label);\n setTyping(false);\n setOpen(false);\n };\n const show = (at: \"first\" | \"last\" | \"selected\") => {\n const pool = enabled;\n const selected = pool.find((o) => o.value === current);\n const pick = at === \"selected\" ? (selected ?? pool[0]) : at === \"first\" ? pool[0] : pool[pool.length - 1];\n setActiveValue(pick?.value ?? null);\n setOpen(true);\n };\n /** Leaving the field: keep a valid choice, or the custom text, and never leave stale text behind. */\n const settle = () => {\n setOpen(false);\n setTyping(false);\n if (allowCustom) setValue(typedText);\n else if (typedText.trim() === \"\") setValue(\"\");\n else if (typedText !== labelOf(current)) setText(labelOf(current));\n };\n\n // Late or changed results: keep the active option if it is still there, else the first enabled one. Focus never\n // moves (it stays in the input; the list uses aria-activedescendant), so typing is never interrupted.\n useEffect(() => {\n if (!open) return;\n if (!enabled.some((o) => o.value === activeValue)) setActiveValue(enabled[0]?.value ?? null);\n });\n\n // The list drops from the whole field (input and any end buttons), found before the layer shows.\n useLayoutEffect(() => {\n anchor.current = (input.current as HTMLInputElement).closest<HTMLElement>(\".cy-text-field\");\n });\n useListboxLayer({ anchor, list, open, onClose: () => setOpen(false) });\n useEffect(() => {\n if (open && activeIndex >= 0)\n list.current?.querySelector(`#${listId}-${activeIndex}`)?.scrollIntoView?.({ block: \"nearest\" });\n }, [open, activeIndex, listId]);\n\n const move = (delta: 1 | -1) => {\n const at = enabled.findIndex((o) => o.value === activeValue);\n const next = enabled[Math.min(Math.max(at + delta, 0), enabled.length - 1)];\n if (next) setActiveValue(next.value);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (isComposing(event)) return;\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n if (!open) show(event.altKey ? \"selected\" : \"first\");\n else move(1);\n return;\n case \"ArrowUp\":\n event.preventDefault();\n if (!open) show(\"last\");\n else move(-1);\n return;\n case \"Enter\": {\n const option = visible[activeIndex];\n if (open && option) {\n event.preventDefault();\n choose(option);\n } else if (allowCustom) settle();\n return;\n }\n case \"Escape\":\n // First Escape closes the list, the next clears the text; with nothing to do, it goes on to a Dialog.\n if (open) {\n event.preventDefault();\n setOpen(false);\n } else if (typedText) {\n event.preventDefault();\n setText(\"\");\n setTyping(false);\n setValue(\"\");\n }\n return;\n case \"Tab\":\n if (open) setOpen(false);\n return;\n }\n };\n\n return (\n <div className={className ? `cy-combobox ${className}` : \"cy-combobox\"} style={style}>\n <TextField\n ref={input}\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error ?? (missing && !current ? text.required : undefined)}\n size={size}\n variant={variant}\n iconStart={iconStart}\n placeholder={placeholder}\n disabled={disabled}\n required={required}\n autoComplete=\"off\"\n role=\"combobox\"\n aria-autocomplete={match ? \"list\" : \"none\"}\n aria-expanded={open}\n aria-controls={listId}\n aria-activedescendant={open && activeIndex >= 0 ? `${listId}-${activeIndex}` : undefined}\n value={typedText}\n onChange={(next) => {\n setText(next);\n setTyping(true);\n if (!open) setOpen(true);\n }}\n onKeyDown={onKeyDown}\n onClick={() => !open && show(\"selected\")}\n // Options never take focus (they are aria-activedescendant targets), so any blur leaves the field.\n onBlur={settle}\n />\n <div\n ref={list}\n id={listId}\n role=\"listbox\"\n aria-label={typeof label === \"string\" ? label : undefined}\n aria-busy={loading || undefined}\n className=\"cy-combobox-list\"\n {...{ popover: \"manual\" }}\n >\n {loading && (\n <div\n role=\"option\"\n aria-disabled=\"true\"\n aria-selected=\"false\"\n tabIndex={-1}\n className=\"cy-combobox-note\"\n >\n {text.loading}\n </div>\n )}\n {!loading && visible.length === 0 && (\n <div\n role=\"option\"\n aria-disabled=\"true\"\n aria-selected=\"false\"\n tabIndex={-1}\n className=\"cy-combobox-note\"\n >\n {text.empty}\n </div>\n )}\n {visible.map((option, index) => (\n <div\n key={option.value}\n id={`${listId}-${index}`}\n role=\"option\"\n aria-selected={option.value === current}\n aria-disabled={option.disabled || undefined}\n data-active={index === activeIndex ? \"\" : undefined}\n className=\"cy-combobox-option\"\n tabIndex={-1}\n onPointerMove={() => !option.disabled && setActiveValue(option.value)}\n onPointerDown={(e) => e.preventDefault()}\n onClick={() => choose(option)}\n onKeyDown={() => {}}\n >\n {option.icon && <Icon icon={option.icon} />}\n <span className=\"cy-combobox-option-text\">\n <span className=\"cy-combobox-option-label\">{option.label}</span>\n {option.description && (\n <span className=\"cy-combobox-option-description\">{option.description}</span>\n )}\n </span>\n </div>\n ))}\n </div>\n <HiddenValue\n name={name}\n value={current}\n required={required}\n disabled={disabled}\n requiredMessage={text.required}\n onInvalid={(event) => {\n event.preventDefault();\n setMissing(true);\n input.current?.focus();\n }}\n onReset={() => {\n resetCurrent(defaultValue);\n resetText(labelOf(defaultValue));\n setTyping(false);\n setOpen(false);\n }}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAgFA,IAAMa,KAAiC;AAAA,EACrC,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AACZ,GACMC,KAAA,CAAYC,GAAwBC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Y8D,MAAU;AACpB,UAAAA,EAAM,eAAe,GACrBpB,EAAW,EAAI,GACfC,EAAM,SAAS,MAAM;AAAA,QACvB;AAAA,QACA,SAAA,MAAe;AACb,UAAAf,GAAapB,CAAY,GACzB0B,GAAUL,EAAQrB,CAAY,CAAC,GAC/B8B,EAAU,EAAK,GACfF,EAAQ,EAAK;AAAA,QACf;AAAA,MACD,CAAA;AAAA,IACE;AAAA,E;AAET"}
|
|
1
|
+
{"version":3,"file":"Combobox.js","names":["useControllableState","OptionIcon","isComposing","TextField","HiddenValue","useListboxLayer","OptionList","OptionListItem","OptionListNote","useEffect","useId","useLayoutEffect","useRef","useState","jsx","jsxs","DEFAULT_LABELS","contains","option","text","Combobox","label","labelHidden","description","error","options","value","defaultValue","onChange","inputValue","onInputChange","filter","allowCustom","loading","placeholder","name","required","disabled","size","variant","iconStart","labels","className","style","listId","current","setCurrent","resetCurrent","labelOf","v","o","typedText","setText","resetText","open","setOpen","typing","setTyping","activeValue","setActiveValue","missing","setMissing","input","anchor","list","match","visible","enabled","activeIndex","setValue","next","choose","show","at","pool","selected","pick","settle","move","delta","onKeyDown","event","index"],"sources":["../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { isComposing } from \"../../foundations/keys.js\";\nimport { OptionIcon, type OptionIconColor } from \"../../foundations/option-icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { useListboxLayer } from \"../../overlay/listbox-layer.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { OptionList, OptionListItem, OptionListNote } from \"../OptionList/OptionList.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface ComboboxTokens {\n listMaxHeight: string;\n listBg: string;\n optionActiveBg: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n combobox: ComboboxTokens;\n }\n}\n\nexport interface ComboboxOption extends OptionIconColor {\n value: string;\n label: string;\n description?: string;\n disabled?: boolean;\n /** Icon before the label in the list. Colour it with `iconTone` or `iconColor`. */\n icon?: IconData;\n}\n\nexport interface ComboboxLabels {\n /** Shown when nothing matches. */\n empty: string;\n /** Shown while `loading`. */\n loading: string;\n /** Error after a blocked submit when `required` and nothing is chosen. */\n required: string;\n}\n\nexport interface ComboboxProps {\n /** The field's label. It also names the list when it is a string. */\n label: ReactNode;\n /** Visually hide the label (it still names the control). Prefer visible labels. */\n labelHidden?: boolean;\n /** Help text shown below the control and read with it. */\n description?: ReactNode;\n /** Your own error; it replaces the field's own messages. */\n error?: ReactNode;\n /** The options to choose from. */\n options: ComboboxOption[];\n /** The chosen option's value (or the typed text, with `allowCustom`). */\n value?: string;\n /** The value chosen at first, when uncontrolled. */\n defaultValue?: string;\n /** Called when the value changes, with the chosen option's value, or an empty string when it is cleared. */\n onChange?: (value: string) => void;\n /** The text in the input. Control it to load options as people type. */\n inputValue?: string;\n /** Called when the text in the input changes (typed, or filled in by a choice), with the text. */\n onInputChange?: (text: string) => void;\n /** Which options match the text. Default: label contains the text, ignoring case. `false`: show `options` as given. */\n filter?: ((option: ComboboxOption, text: string) => boolean) | false;\n /** Accept text that matches no option as the value. */\n allowCustom?: boolean;\n /** Options are being fetched: the list says so and is `aria-busy`. */\n loading?: boolean;\n /** Hint shown in the input while it is empty. */\n placeholder?: string;\n /** Name the value is submitted under in a form. */\n name?: string;\n /** A value must be chosen: submitting the form without one is blocked and shows an error. */\n required?: boolean;\n /** Turns off the input; the value is not submitted with a form. */\n disabled?: boolean;\n /** Size of the field. Default \"md\". */\n size?: Size;\n /** `outline` or `soft` (tinted, borderless until focus). Default \"outline\". */\n variant?: \"outline\" | \"soft\";\n /** Icon at the start of the input. */\n iconStart?: IconData;\n /** Replace the built-in English text: the empty and loading notes and the required error. */\n labels?: Partial<ComboboxLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: ComboboxLabels = {\n empty: \"No matches\",\n loading: \"Loading…\",\n required: \"Please choose a value.\",\n};\nconst contains = (option: ComboboxOption, text: string) =>\n option.label.toLowerCase().includes(text.trim().toLowerCase());\n\n/** Editable combobox with a list popup (WAI-ARIA APG): type to filter, arrows to choose, async options, forms. */\nexport function Combobox({\n label,\n labelHidden,\n description,\n error,\n options,\n value,\n defaultValue = \"\",\n onChange,\n inputValue,\n onInputChange,\n filter,\n allowCustom = false,\n loading = false,\n placeholder,\n name,\n required,\n disabled,\n size = \"md\",\n variant = \"outline\",\n iconStart,\n labels,\n className,\n style,\n}: ComboboxProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const listId = `cy-combobox-${useId().replace(/:/g, \"\")}`;\n const [current, setCurrent, resetCurrent] = useControllableState(value, defaultValue, onChange);\n const labelOf = (v: string) => options.find((o) => o.value === v)?.label ?? (allowCustom ? v : \"\");\n const [typedText, setText, resetText] = useControllableState(\n inputValue,\n () => labelOf(defaultValue),\n onInputChange,\n );\n const [open, setOpen] = useState(false);\n // True once the person has typed since the last choice: only then does the text filter the list.\n const [typing, setTyping] = useState(false);\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const [missing, setMissing] = useState(false);\n const input = useRef<HTMLInputElement>(null);\n const anchor = useRef<HTMLElement | null>(null);\n const list = useRef<HTMLDivElement>(null);\n\n const match = filter === false ? null : (filter ?? contains);\n const visible = match && typing ? options.filter((o) => match(o, typedText)) : options;\n const enabled = visible.filter((o) => !o.disabled);\n const activeIndex = visible.findIndex((o) => o.value === activeValue);\n\n const setValue = (next: string) => {\n if (next === current) return;\n setMissing(false);\n setCurrent(next);\n };\n const choose = (option: ComboboxOption) => {\n if (option.disabled) return;\n setValue(option.value);\n setText(option.label);\n setTyping(false);\n setOpen(false);\n };\n const show = (at: \"first\" | \"last\" | \"selected\") => {\n const pool = enabled;\n const selected = pool.find((o) => o.value === current);\n const pick = at === \"selected\" ? (selected ?? pool[0]) : at === \"first\" ? pool[0] : pool[pool.length - 1];\n setActiveValue(pick?.value ?? null);\n setOpen(true);\n };\n /** Leaving the field: keep a valid choice, or the custom text, and never leave stale text behind. */\n const settle = () => {\n setOpen(false);\n setTyping(false);\n if (allowCustom) setValue(typedText);\n else if (typedText.trim() === \"\") setValue(\"\");\n else if (typedText !== labelOf(current)) setText(labelOf(current));\n };\n\n // Late or changed results: keep the active option if it is still there, else the first enabled one. Focus never\n // moves (it stays in the input; the list uses aria-activedescendant), so typing is never interrupted.\n useEffect(() => {\n if (!open) return;\n if (!enabled.some((o) => o.value === activeValue)) setActiveValue(enabled[0]?.value ?? null);\n });\n\n // The list drops from the whole field (input and any end buttons), found before the layer shows.\n useLayoutEffect(() => {\n anchor.current = (input.current as HTMLInputElement).closest<HTMLElement>(\".cy-text-field\");\n });\n useListboxLayer({ anchor, list, open, onClose: () => setOpen(false) });\n useEffect(() => {\n if (open && activeIndex >= 0)\n list.current?.querySelector(`#${listId}-${activeIndex}`)?.scrollIntoView?.({ block: \"nearest\" });\n }, [open, activeIndex, listId]);\n\n const move = (delta: 1 | -1) => {\n const at = enabled.findIndex((o) => o.value === activeValue);\n const next = enabled[Math.min(Math.max(at + delta, 0), enabled.length - 1)];\n if (next) setActiveValue(next.value);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (isComposing(event)) return;\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n if (!open) show(event.altKey ? \"selected\" : \"first\");\n else move(1);\n return;\n case \"ArrowUp\":\n event.preventDefault();\n if (!open) show(\"last\");\n else move(-1);\n return;\n case \"Enter\": {\n const option = visible[activeIndex];\n if (open && option) {\n event.preventDefault();\n choose(option);\n } else if (allowCustom) settle();\n return;\n }\n case \"Escape\":\n // First Escape closes the list, the next clears the text; with nothing to do, it goes on to a Dialog.\n if (open) {\n event.preventDefault();\n setOpen(false);\n } else if (typedText) {\n event.preventDefault();\n setText(\"\");\n setTyping(false);\n setValue(\"\");\n }\n return;\n case \"Tab\":\n if (open) setOpen(false);\n return;\n }\n };\n\n return (\n <div className={className ? `cy-combobox ${className}` : \"cy-combobox\"} style={style}>\n <TextField\n ref={input}\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error ?? (missing && !current ? text.required : undefined)}\n size={size}\n variant={variant}\n iconStart={iconStart}\n placeholder={placeholder}\n disabled={disabled}\n required={required}\n autoComplete=\"off\"\n role=\"combobox\"\n aria-autocomplete={match ? \"list\" : \"none\"}\n aria-expanded={open}\n aria-controls={listId}\n aria-activedescendant={open && activeIndex >= 0 ? `${listId}-${activeIndex}` : undefined}\n value={typedText}\n onChange={(next) => {\n setText(next);\n setTyping(true);\n if (!open) setOpen(true);\n }}\n onKeyDown={onKeyDown}\n onClick={() => !open && show(\"selected\")}\n // Options never take focus (they are aria-activedescendant targets), so any blur leaves the field.\n onBlur={settle}\n />\n <OptionList ref={list} id={listId} label={typeof label === \"string\" ? label : undefined} busy={loading}>\n {loading && <OptionListNote>{text.loading}</OptionListNote>}\n {!loading && visible.length === 0 && <OptionListNote>{text.empty}</OptionListNote>}\n {visible.map((option, index) => (\n <OptionListItem\n key={option.value}\n id={`${listId}-${index}`}\n label={option.label}\n description={option.description}\n icon={<OptionIcon option={option} plain={option.disabled} className=\"cy-combobox-icon\" />}\n selected={option.value === current}\n disabled={option.disabled}\n active={index === activeIndex}\n onPointerMove={() => !option.disabled && setActiveValue(option.value)}\n onClick={() => choose(option)}\n />\n ))}\n </OptionList>\n <HiddenValue\n name={name}\n value={current}\n required={required}\n disabled={disabled}\n requiredMessage={text.required}\n onInvalid={(event) => {\n event.preventDefault();\n setMissing(true);\n input.current?.focus();\n }}\n onReset={() => {\n resetCurrent(defaultValue);\n resetText(labelOf(defaultValue));\n setTyping(false);\n setOpen(false);\n }}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAmGA,IAAMgB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AK,MAAsB,CAAA;AAAA,UAChF+C,EAAQ,IAAA,CAAKhD,GAAQgE,MACpB,gBAAApE,EAACP,IAAD;AAAA,YAEE,IAAI,GAAGqC,CAAA,IAAUsC,CAAA;AAAA,YACjB,OAAOhE,EAAO;AAAA,YACd,aAAaA,EAAO;AAAA,YACpB,MAAM,gBAAAJ,EAACb,IAAD;AAAA,cAAoB,QAAAiB;AAAA,cAAQ,OAAOA,EAAO;AAAA,cAAU,WAAU;AAAA,YAAoB,CAAA;AAAA,YACxF,UAAUA,EAAO,UAAU2B;AAAA,YAC3B,UAAU3B,EAAO;AAAA,YACjB,QAAQgE,MAAUd;AAAA,YAClB,eAAA,MAAqB,CAAClD,EAAO,YAAYyC,EAAezC,EAAO,KAAK;AAAA,YACpE,SAAA,MAAeqD,EAAOrD,CAAM;AAAA,UAC7B,GAVMA,EAAO,KAUb,CACF;AAAA,QACS;AAAA,M;A,MACZ,gBAAAJ,EAACV,IAAD;AAAA,QACQ,MAAA+B;AAAA,QACN,OAAOU;AAAA,QACG,UAAAT;AAAA,QACA,UAAAC;AAAA,QACV,iBAAiBlB,EAAK;AAAA,QACtB,WAAA,CAAY8D,MAAU;AACpB,UAAAA,EAAM,eAAe,GACrBpB,EAAW,EAAI,GACfC,EAAM,SAAS,MAAM;AAAA,QACvB;AAAA,QACA,SAAA,MAAe;AACb,UAAAf,GAAapB,CAAY,GACzB0B,GAAUL,EAAQrB,CAAY,CAAC,GAC/B8B,EAAU,EAAK,GACfF,EAAQ,EAAK;AAAA,QACf;AAAA,MACD,CAAA;AAAA,IACE;AAAA,E;AAET"}
|
|
@@ -31,17 +31,26 @@ export interface CommandPaletteLabels {
|
|
|
31
31
|
recent: string;
|
|
32
32
|
}
|
|
33
33
|
export interface CommandPaletteProps {
|
|
34
|
+
/** The commands to search and run. */
|
|
34
35
|
commands: Command[];
|
|
35
36
|
/** Called with the chosen command's id; the palette then closes. */
|
|
36
37
|
onRun: (id: string) => void;
|
|
38
|
+
/** Controlled: whether the palette is open. */
|
|
37
39
|
open?: boolean;
|
|
40
|
+
/** Open at first, when uncontrolled. */
|
|
38
41
|
defaultOpen?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Called when the palette opens or closes (shortcut, Escape, a press outside, running a command), with the new
|
|
44
|
+
* state.
|
|
45
|
+
*/
|
|
39
46
|
onOpenChange?: (open: boolean) => void;
|
|
40
47
|
/** Global shortcut that toggles the palette (`mod` is Command on Apple platforms, else Control). `false`: none. */
|
|
41
48
|
shortcut?: string | false;
|
|
42
49
|
/** How many recently run commands to list before you type (default 5, 0 for none). */
|
|
43
50
|
recentLimit?: number;
|
|
51
|
+
/** Replace the built-in English text: the palette's name, the placeholder, the empty note and the recent heading. */
|
|
44
52
|
labels?: Partial<CommandPaletteLabels>;
|
|
53
|
+
/** Added to the panel, for layout. */
|
|
45
54
|
className?: string;
|
|
46
55
|
/** Layout only, applied to the panel. */
|
|
47
56
|
style?: CSSProperties;
|
|
@@ -4,11 +4,11 @@ import { Icon as T } from "../../foundations/Icon/Icon.js";
|
|
|
4
4
|
import { useClientLayoutEffect as U } from "../../foundations/client-layout-effect.js";
|
|
5
5
|
import { useDismiss as W } from "../../overlay/dismiss.js";
|
|
6
6
|
import { DialogBase as z } from "../../foundations/DialogBase/DialogBase.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { useHotkey as G } from "../../foundations/hotkey.js";
|
|
8
|
+
import { Kbd as Q } from "../Kbd/Kbd.js";
|
|
9
|
+
import { isComposing as V } from "../../foundations/keys.js";
|
|
10
|
+
import { InputBase as _ } from "../../foundations/InputBase/InputBase.js";
|
|
11
|
+
import { search as J } from "../../icons/search.js";
|
|
12
12
|
import { Fragment as X, useEffect as j, useId as Y, useMemo as Z, useRef as w, useState as D } from "react";
|
|
13
13
|
import { jsx as l, jsxs as h } from "react/jsx-runtime";
|
|
14
14
|
var ee = {
|
|
@@ -28,7 +28,7 @@ function fe({ commands: d, onRun: $, open: p, defaultOpen: C = !1, onOpenChange:
|
|
|
28
28
|
...ee,
|
|
29
29
|
...k
|
|
30
30
|
}, s = Y().replace(/:/g, ""), [u, f] = H(p, C, b), [g, L] = D(""), [A, K] = D([]), [n, y] = D(0), N = w(null), I = w(null), M = w(null), R = w(null);
|
|
31
|
-
|
|
31
|
+
G(v, () => f(!u));
|
|
32
32
|
const S = Z(() => {
|
|
33
33
|
const e = te(d, g), o = [];
|
|
34
34
|
if (!g && r > 0) {
|
|
@@ -73,7 +73,7 @@ function fe({ commands: d, onRun: $, open: p, defaultOpen: C = !1, onOpenChange:
|
|
|
73
73
|
const B = (e) => {
|
|
74
74
|
!e || e.disabled || (K((o) => [e.id, ...o.filter((t) => t !== e.id)].slice(0, 20)), f(!1), $(e.id));
|
|
75
75
|
}, O = (e) => {
|
|
76
|
-
if (
|
|
76
|
+
if (V(e)) return;
|
|
77
77
|
const o = m.indexOf(n);
|
|
78
78
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
79
79
|
e.preventDefault();
|
|
@@ -95,9 +95,9 @@ function fe({ commands: d, onRun: $, open: p, defaultOpen: C = !1, onOpenChange:
|
|
|
95
95
|
children: [/* @__PURE__ */ h("div", {
|
|
96
96
|
className: "cy-command-palette-search cy-reset",
|
|
97
97
|
children: [/* @__PURE__ */ l(T, {
|
|
98
|
-
icon:
|
|
98
|
+
icon: J,
|
|
99
99
|
className: "cy-command-palette-search-icon"
|
|
100
|
-
}), /* @__PURE__ */ l(
|
|
100
|
+
}), /* @__PURE__ */ l(_, {
|
|
101
101
|
ref: I,
|
|
102
102
|
className: "cy-command-palette-input",
|
|
103
103
|
role: "combobox",
|
|
@@ -162,7 +162,7 @@ function fe({ commands: d, onRun: $, open: p, defaultOpen: C = !1, onOpenChange:
|
|
|
162
162
|
className: "cy-command-palette-label cy-reset",
|
|
163
163
|
children: t.label
|
|
164
164
|
}),
|
|
165
|
-
t.shortcut && /* @__PURE__ */ l(
|
|
165
|
+
t.shortcut && /* @__PURE__ */ l(Q, {
|
|
166
166
|
keys: t.shortcut,
|
|
167
167
|
size: "sm"
|
|
168
168
|
})
|