@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":"PanZoomCanvas.js","names":["_Fragment","useControllableState","useClientLayoutEffect","clamp","useDrag","clampPercent","useZoomGestures","forwardRef","useImperativeHandle","useRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","percent","MIN","MAX","STEP","PanZoomCanvas","label","view","defaultView","onViewChange","bounds","minimap","renderMinimap","renderScreen","children","labels","className","style","ref","text","surface","current","setView","latest","size","setSize","el","measure","s","observer","go","next","zoomAround","scale","at","v","centre","fit","rect","pad","centreOn","p","fitted","gestures","dx","dy","onKeyDown","event","by","move","said","setSaid","map","mapWidth","setMapWidth","w","k","seen","lookAt","mx","my","point","r"],"sources":["../../../src/components/PanZoomCanvas/PanZoomCanvas.tsx"],"sourcesContent":["import {\n type CSSProperties,\n forwardRef,\n type KeyboardEvent,\n type ReactNode,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { clamp } from \"../../foundations/math.js\";\nimport { clampPercent, MAX_PERCENT, MIN_PERCENT } from \"../../foundations/zoom.js\";\nimport { useZoomGestures, type ZoomAnchor } from \"../../foundations/zoom-gestures.js\";\n\nexport interface PanZoomCanvasTokens {\n /** Behind the content. */\n background: string;\n /** Width of the minimap. */\n minimapWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n panZoomCanvas: PanZoomCanvasTokens;\n }\n}\n\n/** Where the canvas is: a point at canvas (x, y) shows at screen (x times scale plus view.x, y times scale plus view.y). */\nexport interface CanvasView {\n x: number;\n y: number;\n /** 1 = 100%; kept between 25% and 800%. */\n scale: number;\n}\n\nexport interface CanvasRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface PanZoomCanvasHandle {\n /** Fits `bounds` (or a given rect) in view. */\n fit: (rect?: CanvasRect) => void;\n /** Zooms to a percent around the viewport's centre. */\n zoomTo: (percent: number) => void;\n /** Centres a rect (a node) without changing the zoom. */\n centreOn: (rect: CanvasRect) => void;\n}\n\n/** What `renderScreen` draws from: the current view and the canvas's size in CSS pixels. */\nexport interface CanvasScreen {\n view: CanvasView;\n width: number;\n height: number;\n}\n\nexport interface PanZoomCanvasLabels {\n /** Announced when the zoom changes. Default \"Zoom 125%\". */\n zoom: (percent: number) => string;\n}\n\nexport interface PanZoomCanvasProps {\n /** Names the canvas (\"Schema diagram\"). */\n label: string;\n view?: CanvasView | undefined;\n /** Where it starts. Default: `bounds` fitted in view (or the origin at 100% without bounds). */\n defaultView?: CanvasView;\n onViewChange?: ((view: CanvasView) => void) | undefined;\n /** The content's extent in canvas units, for fitting and the minimap. */\n bounds?: CanvasRect | undefined;\n /** Show a minimap of `bounds` with the view on it (drag it, or press where to look). */\n minimap?: boolean;\n /** A small drawing of the content for the minimap, in canvas units (it is scaled down). */\n renderMinimap?: () => ReactNode;\n /**\n * A layer in screen pixels under the content, redrawn with every view change: for an engine that paints the whole\n * scene into a `<canvas>` (a canvas point (x, y) is at (x * scale + view.x, y * scale + view.y)). It does not take\n * the pointer, so pressing it pans like the background.\n */\n renderScreen?: (screen: CanvasScreen) => ReactNode;\n /** The content, placed in canvas units (absolutely positioned children). */\n children?: ReactNode;\n labels?: Partial<PanZoomCanvasLabels>;\n className?: string;\n /** Layout only (give it a height). Restyle through --cy-pan-zoom-canvas-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: PanZoomCanvasLabels = { zoom: (percent) => `Zoom ${percent}%` };\nconst MIN = MIN_PERCENT / 100;\nconst MAX = MAX_PERCENT / 100;\n/** Pixels an arrow key pans (Shift: five times as far). */\nconst STEP = 40;\n\n/**\n * A surface to pan and zoom freely in both directions, for diagrams, maps and boards: products place their content in\n * canvas units and keep their own layout and drawing. Drag the empty background (or hold Space and drag) to pan, the\n * wheel pans, Ctrl/Cmd+wheel and a pinch zoom around the pointer, one finger pans on touch; arrow keys pan, Ctrl/Cmd\n * and = - 0 zoom, Shift+1 fits. On the same zoom core as DocumentViewport.\n */\nexport const PanZoomCanvas = forwardRef<PanZoomCanvasHandle, PanZoomCanvasProps>(function PanZoomCanvas(\n {\n label,\n view,\n defaultView,\n onViewChange,\n bounds,\n minimap = false,\n renderMinimap,\n renderScreen,\n children,\n labels,\n className,\n style,\n },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const surface = useRef<HTMLElement>(null);\n const [current, setView] = useControllableState(\n view,\n defaultView ?? { x: 0, y: 0, scale: 1 },\n onViewChange,\n );\n const latest = useRef(current);\n latest.current = current;\n const [size, setSize] = useState({ width: 0, height: 0 });\n useClientLayoutEffect(() => {\n const el = surface.current as HTMLElement;\n const measure = () =>\n setSize((s) =>\n s.width === el.clientWidth && s.height === el.clientHeight\n ? s\n : { width: el.clientWidth, height: el.clientHeight },\n );\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n\n const go = (next: CanvasView) => {\n latest.current = next;\n setView(next);\n };\n const zoomAround = (scale: number, at: { x: number; y: number }) => {\n const v = latest.current;\n const s = clamp(scale, MIN, MAX);\n go({ x: at.x - ((at.x - v.x) * s) / v.scale, y: at.y - ((at.y - v.y) * s) / v.scale, scale: s });\n };\n const centre = () => ({ x: size.width / 2, y: size.height / 2 });\n const fit = (rect = bounds) => {\n if (!rect || !size.width || !size.height) return;\n const pad = Math.min(size.width, size.height) * 0.05;\n const s = clamp(\n Math.min((size.width - 2 * pad) / rect.width, (size.height - 2 * pad) / rect.height),\n MIN,\n MAX,\n );\n go({\n x: (size.width - rect.width * s) / 2 - rect.x * s,\n y: (size.height - rect.height * s) / 2 - rect.y * s,\n scale: s,\n });\n };\n const centreOn = (rect: CanvasRect) => {\n const { scale } = latest.current;\n go({\n x: size.width / 2 - (rect.x + rect.width / 2) * scale,\n y: size.height / 2 - (rect.y + rect.height / 2) * scale,\n scale,\n });\n };\n useImperativeHandle(ref, () => ({\n fit,\n zoomTo: (p) => zoomAround(clampPercent(p) / 100, centre()),\n centreOn,\n }));\n\n // Without a starting view, fit the content once the canvas has a size.\n const fitted = useRef(view !== undefined || defaultView !== undefined);\n useClientLayoutEffect(() => {\n if (fitted.current || !size.width) return;\n fitted.current = true;\n fit();\n });\n\n const percent = Math.round(current.scale * 100);\n const gestures = useZoomGestures(surface, {\n percent,\n onZoom: (p, at: ZoomAnchor) => zoomAround(p / 100, at ?? centre()),\n onPan: (dx, dy) => go({ ...latest.current, x: latest.current.x + dx, y: latest.current.y + dy }),\n });\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n gestures.onKeyDown(event);\n if (event.defaultPrevented || event.target !== event.currentTarget) return;\n if (event.key === \"!\" || (event.shiftKey && event.key === \"1\")) {\n event.preventDefault();\n fit();\n return;\n }\n const by = event.shiftKey ? STEP * 5 : STEP;\n const moves: Record<string, [number, number]> = {\n ArrowLeft: [by, 0],\n ArrowRight: [-by, 0],\n ArrowUp: [0, by],\n ArrowDown: [0, -by],\n };\n const move = moves[event.key];\n if (!move) return;\n event.preventDefault();\n go({ ...current, x: current.x + move[0], y: current.y + move[1] });\n };\n\n // Zoom changes are announced; the first value is not.\n const [said, setSaid] = useState({ percent, text: \"\" });\n if (said.percent !== percent) setSaid({ percent, text: text.zoom(percent) });\n\n // The minimap: `bounds` scaled to its width, with the view drawn on it. Dragging it (or pressing) moves the view.\n const map = useRef<HTMLDivElement>(null);\n // Measured into state (not a ref), so the view box is redrawn once the minimap's real width is known.\n const [mapWidth, setMapWidth] = useState(160);\n useClientLayoutEffect(() => {\n const w = map.current?.clientWidth;\n if (w && w !== mapWidth) setMapWidth(w);\n });\n const k = bounds ? mapWidth / bounds.width : 1;\n const seen = {\n x: (-current.x / current.scale - (bounds?.x ?? 0)) * k,\n y: (-current.y / current.scale - (bounds?.y ?? 0)) * k,\n width: (size.width / current.scale) * k,\n height: (size.height / current.scale) * k,\n };\n /** Centres the view on a point of the minimap (its own pixels). */\n const lookAt = (mx: number, my: number) => {\n if (!bounds) return;\n const { scale } = latest.current;\n go({\n x: size.width / 2 - (bounds.x + mx / k) * scale,\n y: size.height / 2 - (bounds.y + my / k) * scale,\n scale,\n });\n };\n useDrag(map, {\n onStart: ({ point }) => {\n const r = (map.current as HTMLDivElement).getBoundingClientRect();\n lookAt(point.x - r.left, point.y - r.top);\n },\n onMove: ({ point }) => {\n const r = (map.current as HTMLDivElement).getBoundingClientRect();\n lookAt(point.x - r.left, point.y - r.top);\n },\n });\n\n return (\n <>\n <section\n ref={surface}\n aria-label={label}\n // biome-ignore lint/a11y/noNoninteractiveTabindex: arrows pan and Ctrl/Cmd keys zoom the canvas\n tabIndex={0}\n className={className ? `cy-pan-zoom-canvas ${className}` : \"cy-pan-zoom-canvas\"}\n data-panning={gestures.panning ? \"\" : undefined}\n style={style}\n onKeyDown={onKeyDown}\n onKeyUp={gestures.onKeyUp}\n onBlur={gestures.onBlur}\n >\n {renderScreen && size.width > 0 && (\n <div className=\"cy-pan-zoom-canvas-screen cy-reset\">\n {renderScreen({ view: current, width: size.width, height: size.height })}\n </div>\n )}\n <div\n className=\"cy-pan-zoom-canvas-content cy-reset\"\n style={{ transform: `translate(${current.x}px, ${current.y}px) scale(${current.scale})` }}\n >\n {children}\n </div>\n {minimap && bounds && (\n <div\n ref={map}\n className=\"cy-pan-zoom-canvas-minimap cy-reset\"\n style={{ blockSize: bounds.height * k }}\n aria-hidden=\"true\"\n >\n {renderMinimap && (\n <div\n className=\"cy-pan-zoom-canvas-minimap-content cy-reset\"\n style={{ transform: `scale(${k}) translate(${-bounds.x}px, ${-bounds.y}px)` }}\n >\n {renderMinimap()}\n </div>\n )}\n <div\n className=\"cy-pan-zoom-canvas-minimap-view cy-reset\"\n style={{\n insetInlineStart: seen.x,\n insetBlockStart: seen.y,\n inlineSize: seen.width,\n blockSize: seen.height,\n }}\n />\n </div>\n )}\n </section>\n <span className=\"cy-visually-hidden\" role=\"status\">\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5C,KACC,gBAAAd,EAAC,OAAD;AAAA,UACE,WAAU;AAAA,UACV,OAAO,EAAE,WAAW,SAAS0D,CAAA,eAAgB,CAAC9C,EAAO,CAAA,OAAQ,CAACA,EAAO,CAAA,MAAO;AAAA,UAE3E,UAAAE,EAAc;AAAA,QACZ,CAAA,GAEP,gBAAAd,EAAC,OAAD;AAAA,UACE,WAAU;AAAA,UACV,OAAO;AAAA,YACL,kBAAkB2D,EAAK;AAAA,YACvB,iBAAiBA,EAAK;AAAA,YACtB,YAAYA,EAAK;AAAA,YACjB,WAAWA,EAAK;AAAA,UAClB;AAAA,QACD,CAAA,CACE;AAAA,M;A,IAEA;AAAA,EACT,CAAA,GAAA,gBAAA3D,EAAC,QAAD;AAAA,IAAM,WAAU;AAAA,IAAqB,MAAK;AAAA,IACvC,UAAAoD,EAAK;AAAA,EACF,CAAA,CACN,EAAA,CAAA;AAEN,CAAC"}
|
|
1
|
+
{"version":3,"file":"PanZoomCanvas.js","names":["_Fragment","useControllableState","useClientLayoutEffect","clamp","useDrag","clampPercent","useZoomGestures","forwardRef","useImperativeHandle","useRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","percent","MIN","MAX","STEP","PanZoomCanvas","label","view","defaultView","onViewChange","bounds","minimap","renderMinimap","renderScreen","children","labels","className","style","ref","text","surface","current","setView","latest","size","setSize","el","measure","s","observer","go","next","zoomAround","scale","at","v","centre","fit","rect","pad","centreOn","p","fitted","gestures","dx","dy","onKeyDown","event","by","move","said","setSaid","map","mapWidth","setMapWidth","w","k","seen","lookAt","mx","my","point","r"],"sources":["../../../src/components/PanZoomCanvas/PanZoomCanvas.tsx"],"sourcesContent":["import {\n type CSSProperties,\n forwardRef,\n type KeyboardEvent,\n type ReactNode,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { clamp } from \"../../foundations/math.js\";\nimport { clampPercent, MAX_PERCENT, MIN_PERCENT } from \"../../foundations/zoom.js\";\nimport { useZoomGestures, type ZoomAnchor } from \"../../foundations/zoom-gestures.js\";\n\nexport interface PanZoomCanvasTokens {\n /** Behind the content. */\n background: string;\n /** Width of the minimap. */\n minimapWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n panZoomCanvas: PanZoomCanvasTokens;\n }\n}\n\n/** Where the canvas is: a point at canvas (x, y) shows at screen (x times scale plus view.x, y times scale plus view.y). */\nexport interface CanvasView {\n x: number;\n y: number;\n /** 1 = 100%; kept between 25% and 800%. */\n scale: number;\n}\n\nexport interface CanvasRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface PanZoomCanvasHandle {\n /** Fits `bounds` (or a given rect) in view. */\n fit: (rect?: CanvasRect) => void;\n /** Zooms to a percent around the viewport's centre. */\n zoomTo: (percent: number) => void;\n /** Centres a rect (a node) without changing the zoom. */\n centreOn: (rect: CanvasRect) => void;\n}\n\n/** What `renderScreen` draws from: the current view and the canvas's size in CSS pixels. */\nexport interface CanvasScreen {\n view: CanvasView;\n width: number;\n height: number;\n}\n\nexport interface PanZoomCanvasLabels {\n /** Announced when the zoom changes. Default \"Zoom 125%\". */\n zoom: (percent: number) => string;\n}\n\nexport interface PanZoomCanvasProps {\n /** Names the canvas (\"Schema diagram\"). */\n label: string;\n /** Controlled view: the pan offset and the zoom. */\n view?: CanvasView | undefined;\n /** Where it starts. Default: `bounds` fitted in view (or the origin at 100% without bounds). */\n defaultView?: CanvasView;\n /** Called with the new view on every pan and zoom. */\n onViewChange?: ((view: CanvasView) => void) | undefined;\n /** The content's extent in canvas units, for fitting and the minimap. */\n bounds?: CanvasRect | undefined;\n /** Show a minimap of `bounds` with the view on it (drag it, or press where to look). */\n minimap?: boolean;\n /** A small drawing of the content for the minimap, in canvas units (it is scaled down). */\n renderMinimap?: () => ReactNode;\n /**\n * A layer in screen pixels under the content, redrawn with every view change: for an engine that paints the whole\n * scene into a `<canvas>` (a canvas point (x, y) is at (x * scale + view.x, y * scale + view.y)). It does not take\n * the pointer, so pressing it pans like the background.\n */\n renderScreen?: (screen: CanvasScreen) => ReactNode;\n /** The content, placed in canvas units (absolutely positioned children). */\n children?: ReactNode;\n /** Replace the built-in English text: the zoom announcement. */\n labels?: Partial<PanZoomCanvasLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only (give it a height). Restyle through --cy-pan-zoom-canvas-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: PanZoomCanvasLabels = { zoom: (percent) => `Zoom ${percent}%` };\nconst MIN = MIN_PERCENT / 100;\nconst MAX = MAX_PERCENT / 100;\n/** Pixels an arrow key pans (Shift: five times as far). */\nconst STEP = 40;\n\n/**\n * A surface to pan and zoom freely in both directions, for diagrams, maps and boards: products place their content in\n * canvas units and keep their own layout and drawing. Drag the empty background (or hold Space and drag) to pan, the\n * wheel pans, Ctrl/Cmd+wheel and a pinch zoom around the pointer, one finger pans on touch; arrow keys pan, Ctrl/Cmd\n * and = - 0 zoom, Shift+1 fits. On the same zoom core as DocumentViewport.\n */\nexport const PanZoomCanvas = forwardRef<PanZoomCanvasHandle, PanZoomCanvasProps>(function PanZoomCanvas(\n {\n label,\n view,\n defaultView,\n onViewChange,\n bounds,\n minimap = false,\n renderMinimap,\n renderScreen,\n children,\n labels,\n className,\n style,\n },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const surface = useRef<HTMLElement>(null);\n const [current, setView] = useControllableState(\n view,\n defaultView ?? { x: 0, y: 0, scale: 1 },\n onViewChange,\n );\n const latest = useRef(current);\n latest.current = current;\n const [size, setSize] = useState({ width: 0, height: 0 });\n useClientLayoutEffect(() => {\n const el = surface.current as HTMLElement;\n const measure = () =>\n setSize((s) =>\n s.width === el.clientWidth && s.height === el.clientHeight\n ? s\n : { width: el.clientWidth, height: el.clientHeight },\n );\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n\n const go = (next: CanvasView) => {\n latest.current = next;\n setView(next);\n };\n const zoomAround = (scale: number, at: { x: number; y: number }) => {\n const v = latest.current;\n const s = clamp(scale, MIN, MAX);\n go({ x: at.x - ((at.x - v.x) * s) / v.scale, y: at.y - ((at.y - v.y) * s) / v.scale, scale: s });\n };\n const centre = () => ({ x: size.width / 2, y: size.height / 2 });\n const fit = (rect = bounds) => {\n if (!rect || !size.width || !size.height) return;\n const pad = Math.min(size.width, size.height) * 0.05;\n const s = clamp(\n Math.min((size.width - 2 * pad) / rect.width, (size.height - 2 * pad) / rect.height),\n MIN,\n MAX,\n );\n go({\n x: (size.width - rect.width * s) / 2 - rect.x * s,\n y: (size.height - rect.height * s) / 2 - rect.y * s,\n scale: s,\n });\n };\n const centreOn = (rect: CanvasRect) => {\n const { scale } = latest.current;\n go({\n x: size.width / 2 - (rect.x + rect.width / 2) * scale,\n y: size.height / 2 - (rect.y + rect.height / 2) * scale,\n scale,\n });\n };\n useImperativeHandle(ref, () => ({\n fit,\n zoomTo: (p) => zoomAround(clampPercent(p) / 100, centre()),\n centreOn,\n }));\n\n // Without a starting view, fit the content once the canvas has a size.\n const fitted = useRef(view !== undefined || defaultView !== undefined);\n useClientLayoutEffect(() => {\n if (fitted.current || !size.width) return;\n fitted.current = true;\n fit();\n });\n\n const percent = Math.round(current.scale * 100);\n const gestures = useZoomGestures(surface, {\n percent,\n onZoom: (p, at: ZoomAnchor) => zoomAround(p / 100, at ?? centre()),\n onPan: (dx, dy) => go({ ...latest.current, x: latest.current.x + dx, y: latest.current.y + dy }),\n });\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n gestures.onKeyDown(event);\n if (event.defaultPrevented || event.target !== event.currentTarget) return;\n if (event.key === \"!\" || (event.shiftKey && event.key === \"1\")) {\n event.preventDefault();\n fit();\n return;\n }\n const by = event.shiftKey ? STEP * 5 : STEP;\n const moves: Record<string, [number, number]> = {\n ArrowLeft: [by, 0],\n ArrowRight: [-by, 0],\n ArrowUp: [0, by],\n ArrowDown: [0, -by],\n };\n const move = moves[event.key];\n if (!move) return;\n event.preventDefault();\n go({ ...current, x: current.x + move[0], y: current.y + move[1] });\n };\n\n // Zoom changes are announced; the first value is not.\n const [said, setSaid] = useState({ percent, text: \"\" });\n if (said.percent !== percent) setSaid({ percent, text: text.zoom(percent) });\n\n // The minimap: `bounds` scaled to its width, with the view drawn on it. Dragging it (or pressing) moves the view.\n const map = useRef<HTMLDivElement>(null);\n // Measured into state (not a ref), so the view box is redrawn once the minimap's real width is known.\n const [mapWidth, setMapWidth] = useState(160);\n useClientLayoutEffect(() => {\n const w = map.current?.clientWidth;\n if (w && w !== mapWidth) setMapWidth(w);\n });\n const k = bounds ? mapWidth / bounds.width : 1;\n const seen = {\n x: (-current.x / current.scale - (bounds?.x ?? 0)) * k,\n y: (-current.y / current.scale - (bounds?.y ?? 0)) * k,\n width: (size.width / current.scale) * k,\n height: (size.height / current.scale) * k,\n };\n /** Centres the view on a point of the minimap (its own pixels). */\n const lookAt = (mx: number, my: number) => {\n if (!bounds) return;\n const { scale } = latest.current;\n go({\n x: size.width / 2 - (bounds.x + mx / k) * scale,\n y: size.height / 2 - (bounds.y + my / k) * scale,\n scale,\n });\n };\n useDrag(map, {\n onStart: ({ point }) => {\n const r = (map.current as HTMLDivElement).getBoundingClientRect();\n lookAt(point.x - r.left, point.y - r.top);\n },\n onMove: ({ point }) => {\n const r = (map.current as HTMLDivElement).getBoundingClientRect();\n lookAt(point.x - r.left, point.y - r.top);\n },\n });\n\n return (\n <>\n <section\n ref={surface}\n aria-label={label}\n // biome-ignore lint/a11y/noNoninteractiveTabindex: arrows pan and Ctrl/Cmd keys zoom the canvas\n tabIndex={0}\n className={className ? `cy-pan-zoom-canvas ${className}` : \"cy-pan-zoom-canvas\"}\n data-panning={gestures.panning ? \"\" : undefined}\n style={style}\n onKeyDown={onKeyDown}\n onKeyUp={gestures.onKeyUp}\n onBlur={gestures.onBlur}\n >\n {renderScreen && size.width > 0 && (\n <div className=\"cy-pan-zoom-canvas-screen cy-reset\">\n {renderScreen({ view: current, width: size.width, height: size.height })}\n </div>\n )}\n <div\n className=\"cy-pan-zoom-canvas-content cy-reset\"\n style={{ transform: `translate(${current.x}px, ${current.y}px) scale(${current.scale})` }}\n >\n {children}\n </div>\n {minimap && bounds && (\n <div\n ref={map}\n className=\"cy-pan-zoom-canvas-minimap cy-reset\"\n style={{ blockSize: bounds.height * k }}\n aria-hidden=\"true\"\n >\n {renderMinimap && (\n <div\n className=\"cy-pan-zoom-canvas-minimap-content cy-reset\"\n style={{ transform: `scale(${k}) translate(${-bounds.x}px, ${-bounds.y}px)` }}\n >\n {renderMinimap()}\n </div>\n )}\n <div\n className=\"cy-pan-zoom-canvas-minimap-view cy-reset\"\n style={{\n insetInlineStart: seen.x,\n insetBlockStart: seen.y,\n inlineSize: seen.width,\n blockSize: seen.height,\n }}\n />\n </div>\n )}\n </section>\n <span className=\"cy-visually-hidden\" role=\"status\">\n {said.text}\n </span>\n </>\n );\n});\n"],"mappings":";;;;;;;;;AAgGA,IAAMc,KAAsC,EAAE,MAAA,CAAOC,MAAY,QAAQA,CAAA,IAAW,GAC9EC,IAAA,KAAoB,KACpBC,IAAA,MAAoB,KAEpBC,KAAO,IAQAC,KAAgBZ,GAAoD,SAC/E,EACE,OAAAa,GACA,MAAAC,GACA,aAAAC,GACA,cAAAC,GACA,QAAAC,GACA,SAAAC,IAAU,IACV,eAAAC,GACA,cAAAC,GACA,UAAAC,GACA,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GAEFC,GACA;AACA,QAAMC,IAAO;AAAA,IAAE,GAAGnB;AAAA,IAAgB,GAAGe;AAAA,EAAO,GACtCK,IAAUzB,EAAoB,IAAI,GAClC,CAAC0B,GAASC,CAAA,IAAWnC,EACzBoB,GACAC,KAAe;AAAA,IAAE,GAAG;AAAA,IAAG,GAAG;AAAA,IAAG,OAAO;AAAA,EAAE,GAC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"../../tokens/schema.js" {
|
|
|
16
16
|
}
|
|
17
17
|
/** Spread onto the trigger (a Button or IconButton). */
|
|
18
18
|
export interface PopoverTriggerProps {
|
|
19
|
+
/** Spread onto the trigger: the panel is placed against it and focus returns to it on close. */
|
|
19
20
|
ref: Ref<HTMLButtonElement>;
|
|
21
|
+
/** Spread onto the trigger: opens the panel, or closes it when open. */
|
|
20
22
|
onClick: () => void;
|
|
23
|
+
/** Spread onto the trigger: whether the panel is open. */
|
|
21
24
|
"aria-expanded": boolean;
|
|
25
|
+
/** Spread onto the trigger: the id of the panel. */
|
|
22
26
|
"aria-controls": string;
|
|
27
|
+
/** Spread onto the trigger: tells assistive technology it opens a dialog. */
|
|
23
28
|
"aria-haspopup": "dialog";
|
|
24
29
|
}
|
|
25
30
|
export interface PopoverProps {
|
|
@@ -38,8 +43,11 @@ export interface PopoverProps {
|
|
|
38
43
|
} | VirtualAnchor | undefined;
|
|
39
44
|
/** Accessible name of the panel (a non-modal dialog). */
|
|
40
45
|
label: string;
|
|
46
|
+
/** Controlled open state. */
|
|
41
47
|
open?: boolean;
|
|
48
|
+
/** Open at first, when uncontrolled. */
|
|
42
49
|
defaultOpen?: boolean;
|
|
50
|
+
/** Called with the new state when the trigger, Escape or an outside click opens or closes it. */
|
|
43
51
|
onOpenChange?: (open: boolean) => void;
|
|
44
52
|
/** Preferred side; flips when it does not fit. `start`/`end` follow the reading direction. */
|
|
45
53
|
placement?: Placement;
|
|
@@ -47,9 +55,11 @@ export interface PopoverProps {
|
|
|
47
55
|
size?: Size;
|
|
48
56
|
/** Keep Tab inside the panel until it closes. */
|
|
49
57
|
modal?: boolean;
|
|
58
|
+
/** Added to the panel, for layout. */
|
|
50
59
|
className?: string;
|
|
51
60
|
/** Layout only, applied to the panel. */
|
|
52
61
|
style?: CSSProperties;
|
|
62
|
+
/** The panel's content. Focus moves to its first focusable element on open. */
|
|
53
63
|
children?: ReactNode;
|
|
54
64
|
}
|
|
55
65
|
/** Floating panel in the top layer, anchored to its trigger. Escape, outside clicks and focus return are shared. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","names":["_Fragment","useControllableState","useDismiss","usePopover","useAnchoredPosition","useId","useRef","Fragment$1","jsx","jsxs","FOCUSABLE","Popover","trigger","anchor","label","open","defaultOpen","onOpenChange","placement","size","modal","className","style","children","id","isOpen","setOpen","triggerRef","panel","placed","before","wasOpen","returnTo","el","trap","event","items","first","last","active"],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, type Ref, useId, useRef } from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { usePopover } from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition, type VirtualAnchor } from \"../../overlay/use-anchored-position.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface PopoverTokens {\n padding: string;\n radius: string;\n widthSm: string;\n widthMd: string;\n widthLg: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n popover: PopoverTokens;\n }\n}\n\n/** Spread onto the trigger (a Button or IconButton). */\nexport interface PopoverTriggerProps {\n ref: Ref<HTMLButtonElement>;\n onClick: () => void;\n \"aria-expanded\": boolean;\n \"aria-controls\": string;\n \"aria-haspopup\": \"dialog\";\n}\n\nexport interface PopoverProps {\n /**\n * Render the trigger: `(props) => <Button {...props}>Filters</Button>`. Optional with `anchor`: a popover opened\n * at a point (a canvas click) has no trigger, and is controlled with `open`.\n */\n trigger?: ((props: PopoverTriggerProps) => ReactNode) | undefined;\n /**\n * Place it at a point (`{ x, y }` in viewport pixels, such as where a canvas was clicked) or beside any element or\n * virtual anchor, instead of the trigger. Focus goes back to where it was when it closes.\n */\n anchor?: { x: number; y: number } | VirtualAnchor | undefined;\n /** Accessible name of the panel (a non-modal dialog). */\n label: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Preferred side; flips when it does not fit. `start`/`end` follow the reading direction. */\n placement?: Placement;\n /** Panel width preset. */\n size?: Size;\n /** Keep Tab inside the panel until it closes. */\n modal?: boolean;\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n children?: ReactNode;\n}\n\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Floating panel in the top layer, anchored to its trigger. Escape, outside clicks and focus return are shared. */\nexport function Popover({\n trigger,\n anchor,\n label,\n open,\n defaultOpen = false,\n onOpenChange,\n placement = \"bottom\",\n size = \"md\",\n modal = false,\n className,\n style,\n children,\n}: PopoverProps) {\n const id = useId();\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n // An `anchor` replaces the trigger as what the panel is placed against.\n const placed = useRef<HTMLElement | VirtualAnchor | null>(null);\n placed.current = !anchor\n ? triggerRef.current\n : \"getBoundingClientRect\" in anchor\n ? anchor\n : { getBoundingClientRect: () => new DOMRect(anchor.x, anchor.y, 0, 0) };\n // Without a trigger, focus returns to whatever had it when the panel opened.\n const before = useRef<HTMLElement | null>(null);\n const wasOpen = useRef(false);\n if (isOpen && !wasOpen.current && typeof document !== \"undefined\")\n before.current = document.activeElement as HTMLElement | null;\n wasOpen.current = isOpen;\n const returnTo = useRef<HTMLElement | null>(null);\n returnTo.current = trigger ? triggerRef.current : before.current;\n\n // Show before positioning (the panel must be laid out to be measured), then move focus inside.\n usePopover(panel, isOpen, (el) => {\n const first = el.querySelector<HTMLElement>(FOCUSABLE);\n (first ?? el).focus({ preventScroll: true });\n });\n useAnchoredPosition(anchor ? placed : triggerRef, panel, isOpen, placement, 6, \"start\");\n useDismiss({\n open: isOpen,\n onClose: () => setOpen(false),\n inside: [triggerRef, panel],\n returnFocus: returnTo,\n });\n\n const trap = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!modal || event.key !== \"Tab\") return;\n const items = [...event.currentTarget.querySelectorAll<HTMLElement>(FOCUSABLE)];\n if (!items.length) return;\n const first = items[0] as HTMLElement;\n const last = items[items.length - 1] as HTMLElement;\n const active = event.currentTarget.ownerDocument.activeElement;\n if (event.shiftKey && (active === first || active === event.currentTarget)) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n return (\n <>\n {trigger?.({\n ref: triggerRef,\n onClick: () => setOpen(!isOpen),\n \"aria-expanded\": isOpen,\n \"aria-controls\": `${id}-panel`,\n \"aria-haspopup\": \"dialog\",\n })}\n <div\n ref={panel}\n id={`${id}-panel`}\n role=\"dialog\"\n aria-label={label}\n aria-modal={modal || undefined}\n tabIndex={-1}\n {...{ popover: \"manual\" }}\n className={className ? `cy-popover ${className}` : \"cy-popover\"}\n data-size={size}\n style={style}\n onKeyDown={trap}\n >\n {children}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Popover.js","names":["_Fragment","useControllableState","useDismiss","usePopover","useAnchoredPosition","useId","useRef","Fragment$1","jsx","jsxs","FOCUSABLE","Popover","trigger","anchor","label","open","defaultOpen","onOpenChange","placement","size","modal","className","style","children","id","isOpen","setOpen","triggerRef","panel","placed","before","wasOpen","returnTo","el","trap","event","items","first","last","active"],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, type Ref, useId, useRef } from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { usePopover } from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition, type VirtualAnchor } from \"../../overlay/use-anchored-position.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface PopoverTokens {\n padding: string;\n radius: string;\n widthSm: string;\n widthMd: string;\n widthLg: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n popover: PopoverTokens;\n }\n}\n\n/** Spread onto the trigger (a Button or IconButton). */\nexport interface PopoverTriggerProps {\n /** Spread onto the trigger: the panel is placed against it and focus returns to it on close. */\n ref: Ref<HTMLButtonElement>;\n /** Spread onto the trigger: opens the panel, or closes it when open. */\n onClick: () => void;\n /** Spread onto the trigger: whether the panel is open. */\n \"aria-expanded\": boolean;\n /** Spread onto the trigger: the id of the panel. */\n \"aria-controls\": string;\n /** Spread onto the trigger: tells assistive technology it opens a dialog. */\n \"aria-haspopup\": \"dialog\";\n}\n\nexport interface PopoverProps {\n /**\n * Render the trigger: `(props) => <Button {...props}>Filters</Button>`. Optional with `anchor`: a popover opened\n * at a point (a canvas click) has no trigger, and is controlled with `open`.\n */\n trigger?: ((props: PopoverTriggerProps) => ReactNode) | undefined;\n /**\n * Place it at a point (`{ x, y }` in viewport pixels, such as where a canvas was clicked) or beside any element or\n * virtual anchor, instead of the trigger. Focus goes back to where it was when it closes.\n */\n anchor?: { x: number; y: number } | VirtualAnchor | undefined;\n /** Accessible name of the panel (a non-modal dialog). */\n label: string;\n /** Controlled open state. */\n open?: boolean;\n /** Open at first, when uncontrolled. */\n defaultOpen?: boolean;\n /** Called with the new state when the trigger, Escape or an outside click opens or closes it. */\n onOpenChange?: (open: boolean) => void;\n /** Preferred side; flips when it does not fit. `start`/`end` follow the reading direction. */\n placement?: Placement;\n /** Panel width preset. */\n size?: Size;\n /** Keep Tab inside the panel until it closes. */\n modal?: boolean;\n /** Added to the panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n /** The panel's content. Focus moves to its first focusable element on open. */\n children?: ReactNode;\n}\n\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Floating panel in the top layer, anchored to its trigger. Escape, outside clicks and focus return are shared. */\nexport function Popover({\n trigger,\n anchor,\n label,\n open,\n defaultOpen = false,\n onOpenChange,\n placement = \"bottom\",\n size = \"md\",\n modal = false,\n className,\n style,\n children,\n}: PopoverProps) {\n const id = useId();\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n // An `anchor` replaces the trigger as what the panel is placed against.\n const placed = useRef<HTMLElement | VirtualAnchor | null>(null);\n placed.current = !anchor\n ? triggerRef.current\n : \"getBoundingClientRect\" in anchor\n ? anchor\n : { getBoundingClientRect: () => new DOMRect(anchor.x, anchor.y, 0, 0) };\n // Without a trigger, focus returns to whatever had it when the panel opened.\n const before = useRef<HTMLElement | null>(null);\n const wasOpen = useRef(false);\n if (isOpen && !wasOpen.current && typeof document !== \"undefined\")\n before.current = document.activeElement as HTMLElement | null;\n wasOpen.current = isOpen;\n const returnTo = useRef<HTMLElement | null>(null);\n returnTo.current = trigger ? triggerRef.current : before.current;\n\n // Show before positioning (the panel must be laid out to be measured), then move focus inside.\n usePopover(panel, isOpen, (el) => {\n const first = el.querySelector<HTMLElement>(FOCUSABLE);\n (first ?? el).focus({ preventScroll: true });\n });\n useAnchoredPosition(anchor ? placed : triggerRef, panel, isOpen, placement, 6, \"start\");\n useDismiss({\n open: isOpen,\n onClose: () => setOpen(false),\n inside: [triggerRef, panel],\n returnFocus: returnTo,\n });\n\n const trap = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!modal || event.key !== \"Tab\") return;\n const items = [...event.currentTarget.querySelectorAll<HTMLElement>(FOCUSABLE)];\n if (!items.length) return;\n const first = items[0] as HTMLElement;\n const last = items[items.length - 1] as HTMLElement;\n const active = event.currentTarget.ownerDocument.activeElement;\n if (event.shiftKey && (active === first || active === event.currentTarget)) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n return (\n <>\n {trigger?.({\n ref: triggerRef,\n onClick: () => setOpen(!isOpen),\n \"aria-expanded\": isOpen,\n \"aria-controls\": `${id}-panel`,\n \"aria-haspopup\": \"dialog\",\n })}\n <div\n ref={panel}\n id={`${id}-panel`}\n role=\"dialog\"\n aria-label={label}\n aria-modal={modal || undefined}\n tabIndex={-1}\n {...{ popover: \"manual\" }}\n className={className ? `cy-popover ${className}` : \"cy-popover\"}\n data-size={size}\n style={style}\n onKeyDown={trap}\n >\n {children}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;AAqEA,IAAMU,IACJ;AAGF,SAAgBC,EAAQ,EACtB,SAAAC,GACA,QAAAC,GACA,OAAAC,GACA,MAAAC,GACA,aAAAC,IAAc,IACd,cAAAC,GACA,WAAAC,IAAY,UACZ,MAAAC,IAAO,MACP,OAAAC,IAAQ,IACR,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACe;AACf,QAAMC,IAAKnB,EAAM,GACX,CAACoB,GAAQC,CAAA,IAAWzB,EAAqBc,GAAMC,GAAaC,CAAY,GACxEU,IAAarB,EAA0B,IAAI,GAC3CsB,IAAQtB,EAAuB,IAAI,GAEnCuB,IAASvB,EAA2C,IAAI;AAC9D,EAAAuB,EAAO,UAAWhB,IAEd,2BAA2BA,IACzBA,IACA,EAAE,uBAAA,MAA6B,IAAI,QAAQA,EAAO,GAAGA,EAAO,GAAG,GAAG,CAAC,EAAE,IAHvEc,EAAW;AAKf,QAAMG,IAASxB,EAA2B,IAAI,GACxCyB,IAAUzB,EAAO,EAAK;AAC5B,EAAImB,KAAU,CAACM,EAAQ,WAAW,OAAO,WAAa,QACpDD,EAAO,UAAU,SAAS,gBAC5BC,EAAQ,UAAUN;AAClB,QAAMO,IAAW1B,EAA2B,IAAI;AAChD,EAAA0B,EAAS,UAAUpB,IAAUe,EAAW,UAAUG,EAAO,SAGzD3B,EAAWyB,GAAOH,GAAA,C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AAWF;AAAA,IACJ,OAAAG;AAAA,IACP,WAAWY;AAAA,IAEV,UAAAX;AAAA,EACE,CAAA,CACL,EAAA,CAAA;AAEN"}
|
|
@@ -27,9 +27,11 @@ export interface ProgressSegment {
|
|
|
27
27
|
export interface ProgressBarProps {
|
|
28
28
|
/** Accessible name, shown above the bar unless `labelHidden`. */
|
|
29
29
|
label: string;
|
|
30
|
+
/** Visually hide the label (it still names the bar). */
|
|
30
31
|
labelHidden?: boolean;
|
|
31
32
|
/** Current value between 0 and `max`. Leave it out (or pass `indeterminate`) when progress is unknown. */
|
|
32
33
|
value?: number | undefined;
|
|
34
|
+
/** The value that means complete. Default 100. */
|
|
33
35
|
max?: number;
|
|
34
36
|
/** Progress is happening but its amount is unknown. */
|
|
35
37
|
indeterminate?: boolean;
|
|
@@ -46,10 +48,13 @@ export interface ProgressBarProps {
|
|
|
46
48
|
marker?: number | undefined;
|
|
47
49
|
/** Read with the value when there is a marker. Default "marker at 75%". */
|
|
48
50
|
markerLabel?: string | undefined;
|
|
51
|
+
/** Colour of the fill. Default "accent". */
|
|
49
52
|
tone?: Exclude<Tone, "neutral"> | "neutral";
|
|
50
53
|
/** Bar thickness. */
|
|
51
54
|
size?: Size;
|
|
55
|
+
/** Replace the built-in English text: the value text. */
|
|
52
56
|
labels?: Partial<ProgressBarLabels>;
|
|
57
|
+
/** Added to the root element, for layout. */
|
|
53
58
|
className?: string;
|
|
54
59
|
/** Layout only. Restyle through --cy-progress-bar-* tokens. */
|
|
55
60
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","names":["useId","jsx","jsxs","percent","value","max","ProgressBar","label","labelHidden","indeterminate","showValue","segments","offset","marker","markerLabel","tone","size","labels","className","style","id","top","unknown","now","parts","total","sum","p","unknownBar","shownNow","at","v","text","spoken","start","q"],"sources":["../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { type CSSProperties, useId } from \"react\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface ProgressBarTokens {\n heightSm: string;\n heightMd: string;\n heightLg: string;\n radius: string;\n track: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n progressBar: ProgressBarTokens;\n }\n}\n\nexport interface ProgressBarLabels {\n /** Text for the current value, shown with `showValue` and read by screen readers. Default: \"42%\". */\n value: (value: number, max: number) => string;\n}\n\nexport interface ProgressSegment {\n value: number;\n /** Read out with the value (\"Connect 30\"). */\n label: string;\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** A category colour (any CSS colour); overrides `tone`. */\n color?: string;\n}\n\nexport interface ProgressBarProps {\n /** Accessible name, shown above the bar unless `labelHidden`. */\n label: string;\n labelHidden?: boolean;\n /** Current value between 0 and `max`. Leave it out (or pass `indeterminate`) when progress is unknown. */\n value?: number | undefined;\n max?: number;\n /** Progress is happening but its amount is unknown. */\n indeterminate?: boolean;\n /** Show the value text at the end of the label row. */\n showValue?: boolean;\n /**\n * Parts drawn end to end instead of one fill, from `offset`: a request's timing (DNS, connect, wait, download) or a\n * waterfall row. Each has a `label` (read out) and a `tone` or category `color`.\n */\n segments?: ProgressSegment[] | undefined;\n /** Where the first segment starts, in the same units as `max`. Default 0. */\n offset?: number;\n /** A thin mark across the track at this value (a target, a second position). */\n marker?: number | undefined;\n /** Read with the value when there is a marker. Default \"marker at 75%\". */\n markerLabel?: string | undefined;\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** Bar thickness. */\n size?: Size;\n labels?: Partial<ProgressBarLabels>;\n className?: string;\n /** Layout only. Restyle through --cy-progress-bar-* tokens. */\n style?: CSSProperties;\n}\n\nconst percent = (value: number, max: number) => `${Math.round((value / max) * 100)}%`;\n\n/** How far a task has got: a labelled `role=\"progressbar\"`, determinate or indeterminate. */\nexport function ProgressBar({\n label,\n labelHidden = false,\n value,\n max = 100,\n indeterminate = false,\n showValue = false,\n segments,\n offset = 0,\n marker,\n markerLabel,\n tone = \"accent\",\n size = \"md\",\n labels,\n className,\n style,\n}: ProgressBarProps) {\n const id = useId();\n const top = max > 0 ? max : 100;\n const unknown = indeterminate || value === undefined || Number.isNaN(value);\n const now = unknown ? 0 : Math.min(Math.max(value, 0), top);\n const parts = segments?.length ? segments : null;\n const total = parts ? offset + parts.reduce((sum, p) => sum + Math.max(0, p.value), 0) : 0;\n const unknownBar = parts ? false : unknown;\n const shownNow = parts ? Math.min(total, top) : now;\n const at = (v: number) => `${(Math.min(Math.max(v, 0), top) / top) * 100}%`;\n const text = parts\n ? parts.map((p) => `${p.label} ${p.value}`).join(\", \")\n : unknown\n ? \"\"\n : (labels?.value ?? percent)(now, top);\n const spoken =\n marker === undefined\n ? text\n : [text, markerLabel ?? `marker at ${percent(marker, top)}`].filter(Boolean).join(\", \");\n return (\n <div\n className={className ? `cy-progress-bar ${className}` : \"cy-progress-bar\"}\n data-size={size}\n data-tone={tone}\n data-indeterminate={unknownBar || undefined}\n style={style}\n >\n {(!labelHidden || (showValue && !unknown)) && (\n <div className=\"cy-progress-bar-head cy-reset\">\n {!labelHidden && (\n <span id={`${id}-label`} className=\"cy-progress-bar-label cy-reset\">\n {label}\n </span>\n )}\n {showValue && !unknownBar && (\n <span className=\"cy-progress-bar-value cy-reset\" aria-hidden=\"true\">\n {text}\n </span>\n )}\n </div>\n )}\n <div\n role=\"progressbar\"\n className=\"cy-progress-bar-track cy-reset\"\n {...(labelHidden ? { \"aria-label\": label } : { \"aria-labelledby\": `${id}-label` })}\n aria-valuemin={0}\n aria-valuemax={top}\n aria-valuenow={unknownBar ? undefined : shownNow}\n aria-valuetext={unknownBar ? undefined : spoken}\n aria-busy={unknownBar || undefined}\n style={{ \"--_fill\": unknownBar || parts ? undefined : `${(now / top) * 100}%` } as CSSProperties}\n >\n {parts ? (\n parts.map((p, i) => {\n const start = offset + parts.slice(0, i).reduce((sum, q) => sum + Math.max(0, q.value), 0);\n return (\n <div\n key={`${p.label}-${i}`}\n className=\"cy-progress-bar-segment cy-reset\"\n data-tone={p.color ? undefined : (p.tone ?? tone)}\n style={\n {\n \"--_from\": at(start),\n \"--_to\": at(start + Math.max(0, p.value)),\n ...(p.color ? { \"--_seg\": p.color } : {}),\n } as CSSProperties\n }\n />\n );\n })\n ) : (\n <div className=\"cy-progress-bar-fill cy-reset\" />\n )}\n {marker !== undefined && (\n <div className=\"cy-progress-bar-marker cy-reset\" style={{ \"--_at\": at(marker) } as CSSProperties} />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","names":["useId","jsx","jsxs","percent","value","max","ProgressBar","label","labelHidden","indeterminate","showValue","segments","offset","marker","markerLabel","tone","size","labels","className","style","id","top","unknown","now","parts","total","sum","p","unknownBar","shownNow","at","v","text","spoken","start","q"],"sources":["../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { type CSSProperties, useId } from \"react\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface ProgressBarTokens {\n heightSm: string;\n heightMd: string;\n heightLg: string;\n radius: string;\n track: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n progressBar: ProgressBarTokens;\n }\n}\n\nexport interface ProgressBarLabels {\n /** Text for the current value, shown with `showValue` and read by screen readers. Default: \"42%\". */\n value: (value: number, max: number) => string;\n}\n\nexport interface ProgressSegment {\n value: number;\n /** Read out with the value (\"Connect 30\"). */\n label: string;\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** A category colour (any CSS colour); overrides `tone`. */\n color?: string;\n}\n\nexport interface ProgressBarProps {\n /** Accessible name, shown above the bar unless `labelHidden`. */\n label: string;\n /** Visually hide the label (it still names the bar). */\n labelHidden?: boolean;\n /** Current value between 0 and `max`. Leave it out (or pass `indeterminate`) when progress is unknown. */\n value?: number | undefined;\n /** The value that means complete. Default 100. */\n max?: number;\n /** Progress is happening but its amount is unknown. */\n indeterminate?: boolean;\n /** Show the value text at the end of the label row. */\n showValue?: boolean;\n /**\n * Parts drawn end to end instead of one fill, from `offset`: a request's timing (DNS, connect, wait, download) or a\n * waterfall row. Each has a `label` (read out) and a `tone` or category `color`.\n */\n segments?: ProgressSegment[] | undefined;\n /** Where the first segment starts, in the same units as `max`. Default 0. */\n offset?: number;\n /** A thin mark across the track at this value (a target, a second position). */\n marker?: number | undefined;\n /** Read with the value when there is a marker. Default \"marker at 75%\". */\n markerLabel?: string | undefined;\n /** Colour of the fill. Default \"accent\". */\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** Bar thickness. */\n size?: Size;\n /** Replace the built-in English text: the value text. */\n labels?: Partial<ProgressBarLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-progress-bar-* tokens. */\n style?: CSSProperties;\n}\n\nconst percent = (value: number, max: number) => `${Math.round((value / max) * 100)}%`;\n\n/** How far a task has got: a labelled `role=\"progressbar\"`, determinate or indeterminate. */\nexport function ProgressBar({\n label,\n labelHidden = false,\n value,\n max = 100,\n indeterminate = false,\n showValue = false,\n segments,\n offset = 0,\n marker,\n markerLabel,\n tone = \"accent\",\n size = \"md\",\n labels,\n className,\n style,\n}: ProgressBarProps) {\n const id = useId();\n const top = max > 0 ? max : 100;\n const unknown = indeterminate || value === undefined || Number.isNaN(value);\n const now = unknown ? 0 : Math.min(Math.max(value, 0), top);\n const parts = segments?.length ? segments : null;\n const total = parts ? offset + parts.reduce((sum, p) => sum + Math.max(0, p.value), 0) : 0;\n const unknownBar = parts ? false : unknown;\n const shownNow = parts ? Math.min(total, top) : now;\n const at = (v: number) => `${(Math.min(Math.max(v, 0), top) / top) * 100}%`;\n const text = parts\n ? parts.map((p) => `${p.label} ${p.value}`).join(\", \")\n : unknown\n ? \"\"\n : (labels?.value ?? percent)(now, top);\n const spoken =\n marker === undefined\n ? text\n : [text, markerLabel ?? `marker at ${percent(marker, top)}`].filter(Boolean).join(\", \");\n return (\n <div\n className={className ? `cy-progress-bar ${className}` : \"cy-progress-bar\"}\n data-size={size}\n data-tone={tone}\n data-indeterminate={unknownBar || undefined}\n style={style}\n >\n {(!labelHidden || (showValue && !unknown)) && (\n <div className=\"cy-progress-bar-head cy-reset\">\n {!labelHidden && (\n <span id={`${id}-label`} className=\"cy-progress-bar-label cy-reset\">\n {label}\n </span>\n )}\n {showValue && !unknownBar && (\n <span className=\"cy-progress-bar-value cy-reset\" aria-hidden=\"true\">\n {text}\n </span>\n )}\n </div>\n )}\n <div\n role=\"progressbar\"\n className=\"cy-progress-bar-track cy-reset\"\n {...(labelHidden ? { \"aria-label\": label } : { \"aria-labelledby\": `${id}-label` })}\n aria-valuemin={0}\n aria-valuemax={top}\n aria-valuenow={unknownBar ? undefined : shownNow}\n aria-valuetext={unknownBar ? undefined : spoken}\n aria-busy={unknownBar || undefined}\n style={{ \"--_fill\": unknownBar || parts ? undefined : `${(now / top) * 100}%` } as CSSProperties}\n >\n {parts ? (\n parts.map((p, i) => {\n const start = offset + parts.slice(0, i).reduce((sum, q) => sum + Math.max(0, q.value), 0);\n return (\n <div\n key={`${p.label}-${i}`}\n className=\"cy-progress-bar-segment cy-reset\"\n data-tone={p.color ? undefined : (p.tone ?? tone)}\n style={\n {\n \"--_from\": at(start),\n \"--_to\": at(start + Math.max(0, p.value)),\n ...(p.color ? { \"--_seg\": p.color } : {}),\n } as CSSProperties\n }\n />\n );\n })\n ) : (\n <div className=\"cy-progress-bar-fill cy-reset\" />\n )}\n {marker !== undefined && (\n <div className=\"cy-progress-bar-marker cy-reset\" style={{ \"--_at\": at(marker) } as CSSProperties} />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;AAmEA,IAAMG,IAAA,CAAWC,GAAeC,MAAgB,GAAG,KAAK,MAAOD,IAAQC,IAAO,GAAG,CAAA;AAGjF,SAAgBC,EAAY,EAC1B,OAAAC,GACA,aAAAC,IAAc,IACd,OAAAJ,GACA,KAAAC,IAAM,KACN,eAAAI,IAAgB,IAChB,WAAAC,IAAY,IACZ,UAAAC,GACA,QAA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K,WAAU,gCAAiC,CAAA,GAEjDY,MAAW,UACV,gBAAAZ,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAkC,OAAO,EAAE,SAAS6B,EAAGjB,CAAM,EAAE;AAAA,MAAqB,CAAA,CAElG;AAAA,IACF,CAAA,CAAA;AAAA,E;AAET"}
|
|
@@ -14,12 +14,15 @@ export interface ProgressOverlayProps {
|
|
|
14
14
|
title: string;
|
|
15
15
|
/** How far it has got; leave undefined while the amount is unknown. */
|
|
16
16
|
value?: number | undefined;
|
|
17
|
+
/** The value that means complete. Default 100. */
|
|
17
18
|
max?: number | undefined;
|
|
18
19
|
/** A line under the bar ("Page 3: images"). Default: the count, or "Working…". Read out politely as it changes. */
|
|
19
20
|
status?: string | undefined;
|
|
20
21
|
/** Cancels the work: the Cancel button and Escape. Without it the overlay cannot be closed. */
|
|
21
22
|
onCancel?: (() => void) | undefined;
|
|
23
|
+
/** Replace the built-in English text: the Cancel button and the status line. */
|
|
22
24
|
labels?: Partial<ProgressOverlayLabels>;
|
|
25
|
+
/** Added to the dialog's panel, for layout. */
|
|
23
26
|
className?: string;
|
|
24
27
|
/** Layout only. */
|
|
25
28
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressOverlay.js","names":["Button","Dialog","ProgressBar","jsx","jsxs","DEFAULT_LABELS","value","max","ProgressOverlay","open","title","status","onCancel","labels","className","style","text","known","line","next"],"sources":["../../../src/components/ProgressOverlay/ProgressOverlay.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { Button } from \"../Button/Button.js\";\nimport { Dialog } from \"../Dialog/Dialog.js\";\nimport { ProgressBar } from \"../ProgressBar/ProgressBar.js\";\n\nexport interface ProgressOverlayLabels {\n /** The Cancel button. Default \"Cancel\". */\n cancel: string;\n /** Status while the amount is unknown. Default \"Working…\". */\n working: string;\n /** Status from the counts. Default \"3 of 12\". */\n count: (value: number, max: number) => string;\n}\n\nexport interface ProgressOverlayProps {\n /** Show it. */\n open: boolean;\n /** What is happening (\"Compressing the PDF\"). Names the dialog and the progress bar. */\n title: string;\n /** How far it has got; leave undefined while the amount is unknown. */\n value?: number | undefined;\n max?: number | undefined;\n /** A line under the bar (\"Page 3: images\"). Default: the count, or \"Working…\". Read out politely as it changes. */\n status?: string | undefined;\n /** Cancels the work: the Cancel button and Escape. Without it the overlay cannot be closed. */\n onCancel?: (() => void) | undefined;\n labels?: Partial<ProgressOverlayLabels>;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: ProgressOverlayLabels = {\n cancel: \"Cancel\",\n working: \"Working…\",\n count: (value, max) => `${value} of ${max}`,\n};\n\n/**\n * Modal progress for long work the page must wait for (exporting, compressing, converting): a Dialog with a\n * ProgressBar and a status line. Escape and Cancel call `onCancel`; with no `onCancel` it stays until the work ends.\n */\nexport function ProgressOverlay({\n open,\n title,\n value,\n max = 100,\n status,\n onCancel,\n labels,\n className,\n style,\n}: ProgressOverlayProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const known = value !== undefined;\n const line = status ?? (known ? text.count(Math.min(Math.max(value, 0), max), max) : text.working);\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => !next && onCancel?.()}\n title={title}\n size=\"sm\"\n dismissible={!!onCancel}\n actions={onCancel && <Button onClick={onCancel}>{text.cancel}</Button>}\n className={className ? `cy-progress-overlay ${className}` : \"cy-progress-overlay\"}\n {...(style ? { style } : {})}\n >\n <ProgressBar\n label={title}\n labelHidden\n value={value}\n max={max}\n indeterminate={!known}\n labels={{ value: text.count }}\n />\n <p className=\"cy-progress-overlay-status cy-reset\" aria-live=\"polite\">\n {line}\n </p>\n </Dialog>\n );\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"ProgressOverlay.js","names":["Button","Dialog","ProgressBar","jsx","jsxs","DEFAULT_LABELS","value","max","ProgressOverlay","open","title","status","onCancel","labels","className","style","text","known","line","next"],"sources":["../../../src/components/ProgressOverlay/ProgressOverlay.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { Button } from \"../Button/Button.js\";\nimport { Dialog } from \"../Dialog/Dialog.js\";\nimport { ProgressBar } from \"../ProgressBar/ProgressBar.js\";\n\nexport interface ProgressOverlayLabels {\n /** The Cancel button. Default \"Cancel\". */\n cancel: string;\n /** Status while the amount is unknown. Default \"Working…\". */\n working: string;\n /** Status from the counts. Default \"3 of 12\". */\n count: (value: number, max: number) => string;\n}\n\nexport interface ProgressOverlayProps {\n /** Show it. */\n open: boolean;\n /** What is happening (\"Compressing the PDF\"). Names the dialog and the progress bar. */\n title: string;\n /** How far it has got; leave undefined while the amount is unknown. */\n value?: number | undefined;\n /** The value that means complete. Default 100. */\n max?: number | undefined;\n /** A line under the bar (\"Page 3: images\"). Default: the count, or \"Working…\". Read out politely as it changes. */\n status?: string | undefined;\n /** Cancels the work: the Cancel button and Escape. Without it the overlay cannot be closed. */\n onCancel?: (() => void) | undefined;\n /** Replace the built-in English text: the Cancel button and the status line. */\n labels?: Partial<ProgressOverlayLabels>;\n /** Added to the dialog's panel, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: ProgressOverlayLabels = {\n cancel: \"Cancel\",\n working: \"Working…\",\n count: (value, max) => `${value} of ${max}`,\n};\n\n/**\n * Modal progress for long work the page must wait for (exporting, compressing, converting): a Dialog with a\n * ProgressBar and a status line. Escape and Cancel call `onCancel`; with no `onCancel` it stays until the work ends.\n */\nexport function ProgressOverlay({\n open,\n title,\n value,\n max = 100,\n status,\n onCancel,\n labels,\n className,\n style,\n}: ProgressOverlayProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const known = value !== undefined;\n const line = status ?? (known ? text.count(Math.min(Math.max(value, 0), max), max) : text.working);\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => !next && onCancel?.()}\n title={title}\n size=\"sm\"\n dismissible={!!onCancel}\n actions={onCancel && <Button onClick={onCancel}>{text.cancel}</Button>}\n className={className ? `cy-progress-overlay ${className}` : \"cy-progress-overlay\"}\n {...(style ? { style } : {})}\n >\n <ProgressBar\n label={title}\n labelHidden\n value={value}\n max={max}\n indeterminate={!known}\n labels={{ value: text.count }}\n />\n <p className=\"cy-progress-overlay-status cy-reset\" aria-live=\"polite\">\n {line}\n </p>\n </Dialog>\n );\n}\n"],"mappings":";;;;;AAmCA,IAAMK,IAAwC;AAAA,EAC5C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAA,CAAQC,GAAOC,MAAQ,GAAGD,CAAA,OAAYC,CAAA;AACxC;AAMA,SAAgBC,EAAgB,EAC9B,MAAAC,GACA,OAAAC,GACA,OAAAJ,GACA,KAAAC,IAAM,KACN,QAAAI,GACA,UAAAC,GACA,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACuB;AACvB,QAAMC,IAAO;AAAA,IAAE,GAAGX;AAAA,IAAgB,GAAGQ;AAAA,EAAO,GACtCI,IAAQX,MAAU,QAClBY,IAAOP,MAAWM,IAAQD,EAAK,MAAM,KAAK,IAAI,KAAK,IAAIV,GAAO,CAAC,GAAGC,CAAG,GAAGA,CAAG,IAAIS,EAAK;AAC1F,SACE,gBAAAZ,EAACH,GAAD;AAAA,IACQ,MAAAQ;AAAA,IACN,cAAA,CAAeU,MAAS,CAACA,KAAQP,IAAW;AAAA,IACrC,OAAAF;AAAA,IACP,MAAK;AAAA,IACL,aAAa,CAAC,CAACE;AAAA,IACf,SAASA,KAAY,gBAAAT,EAACH,GAAD;AAAA,MAAQ,SAASY;AAAA,MAAW,UAAAI,EAAK;AAAA,IAAe,CAAA;AAAA,IACrE,WAAWF,IAAY,uBAAuBA,CAAA,KAAc;AAAA,IAC5D,GAAKC,IAAQ,EAAE,OAAAA,EAAM,IAAI,CAAC;AAAA,IAR5B,UAAA,CAUE,gBAAAZ,EAACD,GAAD;AAAA,MACE,OAAOQ;AAAA,MACP,aAAA;AAAA,MACO,OAAAJ;AAAA,MACF,KAAAC;AAAA,MACL,eAAe,CAACU;AAAA,MAChB,QAAQ,EAAE,OAAOD,EAAK,MAAM;AAAA,IAC7B,CAAA,GACD,gBAAAb,EAAC,KAAD;AAAA,MAAG,WAAU;AAAA,MAAsC,aAAU;AAAA,MAC1D,UAAAe;AAAA,IACA,CAAA,CACG;AAAA,E;AAEZ"}
|
|
@@ -20,6 +20,7 @@ export interface ProseProps {
|
|
|
20
20
|
size?: Size;
|
|
21
21
|
/** Neutral element to render. Use `article` for a standalone piece of writing. */
|
|
22
22
|
as?: "div" | "article" | "section";
|
|
23
|
+
/** Added to the root element, for layout. */
|
|
23
24
|
className?: string;
|
|
24
25
|
/** Layout only. Restyle through --cy-prose-* tokens. */
|
|
25
26
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prose.js","names":["jsx","Prose","size","Tag","className","style","children"],"sources":["../../../src/components/Prose/Prose.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface ProseTokens {\n /** Longest line length. */\n measure: string;\n /** Space between blocks (paragraphs, lists, headings). */\n flow: string;\n /** Link colour. */\n link: string;\n /** Background of inline code and code blocks. */\n codeBackground: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n prose: ProseTokens;\n }\n}\n\nexport interface ProseProps {\n /** Body text size; headings scale from it. */\n size?: Size;\n /** Neutral element to render. Use `article` for a standalone piece of writing. */\n as?: \"div\" | \"article\" | \"section\";\n className?: string;\n /** Layout only. Restyle through --cy-prose-* tokens. */\n style?: CSSProperties;\n /** Rendered Markdown or other long-form HTML. Cynosure components inside keep their own styles. */\n children?: ReactNode;\n}\n\n/** Typography for long text you do not style element by element: rendered Markdown, docs, release notes, help. */\nexport function Prose({ size = \"md\", as: Tag = \"div\", className, style, children }: ProseProps) {\n return (\n <Tag className={className ? `cy-prose ${className}` : \"cy-prose\"} data-size={size} style={style}>\n {children}\n </Tag>\n );\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Prose.js","names":["jsx","Prose","size","Tag","className","style","children"],"sources":["../../../src/components/Prose/Prose.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface ProseTokens {\n /** Longest line length. */\n measure: string;\n /** Space between blocks (paragraphs, lists, headings). */\n flow: string;\n /** Link colour. */\n link: string;\n /** Background of inline code and code blocks. */\n codeBackground: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n prose: ProseTokens;\n }\n}\n\nexport interface ProseProps {\n /** Body text size; headings scale from it. */\n size?: Size;\n /** Neutral element to render. Use `article` for a standalone piece of writing. */\n as?: \"div\" | \"article\" | \"section\";\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-prose-* tokens. */\n style?: CSSProperties;\n /** Rendered Markdown or other long-form HTML. Cynosure components inside keep their own styles. */\n children?: ReactNode;\n}\n\n/** Typography for long text you do not style element by element: rendered Markdown, docs, release notes, help. */\nexport function Prose({ size = \"md\", as: Tag = \"div\", className, style, children }: ProseProps) {\n return (\n <Tag className={className ? `cy-prose ${className}` : \"cy-prose\"} data-size={size} style={style}>\n {children}\n </Tag>\n );\n}\n"],"mappings":";;AAkCA,SAAgBC,EAAM,EAAE,MAAAC,IAAO,MAAM,IAAIC,IAAM,OAAO,WAAAC,GAAW,OAAAC,GAAO,UAAAC,EAAA,GAAwB;AAC9F,SACE,gBAAAN,EAACG,GAAD;AAAA,IAAK,WAAWC,IAAY,YAAYA,CAAA,KAAc;AAAA,IAAY,aAAWF;AAAA,IAAa,OAAAG;AAAA,IACvF,UAAAC;AAAA,EACE,CAAA;AAET"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type QrLevel } from "../../foundations/qr.js";
|
|
3
|
+
import type { Size } from "../../tokens/schema.js";
|
|
4
|
+
export interface QRCodeTokens {
|
|
5
|
+
/** Colour of the dark modules. Default: the light palette's ink, in every colour mode. */
|
|
6
|
+
color: string;
|
|
7
|
+
/** Colour of the light modules and the quiet zone. Default: the light palette's surface, in every colour mode. */
|
|
8
|
+
background: string;
|
|
9
|
+
/** Width and height at `size="sm"`. */
|
|
10
|
+
sizeSm: string;
|
|
11
|
+
/** Width and height at `size="md"`. */
|
|
12
|
+
sizeMd: string;
|
|
13
|
+
/** Width and height at `size="lg"`. */
|
|
14
|
+
sizeLg: string;
|
|
15
|
+
/** Width and height of the centred icon, as a share of the code's width. Keep it at 22% or less. */
|
|
16
|
+
iconSize: string;
|
|
17
|
+
/** Corner radius of the code, quiet zone included. */
|
|
18
|
+
radius: string;
|
|
19
|
+
}
|
|
20
|
+
declare module "../../tokens/schema.js" {
|
|
21
|
+
interface ComponentTokens {
|
|
22
|
+
qrCode: QRCodeTokens;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export interface QRCodeLabels {
|
|
26
|
+
/** Accessible name when no `label` is given. Default "QR code". */
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
export interface QRCodeProps {
|
|
30
|
+
/** The text to encode, usually a URL. Numbers and upper-case text use the compact modes; anything else is UTF-8. */
|
|
31
|
+
value: string;
|
|
32
|
+
/** Width and height: `sm`, `md` (default) or `lg` from the tokens, or a number of pixels. */
|
|
33
|
+
size?: Size | number;
|
|
34
|
+
/**
|
|
35
|
+
* Error correction: how much of the code can be damaged or covered and still scan (L 7%, M 15%, Q 25%, H 30%).
|
|
36
|
+
* Higher levels need a denser code. Default "M"; always "H" with an `icon`.
|
|
37
|
+
*/
|
|
38
|
+
level?: QrLevel;
|
|
39
|
+
/** Light modules around the code, which scanners need to find it. The standard asks for 4. Default 4. */
|
|
40
|
+
quietZone?: number;
|
|
41
|
+
/** Accessible name. Default `labels.name` ("QR code"). Say where it leads, and show the link as text too. */
|
|
42
|
+
label?: string;
|
|
43
|
+
/** Built-in strings. */
|
|
44
|
+
labels?: Partial<QRCodeLabels>;
|
|
45
|
+
/**
|
|
46
|
+
* A logo drawn in the centre, on the light colour (an `<Icon>` or a small image). It covers modules, so the level is
|
|
47
|
+
* raised to H.
|
|
48
|
+
*/
|
|
49
|
+
icon?: ReactNode;
|
|
50
|
+
/** Added to the root element, for layout. */
|
|
51
|
+
className?: string;
|
|
52
|
+
/** Layout only. Restyle through `--cy-qr-code-*` tokens. */
|
|
53
|
+
style?: CSSProperties;
|
|
54
|
+
}
|
|
55
|
+
/** A QR code drawn as one crisp SVG path, dark on light in every colour mode so phones can scan it. */
|
|
56
|
+
export declare const QRCode: import("react").ForwardRefExoticComponent<QRCodeProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { qrMatrix as y, qrPath as g } from "../../foundations/qr.js";
|
|
3
|
+
import { forwardRef as q, useMemo as b } from "react";
|
|
4
|
+
import { jsx as s, jsxs as M } from "react/jsx-runtime";
|
|
5
|
+
var R = { name: "QR code" }, Q = q(function({ value: t, size: e = "md", level: f = "M", quietZone: h = 4, label: p, labels: u, icon: r, className: c, style: d }, v) {
|
|
6
|
+
const n = r != null && r !== !1, o = n ? "H" : f, a = Math.max(0, Math.floor(h)), { box: i, d: x } = b(() => {
|
|
7
|
+
const m = y(t, { level: o });
|
|
8
|
+
return {
|
|
9
|
+
box: m.length + a * 2,
|
|
10
|
+
d: g(m, a)
|
|
11
|
+
};
|
|
12
|
+
}, [
|
|
13
|
+
t,
|
|
14
|
+
o,
|
|
15
|
+
a
|
|
16
|
+
]), l = typeof e == "number" ? { "--_size": `${e}px` } : void 0;
|
|
17
|
+
return /* @__PURE__ */ M("div", {
|
|
18
|
+
ref: v,
|
|
19
|
+
role: "img",
|
|
20
|
+
"aria-label": p ?? u?.name ?? R.name,
|
|
21
|
+
className: `cy-qr-code${c ? ` ${c}` : ""}`,
|
|
22
|
+
"data-size": typeof e == "number" ? void 0 : e,
|
|
23
|
+
"data-level": o,
|
|
24
|
+
style: l || d ? {
|
|
25
|
+
...l,
|
|
26
|
+
...d
|
|
27
|
+
} : void 0,
|
|
28
|
+
children: [/* @__PURE__ */ s("svg", {
|
|
29
|
+
className: "cy-reset cy-qr-code-svg",
|
|
30
|
+
viewBox: `0 0 ${i} ${i}`,
|
|
31
|
+
shapeRendering: "crispEdges",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
focusable: "false",
|
|
34
|
+
children: /* @__PURE__ */ s("path", {
|
|
35
|
+
className: "cy-reset cy-qr-code-modules",
|
|
36
|
+
d: x
|
|
37
|
+
})
|
|
38
|
+
}), n && /* @__PURE__ */ s("span", {
|
|
39
|
+
className: "cy-qr-code-icon",
|
|
40
|
+
children: r
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
Q as QRCode
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=QRCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QRCode.js","names":["qrMatrix","qrPath","forwardRef","useMemo","jsx","jsxs","DEFAULT_LABELS","QRCode","value","size","level","quietZone","label","labels","icon","className","style","ref","hasIcon","used","q","box","d","matrix","sizing"],"sources":["../../../src/components/QRCode/QRCode.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode, useMemo } from \"react\";\nimport { type QrLevel, qrMatrix, qrPath } from \"../../foundations/qr.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface QRCodeTokens {\n /** Colour of the dark modules. Default: the light palette's ink, in every colour mode. */\n color: string;\n /** Colour of the light modules and the quiet zone. Default: the light palette's surface, in every colour mode. */\n background: string;\n /** Width and height at `size=\"sm\"`. */\n sizeSm: string;\n /** Width and height at `size=\"md\"`. */\n sizeMd: string;\n /** Width and height at `size=\"lg\"`. */\n sizeLg: string;\n /** Width and height of the centred icon, as a share of the code's width. Keep it at 22% or less. */\n iconSize: string;\n /** Corner radius of the code, quiet zone included. */\n radius: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n qrCode: QRCodeTokens;\n }\n}\n\nexport interface QRCodeLabels {\n /** Accessible name when no `label` is given. Default \"QR code\". */\n name: string;\n}\n\nexport interface QRCodeProps {\n /** The text to encode, usually a URL. Numbers and upper-case text use the compact modes; anything else is UTF-8. */\n value: string;\n /** Width and height: `sm`, `md` (default) or `lg` from the tokens, or a number of pixels. */\n size?: Size | number;\n /**\n * Error correction: how much of the code can be damaged or covered and still scan (L 7%, M 15%, Q 25%, H 30%).\n * Higher levels need a denser code. Default \"M\"; always \"H\" with an `icon`.\n */\n level?: QrLevel;\n /** Light modules around the code, which scanners need to find it. The standard asks for 4. Default 4. */\n quietZone?: number;\n /** Accessible name. Default `labels.name` (\"QR code\"). Say where it leads, and show the link as text too. */\n label?: string;\n /** Built-in strings. */\n labels?: Partial<QRCodeLabels>;\n /**\n * A logo drawn in the centre, on the light colour (an `<Icon>` or a small image). It covers modules, so the level is\n * raised to H.\n */\n icon?: ReactNode;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through `--cy-qr-code-*` tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: QRCodeLabels = { name: \"QR code\" };\n\n/** A QR code drawn as one crisp SVG path, dark on light in every colour mode so phones can scan it. */\nexport const QRCode = forwardRef<HTMLDivElement, QRCodeProps>(function QRCode(\n { value, size = \"md\", level = \"M\", quietZone = 4, label, labels, icon, className, style },\n ref,\n) {\n const hasIcon = icon != null && icon !== false;\n const used = hasIcon ? \"H\" : level;\n const q = Math.max(0, Math.floor(quietZone));\n const { box, d } = useMemo(() => {\n const matrix = qrMatrix(value, { level: used });\n return { box: matrix.length + q * 2, d: qrPath(matrix, q) };\n }, [value, used, q]);\n const sizing = typeof size === \"number\" ? ({ \"--_size\": `${size}px` } as CSSProperties) : undefined;\n return (\n <div\n ref={ref}\n role=\"img\"\n aria-label={label ?? labels?.name ?? DEFAULT_LABELS.name}\n className={`cy-qr-code${className ? ` ${className}` : \"\"}`}\n data-size={typeof size === \"number\" ? undefined : size}\n data-level={used}\n style={sizing || style ? { ...sizing, ...style } : undefined}\n >\n <svg\n className=\"cy-reset cy-qr-code-svg\"\n viewBox={`0 0 ${box} ${box}`}\n shapeRendering=\"crispEdges\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path className=\"cy-reset cy-qr-code-modules\" d={d} />\n </svg>\n {hasIcon && <span className=\"cy-qr-code-icon\">{icon}</span>}\n </div>\n );\n});\n"],"mappings":";;;;AA2DA,IAAMM,IAA+B,EAAE,MAAM,UAAU,GAG1CC,IAASL,EAAwC,SAC5D,EAAE,OAAAM,GAAO,MAAAC,IAAO,MAAM,OAAAC,IAAQ,KAAK,WAAAC,IAAY,GAAG,OAAAC,GAAO,QAAAC,GAAQ,MAAAC,GAAM,WAAAC,GAAW,OAAAC,EAAA,GAClFC,GACA;AACA,QAAMC,IAAUJ,KAAQ,QAAQA,MAAS,IACnCK,IAAOD,IAAU,MAAMR,GACvBU,IAAI,KAAK,IAAI,GAAG,KAAK,MAAMT,CAAS,CAAC,GACrC,EAAE,KAAAU,GAAK,GAAAC,EAAA,IAAMnB,EAAA,MAAc;AAC/B,UAAMoB,IAASvB,EAASQ,GAAO,EAAE,OAAOW,EAAK,CAAC;AAC9C,WAAO;AAAA,MAAE,KAAKI,EAAO,SAASH,IAAI;AAAA,MAAG,GAAGnB,EAAOsB,GAAQH,CAAC;AAAA,IAAE;AAAA,EAC5D,GAAG;AAAA,IAACZ;AAAA,IAAOW;AAAA,IAAMC;AAAA,EAAC,CAAC,GACbI,IAAS,OAAOf,KAAS,WAAY,EAAE,WAAW,GAAGA,CAAA,KAAS,IAAsB;AAC1F,SACE,gBAAAJ,EAAC,OAAD;AAAA,IACO,KAAAY;AAAA,IACL,MAAK;AAAA,IACL,cAAYL,KAASC,GAAQ,QAAQP,EAAe;AAAA,IACpD,WAAW,aAAaS,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACtD,aAAW,OAAON,KAAS,WAAW,SAAYA;AAAA,IAClD,cAAYU;AAAA,IACZ,OAAOK,KAAUR,IAAQ;AAAA,MAAE,GAAGQ;AAAA,MAAQ,GAAGR;AAAA,IAAM,IAAI;AAAA,IAPrD,UAAA,CASE,gBAAAZ,EAAC,OAAD;AAAA,MACE,WAAU;AAAA,MACV,SAAS,OAAOiB,CAAA,IAAOA,CAAA;AAAA,MACvB,gBAAe;AAAA,MACf,eAAY;AAAA,MACZ,WAAU;AAAA,MAEV,UAAA,gBAAAjB,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAiC,GAAAkB;AAAA,MAAI,CAAA;AAAA,IAClD,CAAA,GACJJ,KAAW,gBAAAd,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAmB,UAAAU;AAAA,IAAW,CAAA,CACvD;AAAA,E;AAET,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { QRCode, type QRCodeLabels, type QRCodeProps, type QRCodeTokens } from "./QRCode.js";
|
|
@@ -7,22 +7,35 @@ export interface RadioOption {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface RadioGroupProps {
|
|
10
|
+
/** Names the group, shown above the options. */
|
|
10
11
|
label: ReactNode;
|
|
11
12
|
/** Visually hide the label (it still names the control). Prefer visible labels. */
|
|
12
13
|
labelHidden?: boolean | undefined;
|
|
14
|
+
/** Help text shown below the options. */
|
|
13
15
|
description?: ReactNode;
|
|
16
|
+
/** Error message shown below the options and announced. */
|
|
14
17
|
error?: ReactNode;
|
|
18
|
+
/** The choices: `{ value, label, description?, disabled? }`. */
|
|
15
19
|
options: RadioOption[];
|
|
16
20
|
/** Native group name (generated when omitted). */
|
|
17
21
|
name?: string;
|
|
22
|
+
/** Controlled selected value. */
|
|
18
23
|
value?: string;
|
|
24
|
+
/** Selected value at first, when uncontrolled. */
|
|
19
25
|
defaultValue?: string | undefined;
|
|
26
|
+
/** Called with the option's value when it is chosen. */
|
|
20
27
|
onChange?: (value: string) => void;
|
|
28
|
+
/** Stack the options, or lay them in a row that wraps. Default "vertical". */
|
|
21
29
|
orientation?: "vertical" | "horizontal";
|
|
30
|
+
/** The form will not submit until an option is chosen; also draws the required marker. */
|
|
22
31
|
required?: boolean;
|
|
32
|
+
/** Disables every option. */
|
|
23
33
|
disabled?: boolean;
|
|
34
|
+
/** Size of the radios and their text. Default "md". */
|
|
24
35
|
size?: Size;
|
|
36
|
+
/** Colour of the chosen radio. Default "accent". */
|
|
25
37
|
tone?: Tone;
|
|
38
|
+
/** Added to the root element, for layout. */
|
|
26
39
|
className?: string;
|
|
27
40
|
/** Layout only. */
|
|
28
41
|
style?: CSSProperties;
|
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { ChoiceBase as N } from "../../foundations/ChoiceBase/ChoiceBase.js";
|
|
3
|
+
import { Choice as k } from "../Choice/Choice.js";
|
|
4
|
+
import { Field as x } from "../Field/Field.js";
|
|
5
|
+
import { useId as j } from "react";
|
|
5
6
|
import { jsx as a } from "react/jsx-runtime";
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
return /* @__PURE__ */ a(
|
|
7
|
+
function $({ label: i, labelHidden: l, description: t, error: m, options: u, name: n, value: c, defaultValue: s, onChange: p, orientation: h = "vertical", required: o, disabled: v, size: r = "md", tone: f = "accent", className: g, style: b }) {
|
|
8
|
+
const y = j(), C = n ?? `cy-radio-${y}`;
|
|
9
|
+
return /* @__PURE__ */ a(x, {
|
|
9
10
|
group: !0,
|
|
10
|
-
label:
|
|
11
|
-
labelHidden:
|
|
12
|
-
description:
|
|
13
|
-
error:
|
|
14
|
-
required:
|
|
15
|
-
size:
|
|
11
|
+
label: i,
|
|
12
|
+
labelHidden: l,
|
|
13
|
+
description: t,
|
|
14
|
+
error: m,
|
|
15
|
+
required: o,
|
|
16
|
+
size: r,
|
|
16
17
|
className: g,
|
|
17
|
-
style:
|
|
18
|
+
style: b,
|
|
18
19
|
children: () => /* @__PURE__ */ a("div", {
|
|
19
20
|
className: "cy-radio-group",
|
|
20
|
-
"data-orientation":
|
|
21
|
-
children:
|
|
22
|
-
kind: "radio",
|
|
21
|
+
"data-orientation": h,
|
|
22
|
+
children: u.map((e) => /* @__PURE__ */ a(k, {
|
|
23
23
|
label: e.label,
|
|
24
24
|
description: e.description,
|
|
25
|
-
name:
|
|
25
|
+
name: C,
|
|
26
26
|
value: e.value,
|
|
27
|
-
required:
|
|
28
|
-
disabled:
|
|
29
|
-
size:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
required: o,
|
|
28
|
+
disabled: v || e.disabled,
|
|
29
|
+
size: r,
|
|
30
|
+
...c !== void 0 ? { checked: c === e.value } : { defaultChecked: s === e.value },
|
|
31
|
+
onChange: (d) => d && p?.(e.value),
|
|
32
|
+
control: (d) => /* @__PURE__ */ a("span", {
|
|
33
|
+
className: "cy-radio-group-radio",
|
|
34
|
+
"data-size": r,
|
|
35
|
+
"data-tone": f,
|
|
36
|
+
children: /* @__PURE__ */ a(N, {
|
|
37
|
+
...d,
|
|
38
|
+
type: "radio"
|
|
39
|
+
})
|
|
40
|
+
})
|
|
33
41
|
}, e.value))
|
|
34
42
|
})
|
|
35
43
|
});
|
|
36
44
|
}
|
|
37
45
|
export {
|
|
38
|
-
|
|
46
|
+
$ as RadioGroup
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","names":["
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","names":["ChoiceBase","Choice","Field","useId","jsx","RadioGroup","label","labelHidden","description","error","options","name","value","defaultValue","onChange","orientation","required","disabled","size","tone","className","style","generated","groupName","option","checked","input"],"sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useId } from \"react\";\nimport { ChoiceBase } from \"../../foundations/ChoiceBase/ChoiceBase.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\nimport { Choice } from \"../Choice/Choice.js\";\nimport { Field } from \"../Field/Field.js\";\n\nexport interface RadioOption {\n value: string;\n label: ReactNode;\n description?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface RadioGroupProps {\n /** Names the group, shown above the options. */\n label: ReactNode;\n /** Visually hide the label (it still names the control). Prefer visible labels. */\n labelHidden?: boolean | undefined;\n /** Help text shown below the options. */\n description?: ReactNode;\n /** Error message shown below the options and announced. */\n error?: ReactNode;\n /** The choices: `{ value, label, description?, disabled? }`. */\n options: RadioOption[];\n /** Native group name (generated when omitted). */\n name?: string;\n /** Controlled selected value. */\n value?: string;\n /** Selected value at first, when uncontrolled. */\n defaultValue?: string | undefined;\n /** Called with the option's value when it is chosen. */\n onChange?: (value: string) => void;\n /** Stack the options, or lay them in a row that wraps. Default \"vertical\". */\n orientation?: \"vertical\" | \"horizontal\";\n /** The form will not submit until an option is chosen; also draws the required marker. */\n required?: boolean;\n /** Disables every option. */\n disabled?: boolean;\n /** Size of the radios and their text. Default \"md\". */\n size?: Size;\n /** Colour of the chosen radio. Default \"accent\". */\n tone?: Tone;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** One choice from a list, on native radios: arrows, wrap, disabled skipping, RTL, forms and reset are native. */\nexport function RadioGroup({\n label,\n labelHidden,\n description,\n error,\n options,\n name,\n value,\n defaultValue,\n onChange,\n orientation = \"vertical\",\n required,\n disabled,\n size = \"md\",\n tone = \"accent\",\n className,\n style,\n}: RadioGroupProps) {\n const generated = useId();\n const groupName = name ?? `cy-radio-${generated}`;\n return (\n <Field\n group\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error}\n required={required}\n size={size}\n className={className}\n style={style}\n >\n {() => (\n <div className=\"cy-radio-group\" data-orientation={orientation}>\n {options.map((option) => (\n <Choice\n key={option.value}\n label={option.label}\n description={option.description}\n name={groupName}\n value={option.value}\n required={required}\n disabled={disabled || option.disabled}\n size={size}\n {...(value !== undefined\n ? { checked: value === option.value }\n : { defaultChecked: defaultValue === option.value })}\n onChange={(checked) => checked && onChange?.(option.value)}\n control={(input) => (\n <span className=\"cy-radio-group-radio\" data-size={size} data-tone={tone}>\n <ChoiceBase {...input} type=\"radio\" />\n </span>\n )}\n />\n ))}\n </div>\n )}\n </Field>\n );\n}\n"],"mappings":";;;;;;AAiDA,SAAgBK,EAAW,EACzB,OAAAC,GACA,aAAAC,GACA,aAAAC,GACA,OAAAC,GACA,SAAAC,GACA,MAAAC,GACA,OAAAC,GACA,cAAAC,GACA,UAAAC,GACA,aAAAC,IAAc,YACd,UAAAC,GACA,UAAAC,GACA,MAAAC,IAAO,MACP,MAAAC,IAAO,UACP,WAAAC,GACA,OAAAC,EAAA,GACkB;AAClB,QAAMC,IAAYnB,EAAM,GAClBoB,IAAYZ,KAAQ,YAAYW,CAAA;AACtC,SACE,gBAAAlB,EAACF,GAAD;AAAA,IACE,OAAA;AAAA,IACO,OAAAI;AAAA,IACM,aAAAC;AAAA,IACA,aAAAC;AAAA,IACN,OAAAC;AAAA,IACG,UAAAO;AAAA,IACJ,MAAAE;AAAA,IACK,WAAAE;AAAA,IACJ,OAAAC;AAAA,IAGL,UAAA,MAAA,gBAAAjB,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAiB,oBAAkBW;AAAA,MAC/C,UAAAL,EAAQ,IAAA,CAAKc,MACZ,gBAAApB,EAACH,GAAD;AAAA,QAEE,OAAOuB,EAAO;AAAA,QACd,aAAaA,EAAO;AAAA,QACpB,MAAMD;AAAA,QACN,OAAOC,EAAO;AAAA,QACJ,UAAAR;AAAA,QACV,UAAUC,KAAYO,EAAO;AAAA,QACvB,MAAAN;AAAA,QACN,GAAKN,MAAU,SACX,EAAE,SAASA,MAAUY,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