@arshad-shah/cynosure 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/adapters/astro/index.d.ts +53 -0
- package/dist/adapters/astro/index.js +27 -0
- package/dist/adapters/astro/index.js.map +1 -0
- package/dist/adapters/vite/index.d.ts +11 -0
- package/dist/adapters/vite/index.js +33 -12
- package/dist/adapters/vite/index.js.map +1 -1
- package/dist/brands/googleplay.d.ts +2 -0
- package/dist/brands/googleplay.js +17 -0
- package/dist/brands/googleplay.js.map +1 -0
- package/dist/brands/index.d.ts +1 -0
- package/dist/brands/index.js +132 -130
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Accordion/Accordion.js +26 -26
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Announcer/Announcer.d.ts +2 -1
- package/dist/components/Announcer/Announcer.js +32 -34
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.js +41 -41
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Avatar/Avatar.js +20 -20
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Badge/Badge.d.ts +19 -5
- package/dist/components/Badge/Badge.js +19 -13
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Button/Button.d.ts +30 -6
- package/dist/components/Button/Button.js +50 -42
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.js +158 -161
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Calendar/dates.js +42 -38
- package/dist/components/Calendar/dates.js.map +1 -1
- package/dist/components/Card/Card.d.ts +22 -2
- package/dist/components/Card/Card.js +60 -52
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/ChatMessage/ChatMessage.d.ts +55 -0
- package/dist/components/ChatMessage/ChatMessage.js +50 -0
- package/dist/components/ChatMessage/ChatMessage.js.map +1 -0
- package/dist/components/ChatMessage/index.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +4 -4
- package/dist/components/Checkbox/Checkbox.js +33 -8
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checklist/Checklist.js +21 -21
- package/dist/components/Checklist/Checklist.js.map +1 -1
- package/dist/components/Choice/Choice.d.ts +73 -0
- package/dist/components/Choice/Choice.js +41 -0
- package/dist/components/Choice/Choice.js.map +1 -0
- package/dist/components/Choice/index.d.ts +1 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +6 -1
- package/dist/components/CodeBlock/CodeBlock.js +40 -37
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/ColorField/ColorField.d.ts +3 -2
- package/dist/components/ColorField/ColorField.js +202 -212
- package/dist/components/ColorField/ColorField.js.map +1 -1
- package/dist/components/ColorField/read-color.js +5 -6
- package/dist/components/ColorField/read-color.js.map +1 -1
- package/dist/components/ColorSwatches/ColorSwatches.js +42 -33
- package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts +13 -2
- package/dist/components/Combobox/Combobox.js +118 -129
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.d.ts +14 -1
- package/dist/components/CommandPalette/CommandPalette.js +153 -109
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/components/CommandPalette/index.d.ts +1 -1
- package/dist/components/CompareSlider/CompareSlider.js +14 -14
- package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
- package/dist/components/Container/Container.d.ts +2 -2
- package/dist/components/Container/Container.js +17 -13
- package/dist/components/Container/Container.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.d.ts +27 -13
- package/dist/components/ContextMenu/ContextMenu.js +64 -46
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.js +41 -41
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DataGrid/DataGrid.d.ts +135 -0
- package/dist/components/DataGrid/DataGrid.js +385 -0
- package/dist/components/DataGrid/DataGrid.js.map +1 -0
- package/dist/components/DataGrid/index.d.ts +1 -0
- package/dist/components/DateField/DateField.d.ts +4 -3
- package/dist/components/DateField/DateField.js +70 -59
- package/dist/components/DateField/DateField.js.map +1 -1
- package/dist/components/DeviceFrame/DeviceFrame.d.ts +63 -0
- package/dist/components/DeviceFrame/DeviceFrame.js +54 -0
- package/dist/components/DeviceFrame/DeviceFrame.js.map +1 -0
- package/dist/components/DeviceFrame/index.d.ts +1 -0
- package/dist/components/Dialog/Dialog.d.ts +10 -1
- package/dist/components/Dialog/Dialog.js +82 -81
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Disclosure/Disclosure.d.ts +15 -1
- package/dist/components/Disclosure/Disclosure.js +37 -30
- package/dist/components/Disclosure/Disclosure.js.map +1 -1
- package/dist/components/DocumentViewport/DocumentViewport.js +54 -57
- package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +5 -2
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +59 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js +53 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js.map +1 -0
- package/dist/components/ErrorBoundary/index.d.ts +1 -0
- package/dist/components/Field/Field.d.ts +38 -5
- package/dist/components/Field/Field.js +48 -42
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/Field/index.d.ts +1 -1
- package/dist/components/FileDrop/FileDrop.d.ts +26 -1
- package/dist/components/FileDrop/FileDrop.js +150 -99
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.js +80 -77
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +32 -11
- package/dist/components/Grid/Grid.js +78 -48
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/index.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +4 -2
- package/dist/components/Heading/Heading.js.map +1 -1
- package/dist/components/HighlightedText/HighlightedText.d.ts +40 -0
- package/dist/components/HighlightedText/HighlightedText.js +36 -0
- package/dist/components/HighlightedText/HighlightedText.js.map +1 -0
- package/dist/components/HighlightedText/index.d.ts +2 -0
- package/dist/components/HotkeyField/HotkeyField.d.ts +84 -0
- package/dist/components/HotkeyField/HotkeyField.js +161 -0
- package/dist/components/HotkeyField/HotkeyField.js.map +1 -0
- package/dist/components/HotkeyField/index.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.js +6 -6
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +16 -1
- package/dist/components/IconButton/IconButton.js +20 -15
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/IconTile/IconTile.d.ts +45 -0
- package/dist/components/IconTile/IconTile.js +25 -0
- package/dist/components/IconTile/IconTile.js.map +1 -0
- package/dist/components/IconTile/index.d.ts +1 -0
- package/dist/components/Image/Image.js.map +1 -1
- package/dist/components/Inline/Inline.d.ts +3 -3
- package/dist/components/Inline/Inline.js +12 -22
- package/dist/components/Inline/Inline.js.map +1 -1
- package/dist/components/Kbd/Kbd.d.ts +0 -2
- package/dist/components/Kbd/Kbd.js +16 -22
- package/dist/components/Kbd/Kbd.js.map +1 -1
- package/dist/components/KeyValueEditor/KeyValueEditor.js +37 -36
- package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
- package/dist/components/KeyValueEditor/bulk.js +3 -4
- package/dist/components/KeyValueEditor/bulk.js.map +1 -1
- package/dist/components/Link/Link.d.ts +9 -1
- package/dist/components/Link/Link.js +20 -18
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/List/List.d.ts +73 -0
- package/dist/components/List/List.js +64 -0
- package/dist/components/List/List.js.map +1 -0
- package/dist/components/List/index.d.ts +1 -0
- package/dist/components/ListRow/ListRow.d.ts +105 -0
- package/dist/components/ListRow/ListRow.js +164 -0
- package/dist/components/ListRow/ListRow.js.map +1 -0
- package/dist/components/ListRow/index.d.ts +1 -0
- package/dist/components/LoadingDots/LoadingDots.d.ts +7 -2
- package/dist/components/LoadingDots/LoadingDots.js +28 -18
- package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts +29 -11
- package/dist/components/Menu/Menu.js +204 -111
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Menubar/Menubar.d.ts +40 -0
- package/dist/components/Menubar/Menubar.js +82 -0
- package/dist/components/Menubar/Menubar.js.map +1 -0
- package/dist/components/Menubar/index.d.ts +1 -0
- package/dist/components/Notice/Notice.d.ts +11 -2
- package/dist/components/Notice/Notice.js +31 -27
- package/dist/components/Notice/Notice.js.map +1 -1
- package/dist/components/NumberField/NumberField.d.ts +8 -3
- package/dist/components/NumberField/NumberField.js +151 -100
- package/dist/components/NumberField/NumberField.js.map +1 -1
- package/dist/components/OptionList/OptionList.d.ts +102 -0
- package/dist/components/OptionList/OptionList.js +98 -0
- package/dist/components/OptionList/OptionList.js.map +1 -0
- package/dist/components/OptionList/index.d.ts +1 -0
- package/dist/components/OverlayFrame/OverlayFrame.d.ts +33 -0
- package/dist/components/OverlayFrame/OverlayFrame.js +20 -0
- package/dist/components/OverlayFrame/OverlayFrame.js.map +1 -0
- package/dist/components/OverlayFrame/index.d.ts +1 -0
- package/dist/components/PageHeader/PageHeader.d.ts +6 -0
- package/dist/components/PageHeader/PageHeader.js +27 -27
- package/dist/components/PageHeader/PageHeader.js.map +1 -1
- package/dist/components/Pagination/Pagination.js +31 -30
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +71 -4
- package/dist/components/PanZoomCanvas/PanZoomCanvas.js +197 -141
- package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
- package/dist/components/PanZoomCanvas/index.d.ts +1 -1
- package/dist/components/PathField/PathField.d.ts +68 -0
- package/dist/components/PathField/PathField.js +67 -0
- package/dist/components/PathField/PathField.js.map +1 -0
- package/dist/components/PathField/index.d.ts +1 -0
- package/dist/components/Popover/Popover.d.ts +16 -3
- package/dist/components/Popover/Popover.js +51 -42
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +4 -3
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/QRCode/QRCode.d.ts +56 -0
- package/dist/components/QRCode/QRCode.js +48 -0
- package/dist/components/QRCode/QRCode.js.map +1 -0
- package/dist/components/QRCode/index.d.ts +1 -0
- package/dist/components/RadioGroup/RadioGroup.js +32 -24
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/RowActions/RowActions.d.ts +35 -0
- package/dist/components/RowActions/RowActions.js +38 -0
- package/dist/components/RowActions/RowActions.js.map +1 -0
- package/dist/components/RowActions/index.d.ts +1 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +55 -0
- package/dist/components/ScrollArea/ScrollArea.js +55 -0
- package/dist/components/ScrollArea/ScrollArea.js.map +1 -0
- package/dist/components/ScrollArea/index.d.ts +1 -0
- package/dist/components/SearchField/SearchField.d.ts +17 -0
- package/dist/components/SearchField/SearchField.js +31 -17
- package/dist/components/SearchField/SearchField.js.map +1 -1
- package/dist/components/SearchField/index.d.ts +1 -1
- package/dist/components/Section/Section.d.ts +57 -0
- package/dist/components/Section/Section.js +27 -0
- package/dist/components/Section/Section.js.map +1 -0
- package/dist/components/Section/index.d.ts +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +6 -3
- package/dist/components/SegmentedControl/SegmentedControl.js +24 -20
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.d.ts +22 -6
- package/dist/components/Select/Select.js +155 -156
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/SelectionFrame/frame-math.js +19 -20
- package/dist/components/SelectionFrame/frame-math.js.map +1 -1
- package/dist/components/Sheet/Sheet.js +12 -7
- package/dist/components/Sheet/Sheet.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +13 -1
- package/dist/components/SideNav/SideNav.js +100 -91
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.js +63 -62
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/SignaturePad/ink.js +0 -1
- package/dist/components/SignaturePad/ink.js.map +1 -1
- package/dist/components/SiteFooter/SiteFooter.d.ts +66 -0
- package/dist/components/SiteFooter/SiteFooter.js +80 -0
- package/dist/components/SiteFooter/SiteFooter.js.map +1 -0
- package/dist/components/SiteFooter/index.d.ts +1 -0
- package/dist/components/SiteHeader/SiteHeader.d.ts +78 -0
- package/dist/components/SiteHeader/SiteHeader.js +114 -0
- package/dist/components/SiteHeader/SiteHeader.js.map +1 -0
- package/dist/components/SiteHeader/index.d.ts +1 -0
- package/dist/components/SkipLink/SkipLink.d.ts +42 -0
- package/dist/components/SkipLink/SkipLink.js +43 -0
- package/dist/components/SkipLink/SkipLink.js.map +1 -0
- package/dist/components/SkipLink/index.d.ts +1 -0
- package/dist/components/Slider/Slider.js +88 -91
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/SortButton/SortButton.d.ts +36 -0
- package/dist/components/SortButton/SortButton.js +35 -0
- package/dist/components/SortButton/SortButton.js.map +1 -0
- package/dist/components/SortButton/index.d.ts +1 -0
- package/dist/components/SortableList/SortableList.js +146 -120
- package/dist/components/SortableList/SortableList.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +32 -12
- package/dist/components/SplitPane/SplitPane.js +105 -59
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +16 -7
- package/dist/components/Stack/Stack.js +32 -18
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -1
- package/dist/components/Stat/Stat.d.ts +88 -0
- package/dist/components/Stat/Stat.js +105 -0
- package/dist/components/Stat/Stat.js.map +1 -0
- package/dist/components/Stat/index.d.ts +1 -0
- package/dist/components/StatusBar/StatusBar.d.ts +95 -0
- package/dist/components/StatusBar/StatusBar.js +110 -0
- package/dist/components/StatusBar/StatusBar.js.map +1 -0
- package/dist/components/StatusBar/index.d.ts +1 -0
- package/dist/components/Steps/Steps.d.ts +10 -4
- package/dist/components/Steps/Steps.js +31 -30
- package/dist/components/Steps/Steps.js.map +1 -1
- package/dist/components/Switch/Switch.d.ts +4 -4
- package/dist/components/Switch/Switch.js +18 -7
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Table/Table.d.ts +6 -6
- package/dist/components/Table/Table.js +73 -102
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +55 -6
- package/dist/components/Tabs/Tabs.js +288 -169
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.d.ts +10 -2
- package/dist/components/TagInput/TagInput.js +137 -148
- package/dist/components/TagInput/TagInput.js.map +1 -1
- package/dist/components/Text/Text.d.ts +6 -0
- package/dist/components/Text/Text.js +18 -17
- package/dist/components/Text/Text.js.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +37 -6
- package/dist/components/TextArea/TextArea.js +200 -72
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/TextField/TextField.d.ts +22 -6
- package/dist/components/TextField/TextField.js +59 -53
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +7 -1
- package/dist/components/ThemeToggle/ThemeToggle.js +33 -30
- package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
- package/dist/components/TimeField/TimeField.d.ts +4 -3
- package/dist/components/TimeField/TimeField.js +197 -183
- package/dist/components/TimeField/TimeField.js.map +1 -1
- package/dist/components/TitleBar/TitleBar.d.ts +91 -0
- package/dist/components/TitleBar/TitleBar.js +80 -0
- package/dist/components/TitleBar/TitleBar.js.map +1 -0
- package/dist/components/TitleBar/index.d.ts +1 -0
- package/dist/components/Toast/Toast.d.ts +17 -2
- package/dist/components/Toast/Toast.js +166 -147
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/Toolbar/Toolbar.js +11 -12
- package/dist/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +23 -1
- package/dist/components/Tooltip/Tooltip.js +50 -31
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +92 -11
- package/dist/components/Tree/Tree.js +332 -164
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.d.ts +27 -4
- package/dist/components/VirtualList/VirtualList.js +179 -145
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualList/index.d.ts +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +17 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/components/VisuallyHidden/index.d.ts +1 -0
- package/dist/components/ZoomControls/ZoomControls.d.ts +6 -2
- package/dist/components/ZoomControls/ZoomControls.js +37 -37
- package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
- package/dist/entries/tokens.js +22 -16
- package/dist/foundations/ChoiceBase/ChoiceBase.js +15 -13
- package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
- package/dist/foundations/HiddenValue/HiddenValue.js +5 -5
- package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
- package/dist/foundations/Icon/Icon.d.ts +6 -1
- package/dist/foundations/Icon/Icon.js +15 -14
- package/dist/foundations/Icon/Icon.js.map +1 -1
- package/dist/foundations/LiveRegion/LiveRegion.d.ts +33 -0
- package/dist/foundations/LiveRegion/LiveRegion.js +29 -0
- package/dist/foundations/LiveRegion/LiveRegion.js.map +1 -0
- package/dist/foundations/LiveRegion/index.d.ts +1 -0
- package/dist/foundations/canvas-size.d.ts +14 -0
- package/dist/foundations/canvas-size.js +32 -0
- package/dist/foundations/canvas-size.js.map +1 -0
- package/dist/foundations/dir.js +0 -1
- package/dist/foundations/dir.js.map +1 -1
- package/dist/foundations/draft.d.ts +14 -0
- package/dist/foundations/draft.js +22 -0
- package/dist/foundations/draft.js.map +1 -0
- package/dist/foundations/edge.d.ts +20 -0
- package/dist/foundations/edge.js +26 -0
- package/dist/foundations/edge.js.map +1 -0
- package/dist/foundations/focus.d.ts +5 -0
- package/dist/foundations/focus.js +10 -0
- package/dist/foundations/focus.js.map +1 -0
- package/dist/foundations/hotkey.d.ts +23 -1
- package/dist/foundations/hotkey.js +48 -26
- package/dist/foundations/hotkey.js.map +1 -1
- package/dist/foundations/icon-size.d.ts +7 -0
- package/dist/foundations/icon-size.js +6 -0
- package/dist/foundations/icon-size.js.map +1 -0
- package/dist/foundations/image-outcome.d.ts +8 -3
- package/dist/foundations/image-outcome.js +12 -8
- package/dist/foundations/image-outcome.js.map +1 -1
- package/dist/foundations/keys.js +12 -13
- package/dist/foundations/keys.js.map +1 -1
- package/dist/foundations/layout.d.ts +81 -0
- package/dist/foundations/layout.js +29 -0
- package/dist/foundations/layout.js.map +1 -0
- package/dist/foundations/listbox.d.ts +47 -2
- package/dist/foundations/listbox.js +56 -25
- package/dist/foundations/listbox.js.map +1 -1
- package/dist/foundations/math.d.ts +25 -0
- package/dist/foundations/math.js +14 -3
- package/dist/foundations/math.js.map +1 -1
- package/dist/foundations/media-query.d.ts +5 -0
- package/dist/foundations/media-query.js +14 -0
- package/dist/foundations/media-query.js.map +1 -0
- package/dist/foundations/motion.d.ts +12 -0
- package/dist/foundations/motion.js +21 -0
- package/dist/foundations/motion.js.map +1 -0
- package/dist/foundations/option-icon.d.ts +3 -1
- package/dist/foundations/option-icon.js +6 -6
- package/dist/foundations/option-icon.js.map +1 -1
- package/dist/foundations/printing.d.ts +6 -0
- package/dist/foundations/printing.js +17 -0
- package/dist/foundations/printing.js.map +1 -0
- package/dist/foundations/qr.d.ts +42 -0
- package/dist/foundations/qr.js +245 -0
- package/dist/foundations/qr.js.map +1 -0
- package/dist/foundations/refs.d.ts +8 -0
- package/dist/foundations/refs.js +14 -0
- package/dist/foundations/refs.js.map +1 -0
- package/dist/foundations/reorder.js +5 -6
- package/dist/foundations/reorder.js.map +1 -1
- package/dist/foundations/roving-focus.d.ts +10 -0
- package/dist/foundations/roving-focus.js +34 -31
- package/dist/foundations/roving-focus.js.map +1 -1
- package/dist/foundations/scroll-align.d.ts +11 -0
- package/dist/foundations/scroll-align.js +8 -0
- package/dist/foundations/scroll-align.js.map +1 -0
- package/dist/foundations/sort.d.ts +13 -0
- package/dist/foundations/sort.js +26 -0
- package/dist/foundations/sort.js.map +1 -0
- package/dist/foundations/text-match.d.ts +11 -0
- package/dist/foundations/text-match.js +20 -0
- package/dist/foundations/text-match.js.map +1 -0
- package/dist/foundations/tone-icons.js +4 -5
- package/dist/foundations/tone-icons.js.map +1 -1
- package/dist/foundations/use-follow.d.ts +29 -0
- package/dist/foundations/use-follow.js +51 -0
- package/dist/foundations/use-follow.js.map +1 -0
- package/dist/foundations/virtual-window.d.ts +22 -5
- package/dist/foundations/virtual-window.js +58 -54
- package/dist/foundations/virtual-window.js.map +1 -1
- package/dist/foundations/zoom-gestures.d.ts +23 -1
- package/dist/foundations/zoom-gestures.js +123 -84
- package/dist/foundations/zoom-gestures.js.map +1 -1
- package/dist/foundations/zoom.d.ts +10 -4
- package/dist/foundations/zoom.js +16 -17
- package/dist/foundations/zoom.js.map +1 -1
- package/dist/icons/book-marked.d.ts +2 -0
- package/dist/icons/book-marked.js +14 -0
- package/dist/icons/book-marked.js.map +1 -0
- package/dist/icons/boxes.d.ts +2 -0
- package/dist/icons/boxes.js +34 -0
- package/dist/icons/boxes.js.map +1 -0
- package/dist/icons/by-name.d.ts +11 -0
- package/dist/icons/by-name.js +11 -0
- package/dist/icons/by-name.js.map +1 -0
- package/dist/icons/cable.d.ts +2 -0
- package/dist/icons/cable.js +14 -0
- package/dist/icons/cable.js.map +1 -0
- package/dist/icons/calendar-days.d.ts +2 -0
- package/dist/icons/calendar-days.js +24 -0
- package/dist/icons/calendar-days.js.map +1 -0
- package/dist/icons/check-check.d.ts +2 -0
- package/dist/icons/check-check.js +17 -0
- package/dist/icons/check-check.js.map +1 -0
- package/dist/icons/check-square.d.ts +2 -0
- package/dist/icons/check-square.js +14 -0
- package/dist/icons/check-square.js.map +1 -0
- package/dist/icons/clipboard-paste.d.ts +2 -0
- package/dist/icons/clipboard-paste.js +30 -0
- package/dist/icons/clipboard-paste.js.map +1 -0
- package/dist/icons/crescent.d.ts +2 -0
- package/dist/icons/crescent.js +14 -0
- package/dist/icons/crescent.js.map +1 -0
- package/dist/icons/facet.d.ts +274 -0
- package/dist/icons/facet.js +830 -0
- package/dist/icons/facet.js.map +1 -0
- package/dist/icons/file-plus.d.ts +2 -0
- package/dist/icons/file-plus.js +14 -0
- package/dist/icons/file-plus.js.map +1 -0
- package/dist/icons/file-question.d.ts +2 -0
- package/dist/icons/file-question.js +14 -0
- package/dist/icons/file-question.js.map +1 -0
- package/dist/icons/file-search.d.ts +2 -0
- package/dist/icons/file-search.js +24 -0
- package/dist/icons/file-search.js.map +1 -0
- package/dist/icons/function.d.ts +2 -0
- package/dist/icons/function.js +20 -0
- package/dist/icons/function.js.map +1 -0
- package/dist/icons/gauge.d.ts +2 -0
- package/dist/icons/gauge.js +14 -0
- package/dist/icons/gauge.js.map +1 -0
- package/dist/icons/hourglass.d.ts +2 -0
- package/dist/icons/hourglass.js +14 -0
- package/dist/icons/hourglass.js.map +1 -0
- package/dist/icons/index.d.ts +1 -240
- package/dist/icons/index.js +546 -478
- package/dist/icons/kaaba.d.ts +2 -0
- package/dist/icons/kaaba.js +14 -0
- package/dist/icons/kaaba.js.map +1 -0
- package/dist/icons/keywords.d.ts +35 -1
- package/dist/icons/keywords.js +274 -1
- package/dist/icons/keywords.js.map +1 -1
- package/dist/icons/languages.d.ts +2 -0
- package/dist/icons/languages.js +14 -0
- package/dist/icons/languages.js.map +1 -0
- package/dist/icons/list-tree.d.ts +2 -0
- package/dist/icons/list-tree.js +14 -0
- package/dist/icons/list-tree.js.map +1 -0
- package/dist/icons/loader.d.ts +2 -0
- package/dist/icons/loader.js +14 -0
- package/dist/icons/loader.js.map +1 -0
- package/dist/icons/monitor-down.d.ts +2 -0
- package/dist/icons/monitor-down.js +24 -0
- package/dist/icons/monitor-down.js.map +1 -0
- package/dist/icons/mosque.d.ts +2 -0
- package/dist/icons/mosque.js +14 -0
- package/dist/icons/mosque.js.map +1 -0
- package/dist/icons/panel-right.d.ts +2 -0
- package/dist/icons/panel-right.js +20 -0
- package/dist/icons/panel-right.js.map +1 -0
- package/dist/icons/party-popper.d.ts +2 -0
- package/dist/icons/party-popper.js +14 -0
- package/dist/icons/party-popper.js.map +1 -0
- package/dist/icons/power-off.d.ts +2 -0
- package/dist/icons/power-off.js +14 -0
- package/dist/icons/power-off.js.map +1 -0
- package/dist/icons/prayer-beads.d.ts +2 -0
- package/dist/icons/prayer-beads.js +67 -0
- package/dist/icons/prayer-beads.js.map +1 -0
- package/dist/icons/qr-code.d.ts +2 -0
- package/dist/icons/qr-code.js +38 -0
- package/dist/icons/qr-code.js.map +1 -0
- package/dist/icons/refresh-cw.d.ts +2 -0
- package/dist/icons/refresh-cw.js +14 -0
- package/dist/icons/refresh-cw.js.map +1 -0
- package/dist/icons/rocket.d.ts +2 -0
- package/dist/icons/rocket.js +21 -0
- package/dist/icons/rocket.js.map +1 -0
- package/dist/icons/rows.d.ts +2 -0
- package/dist/icons/rows.js +20 -0
- package/dist/icons/rows.js.map +1 -0
- package/dist/icons/scissors.d.ts +2 -0
- package/dist/icons/scissors.js +26 -0
- package/dist/icons/scissors.js.map +1 -0
- package/dist/icons/shield-question.d.ts +2 -0
- package/dist/icons/shield-question.js +14 -0
- package/dist/icons/shield-question.js.map +1 -0
- package/dist/icons/square-plus.d.ts +2 -0
- package/dist/icons/square-plus.js +20 -0
- package/dist/icons/square-plus.js.map +1 -0
- package/dist/icons/text-select.d.ts +2 -0
- package/dist/icons/text-select.js +14 -0
- package/dist/icons/text-select.js.map +1 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/icons/types.js +2 -1
- package/dist/icons/types.js.map +1 -1
- package/dist/icons/window-maximize.d.ts +2 -0
- package/dist/icons/window-maximize.js +14 -0
- package/dist/icons/window-maximize.js.map +1 -0
- package/dist/icons/window-restore.d.ts +2 -0
- package/dist/icons/window-restore.js +20 -0
- package/dist/icons/window-restore.js.map +1 -0
- package/dist/index.d.ts +38 -9
- package/dist/index.js +326 -249
- package/dist/overlay/dismiss.js +15 -13
- package/dist/overlay/dismiss.js.map +1 -1
- package/dist/overlay/floating.d.ts +7 -2
- package/dist/overlay/floating.js +29 -21
- package/dist/overlay/floating.js.map +1 -1
- package/dist/overlay/listbox-layer.d.ts +3 -2
- package/dist/overlay/listbox-layer.js.map +1 -1
- package/dist/overlay/position.d.ts +5 -2
- package/dist/overlay/position.js +19 -19
- package/dist/overlay/position.js.map +1 -1
- package/dist/overlay/toast-host.js +3 -2
- package/dist/overlay/toast-host.js.map +1 -1
- package/dist/overlay/use-anchored-position.d.ts +2 -2
- package/dist/overlay/use-anchored-position.js +25 -25
- package/dist/overlay/use-anchored-position.js.map +1 -1
- package/dist/styles/announcer.css +1 -1
- package/dist/styles/app-shell.css +1 -1
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/chat-message.css +1 -0
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/choice-base.css +1 -0
- package/dist/styles/choice.css +1 -1
- package/dist/styles/code-block.css +1 -1
- package/dist/styles/color-field.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +1 -1
- package/dist/styles/copy-button.css +1 -1
- package/dist/styles/data-grid.css +1 -0
- package/dist/styles/date-field.css +1 -1
- package/dist/styles/device-frame.css +1 -0
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/disclosure.css +1 -1
- package/dist/styles/error-boundary.css +1 -0
- package/dist/styles/field.css +1 -1
- package/dist/styles/file-drop.css +1 -1
- package/dist/styles/floating-toolbar.css +1 -1
- package/dist/styles/generated-css.d.ts +1 -1
- package/dist/styles/generated-css.js +3 -3
- package/dist/styles/generated-css.js.map +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heading.css +1 -1
- package/dist/styles/highlighted-text.css +1 -0
- package/dist/styles/hotkey-field.css +1 -0
- package/dist/styles/icon-tile.css +1 -0
- package/dist/styles/icon.css +1 -1
- package/dist/styles/inline.css +1 -0
- package/dist/styles/key-value-editor.css +1 -1
- package/dist/styles/link.css +1 -1
- package/dist/styles/list-row.css +1 -0
- package/dist/styles/list.css +1 -0
- package/dist/styles/loading-dots.css +1 -1
- package/dist/styles/manifest.json +852 -0
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -0
- package/dist/styles/notice.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/option-list.css +1 -0
- package/dist/styles/overlay-frame.css +1 -0
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/pan-zoom-canvas.css +1 -1
- package/dist/styles/path-field.css +1 -0
- package/dist/styles/popover.css +1 -1
- package/dist/styles/progress-bar.css +1 -1
- package/dist/styles/qr-code.css +1 -0
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/row-actions.css +1 -0
- package/dist/styles/scroll-area.css +1 -0
- package/dist/styles/search-field.css +1 -1
- package/dist/styles/section.css +1 -0
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sheet.css +1 -1
- package/dist/styles/side-nav.css +1 -1
- package/dist/styles/site-footer.css +1 -0
- package/dist/styles/site-header.css +1 -0
- package/dist/styles/skip-link.css +1 -0
- package/dist/styles/sort-button.css +1 -0
- package/dist/styles/sortable-list.css +1 -1
- package/dist/styles/split-pane.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/stat.css +1 -0
- package/dist/styles/status-bar.css +1 -0
- package/dist/styles/steps.css +1 -1
- package/dist/styles/switch.css +1 -0
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/tag-input.css +1 -1
- package/dist/styles/text-area.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/text.css +1 -1
- package/dist/styles/time-field.css +1 -1
- package/dist/styles/title-bar.css +1 -0
- package/dist/styles/toast.css +1 -1
- package/dist/styles/tokens.css +3 -3
- package/dist/styles/tree.css +1 -1
- package/dist/styles/virtual-list.css +1 -1
- package/dist/styles/visually-hidden.css +1 -0
- package/dist/styles.css +3 -3
- package/dist/theme/CynosureTheme.d.ts +7 -3
- package/dist/theme/CynosureTheme.js +47 -31
- package/dist/theme/CynosureTheme.js.map +1 -1
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/theme-context.d.ts +9 -0
- package/dist/theme/theme-context.js +8 -0
- package/dist/theme/theme-context.js.map +1 -0
- package/dist/theme/theme-init-script.js +0 -1
- package/dist/theme/theme-init-script.js.map +1 -1
- package/dist/theme/use-color-mode.d.ts +3 -2
- package/dist/theme/use-color-mode.js +35 -38
- package/dist/theme/use-color-mode.js.map +1 -1
- package/dist/theme/use-cynosure-theme.d.ts +18 -0
- package/dist/theme/use-cynosure-theme.js +23 -0
- package/dist/theme/use-cynosure-theme.js.map +1 -0
- package/dist/tokens/chart-themes.d.ts +38 -0
- package/dist/tokens/chart-themes.js +35 -0
- package/dist/tokens/chart-themes.js.map +1 -0
- package/dist/tokens/create-theme.d.ts +11 -1
- package/dist/tokens/create-theme.js +194 -125
- package/dist/tokens/create-theme.js.map +1 -1
- package/dist/tokens/defaults.d.ts +3 -3
- package/dist/tokens/defaults.js +1 -0
- package/dist/tokens/defaults.js.map +1 -1
- package/dist/tokens/editor-themes.d.ts +9 -2
- package/dist/tokens/editor-themes.js +43 -42
- package/dist/tokens/editor-themes.js.map +1 -1
- package/dist/tokens/index.d.ts +3 -1
- package/dist/tokens/named-themes.d.ts +41 -0
- package/dist/tokens/named-themes.js +118 -0
- package/dist/tokens/named-themes.js.map +1 -0
- package/dist/tokens/schema.d.ts +24 -1
- package/dist/tokens/schema.js +13 -0
- package/dist/tokens/schema.js.map +1 -0
- package/dist/tokens/to-css.js +34 -31
- package/dist/tokens/to-css.js.map +1 -1
- package/package.json +15 -6
- package/dist/components/Checkbox/ChoiceRow.d.ts +0 -39
- package/dist/components/Checkbox/ChoiceRow.js +0 -58
- package/dist/components/Checkbox/ChoiceRow.js.map +0 -1
- package/dist/components/Stack/space.d.ts +0 -18
- package/dist/components/Stack/space.js +0 -12
- package/dist/components/Stack/space.js.map +0 -1
- package/dist/styles/hidden-value.css +0 -1
- package/dist/styles/iconbutton.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathField.js","names":["useControllableState","Button","TextField","forwardRef","useState","jsx","DEFAULT_LABELS","BUTTON_SIZE","PathField","label","labelHidden","layout","width","description","error","value","defaultValue","onChange","onPick","name","form","required","disabled","placeholder","iconStart","size","variant","labels","className","style","ref","text","path","setPath","picking","setPicking","pick","chosen"],"sources":["../../../src/components/PathField/PathField.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode, useState } from \"react\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { DenseSize } from \"../../tokens/schema.js\";\nimport { Button } from \"../Button/Button.js\";\nimport type { FieldLayoutProps } from \"../Field/Field.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface PathFieldTokens {\n /** Space between the Browse button and the end of the field. */\n browseInset: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n pathField: PathFieldTokens;\n }\n}\n\nexport interface PathFieldLabels {\n /** The button that opens the picker. Default: \"Browse…\". */\n browse: string;\n /** The clear button. Default: \"Clear\". */\n clear: string;\n}\n\nexport interface PathFieldProps extends FieldLayoutProps {\n /** The field's label and accessible name. */\n label: ReactNode;\n /** Visually hide the label (it still names the field). Prefer visible labels. */\n labelHidden?: boolean | undefined;\n /** Help text shown below the field and read with it. */\n description?: ReactNode;\n /** Your own error message, shown below the field. */\n error?: ReactNode;\n /** The path (controlled). */\n value?: string | undefined;\n /** The path at first, when uncontrolled. */\n defaultValue?: string | undefined;\n /** Called with the new path when it is typed, picked or cleared. */\n onChange?: ((value: string) => void) | undefined;\n /**\n * Opens your picker (Electron's `dialog.showOpenDialog` over IPC, a file system access handle) and resolves with the\n * chosen path, or null when it was cancelled. The button is busy until it settles; a cancel or a failure (the\n * promise rejects) leaves the path as it was.\n */\n onPick: () => Promise<string | null>;\n /** Name the path is submitted under in a form. */\n name?: string | undefined;\n /** Id of the form it belongs to, when it is not inside that form. */\n form?: string | undefined;\n /** The form cannot be submitted while the path is empty. */\n required?: boolean | undefined;\n /** Turns off the field and its buttons; the path is not submitted. */\n disabled?: boolean | undefined;\n /** Hint shown in the field while it is empty. */\n placeholder?: string | undefined;\n /** Icon at the start of the field. */\n iconStart?: IconData | undefined;\n /** Field height and text size. Default \"md\". */\n size?: DenseSize;\n /** `outline` or `soft` (tinted, borderless until focus). Default \"outline\". */\n variant?: \"outline\" | \"soft\";\n /** Replace the built-in English text: the Browse and clear buttons. */\n labels?: Partial<PathFieldLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-path-field-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: PathFieldLabels = { browse: \"Browse…\", clear: \"Clear\" };\n\n/** The Browse button one step smaller than the field, so it sits inside it. */\nconst BUTTON_SIZE = { xs: \"xs\", sm: \"xs\", md: \"sm\", lg: \"md\" } as const;\n\n/**\n * A file or folder path: a text field with a Browse button that asks your picker for a path, and a clear button.\n * The path can also be typed. For an app with its own file dialog (Electron), where a browser file input has no path.\n */\nexport const PathField = forwardRef<HTMLInputElement, PathFieldProps>(function PathField(\n {\n label,\n labelHidden,\n layout,\n width,\n description,\n error,\n value,\n defaultValue = \"\",\n onChange,\n onPick,\n name,\n form,\n required,\n disabled,\n placeholder,\n iconStart,\n size = \"md\",\n variant = \"outline\",\n labels,\n className,\n style,\n },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [path, setPath] = useControllableState(value, defaultValue, onChange);\n const [picking, setPicking] = useState(false);\n\n const pick = () => {\n setPicking(true);\n // A picker that fails changes nothing: the button stops being busy and the path stays.\n onPick()\n .then(\n (chosen) => {\n if (chosen !== null) setPath(chosen);\n },\n () => {},\n )\n .finally(() => setPicking(false));\n };\n\n return (\n <div className={className ? `cy-path-field ${className}` : \"cy-path-field\"} style={style}>\n <TextField\n ref={ref}\n label={label}\n labelHidden={labelHidden}\n layout={layout}\n width={width}\n description={description}\n error={error}\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n placeholder={placeholder}\n iconStart={iconStart}\n size={size}\n variant={variant}\n autoComplete=\"off\"\n spellCheck={false}\n value={path}\n onChange={setPath}\n clearable={!disabled}\n labels={{ clear: text.clear }}\n addonEnd={\n <Button\n className=\"cy-path-field-browse\"\n variant=\"soft\"\n tone=\"neutral\"\n size={BUTTON_SIZE[size]}\n disabled={disabled}\n loading={picking}\n onClick={pick}\n >\n {text.browse}\n </Button>\n }\n />\n </div>\n );\n});\n"],"mappings":";;;;;;AAuEA,IAAMM,IAAkC;AAAA,EAAE,QAAQ;AAAA,EAAW,OAAO;AAAQ,GAGtEC,IAAc;AAAA,EAAE,IAAI;AAAA,EAAM,IAAI;AAAA,EAAM,IAAI;AAAA,EAAM,IAAI;AAAK,GAMhDC,IAAY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OAAOS,EAAK,MAAM;AAAA,MAC5B,UACE,gBAAA1B,EAACJ,GAAD;AAAA,QACE,WAAU;AAAA,QACV,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,MAAMM,EAAYkB,CAAA;AAAA,QACR,UAAAH;AAAA,QACV,SAASY;AAAA,QACT,SAASE;AAAA,QAER,UAAAL,EAAK;AAAA,MACA,CAAA;AAAA,IAEX,CAAA;AAAA,EACE,CAAA;AAET,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PathField, type PathFieldLabels, type PathFieldProps, type PathFieldTokens, } from "./PathField.js";
|
|
@@ -51,16 +51,29 @@ export interface PopoverProps {
|
|
|
51
51
|
onOpenChange?: (open: boolean) => void;
|
|
52
52
|
/** Preferred side; flips when it does not fit. `start`/`end` follow the reading direction. */
|
|
53
53
|
placement?: Placement;
|
|
54
|
-
/** Panel width preset. */
|
|
54
|
+
/** Panel width preset: the most it grows to (or, with `width="fixed"`, its width). */
|
|
55
55
|
size?: Size;
|
|
56
|
+
/**
|
|
57
|
+
* How wide the panel is. `content` (default): as wide as its content, up to the `size` preset. `trigger`: at least
|
|
58
|
+
* as wide as the trigger or anchor element, lined up with it (a list under a wide button). `fixed`: exactly the
|
|
59
|
+
* `size` preset (`--cy-popover-width-{sm,md,lg}`), however short the content.
|
|
60
|
+
*/
|
|
61
|
+
width?: "content" | "trigger" | "fixed";
|
|
62
|
+
/**
|
|
63
|
+
* Where focus goes on open. `first` (default): the first control inside, or the panel when it has none. `panel`:
|
|
64
|
+
* the panel itself, so a screen reader starts at its top. `none`: focus stays where it is (a field the person is
|
|
65
|
+
* typing in); Escape and outside presses still close it, and Tab from the trigger, or from an anchor the panel
|
|
66
|
+
* follows in the document, moves into it.
|
|
67
|
+
*/
|
|
68
|
+
initialFocus?: "first" | "panel" | "none";
|
|
56
69
|
/** Keep Tab inside the panel until it closes. */
|
|
57
70
|
modal?: boolean;
|
|
58
71
|
/** Added to the panel, for layout. */
|
|
59
72
|
className?: string;
|
|
60
73
|
/** Layout only, applied to the panel. */
|
|
61
74
|
style?: CSSProperties;
|
|
62
|
-
/** The panel's content. Focus moves to its first focusable element on open. */
|
|
75
|
+
/** The panel's content. Focus moves to its first focusable element on open (see `initialFocus`). */
|
|
63
76
|
children?: ReactNode;
|
|
64
77
|
}
|
|
65
78
|
/** Floating panel in the top layer, anchored to its trigger. Escape, outside clicks and focus return are shared. */
|
|
66
|
-
export declare function Popover({ trigger, anchor, label, open, defaultOpen, onOpenChange, placement, size, modal, className, style, children, }: PopoverProps): import("react").JSX.Element;
|
|
79
|
+
export declare function Popover({ trigger, anchor, label, open, defaultOpen, onOpenChange, placement, size, width, initialFocus, modal, className, style, children, }: PopoverProps): import("react").JSX.Element;
|
|
@@ -1,55 +1,64 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useControllableState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
import { useControllableState as F } from "../../foundations/controllable.js";
|
|
3
|
+
import { deepActiveElement as R } from "../../foundations/focus.js";
|
|
4
|
+
import { useDismiss as K } from "../../overlay/dismiss.js";
|
|
5
|
+
import { usePopover as j } from "../../overlay/floating.js";
|
|
6
|
+
import { useAnchoredPosition as k } from "../../overlay/use-anchored-position.js";
|
|
7
|
+
import { useId as q, useRef as o } from "react";
|
|
8
|
+
import { Fragment as I, jsx as z, jsxs as L } from "react/jsx-runtime";
|
|
9
|
+
var T = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]):not([aria-hidden="true"]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
10
|
+
function Q({ trigger: c, anchor: t, label: w, open: O, defaultOpen: S = !1, onOpenChange: $, placement: A = "bottom", size: B = "md", width: l = "content", initialFocus: p = "first", modal: d = !1, className: f, style: P, children: h }) {
|
|
11
|
+
const m = q(), [r, g] = F(O, S, $), i = o(null), s = o(null), u = o(null);
|
|
12
|
+
u.current = t ? "getBoundingClientRect" in t ? t : { getBoundingClientRect: () => new DOMRect(t.x, t.y, 0, 0) } : i.current;
|
|
13
|
+
const y = o(null), b = o(!1);
|
|
14
|
+
r && !b.current && (y.current = R()), b.current = r;
|
|
15
|
+
const x = o(null);
|
|
16
|
+
x.current = c ? i.current : y.current;
|
|
17
|
+
const v = o(null);
|
|
18
|
+
v.current = t && "nodeType" in t ? t : null, j(s, r, (e) => {
|
|
19
|
+
const n = t ? u.current : i.current;
|
|
20
|
+
l === "trigger" && n && e.style.setProperty("--_anchor-w", `${n.getBoundingClientRect().width}px`), p !== "none" && ((p === "first" ? e.querySelector(T) : null) ?? e).focus({ preventScroll: !0 });
|
|
21
|
+
}), k(t ? u : i, s, r, A, 6, "start"), K({
|
|
22
|
+
open: r,
|
|
23
|
+
onClose: () => g(!1),
|
|
24
|
+
inside: [
|
|
25
|
+
i,
|
|
26
|
+
s,
|
|
27
|
+
v
|
|
28
|
+
],
|
|
29
|
+
returnFocus: x
|
|
22
30
|
});
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
const
|
|
28
|
-
e.shiftKey && (a ===
|
|
31
|
+
const E = (e) => {
|
|
32
|
+
if (!d || e.key !== "Tab") return;
|
|
33
|
+
const n = [...e.currentTarget.querySelectorAll(T)];
|
|
34
|
+
if (!n.length) return;
|
|
35
|
+
const C = n[0], D = n[n.length - 1], a = R(e.currentTarget.ownerDocument);
|
|
36
|
+
e.shiftKey && (a === C || a === e.currentTarget) ? (e.preventDefault(), D.focus()) : !e.shiftKey && a === D && (e.preventDefault(), C.focus());
|
|
29
37
|
};
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
ref: o,
|
|
32
|
-
onClick: () => p(!t),
|
|
33
|
-
"aria-expanded": t,
|
|
34
|
-
"aria-controls": `${d}-panel`,
|
|
35
|
-
"aria-haspopup": "dialog"
|
|
36
|
-
}), /* @__PURE__ */ j("div", {
|
|
38
|
+
return /* @__PURE__ */ L(I, { children: [c?.({
|
|
37
39
|
ref: i,
|
|
38
|
-
|
|
40
|
+
onClick: () => g(!r),
|
|
41
|
+
"aria-expanded": r,
|
|
42
|
+
"aria-controls": `${m}-panel`,
|
|
43
|
+
"aria-haspopup": "dialog"
|
|
44
|
+
}), /* @__PURE__ */ z("div", {
|
|
45
|
+
ref: s,
|
|
46
|
+
id: `${m}-panel`,
|
|
39
47
|
role: "dialog",
|
|
40
|
-
"aria-label":
|
|
41
|
-
"aria-modal":
|
|
48
|
+
"aria-label": w,
|
|
49
|
+
"aria-modal": d || void 0,
|
|
42
50
|
tabIndex: -1,
|
|
43
51
|
popover: "manual",
|
|
44
|
-
className:
|
|
45
|
-
"data-size":
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
className: f ? `cy-popover ${f}` : "cy-popover",
|
|
53
|
+
"data-size": B,
|
|
54
|
+
"data-width": l === "content" ? void 0 : l,
|
|
55
|
+
style: P,
|
|
56
|
+
onKeyDown: E,
|
|
57
|
+
children: h
|
|
49
58
|
})] });
|
|
50
59
|
}
|
|
51
60
|
export {
|
|
52
|
-
|
|
61
|
+
Q as Popover
|
|
53
62
|
};
|
|
54
63
|
|
|
55
64
|
//# sourceMappingURL=Popover.js.map
|
|
@@ -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 /** 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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GAAGD,CAAA;AAAA,IACpB,iBAAiB;AAAA,EACnB,CAAC,GACD,gBAAAhB,EAAC,OAAD;AAAA,IACE,KAAKoB;AAAA,IACL,IAAI,GAAGJ,CAAA;AAAA,IACP,MAAK;AAAA,IACL,cAAYV;AAAA,IACZ,cAAYM,KAAS;AAAA,IACrB,UAAU;AAAA,IACJ,SAAS;AAAA,IACf,WAAWC,IAAY,cAAcA,CAAA,KAAc;AAAA,IACnD,aAAWF;AAAA,IACJ,OAAAG;AAAA,IACP,WAAWY;AAAA,IAEV,UAAAX;AAAA,EACE,CAAA,CACL,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"Popover.js","names":["_Fragment","useControllableState","deepActiveElement","useDismiss","usePopover","useAnchoredPosition","useId","useRef","Fragment$1","jsx","jsxs","FOCUSABLE","Popover","trigger","anchor","label","open","defaultOpen","onOpenChange","placement","size","width","initialFocus","modal","className","style","children","id","isOpen","setOpen","triggerRef","panel","placed","before","wasOpen","returnTo","anchorEl","el","against","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 { deepActiveElement } from \"../../foundations/focus.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: the most it grows to (or, with `width=\"fixed\"`, its width). */\n size?: Size;\n /**\n * How wide the panel is. `content` (default): as wide as its content, up to the `size` preset. `trigger`: at least\n * as wide as the trigger or anchor element, lined up with it (a list under a wide button). `fixed`: exactly the\n * `size` preset (`--cy-popover-width-{sm,md,lg}`), however short the content.\n */\n width?: \"content\" | \"trigger\" | \"fixed\";\n /**\n * Where focus goes on open. `first` (default): the first control inside, or the panel when it has none. `panel`:\n * the panel itself, so a screen reader starts at its top. `none`: focus stays where it is (a field the person is\n * typing in); Escape and outside presses still close it, and Tab from the trigger, or from an anchor the panel\n * follows in the document, moves into it.\n */\n initialFocus?: \"first\" | \"panel\" | \"none\";\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 (see `initialFocus`). */\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 width = \"content\",\n initialFocus = \"first\",\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) before.current = deepActiveElement();\n wasOpen.current = isOpen;\n const returnTo = useRef<HTMLElement | null>(null);\n returnTo.current = trigger ? triggerRef.current : before.current;\n\n // An anchor element counts as inside, as the trigger does: pressing it (back into a field) is not an outside press.\n const anchorEl = useRef<HTMLElement | null>(null);\n anchorEl.current = anchor && \"nodeType\" in anchor ? (anchor as HTMLElement) : null;\n\n // Show before positioning (the panel must be laid out to be measured), size it, then move focus inside.\n usePopover(panel, isOpen, (el) => {\n const against = anchor ? placed.current : triggerRef.current;\n if (width === \"trigger\" && against)\n el.style.setProperty(\"--_anchor-w\", `${against.getBoundingClientRect().width}px`);\n if (initialFocus === \"none\") return;\n const first = initialFocus === \"first\" ? el.querySelector<HTMLElement>(FOCUSABLE) : null;\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, anchorEl],\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 = deepActiveElement(event.currentTarget.ownerDocument);\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 data-width={width === \"content\" ? undefined : width}\n style={style}\n onKeyDown={trap}\n >\n {children}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAmFA,IAAMW,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,WACR,cAAAC,IAAe,SACf,OAAAC,IAAQ,IACR,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACe;AACf,QAAMC,IAAKrB,EAAM,GACX,CAACsB,GAAQC,CAAA,IAAW5B,EAAqBe,GAAMC,GAAaC,CAAY,GACxEY,IAAav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C,GAAGD,EAAM,cAAc,iBAA8B7B,CAAS,CAAC;AAC9E,QAAI,CAAC8B,EAAM,OAAQ;AACnB,UAAMC,IAAQD,EAAM,CAAA,GACdE,IAAOF,EAAMA,EAAM,SAAS,CAAA,GAC5BG,IAAS1C,EAAkBsC,EAAM,cAAc,aAAa;AAClE,IAAIA,EAAM,aAAaI,MAAWF,KAASE,MAAWJ,EAAM,kBAC1DA,EAAM,eAAe,GACrBG,EAAK,MAAM,KACF,CAACH,EAAM,YAAYI,MAAWD,MACvCH,EAAM,eAAe,GACrBE,EAAM,MAAM;AAAA,EAEhB;AAEA,SACE,gBAAAhC,EAAAV,GAAA,EAAA,UAAA,CACGa,IAAU;AAAA,IACT,KAAKiB;AAAA,IACL,SAAA,MAAeD,EAAQ,CAACD,CAAM;AAAA,IAC9B,iBAAiBA;AAAA,IACjB,iBAAiB,GAAGD,CAAA;AAAA,IACpB,iBAAiB;AAAA,EACnB,CAAC,GACD,gBAAAlB,EAAC,OAAD;AAAA,IACE,KAAKsB;AAAA,IACL,IAAI,GAAGJ,CAAA;AAAA,IACP,MAAK;AAAA,IACL,cAAYZ;AAAA,IACZ,cAAYQ,KAAS;AAAA,IACrB,UAAU;AAAA,IACJ,SAAS;AAAA,IACf,WAAWC,IAAY,cAAcA,CAAA,KAAc;AAAA,IACnD,aAAWJ;AAAA,IACX,cAAYC,MAAU,YAAY,SAAYA;AAAA,IACvC,OAAAI;AAAA,IACP,WAAWc;AAAA,IAEV,UAAAb;AAAA,EACE,CAAA,CACL,EAAA,CAAA;AAEN"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DenseSize, Tone } from "../../tokens/schema.js";
|
|
3
3
|
export interface ProgressBarTokens {
|
|
4
|
+
heightXs: string;
|
|
4
5
|
heightSm: string;
|
|
5
6
|
heightMd: string;
|
|
6
7
|
heightLg: string;
|
|
@@ -50,8 +51,8 @@ export interface ProgressBarProps {
|
|
|
50
51
|
markerLabel?: string | undefined;
|
|
51
52
|
/** Colour of the fill. Default "accent". */
|
|
52
53
|
tone?: Exclude<Tone, "neutral"> | "neutral";
|
|
53
|
-
/** Bar thickness. */
|
|
54
|
-
size?:
|
|
54
|
+
/** Bar thickness. `xs` is a hairline track with smaller label text, for dense desktop chrome. Default "md". */
|
|
55
|
+
size?: DenseSize;
|
|
55
56
|
/** Replace the built-in English text: the value text. */
|
|
56
57
|
labels?: Partial<ProgressBarLabels>;
|
|
57
58
|
/** Added to the root element, for layout. */
|
|
@@ -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 {
|
|
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 { DenseSize, Tone } from \"../../tokens/schema.js\";\n\nexport interface ProgressBarTokens {\n heightXs: string;\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. `xs` is a hairline track with smaller label text, for dense desktop chrome. Default \"md\". */\n size?: DenseSize;\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":";;;AAoEA,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,QAAAC,IAAS,GACT,QAAAC,GACA,aAAAC,GACA,MAAAC,IAAO,UACP,MAAAC,IAAO,MACP,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACmB;AACnB,QAAMC,IAAKpB,EAAM,GACXqB,IAAMhB,IAAM,IAAIA,IAAM,KACtBiB,IAAUb,KAAiBL,MAAU,UAAa,OAAO,MAAMA,CAAK,GACpEmB,IAAMD,IAAU,IAAI,KAAK,IAAI,KAAK,IAAIlB,GAAO,CAAC,GAAGiB,CAAG,GACpDG,IAAQb,GAAU,SAASA,IAAW,MACtCc,IAAQD,IAAQZ,IAASY,EAAM,OAAA,CAAQE,GAAKC,MAAMD,IAAM,KAAK,IAAI,GAAGC,EAAE,KAAK,GAAG,CAAC,IAAI,GACnFC,IAAaJ,IAAQ,KAAQF,GAC7BO,IAAWL,IAAQ,KAAK,IAAIC,GAAOJ,CAAG,IAAIE,GAC1CO,IAAA,CAAMC,MAAc,GAAI,KAAK,IAAI,KAAK,IAAIA,GAAG,CAAC,GAAGV,CAAG,IAAIA,IAAO,GAAA,KAC/DW,IAAOR,IACTA,EAAM,IAAA,CAAKG,MAAM,GAAGA,EAAE,KAAA,IAASA,EAAE,KAAA,EAAO,EAAE,KAAK,IAAI,IACnDL,IACE,MACCL,GAAQ,SAASd,GAASoB,GAAKF,CAAG,GACnCY,IACJpB,MAAW,SACPmB,IACA,CAACA,GAAMl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E,WAAU;AAAA,UACV,aAAW0B,EAAE,QAAQ,SAAaA,EAAE,QAAQZ;AAAA,UAC5C,OACE;AAAA,YACE,WAAWe,EAAGI,CAAK;AAAA,YACnB,SAASJ,EAAGI,IAAQ,KAAK,IAAI,GAAGP,EAAE,KAAK,CAAC;AAAA,YACxC,GAAIA,EAAE,QAAQ,EAAE,UAAUA,EAAE,MAAM,IAAI,CAAC;AAAA,UACzC;AAAA,QAEH,GAVM,GAAGA,EAAE,KAAA,IAAS,CAAA,EAUpB;AAAA,MAEL,CAAC,IAED,gBAAA1B,EAAC,OAAD,EAAK,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"}
|
|
@@ -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,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AM,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";
|
|
@@ -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 ))}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A;AAAA,QACjC,CAAA;AAAA,MAET,GAjBMF,EAAO,KAiBb,CACF;AAAA,IACE,CAAA;AAAA,EAEF,CAAA;AAEX"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode, type RefObject } from "react";
|
|
2
|
+
export interface RowActionsTokens {
|
|
3
|
+
/** Space between the controls. */
|
|
4
|
+
gap: string;
|
|
5
|
+
/** Fill behind the controls, for actions drawn over the end of a row (ListRow sets it to the row's colour). */
|
|
6
|
+
background: string;
|
|
7
|
+
}
|
|
8
|
+
declare module "../../tokens/schema.js" {
|
|
9
|
+
interface ComponentTokens {
|
|
10
|
+
rowActions: RowActionsTokens;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface RowActionsProps {
|
|
14
|
+
/** The controls: `IconButton`s, a `Menu`, a `Toolbar` of them. */
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the controls are in the Tab order. A ref to the row's own control (the one a list's roving focus moves
|
|
18
|
+
* between): they are in it only while that control is the list's Tab stop, or always when the ref is empty (a row
|
|
19
|
+
* that cannot be pressed). `true` or `false`: always or never. Left out: their own tabindex is left alone (a
|
|
20
|
+
* `Toolbar` inside manages it).
|
|
21
|
+
*/
|
|
22
|
+
tabbable?: boolean | RefObject<HTMLElement | null> | undefined;
|
|
23
|
+
/** Shown whatever the pointer does, such as on a selected row. Default false. */
|
|
24
|
+
shown?: boolean | undefined;
|
|
25
|
+
/** Added to the root element, for layout (its place in the row). */
|
|
26
|
+
className?: string | undefined;
|
|
27
|
+
/** Layout only. Restyle through --cy-row-actions-* tokens. */
|
|
28
|
+
style?: CSSProperties | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The buttons at the end of a row (ListRow, Tree items, ChatMessage). With a mouse they wait, in place, until their
|
|
32
|
+
* row (the element that holds them, or an ancestor with `data-row-actions-host`) is hovered or holds focus, or a menu of theirs is open; where there is no hover
|
|
33
|
+
* (touch) they are always shown. `tabbable` puts them in the Tab order only on the row that holds the Tab stop.
|
|
34
|
+
*/
|
|
35
|
+
export declare const RowActions: import("react").ForwardRefExoticComponent<RowActionsProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useClientLayoutEffect as v } from "../../foundations/client-layout-effect.js";
|
|
3
|
+
import { forwardRef as w, useImperativeHandle as x, useRef as m } from "react";
|
|
4
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
5
|
+
var I = (o) => [...o.querySelectorAll("button, a[href], input, select, textarea, [tabindex]")].filter((r) => {
|
|
6
|
+
const t = r.closest("[popover]");
|
|
7
|
+
return !t || !o.contains(t);
|
|
8
|
+
}), j = w(function({ children: r, tabbable: t, shown: l = !1, className: i, style: p }, d) {
|
|
9
|
+
const n = m(null);
|
|
10
|
+
return x(d, () => n.current), v(() => {
|
|
11
|
+
const s = n.current;
|
|
12
|
+
if (!s || t === void 0) return;
|
|
13
|
+
const e = typeof t == "object" ? t.current : null, u = () => {
|
|
14
|
+
const f = typeof t == "object" ? !e || e.tabIndex === 0 ? 0 : -1 : t ? 0 : -1;
|
|
15
|
+
for (const a of I(s)) a.tabIndex !== f && (a.tabIndex = f);
|
|
16
|
+
};
|
|
17
|
+
u();
|
|
18
|
+
const c = new MutationObserver(u);
|
|
19
|
+
return c.observe(s, {
|
|
20
|
+
childList: !0,
|
|
21
|
+
subtree: !0
|
|
22
|
+
}), e && c.observe(e, {
|
|
23
|
+
attributes: !0,
|
|
24
|
+
attributeFilter: ["tabindex"]
|
|
25
|
+
}), () => c.disconnect();
|
|
26
|
+
}), /* @__PURE__ */ y("span", {
|
|
27
|
+
ref: n,
|
|
28
|
+
className: i ? `cy-row-actions ${i}` : "cy-row-actions",
|
|
29
|
+
"data-shown": l ? "" : void 0,
|
|
30
|
+
style: p,
|
|
31
|
+
children: r
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
export {
|
|
35
|
+
j as RowActions
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=RowActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowActions.js","names":["useClientLayoutEffect","forwardRef","useImperativeHandle","useRef","jsx","controlsOf","root","el","popover","RowActions","children","tabbable","shown","className","style","ref","follow","sync","want","control","observer"],"sources":["../../../src/components/RowActions/RowActions.tsx"],"sourcesContent":["import {\n type CSSProperties,\n forwardRef,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\n\nexport interface RowActionsTokens {\n /** Space between the controls. */\n gap: string;\n /** Fill behind the controls, for actions drawn over the end of a row (ListRow sets it to the row's colour). */\n background: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n rowActions: RowActionsTokens;\n }\n}\n\nexport interface RowActionsProps {\n /** The controls: `IconButton`s, a `Menu`, a `Toolbar` of them. */\n children?: ReactNode;\n /**\n * Whether the controls are in the Tab order. A ref to the row's own control (the one a list's roving focus moves\n * between): they are in it only while that control is the list's Tab stop, or always when the ref is empty (a row\n * that cannot be pressed). `true` or `false`: always or never. Left out: their own tabindex is left alone (a\n * `Toolbar` inside manages it).\n */\n tabbable?: boolean | RefObject<HTMLElement | null> | undefined;\n /** Shown whatever the pointer does, such as on a selected row. Default false. */\n shown?: boolean | undefined;\n /** Added to the root element, for layout (its place in the row). */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-row-actions-* tokens. */\n style?: CSSProperties | undefined;\n}\n\n/** The controls of a row, without those of a popover opened from them (a Menu's panel). */\nconst controlsOf = (root: HTMLElement) =>\n [...root.querySelectorAll<HTMLElement>(\"button, a[href], input, select, textarea, [tabindex]\")].filter(\n (el) => {\n const popover = el.closest(\"[popover]\");\n return !popover || !root.contains(popover);\n },\n );\n\n/**\n * The buttons at the end of a row (ListRow, Tree items, ChatMessage). With a mouse they wait, in place, until their\n * row (the element that holds them, or an ancestor with `data-row-actions-host`) is hovered or holds focus, or a menu of theirs is open; where there is no hover\n * (touch) they are always shown. `tabbable` puts them in the Tab order only on the row that holds the Tab stop.\n */\nexport const RowActions = forwardRef<HTMLSpanElement, RowActionsProps>(function RowActions(\n { children, tabbable, shown = false, className, style },\n ref,\n) {\n const root = useRef<HTMLSpanElement>(null);\n useImperativeHandle(ref, () => root.current as HTMLSpanElement);\n\n // Keep the controls' tabindex in line: after every render (the row's control may have been replaced), when the\n // controls change (a Menu trigger rendered later) and, following a row control, when roving focus moves the Tab stop.\n useClientLayoutEffect(() => {\n const el = root.current;\n if (!el || tabbable === undefined) return;\n const follow = typeof tabbable === \"object\" ? tabbable.current : null;\n const sync = () => {\n const want =\n typeof tabbable === \"object\" ? (!follow || follow.tabIndex === 0 ? 0 : -1) : tabbable ? 0 : -1;\n for (const control of controlsOf(el)) if (control.tabIndex !== want) control.tabIndex = want;\n };\n sync();\n const observer = new MutationObserver(sync);\n observer.observe(el, { childList: true, subtree: true });\n if (follow) observer.observe(follow, { attributes: true, attributeFilter: [\"tabindex\"] });\n return () => observer.disconnect();\n });\n\n return (\n <span\n ref={root}\n className={className ? `cy-row-actions ${className}` : \"cy-row-actions\"}\n data-shown={shown ? \"\" : undefined}\n style={style}\n >\n {children}\n </span>\n );\n});\n"],"mappings":";;;;AA0CA,IAAMK,IAAA,CAAcC,MAClB,CAAC,GAAGA,EAAK,iBAA8B,sDAAsD,CAAC,EAAE,OAAA,CAC7FC,MAAO;AACN,QAAMC,IAAUD,EAAG,QAAQ,WAAW;AACtC,SAAO,CAACC,KAAW,CAACF,EAAK,SAASE,CAAO;AAC3C,CACF,GAOWC,IAAaR,EAA6C,SACrE,EAAE,UAAAS,GAAU,UAAAC,GAAU,OAAAC,IAAQ,IAAO,WAAAC,GAAW,OAAAC,EAAA,GAChDC,GACA;AACA,QAAMT,IAAOH,EAAwB,IAAI;AACzC,SAAAD,EAAoBa,GAA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