@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":"CommandPalette.js","names":["useControllableState","Icon","useClientLayoutEffect","useDismiss","DialogBase","InputBase","isComposing","useHotkey","search","Kbd","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 commands: Command[];\n /** Called with the chosen command's id; the palette then closes. */\n onRun: (id: string) => void;\n open?: boolean;\n defaultOpen?: boolean;\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 labels?: Partial<CommandPaletteLabels>;\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":";;;;;;;;;;;;;AAyEA,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;AAG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AAK;AACA,kBAAMR,IAAIQ;AACV,mBACE,gBAAAtD,EAACN,GAAD,EAAA,UACE,gBAAAO,EAAC,OAAD;AAAA,cACE,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,EAACP,GAAD;AAAA,kBAAK,MAAMwD,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","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,SAAg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A,kBAAMR,IAAIQ;AACV,mBACE,gBAAAtD,EAACN,GAAD,EAAA,UACE,gBAAAO,EAAC,OAAD;AAAA,cACE,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"}
|
|
@@ -26,11 +26,15 @@ export interface CompareSliderProps {
|
|
|
26
26
|
after: ReactNode;
|
|
27
27
|
/** Divider position: percent of the width showing `before`. */
|
|
28
28
|
value?: number | undefined;
|
|
29
|
+
/** The divider's starting position when uncontrolled, 0 to 100. Default 50. */
|
|
29
30
|
defaultValue?: number;
|
|
31
|
+
/** Called as the divider moves (drag, click or keys), with the new position, 0 to 100. */
|
|
30
32
|
onChange?: ((value: number) => void) | undefined;
|
|
31
33
|
/** Show the Before and After tags. Default true. */
|
|
32
34
|
showTags?: boolean;
|
|
35
|
+
/** Replace the built-in English text: the divider's name, its spoken position and the two tags. */
|
|
33
36
|
labels?: Partial<CompareSliderLabels>;
|
|
37
|
+
/** Added to the root element, for layout. */
|
|
34
38
|
className?: string;
|
|
35
39
|
/** Layout only. Restyle through --cy-compare-slider-* tokens. */
|
|
36
40
|
style?: CSSProperties;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useControllableState as D } from "../../foundations/controllable.js";
|
|
3
3
|
import { clamp as f } from "../../foundations/math.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { stepKey as F } from "../../foundations/keys.js";
|
|
5
|
+
import { useDrag as $ } from "../../foundations/drag.js";
|
|
6
6
|
import { useRef as c } from "react";
|
|
7
7
|
import { Fragment as B, jsx as t, jsxs as y } from "react/jsx-runtime";
|
|
8
8
|
var E = {
|
|
@@ -22,7 +22,7 @@ function z({ before: n, after: v, value: h, defaultValue: x = 50, onChange: b, s
|
|
|
22
22
|
const r = s.current.getBoundingClientRect();
|
|
23
23
|
return (e - r.left) / r.width * 100;
|
|
24
24
|
}, p = c(a);
|
|
25
|
-
|
|
25
|
+
$(s, {
|
|
26
26
|
touchAction: "css",
|
|
27
27
|
onStart: ({ point: e }) => {
|
|
28
28
|
p.current = a, l.current?.focus({ preventScroll: !0 }), i(m(e.x));
|
|
@@ -31,7 +31,7 @@ function z({ before: n, after: v, value: h, defaultValue: x = 50, onChange: b, s
|
|
|
31
31
|
onEnd: (e, r) => r && i(p.current)
|
|
32
32
|
});
|
|
33
33
|
const C = (e) => {
|
|
34
|
-
const r =
|
|
34
|
+
const r = F(e, {
|
|
35
35
|
value: a,
|
|
36
36
|
min: 0,
|
|
37
37
|
max: 100,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompareSlider.js","names":["_Fragment","useControllableState","clamp","
|
|
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;AACjD,IAAAH,EAAOI,CAAC;AAAA,EACV,GACMC,IAAA,CAASC,MAAc;AAC3B,UAAMC,IAAO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E,gBAAAO,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAiC,aAAU;AAAA,QAAS,eAAY;AAAA,QAC7E,UAAAc,EAAK;AAAA,MACF,CAAA,GACN,gBAAAd,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAiC,aAAU;AAAA,QAAQ,eAAY;AAAA,QAC5E,UAAAc,EAAK;AAAA,MACF,CAAA,CACN,EAAA,CAAA;AAAA,MAEJ,gBAAAd,EAAC,OAAD;AAAA,QACE,KAAKgB;AAAA,QACL,MAAK;AAAA,QACL,UAAU;AAAA,QACV,cAAYF,EAAK;AAAA,QACjB,oBAAiB;AAAA,QACjB,iBAAe;AAAA,QACf,iBAAe;AAAA,QACf,iBAAekB;AAAA,QACf,kBAAgBlB,EAAK,SAASkB,CAAK;AAAA,QACnC,WAAU;AAAA,QACC,WAAAF;AAAA,QAEX,UAAA,gBAAA9B,EAAC,QAAD;AAAA,UAAM,WAAU;AAAA,UAAkC,eAAY;AAAA,QAAQ,CAAA;AAAA,MACnE,CAAA;AAAA,IACF;AAAA,E;AAET"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type LayoutAttributes, type Space, type VisibilityProps } from "../Stack/space.js";
|
|
3
|
+
export interface ContainerTokens {
|
|
4
|
+
/** Widest a `size="sm"` container gets, gutters included. */
|
|
5
|
+
sizeSm: string;
|
|
6
|
+
/** Widest a `size="md"` container gets, gutters included. */
|
|
7
|
+
sizeMd: string;
|
|
8
|
+
/** Widest a `size="lg"` container gets, gutters included. */
|
|
9
|
+
sizeLg: string;
|
|
10
|
+
/** Widest a `size="xl"` container gets, gutters included. */
|
|
11
|
+
sizeXl: string;
|
|
12
|
+
/** Side gutters when the `padding` prop is not set. */
|
|
13
|
+
padding: string;
|
|
14
|
+
}
|
|
15
|
+
declare module "../../tokens/schema.js" {
|
|
16
|
+
interface ComponentTokens {
|
|
17
|
+
container: ContainerTokens;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export interface ContainerProps extends VisibilityProps, LayoutAttributes {
|
|
21
|
+
/** Widest the column gets, gutters included; `full` has no limit. Default "lg". */
|
|
22
|
+
size?: "sm" | "md" | "lg" | "xl" | "full";
|
|
23
|
+
/**
|
|
24
|
+
* Space token for the gutters at the inline start and end. They never get narrower than the device's safe area
|
|
25
|
+
* (a phone's notch or rounded corners). Default: the `--cy-container-padding` token (space 6).
|
|
26
|
+
*/
|
|
27
|
+
padding?: Space | undefined;
|
|
28
|
+
/** Space token of padding at the block start and end (top and bottom). Default: none. */
|
|
29
|
+
paddingBlock?: Space | undefined;
|
|
30
|
+
/** Centre the column in the space around it. `false` keeps it at the inline start. Default true. */
|
|
31
|
+
center?: boolean;
|
|
32
|
+
/** Element to render: `main` for the page's main content, once per page. Default "div". */
|
|
33
|
+
as?: "div" | "main" | "section" | "article";
|
|
34
|
+
/** Added to the root element, for layout. */
|
|
35
|
+
className?: string;
|
|
36
|
+
/** Layout only. Change the widths through the --cy-container-* tokens. */
|
|
37
|
+
style?: CSSProperties;
|
|
38
|
+
/** The page content. */
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
/** Set on the root element, for tests. */
|
|
41
|
+
"data-testid"?: string;
|
|
42
|
+
}
|
|
43
|
+
/** The page column: centres its content, caps its width and adds side gutters, so every page lines up. */
|
|
44
|
+
export declare const Container: import("react").ForwardRefExoticComponent<ContainerProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { space as o, visibilityAttrs as d } from "../Stack/space.js";
|
|
3
|
+
import { forwardRef as y } from "react";
|
|
4
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
5
|
+
var j = y(function({ size: n = "lg", padding: r, paddingBlock: i, center: a = !0, hideBelow: s, hideAbove: c, as: f = "div", className: e, style: m, children: l, ...p }, v) {
|
|
6
|
+
const u = f, t = {};
|
|
7
|
+
return r && (t["--_pad-inline"] = o(r)), i && (t["--_pad-block"] = o(i)), /* @__PURE__ */ b(u, {
|
|
8
|
+
ref: v,
|
|
9
|
+
...p,
|
|
10
|
+
className: `cy-container${e ? ` ${e}` : ""}`,
|
|
11
|
+
"data-size": n,
|
|
12
|
+
"data-center": a ? "" : void 0,
|
|
13
|
+
...d({
|
|
14
|
+
hideBelow: s,
|
|
15
|
+
hideAbove: c
|
|
16
|
+
}),
|
|
17
|
+
style: {
|
|
18
|
+
...t,
|
|
19
|
+
...m
|
|
20
|
+
},
|
|
21
|
+
children: l
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
j as Container
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=Container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.js","names":["space","visibilityAttrs","forwardRef","jsx","Container","size","padding","paddingBlock","center","hideBelow","hideAbove","as","className","style","children","rest","ref","Tag","vars"],"sources":["../../../src/components/Container/Container.tsx"],"sourcesContent":["import { type CSSProperties, type ElementType, forwardRef, type ReactNode } from \"react\";\nimport {\n type LayoutAttributes,\n type Space,\n space,\n type VisibilityProps,\n visibilityAttrs,\n} from \"../Stack/space.js\";\n\nexport interface ContainerTokens {\n /** Widest a `size=\"sm\"` container gets, gutters included. */\n sizeSm: string;\n /** Widest a `size=\"md\"` container gets, gutters included. */\n sizeMd: string;\n /** Widest a `size=\"lg\"` container gets, gutters included. */\n sizeLg: string;\n /** Widest a `size=\"xl\"` container gets, gutters included. */\n sizeXl: string;\n /** Side gutters when the `padding` prop is not set. */\n padding: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n container: ContainerTokens;\n }\n}\n\nexport interface ContainerProps extends VisibilityProps, LayoutAttributes {\n /** Widest the column gets, gutters included; `full` has no limit. Default \"lg\". */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n /**\n * Space token for the gutters at the inline start and end. They never get narrower than the device's safe area\n * (a phone's notch or rounded corners). Default: the `--cy-container-padding` token (space 6).\n */\n padding?: Space | undefined;\n /** Space token of padding at the block start and end (top and bottom). Default: none. */\n paddingBlock?: Space | undefined;\n /** Centre the column in the space around it. `false` keeps it at the inline start. Default true. */\n center?: boolean;\n /** Element to render: `main` for the page's main content, once per page. Default \"div\". */\n as?: \"div\" | \"main\" | \"section\" | \"article\";\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Change the widths through the --cy-container-* tokens. */\n style?: CSSProperties;\n /** The page content. */\n children?: ReactNode;\n /** Set on the root element, for tests. */\n \"data-testid\"?: string;\n}\n\n/** The page column: centres its content, caps its width and adds side gutters, so every page lines up. */\nexport const Container = forwardRef<HTMLElement, ContainerProps>(function Container(\n {\n size = \"lg\",\n padding,\n paddingBlock,\n center = true,\n hideBelow,\n hideAbove,\n as = \"div\",\n className,\n style,\n children,\n ...rest\n },\n ref,\n) {\n const Tag = as as ElementType;\n const vars: Record<string, string> = {};\n if (padding) vars[\"--_pad-inline\"] = space(padding);\n if (paddingBlock) vars[\"--_pad-block\"] = space(paddingBlock);\n return (\n <Tag\n ref={ref}\n {...rest}\n className={`cy-container${className ? ` ${className}` : \"\"}`}\n data-size={size}\n data-center={center ? \"\" : undefined}\n {...visibilityAttrs({ hideBelow, hideAbove })}\n style={{ ...vars, ...style } as CSSProperties}\n >\n {children}\n </Tag>\n );\n});\n"],"mappings":";;;;AAqDA,IAAaI,IAAYF,EAAwC,SAC/D,EACE,MAAAG,IAAO,MACP,SAAAC,GACA,cAAAC,GACA,QAAAC,IAAS,IACT,WAAAC,GACA,WAAAC,GACA,IAAAC,IAAK,OACL,WAAAC,GACA,OAAAC,GACA,UAAAC,GACA,GAAGC,EAAA,GAELC,GACA;AACA,QAAMC,IAAMN,GACNO,IAA+B,CAAC;AACtC,SAAIZ,MAASY,EAAK,eAAA,IAAmBlB,EAAMM,CAAO,IAC9CC,MAAcW,EAAK,cAAA,IAAkBlB,EAAMO,CAAY,IAEzD,gBAAAJ,EAACc,GAAD;AAAA,IACO,KAAAD;AAAA,IACL,GAAID;AAAA,IACJ,WAAW,eAAeH,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACxD,aAAWP;AAAA,IACX,eAAaG,IAAS,KAAK;AAAA,IAC3B,GAAIP,EAAgB;AAAA,MAAE,WAAAQ;AAAA,MAAW,WAAAC;AAAA,IAAU,CAAC;AAAA,IAC5C,OAAO;AAAA,MAAE,GAAGQ;AAAA,MAAM,GAAGL;AAAA,IAAM;AAAA,IAE1B,UAAAC;AAAA,EACE,CAAA;AAET,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Container, type ContainerProps, type ContainerTokens } from "./Container.js";
|
|
@@ -2,13 +2,21 @@ import { type CSSProperties, type KeyboardEvent, type MouseEvent, type PointerEv
|
|
|
2
2
|
import { type MenuEntry } from "../Menu/Menu.js";
|
|
3
3
|
/** Spread onto the one element that opens the menu (a row, a card, a canvas). */
|
|
4
4
|
export interface ContextMenuTargetProps {
|
|
5
|
+
/** Spread onto the target: focus returns to it when the menu closes. */
|
|
5
6
|
ref: Ref<HTMLElement>;
|
|
7
|
+
/** Spread onto the target: opens the menu on right-click, in place of the browser's own menu. */
|
|
6
8
|
onContextMenu: (event: MouseEvent<HTMLElement>) => void;
|
|
9
|
+
/** Spread onto the target: opens the menu on Shift+F10 or the context menu key while the target has focus. */
|
|
7
10
|
onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
11
|
+
/** Spread onto the target: starts the long press that opens the menu on touch screens. */
|
|
8
12
|
onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
13
|
+
/** Spread onto the target: cancels the long press when the finger moves (a scroll). */
|
|
9
14
|
onPointerMove: (event: PointerEvent<HTMLElement>) => void;
|
|
15
|
+
/** Spread onto the target: cancels the long press when the finger lifts early. */
|
|
10
16
|
onPointerUp: () => void;
|
|
17
|
+
/** Spread onto the target: cancels the long press when the browser takes over the touch. */
|
|
11
18
|
onPointerCancel: () => void;
|
|
19
|
+
/** Spread onto the target: tells assistive tech that Shift+F10 opens the menu. */
|
|
12
20
|
"aria-keyshortcuts": "Shift+F10";
|
|
13
21
|
}
|
|
14
22
|
export interface ContextMenuProps {
|
|
@@ -16,12 +24,15 @@ export interface ContextMenuProps {
|
|
|
16
24
|
children: (props: ContextMenuTargetProps) => ReactNode;
|
|
17
25
|
/** Accessible name of the menu. */
|
|
18
26
|
label: string;
|
|
27
|
+
/** The commands, as in `Menu`: items, or sections of items with a group name. */
|
|
19
28
|
items: MenuEntry[];
|
|
29
|
+
/** Called when an item is chosen, with its `value`. */
|
|
20
30
|
onSelect: (value: string) => void;
|
|
21
31
|
/** Called when the menu opens or closes, e.g. to highlight the row it belongs to. */
|
|
22
32
|
onOpenChange?: ((open: boolean) => void) | undefined;
|
|
23
33
|
/** The browser's own menu shows instead. */
|
|
24
34
|
disabled?: boolean;
|
|
35
|
+
/** Added to the menu panel, for layout. */
|
|
25
36
|
className?: string;
|
|
26
37
|
/** Layout only, applied to the panel. */
|
|
27
38
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","names":["_Fragment","MenuPanel","useCallback","useEffect","useId","useRef","useState","Fragment$1","jsx","jsxs","LONG_PRESS","SLOP","point","x","y","ContextMenu","children","label","items","onSelect","onOpenChange","disabled","className","style","id","open","setOpen","target","anchor","press","changed","show","at","close","first","cancelPress","event","fromKeyboard","p"],"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type Ref,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport type { VirtualAnchor } from \"../../overlay/use-anchored-position.js\";\nimport { type MenuEntry, MenuPanel } from \"../Menu/Menu.js\";\n\n/** Spread onto the one element that opens the menu (a row, a card, a canvas). */\nexport interface ContextMenuTargetProps {\n ref: Ref<HTMLElement>;\n onContextMenu: (event: MouseEvent<HTMLElement>) => void;\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n onPointerDown: (event: PointerEvent<HTMLElement>) => void;\n onPointerMove: (event: PointerEvent<HTMLElement>) => void;\n onPointerUp: () => void;\n onPointerCancel: () => void;\n \"aria-keyshortcuts\": \"Shift+F10\";\n}\n\nexport interface ContextMenuProps {\n /** Render the target: `(props) => <div {...props} tabIndex={0}>…</div>`. Make it focusable for keyboard users. */\n children: (props: ContextMenuTargetProps) => ReactNode;\n /** Accessible name of the menu. */\n label: string;\n items: MenuEntry[];\n onSelect: (value: string) => void;\n /** Called when the menu opens or closes, e.g. to highlight the row it belongs to. */\n onOpenChange?: ((open: boolean) => void) | undefined;\n /** The browser's own menu shows instead. */\n disabled?: boolean;\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n}\n\n/** How long a touch must stay down to open the menu (iOS fires no contextmenu event). */\nconst LONG_PRESS = 500;\n/** How far a touch may drift before it counts as a scroll instead of a long press. */\nconst SLOP = 10;\n\nconst point = (x: number, y: number): VirtualAnchor => ({\n getBoundingClientRect: () => new DOMRect(x, y, 0, 0),\n});\n\n/**\n * A menu of commands for one thing, opened where the person points: right-click, a long press on touch screens,\n * or Shift+F10 / the context menu key on the focused target. The menu itself behaves like `Menu`.\n */\nexport function ContextMenu({\n children,\n label,\n items,\n onSelect,\n onOpenChange,\n disabled = false,\n className,\n style,\n}: ContextMenuProps) {\n const id = useId();\n const [open, setOpen] = useState(false);\n const target = useRef<HTMLElement>(null);\n const anchor = useRef<HTMLElement | VirtualAnchor | null>(null);\n const press = useRef<{ x: number; y: number; timer: ReturnType<typeof setTimeout> } | null>(null);\n const changed = useRef(onOpenChange);\n changed.current = onOpenChange;\n\n const show = useCallback((at: HTMLElement | VirtualAnchor) => {\n anchor.current = at;\n setOpen(true);\n }, []);\n const close = useCallback(() => setOpen(false), []);\n const first = useRef(true);\n useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n changed.current?.(open);\n }, [open]);\n\n const cancelPress = () => {\n if (press.current) clearTimeout(press.current.timer);\n press.current = null;\n };\n useEffect(() => cancelPress, []);\n\n return (\n <>\n {children({\n ref: target,\n \"aria-keyshortcuts\": \"Shift+F10\",\n onContextMenu: (event) => {\n if (disabled) return;\n event.preventDefault();\n cancelPress();\n // A keyboard-made contextmenu event has no pointer position: place the menu at the target instead.\n const fromKeyboard = event.clientX === 0 && event.clientY === 0;\n show(fromKeyboard ? event.currentTarget : point(event.clientX, event.clientY));\n },\n onKeyDown: (event) => {\n if (disabled || event.target !== event.currentTarget) return;\n if (event.key === \"ContextMenu\" || (event.key === \"F10\" && event.shiftKey)) {\n event.preventDefault();\n show(event.currentTarget);\n }\n },\n onPointerDown: (event) => {\n if (disabled || event.pointerType !== \"touch\") return;\n const { clientX: x, clientY: y } = event;\n cancelPress();\n press.current = { x, y, timer: setTimeout(() => show(point(x, y)), LONG_PRESS) };\n },\n onPointerMove: (event) => {\n const p = press.current;\n if (p && Math.hypot(event.clientX - p.x, event.clientY - p.y) > SLOP) cancelPress();\n },\n onPointerUp: cancelPress,\n onPointerCancel: cancelPress,\n })}\n <MenuPanel\n id={id}\n label={label}\n items={items}\n onSelect={onSelect}\n open={open}\n onClose={close}\n focusOn=\"first\"\n anchor={anchor}\n placement=\"bottom\"\n offset={2}\n inside={[]}\n returnFocus={target}\n className={className}\n style={style}\n />\n </>\n );\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","names":["_Fragment","MenuPanel","useCallback","useEffect","useId","useRef","useState","Fragment$1","jsx","jsxs","LONG_PRESS","SLOP","point","x","y","ContextMenu","children","label","items","onSelect","onOpenChange","disabled","className","style","id","open","setOpen","target","anchor","press","changed","show","at","close","first","cancelPress","event","fromKeyboard","p"],"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type Ref,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport type { VirtualAnchor } from \"../../overlay/use-anchored-position.js\";\nimport { type MenuEntry, MenuPanel } from \"../Menu/Menu.js\";\n\n/** Spread onto the one element that opens the menu (a row, a card, a canvas). */\nexport interface ContextMenuTargetProps {\n /** Spread onto the target: focus returns to it when the menu closes. */\n ref: Ref<HTMLElement>;\n /** Spread onto the target: opens the menu on right-click, in place of the browser's own menu. */\n onContextMenu: (event: MouseEvent<HTMLElement>) => void;\n /** Spread onto the target: opens the menu on Shift+F10 or the context menu key while the target has focus. */\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n /** Spread onto the target: starts the long press that opens the menu on touch screens. */\n onPointerDown: (event: PointerEvent<HTMLElement>) => void;\n /** Spread onto the target: cancels the long press when the finger moves (a scroll). */\n onPointerMove: (event: PointerEvent<HTMLElement>) => void;\n /** Spread onto the target: cancels the long press when the finger lifts early. */\n onPointerUp: () => void;\n /** Spread onto the target: cancels the long press when the browser takes over the touch. */\n onPointerCancel: () => void;\n /** Spread onto the target: tells assistive tech that Shift+F10 opens the menu. */\n \"aria-keyshortcuts\": \"Shift+F10\";\n}\n\nexport interface ContextMenuProps {\n /** Render the target: `(props) => <div {...props} tabIndex={0}>…</div>`. Make it focusable for keyboard users. */\n children: (props: ContextMenuTargetProps) => ReactNode;\n /** Accessible name of the menu. */\n label: string;\n /** The commands, as in `Menu`: items, or sections of items with a group name. */\n items: MenuEntry[];\n /** Called when an item is chosen, with its `value`. */\n onSelect: (value: string) => void;\n /** Called when the menu opens or closes, e.g. to highlight the row it belongs to. */\n onOpenChange?: ((open: boolean) => void) | undefined;\n /** The browser's own menu shows instead. */\n disabled?: boolean;\n /** Added to the menu panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n}\n\n/** How long a touch must stay down to open the menu (iOS fires no contextmenu event). */\nconst LONG_PRESS = 500;\n/** How far a touch may drift before it counts as a scroll instead of a long press. */\nconst SLOP = 10;\n\nconst point = (x: number, y: number): VirtualAnchor => ({\n getBoundingClientRect: () => new DOMRect(x, y, 0, 0),\n});\n\n/**\n * A menu of commands for one thing, opened where the person points: right-click, a long press on touch screens,\n * or Shift+F10 / the context menu key on the focused target. The menu itself behaves like `Menu`.\n */\nexport function ContextMenu({\n children,\n label,\n items,\n onSelect,\n onOpenChange,\n disabled = false,\n className,\n style,\n}: ContextMenuProps) {\n const id = useId();\n const [open, setOpen] = useState(false);\n const target = useRef<HTMLElement>(null);\n const anchor = useRef<HTMLElement | VirtualAnchor | null>(null);\n const press = useRef<{ x: number; y: number; timer: ReturnType<typeof setTimeout> } | null>(null);\n const changed = useRef(onOpenChange);\n changed.current = onOpenChange;\n\n const show = useCallback((at: HTMLElement | VirtualAnchor) => {\n anchor.current = at;\n setOpen(true);\n }, []);\n const close = useCallback(() => setOpen(false), []);\n const first = useRef(true);\n useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n changed.current?.(open);\n }, [open]);\n\n const cancelPress = () => {\n if (press.current) clearTimeout(press.current.timer);\n press.current = null;\n };\n useEffect(() => cancelPress, []);\n\n return (\n <>\n {children({\n ref: target,\n \"aria-keyshortcuts\": \"Shift+F10\",\n onContextMenu: (event) => {\n if (disabled) return;\n event.preventDefault();\n cancelPress();\n // A keyboard-made contextmenu event has no pointer position: place the menu at the target instead.\n const fromKeyboard = event.clientX === 0 && event.clientY === 0;\n show(fromKeyboard ? event.currentTarget : point(event.clientX, event.clientY));\n },\n onKeyDown: (event) => {\n if (disabled || event.target !== event.currentTarget) return;\n if (event.key === \"ContextMenu\" || (event.key === \"F10\" && event.shiftKey)) {\n event.preventDefault();\n show(event.currentTarget);\n }\n },\n onPointerDown: (event) => {\n if (disabled || event.pointerType !== \"touch\") return;\n const { clientX: x, clientY: y } = event;\n cancelPress();\n press.current = { x, y, timer: setTimeout(() => show(point(x, y)), LONG_PRESS) };\n },\n onPointerMove: (event) => {\n const p = press.current;\n if (p && Math.hypot(event.clientX - p.x, event.clientY - p.y) > SLOP) cancelPress();\n },\n onPointerUp: cancelPress,\n onPointerCancel: cancelPress,\n })}\n <MenuPanel\n id={id}\n label={label}\n items={items}\n onSelect={onSelect}\n open={open}\n onClose={close}\n focusOn=\"first\"\n anchor={anchor}\n placement=\"bottom\"\n offset={2}\n inside={[]}\n returnFocus={target}\n className={className}\n style={style}\n />\n </>\n );\n}\n"],"mappings":";;;;AAwDA,IAAMU,IAAa,KAEbC,IAAO,IAEPC,IAAA,CAASC,GAAWC,OAA8B,EACtD,uBAAA,MAA6B,IAAI,QAAQD,GAAGC,GAAG,GAAG,CAAC,EACrD;AAMA,SAAgBC,EAAY,EAC1B,UAAAC,GACA,OAAAC,GACA,OAAAC,GACA,UAAAC,GACA,cAAAC,GACA,UAAAC,IAAW,IACX,WAAAC,GACA,OAAAC,EAAA,GACmB;AACnB,QAAMC,IAAKpB,EAAM,GACX,CAACqB,GAAMC,CAAA,IAAWpB,EAAS,EAAK,GAChCqB,IAAStB,EAAoB,IAAI,GACjCuB,IAASvB,EAA2C,IAAI,GACxDwB,IAAQxB,EAA8E,IAAI,GAC1FyB,IAAUzB,EAAOe,CAAY;AACnC,EAAAU,EAAQ,UAAUV;AAElB,QAAMW,IAAO7B,EAAA,CAAa8B,MAAoC;AAC5D,IAAAJ,EAAO,UAAUI,GACjBN,EAAQ,EAAI;AAAA,EACd,GAAG,CAAC,CAAC,GACCO,IAAQ/B,EAAA,MAAkBwB,EAAQ,EAAK,GAAG,CAAC,CAAC,GAC5CQ,IAAQ7B,EAAO,EAAI;AACzB,EAAAF,EAAA,MAAgB;AACd,QAAI+B,EAAM,SAAS;AACjB,MAAAA,EAAM,UAAU;AAChB;AAAA,IACF;AACA,IAAAJ,EAAQ,UAAUL,CAAI;AAAA,EACxB,GAAG,CAACA,CAAI,CAAC;AAET,QAAMU,IAAA,MAAoB;AACxB,IAAIN,EAAM,WAAS,aAAaA,EAAM,QAAQ,KAAK,GACnDA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AAAA,IACJ,MAAAM;AAAA,IACN,SAASQ;AAAA,IACT,SAAQ;AAAA,IACA,QAAAL;AAAA,IACR,WAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ,CAAC;AAAA,IACT,aAAaD;AAAA,IACF,WAAAL;AAAA,IACJ,OAAAC;AAAA,EACR,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -13,6 +13,7 @@ export interface CopyButtonLabels {
|
|
|
13
13
|
export interface CopyButtonProps {
|
|
14
14
|
/** The text to copy (or a function that returns it when clicked). */
|
|
15
15
|
value: string | (() => string);
|
|
16
|
+
/** Replace the built-in English text: the button's name before copying, after a copy and after a failure. */
|
|
16
17
|
labels?: Partial<CopyButtonLabels>;
|
|
17
18
|
/** Milliseconds before the button goes back to its copy state (default 2000). */
|
|
18
19
|
timeout?: number;
|
|
@@ -21,12 +22,19 @@ export interface CopyButtonProps {
|
|
|
21
22
|
* document, `chrome.runtime` messaging) or tests. A rejection or throw shows the failed state.
|
|
22
23
|
*/
|
|
23
24
|
copy?: (text: string) => Promise<void> | void;
|
|
25
|
+
/** Called after a successful copy, with the text that was copied. */
|
|
24
26
|
onCopy?: (text: string) => void;
|
|
27
|
+
/** Called when copying fails, with the error. */
|
|
25
28
|
onError?: (error: unknown) => void;
|
|
29
|
+
/** Size of the button. Default "md". */
|
|
26
30
|
size?: Size;
|
|
31
|
+
/** Fill style of the button. Default "ghost". */
|
|
27
32
|
variant?: ButtonVariant;
|
|
33
|
+
/** Where the label tooltip appears. Default "top". */
|
|
28
34
|
tooltipPlacement?: Placement;
|
|
35
|
+
/** The button cannot be pressed. */
|
|
29
36
|
disabled?: boolean;
|
|
37
|
+
/** Added to the root element, for layout. */
|
|
30
38
|
className?: string;
|
|
31
39
|
/** Layout only. */
|
|
32
40
|
style?: CSSProperties;
|
|
@@ -3,8 +3,8 @@ import { IconButton as B } from "../IconButton/IconButton.js";
|
|
|
3
3
|
import { check as L } from "../../icons/check.js";
|
|
4
4
|
import { copy as S } from "../../icons/copy.js";
|
|
5
5
|
import { xCircle as j } from "../../icons/x-circle.js";
|
|
6
|
-
import { useEffect as k, useRef as A, useState as
|
|
7
|
-
import { jsx as
|
|
6
|
+
import { useEffect as k, useRef as A, useState as l } from "react";
|
|
7
|
+
import { jsx as u, jsxs as D } from "react/jsx-runtime";
|
|
8
8
|
var F = {
|
|
9
9
|
copy: "Copy",
|
|
10
10
|
copied: "Copied",
|
|
@@ -13,43 +13,44 @@ var F = {
|
|
|
13
13
|
if (!navigator.clipboard?.writeText) throw new Error("Clipboard unavailable");
|
|
14
14
|
return navigator.clipboard.writeText(e);
|
|
15
15
|
};
|
|
16
|
-
function $({ value: e, labels: m, timeout:
|
|
17
|
-
const
|
|
16
|
+
function $({ value: e, labels: m, timeout: y = 2e3, copy: f = I, onCopy: w, onError: b, size: v = "md", variant: C = "ghost", tooltipPlacement: s, disabled: x, className: n, style: T }) {
|
|
17
|
+
const c = {
|
|
18
18
|
...F,
|
|
19
19
|
...m
|
|
20
|
-
}, [
|
|
21
|
-
k(() => () => clearTimeout(
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
|
|
20
|
+
}, [t, d] = l("idle"), [h, i] = l(""), r = A(void 0);
|
|
21
|
+
k(() => () => clearTimeout(r.current), []);
|
|
22
|
+
const p = (o) => {
|
|
23
|
+
d(o), i(o === "copied" ? c.copied : c.failed), clearTimeout(r.current), r.current = setTimeout(() => {
|
|
24
|
+
d("idle"), i("");
|
|
25
|
+
}, y);
|
|
26
|
+
}, g = async () => {
|
|
27
|
+
i("");
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
30
|
-
await
|
|
31
|
-
} catch (
|
|
32
|
-
await new Promise((a) => setTimeout(a)),
|
|
29
|
+
const o = typeof e == "function" ? e() : e;
|
|
30
|
+
await f(o), await new Promise((a) => setTimeout(a)), p("copied"), w?.(o);
|
|
31
|
+
} catch (o) {
|
|
32
|
+
await new Promise((a) => setTimeout(a)), p("failed"), b?.(o);
|
|
33
33
|
}
|
|
34
|
-
}, E =
|
|
34
|
+
}, E = t === "copied" ? c.copied : t === "failed" ? c.failed : c.copy;
|
|
35
35
|
return /* @__PURE__ */ D("span", {
|
|
36
36
|
className: n ? `cy-copy-button ${n}` : "cy-copy-button",
|
|
37
|
-
"data-state":
|
|
38
|
-
style:
|
|
39
|
-
children: [/* @__PURE__ */
|
|
40
|
-
icon:
|
|
37
|
+
"data-state": t,
|
|
38
|
+
style: T,
|
|
39
|
+
children: [/* @__PURE__ */ u(B, {
|
|
40
|
+
icon: t === "copied" ? L : t === "failed" ? j : S,
|
|
41
41
|
label: E,
|
|
42
|
-
size:
|
|
43
|
-
variant:
|
|
44
|
-
|
|
42
|
+
size: v,
|
|
43
|
+
variant: C,
|
|
44
|
+
iconColor: t === "copied" ? "var(--cy-color-success-text)" : t === "failed" ? "var(--cy-color-danger-text)" : void 0,
|
|
45
|
+
disabled: x,
|
|
45
46
|
onClick: () => {
|
|
46
|
-
|
|
47
|
+
g();
|
|
47
48
|
},
|
|
48
49
|
...s ? { tooltipPlacement: s } : {}
|
|
49
|
-
}), /* @__PURE__ */
|
|
50
|
-
className: "cy-copy-button-status cy-reset",
|
|
50
|
+
}), /* @__PURE__ */ u("span", {
|
|
51
|
+
className: "cy-copy-button-status cy-reset cy-visually-hidden",
|
|
51
52
|
role: "status",
|
|
52
|
-
children:
|
|
53
|
+
children: h
|
|
53
54
|
})]
|
|
54
55
|
});
|
|
55
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.js","names":["copy","copyIcon","IconButton","check","copy","xCircle","useEffect","useRef","useState","jsx","jsxs","DEFAULT_LABELS","writeClipboard","text","CopyButton","value","labels","timeout","copy$1","onCopy","onError","size","variant","tooltipPlacement","disabled","className","style","state","setState","message","setMessage","timer","settle","next","run","content","resolve","error","label"],"sources":["../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { type CSSProperties, useEffect, useRef, useState } from \"react\";\nimport { check } from \"../../icons/check.js\";\nimport { copy as copyIcon } from \"../../icons/copy.js\";\nimport { xCircle } from \"../../icons/x-circle.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport type { ButtonVariant } from \"../Button/Button.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface CopyButtonLabels {\n /** Name and tooltip before copying. */\n copy: string;\n /** Name, tooltip and announcement after a successful copy. */\n copied: string;\n /** Name, tooltip and announcement when the clipboard refused. */\n failed: string;\n}\n\nexport interface CopyButtonProps {\n /** The text to copy (or a function that returns it when clicked). */\n value: string | (() => string);\n labels?: Partial<CopyButtonLabels>;\n /** Milliseconds before the button goes back to its copy state (default 2000). */\n timeout?: number;\n /**\n * Writes to the clipboard. Defaults to `navigator.clipboard.writeText`; pass your own for extensions (an offscreen\n * document, `chrome.runtime` messaging) or tests. A rejection or throw shows the failed state.\n */\n copy?: (text: string) => Promise<void> | void;\n onCopy?: (text: string) => void;\n onError?: (error: unknown) => void;\n size?: Size;\n variant?: ButtonVariant;\n tooltipPlacement?: Placement;\n disabled?: boolean;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\ntype State = \"idle\" | \"copied\" | \"failed\";\nconst DEFAULT_LABELS: CopyButtonLabels = { copy: \"Copy\", copied: \"Copied\", failed: \"Could not copy\" };\n\nconst writeClipboard = (text: string) => {\n if (!navigator.clipboard?.writeText) throw new Error(\"Clipboard unavailable\");\n return navigator.clipboard.writeText(text);\n};\n\n/** An IconButton that copies a value, swaps to a check (or an error) and announces the result. Never throws. */\nexport function CopyButton({\n value,\n labels,\n timeout = 2000,\n copy = writeClipboard,\n onCopy,\n onError,\n size = \"md\",\n variant = \"ghost\",\n tooltipPlacement,\n disabled,\n className,\n style,\n}: CopyButtonProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [state, setState] = useState<State>(\"idle\");\n const [message, setMessage] = useState(\"\");\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n useEffect(() => () => clearTimeout(timer.current), []);\n\n const settle = (next: State) => {\n setState(next);\n setMessage(next === \"copied\" ? text.copied : text.failed);\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n setState(\"idle\");\n setMessage(\"\");\n }, timeout);\n };\n\n const run = async () => {\n // Clear the live region first, so copying again while it still says \"Copied\" is announced again.\n setMessage(\"\");\n try {\n const content = typeof value === \"function\" ? value() : value;\n await copy(content);\n await new Promise((resolve) => setTimeout(resolve));\n settle(\"copied\");\n onCopy?.(content);\n } catch (error) {\n await new Promise((resolve) => setTimeout(resolve));\n settle(\"failed\");\n onError?.(error);\n }\n };\n\n const label = state === \"copied\" ? text.copied : state === \"failed\" ? text.failed : text.copy;\n return (\n <span\n className={className ? `cy-copy-button ${className}` : \"cy-copy-button\"}\n data-state={state}\n style={style}\n >\n <IconButton\n icon={state === \"copied\" ? check : state === \"failed\" ? xCircle : copyIcon}\n label={label}\n size={size}\n variant={variant}\n disabled={disabled}\n onClick={() => void run()}\n {...(tooltipPlacement ? { tooltipPlacement } : {})}\n />\n <span className=\"cy-copy-button-status cy-reset\" role=\"status\">\n {message}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"CopyButton.js","names":["copy","copyIcon","IconButton","check","copy","xCircle","useEffect","useRef","useState","jsx","jsxs","DEFAULT_LABELS","writeClipboard","text","CopyButton","value","labels","timeout","copy$1","onCopy","onError","size","variant","tooltipPlacement","disabled","className","style","state","setState","message","setMessage","timer","settle","next","run","content","resolve","error","label"],"sources":["../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { type CSSProperties, useEffect, useRef, useState } from \"react\";\nimport { check } from \"../../icons/check.js\";\nimport { copy as copyIcon } from \"../../icons/copy.js\";\nimport { xCircle } from \"../../icons/x-circle.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport type { ButtonVariant } from \"../Button/Button.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface CopyButtonLabels {\n /** Name and tooltip before copying. */\n copy: string;\n /** Name, tooltip and announcement after a successful copy. */\n copied: string;\n /** Name, tooltip and announcement when the clipboard refused. */\n failed: string;\n}\n\nexport interface CopyButtonProps {\n /** The text to copy (or a function that returns it when clicked). */\n value: string | (() => string);\n /** Replace the built-in English text: the button's name before copying, after a copy and after a failure. */\n labels?: Partial<CopyButtonLabels>;\n /** Milliseconds before the button goes back to its copy state (default 2000). */\n timeout?: number;\n /**\n * Writes to the clipboard. Defaults to `navigator.clipboard.writeText`; pass your own for extensions (an offscreen\n * document, `chrome.runtime` messaging) or tests. A rejection or throw shows the failed state.\n */\n copy?: (text: string) => Promise<void> | void;\n /** Called after a successful copy, with the text that was copied. */\n onCopy?: (text: string) => void;\n /** Called when copying fails, with the error. */\n onError?: (error: unknown) => void;\n /** Size of the button. Default \"md\". */\n size?: Size;\n /** Fill style of the button. Default \"ghost\". */\n variant?: ButtonVariant;\n /** Where the label tooltip appears. Default \"top\". */\n tooltipPlacement?: Placement;\n /** The button cannot be pressed. */\n disabled?: boolean;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\ntype State = \"idle\" | \"copied\" | \"failed\";\nconst DEFAULT_LABELS: CopyButtonLabels = { copy: \"Copy\", copied: \"Copied\", failed: \"Could not copy\" };\n\nconst writeClipboard = (text: string) => {\n if (!navigator.clipboard?.writeText) throw new Error(\"Clipboard unavailable\");\n return navigator.clipboard.writeText(text);\n};\n\n/** An IconButton that copies a value, swaps to a check (or an error) and announces the result. Never throws. */\nexport function CopyButton({\n value,\n labels,\n timeout = 2000,\n copy = writeClipboard,\n onCopy,\n onError,\n size = \"md\",\n variant = \"ghost\",\n tooltipPlacement,\n disabled,\n className,\n style,\n}: CopyButtonProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [state, setState] = useState<State>(\"idle\");\n const [message, setMessage] = useState(\"\");\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n useEffect(() => () => clearTimeout(timer.current), []);\n\n const settle = (next: State) => {\n setState(next);\n setMessage(next === \"copied\" ? text.copied : text.failed);\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n setState(\"idle\");\n setMessage(\"\");\n }, timeout);\n };\n\n const run = async () => {\n // Clear the live region first, so copying again while it still says \"Copied\" is announced again.\n setMessage(\"\");\n try {\n const content = typeof value === \"function\" ? value() : value;\n await copy(content);\n await new Promise((resolve) => setTimeout(resolve));\n settle(\"copied\");\n onCopy?.(content);\n } catch (error) {\n await new Promise((resolve) => setTimeout(resolve));\n settle(\"failed\");\n onError?.(error);\n }\n };\n\n const label = state === \"copied\" ? text.copied : state === \"failed\" ? text.failed : text.copy;\n return (\n <span\n className={className ? `cy-copy-button ${className}` : \"cy-copy-button\"}\n data-state={state}\n style={style}\n >\n <IconButton\n icon={state === \"copied\" ? check : state === \"failed\" ? xCircle : copyIcon}\n label={label}\n size={size}\n variant={variant}\n iconColor={\n state === \"copied\"\n ? \"var(--cy-color-success-text)\"\n : state === \"failed\"\n ? \"var(--cy-color-danger-text)\"\n : undefined\n }\n disabled={disabled}\n onClick={() => void run()}\n {...(tooltipPlacement ? { tooltipPlacement } : {})}\n />\n <span className=\"cy-copy-button-status cy-reset cy-visually-hidden\" role=\"status\">\n {message}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;;AAiDA,IAAMW,IAAmC;AAAA,EAAE,MAAM;AAAA,EAAQ,QAAQ;AAAA,EAAU,QAAQ;AAAiB,GAE9FC,IAAA,CAAkBC,MAAiB;AACvC,MAAI,CAAC,UAAU,WAAW,UAAW,OAAM,IAAI,MAAM,uBAAuB;AAC5E,SAAO,UAAU,UAAU,UAAUA,CAAI;AAC3C;AAGA,SAAgBC,EAAW,EACzB,OAAAC,GACA,QAAAC,GACA,SAAAC,IAAU,KACV,MAAAC,IAAON,GACP,QAAAO,GACA,SAAAC,GACA,MAAA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,MAAU,WAAWxB,IAAQwB,MAAU,WAAWtB,IAAUJ;AAAAA,MAC3D,OAAAqC;AAAA,MACD,MAAAjB;AAAA,MACG,SAAAC;AAAA,MACT,WACEK,MAAU,WACN,iCACAA,MAAU,WACR,gCACA;AAAA,MAEE,UAAAH;AAAA,MACV,SAAA,MAAA;AAAe,QAAKU,EAAI;AAAA;AAAA,MACxB,GAAKX,IAAmB,EAAE,kBAAAA,EAAiB,IAAI,CAAC;AAAA,IACjD,CAAA,GACD,gBAAAd,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAoD,MAAK;AAAA,MACtE,UAAAoB;AAAA,IACG,CAAA,CACF;AAAA,E;AAEV"}
|
|
@@ -12,30 +12,47 @@ export interface DateFieldLabels {
|
|
|
12
12
|
next: string;
|
|
13
13
|
}
|
|
14
14
|
export interface DateFieldProps {
|
|
15
|
+
/** Visible label; it names the field. */
|
|
15
16
|
label: ReactNode;
|
|
17
|
+
/** Visually hide the label (it still names the field). Prefer visible labels. */
|
|
16
18
|
labelHidden?: boolean;
|
|
19
|
+
/** Help text shown below the field. */
|
|
17
20
|
description?: ReactNode;
|
|
18
21
|
/** Your own error; it replaces the field's own messages. */
|
|
19
22
|
error?: ReactNode;
|
|
20
23
|
/** `YYYY-MM-DD`, or null when empty. */
|
|
21
24
|
value?: string | null;
|
|
25
|
+
/** Starting date when uncontrolled, as `YYYY-MM-DD`. */
|
|
22
26
|
defaultValue?: string | null;
|
|
23
27
|
/** A valid, available date (or null when cleared), when typing is finished or a day is picked. */
|
|
24
28
|
onChange?: (date: string | null) => void;
|
|
29
|
+
/** Earliest date that can be typed or picked, as `YYYY-MM-DD`. */
|
|
25
30
|
min?: string | undefined;
|
|
31
|
+
/** Latest date that can be typed or picked, as `YYYY-MM-DD`. */
|
|
26
32
|
max?: string | undefined;
|
|
33
|
+
/** Return true for dates that cannot be chosen (fully booked, weekends). */
|
|
27
34
|
isDateDisabled?: ((date: string) => boolean) | undefined;
|
|
28
35
|
/** The calendar's locale and first day of the week. */
|
|
29
36
|
locale?: string | undefined;
|
|
37
|
+
/** 0 Sunday to 6 Saturday. Default: the locale's first day, else Monday. */
|
|
30
38
|
weekStartsOn?: number | undefined;
|
|
39
|
+
/** What the calendar counts as today, as `YYYY-MM-DD`. Default: the device's date. */
|
|
31
40
|
today?: string | undefined;
|
|
41
|
+
/** Name the field's text is submitted under in a form. */
|
|
32
42
|
name?: string | undefined;
|
|
43
|
+
/** Id of the form it belongs to, when it is not inside that form. */
|
|
33
44
|
form?: string | undefined;
|
|
45
|
+
/** Marks the field as required for form validation. */
|
|
34
46
|
required?: boolean | undefined;
|
|
47
|
+
/** Turns off the field and the calendar button. */
|
|
35
48
|
disabled?: boolean | undefined;
|
|
49
|
+
/** The date can be read but not changed; the calendar button is hidden. */
|
|
36
50
|
readOnly?: boolean | undefined;
|
|
51
|
+
/** Size of the field. Default "md". */
|
|
37
52
|
size?: Size;
|
|
53
|
+
/** Replace the built-in English text: the calendar button, the two error messages and the month buttons. */
|
|
38
54
|
labels?: Partial<DateFieldLabels>;
|
|
55
|
+
/** Added to the root element, for layout. */
|
|
39
56
|
className?: string;
|
|
40
57
|
/** Layout only. */
|
|
41
58
|
style?: CSSProperties;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useControllableState as _ } from "../../foundations/controllable.js";
|
|
3
3
|
import { IconButton as G } from "../IconButton/IconButton.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { Popover as J } from "../Popover/Popover.js";
|
|
5
|
+
import { addDays as Q, addMonths as V, isISODate as b } from "../Calendar/dates.js";
|
|
6
|
+
import { Calendar as W } from "../Calendar/Calendar.js";
|
|
7
7
|
import { TextField as X } from "../TextField/TextField.js";
|
|
8
8
|
import { calendar as Z } from "../../icons/calendar.js";
|
|
9
9
|
import { useEffect as H, useId as ee, useRef as oe, useState as D } from "react";
|
|
@@ -39,7 +39,7 @@ function de({ label: c, labelHidden: t, description: C, error: Y, value: I, defa
|
|
|
39
39
|
const h = o === null ? r : b(u(o)) ? u(o) : null;
|
|
40
40
|
if (!h) return;
|
|
41
41
|
e.preventDefault();
|
|
42
|
-
const B = e.key === "ArrowUp" ? 1 : -1, y = e.shiftKey ?
|
|
42
|
+
const B = e.key === "ArrowUp" ? 1 : -1, y = e.shiftKey ? V(h, B) : Q(h, B);
|
|
43
43
|
l !== void 0 && y < l || a !== void 0 && y > a || k(y);
|
|
44
44
|
};
|
|
45
45
|
return H(() => {
|
|
@@ -65,7 +65,7 @@ function de({ label: c, labelHidden: t, description: C, error: Y, value: I, defa
|
|
|
65
65
|
size: j,
|
|
66
66
|
className: S ? `cy-date-field ${S}` : "cy-date-field",
|
|
67
67
|
...$ ? { style: $ } : {},
|
|
68
|
-
addonEnd: !d && /* @__PURE__ */ s(
|
|
68
|
+
addonEnd: !d && /* @__PURE__ */ s(J, {
|
|
69
69
|
label: n.open,
|
|
70
70
|
open: v,
|
|
71
71
|
onOpenChange: M,
|
|
@@ -83,7 +83,7 @@ function de({ label: c, labelHidden: t, description: C, error: Y, value: I, defa
|
|
|
83
83
|
children: /* @__PURE__ */ s("div", {
|
|
84
84
|
id: `${m}-calendar`,
|
|
85
85
|
className: "cy-date-field-calendar",
|
|
86
|
-
children: /* @__PURE__ */ s(
|
|
86
|
+
children: /* @__PURE__ */ s(W, {
|
|
87
87
|
value: o !== null && b(u(o)) ? u(o) : r,
|
|
88
88
|
onChange: (e) => {
|
|
89
89
|
k(e), M(!1), w.current?.focus();
|