@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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Icon as I } from "../../foundations/Icon/Icon.js";
|
|
3
|
+
import { useImageOutcome as N } from "../../foundations/image-outcome.js";
|
|
4
|
+
import { user as b } from "../../icons/user.js";
|
|
5
|
+
import { Children as E, createContext as L, forwardRef as $, useContext as O, useRef as _ } from "react";
|
|
6
|
+
import { jsx as s, jsxs as w } from "react/jsx-runtime";
|
|
7
|
+
var j = {
|
|
8
|
+
online: "online",
|
|
9
|
+
away: "away",
|
|
10
|
+
busy: "busy",
|
|
11
|
+
offline: "offline"
|
|
12
|
+
}, S = [
|
|
13
|
+
"accent",
|
|
14
|
+
"info",
|
|
15
|
+
"success",
|
|
16
|
+
"warning",
|
|
17
|
+
"danger"
|
|
18
|
+
], G = /^[^\p{L}\p{N}\p{Extended_Pictographic}\p{Regional_Indicator}]+/u;
|
|
19
|
+
function T(t) {
|
|
20
|
+
return (Intl.Segmenter ? new Intl.Segmenter().segment(t)[Symbol.iterator]().next().value?.segment : Array.from(t)[0]).toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
function z(t) {
|
|
23
|
+
const e = t.split(/\s+/).map((r) => r.replace(G, "")).filter(Boolean);
|
|
24
|
+
return (e.length > 1 ? [e[0], e.at(-1)] : e).map(T).join("");
|
|
25
|
+
}
|
|
26
|
+
function R(t) {
|
|
27
|
+
let e = 0;
|
|
28
|
+
for (let r = 0; r < t.length; r++) e = e * 31 + t.charCodeAt(r) >>> 0;
|
|
29
|
+
return S[e % S.length];
|
|
30
|
+
}
|
|
31
|
+
var x = L(void 0), U = $(function({ name: e, initials: r, src: o, icon: d, size: v = "md", shape: u = "circle", tone: m = "neutral", color: i, status: a, labels: p, decorative: l = !1, className: f, style: n }, g) {
|
|
32
|
+
const C = O(x), h = _(null), c = N(h, o ?? ""), y = c.outcome === "loaded" ? !0 : c.outcome === "error" ? !1 : void 0, A = r ?? (d ? "" : z(e));
|
|
33
|
+
return /* @__PURE__ */ w("span", {
|
|
34
|
+
ref: g,
|
|
35
|
+
className: `cy-avatar${f ? ` ${f}` : ""}`,
|
|
36
|
+
...l || !e.trim() ? { "aria-hidden": !0 } : {
|
|
37
|
+
role: "img",
|
|
38
|
+
"aria-label": a ? `${e}, ${p?.[a] ?? j[a]}` : e
|
|
39
|
+
},
|
|
40
|
+
"data-size": C ?? v,
|
|
41
|
+
"data-shape": u,
|
|
42
|
+
"data-tone": i ? void 0 : m === "auto" ? R(e) : m,
|
|
43
|
+
"data-color": i ? "" : void 0,
|
|
44
|
+
style: i ? {
|
|
45
|
+
"--_tone": i,
|
|
46
|
+
...n
|
|
47
|
+
} : n,
|
|
48
|
+
children: [
|
|
49
|
+
y !== !0 && (A ? /* @__PURE__ */ s("span", {
|
|
50
|
+
className: "cy-reset cy-avatar-initials",
|
|
51
|
+
children: A
|
|
52
|
+
}) : /* @__PURE__ */ s(I, { icon: d ?? b })),
|
|
53
|
+
o && y !== !1 && /* @__PURE__ */ s("img", {
|
|
54
|
+
ref: h,
|
|
55
|
+
className: "cy-reset cy-avatar-image",
|
|
56
|
+
src: o,
|
|
57
|
+
alt: "",
|
|
58
|
+
"data-state": c.outcome,
|
|
59
|
+
onLoad: c.loaded,
|
|
60
|
+
onError: c.failed
|
|
61
|
+
}, o),
|
|
62
|
+
a && /* @__PURE__ */ s("span", {
|
|
63
|
+
className: "cy-reset cy-avatar-status",
|
|
64
|
+
"data-status": a
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
}), q = $(function({ children: e, label: r, max: o, size: d = "md", labels: v, className: u, style: m }, i) {
|
|
69
|
+
const a = E.toArray(e), p = o !== void 0 && a.length > o ? Math.max(o, 0) : a.length, l = a.slice(p), f = l.map((n) => n.props?.name).filter((n) => n !== void 0);
|
|
70
|
+
return /* @__PURE__ */ s("div", {
|
|
71
|
+
ref: i,
|
|
72
|
+
role: "group",
|
|
73
|
+
"aria-label": r,
|
|
74
|
+
className: `cy-avatar-group${u ? ` ${u}` : ""}`,
|
|
75
|
+
style: m,
|
|
76
|
+
children: /* @__PURE__ */ w(x.Provider, {
|
|
77
|
+
value: d,
|
|
78
|
+
children: [a.slice(0, p), l.length > 0 && /* @__PURE__ */ s(U, {
|
|
79
|
+
name: (v?.more ?? ((n, g) => `${n} more: ${g.join(", ")}`))(l.length, f),
|
|
80
|
+
initials: `+${l.length}`
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
export {
|
|
86
|
+
U as Avatar,
|
|
87
|
+
q as AvatarGroup
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=Avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":["Icon","useImageOutcome","user","Children","createContext","forwardRef","useContext","useRef","jsx","jsxs","STATUS_LABELS","AUTO_TONES","LEADING","firstCharacter","word","initialsOf","name","words","toneOf","hash","i","GroupSize","Avatar","initials","src","icon","size","shape","tone","color","status","labels","decorative","className","style","ref","groupSize","image","picture","outcome","letters","AvatarGroup","children","label","max","all","shown","hidden","names","child","count","list"],"sources":["../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import {\n Children,\n type CSSProperties,\n createContext,\n forwardRef,\n type ReactElement,\n type ReactNode,\n useContext,\n useRef,\n} from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { useImageOutcome } from \"../../foundations/image-outcome.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { user } from \"../../icons/user.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\n\nexport interface AvatarTokens {\n /** Width and height at `size=\"xs\"`. */\n sizeXs: string;\n /** Width and height at `size=\"sm\"` (the small control height). */\n sizeSm: string;\n /** Width and height at `size=\"md\"` (the medium control height). */\n sizeMd: string;\n /** Width and height at `size=\"lg\"` (the large control height). */\n sizeLg: string;\n /** Width and height at `size=\"xl\"`. */\n sizeXl: string;\n /** Corner radius of the square shape. */\n radius: string;\n /** Weight of the initials. */\n fontWeight: string;\n /** Tint strength of the fallback (percentage of the tone mixed into the surface). */\n softMix: string;\n /** Diameter of the status dot. */\n statusSize: string;\n /** Colour of the ring around grouped avatars and the status dot (the surface they sit on). */\n ringColor: string;\n /** Width of that ring. */\n ringWidth: string;\n /** How far each avatar in an AvatarGroup slides over the one before it. */\n overlap: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n avatar: AvatarTokens;\n }\n}\n\nexport type AvatarSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type AvatarStatus = \"online\" | \"away\" | \"busy\" | \"offline\";\n\n/** The spoken names of the statuses. */\nexport type AvatarLabels = Record<AvatarStatus, string>;\n\nconst STATUS_LABELS: AvatarLabels = { online: \"online\", away: \"away\", busy: \"busy\", offline: \"offline\" };\nconst AUTO_TONES: readonly Tone[] = [\"accent\", \"info\", \"success\", \"warning\", \"danger\"];\n/** Punctuation before a word's first letter, number or emoji (\"(Guest)\", \"@ada\"). */\nconst LEADING = /^[^\\p{L}\\p{N}\\p{Extended_Pictographic}\\p{Regional_Indicator}]+/u;\n\n/** The first character as a person sees it: a whole emoji or accented letter where the engine can segment text. */\nfunction firstCharacter(word: string): string {\n const first = Intl.Segmenter\n ? new Intl.Segmenter().segment(word)[Symbol.iterator]().next().value?.segment\n : Array.from(word)[0];\n return (first as string).toUpperCase();\n}\n\n/** First letters of the first and last word, upper-cased. One word gives one letter. */\nfunction initialsOf(name: string): string {\n const words = name\n .split(/\\s+/)\n .map((word) => word.replace(LEADING, \"\"))\n .filter(Boolean);\n return (words.length > 1 ? [words[0] as string, words.at(-1) as string] : words)\n .map(firstCharacter)\n .join(\"\");\n}\n\n/** The same tone for the same name, on every render and on the server. */\nfunction toneOf(name: string): Tone {\n let hash = 0;\n for (let i = 0; i < name.length; i++) hash = (hash * 31 + name.charCodeAt(i)) >>> 0;\n return AUTO_TONES[hash % AUTO_TONES.length] as Tone;\n}\n\n/** The size an AvatarGroup gives its avatars. */\nconst GroupSize = createContext<AvatarSize | undefined>(undefined);\n\nexport interface AvatarProps {\n /** Who or what it is: the accessible name, and where the initials come from. An empty name is not announced. */\n name: string;\n /** Replaces the initials worked out from `name` (one or two characters). */\n initials?: string | undefined;\n /** The picture. The fallback shows while it loads, and stays when it is missing or fails to load. */\n src?: string | undefined;\n /**\n * The fallback for things that are not people: shown instead of initials worked out from `name`. Without it, a\n * name with no letters falls back to the `user` icon.\n */\n icon?: IconData | undefined;\n /** Width and height. Inside an AvatarGroup the group's `size` is used. Default \"md\". */\n size?: AvatarSize;\n /** Outline: a circle, or a square with rounded corners. Default \"circle\". */\n shape?: \"circle\" | \"square\";\n /**\n * Colour of the fallback. `\"auto\"` picks a tone from `name`, the same one every time, so people in a list are\n * easier to tell apart (decoration: the name still has to be shown or spoken). Default \"neutral\".\n */\n tone?: Tone | \"auto\";\n /** Any CSS colour for the fallback, for a one-off. Overrides `tone`. */\n color?: string | undefined;\n /** A dot at the corner, spoken after the name (\"Ada Lovelace, online\"). */\n status?: AvatarStatus | undefined;\n /** The spoken names of the statuses, to translate them. */\n labels?: Partial<AvatarLabels>;\n /** Hides the avatar from assistive technology, for when the name is written beside it. */\n decorative?: boolean;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through `--cy-avatar-*` tokens. */\n style?: CSSProperties;\n}\n\n/** A person, team or thing as a picture, falling back to initials and then to an icon. */\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n {\n name,\n initials,\n src,\n icon,\n size = \"md\",\n shape = \"circle\",\n tone = \"neutral\",\n color,\n status,\n labels,\n decorative = false,\n className,\n style,\n },\n ref,\n) {\n const groupSize = useContext(GroupSize);\n const image = useRef<HTMLImageElement>(null);\n // A new `src` starts again from the fallback; the picture shows once it has loaded and goes if it fails. Before\n // script runs (server HTML, a page never hydrated) the picture is shown over the fallback as the browser has it.\n const picture = useImageOutcome(image, src ?? \"\");\n const outcome = picture.outcome === \"loaded\" ? true : picture.outcome === \"error\" ? false : undefined;\n const letters = initials ?? (icon ? \"\" : initialsOf(name));\n return (\n <span\n ref={ref}\n className={`cy-avatar${className ? ` ${className}` : \"\"}`}\n {...(decorative || !name.trim()\n ? { \"aria-hidden\": true }\n : {\n role: \"img\",\n \"aria-label\": status ? `${name}, ${labels?.[status] ?? STATUS_LABELS[status]}` : name,\n })}\n data-size={groupSize ?? size}\n data-shape={shape}\n data-tone={color ? undefined : tone === \"auto\" ? toneOf(name) : tone}\n data-color={color ? \"\" : undefined}\n style={color ? ({ \"--_tone\": color, ...style } as CSSProperties) : style}\n >\n {outcome !== true &&\n (letters ? (\n <span className=\"cy-reset cy-avatar-initials\">{letters}</span>\n ) : (\n <Icon icon={icon ?? user} />\n ))}\n {src && outcome !== false && (\n <img\n // A new element for each picture, so `complete` never describes the one before.\n key={src}\n ref={image}\n className=\"cy-reset cy-avatar-image\"\n src={src}\n alt=\"\"\n data-state={picture.outcome}\n onLoad={picture.loaded}\n onError={picture.failed}\n />\n )}\n {status && <span className=\"cy-reset cy-avatar-status\" data-status={status} />}\n </span>\n );\n});\n\nexport interface AvatarGroupLabels {\n /** Accessible name of the \"+3\" avatar, from how many are hidden and their names. */\n more: (count: number, names: string[]) => string;\n}\n\nexport interface AvatarGroupProps {\n /** The Avatars, in order. */\n children: ReactNode;\n /** Names the group for assistive technology (\"Reviewers\"). */\n label: string;\n /** Show this many avatars, then one \"+3\" avatar that stands for the rest. */\n max?: number | undefined;\n /** Size of every avatar in the group. Default \"md\". */\n size?: AvatarSize;\n /** The built-in string, to translate it. */\n labels?: Partial<AvatarGroupLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through `--cy-avatar-*` tokens. */\n style?: CSSProperties;\n}\n\n/** Several avatars overlapping along the reading direction, the rest summarised as \"+3\". */\nexport const AvatarGroup = forwardRef<HTMLDivElement, AvatarGroupProps>(function AvatarGroup(\n { children, label, max, size = \"md\", labels, className, style },\n ref,\n) {\n const all = Children.toArray(children);\n const shown = max !== undefined && all.length > max ? Math.max(max, 0) : all.length;\n const hidden = all.slice(shown);\n const names = hidden\n .map((child) => (child as ReactElement<Partial<AvatarProps>>).props?.name)\n .filter((name) => name !== undefined);\n return (\n // biome-ignore lint/a11y/useSemanticElements: a group of pictures, not a form's fieldset\n <div\n ref={ref}\n role=\"group\"\n aria-label={label}\n className={`cy-avatar-group${className ? ` ${className}` : \"\"}`}\n style={style}\n >\n <GroupSize.Provider value={size}>\n {all.slice(0, shown)}\n {hidden.length > 0 && (\n <Avatar\n name={(labels?.more ?? ((count, list) => `${count} more: ${list.join(\", \")}`))(\n hidden.length,\n names,\n )}\n initials={`+${hidden.length}`}\n />\n )}\n </GroupSize.Provider>\n </div>\n );\n});\n"],"mappings":";;;;;;AAuDA,IAAMU,IAA8B;AAAA,EAAE,QAAQ;AAAA,EAAU,MAAM;AAAA,EAAQ,MAAM;AAAA,EAAQ,SAAS;AAAU,GACjGC,IAA8B;AAAA,EAAC;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAW;AAAQ,GAE/EC,IAAU;AAGhB,SAASC,EAAeC,GAAsB;AAI5C,UAHc,KAAK,YACf,IAAI,KAAK,UAAU,EAAE,QAAQA,CAAI,EAAE,OAAO,QAAA,EAAU,EAAE,KAAK,EAAE,OAAO,UACpE,MAAM,KAAKA,CAAI,EAAE,CAAA,GACI,YAAY;AACvC;AAGA,SAASC,EAAWC,GAAsB;AACxC,QAAMC,IAAQD,EACX,MAAM,KAAK,EACX,IAAA,CAAKF,MAASA,EAAK,QAAQF,GAAS,EAAE,CAAC,EACvC,OAAO,OAAO;AACjB,UAAQK,EAAM,SAAS,IAAI,CAACA,EAAM,CAAA,GAAcA,EAAM,GAAG,EAAE,CAAW,IAAIA,GACvE,IAAIJ,CAAc,EAClB,KAAK,EAAE;AACZ;AAGA,SAASK,EAAOF,GAAoB;AAClC,MAAIG,IAAO;AACX,WAASC,IAAI,GAAGA,IAAI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AAQ,SAAA,CAAUmB,GAAOC,MAAS,GAAGD,CAAA,UAAeC,EAAK,KAAK,IAAI,CAAA,KACvEJ,EAAO,QACPC,CACF;AAAA,QACA,UAAU,IAAID,EAAO,MAAA;AAAA,MACtB,CAAA,CAEe;AAAA,I;A,EACjB,CAAA;AAET,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Avatar, AvatarGroup, type AvatarGroupLabels, type AvatarGroupProps, type AvatarLabels, type AvatarProps, type AvatarSize, type AvatarStatus, type AvatarTokens, } from "./Avatar.js";
|
|
@@ -12,10 +12,15 @@ declare module "../../tokens/schema.js" {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export interface BadgeProps {
|
|
15
|
+
/** The badge's text. */
|
|
15
16
|
children: ReactNode;
|
|
17
|
+
/** Semantic colour. Default "neutral". */
|
|
16
18
|
tone?: Tone;
|
|
19
|
+
/** Fill style. Default "soft". */
|
|
17
20
|
variant?: "soft" | "solid" | "outline";
|
|
21
|
+
/** Size of the badge. Default "md". */
|
|
18
22
|
size?: Size;
|
|
23
|
+
/** Icon shown before the text. */
|
|
19
24
|
icon?: IconData | undefined;
|
|
20
25
|
/**
|
|
21
26
|
* A category colour (any CSS colour), for labels a product colours itself (HTTP methods, calendar categories). The
|
|
@@ -24,6 +29,7 @@ export interface BadgeProps {
|
|
|
24
29
|
color?: string | undefined;
|
|
25
30
|
/** A dot before the text: `true` for a steady one, `"live"` for a pulsing one (recording, connected). */
|
|
26
31
|
dot?: boolean | "live";
|
|
32
|
+
/** Added to the root element, for layout. */
|
|
27
33
|
className?: string;
|
|
28
34
|
/** Layout only. */
|
|
29
35
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","names":["Icon","jsx","jsxs","Badge","children","tone","variant","size","icon","color","dot","className","style"],"sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface BadgeTokens {\n radius: string;\n tracking: string;\n softMix: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n badge: BadgeTokens;\n }\n}\n\nexport interface BadgeProps {\n children: ReactNode;\n tone?: Tone;\n variant?: \"soft\" | \"solid\" | \"outline\";\n size?: Size;\n icon?: IconData | undefined;\n /**\n * A category colour (any CSS colour), for labels a product colours itself (HTTP methods, calendar categories). The\n * text is mixed toward the ink so it stays readable. Overrides `tone`.\n */\n color?: string | undefined;\n /** A dot before the text: `true` for a steady one, `\"live\"` for a pulsing one (recording, connected). */\n dot?: boolean | \"live\";\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Small status or category label in the mono \"eyebrow\" style. */\nexport function Badge({\n children,\n tone = \"neutral\",\n variant = \"soft\",\n size = \"md\",\n icon,\n color,\n dot,\n className,\n style,\n}: BadgeProps) {\n return (\n <span\n className={`cy-badge${className ? ` ${className}` : \"\"}`}\n data-tone={color ? undefined : tone}\n data-color={color ? \"\" : undefined}\n data-variant={variant}\n data-size={size}\n style={color ? ({ \"--_tone\": color, ...style } as CSSProperties) : style}\n >\n {dot && (\n <span\n className=\"cy-badge-dot cy-reset\"\n data-live={dot === \"live\" ? \"\" : undefined}\n aria-hidden=\"true\"\n />\n )}\n {icon && <Icon icon={icon} size=\"sm\" />}\n {children}\n </span>\n );\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Badge.js","names":["Icon","jsx","jsxs","Badge","children","tone","variant","size","icon","color","dot","className","style"],"sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface BadgeTokens {\n radius: string;\n tracking: string;\n softMix: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n badge: BadgeTokens;\n }\n}\n\nexport interface BadgeProps {\n /** The badge's text. */\n children: ReactNode;\n /** Semantic colour. Default \"neutral\". */\n tone?: Tone;\n /** Fill style. Default \"soft\". */\n variant?: \"soft\" | \"solid\" | \"outline\";\n /** Size of the badge. Default \"md\". */\n size?: Size;\n /** Icon shown before the text. */\n icon?: IconData | undefined;\n /**\n * A category colour (any CSS colour), for labels a product colours itself (HTTP methods, calendar categories). The\n * text is mixed toward the ink so it stays readable. Overrides `tone`.\n */\n color?: string | undefined;\n /** A dot before the text: `true` for a steady one, `\"live\"` for a pulsing one (recording, connected). */\n dot?: boolean | \"live\";\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Small status or category label in the mono \"eyebrow\" style. */\nexport function Badge({\n children,\n tone = \"neutral\",\n variant = \"soft\",\n size = \"md\",\n icon,\n color,\n dot,\n className,\n style,\n}: BadgeProps) {\n return (\n <span\n className={`cy-badge${className ? ` ${className}` : \"\"}`}\n data-tone={color ? undefined : tone}\n data-color={color ? \"\" : undefined}\n data-variant={variant}\n data-size={size}\n style={color ? ({ \"--_tone\": color, ...style } as CSSProperties) : style}\n >\n {dot && (\n <span\n className=\"cy-badge-dot cy-reset\"\n data-live={dot === \"live\" ? \"\" : undefined}\n aria-hidden=\"true\"\n />\n )}\n {icon && <Icon icon={icon} size=\"sm\" />}\n {children}\n </span>\n );\n}\n"],"mappings":";;;AA0CA,SAAgBG,EAAM,EACpB,UAAAC,GACA,MAAAC,IAAO,WACP,SAAAC,IAAU,QACV,MAAAC,IAAO,MACP,MAAAC,GACA,OAAAC,GACA,KAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACa;AACb,SACE,gBAAAV,EAAC,QAAD;AAAA,IACE,WAAW,WAAWS,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACpD,aAAWF,IAAQ,SAAYJ;AAAA,IAC/B,cAAYI,IAAQ,KAAK;AAAA,IACzB,gBAAcH;AAAA,IACd,aAAWC;AAAA,IACX,OAAOE,IAAS;AAAA,MAAE,WAAWA;AAAA,MAAO,GAAGG;AAAA,IAAM,IAAsBA;AAAA,IANrE,UAAA;AAAA,MAQGF,KACC,gBAAAT,EAAC,QAAD;AAAA,QACE,WAAU;AAAA,QACV,aAAWS,MAAQ,SAAS,KAAK;AAAA,QACjC,eAAY;AAAA,MACb,CAAA;AAAA,MAEFF,KAAQ,gBAAAP,EAACD,GAAD;AAAA,QAAY,MAAAQ;AAAA,QAAM,MAAK;AAAA,MAAM,CAAA;AAAA,MACrCJ;AAAA,IACG;AAAA,E;AAEV"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type CSSProperties, type MouseEvent } from "react";
|
|
2
|
+
import type { IconData } from "../../icons/types.js";
|
|
3
|
+
export interface BreadcrumbsTokens {
|
|
4
|
+
/** Space between crumbs and separators. */
|
|
5
|
+
gap: string;
|
|
6
|
+
/** Widest a single crumb's label gets before it is cut with an ellipsis. */
|
|
7
|
+
itemMaxWidth: string;
|
|
8
|
+
/** Colour of the separators. */
|
|
9
|
+
separatorColor: string;
|
|
10
|
+
}
|
|
11
|
+
declare module "../../tokens/schema.js" {
|
|
12
|
+
interface ComponentTokens {
|
|
13
|
+
breadcrumbs: BreadcrumbsTokens;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export interface BreadcrumbItem {
|
|
17
|
+
/** The page's name. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Where the crumb goes: it becomes a link. Ignored on the last item (the current page). */
|
|
20
|
+
href?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Called when the crumb is chosen, in the trail or in the menu of hidden items. With `href`, call
|
|
23
|
+
* `event.preventDefault()` to route on the client. Without `href` the crumb is a button.
|
|
24
|
+
*/
|
|
25
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
26
|
+
/** A Facet icon before the label. */
|
|
27
|
+
icon?: IconData;
|
|
28
|
+
}
|
|
29
|
+
export interface BreadcrumbsProps {
|
|
30
|
+
/** The trail, from the top of the site to the current page. The last item is the current page. */
|
|
31
|
+
items: BreadcrumbItem[];
|
|
32
|
+
/**
|
|
33
|
+
* Most crumbs to show. With more items, the first one and the last `maxItems - 1` stay and the ones between go into
|
|
34
|
+
* a menu behind a "more" button. Values under 2 count as 2. Default: every item is shown.
|
|
35
|
+
*/
|
|
36
|
+
maxItems?: number;
|
|
37
|
+
/** The icon between crumbs. It is decorative and mirrored in right-to-left text. Default `chevronRight`. */
|
|
38
|
+
separator?: IconData;
|
|
39
|
+
/** Text size. Default "md". */
|
|
40
|
+
size?: "sm" | "md";
|
|
41
|
+
/**
|
|
42
|
+
* Replace the built-in English text: `nav` names the landmark (default "Breadcrumb"), `more` names the button and
|
|
43
|
+
* the menu of hidden items (default "Show the full path").
|
|
44
|
+
*/
|
|
45
|
+
labels?: {
|
|
46
|
+
nav?: string;
|
|
47
|
+
more?: string;
|
|
48
|
+
};
|
|
49
|
+
/** Added to the root element, for layout. */
|
|
50
|
+
className?: string;
|
|
51
|
+
/** Layout only. Restyle through --cy-breadcrumbs-* tokens. */
|
|
52
|
+
style?: CSSProperties;
|
|
53
|
+
}
|
|
54
|
+
/** The trail from the top of a site or app to the current page (APG breadcrumb): links, then the current page. */
|
|
55
|
+
export declare const Breadcrumbs: import("react").ForwardRefExoticComponent<BreadcrumbsProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Icon as y } from "../../foundations/Icon/Icon.js";
|
|
3
|
+
import { Button as x } from "../Button/Button.js";
|
|
4
|
+
import { IconButton as C } from "../IconButton/IconButton.js";
|
|
5
|
+
import { chevronRight as B } from "../../icons/chevron-right.js";
|
|
6
|
+
import { moreHorizontal as S } from "../../icons/more-horizontal.js";
|
|
7
|
+
import { Link as $ } from "../Link/Link.js";
|
|
8
|
+
import { Menu as M } from "../Menu/Menu.js";
|
|
9
|
+
import { forwardRef as R, useRef as j } from "react";
|
|
10
|
+
import { Fragment as w, jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
11
|
+
var J = R(function({ items: n, maxItems: k, separator: g = B, size: l = "md", labels: i, className: m, style: N }, v) {
|
|
12
|
+
const d = j(null), s = n.length - 1, b = Math.max(k ?? n.length, 2), o = (r) => n.length > b && r > 0 && r <= s - (b - 1), u = i?.more ?? "Show the full path", h = /* @__PURE__ */ e(y, {
|
|
13
|
+
icon: g,
|
|
14
|
+
size: "sm",
|
|
15
|
+
className: "cy-breadcrumbs-separator"
|
|
16
|
+
}), f = (r, a) => {
|
|
17
|
+
const c = /* @__PURE__ */ t(w, { children: [r.icon && /* @__PURE__ */ e(y, { icon: r.icon }), /* @__PURE__ */ e("span", {
|
|
18
|
+
className: "cy-breadcrumbs-label cy-reset",
|
|
19
|
+
children: r.label
|
|
20
|
+
})] });
|
|
21
|
+
return /* @__PURE__ */ t("li", {
|
|
22
|
+
className: "cy-breadcrumbs-item cy-reset",
|
|
23
|
+
"data-index": a,
|
|
24
|
+
hidden: o(a),
|
|
25
|
+
children: [a === s ? /* @__PURE__ */ e("span", {
|
|
26
|
+
className: "cy-breadcrumbs-current cy-reset",
|
|
27
|
+
"aria-current": "page",
|
|
28
|
+
children: c
|
|
29
|
+
}) : r.href ? /* @__PURE__ */ e($, {
|
|
30
|
+
href: r.href,
|
|
31
|
+
tone: "neutral",
|
|
32
|
+
size: l,
|
|
33
|
+
className: "cy-breadcrumbs-link",
|
|
34
|
+
...r.onClick ? { onClick: r.onClick } : {},
|
|
35
|
+
children: c
|
|
36
|
+
}) : r.onClick ? /* @__PURE__ */ e(x, {
|
|
37
|
+
variant: "ghost",
|
|
38
|
+
size: l,
|
|
39
|
+
icon: r.icon,
|
|
40
|
+
className: "cy-breadcrumbs-link",
|
|
41
|
+
onClick: r.onClick,
|
|
42
|
+
children: r.label
|
|
43
|
+
}) : /* @__PURE__ */ e("span", {
|
|
44
|
+
className: "cy-breadcrumbs-text cy-reset",
|
|
45
|
+
children: c
|
|
46
|
+
}), a < s && !o(a) && h]
|
|
47
|
+
}, a);
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ e("nav", {
|
|
50
|
+
ref: v,
|
|
51
|
+
"aria-label": i?.nav ?? "Breadcrumb",
|
|
52
|
+
className: `cy-breadcrumbs${m ? ` ${m}` : ""}`,
|
|
53
|
+
"data-size": l,
|
|
54
|
+
style: N,
|
|
55
|
+
children: /* @__PURE__ */ e("ol", {
|
|
56
|
+
ref: d,
|
|
57
|
+
className: "cy-breadcrumbs-list cy-reset",
|
|
58
|
+
children: n.map((r, a) => a === 1 && o(1) ? [/* @__PURE__ */ t("li", {
|
|
59
|
+
className: "cy-breadcrumbs-item cy-reset",
|
|
60
|
+
children: [/* @__PURE__ */ e(M, {
|
|
61
|
+
label: u,
|
|
62
|
+
trigger: (c) => /* @__PURE__ */ e(C, {
|
|
63
|
+
...c,
|
|
64
|
+
icon: S,
|
|
65
|
+
label: u,
|
|
66
|
+
variant: "ghost",
|
|
67
|
+
size: "sm"
|
|
68
|
+
}),
|
|
69
|
+
items: n.flatMap((c, p) => o(p) ? [{
|
|
70
|
+
value: String(p),
|
|
71
|
+
label: c.label,
|
|
72
|
+
disabled: !c.href && !c.onClick,
|
|
73
|
+
...c.icon ? { icon: c.icon } : {}
|
|
74
|
+
}] : []),
|
|
75
|
+
onSelect: (c) => d.current?.querySelector(`[data-index="${c}"] > .cy-breadcrumbs-link`)?.click()
|
|
76
|
+
}), h]
|
|
77
|
+
}, "more"), f(r, a)] : f(r, a))
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
export {
|
|
82
|
+
J as Breadcrumbs
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=Breadcrumbs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.js","names":["_Fragment","Icon","Button","IconButton","chevronRight","moreHorizontal","Link","Menu","forwardRef","useRef","Fragment$1","jsx","jsxs","Breadcrumbs","items","maxItems","separator","size","labels","className","style","ref","list","last","keep","hidden","i","more","sep","crumb","item","content","props","entry","at"],"sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type MouseEvent, useRef } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { chevronRight } from \"../../icons/chevron-right.js\";\nimport { moreHorizontal } from \"../../icons/more-horizontal.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { Button } from \"../Button/Button.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Link } from \"../Link/Link.js\";\nimport { Menu } from \"../Menu/Menu.js\";\n\nexport interface BreadcrumbsTokens {\n /** Space between crumbs and separators. */\n gap: string;\n /** Widest a single crumb's label gets before it is cut with an ellipsis. */\n itemMaxWidth: string;\n /** Colour of the separators. */\n separatorColor: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n breadcrumbs: BreadcrumbsTokens;\n }\n}\n\nexport interface BreadcrumbItem {\n /** The page's name. */\n label: string;\n /** Where the crumb goes: it becomes a link. Ignored on the last item (the current page). */\n href?: string;\n /**\n * Called when the crumb is chosen, in the trail or in the menu of hidden items. With `href`, call\n * `event.preventDefault()` to route on the client. Without `href` the crumb is a button.\n */\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n /** A Facet icon before the label. */\n icon?: IconData;\n}\n\nexport interface BreadcrumbsProps {\n /** The trail, from the top of the site to the current page. The last item is the current page. */\n items: BreadcrumbItem[];\n /**\n * Most crumbs to show. With more items, the first one and the last `maxItems - 1` stay and the ones between go into\n * a menu behind a \"more\" button. Values under 2 count as 2. Default: every item is shown.\n */\n maxItems?: number;\n /** The icon between crumbs. It is decorative and mirrored in right-to-left text. Default `chevronRight`. */\n separator?: IconData;\n /** Text size. Default \"md\". */\n size?: \"sm\" | \"md\";\n /**\n * Replace the built-in English text: `nav` names the landmark (default \"Breadcrumb\"), `more` names the button and\n * the menu of hidden items (default \"Show the full path\").\n */\n labels?: { nav?: string; more?: string };\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-breadcrumbs-* tokens. */\n style?: CSSProperties;\n}\n\n/** The trail from the top of a site or app to the current page (APG breadcrumb): links, then the current page. */\nexport const Breadcrumbs = forwardRef<HTMLElement, BreadcrumbsProps>(function Breadcrumbs(\n { items, maxItems, separator = chevronRight, size = \"md\", labels, className, style },\n ref,\n) {\n const list = useRef<HTMLOListElement>(null);\n const last = items.length - 1;\n const keep = Math.max(maxItems ?? items.length, 2);\n // Hidden when collapsed: everything between the first item and the last `keep - 1`.\n const hidden = (i: number) => items.length > keep && i > 0 && i <= last - (keep - 1);\n const more = labels?.more ?? \"Show the full path\";\n const sep = <Icon icon={separator} size=\"sm\" className=\"cy-breadcrumbs-separator\" />;\n\n const crumb = (item: BreadcrumbItem, i: number) => {\n const content = (\n <>\n {item.icon && <Icon icon={item.icon} />}\n <span className=\"cy-breadcrumbs-label cy-reset\">{item.label}</span>\n </>\n );\n return (\n // Hidden crumbs stay in the DOM (out of the accessibility tree): the menu activates them, so a menu choice is\n // the same click as one in the trail.\n <li key={i} className=\"cy-breadcrumbs-item cy-reset\" data-index={i} hidden={hidden(i)}>\n {i === last ? (\n <span className=\"cy-breadcrumbs-current cy-reset\" aria-current=\"page\">\n {content}\n </span>\n ) : item.href ? (\n <Link\n href={item.href}\n tone=\"neutral\"\n size={size}\n className=\"cy-breadcrumbs-link\"\n {...(item.onClick ? { onClick: item.onClick } : {})}\n >\n {content}\n </Link>\n ) : item.onClick ? (\n <Button\n variant=\"ghost\"\n size={size}\n icon={item.icon}\n className=\"cy-breadcrumbs-link\"\n onClick={item.onClick}\n >\n {item.label}\n </Button>\n ) : (\n <span className=\"cy-breadcrumbs-text cy-reset\">{content}</span>\n )}\n {i < last && !hidden(i) && sep}\n </li>\n );\n };\n\n return (\n <nav\n ref={ref}\n aria-label={labels?.nav ?? \"Breadcrumb\"}\n className={`cy-breadcrumbs${className ? ` ${className}` : \"\"}`}\n data-size={size}\n style={style}\n >\n <ol ref={list} className=\"cy-breadcrumbs-list cy-reset\">\n {items.map((item, i) =>\n i === 1 && hidden(1)\n ? [\n <li key=\"more\" className=\"cy-breadcrumbs-item cy-reset\">\n <Menu\n label={more}\n trigger={(props) => (\n <IconButton {...props} icon={moreHorizontal} label={more} variant=\"ghost\" size=\"sm\" />\n )}\n items={items.flatMap((entry, at) =>\n hidden(at)\n ? [\n {\n value: String(at),\n label: entry.label,\n disabled: !entry.href && !entry.onClick,\n ...(entry.icon ? { icon: entry.icon } : {}),\n },\n ]\n : [],\n )}\n onSelect={(at) =>\n list.current\n ?.querySelector<HTMLElement>(`[data-index=\"${at}\"] > .cy-breadcrumbs-link`)\n ?.click()\n }\n />\n {sep}\n </li>,\n crumb(item, i),\n ]\n : crumb(item, i),\n )}\n </ol>\n </nav>\n );\n});\n"],"mappings":";;;;;;;;;;AA+DA,IAAaa,IAAcL,EAA0C,SACnE,EAAE,OAAAM,GAAO,UAAAC,GAAU,WAAAC,IAAYZ,GAAc,MAAAa,IAAO,MAAM,QAAAC,GAAQ,WAAAC,GAAW,OAAAC,EAAA,GAC7EC,GACA;AACA,QAAMC,IAAOb,EAAyB,IAAI,GACpCc,IAAOT,EAAM,SAAS,GACtBU,IAAO,KAAK,IAAIT,KAAYD,EAAM,QAAQ,CAAC,GAE3CW,IAAA,CAAUC,MAAcZ,EAAM,SAASU,KAAQE,IAAI,KAAKA,KAAKH,KAAQC,IAAO,IAC5EG,IAAOT,GAAQ,QAAQ,sBACvBU,IAAM,gBAAAjB,EAACV,GAAD;AAAA,IAAM,MAAMe;AAAA,IAAW,MAAK;AAAA,IAAK,WAAU;AAAA,EAA4B,CAAA,GAE7Ea,IAAA,CAASC,GAAsBJ,MAAc;AACjD,UAAMK,IACJ,gBAAAnB,EAAAZ,GAAA,EAAA,U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,MAAI,KAAKW;AAAA,MAAM,WAAU;AAAA,MACtB,UAAAR,EAAM,IAAA,CAAKgB,GAAMJ,MAChBA,MAAM,KAAKD,EAAO,CAAC,IACf,CACE,gBAAAb,EAAC,MAAD;AAAA,QAAe,WAAU;AAAA,QAAzB,UAAA,CACE,gBAAAD,EAACJ,GAAD;AAAA,UACE,OAAOoB;AAAA,UACP,SAAA,CAAUK,MACR,gBAAArB,EAACR,GAAD;AAAA,YAAY,GAAI6B;AAAA,YAAO,MAAM3B;AAAA,YAAgB,OAAOsB;AAAA,YAAM,SAAQ;AAAA,YAAQ,MAAK;AAAA,UAAM,CAAA;AAAA,UAEvF,OAAOb,EAAM,QAAA,CAASmB,GAAOC,MAC3BT,EAAOS,CAAE,IACL,CACE;AAAA,YACE,OAAO,OAAOA,CAAE;AAAA,YAChB,OAAOD,EAAM;AAAA,YACb,UAAU,CAACA,EAAM,QAAQ,CAACA,EAAM;AAAA,YAChC,GAAIA,EAAM,OAAO,EAAE,MAAMA,EAAM,KAAK,IAAI,CAAC;AAAA,UAC3C,CACF,IACA,CAAC,CACP;AAAA,UACA,UAAA,CAAWC,MACTZ,EAAK,SACD,cAA2B,gBAAgBY,CAAA,2BAA6B,GACxE,MAAM;AAAA,QAEb,CAAA,GACAN,CACC;AAAA,MAzBI,GAAA,MAyBJ,GACJC,EAAMC,GAAMJ,CAAC,CACf,IACAG,EAAMC,GAAMJ,CAAC,CACnB;AAAA,IACE,CAAA;AAAA,EACD,CAAA;AAET,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type BreadcrumbItem, Breadcrumbs, type BreadcrumbsProps, type BreadcrumbsTokens, } from "./Breadcrumbs.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CSSProperties, type ReactNode } from "react";
|
|
1
|
+
import { type AriaAttributes, type CSSProperties, type ReactNode, type Ref } from "react";
|
|
2
2
|
import { type ButtonBaseProps } from "../../foundations/ButtonBase/ButtonBase.js";
|
|
3
3
|
import type { IconData } from "../../icons/types.js";
|
|
4
4
|
import type { Size, Tone } from "../../tokens/schema.js";
|
|
@@ -30,6 +30,13 @@ export interface ButtonProps extends Omit<ButtonBaseProps, "children" | "classNa
|
|
|
30
30
|
variant?: ButtonVariant;
|
|
31
31
|
/** Semantic colour. */
|
|
32
32
|
tone?: Tone;
|
|
33
|
+
/**
|
|
34
|
+
* A one-off colour (any CSS colour), for a brand button such as "Get it on Google Play". Overrides `tone`. The text
|
|
35
|
+
* on a solid fill is white or black, whichever reads; on the other variants the colour is darkened or lightened
|
|
36
|
+
* until it reads on the surface. Prefer a tone or the theme's accent.
|
|
37
|
+
*/
|
|
38
|
+
color?: string | undefined;
|
|
39
|
+
/** Height and text size of the button. Default "md". */
|
|
33
40
|
size?: Size;
|
|
34
41
|
/** Leading icon (inline-start, RTL aware). */
|
|
35
42
|
icon?: IconData | undefined;
|
|
@@ -41,11 +48,20 @@ export interface ButtonProps extends Omit<ButtonBaseProps, "children" | "classNa
|
|
|
41
48
|
fullWidth?: boolean;
|
|
42
49
|
/**
|
|
43
50
|
* A link that looks like a button (it navigates: a real `<a>`, so it opens in a new tab, can be copied, and so on).
|
|
44
|
-
* Only safe URLs are linked. The forwarded ref is not attached to a link.
|
|
51
|
+
* Only safe URLs are linked. The forwarded ref is not attached to a link (use `linkRef`). A link takes `target`,
|
|
52
|
+
* `id`, `aria-label`, `aria-current`, `className`, `style`, `data-testid` and `onClick`; the other button
|
|
53
|
+
* attributes do not apply to it.
|
|
45
54
|
*/
|
|
46
55
|
href?: string | undefined;
|
|
47
56
|
/** With `href`: where it opens, e.g. `_blank`. */
|
|
48
57
|
target?: string | undefined;
|
|
58
|
+
/** With `href`: receives the link element (the forwarded ref is for the button element). */
|
|
59
|
+
linkRef?: Ref<HTMLAnchorElement> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Square: as wide as it is tall, with no padding, for one icon as the content. Prefer IconButton, which sets it and
|
|
62
|
+
* adds the required label and its tooltip. Default false.
|
|
63
|
+
*/
|
|
64
|
+
square?: boolean;
|
|
49
65
|
/**
|
|
50
66
|
* Ask before acting, in place: the first press arms the button and shows this text ("Press again to delete"), a
|
|
51
67
|
* second press within 4 seconds acts. Escape, leaving the button or the time running out disarms it.
|
|
@@ -56,10 +72,19 @@ export interface ButtonProps extends Omit<ButtonBaseProps, "children" | "classNa
|
|
|
56
72
|
* users still reach it with Tab.
|
|
57
73
|
*/
|
|
58
74
|
keepFocus?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Marks the button or link as the current item of a set: `"page"` for the page being shown (a link to it in a
|
|
77
|
+
* navigation bar or in Pagination), or `"step"`, `"location"`, `"date"`, `"time"` or `true`. Set on the button or
|
|
78
|
+
* link element. Default: not set.
|
|
79
|
+
*/
|
|
80
|
+
"aria-current"?: AriaAttributes["aria-current"];
|
|
81
|
+
/** Added to the button (or link) element, for layout. */
|
|
59
82
|
className?: string;
|
|
60
83
|
/** Layout only. Restyle through `--cy-button-*` tokens. */
|
|
61
84
|
style?: CSSProperties;
|
|
85
|
+
/** The button's label. */
|
|
62
86
|
children: ReactNode;
|
|
87
|
+
/** Set on the button (or link) element, to find it in tests. */
|
|
63
88
|
"data-testid"?: string;
|
|
64
89
|
}
|
|
65
90
|
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,77 +1,86 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ButtonBase as
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { LinkBase as
|
|
5
|
-
import { LoadingDots as
|
|
6
|
-
import { forwardRef as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
var
|
|
9
|
-
const
|
|
10
|
-
clearTimeout(
|
|
2
|
+
import { ButtonBase as q } from "../../foundations/ButtonBase/ButtonBase.js";
|
|
3
|
+
import { Icon as g } from "../../foundations/Icon/Icon.js";
|
|
4
|
+
import { LinkBase as A } from "../../foundations/LinkBase/LinkBase.js";
|
|
5
|
+
import { LoadingDots as E } from "../LoadingDots/LoadingDots.js";
|
|
6
|
+
import { forwardRef as F, useEffect as I, useRef as K, useState as P } from "react";
|
|
7
|
+
import { Fragment as _, jsx as a, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
var V = F(function({ variant: w = "outline", tone: T = "neutral", color: n, size: u = "md", icon: l, iconEnd: c, loading: r = !1, fullWidth: x, href: f, target: z, linkRef: N, square: $ = !1, confirm: m, keepFocus: p = !1, className: v, children: j, onClick: y, onKeyDown: L, onBlur: M, onPointerDown: R, ...e }, S) {
|
|
9
|
+
const b = u === "lg" ? "lg" : "md", [o, s] = P(!1), i = K(void 0), d = () => {
|
|
10
|
+
clearTimeout(i.current), s(!1);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
if (m !== void 0 && !
|
|
16
|
-
|
|
12
|
+
I(() => () => clearTimeout(i.current), []);
|
|
13
|
+
const k = (t) => {
|
|
14
|
+
if (r) return t.preventDefault();
|
|
15
|
+
if (m !== void 0 && !o) {
|
|
16
|
+
s(!0), clearTimeout(i.current), i.current = setTimeout(() => s(!1), 4e3);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
className: `cy-button cy-motion-trigger${
|
|
22
|
-
"data-variant":
|
|
23
|
-
"data-tone":
|
|
19
|
+
d(), y?.(t);
|
|
20
|
+
}, D = {
|
|
21
|
+
className: `cy-button cy-motion-trigger${v ? ` ${v}` : ""}`,
|
|
22
|
+
"data-variant": w,
|
|
23
|
+
"data-tone": n ? void 0 : T,
|
|
24
|
+
"data-color": n ? "" : void 0,
|
|
24
25
|
"data-size": u,
|
|
25
|
-
"data-full":
|
|
26
|
-
"data-
|
|
27
|
-
"data-
|
|
28
|
-
|
|
26
|
+
"data-full": x ? "" : void 0,
|
|
27
|
+
"data-square": $ ? "" : void 0,
|
|
28
|
+
"data-loading": r ? "" : void 0,
|
|
29
|
+
"data-armed": o ? "" : void 0,
|
|
30
|
+
style: n ? {
|
|
31
|
+
"--_tone": n,
|
|
32
|
+
...e.style
|
|
33
|
+
} : e.style
|
|
34
|
+
}, B = /* @__PURE__ */ h(_, { children: [/* @__PURE__ */ h("span", {
|
|
29
35
|
className: "cy-reset cy-button-content",
|
|
30
36
|
children: [
|
|
31
|
-
|
|
32
|
-
icon:
|
|
33
|
-
size:
|
|
37
|
+
l && /* @__PURE__ */ a(g, {
|
|
38
|
+
icon: l,
|
|
39
|
+
size: b
|
|
34
40
|
}),
|
|
35
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ a("span", {
|
|
36
42
|
className: "cy-reset cy-button-label",
|
|
37
|
-
children:
|
|
43
|
+
children: o ? m : j
|
|
38
44
|
}),
|
|
39
|
-
|
|
40
|
-
icon:
|
|
41
|
-
size:
|
|
45
|
+
c && /* @__PURE__ */ a(g, {
|
|
46
|
+
icon: c,
|
|
47
|
+
size: b
|
|
42
48
|
})
|
|
43
49
|
]
|
|
44
|
-
}),
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
}), r && /* @__PURE__ */ a(E, { className: "cy-button-loading" })] });
|
|
51
|
+
return f !== void 0 ? /* @__PURE__ */ a(A, {
|
|
52
|
+
ref: N,
|
|
53
|
+
href: f,
|
|
54
|
+
target: z,
|
|
55
|
+
...D,
|
|
56
|
+
id: e.id,
|
|
57
|
+
"data-testid": e["data-testid"],
|
|
58
|
+
"aria-label": e["aria-label"],
|
|
59
|
+
"aria-current": e["aria-current"],
|
|
60
|
+
onClick: y,
|
|
61
|
+
children: B
|
|
62
|
+
}) : /* @__PURE__ */ a(q, {
|
|
63
|
+
ref: S,
|
|
64
|
+
...e,
|
|
65
|
+
...D,
|
|
66
|
+
"aria-busy": r || void 0,
|
|
67
|
+
"aria-disabled": r || void 0,
|
|
68
|
+
onClick: k,
|
|
69
|
+
onMouseDown: p ? (t) => t.preventDefault() : e.onMouseDown,
|
|
61
70
|
onPointerDown: (t) => {
|
|
62
|
-
|
|
71
|
+
p && t.preventDefault(), R?.(t);
|
|
63
72
|
},
|
|
64
73
|
onKeyDown: (t) => {
|
|
65
|
-
|
|
74
|
+
o && t.key === "Escape" && (t.preventDefault(), d()), L?.(t);
|
|
66
75
|
},
|
|
67
76
|
onBlur: (t) => {
|
|
68
|
-
|
|
77
|
+
o && d(), M?.(t);
|
|
69
78
|
},
|
|
70
|
-
children:
|
|
79
|
+
children: B
|
|
71
80
|
});
|
|
72
81
|
});
|
|
73
82
|
export {
|
|
74
|
-
|
|
83
|
+
V as Button
|
|
75
84
|
};
|
|
76
85
|
|
|
77
86
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["_Fragment","ButtonBase","Icon","LinkBase","LoadingDots","forwardRef","useEffect","useRef","useState","Fragment$1","jsx","jsxs","Button","variant","tone","size","icon","iconEnd","loading","fullWidth","href","target","confirm","keepFocus","className","children","onClick","onKeyDown","onBlur","onPointerDown","rest","ref","iconSize","armed","setArmed","timer","disarm","press","event","shared","content"],"sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import {\n type CSSProperties,\n forwardRef,\n type MouseEvent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ButtonBase, type ButtonBaseProps } from \"../../foundations/ButtonBase/ButtonBase.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { LinkBase } from \"../../foundations/LinkBase/LinkBase.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\nimport { LoadingDots } from \"../LoadingDots/LoadingDots.js\";\n\nexport interface ButtonTokens {\n heightSm: string;\n heightMd: string;\n heightLg: string;\n radius: string;\n paddingInline: string;\n gap: string;\n fontWeight: string;\n maxWidth: string;\n /** Inset highlight + drop shadow on solid buttons. */\n solidShadow: string;\n /** Tint strength of soft buttons (percentage of the tone mixed into the surface). */\n softMix: string;\n /** Border strength of outline buttons (percentage of the tone mixed into the line colour). */\n outlineMix: string;\n pressScale: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n button: ButtonTokens;\n }\n}\n\nexport type ButtonVariant = \"solid\" | \"soft\" | \"outline\" | \"ghost\";\n\nexport interface ButtonProps extends Omit<ButtonBaseProps, \"children\" | \"className\" | \"style\" | \"color\"> {\n /** Fill style. */\n variant?: ButtonVariant;\n /** Semantic colour. */\n tone?: Tone;\n size?: Size;\n /** Leading icon (inline-start, RTL aware). */\n icon?: IconData | undefined;\n /** Trailing icon (inline-end). */\n iconEnd?: IconData | undefined;\n /** Shows LoadingDots, sets aria-busy and ignores activation while keeping the button's width. */\n loading?: boolean;\n /** Stretch to the container's width. */\n fullWidth?: boolean;\n /**\n * A link that looks like a button (it navigates: a real `<a>`, so it opens in a new tab, can be copied, and so on).\n * Only safe URLs are linked. The forwarded ref is not attached to a link.\n */\n href?: string | undefined;\n /** With `href`: where it opens, e.g. `_blank`. */\n target?: string | undefined;\n /**\n * Ask before acting, in place: the first press arms the button and shows this text (\"Press again to delete\"), a\n * second press within 4 seconds acts. Escape, leaving the button or the time running out disarms it.\n */\n confirm?: ReactNode;\n /**\n * A pointer press leaves focus where it was (an on-screen keypad beside a field keeps the field's caret). Keyboard\n * users still reach it with Tab.\n */\n keepFocus?: boolean;\n className?: string;\n /** Layout only. Restyle through `--cy-button-*` tokens. */\n style?: CSSProperties;\n children: ReactNode;\n \"data-testid\"?: string;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"outline\",\n tone = \"neutral\",\n size = \"md\",\n icon,\n iconEnd,\n loading = false,\n fullWidth,\n href,\n target,\n confirm,\n keepFocus = false,\n className,\n children,\n onClick,\n onKeyDown,\n onBlur,\n onPointerDown,\n ...rest\n },\n ref,\n) {\n const iconSize = size === \"lg\" ? \"lg\" : \"md\";\n const [armed, setArmed] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const disarm = () => {\n clearTimeout(timer.current);\n setArmed(false);\n };\n useEffect(() => () => clearTimeout(timer.current), []);\n const press = (event: MouseEvent<HTMLButtonElement>) => {\n if (loading) return event.preventDefault();\n if (confirm !== undefined && !armed) {\n setArmed(true);\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setArmed(false), 4000);\n return;\n }\n disarm();\n onClick?.(event);\n };\n const shared = {\n className: `cy-button cy-motion-trigger${className ? ` ${className}` : \"\"}`,\n \"data-variant\": variant,\n \"data-tone\": tone,\n \"data-size\": size,\n \"data-full\": fullWidth ? \"\" : undefined,\n \"data-loading\": loading ? \"\" : undefined,\n \"data-armed\": armed ? \"\" : undefined,\n };\n const content = (\n <>\n <span className=\"cy-reset cy-button-content\">\n {icon && <Icon icon={icon} size={iconSize} />}\n <span className=\"cy-reset cy-button-label\">{armed ? confirm : children}</span>\n {iconEnd && <Icon icon={iconEnd} size={iconSize} />}\n </span>\n {loading && <LoadingDots className=\"cy-button-loading\" />}\n </>\n );\n if (href !== undefined)\n return (\n <LinkBase\n href={href}\n target={target}\n {...shared}\n data-testid={rest[\"data-testid\"]}\n aria-label={rest[\"aria-label\"]}\n onClick={onClick as unknown as (e: MouseEvent<HTMLAnchorElement>) => void}\n >\n {content}\n </LinkBase>\n );\n return (\n <ButtonBase\n ref={ref}\n {...rest}\n {...shared}\n aria-busy={loading || undefined}\n aria-disabled={loading || undefined}\n onClick={press}\n onMouseDown={keepFocus ? (event) => event.preventDefault() : rest.onMouseDown}\n onPointerDown={(event) => {\n // Pressing without taking focus: the field beside it keeps its caret.\n if (keepFocus) event.preventDefault();\n onPointerDown?.(event);\n }}\n onKeyDown={(event) => {\n if (armed && event.key === \"Escape\") {\n event.preventDefault();\n disarm();\n }\n onKeyDown?.(event);\n }}\n onBlur={(event) => {\n if (armed) disarm();\n onBlur?.(event);\n }}\n >\n {content}\n </ButtonBase>\n );\n});\n"],"mappings":";;;;;;;AAgFA,IAAaY,IAASP,EAA2C,SAC/D,EACE,SAAAQ,IAAU,WACV,MAAAC,IAAO,WACP,MAAAC,IAAO,MACP,MAAAC,GACA,SAAAC,GACA,SAAAC,IAAU,IACV,WAAAC,GACA,MAAAC,GACA,QAAAC,GACA,SAAAC,GACA,WAAAC,IAAY,IACZ,WAAAC,GACA,UAAAC,GACA,SAAAC,GACA,WAAAC,GACA,QAAAC,GACA,eAAAC,GACA,GAAGC,EAAA,GAELC,GACA;AACA,QAAMC,IAAWjB,MAAS,OAAO,OAAO,MAClC,CAACkB,GAAOC,CAAA,IAAY1B,EAAS,EAAK,GAClC2B,IAAQ5B,EAAkD,MAAS,GACnE6B,IAAA,MAAe;AACnB,iBAAaD,EAAM,OAAO,GAC1BD,EAAS,EAAK;AAAA,EAChB;AACA,EAAA5B,EAAA,MAAA,MAAsB,aAAa6B,EAAM,OAAO,GAAG,CAAC,CAAC;AACrD,QAAME,IAAA,CAASC,MAAyC;AACtD,QAAIpB,EAAS,QAAOoB,EAAM,eAAe;AACzC,QAAIhB,MAAY,UAAa,CAACW,GAAO;AACnC,MAAAC,EAAS,EAAI,GACb,aAAaC,EAAM,OAAO,GAC1BA,EAAM,UAAU,WAAA,MAAiBD,EAAS,EAAK,GAAG,GAAI;AACtD;AAAA,IACF;AACA,IAAAE,EAAO,GACPV,IAAUY,CAAK;AAAA,EACjB,GACMC,IAAS;AAAA,IACb,WAAW,8BAA8Bf,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACvE,gBAAgBX;AAAA,IAChB,aAAaC;AAAA,IACb,aAAaC;AAAA,IACb,aAAaI,IAAY,KAAK;AAAA,IAC9B,gBAAgBD,IAAU,KAAK;AAAA,IAC/B,cAAce,IAAQ,KAAK;AAAA,EAC7B,GACMO,IACJ,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ClBR,IAASU,CAAK;AAAA,IAChB;AAAA,IAEC,UAAAE;AAAA,EACS,CAAA;AAEhB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Button.js","names":["_Fragment","ButtonBase","Icon","LinkBase","LoadingDots","forwardRef","useEffect","useRef","useState","Fragment$1","jsx","jsxs","Button","variant","tone","color","size","icon","iconEnd","loading","fullWidth","href","target","linkRef","square","confirm","keepFocus","className","children","onClick","onKeyDown","onBlur","onPointerDown","rest","ref","iconSize","armed","setArmed","timer","disarm","press","event","shared","content"],"sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import {\n type AriaAttributes,\n type CSSProperties,\n forwardRef,\n type MouseEvent,\n type ReactNode,\n type Ref,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ButtonBase, type ButtonBaseProps } from \"../../foundations/ButtonBase/ButtonBase.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { LinkBase } from \"../../foundations/LinkBase/LinkBase.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\nimport { LoadingDots } from \"../LoadingDots/LoadingDots.js\";\n\nexport interface ButtonTokens {\n heightSm: string;\n heightMd: string;\n heightLg: string;\n radius: string;\n paddingInline: string;\n gap: string;\n fontWeight: string;\n maxWidth: string;\n /** Inset highlight + drop shadow on solid buttons. */\n solidShadow: string;\n /** Tint strength of soft buttons (percentage of the tone mixed into the surface). */\n softMix: string;\n /** Border strength of outline buttons (percentage of the tone mixed into the line colour). */\n outlineMix: string;\n pressScale: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n button: ButtonTokens;\n }\n}\n\nexport type ButtonVariant = \"solid\" | \"soft\" | \"outline\" | \"ghost\";\n\nexport interface ButtonProps extends Omit<ButtonBaseProps, \"children\" | \"className\" | \"style\" | \"color\"> {\n /** Fill style. */\n variant?: ButtonVariant;\n /** Semantic colour. */\n tone?: Tone;\n /**\n * A one-off colour (any CSS colour), for a brand button such as \"Get it on Google Play\". Overrides `tone`. The text\n * on a solid fill is white or black, whichever reads; on the other variants the colour is darkened or lightened\n * until it reads on the surface. Prefer a tone or the theme's accent.\n */\n color?: string | undefined;\n /** Height and text size of the button. Default \"md\". */\n size?: Size;\n /** Leading icon (inline-start, RTL aware). */\n icon?: IconData | undefined;\n /** Trailing icon (inline-end). */\n iconEnd?: IconData | undefined;\n /** Shows LoadingDots, sets aria-busy and ignores activation while keeping the button's width. */\n loading?: boolean;\n /** Stretch to the container's width. */\n fullWidth?: boolean;\n /**\n * A link that looks like a button (it navigates: a real `<a>`, so it opens in a new tab, can be copied, and so on).\n * Only safe URLs are linked. The forwarded ref is not attached to a link (use `linkRef`). A link takes `target`,\n * `id`, `aria-label`, `aria-current`, `className`, `style`, `data-testid` and `onClick`; the other button\n * attributes do not apply to it.\n */\n href?: string | undefined;\n /** With `href`: where it opens, e.g. `_blank`. */\n target?: string | undefined;\n /** With `href`: receives the link element (the forwarded ref is for the button element). */\n linkRef?: Ref<HTMLAnchorElement> | undefined;\n /**\n * Square: as wide as it is tall, with no padding, for one icon as the content. Prefer IconButton, which sets it and\n * adds the required label and its tooltip. Default false.\n */\n square?: boolean;\n /**\n * Ask before acting, in place: the first press arms the button and shows this text (\"Press again to delete\"), a\n * second press within 4 seconds acts. Escape, leaving the button or the time running out disarms it.\n */\n confirm?: ReactNode;\n /**\n * A pointer press leaves focus where it was (an on-screen keypad beside a field keeps the field's caret). Keyboard\n * users still reach it with Tab.\n */\n keepFocus?: boolean;\n /**\n * Marks the button or link as the current item of a set: `\"page\"` for the page being shown (a link to it in a\n * navigation bar or in Pagination), or `\"step\"`, `\"location\"`, `\"date\"`, `\"time\"` or `true`. Set on the button or\n * link element. Default: not set.\n */\n \"aria-current\"?: AriaAttributes[\"aria-current\"];\n /** Added to the button (or link) element, for layout. */\n className?: string;\n /** Layout only. Restyle through `--cy-button-*` tokens. */\n style?: CSSProperties;\n /** The button's label. */\n children: ReactNode;\n /** Set on the button (or link) element, to find it in tests. */\n \"data-testid\"?: string;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"outline\",\n tone = \"neutral\",\n color,\n size = \"md\",\n icon,\n iconEnd,\n loading = false,\n fullWidth,\n href,\n target,\n linkRef,\n square = false,\n confirm,\n keepFocus = false,\n className,\n children,\n onClick,\n onKeyDown,\n onBlur,\n onPointerDown,\n ...rest\n },\n ref,\n) {\n const iconSize = size === \"lg\" ? \"lg\" : \"md\";\n const [armed, setArmed] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const disarm = () => {\n clearTimeout(timer.current);\n setArmed(false);\n };\n useEffect(() => () => clearTimeout(timer.current), []);\n const press = (event: MouseEvent<HTMLButtonElement>) => {\n if (loading) return event.preventDefault();\n if (confirm !== undefined && !armed) {\n setArmed(true);\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setArmed(false), 4000);\n return;\n }\n disarm();\n onClick?.(event);\n };\n const shared = {\n className: `cy-button cy-motion-trigger${className ? ` ${className}` : \"\"}`,\n \"data-variant\": variant,\n \"data-tone\": color ? undefined : tone,\n \"data-color\": color ? \"\" : undefined,\n \"data-size\": size,\n \"data-full\": fullWidth ? \"\" : undefined,\n \"data-square\": square ? \"\" : undefined,\n \"data-loading\": loading ? \"\" : undefined,\n \"data-armed\": armed ? \"\" : undefined,\n style: color ? ({ \"--_tone\": color, ...rest.style } as CSSProperties) : rest.style,\n };\n const content = (\n <>\n <span className=\"cy-reset cy-button-content\">\n {icon && <Icon icon={icon} size={iconSize} />}\n <span className=\"cy-reset cy-button-label\">{armed ? confirm : children}</span>\n {iconEnd && <Icon icon={iconEnd} size={iconSize} />}\n </span>\n {loading && <LoadingDots className=\"cy-button-loading\" />}\n </>\n );\n if (href !== undefined)\n return (\n <LinkBase\n ref={linkRef}\n href={href}\n target={target}\n {...shared}\n id={rest.id}\n data-testid={rest[\"data-testid\"]}\n aria-label={rest[\"aria-label\"]}\n aria-current={rest[\"aria-current\"]}\n onClick={onClick as unknown as (e: MouseEvent<HTMLAnchorElement>) => void}\n >\n {content}\n </LinkBase>\n );\n return (\n <ButtonBase\n ref={ref}\n {...rest}\n {...shared}\n aria-busy={loading || undefined}\n aria-disabled={loading || undefined}\n onClick={press}\n onMouseDown={keepFocus ? (event) => event.preventDefault() : rest.onMouseDown}\n onPointerDown={(event) => {\n // Pressing without taking focus: the field beside it keeps its caret.\n if (keepFocus) event.preventDefault();\n onPointerDown?.(event);\n }}\n onKeyDown={(event) => {\n if (armed && event.key === \"Escape\") {\n event.preventDefault();\n disarm();\n }\n onKeyDown?.(event);\n }}\n onBlur={(event) => {\n if (armed) disarm();\n onBlur?.(event);\n }}\n >\n {content}\n </ButtonBase>\n );\n});\n"],"mappings":";;;;;;;AA2GA,IAAaY,IAASP,EAA2C,SAC/D,EACE,SAAAQ,IAAU,WACV,MAAAC,IAAO,WACP,OAAAC,GACA,MAAAC,IAAO,MACP,MAAAC,GACA,SAAAC,GACA,SAAAC,IAAU,IACV,WAAAC,GACA,MAAAC,GACA,QAAAC,GACA,SAAAC,GACA,QAAAC,IAAS,IACT,SAAAC,GACA,WAAAC,IAAY,IACZ,WAAAC,GACA,UAAAC,GACA,SAAAC,GACA,WAAAC,GACA,QAAAC,GACA,eAAAC,GACA,GAAGC,EAAA,GAELC,GACA;AACA,QAAMC,IAAWnB,MAAS,OAAO,OAAO,MAClC,CAACoB,GAAOC,CAAA,IAAY7B,EAAS,EAAK,GAClC8B,IAAQ/B,EAAkD,MAAS,GACnEgC,IAAA,MAAe;AACnB,iBAAaD,EAAM,OAAO,GAC1BD,EAAS,EAAK;AAAA,EAChB;AACA,EAAA/B,EAAA,MAAA,MAAsB,aAAagC,EAAM,OAAO,GAAG,CAAC,CAAC;AACrD,QAAME,IAAA,CAASC,MAAyC;AACtD,QAAItB,EAAS,QAAOsB,EAAM,eAAe;AACzC,QAAIhB,MAAY,UAAa,CAACW,GAAO;AACnC,MAAAC,EAAS,EAAI,G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