@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.js","names":["_Fragment","useControllableState","useClientLayoutEffect","clamp","IconButton","minus","plus","TextField","useDrag","HiddenValue","useMemo","useRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","places","n","parseNumber","text","locale","options","parts","group","p","decimal","cleaned","NumberField","label","labelHidden","description","error","value","defaultValue","onChange","min","max","step","largeStep","formatOptions","hideSteppers","name","form","required","disabled","readOnly","placeholder","size","variant","labels","scrub","className","style","current","setCurrent","resetCurrent","draft","setDraft","input","format","shown","limit","commit","next","stepBy","delta","base","from","start","snapped","digits","commitDraft","parsed","onKeyDown","event","big","moves","move","handle","el","scrubFrom","steps","_","cancelled","atMin","atMax","integers"],"sources":["../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, useMemo, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { clamp } from \"../../foundations/math.js\";\nimport { minus } from \"../../icons/minus.js\";\nimport { plus } from \"../../icons/plus.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface NumberFieldLabels {\n /** Stepper button names. Defaults: \"Decrease\", \"Increase\". */\n decrement: string;\n increment: string;\n}\n\nexport interface NumberFieldProps {\n /** Visible label; it names the field. */\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. */\n description?: ReactNode;\n /** Error message shown below the field; it marks the field invalid. */\n error?: ReactNode;\n /** `null` is empty. */\n value?: number | null | undefined;\n /** Starting value when uncontrolled; `null` is empty. */\n defaultValue?: number | null;\n /** Called with the new value when it is committed: a step, Enter, or leaving the field. */\n onChange?: ((value: number | null) => void) | undefined;\n /** Smallest value. Typed and stepped values are kept at or above it, and Home jumps to it. */\n min?: number | undefined;\n /** Largest value. Typed and stepped values are kept at or below it, and End jumps to it. */\n max?: number | undefined;\n /** Arrow keys and steppers move by this; values they produce snap to it. Default 1. */\n step?: number;\n /** Page Up and Page Down move by this. Default: 10 steps. */\n largeStep?: number;\n /** Locale for reading and writing numbers. Default: the browser's. */\n locale?: string | undefined;\n /** How the value is written: currency, percent, units, digits… (`Intl.NumberFormat` options). */\n formatOptions?: Intl.NumberFormatOptions | undefined;\n /** Hide the − and + buttons (the keyboard still steps). */\n hideSteppers?: boolean;\n /** Name the plain number 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 /** Marks the field as required for form validation. */\n required?: boolean | undefined;\n /** Turns off the field and its stepper buttons. */\n disabled?: boolean | undefined;\n /** The value can be read but not changed. */\n readOnly?: boolean | undefined;\n /** Hint shown while the field is empty. */\n placeholder?: string | undefined;\n /** Size of the field. Default \"md\". */\n size?: Size;\n /** `outline` or `soft` (tinted, borderless until focus). Default \"outline\". */\n variant?: \"outline\" | \"soft\";\n /** Replace the built-in English text: the stepper button names. */\n labels?: Partial<NumberFieldLabels>;\n /**\n * Drag the label sideways to change the value, as design tools do: one `step` every few pixels, Shift for ten. Escape\n * mid-drag puts it back. The keys and the steppers still work as before.\n */\n scrub?: boolean;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: NumberFieldLabels = { decrement: \"Decrease\", increment: \"Increase\" };\n\n/** Decimal places of `n`, so stepping by 0.1 gives 0.3 and not 0.30000000000000004. */\nconst places = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n\n/** Reads what a person typed in `locale`: group separators, the local decimal mark, a typographic minus, a % or a currency. */\nexport function parseNumber(\n text: string,\n locale?: string,\n options?: Intl.NumberFormatOptions,\n): number | null {\n const parts = new Intl.NumberFormat(locale).formatToParts(-12345.6);\n const group = parts.find((p) => p.type === \"group\")?.value ?? \",\";\n const decimal = parts.find((p) => p.type === \"decimal\")?.value ?? \".\";\n const cleaned = text\n .replace(/[−‒–]/g, \"-\")\n .split(group)\n .join(group.trim() ? \"\" : group)\n .replace(/\\s/g, \"\")\n .split(decimal)\n .join(\".\")\n .replace(/[^\\d.-]/g, \"\");\n if (!/^-?\\d*\\.?\\d+$|^-?\\d+\\.?$/.test(cleaned)) return null;\n const n = Number(cleaned);\n if (!Number.isFinite(n)) return null;\n return options?.style === \"percent\" ? n / 100 : n;\n}\n\n/**\n * A number input: type it in your own format, or step it with the arrow keys, Page Up/Down, Home/End or the − and +\n * buttons. APG spinbutton; locale-aware; takes part in forms with the plain number.\n */\nexport function NumberField({\n label,\n labelHidden,\n description,\n error,\n value,\n defaultValue = null,\n onChange,\n min,\n max,\n step = 1,\n largeStep,\n locale,\n formatOptions,\n hideSteppers = false,\n name,\n form,\n required,\n disabled,\n readOnly,\n placeholder,\n size = \"md\",\n variant = \"outline\",\n labels,\n scrub = false,\n className,\n style,\n}: NumberFieldProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [current, setCurrent, resetCurrent] = useControllableState<number | null>(\n value,\n defaultValue,\n onChange,\n );\n const [draft, setDraft] = useState<string | null>(null);\n const input = useRef<HTMLInputElement>(null);\n const format = useMemo(\n () => new Intl.NumberFormat(locale, { maximumFractionDigits: 20, ...formatOptions }),\n [locale, formatOptions],\n );\n const shown = (n: number | null) => (n === null ? \"\" : format.format(n));\n\n const limit = (n: number) => clamp(n, min ?? Number.NEGATIVE_INFINITY, max ?? Number.POSITIVE_INFINITY);\n const commit = (next: number | null) => {\n setDraft(null);\n if (next !== current) setCurrent(next);\n };\n const stepBy = (delta: number) => {\n if (disabled || readOnly) return;\n const base = min ?? 0;\n const from = draft !== null ? (parseNumber(draft, locale, formatOptions) ?? current) : current;\n const start = from ?? (delta > 0 ? (min ?? 0) : (max ?? 0));\n // Snap onto the step grid (counted from min), then round away floating-point noise.\n const snapped = from === null ? start : Math.round((start - base + delta) / step) * step + base;\n const digits = Math.max(places(step), places(base));\n commit(limit(Number(snapped.toFixed(digits))));\n };\n const commitDraft = () => {\n if (draft === null) return;\n if (draft.trim() === \"\") return commit(null);\n const parsed = parseNumber(draft, locale, formatOptions);\n // Unreadable text goes back to the last good value.\n commit(parsed === null ? current : limit(parsed));\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n const big = largeStep ?? step * 10;\n const moves: Record<string, () => void> = {\n ArrowUp: () => stepBy(step),\n ArrowDown: () => stepBy(-step),\n PageUp: () => stepBy(big),\n PageDown: () => stepBy(-big),\n Enter: commitDraft,\n };\n if (min !== undefined) moves.Home = () => !disabled && !readOnly && commit(min);\n if (max !== undefined) moves.End = () => !disabled && !readOnly && commit(max);\n const move = moves[event.key];\n if (!move) return;\n if (event.key !== \"Enter\") event.preventDefault();\n move();\n };\n\n // Scrubbing: the field's own <label> is the handle.\n const handle = useRef<HTMLElement | null>(null);\n useClientLayoutEffect(() => {\n const el =\n scrub && !disabled && !readOnly\n ? ((input.current?.labels?.[0] as HTMLElement | undefined) ?? null)\n : null;\n if (handle.current && handle.current !== el) delete handle.current.dataset.scrub;\n if (el) el.dataset.scrub = \"\";\n handle.current = el;\n });\n const scrubFrom = useRef<number | null>(null);\n useDrag(handle, {\n distance: 3,\n touchAction: \"css\",\n onStart: () => {\n scrubFrom.current = current;\n },\n onMove: ({ delta, event }) => {\n const steps = Math.round(delta.x / 4) * (event.shiftKey ? 10 : 1);\n const from = scrubFrom.current ?? min ?? 0;\n const digits = Math.max(places(step), places(min ?? 0));\n commit(limit(Number((from + steps * step).toFixed(digits))));\n },\n onEnd: (_, cancelled) => {\n if (cancelled) commit(scrubFrom.current);\n input.current?.focus({ preventScroll: true });\n },\n });\n\n const atMin = current !== null && min !== undefined && current <= min;\n const atMax = current !== null && max !== undefined && current >= max;\n const integers = Number.isInteger(step) && (min ?? 0) >= 0 && formatOptions?.style !== \"percent\";\n\n return (\n <>\n <TextField\n ref={input}\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error}\n size={size}\n variant={variant}\n className={className ? `cy-number-field ${className}` : \"cy-number-field\"}\n {...(style ? { style } : {})}\n role=\"spinbutton\"\n inputMode={integers ? \"numeric\" : \"decimal\"}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-valuenow={current ?? undefined}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuetext={current === null ? undefined : shown(current)}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n placeholder={placeholder}\n form={form}\n value={draft ?? shown(current)}\n onChange={setDraft}\n onKeyDown={onKeyDown}\n onBlur={commitDraft}\n addonEnd={\n !hideSteppers && (\n <span className=\"cy-number-field-steppers\">\n <IconButton\n icon={minus}\n label={text.decrement}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMin}\n onClick={() => {\n stepBy(-step);\n input.current?.focus();\n }}\n />\n <IconButton\n icon={plus}\n label={text.increment}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMax}\n onClick={() => {\n stepBy(step);\n input.current?.focus();\n }}\n />\n </span>\n )\n }\n />\n <HiddenValue\n name={name}\n form={form}\n value={current === null ? \"\" : String(current)}\n disabled={disabled}\n onReset={() => {\n setDraft(null);\n resetCurrent(defaultValue);\n }}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4EA,IAAMgB,KAAoC;AAAA,EAAE,WAAW;AAAA,EAAY,WAAW;AAAW,GAGnFC,IAAA,CAAUC,OAAe,OAAOA,CAAC,EAAE,MAAM,GAAG,EAAE,CAAA,KAAM,IAAI;AAG9D,SAAgBC,EACdC,GACAC,GACAC,GACe;AACf,QAAMC,IAAQ,IAAI,KAAK,aAAaF,CAAM,EAAE,cAAc,QAAQ,GAC5DG,IAAQD,EAAM,KAAA,CAAME,MAAMA,EAAE,SAAS,OAAO,GAAG,SAAS,KACxDC,IAAUH,EAAM,KAAA,CAAME,MAAMA,EAAE,SAAS,SAAS,GAAG,SAAS,KAC5DE,IAAUP,EACb,QAAQ,UAAU,GAAG,EACrB,MAAMI,CAAK,EACX,KAAKA,EAAM,KAAK,IAAI,KAAKA,CAAK,EAC9B,QAAQ,OAAO,EAAE,EACjB,MAAME,CAAO,EACb,KAAK,GAAG,EACR,QAAQ,YAAY,EAAE;AACzB,MAAI,CAAC,2BAA2B,KAAKC,CAAO,EAAG,QAAO;AACtD,QAAMT,IAAI,OAAOS,CAAO;AACxB,SAAK,OAAO,SAAST,CAAC,IACfI,GAAS,UAAU,YAAYJ,IAAI,MAAMA,IADhB;AAElC;AAMA,SAAgBU,GAAY,EAC1B,OAAAC,GACA,aAAAC,G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EAAS,IAAI,GACbF,EAAatB,CAAY;AAAA,IAC3B;AAAA,EACD,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"NumberField.js","names":["_Fragment","useControllableState","useClientLayoutEffect","ariaNumber","clamp","plainNumber","roundLike","snapToStep","IconButton","minus","plus","TextField","useDrag","HiddenValue","useMemo","useRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","marksCache","SAMPLES","marksOf","locale","options","id","known","plain","numberingSystem","styled","n","parts","of","type","fallback","p","digitFormat","marks","_","d","x","y","BIDI","parseNumber","text","group","decimal","digits","affixes","t","bracketed","affix","c","local","minusMark","cleaned","NumberField","label","labelHidden","layout","width","description","error","value","defaultValue","onChange","min","max","step","largeStep","formatOptions","hideSteppers","name","form","required","disabled","readOnly","placeholder","size","variant","labels","scrub","className","style","current","setCurrent","resetCurrent","draft","setDraft","input","format","shown","limit","commit","next","stepBy","delta","base","from","start","commitDraft","parsed","onKeyDown","event","big","moves","move","handle","el","scrubFrom","steps","cancelled","atMin","atMax","integers"],"sources":["../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, useMemo, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { ariaNumber, clamp, plainNumber, roundLike, snapToStep } from \"../../foundations/math.js\";\nimport { minus } from \"../../icons/minus.js\";\nimport { plus } from \"../../icons/plus.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport type { FieldLayoutProps } from \"../Field/Field.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface NumberFieldLabels {\n /** Stepper button names. Defaults: \"Decrease\", \"Increase\". */\n decrement: string;\n increment: string;\n}\n\nexport interface NumberFieldProps extends FieldLayoutProps {\n /** Visible label; it names the field. */\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. */\n description?: ReactNode;\n /** Error message shown below the field; it marks the field invalid. */\n error?: ReactNode;\n /** `null` is empty. */\n value?: number | null | undefined;\n /** Starting value when uncontrolled; `null` is empty. */\n defaultValue?: number | null;\n /** Called with the new value when it is committed: a step, Enter, or leaving the field. */\n onChange?: ((value: number | null) => void) | undefined;\n /** Smallest value. Typed and stepped values are kept at or above it, and Home jumps to it. */\n min?: number | undefined;\n /** Largest value. Typed and stepped values are kept at or below it, and End jumps to it. */\n max?: number | undefined;\n /** Arrow keys and steppers move by this; values they produce snap to it. Default 1. */\n step?: number;\n /** Page Up and Page Down move by this. Default: 10 steps. */\n largeStep?: number;\n /** Locale for reading and writing numbers. Default: the browser's. */\n locale?: string | undefined;\n /** How the value is written: currency, percent, units, digits… (`Intl.NumberFormat` options). */\n formatOptions?: Intl.NumberFormatOptions | undefined;\n /** Hide the − and + buttons (the keyboard still steps). */\n hideSteppers?: boolean;\n /** Name the plain number 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 /** Marks the field as required for form validation. */\n required?: boolean | undefined;\n /** Turns off the field and its stepper buttons. */\n disabled?: boolean | undefined;\n /** The value can be read but not changed. */\n readOnly?: boolean | undefined;\n /** Hint shown while the field is empty. */\n placeholder?: string | undefined;\n /** Size of the field. Default \"md\". */\n size?: Size;\n /** `outline` or `soft` (tinted, borderless until focus). Default \"outline\". */\n variant?: \"outline\" | \"soft\";\n /** Replace the built-in English text: the stepper button names. */\n labels?: Partial<NumberFieldLabels>;\n /**\n * Drag the label sideways to change the value, as design tools do: one `step` every few pixels, Shift for ten. Escape\n * mid-drag puts it back. The keys and the steppers still work as before.\n */\n scrub?: boolean;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: NumberFieldLabels = { decrement: \"Decrease\", increment: \"Increase\" };\n\n/** The marks a format writes, learnt from `Intl.NumberFormat` itself so every locale reads its own output. */\ninterface NumberMarks {\n group: string;\n decimal: string;\n minus: string;\n /** The ten digits of its numbering system, 0 to 9 (Arabic-Indic, Devanagari…). */\n digits: string[];\n /** Currency, percent and unit text and literals (\"kr.\", \"%\", \"km/h\"), longest first. */\n affixes: string[];\n}\n\nconst marksCache = new Map<string, NumberMarks>();\nconst SAMPLES = [-1234567.5, 1234567.5, 1, 2];\n\nfunction marksOf(locale: string | undefined, options: Intl.NumberFormatOptions | undefined): NumberMarks {\n const id = JSON.stringify([locale ?? \"\", options ?? {}]);\n const known = marksCache.get(id);\n if (known) return known;\n const plain = new Intl.NumberFormat(locale);\n const numberingSystem = (\n options?.numberingSystem ? new Intl.NumberFormat(locale, options) : plain\n ).resolvedOptions().numberingSystem;\n // The separators and signs of the field's own style (a currency may group differently), else of plain numbers.\n let styled: Intl.NumberFormatPart[] = [];\n try {\n styled = SAMPLES.flatMap((n) =>\n new Intl.NumberFormat(locale, {\n ...options,\n minimumFractionDigits: 1,\n maximumFractionDigits: 1,\n minimumSignificantDigits: undefined,\n maximumSignificantDigits: undefined,\n }).formatToParts(n),\n );\n } catch {\n // Options that refuse one fraction digit: plain numbers' marks are enough.\n }\n const parts = [...styled, ...plain.formatToParts(-12345.6)];\n const of = (type: string, fallback: string) => parts.find((p) => p.type === type)?.value ?? fallback;\n const digitFormat = new Intl.NumberFormat(locale, { numberingSystem, useGrouping: false });\n const marks: NumberMarks = {\n group: of(\"group\", \",\"),\n decimal: of(\"decimal\", \".\"),\n minus: of(\"minusSign\", \"-\"),\n digits: Array.from({ length: 10 }, (_, d) => digitFormat.format(d)),\n affixes: [\n ...new Set(\n styled\n .filter((p) => [\"currency\", \"percentSign\", \"unit\", \"literal\", \"compact\"].includes(p.type))\n .map((p) => p.value.trim())\n .filter(Boolean),\n ),\n ].sort((x, y) => y.length - x.length),\n };\n marksCache.set(id, marks);\n return marks;\n}\n\n/** Bidirectional marks some locales put around signs (Arabic's U+061C before the minus). */\nconst BIDI = /[\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]/g;\n\n/**\n * Reads what a person typed, or what the field wrote, in `locale` and `options`: the locale's digits (Arabic-Indic,\n * Devanagari…), group separators, decimal mark and minus, a typographic minus, currency, percent and unit text, and\n * accounting brackets.\n */\nexport function parseNumber(\n text: string,\n locale?: string,\n options?: Intl.NumberFormatOptions,\n): number | null {\n const { group, decimal, minus, digits, affixes } = marksOf(locale, options);\n let t = text.replace(BIDI, \"\");\n // Accounting style writes a negative amount in brackets.\n const bracketed = /\\(.*\\)/.test(t);\n // Currency, percent and unit text first, so a dot in \"kr.\" is not read as a separator.\n for (const affix of affixes)\n if (affix !== group.trim() && affix !== decimal && affix !== minus.replace(BIDI, \"\"))\n t = t.split(affix).join(\" \");\n t = t.replace(/\\p{Nd}/gu, (c) => {\n const local = digits.indexOf(c);\n return local >= 0 ? String(local) : c;\n });\n t = t.replace(/[()]/g, \"\");\n const minusMark = minus.replace(BIDI, \"\");\n if (minusMark && minusMark !== \"-\") t = t.split(minusMark).join(\"-\");\n t = t.replace(/[−‒–]/g, \"-\");\n // A group mark that is a space (French, Swedish) matches any space; a typographic apostrophe matches a plain one.\n if (!group.trim()) t = t.replace(/\\s/g, \"\");\n else {\n t = t.split(group).join(\"\");\n if (group === \"’\") t = t.split(\"'\").join(\"\");\n }\n const cleaned = t\n .replace(/\\s/g, \"\")\n .split(decimal)\n .join(\".\")\n .replace(/[^\\d.-]/g, \"\");\n if (!/^-?\\d*\\.?\\d+$|^-?\\d+\\.?$/.test(cleaned)) return null;\n let n = Number(cleaned);\n if (!Number.isFinite(n)) return null;\n if (bracketed && n > 0) n = -n;\n // Percent text is a hundred times the value; round away the noise of dividing (12.5% is 0.125).\n return options?.style === \"percent\" ? Number((n / 100).toPrecision(15)) : n;\n}\n\n/**\n * A number input: type it in your own format, or step it with the arrow keys, Page Up/Down, Home/End or the − and +\n * buttons. APG spinbutton; locale-aware; takes part in forms with the plain number.\n */\nexport function NumberField({\n label,\n labelHidden,\n layout,\n width,\n description,\n error,\n value,\n defaultValue = null,\n onChange,\n min,\n max,\n step = 1,\n largeStep,\n locale,\n formatOptions,\n hideSteppers = false,\n name,\n form,\n required,\n disabled,\n readOnly,\n placeholder,\n size = \"md\",\n variant = \"outline\",\n labels,\n scrub = false,\n className,\n style,\n}: NumberFieldProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [current, setCurrent, resetCurrent] = useControllableState<number | null>(\n value,\n defaultValue,\n onChange,\n );\n const [draft, setDraft] = useState<string | null>(null);\n const input = useRef<HTMLInputElement>(null);\n const format = useMemo(\n () => new Intl.NumberFormat(locale, { maximumFractionDigits: 20, ...formatOptions }),\n [locale, formatOptions],\n );\n const shown = (n: number | null) => (n === null ? \"\" : format.format(n));\n\n const limit = (n: number) => clamp(n, min ?? Number.NEGATIVE_INFINITY, max ?? Number.POSITIVE_INFINITY);\n const commit = (next: number | null) => {\n setDraft(null);\n if (next !== current) setCurrent(next);\n };\n const stepBy = (delta: number) => {\n if (disabled || readOnly) return;\n const base = min ?? 0;\n const from = draft !== null ? (parseNumber(draft, locale, formatOptions) ?? current) : current;\n const start = from ?? (delta > 0 ? (min ?? 0) : (max ?? 0));\n // Snap onto the step grid (counted from min), without floating-point noise (0.3, not 0.30000000000000004).\n commit(limit(from === null ? roundLike(start, step, base) : snapToStep(start + delta, step, base)));\n };\n const commitDraft = () => {\n if (draft === null) return;\n if (draft.trim() === \"\") return commit(null);\n const parsed = parseNumber(draft, locale, formatOptions);\n // Unreadable text goes back to the last good value.\n commit(parsed === null ? current : limit(parsed));\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n const big = largeStep ?? step * 10;\n const moves: Record<string, () => void> = {\n ArrowUp: () => stepBy(step),\n ArrowDown: () => stepBy(-step),\n PageUp: () => stepBy(big),\n PageDown: () => stepBy(-big),\n Enter: commitDraft,\n };\n if (min !== undefined) moves.Home = () => !disabled && !readOnly && commit(min);\n if (max !== undefined) moves.End = () => !disabled && !readOnly && commit(max);\n const move = moves[event.key];\n if (!move) return;\n if (event.key !== \"Enter\") event.preventDefault();\n move();\n };\n\n // Scrubbing: the field's own <label> is the handle.\n const handle = useRef<HTMLElement | null>(null);\n useClientLayoutEffect(() => {\n const el =\n scrub && !disabled && !readOnly\n ? ((input.current?.labels?.[0] as HTMLElement | undefined) ?? null)\n : null;\n if (handle.current && handle.current !== el) delete handle.current.dataset.scrub;\n if (el) el.dataset.scrub = \"\";\n handle.current = el;\n });\n const scrubFrom = useRef<number | null>(null);\n useDrag(handle, {\n distance: 3,\n touchAction: \"css\",\n onStart: () => {\n scrubFrom.current = current;\n },\n onMove: ({ delta, event }) => {\n const steps = Math.round(delta.x / 4) * (event.shiftKey ? 10 : 1);\n const from = scrubFrom.current ?? min ?? 0;\n commit(limit(roundLike(from + steps * step, step, min ?? 0)));\n },\n onEnd: (_, cancelled) => {\n if (cancelled) commit(scrubFrom.current);\n input.current?.focus({ preventScroll: true });\n },\n });\n\n const atMin = current !== null && min !== undefined && current <= min;\n const atMax = current !== null && max !== undefined && current >= max;\n const integers = Number.isInteger(step) && (min ?? 0) >= 0 && formatOptions?.style !== \"percent\";\n\n return (\n <>\n <TextField\n ref={input}\n label={label}\n labelHidden={labelHidden}\n layout={layout}\n width={width}\n description={description}\n error={error}\n size={size}\n variant={variant}\n className={className ? `cy-number-field ${className}` : \"cy-number-field\"}\n {...(style ? { style } : {})}\n role=\"spinbutton\"\n inputMode={integers ? \"numeric\" : \"decimal\"}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-valuenow={ariaNumber(current)}\n aria-valuemin={ariaNumber(min)}\n aria-valuemax={ariaNumber(max)}\n aria-valuetext={current === null ? undefined : shown(current)}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n placeholder={placeholder}\n form={form}\n value={draft ?? shown(current)}\n onChange={setDraft}\n onKeyDown={onKeyDown}\n onBlur={commitDraft}\n addonEnd={\n !hideSteppers && (\n <span className=\"cy-number-field-steppers\">\n <IconButton\n icon={minus}\n label={text.decrement}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMin}\n onClick={() => {\n stepBy(-step);\n input.current?.focus();\n }}\n />\n <IconButton\n icon={plus}\n label={text.increment}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMax}\n onClick={() => {\n stepBy(step);\n input.current?.focus();\n }}\n />\n </span>\n )\n }\n />\n <HiddenValue\n name={name}\n form={form}\n value={current === null ? \"\" : plainNumber(current)}\n disabled={disabled}\n onReset={() => {\n setDraft(null);\n resetCurrent(defaultValue);\n }}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA6EA,IAAMoB,KAAoC;AAAA,EAAE,WAAW;AAAA,EAAY,WAAW;AAAW,GAanFC,IAAa,oBAAI,IAAyB,GAC1CC,KAAU;AAAA,EAAC;AAAA,EAAY;AAAA,EAAW;AAAA,EAAG;AAAC;AAE5C,SAASC,GAAQC,GAA4BC,GAA4D;AACvG,QAAMC,IAAK,KAAK,UAAU,CAACF,KAAU,IAAIC,KAAW,CAAC,CAAC,CAAC,GACjDE,IAAQN,EAAW,IAAIK,CAAE;AAC/B,MAAIC,EAAO,QAAOA;AAClB,QAAMC,IAAQ,IAAI,KAAK,aAAaJ,CAAM,GACpCK,KACJJ,GAAS,kBAAkB,IAAI,KAAK,aAAaD,GAAQC,CAAO,IAAIG,GACpE,gBAAgB,EAAE;AAEpB,MAAIE,IAAkC,CAAC;AACvC,MAAI;AACF,IAAAA,IAASR,GAAQ,QAAA,CAASS,MACxB,IAAI,KAAK,aAAaP,GAAQ;AAAA,MAC5B,GAAGC;AAAA,MACH,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,MACvB,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,IAC5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;AAAA,IAClD,UAAAV;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACG,aAAAC;AAAA,IACP,MAAAJ;AAAA,IACN,OAAOc,KAASI,EAAMP,CAAO;AAAA,IAC7B,UAAUI;AAAA,IACC,WAAAc;AAAA,IACX,QAAQF;AAAA,IACR,UACE,CAAC7B,KACC,gBAAArD,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAhB,UAAA,CACE,gBAAAD,EAACV,GAAD;AAAA,QACE,MAAMC;AAAA,QACN,OAAOoC,EAAK;AAAA,QACZ,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,UAAU;AAAA,QACV,UAAU+B,KAAYC,KAAYoC;AAAA,QAClC,SAAA,MAAe;AACb,UAAAjB,EAAO,CAAC3B,CAAI,GACZqB,EAAM,SAAS,MAAM;AAAA,QACvB;AAAA,MACD,CAAA,GACD,gBAAAxE,EAACV,GAAD;AAAA,QACE,MAAME;AAAA,QACN,OAAOmC,EAAK;AAAA,QACZ,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,UAAU;AAAA,QACV,UAAU+B,KAAYC,KAAYqC;AAAA,QAClC,SAAA,MAAe;AACb,UAAAlB,EAAO3B,CAAI,GACXqB,EAAM,SAAS,MAAM;AAAA,QACvB;AAAA,MACD,CAAA,CACG;AAAA,I;A,EAGX,CAAA,GACD,gBAAAxE,EAACL,IAAD;AAAA,IACQ,MAAA4D;AAAA,IACA,MAAAC;AAAA,IACN,OAAOW,MAAY,OAAO,KAAKhF,GAAYgF,CAAO;AAAA,IACxC,UAAAT;AAAA,IACV,SAAA,MAAe;AACb,MAAAa,EAAS,IAAI,GACbF,GAAatB,CAAY;AAAA,IAC3B;AAAA,EACD,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type CSSProperties, type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import type { IconData } from "../../icons/types.js";
|
|
3
|
+
export interface OptionListTokens {
|
|
4
|
+
bg: string;
|
|
5
|
+
shadow: string;
|
|
6
|
+
maxHeight: string;
|
|
7
|
+
maxWidth: string;
|
|
8
|
+
activeBg: string;
|
|
9
|
+
}
|
|
10
|
+
declare module "../../tokens/schema.js" {
|
|
11
|
+
interface ComponentTokens {
|
|
12
|
+
optionList: OptionListTokens;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** An action at the foot of a field's list ("Manage connections…"): Select's and Combobox's `footer`. */
|
|
16
|
+
export interface OptionListAction {
|
|
17
|
+
/** The action's text. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Icon before the text. */
|
|
20
|
+
icon?: IconData;
|
|
21
|
+
/** Runs the action, after the list has closed. The field's value does not change. */
|
|
22
|
+
onSelect: () => void;
|
|
23
|
+
}
|
|
24
|
+
export interface OptionListProps {
|
|
25
|
+
/** The list's id: the field's `aria-controls`, and the prefix of the options' ids. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Accessible name, when no visible label names the list through `aria-labelledby`. */
|
|
28
|
+
label?: string | undefined;
|
|
29
|
+
/** The id of the visible label that names the list. */
|
|
30
|
+
"aria-labelledby"?: string | undefined;
|
|
31
|
+
/** Options are still loading (`aria-busy`). */
|
|
32
|
+
busy?: boolean | undefined;
|
|
33
|
+
/** Added to the root element, for layout. */
|
|
34
|
+
className?: string;
|
|
35
|
+
/** Layout only. Restyle through --cy-option-list-* tokens. */
|
|
36
|
+
style?: CSSProperties;
|
|
37
|
+
/** OptionListItem, OptionListNote and OptionListGroup. */
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* An action pinned under the options, set off by a line and kept in view while they scroll ("Manage
|
|
41
|
+
* connections…"). The list draws it as an option (a listbox holds only options), so the field's arrow keys reach it
|
|
42
|
+
* after the last option and Enter runs it, while focus stays in the field. Select's and Combobox's `footer`.
|
|
43
|
+
*/
|
|
44
|
+
footer?: OptionListFooter | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The footer row: an action the list draws and the field that owns the list runs. */
|
|
47
|
+
export interface OptionListFooter {
|
|
48
|
+
/** The action: its label, icon and what it does. */
|
|
49
|
+
action: OptionListAction;
|
|
50
|
+
/** The row's id, the target of the field's `aria-activedescendant` (with `useActiveOption`, `optionId(count)`). */
|
|
51
|
+
id: string;
|
|
52
|
+
/** The arrow keys are on it (highlighted). */
|
|
53
|
+
active: boolean;
|
|
54
|
+
/** The pointer moved over it: make it the active option. */
|
|
55
|
+
onActive: () => void;
|
|
56
|
+
/** A press on it: close the list, then run the action. */
|
|
57
|
+
onRun: () => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The drop-down list of options under a field: Select, Combobox, TagInput and TextArea's mentions draw their lists
|
|
61
|
+
* with it. It is a manual popover; show, place and dismiss it with `useListboxLayer`, and move the active option with
|
|
62
|
+
* `aria-activedescendant` from the field, which keeps focus.
|
|
63
|
+
*/
|
|
64
|
+
export declare const OptionList: import("react").ForwardRefExoticComponent<OptionListProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
65
|
+
export interface OptionListItemProps extends Omit<HTMLAttributes<HTMLDivElement>, "role" | "tabIndex" | "className" | "style" | "children"> {
|
|
66
|
+
/** The option's id, the target of the field's `aria-activedescendant`. */
|
|
67
|
+
id: string;
|
|
68
|
+
/** The option's text. */
|
|
69
|
+
label: ReactNode;
|
|
70
|
+
/** A second, muted line under the label. */
|
|
71
|
+
description?: ReactNode;
|
|
72
|
+
/** Drawn before the text: the option's icon. */
|
|
73
|
+
icon?: ReactNode;
|
|
74
|
+
/** The chosen option (`aria-selected`). */
|
|
75
|
+
selected?: boolean;
|
|
76
|
+
/** The option the arrow keys are on (highlighted). */
|
|
77
|
+
active?: boolean;
|
|
78
|
+
/** Shown but not choosable (`aria-disabled`). */
|
|
79
|
+
disabled?: boolean | undefined;
|
|
80
|
+
/** Drawn at the end of the row, smaller and muted: a shortcut, a count. */
|
|
81
|
+
trailing?: ReactNode;
|
|
82
|
+
/** Drawn muted but still choosable: an option that is there but not in use (a saved, unconnected connection). */
|
|
83
|
+
dimmed?: boolean | undefined;
|
|
84
|
+
}
|
|
85
|
+
/** One option of an OptionList. A press never moves focus out of the field the list drops down from. */
|
|
86
|
+
export declare function OptionListItem({ id, label, description, icon, selected, active, disabled, trailing, dimmed, onPointerDown, ...rest }: OptionListItemProps): import("react").JSX.Element;
|
|
87
|
+
export interface OptionListNoteProps {
|
|
88
|
+
/** The text: "No matches", "Loading…". */
|
|
89
|
+
children: ReactNode;
|
|
90
|
+
}
|
|
91
|
+
/** A line in place of options (nothing matches, still loading): an option that cannot be chosen. */
|
|
92
|
+
export declare function OptionListNote({ children }: OptionListNoteProps): import("react").JSX.Element;
|
|
93
|
+
export interface OptionListGroupProps {
|
|
94
|
+
/** The heading's id (it names the group). */
|
|
95
|
+
id: string;
|
|
96
|
+
/** The heading: small and muted, passed over by the arrow keys. */
|
|
97
|
+
label: ReactNode;
|
|
98
|
+
/** The group's OptionListItems. */
|
|
99
|
+
children: ReactNode;
|
|
100
|
+
}
|
|
101
|
+
/** A labelled run of options inside an OptionList. */
|
|
102
|
+
export declare function OptionListGroup({ id, label, children }: OptionListGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Icon as v } from "../../foundations/Icon/Icon.js";
|
|
3
|
+
import { forwardRef as y } from "react";
|
|
4
|
+
import { jsx as o, jsxs as c } from "react/jsx-runtime";
|
|
5
|
+
var x = y(function({ id: e, label: a, "aria-labelledby": t, busy: r, className: l, style: d, children: s, footer: i }, p) {
|
|
6
|
+
return /* @__PURE__ */ c("div", {
|
|
7
|
+
ref: p,
|
|
8
|
+
id: e,
|
|
9
|
+
role: "listbox",
|
|
10
|
+
"aria-label": t ? void 0 : a,
|
|
11
|
+
"aria-labelledby": t,
|
|
12
|
+
"aria-busy": r || void 0,
|
|
13
|
+
className: `cy-option-list${l ? ` ${l}` : ""}`,
|
|
14
|
+
style: d,
|
|
15
|
+
popover: "manual",
|
|
16
|
+
children: [s, i && /* @__PURE__ */ o("div", {
|
|
17
|
+
role: "none",
|
|
18
|
+
className: "cy-option-list-footer cy-reset",
|
|
19
|
+
children: /* @__PURE__ */ o(b, {
|
|
20
|
+
id: i.id,
|
|
21
|
+
label: i.action.label,
|
|
22
|
+
icon: i.action.icon && /* @__PURE__ */ o(v, {
|
|
23
|
+
icon: i.action.icon,
|
|
24
|
+
className: "cy-option-list-icon"
|
|
25
|
+
}),
|
|
26
|
+
active: i.active,
|
|
27
|
+
onPointerMove: i.onActive,
|
|
28
|
+
onClick: i.onRun
|
|
29
|
+
})
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
function b({ id: n, label: e, description: a, icon: t, selected: r = !1, active: l = !1, disabled: d, trailing: s, dimmed: i, onPointerDown: p, ...m }) {
|
|
34
|
+
return /* @__PURE__ */ c("div", {
|
|
35
|
+
...m,
|
|
36
|
+
id: n,
|
|
37
|
+
role: "option",
|
|
38
|
+
"aria-selected": r,
|
|
39
|
+
"aria-disabled": d || void 0,
|
|
40
|
+
"data-active": l ? "" : void 0,
|
|
41
|
+
"data-dimmed": i ? "" : void 0,
|
|
42
|
+
className: "cy-option-list-option",
|
|
43
|
+
tabIndex: -1,
|
|
44
|
+
onPointerDown: (u) => {
|
|
45
|
+
u.preventDefault(), p?.(u);
|
|
46
|
+
},
|
|
47
|
+
onKeyDown: m.onKeyDown ?? (() => {
|
|
48
|
+
}),
|
|
49
|
+
children: [
|
|
50
|
+
t,
|
|
51
|
+
/* @__PURE__ */ c("span", {
|
|
52
|
+
className: "cy-option-list-text",
|
|
53
|
+
children: [/* @__PURE__ */ o("span", {
|
|
54
|
+
className: "cy-option-list-label",
|
|
55
|
+
children: e
|
|
56
|
+
}), a && /* @__PURE__ */ o("span", {
|
|
57
|
+
className: "cy-option-list-description",
|
|
58
|
+
children: a
|
|
59
|
+
})]
|
|
60
|
+
}),
|
|
61
|
+
s && /* @__PURE__ */ o("span", {
|
|
62
|
+
className: "cy-option-list-trailing",
|
|
63
|
+
children: s
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function L({ children: n }) {
|
|
69
|
+
return /* @__PURE__ */ o("div", {
|
|
70
|
+
role: "option",
|
|
71
|
+
"aria-disabled": "true",
|
|
72
|
+
"aria-selected": "false",
|
|
73
|
+
tabIndex: -1,
|
|
74
|
+
className: "cy-option-list-note",
|
|
75
|
+
children: n
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function O({ id: n, label: e, children: a }) {
|
|
79
|
+
return /* @__PURE__ */ c("div", {
|
|
80
|
+
role: "group",
|
|
81
|
+
"aria-labelledby": n,
|
|
82
|
+
className: "cy-option-list-group cy-reset",
|
|
83
|
+
children: [/* @__PURE__ */ o("div", {
|
|
84
|
+
id: n,
|
|
85
|
+
className: "cy-option-list-group-label",
|
|
86
|
+
role: "presentation",
|
|
87
|
+
children: e
|
|
88
|
+
}), a]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
x as OptionList,
|
|
93
|
+
O as OptionListGroup,
|
|
94
|
+
b as OptionListItem,
|
|
95
|
+
L as OptionListNote
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=OptionList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptionList.js","names":["Icon","forwardRef","jsx","jsxs","OptionList","id","label","labelledBy","busy","className","style","children","footer","ref","OptionListItem","description","icon","selected","active","disabled","trailing","dimmed","onPointerDown","rest","event","OptionListNote","OptionListGroup"],"sources":["../../../src/components/OptionList/OptionList.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\n\nexport interface OptionListTokens {\n bg: string;\n shadow: string;\n maxHeight: string;\n maxWidth: string;\n activeBg: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n optionList: OptionListTokens;\n }\n}\n\n/** An action at the foot of a field's list (\"Manage connections…\"): Select's and Combobox's `footer`. */\nexport interface OptionListAction {\n /** The action's text. */\n label: string;\n /** Icon before the text. */\n icon?: IconData;\n /** Runs the action, after the list has closed. The field's value does not change. */\n onSelect: () => void;\n}\n\nexport interface OptionListProps {\n /** The list's id: the field's `aria-controls`, and the prefix of the options' ids. */\n id: string;\n /** Accessible name, when no visible label names the list through `aria-labelledby`. */\n label?: string | undefined;\n /** The id of the visible label that names the list. */\n \"aria-labelledby\"?: string | undefined;\n /** Options are still loading (`aria-busy`). */\n busy?: boolean | undefined;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-option-list-* tokens. */\n style?: CSSProperties;\n /** OptionListItem, OptionListNote and OptionListGroup. */\n children?: ReactNode;\n /**\n * An action pinned under the options, set off by a line and kept in view while they scroll (\"Manage\n * connections…\"). The list draws it as an option (a listbox holds only options), so the field's arrow keys reach it\n * after the last option and Enter runs it, while focus stays in the field. Select's and Combobox's `footer`.\n */\n footer?: OptionListFooter | undefined;\n}\n\n/** The footer row: an action the list draws and the field that owns the list runs. */\nexport interface OptionListFooter {\n /** The action: its label, icon and what it does. */\n action: OptionListAction;\n /** The row's id, the target of the field's `aria-activedescendant` (with `useActiveOption`, `optionId(count)`). */\n id: string;\n /** The arrow keys are on it (highlighted). */\n active: boolean;\n /** The pointer moved over it: make it the active option. */\n onActive: () => void;\n /** A press on it: close the list, then run the action. */\n onRun: () => void;\n}\n\n/**\n * The drop-down list of options under a field: Select, Combobox, TagInput and TextArea's mentions draw their lists\n * with it. It is a manual popover; show, place and dismiss it with `useListboxLayer`, and move the active option with\n * `aria-activedescendant` from the field, which keeps focus.\n */\nexport const OptionList = forwardRef<HTMLDivElement, OptionListProps>(function OptionList(\n { id, label, \"aria-labelledby\": labelledBy, busy, className, style, children, footer },\n ref,\n) {\n return (\n <div\n ref={ref}\n id={id}\n role=\"listbox\"\n aria-label={labelledBy ? undefined : label}\n aria-labelledby={labelledBy}\n aria-busy={busy || undefined}\n className={`cy-option-list${className ? ` ${className}` : \"\"}`}\n style={style}\n {...{ popover: \"manual\" }}\n >\n {children}\n {footer && (\n <div role=\"none\" className=\"cy-option-list-footer cy-reset\">\n <OptionListItem\n id={footer.id}\n label={footer.action.label}\n icon={footer.action.icon && <Icon icon={footer.action.icon} className=\"cy-option-list-icon\" />}\n active={footer.active}\n onPointerMove={footer.onActive}\n onClick={footer.onRun}\n />\n </div>\n )}\n </div>\n );\n});\n\nexport interface OptionListItemProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"role\" | \"tabIndex\" | \"className\" | \"style\" | \"children\"> {\n /** The option's id, the target of the field's `aria-activedescendant`. */\n id: string;\n /** The option's text. */\n label: ReactNode;\n /** A second, muted line under the label. */\n description?: ReactNode;\n /** Drawn before the text: the option's icon. */\n icon?: ReactNode;\n /** The chosen option (`aria-selected`). */\n selected?: boolean;\n /** The option the arrow keys are on (highlighted). */\n active?: boolean;\n /** Shown but not choosable (`aria-disabled`). */\n disabled?: boolean | undefined;\n /** Drawn at the end of the row, smaller and muted: a shortcut, a count. */\n trailing?: ReactNode;\n /** Drawn muted but still choosable: an option that is there but not in use (a saved, unconnected connection). */\n dimmed?: boolean | undefined;\n}\n\n/** One option of an OptionList. A press never moves focus out of the field the list drops down from. */\nexport function OptionListItem({\n id,\n label,\n description,\n icon,\n selected = false,\n active = false,\n disabled,\n trailing,\n dimmed,\n onPointerDown,\n ...rest\n}: OptionListItemProps) {\n return (\n <div\n {...rest}\n id={id}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={disabled || undefined}\n data-active={active ? \"\" : undefined}\n data-dimmed={dimmed ? \"\" : undefined}\n className=\"cy-option-list-option\"\n tabIndex={-1}\n onPointerDown={(event) => {\n // Keep focus in the field: the options are aria-activedescendant targets.\n event.preventDefault();\n onPointerDown?.(event);\n }}\n onKeyDown={rest.onKeyDown ?? (() => {})}\n >\n {icon}\n <span className=\"cy-option-list-text\">\n <span className=\"cy-option-list-label\">{label}</span>\n {description && <span className=\"cy-option-list-description\">{description}</span>}\n </span>\n {trailing && <span className=\"cy-option-list-trailing\">{trailing}</span>}\n </div>\n );\n}\n\nexport interface OptionListNoteProps {\n /** The text: \"No matches\", \"Loading…\". */\n children: ReactNode;\n}\n\n/** A line in place of options (nothing matches, still loading): an option that cannot be chosen. */\nexport function OptionListNote({ children }: OptionListNoteProps) {\n return (\n <div\n role=\"option\"\n aria-disabled=\"true\"\n aria-selected=\"false\"\n tabIndex={-1}\n className=\"cy-option-list-note\"\n >\n {children}\n </div>\n );\n}\n\nexport interface OptionListGroupProps {\n /** The heading's id (it names the group). */\n id: string;\n /** The heading: small and muted, passed over by the arrow keys. */\n label: ReactNode;\n /** The group's OptionListItems. */\n children: ReactNode;\n}\n\n/** A labelled run of options inside an OptionList. */\nexport function OptionListGroup({ id, label, children }: OptionListGroupProps) {\n return (\n // biome-ignore lint/a11y/useSemanticElements: a group of options inside a listbox; a fieldset is a form control\n <div role=\"group\" aria-labelledby={id} className=\"cy-option-list-group cy-reset\">\n <div id={id} className=\"cy-option-list-group-label\" role=\"presentation\">\n {label}\n </div>\n {children}\n </div>\n );\n}\n"],"mappings":";;;;AAsEA,IAAaI,IAAaH,EAA4C,SACpE,EAAE,IAAAI,GAAI,OAAAC,GAAO,mBAAmBC,GAAY,MAAAC,GAAM,WAAAC,GAAW,OAAAC,GAAO,UAAAC,GAAU,QAAAC,EAAA,GAC9EC,GACA;AACA,SACE,gBAAAV,EAAC,OAAD;AAAA,IACO,KAAAU;AAAA,IACD,IAAAR;AAAA,IACJ,MAAK;AAAA,IACL,cAAYE,IAAa,SAAYD;AAAA,IACrC,mBAAiBC;AAAA,IACjB,aAAWC,KAAQ;AAAA,IACnB,WAAW,iBAAiBC,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACnD,OAAAC;AAAA,IACD,SAAS;AAAA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;AAAA,UAA8B,UAAAa;AAAA,QAAkB,CAAA,CAC5E;AAAA,M;A,MACLK,KAAY,gBAAAlB,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAA2B,UAAAkB;AAAA,MAAe,CAAA;AAAA,IACpE;AAAA,E;AAET;AAQA,SAAgBK,EAAe,EAAE,UAAAd,EAAA,GAAiC;AAChE,SACE,gBAAAT,EAAC,OAAD;AAAA,IACE,MAAK;AAAA,IACL,iBAAc;AAAA,IACd,iBAAc;AAAA,IACd,UAAU;AAAA,IACV,WAAU;AAAA,IAET,UAAAS;AAAA,EACE,CAAA;AAET;AAYA,SAAgBe,EAAgB,EAAE,IAAArB,GAAI,OAAAC,GAAO,UAAAK,EAAA,GAAkC;AAC7E,SAEE,gBAAAR,EAAC,OAAD;AAAA,IAAK,MAAK;AAAA,IAAQ,mBAAiBE;AAAA,IAAI,WAAU;AAAA,IAAjD,UAAA,CACE,gBAAAH,EAAC,OAAD;AAAA,MAAS,IAAAG;AAAA,MAAI,WAAU;AAAA,MAA6B,MAAK;AAAA,MACtD,UAAAC;AAAA,IACE,CAAA,GACJK,CACE;AAAA,E;AAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OptionList, type OptionListAction, OptionListGroup, type OptionListGroupProps, OptionListItem, type OptionListItemProps, OptionListNote, type OptionListNoteProps, type OptionListProps, type OptionListTokens, } from "./OptionList.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
export interface OverlayFrameTokens {
|
|
3
|
+
/** Space between the bottom edge and the overlay. */
|
|
4
|
+
offset: string;
|
|
5
|
+
/** Stacking order of the overlay over the content (sticky rows, a pinned heading). */
|
|
6
|
+
layer: string;
|
|
7
|
+
}
|
|
8
|
+
declare module "../../tokens/schema.js" {
|
|
9
|
+
interface ComponentTokens {
|
|
10
|
+
overlayFrame: OverlayFrameTokens;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface OverlayFrameProps {
|
|
14
|
+
/**
|
|
15
|
+
* Content pinned over the frame at the bottom centre that does not scroll with what it covers: a "3 new" pill, a
|
|
16
|
+
* "jump to latest" button. Nothing (null, undefined or false): no overlay.
|
|
17
|
+
*/
|
|
18
|
+
overlay?: ReactNode;
|
|
19
|
+
/** What the overlay sits over: one element (a scroller) that fills the frame. */
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
/** Added to the root element, for layout. */
|
|
22
|
+
className?: string | undefined;
|
|
23
|
+
/** Layout only. Restyle through --cy-overlay-frame-* tokens. */
|
|
24
|
+
style?: CSSProperties | undefined;
|
|
25
|
+
/** Set on the root element, for tests. */
|
|
26
|
+
"data-testid"?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A frame whose content fills it, with an overlay at the bottom centre that stays put while the content scrolls
|
|
30
|
+
* under it. ScrollArea and VirtualList hold their scroller in one. The frame is always there, overlay or not, so an
|
|
31
|
+
* overlay that comes and goes never remounts the content (which would lose its scroll position).
|
|
32
|
+
*/
|
|
33
|
+
export declare const OverlayFrame: import("react").ForwardRefExoticComponent<OverlayFrameProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
|
+
import { jsx as o, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
var t = f(function({ overlay: r, children: a, className: e, style: l, ...m }, c) {
|
|
5
|
+
return /* @__PURE__ */ i("div", {
|
|
6
|
+
ref: c,
|
|
7
|
+
...m,
|
|
8
|
+
className: e ? `cy-overlay-frame ${e}` : "cy-overlay-frame",
|
|
9
|
+
style: l,
|
|
10
|
+
children: [a, r != null && r !== !1 && /* @__PURE__ */ o("div", {
|
|
11
|
+
className: "cy-overlay-frame-overlay cy-reset",
|
|
12
|
+
children: r
|
|
13
|
+
})]
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
t as OverlayFrame
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=OverlayFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayFrame.js","names":["forwardRef","jsx","jsxs","OverlayFrame","overlay","children","className","style","rest","ref"],"sources":["../../../src/components/OverlayFrame/OverlayFrame.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode } from \"react\";\n\nexport interface OverlayFrameTokens {\n /** Space between the bottom edge and the overlay. */\n offset: string;\n /** Stacking order of the overlay over the content (sticky rows, a pinned heading). */\n layer: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n overlayFrame: OverlayFrameTokens;\n }\n}\n\nexport interface OverlayFrameProps {\n /**\n * Content pinned over the frame at the bottom centre that does not scroll with what it covers: a \"3 new\" pill, a\n * \"jump to latest\" button. Nothing (null, undefined or false): no overlay.\n */\n overlay?: ReactNode;\n /** What the overlay sits over: one element (a scroller) that fills the frame. */\n children?: ReactNode;\n /** Added to the root element, for layout. */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-overlay-frame-* tokens. */\n style?: CSSProperties | undefined;\n /** Set on the root element, for tests. */\n \"data-testid\"?: string | undefined;\n}\n\n/**\n * A frame whose content fills it, with an overlay at the bottom centre that stays put while the content scrolls\n * under it. ScrollArea and VirtualList hold their scroller in one. The frame is always there, overlay or not, so an\n * overlay that comes and goes never remounts the content (which would lose its scroll position).\n */\nexport const OverlayFrame = forwardRef<HTMLDivElement, OverlayFrameProps>(function OverlayFrame(\n { overlay, children, className, style, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n {...rest}\n className={className ? `cy-overlay-frame ${className}` : \"cy-overlay-frame\"}\n style={style}\n >\n {children}\n {overlay != null && overlay !== false && (\n <div className=\"cy-overlay-frame-overlay cy-reset\">{overlay}</div>\n )}\n </div>\n );\n});\n"],"mappings":";;;AAoCA,IAAaG,IAAeH,EAA8C,SACxE,EAAE,SAAAI,GAAS,UAAAC,GAAU,WAAAC,GAAW,OAAAC,GAAO,GAAGC,EAAA,GAC1CC,GACA;AACA,SACE,gBAAAP,EAAC,OAAD;AAAA,IACO,KAAAO;AAAA,IACL,GAAID;AAAA,IACJ,WAAWF,IAAY,oBAAoBA,CAAA,KAAc;AAAA,IAClD,OAAAC;AAAA,IAJT,UAAA,CAMGF,GACAD,KAAW,QAAQA,MAAY,MAC9B,gBAAAH,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAqC,UAAAG;AAAA,IAAa,CAAA,CAEhE;AAAA,E;AAET,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OverlayFrame, type OverlayFrameProps, type OverlayFrameTokens } from "./OverlayFrame.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type HeadingSize } from "../Heading/Heading.js";
|
|
2
3
|
export interface PageHeaderTokens {
|
|
3
4
|
/** Space between the breadcrumbs, the title block, the actions and the content below them. */
|
|
4
5
|
gap: string;
|
|
@@ -28,6 +29,11 @@ export interface PageHeaderProps {
|
|
|
28
29
|
* Heading's sizes); "lg" is the hero "display" size for a landing page. Default "md".
|
|
29
30
|
*/
|
|
30
31
|
size?: "md" | "lg";
|
|
32
|
+
/**
|
|
33
|
+
* Any of Heading's sizes for the title, instead of the one `size` gives: `"3xl"` sits between "md" (2xl at level 1)
|
|
34
|
+
* and "lg" (display), for a section's landing page. The level and the rest of the header are unchanged.
|
|
35
|
+
*/
|
|
36
|
+
titleSize?: HeadingSize | undefined;
|
|
31
37
|
/** A short label above the title that says where the page belongs. It comes before the title in reading order. */
|
|
32
38
|
eyebrow?: ReactNode | undefined;
|
|
33
39
|
/** One or two sentences under the title, as a lead paragraph. Pass inline content only. */
|
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Heading as
|
|
3
|
-
import { Text as
|
|
4
|
-
import { forwardRef as
|
|
2
|
+
import { Heading as x } from "../Heading/Heading.js";
|
|
3
|
+
import { Text as p } from "../Text/Text.js";
|
|
4
|
+
import { forwardRef as u } from "react";
|
|
5
5
|
import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
6
|
-
var
|
|
7
|
-
return /* @__PURE__ */ a(
|
|
8
|
-
ref:
|
|
9
|
-
className:
|
|
6
|
+
var z = u(function({ title: y, headingLevel: n = 1, size: r = "md", titleSize: d, eyebrow: c, description: s, breadcrumbs: i, actions: l, meta: t, children: h, align: g = "start", divider: o = !1, as: v = "header", className: m, style: N }, f) {
|
|
7
|
+
return /* @__PURE__ */ a(v, {
|
|
8
|
+
ref: f,
|
|
9
|
+
className: m ? `cy-page-header ${m}` : "cy-page-header",
|
|
10
10
|
"data-size": r,
|
|
11
|
-
"data-align":
|
|
12
|
-
"data-divider":
|
|
13
|
-
style:
|
|
11
|
+
"data-align": g,
|
|
12
|
+
"data-divider": o ? "" : void 0,
|
|
13
|
+
style: N,
|
|
14
14
|
children: [
|
|
15
|
-
|
|
15
|
+
i && /* @__PURE__ */ e("div", {
|
|
16
16
|
className: "cy-page-header-breadcrumbs cy-reset",
|
|
17
|
-
children:
|
|
17
|
+
children: i
|
|
18
18
|
}),
|
|
19
19
|
/* @__PURE__ */ a("div", {
|
|
20
20
|
className: "cy-page-header-main cy-reset",
|
|
21
21
|
children: [/* @__PURE__ */ a("div", {
|
|
22
22
|
className: "cy-page-header-text cy-reset",
|
|
23
23
|
children: [
|
|
24
|
-
|
|
24
|
+
c && /* @__PURE__ */ e(p, {
|
|
25
25
|
as: "p",
|
|
26
26
|
variant: "eyebrow",
|
|
27
27
|
className: "cy-page-header-eyebrow",
|
|
28
|
-
children:
|
|
28
|
+
children: c
|
|
29
29
|
}),
|
|
30
|
-
/* @__PURE__ */ e(
|
|
31
|
-
level:
|
|
32
|
-
...r === "lg" ? { size: "display" } : {},
|
|
30
|
+
/* @__PURE__ */ e(x, {
|
|
31
|
+
level: n,
|
|
32
|
+
...d ? { size: d } : r === "lg" ? { size: "display" } : {},
|
|
33
33
|
className: "cy-page-header-title",
|
|
34
|
-
children:
|
|
34
|
+
children: y
|
|
35
35
|
}),
|
|
36
|
-
|
|
36
|
+
s && /* @__PURE__ */ e(p, {
|
|
37
37
|
as: "p",
|
|
38
38
|
variant: "lead",
|
|
39
39
|
className: "cy-page-header-description",
|
|
40
|
-
children:
|
|
40
|
+
children: s
|
|
41
41
|
}),
|
|
42
|
-
|
|
42
|
+
t && /* @__PURE__ */ e("div", {
|
|
43
43
|
className: "cy-page-header-meta",
|
|
44
|
-
children:
|
|
44
|
+
children: t
|
|
45
45
|
})
|
|
46
46
|
]
|
|
47
|
-
}),
|
|
47
|
+
}), l && /* @__PURE__ */ e("div", {
|
|
48
48
|
className: "cy-page-header-actions cy-reset",
|
|
49
|
-
children:
|
|
49
|
+
children: l
|
|
50
50
|
})]
|
|
51
51
|
}),
|
|
52
|
-
|
|
52
|
+
h && /* @__PURE__ */ e("div", {
|
|
53
53
|
className: "cy-page-header-body cy-reset",
|
|
54
|
-
children:
|
|
54
|
+
children: h
|
|
55
55
|
})
|
|
56
56
|
]
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
export {
|
|
60
|
-
|
|
60
|
+
z as PageHeader
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
//# sourceMappingURL=PageHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageHeader.js","names":["Heading","Text","forwardRef","jsx","jsxs","PageHeader","title","headingLevel","size","eyebrow","description","breadcrumbs","actions","meta","children","align","divider","Tag","className","style","ref"],"sources":["../../../src/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode } from \"react\";\nimport { Heading } from \"../Heading/Heading.js\";\nimport { Text } from \"../Text/Text.js\";\n\nexport interface PageHeaderTokens {\n /** Space between the breadcrumbs, the title block, the actions and the content below them. */\n gap: string;\n /** Space between the eyebrow, the title, the description and the meta row. */\n textGap: string;\n /** Space between two actions and between items of the meta row. */\n actionsGap: string;\n /** Longest line of the description. */\n descriptionMaxWidth: string;\n /** Colour of the bottom border drawn by `divider`. */\n dividerColor: string;\n /** Space between the header's content and the bottom border drawn by `divider`. */\n dividerSpace: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n pageHeader: PageHeaderTokens;\n }\n}\n\nexport interface PageHeaderProps {\n /** What the page or section is. Rendered as the header's one heading. */\n title: ReactNode;\n /** Heading level of the title, to fit the page outline. Default 1. */\n headingLevel?: 1 | 2 | 3;\n /**\n * Size of the title. \"md\" is the usual size of the heading level (level 1 \"2xl\", level 2 \"xl\", level 3 \"lg\" in\n * Heading's sizes); \"lg\" is the hero \"display\" size for a landing page. Default \"md\".\n */\n size?: \"md\" | \"lg\";\n /** A short label above the title that says where the page belongs. It comes before the title in reading order. */\n eyebrow?: ReactNode | undefined;\n /** One or two sentences under the title, as a lead paragraph. Pass inline content only. */\n description?: ReactNode | undefined;\n /** The trail to this page, shown above the eyebrow and the title. Pass a `Breadcrumbs`. */\n breadcrumbs?: ReactNode | undefined;\n /**\n * The page's buttons. They sit at the inline end, level with the top of the title block, and move below the text\n * when the header itself is narrower than 36rem or when `align` is \"center\".\n */\n actions?: ReactNode | undefined;\n /** A row under the description for badges, dates and authors. It wraps. */\n meta?: ReactNode | undefined;\n /** Anything below the rest of the header, at full width: tabs, a search field. */\n children?: ReactNode;\n /** \"start\" for pages; \"center\" centres the text and puts the actions below it, for landing pages. Default \"start\". */\n align?: \"start\" | \"center\";\n /** Draws a bottom border with space above it, to separate the header from the page. Default false. */\n divider?: boolean;\n /**\n * The element rendered. A `header` inside `main` is not a banner landmark, so no choice adds a landmark.\n * Default \"header\".\n */\n as?: \"header\" | \"div\" | \"section\";\n /** Added to the root element, for layout. */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-page-header-* tokens. */\n style?: CSSProperties | undefined;\n}\n\n/** The top of a page or a major section: where you are, what this is, a sentence about it and the page's actions. */\nexport const PageHeader = forwardRef<HTMLElement, PageHeaderProps>(function PageHeader(\n {\n title,\n headingLevel = 1,\n size = \"md\",\n eyebrow,\n description,\n breadcrumbs,\n actions,\n meta,\n children,\n align = \"start\",\n divider = false,\n as: Tag = \"header\",\n className,\n style,\n },\n ref,\n) {\n return (\n <Tag\n // One component, three elements: the ref is the element's own, typed as the common HTMLElement.\n ref={ref as never}\n className={className ? `cy-page-header ${className}` : \"cy-page-header\"}\n data-size={size}\n data-align={align}\n data-divider={divider ? \"\" : undefined}\n style={style}\n >\n {breadcrumbs && <div className=\"cy-page-header-breadcrumbs cy-reset\">{breadcrumbs}</div>}\n <div className=\"cy-page-header-main cy-reset\">\n <div className=\"cy-page-header-text cy-reset\">\n {eyebrow && (\n <Text as=\"p\" variant=\"eyebrow\" className=\"cy-page-header-eyebrow\">\n {eyebrow}\n </Text>\n )}\n <Heading\n level={headingLevel}\n {...(size === \"lg\" ? { size: \"display\" as const } : {})}\n className=\"cy-page-header-title\"\n >\n {title}\n </Heading>\n {description && (\n <Text as=\"p\" variant=\"lead\" className=\"cy-page-header-description\">\n {description}\n </Text>\n )}\n {meta && <div className=\"cy-page-header-meta\">{meta}</div>}\n </div>\n {actions && <div className=\"cy-page-header-actions cy-reset\">{actions}</div>}\n </div>\n {children && <div className=\"cy-page-header-body cy-reset\">{children}</div>}\n </Tag>\n );\n});\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"PageHeader.js","names":["Heading","Text","forwardRef","jsx","jsxs","PageHeader","title","headingLevel","size","titleSize","eyebrow","description","breadcrumbs","actions","meta","children","align","divider","Tag","className","style","ref"],"sources":["../../../src/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode } from \"react\";\nimport { Heading, type HeadingSize } from \"../Heading/Heading.js\";\nimport { Text } from \"../Text/Text.js\";\n\nexport interface PageHeaderTokens {\n /** Space between the breadcrumbs, the title block, the actions and the content below them. */\n gap: string;\n /** Space between the eyebrow, the title, the description and the meta row. */\n textGap: string;\n /** Space between two actions and between items of the meta row. */\n actionsGap: string;\n /** Longest line of the description. */\n descriptionMaxWidth: string;\n /** Colour of the bottom border drawn by `divider`. */\n dividerColor: string;\n /** Space between the header's content and the bottom border drawn by `divider`. */\n dividerSpace: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n pageHeader: PageHeaderTokens;\n }\n}\n\nexport interface PageHeaderProps {\n /** What the page or section is. Rendered as the header's one heading. */\n title: ReactNode;\n /** Heading level of the title, to fit the page outline. Default 1. */\n headingLevel?: 1 | 2 | 3;\n /**\n * Size of the title. \"md\" is the usual size of the heading level (level 1 \"2xl\", level 2 \"xl\", level 3 \"lg\" in\n * Heading's sizes); \"lg\" is the hero \"display\" size for a landing page. Default \"md\".\n */\n size?: \"md\" | \"lg\";\n /**\n * Any of Heading's sizes for the title, instead of the one `size` gives: `\"3xl\"` sits between \"md\" (2xl at level 1)\n * and \"lg\" (display), for a section's landing page. The level and the rest of the header are unchanged.\n */\n titleSize?: HeadingSize | undefined;\n /** A short label above the title that says where the page belongs. It comes before the title in reading order. */\n eyebrow?: ReactNode | undefined;\n /** One or two sentences under the title, as a lead paragraph. Pass inline content only. */\n description?: ReactNode | undefined;\n /** The trail to this page, shown above the eyebrow and the title. Pass a `Breadcrumbs`. */\n breadcrumbs?: ReactNode | undefined;\n /**\n * The page's buttons. They sit at the inline end, level with the top of the title block, and move below the text\n * when the header itself is narrower than 36rem or when `align` is \"center\".\n */\n actions?: ReactNode | undefined;\n /** A row under the description for badges, dates and authors. It wraps. */\n meta?: ReactNode | undefined;\n /** Anything below the rest of the header, at full width: tabs, a search field. */\n children?: ReactNode;\n /** \"start\" for pages; \"center\" centres the text and puts the actions below it, for landing pages. Default \"start\". */\n align?: \"start\" | \"center\";\n /** Draws a bottom border with space above it, to separate the header from the page. Default false. */\n divider?: boolean;\n /**\n * The element rendered. A `header` inside `main` is not a banner landmark, so no choice adds a landmark.\n * Default \"header\".\n */\n as?: \"header\" | \"div\" | \"section\";\n /** Added to the root element, for layout. */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-page-header-* tokens. */\n style?: CSSProperties | undefined;\n}\n\n/** The top of a page or a major section: where you are, what this is, a sentence about it and the page's actions. */\nexport const PageHeader = forwardRef<HTMLElement, PageHeaderProps>(function PageHeader(\n {\n title,\n headingLevel = 1,\n size = \"md\",\n titleSize,\n eyebrow,\n description,\n breadcrumbs,\n actions,\n meta,\n children,\n align = \"start\",\n divider = false,\n as: Tag = \"header\",\n className,\n style,\n },\n ref,\n) {\n return (\n <Tag\n // One component, three elements: the ref is the element's own, typed as the common HTMLElement.\n ref={ref as never}\n className={className ? `cy-page-header ${className}` : \"cy-page-header\"}\n data-size={size}\n data-align={align}\n data-divider={divider ? \"\" : undefined}\n style={style}\n >\n {breadcrumbs && <div className=\"cy-page-header-breadcrumbs cy-reset\">{breadcrumbs}</div>}\n <div className=\"cy-page-header-main cy-reset\">\n <div className=\"cy-page-header-text cy-reset\">\n {eyebrow && (\n <Text as=\"p\" variant=\"eyebrow\" className=\"cy-page-header-eyebrow\">\n {eyebrow}\n </Text>\n )}\n <Heading\n level={headingLevel}\n {...(titleSize ? { size: titleSize } : size === \"lg\" ? { size: \"display\" as const } : {})}\n className=\"cy-page-header-title\"\n >\n {title}\n </Heading>\n {description && (\n <Text as=\"p\" variant=\"lead\" className=\"cy-page-header-description\">\n {description}\n </Text>\n )}\n {meta && <div className=\"cy-page-header-meta\">{meta}</div>}\n </div>\n {actions && <div className=\"cy-page-header-actions cy-reset\">{actions}</div>}\n </div>\n {children && <div className=\"cy-page-header-body cy-reset\">{children}</div>}\n </Tag>\n );\n});\n"],"mappings":";;;;;AAuEA,IAAaK,IAAaH,EAAyC,SACjE,EACE,OAAAI,GACA,cAAAC,IAAe,GACf,MAAAC,IAAO,MACP,WAAAC,GACA,SAAAC,GACA,aAAAC,GACA,aAAAC,GACA,SAAAC,GACA,MAAAC,GACA,UAAAC,GACA,O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