@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,10 +1,14 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
import { type Theme } from "../tokens/index.js";
|
|
3
|
+
import type { ColorMode } from "./use-color-mode.js";
|
|
3
4
|
export interface CynosureThemeProps {
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* A theme from `createTheme()`, or a named theme's `theme` (`defineTheme`, `createThemeRegistry`). Omit to inherit
|
|
7
|
+
* every token from the surrounding theme (or the default stylesheet).
|
|
8
|
+
*/
|
|
5
9
|
theme?: Theme;
|
|
6
|
-
/** Omit to inherit the surrounding mode. `system` follows the OS. */
|
|
7
|
-
mode?:
|
|
10
|
+
/** Omit to inherit the surrounding mode. `system` follows the OS. A theme fixed to one mode (Midnight) ignores it. */
|
|
11
|
+
mode?: ColorMode;
|
|
8
12
|
/** `more` uses the higher-contrast palettes. `system`, or leaving it out, follows the OS setting. */
|
|
9
13
|
contrast?: "normal" | "more" | "system";
|
|
10
14
|
/** `self` (default) themes only this wrapper. `document` themes `<html>`; only for apps that own the page. */
|
|
@@ -1,41 +1,57 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
import { useClientLayoutEffect as k } from "../foundations/client-layout-effect.js";
|
|
3
|
+
import { useMediaQuery as w } from "../foundations/media-query.js";
|
|
4
|
+
import { themeProperties as L } from "../tokens/to-css.js";
|
|
5
|
+
import { ThemeContext as d } from "./theme-context.js";
|
|
6
|
+
import { useContext as O, useMemo as x } from "react";
|
|
7
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
8
|
+
function B({ theme: r, mode: m, contrast: o, target: u = "self", as: C = "div", className: l, style: h, children: v }) {
|
|
9
|
+
const a = O(d), j = w("(prefers-contrast: more)"), s = o === "more" || o !== "normal" && j, c = x(() => r ? L(r, { contrast: s }) : {}, [r, s]), f = r ?? a?.theme, p = f?.mode, i = r?.mode ?? (m && (p ?? m)), P = a?.mode, b = a?.more, A = x(() => ({
|
|
10
|
+
theme: f,
|
|
11
|
+
mode: p ?? m ?? P ?? "system",
|
|
12
|
+
more: r || o ? s : b ?? s
|
|
13
|
+
}), [
|
|
14
|
+
f,
|
|
15
|
+
p,
|
|
16
|
+
m,
|
|
17
|
+
P,
|
|
18
|
+
r,
|
|
19
|
+
o,
|
|
20
|
+
s,
|
|
21
|
+
b
|
|
22
|
+
]);
|
|
23
|
+
return k(() => {
|
|
24
|
+
if (u !== "document") return;
|
|
25
|
+
const t = document.documentElement, M = Object.keys(c), E = M.map((e) => [e, t.style.getPropertyValue(e)]), T = ["data-cy-mode", "data-cy-contrast"].map((e) => [e, t.getAttribute(e)]);
|
|
26
|
+
for (const e of M) t.style.setProperty(e, c[e]);
|
|
27
|
+
return i && t.setAttribute("data-cy-mode", i), o && t.setAttribute("data-cy-contrast", o), () => {
|
|
28
|
+
for (const [e, n] of E) n ? t.style.setProperty(e, n) : t.style.removeProperty(e);
|
|
29
|
+
for (const [e, n] of T) n === null ? t.removeAttribute(e) : t.setAttribute(e, n);
|
|
20
30
|
};
|
|
21
31
|
}, [
|
|
32
|
+
u,
|
|
22
33
|
c,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
i,
|
|
35
|
+
o
|
|
36
|
+
]), u === "document" ? /* @__PURE__ */ y(d.Provider, {
|
|
37
|
+
value: A,
|
|
38
|
+
children: v
|
|
39
|
+
}) : /* @__PURE__ */ y(d.Provider, {
|
|
40
|
+
value: A,
|
|
41
|
+
children: /* @__PURE__ */ y(C, {
|
|
42
|
+
className: l ? `cy-theme ${l}` : "cy-theme",
|
|
43
|
+
"data-cy-mode": i,
|
|
44
|
+
"data-cy-contrast": o,
|
|
45
|
+
style: {
|
|
46
|
+
...c,
|
|
47
|
+
...h
|
|
48
|
+
},
|
|
49
|
+
children: v
|
|
50
|
+
})
|
|
35
51
|
});
|
|
36
52
|
}
|
|
37
53
|
export {
|
|
38
|
-
|
|
54
|
+
B as CynosureTheme
|
|
39
55
|
};
|
|
40
56
|
|
|
41
57
|
//# sourceMappingURL=CynosureTheme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CynosureTheme.js","names":["
|
|
1
|
+
{"version":3,"file":"CynosureTheme.js","names":["useClientLayoutEffect","useMediaQuery","themeProperties","ThemeContext","useContext","useMemo","jsx","CynosureTheme","theme","mode","contrast","target","Tag","className","style","children","parent","osMore","more","properties","painted","fixed","ownMode","parentMode","parentMore","state","html","names","previousProps","name","previousAttrs","a","value","attr"],"sources":["../../src/theme/CynosureTheme.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useContext, useMemo } from \"react\";\nimport { useClientLayoutEffect } from \"../foundations/client-layout-effect.js\";\nimport { useMediaQuery } from \"../foundations/media-query.js\";\nimport { type Theme, themeProperties } from \"../tokens/index.js\";\nimport { ThemeContext, type ThemeState } from \"./theme-context.js\";\nimport type { ColorMode } from \"./use-color-mode.js\";\n\nexport interface CynosureThemeProps {\n /**\n * A theme from `createTheme()`, or a named theme's `theme` (`defineTheme`, `createThemeRegistry`). Omit to inherit\n * every token from the surrounding theme (or the default stylesheet).\n */\n theme?: Theme;\n /** Omit to inherit the surrounding mode. `system` follows the OS. A theme fixed to one mode (Midnight) ignores it. */\n mode?: ColorMode;\n /** `more` uses the higher-contrast palettes. `system`, or leaving it out, follows the OS setting. */\n contrast?: \"normal\" | \"more\" | \"system\";\n /** `self` (default) themes only this wrapper. `document` themes `<html>`; only for apps that own the page. */\n target?: \"self\" | \"document\";\n /** The wrapper element. Default \"div\". */\n as?: \"div\" | \"span\";\n /** Added to the wrapper element. Not used with `target=\"document\"`, which renders no wrapper. */\n className?: string;\n /** Layout only (margin, placement). Restyle through tokens. */\n style?: CSSProperties;\n /** Everything that should use the theme. */\n children?: ReactNode;\n}\n\n/** Applies a Cynosure theme to its own wrapper (or, opt-in, to the document). Never writes to <head> or <body>. */\nexport function CynosureTheme({\n theme,\n mode,\n contrast,\n target = \"self\",\n as: Tag = \"div\",\n className,\n style,\n children,\n}: CynosureThemeProps) {\n const parent = useContext(ThemeContext);\n const osMore = useMediaQuery(\"(prefers-contrast: more)\");\n // Undefined contrast follows the OS, like \"system\" (spec §6.4: system by default).\n const more = contrast === \"more\" || (contrast !== \"normal\" && osMore);\n const properties = useMemo(() => (theme ? themeProperties(theme, { contrast: more }) : {}), [theme, more]);\n // A theme fixed to one mode (its own, or the one it inherits) wins over the mode prop.\n const painted = theme ?? parent?.theme;\n const fixed = painted?.mode;\n const ownMode = theme?.mode ?? (mode && (fixed ?? mode));\n const parentMode = parent?.mode;\n const parentMore = parent?.more;\n // What useCynosureTheme reads below this wrapper: the same theme, mode and contrast the wrapper paints.\n const state = useMemo<ThemeState>(\n () => ({\n theme: painted,\n mode: fixed ?? mode ?? parentMode ?? \"system\",\n more: theme || contrast ? more : (parentMore ?? more),\n }),\n [painted, fixed, mode, parentMode, theme, contrast, more, parentMore],\n );\n\n useClientLayoutEffect(() => {\n if (target !== \"document\") return;\n const html = document.documentElement;\n const names = Object.keys(properties);\n // Remember what the host had so unmounting restores it instead of deleting it.\n const previousProps = names.map((name) => [name, html.style.getPropertyValue(name)] as const);\n const previousAttrs = ([\"data-cy-mode\", \"data-cy-contrast\"] as const).map(\n (a) => [a, html.getAttribute(a)] as const,\n );\n for (const name of names) html.style.setProperty(name, properties[name] as string);\n if (ownMode) html.setAttribute(\"data-cy-mode\", ownMode);\n if (contrast) html.setAttribute(\"data-cy-contrast\", contrast);\n return () => {\n for (const [name, value] of previousProps)\n if (value) html.style.setProperty(name, value);\n else html.style.removeProperty(name);\n for (const [attr, value] of previousAttrs)\n if (value === null) html.removeAttribute(attr);\n else html.setAttribute(attr, value);\n };\n }, [target, properties, ownMode, contrast]);\n\n if (target === \"document\") return <ThemeContext.Provider value={state}>{children}</ThemeContext.Provider>;\n return (\n <ThemeContext.Provider value={state}>\n <Tag\n className={className ? `cy-theme ${className}` : \"cy-theme\"}\n data-cy-mode={ownMode}\n data-cy-contrast={contrast}\n style={{ ...(properties as CSSProperties), ...style }}\n >\n {children}\n </Tag>\n </ThemeContext.Provider>\n );\n}\n"],"mappings":";;;;;;;AA8BA,SAAgBO,EAAc,EAC5B,OAAAC,GACA,MAAAC,GACA,UAAAC,GACA,QAAAC,IAAS,QACT,IAAIC,IAAM,OACV,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACqB;AACrB,QAAMC,IAASZ,EAAWD,CAAY,GAChCc,IAAShB,EAAc,0BAA0B,GAEjDiB,IAAOR,MAAa,UAAWA,MAAa,YAAYO,GACxDE,IAAad,EAAA,MAAeG,IAAQN,EAAgBM,GAAO,EAAE,UAAUU,EAAK,CAAC,IAAI,CAAC,GAAI,CAACV,GAAOU,CAAI,CAAC,GAEnGE,IAAUZ,KAASQ,GAAQ,OAC3BK,IAAQD,GAAS,MACjBE,IAAUd,GAAO,SAASC,MAASY,KAASZ,KAC5Cc,IAAaP,GAAQ,MACrBQ,IAAaR,GAAQ,MAErBS,IAAQpB,EAAA,OACL;AAAA,IACL,OAAOe;AAAA,IACP,MAAMC,KAASZ,KAAQc,KAAc;AAAA,IACrC,MAAMf,KAASE,IAAWQ,IAAQM,KAAcN;AAAA,EAClD,IACA;AAAA,IAACE;AAAA,IAASC;AAAA,IAAOZ;AAAA,IAAMc;AAAA,IAAYf;AAAA,IAAOE;AAAA,IAAUQ;AAAA,IAAMM;AAAA,EAAU,CACtE;AAwBA,SAtBAxB,EAAA,MAA4B;AAC1B,QAAIW,MAAW,WAAY;AAC3B,UAAMe,IAAO,SAAS,iBAChBC,IAAQ,OAAO,KAAKR,CAAU,GAE9BS,IAAgBD,EAAM,IAAA,CAAKE,MAAS,CAACA,GAAMH,EAAK,MAAM,iBAAiBG,CAAI,CAAC,CAAU,GACtFC,IAAiB,CAAC,gBAAgB,kBAAkB,EAAY,IAAA,CACnEC,MAAM,CAACA,GAAGL,EAAK,aAAaK,CAAC,CAAC,CACjC;AACA,eAAWF,KAAQF,EAAO,CAAAD,EAAK,MAAM,YAAYG,GAAMV,EAAWU,CAAA,CAAe;AACjF,WAAIP,KAASI,EAAK,aAAa,gBAAgBJ,CAAO,GAClDZ,KAAUgB,EAAK,aAAa,oBAAoBhB,CAAQ,GAC5D,MAAa;AACX,iBAAW,CAACmB,GAAMG,CAAA,KAAUJ,EAC1B,CAAII,IAAON,EAAK,MAAM,YAAYG,GAAMG,CAAK,IACxCN,EAAK,MAAM,eAAeG,CAAI;AACrC,iBAAW,CAACI,GAAMD,CAAA,KAAUF,EAC1B,CAAIE,MAAU,OAAMN,EAAK,gBAAgBO,CAAI,IACxCP,EAAK,aAAaO,GAAMD,CAAK;AAAA,IACtC;AAAA,EACF,GAAG;AAAA,IAACrB;AAAA,IAAQQ;AAAA,IAAYG;AAAA,IAASZ;AAAA,EAAQ,CAAC,GAEtCC,MAAW,aAAmB,gBAAAL,EAACH,EAAa,UAAd;AAAA,IAAuB,OAAOsB;AAAA,IAAQ,UAAAV;AAAA,EAAgC,CAAA,IAEtG,gBAAAT,EAACH,EAAa,UAAd;AAAA,IAAuB,OAAOsB;AAAA,IAC5B,UAAA,gBAAAnB,EAACM,GAAD;AAAA,MACE,WAAWC,IAAY,YAAYA,CAAA,KAAc;AAAA,MACjD,gBAAcS;AAAA,MACd,oBAAkBZ;AAAA,MAClB,OAAO;AAAA,QAAE,GAAIS;AAAA,QAA8B,GAAGL;AAAA,MAAM;AAAA,MAEnD,UAAAC;AAAA,IACE,CAAA;AAAA,EACgB,CAAA;AAE3B"}
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { CynosureTheme, type CynosureThemeProps } from "./CynosureTheme.js";
|
|
2
2
|
export { type ThemeInitScriptOptions, themeInitScript } from "./theme-init-script.js";
|
|
3
3
|
export { type ColorMode, type ColorModeStorage, useColorMode } from "./use-color-mode.js";
|
|
4
|
+
export { type CynosureThemeValue, useCynosureTheme } from "./use-cynosure-theme.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Theme } from "../tokens/index.js";
|
|
2
|
+
import type { ColorMode } from "./use-color-mode.js";
|
|
3
|
+
/** What the nearest CynosureTheme paints: its theme (or the one it inherits), mode and contrast. */
|
|
4
|
+
export interface ThemeState {
|
|
5
|
+
theme: Theme | undefined;
|
|
6
|
+
mode: ColorMode;
|
|
7
|
+
more: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const ThemeContext: import("react").Context<ThemeState | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-context.js","names":["createContext","ThemeContext"],"sources":["../../src/theme/theme-context.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport type { Theme } from \"../tokens/index.js\";\nimport type { ColorMode } from \"./use-color-mode.js\";\n\n/** What the nearest CynosureTheme paints: its theme (or the one it inherits), mode and contrast. */\nexport interface ThemeState {\n theme: Theme | undefined;\n mode: ColorMode;\n more: boolean;\n}\n\nexport const ThemeContext = createContext<ThemeState | null>(null);\n"],"mappings":";;AAWA,IAAaC,IAAeD,EAAiC,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-init-script.js","names":["literal","value","themeInitScript","key","selector","target"],"sources":["../../src/theme/theme-init-script.ts"],"sourcesContent":["export interface ThemeInitScriptOptions {\n /** localStorage key; must match `useColorMode({ key })`. Default: \"cy-color-mode\". */\n key?: string;\n /** Element to mark with `data-cy-mode`. Default: `<html>` (apps that own the page, like `target=\"document\"`). */\n selector?: string;\n}\n\n/** JSON string literal that is also safe inside an HTML <script> element (no \"<\" at all). */\nconst literal = (value: string) => JSON.stringify(value).replace(/</g, \"\\\\u003c\");\n\n/**\n * The text of a tiny script that applies the saved colour mode before the first paint, so a dark-mode visitor never\n * sees a light flash. Cynosure injects nothing: place it yourself, early in the page (inline in `<head>`, or written\n * to a file for pages whose content security policy forbids inline scripts). Reads localStorage only.\n */\nexport function themeInitScript({ key = \"cy-color-mode\", selector }: ThemeInitScriptOptions = {}): string {\n const target = selector ? `document.querySelector(${literal(selector)})` : \"document.documentElement\";\n return `(function(){try{var m=localStorage.getItem(${literal(key)});if(m!==\"light\"&&m!==\"dark\"&&m!==\"system\")return;var e=${target};if(e)e.setAttribute(\"data-cy-mode\",m)}catch(_){}})();`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme-init-script.js","names":["literal","value","themeInitScript","key","selector","target"],"sources":["../../src/theme/theme-init-script.ts"],"sourcesContent":["export interface ThemeInitScriptOptions {\n /** localStorage key; must match `useColorMode({ key })`. Default: \"cy-color-mode\". */\n key?: string;\n /** Element to mark with `data-cy-mode`. Default: `<html>` (apps that own the page, like `target=\"document\"`). */\n selector?: string;\n}\n\n/** JSON string literal that is also safe inside an HTML <script> element (no \"<\" at all). */\nconst literal = (value: string) => JSON.stringify(value).replace(/</g, \"\\\\u003c\");\n\n/**\n * The text of a tiny script that applies the saved colour mode before the first paint, so a dark-mode visitor never\n * sees a light flash. Cynosure injects nothing: place it yourself, early in the page (inline in `<head>`, or written\n * to a file for pages whose content security policy forbids inline scripts). Reads localStorage only.\n */\nexport function themeInitScript({ key = \"cy-color-mode\", selector }: ThemeInitScriptOptions = {}): string {\n const target = selector ? `document.querySelector(${literal(selector)})` : \"document.documentElement\";\n return `(function(){try{var m=localStorage.getItem(${literal(key)});if(m!==\"light\"&&m!==\"dark\"&&m!==\"system\")return;var e=${target};if(e)e.setAttribute(\"data-cy-mode\",m)}catch(_){}})();`;\n}\n"],"mappings":"AAQA,IAAMA,IAAA,CAAWC,MAAkB,KAAK,UAAUA,CAAK,EAAE,QAAQ,MAAM,SAAS;AAOhF,SAAgBC,EAAgB,EAAE,KAAAC,IAAM,iBAAiB,UAAAC,EAAA,IAAqC,CAAC,GAAW;AACxG,QAAMC,IAASD,IAAW,0BAA0BJ,EAAQI,CAAQ,CAAA,MAAO;AAC3E,SAAO,8CAA8CJ,EAAQG,CAAG,CAAA,2DAA4DE,CAAA;AAC9H"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ThemeMode } from "../tokens/schema.js";
|
|
2
|
+
export type ColorMode = ThemeMode | "system";
|
|
2
3
|
export interface ColorModeStorage {
|
|
3
4
|
get(key: string): string | null | Promise<string | null>;
|
|
4
5
|
set(key: string, value: string): void | Promise<void>;
|
|
@@ -10,5 +11,5 @@ export declare function useColorMode(options?: {
|
|
|
10
11
|
}): {
|
|
11
12
|
mode: ColorMode;
|
|
12
13
|
setMode: (next: ColorMode) => void;
|
|
13
|
-
resolved:
|
|
14
|
+
resolved: ThemeMode;
|
|
14
15
|
};
|
|
@@ -1,64 +1,61 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useClientLayoutEffect as
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { useClientLayoutEffect as y } from "../foundations/client-layout-effect.js";
|
|
3
|
+
import { useMediaQuery as g } from "../foundations/media-query.js";
|
|
4
|
+
import { useCallback as h, useEffect as v, useRef as i, useState as w } from "react";
|
|
5
|
+
var u = "cy-color-mode-change", E = [
|
|
5
6
|
"light",
|
|
6
7
|
"dark",
|
|
7
8
|
"system"
|
|
8
|
-
],
|
|
9
|
-
get: (
|
|
10
|
-
set: (
|
|
9
|
+
], m = (e) => E.includes(e), d = {
|
|
10
|
+
get: (e) => globalThis.localStorage?.getItem(e) ?? null,
|
|
11
|
+
set: (e, t) => globalThis.localStorage?.setItem(e, t)
|
|
11
12
|
};
|
|
12
|
-
function
|
|
13
|
+
function k(e, t) {
|
|
13
14
|
try {
|
|
14
|
-
const s =
|
|
15
|
-
return s instanceof Promise ? s.then((
|
|
15
|
+
const s = e.get(t);
|
|
16
|
+
return s instanceof Promise ? s.then((o) => m(o) ? o : "system").catch(() => "system") : m(s) ? s : "system";
|
|
16
17
|
} catch {
|
|
17
18
|
return "system";
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!(e instanceof Promise)) c(e);
|
|
21
|
+
function M(e = {}) {
|
|
22
|
+
const { key: t = "cy-color-mode" } = e, s = i(e.storage ?? d);
|
|
23
|
+
s.current = e.storage ?? d;
|
|
24
|
+
const o = i(!1), [l, c] = w("system"), f = g("(prefers-color-scheme: dark)");
|
|
25
|
+
return y(() => {
|
|
26
|
+
o.current = !1;
|
|
27
|
+
const r = k(s.current, t);
|
|
28
|
+
if (!(r instanceof Promise)) c(r);
|
|
29
29
|
else {
|
|
30
|
-
let
|
|
31
|
-
return
|
|
32
|
-
|
|
30
|
+
let n = !0;
|
|
31
|
+
return r.then((a) => n && !o.current && c(a)), () => {
|
|
32
|
+
n = !1;
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
}, [
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const e = (o) => {
|
|
40
|
-
const n = o.detail;
|
|
41
|
-
n.key === r && (a.current = !0, c(n.mode));
|
|
35
|
+
}, [t]), v(() => {
|
|
36
|
+
const r = (n) => {
|
|
37
|
+
const a = n.detail;
|
|
38
|
+
a.key === t && (o.current = !0, c(a.mode));
|
|
42
39
|
};
|
|
43
|
-
return window.addEventListener(
|
|
44
|
-
}, [
|
|
40
|
+
return window.addEventListener(u, r), () => window.removeEventListener(u, r);
|
|
41
|
+
}, [t]), {
|
|
45
42
|
mode: l,
|
|
46
|
-
setMode:
|
|
47
|
-
|
|
48
|
-
key:
|
|
49
|
-
mode:
|
|
43
|
+
setMode: h((r) => {
|
|
44
|
+
o.current = !0, c(r), window.dispatchEvent(new CustomEvent(u, { detail: {
|
|
45
|
+
key: t,
|
|
46
|
+
mode: r
|
|
50
47
|
} }));
|
|
51
48
|
try {
|
|
52
|
-
Promise.resolve(s.current.set(
|
|
49
|
+
Promise.resolve(s.current.set(t, r)).catch(() => {
|
|
53
50
|
});
|
|
54
51
|
} catch {
|
|
55
52
|
}
|
|
56
|
-
}, [
|
|
57
|
-
resolved: l === "system" ?
|
|
53
|
+
}, [t]),
|
|
54
|
+
resolved: l === "system" ? f ? "dark" : "light" : l
|
|
58
55
|
};
|
|
59
56
|
}
|
|
60
57
|
export {
|
|
61
|
-
|
|
58
|
+
M as useColorMode
|
|
62
59
|
};
|
|
63
60
|
|
|
64
61
|
//# sourceMappingURL=use-color-mode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-color-mode.js","names":["useClientLayoutEffect","useCallback","useEffect","useRef","useState","CHANGE","MODES","isMode","v","localStorageAdapter","k","read","storage","key","value","
|
|
1
|
+
{"version":3,"file":"use-color-mode.js","names":["useClientLayoutEffect","useMediaQuery","useCallback","useEffect","useRef","useState","CHANGE","MODES","isMode","v","localStorageAdapter","k","read","storage","key","value","useColorMode","options","storageRef","touched","mode","setState","systemDark","initial","live","m","follow","e","detail","next"],"sources":["../../src/theme/use-color-mode.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../foundations/client-layout-effect.js\";\nimport { useMediaQuery } from \"../foundations/media-query.js\";\nimport type { ThemeMode } from \"../tokens/schema.js\";\n\nconst CHANGE = \"cy-color-mode-change\";\n\nexport type ColorMode = ThemeMode | \"system\";\n\nexport interface ColorModeStorage {\n get(key: string): string | null | Promise<string | null>;\n set(key: string, value: string): void | Promise<void>;\n}\n\nconst MODES: readonly ColorMode[] = [\"light\", \"dark\", \"system\"];\nconst isMode = (v: unknown): v is ColorMode => MODES.includes(v as ColorMode);\n\nconst localStorageAdapter: ColorModeStorage = {\n get: (k) => globalThis.localStorage?.getItem(k) ?? null,\n set: (k, v) => globalThis.localStorage?.setItem(k, v),\n};\n\nfunction read(storage: ColorModeStorage, key: string): ColorMode | Promise<ColorMode> {\n try {\n const value = storage.get(key);\n if (value instanceof Promise) return value.then((v) => (isMode(v) ? v : \"system\")).catch(() => \"system\");\n return isMode(value) ? value : \"system\";\n } catch {\n return \"system\";\n }\n}\n\n/** The user's colour mode, persisted through `storage` (localStorage by default). Never throws. */\nexport function useColorMode(options: { storage?: ColorModeStorage; key?: string } = {}) {\n const { key = \"cy-color-mode\" } = options;\n // The storage object may be recreated on every render (inline literal); keep the latest without re-reading.\n const storageRef = useRef(options.storage ?? localStorageAdapter);\n storageRef.current = options.storage ?? localStorageAdapter;\n const touched = useRef(false);\n // Server and first client render agree on \"system\"; storage is read after mount (hydration-safe).\n const [mode, setState] = useState<ColorMode>(\"system\");\n const systemDark = useMediaQuery(\"(prefers-color-scheme: dark)\");\n\n useClientLayoutEffect(() => {\n touched.current = false;\n const initial = read(storageRef.current, key);\n if (!(initial instanceof Promise)) setState(initial);\n else {\n let live = true;\n // A user choice made while the read was pending always wins.\n initial.then((m) => live && !touched.current && setState(m));\n return () => {\n live = false;\n };\n }\n }, [key]);\n\n // Other hooks on the page (e.g. an uncontrolled ThemeToggle) announce changes; follow them.\n useEffect(() => {\n const follow = (e: Event) => {\n const detail = (e as CustomEvent<{ key: string; mode: ColorMode }>).detail;\n if (detail.key !== key) return;\n touched.current = true;\n setState(detail.mode);\n };\n window.addEventListener(CHANGE, follow);\n return () => window.removeEventListener(CHANGE, follow);\n }, [key]);\n\n const setMode = useCallback(\n (next: ColorMode) => {\n touched.current = true;\n setState(next);\n window.dispatchEvent(new CustomEvent(CHANGE, { detail: { key, mode: next } }));\n try {\n void Promise.resolve(storageRef.current.set(key, next)).catch(() => {});\n } catch {\n /* storage unavailable: keep the in-memory value */\n }\n },\n [key],\n );\n\n const resolved: ThemeMode = mode === \"system\" ? (systemDark ? \"dark\" : \"light\") : mode;\n return { mode, setMode, resolved };\n}\n"],"mappings":";;;;AAKA,IAAMM,IAAS,wBASTC,IAA8B;AAAA,EAAC;AAAA,EAAS;AAAA,EAAQ;AAAQ,GACxDC,IAAA,CAAUC,MAA+BF,EAAM,SAASE,CAAc,GAEtEC,IAAwC;AAAA,EAC5C,KAAA,CAAMC,MAAM,WAAW,cAAc,QAAQA,CAAC,KAAK;AAAA,EACnD,KAAA,CAAMA,GAAGF,MAAM,WAAW,cAAc,QAAQE,GAAGF,CAAC;AACtD;AAEA,SAASG,EAAKC,GAA2BC,GAA6C;AACpF,MAAI;AACF,UAAMC,IAAQF,EAAQ,IAAIC,CAAG;AAC7B,WAAIC,aAAiB,UAAgBA,EAAM,KAAA,CAAMN,MAAOD,EAAOC,CAAC,IAAIA,IAAI,QAAS,EAAE,MAAA,MAAY,QAAQ,IAChGD,EAAOO,CAAK,IAAIA,IAAQ;AAAA,EACjC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGA,SAAgBC,EAAaC,IAAwD,CAAC,GAAG;AACvF,QAAM,EAAE,KAAAH,IAAM,gBAAA,IAAoBG,GAE5BC,IAAad,EAAOa,EAAQ,WAAWP,CAAmB;AAChE,EAAAQ,EAAW,UAAUD,EAAQ,WAAWP;AACxC,QAAMS,IAAUf,EAAO,EAAK,GAEtB,CAACgB,GAAMC,CAAA,IAAYhB,EAAoB,QAAQ,GAC/CiB,IAAarB,EAAc,8BAA8B;AAE/D,SAAAD,EAAA,MAA4B;AAC1B,IAAAmB,EAAQ,UAAU;AAClB,UAAMI,IAAUX,EAAKM,EAAW,SAASJ,CAAG;AAC5C,QAAI,EAAES,aAAmB,SAAU,CAAAF,EAASE,CAAO;AAAA,SAC9C;AACH,UAAIC,IAAO;AAEX,aAAAD,EAAQ,KAAA,CAAME,MAAMD,KAAQ,CAACL,EAAQ,WAAWE,EAASI,CAAC,CAAC,GAC3D,MAAa;AACX,QAAAD,IAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,GAAG,CAACV,CAAG,CAAC,GAGRX,EAAA,MAAgB;AACd,UAAMuB,IAAA,CAAUC,MAAa;AAC3B,YAAMC,IAAUD,EAAoD;AACpE,MAAIC,EAAO,QAAQd,MACnBK,EAAQ,UAAU,IAClBE,EAASO,EAAO,IAAI;AAAA,IACtB;AACA,kBAAO,iBAAiBtB,GAAQoB,CAAM,GACtC,MAAa,OAAO,oBAAoBpB,GAAQoB,CAAM;AAAA,EACxD,GAAG,CAACZ,CAAG,CAAC,GAiBD;AAAA,IAAE,MAAAM;AAAA,IAAM,SAfClB,EAAA,CACb2B,MAAoB;AACnB,MAAAV,EAAQ,UAAU,IAClBE,EAASQ,CAAI,GACb,OAAO,cAAc,IAAI,YAAYvB,GAAQ,EAAE,QAAQ;AAAA,QAAE,KAAAQ;AAAA,QAAK,MAAMe;AAAA,MAAK,EAAE,CAAC,CAAC;AAC7E,UAAI;AACF,gBAAa,QAAQX,EAAW,QAAQ,IAAIJ,GAAKe,CAAI,CAAC,EAAE,MAAA,MAAY;AAAA,QAAC,CAAC;AAAA,MACxE,QAAQ;AAAA,MAER;AAAA,IACF,GACA,CAACf,CAAG,CAIS;AAAA,IAAS,UADIM,MAAS,WAAYE,IAAa,SAAS,UAAWF;AAAA,EACjD;AACnC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ColorTokens, type GlobalTokens, type PaletteName, type Theme } from "../tokens/index.js";
|
|
2
|
+
/** The theme in force where `useCynosureTheme` is called, resolved for code that cannot read CSS variables. */
|
|
3
|
+
export interface CynosureThemeValue {
|
|
4
|
+
/** The theme of the nearest `CynosureTheme` that has one (Cynosure's own theme when there is none). */
|
|
5
|
+
theme: Theme;
|
|
6
|
+
/** The palette being shown: the mode (a fixed-mode theme's own, or the OS for `system`) plus contrast. */
|
|
7
|
+
palette: PaletteName;
|
|
8
|
+
/** That palette's colours as concrete hex values, for canvas `fillStyle`, chart and editor themes. */
|
|
9
|
+
colors: ColorTokens;
|
|
10
|
+
/** The type ramp in px, already multiplied by the theme's scale. */
|
|
11
|
+
fontSize: GlobalTokens["font"]["size"];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The theme, palette and resolved colours where it is called. Re-renders when the theme, the mode, the contrast or the
|
|
15
|
+
* OS setting they follow changes, so a canvas or chart can redraw or re-register its theme. Reads the nearest
|
|
16
|
+
* `CynosureTheme`; pass `mode` there (from `useColorMode`) so this knows a mode set on the page.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useCynosureTheme(): CynosureThemeValue;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMediaQuery as s } from "../foundations/media-query.js";
|
|
3
|
+
import { createTheme as i } from "../tokens/create-theme.js";
|
|
4
|
+
import { resolveColors as l } from "../tokens/chart-themes.js";
|
|
5
|
+
import { ThemeContext as p } from "./theme-context.js";
|
|
6
|
+
import { useContext as u, useMemo as d } from "react";
|
|
7
|
+
var m;
|
|
8
|
+
function M() {
|
|
9
|
+
const o = u(p), n = s("(prefers-color-scheme: dark)"), c = s("(prefers-contrast: more)");
|
|
10
|
+
m ??= i();
|
|
11
|
+
const e = o?.theme ?? m, r = e.mode ?? o?.mode ?? "system", a = r === "system" ? n : r === "dark", f = o ? o.more : c, t = `${a ? "dark" : "light"}${f ? "-contrast" : ""}`;
|
|
12
|
+
return d(() => ({
|
|
13
|
+
theme: e,
|
|
14
|
+
palette: t,
|
|
15
|
+
colors: l(e, t),
|
|
16
|
+
fontSize: e.global.font.size
|
|
17
|
+
}), [e, t]);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
M as useCynosureTheme
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=use-cynosure-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-cynosure-theme.js","names":["useMediaQuery","createTheme","resolveColors","ThemeContext","useContext","useMemo","fallback","useCynosureTheme","state","systemDark","osMore","theme","mode","dark","more","palette"],"sources":["../../src/theme/use-cynosure-theme.ts"],"sourcesContent":["import { useContext, useMemo } from \"react\";\nimport { useMediaQuery } from \"../foundations/media-query.js\";\nimport {\n type ColorTokens,\n createTheme,\n type GlobalTokens,\n type PaletteName,\n resolveColors,\n type Theme,\n} from \"../tokens/index.js\";\nimport { ThemeContext } from \"./theme-context.js\";\n\n/** The theme in force where `useCynosureTheme` is called, resolved for code that cannot read CSS variables. */\nexport interface CynosureThemeValue {\n /** The theme of the nearest `CynosureTheme` that has one (Cynosure's own theme when there is none). */\n theme: Theme;\n /** The palette being shown: the mode (a fixed-mode theme's own, or the OS for `system`) plus contrast. */\n palette: PaletteName;\n /** That palette's colours as concrete hex values, for canvas `fillStyle`, chart and editor themes. */\n colors: ColorTokens;\n /** The type ramp in px, already multiplied by the theme's scale. */\n fontSize: GlobalTokens[\"font\"][\"size\"];\n}\n\nlet fallback: Theme | undefined;\n\n/**\n * The theme, palette and resolved colours where it is called. Re-renders when the theme, the mode, the contrast or the\n * OS setting they follow changes, so a canvas or chart can redraw or re-register its theme. Reads the nearest\n * `CynosureTheme`; pass `mode` there (from `useColorMode`) so this knows a mode set on the page.\n */\nexport function useCynosureTheme(): CynosureThemeValue {\n const state = useContext(ThemeContext);\n const systemDark = useMediaQuery(\"(prefers-color-scheme: dark)\");\n const osMore = useMediaQuery(\"(prefers-contrast: more)\");\n fallback ??= createTheme();\n const theme = state?.theme ?? fallback;\n const mode = theme.mode ?? state?.mode ?? \"system\";\n const dark = mode === \"system\" ? systemDark : mode === \"dark\";\n const more = state ? state.more : osMore;\n const palette = `${dark ? \"dark\" : \"light\"}${more ? \"-contrast\" : \"\"}` as PaletteName;\n return useMemo(\n () => ({ theme, palette, colors: resolveColors(theme, palette), fontSize: theme.global.font.size }),\n [theme, palette],\n );\n}\n"],"mappings":";;;;;;AAwBA,IAAIM;AAOJ,SAAgBC,IAAuC;AACrD,QAAMC,IAAQJ,EAAWD,CAAY,GAC/BM,IAAaT,EAAc,8BAA8B,GACzDU,IAASV,EAAc,0BAA0B;AACvD,EAAAM,MAAaL,EAAY;AACzB,QAAMU,IAAQH,GAAO,SAASF,GACxBM,IAAOD,EAAM,QAAQH,GAAO,QAAQ,UACpCK,IAAOD,MAAS,WAAWH,IAAaG,MAAS,QACjDE,IAAON,IAAQA,EAAM,OAAOE,GAC5BK,IAAU,GAAGF,IAAO,SAAS,OAAA,GAAUC,IAAO,cAAc,EAAA;AAClE,SAAOT,EAAA,OACE;AAAA,IAAE,OAAAM;AAAA,IAAO,SAAAI;AAAA,IAAS,QAAQb,EAAcS,GAAOI,CAAO;AAAA,IAAG,UAAUJ,EAAM,OAAO,KAAK;AAAA,EAAK,IACjG,CAACA,GAAOI,CAAO,CACjB;AACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ColorTokens, PaletteName, Theme } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every colour of one palette as a concrete value (hex, or 8-digit hex where the colour is translucent), for a canvas
|
|
4
|
+
* `fillStyle` or a chart library's theme.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveColors(theme?: Theme, palette?: PaletteName): ColorTokens;
|
|
7
|
+
/**
|
|
8
|
+
* swift-chart's theme shape (`addTheme(name, swiftChartTheme(…))` from `@arshad-shah/swift-chart`), written out so the
|
|
9
|
+
* library is not imported.
|
|
10
|
+
*/
|
|
11
|
+
export interface SwiftChartTheme {
|
|
12
|
+
/** The chart's page background. */
|
|
13
|
+
bg: string;
|
|
14
|
+
/** Panels and plot areas. */
|
|
15
|
+
surface: string;
|
|
16
|
+
/** Gridlines: quieter than the axis. */
|
|
17
|
+
grid: string;
|
|
18
|
+
/** Labels and values. */
|
|
19
|
+
text: string;
|
|
20
|
+
/** Axis ticks and secondary labels. */
|
|
21
|
+
textMuted: string;
|
|
22
|
+
/** Axis lines. */
|
|
23
|
+
axis: string;
|
|
24
|
+
/** Gains (up candles, positive bars). */
|
|
25
|
+
positive: string;
|
|
26
|
+
/** Losses. */
|
|
27
|
+
negative: string;
|
|
28
|
+
/** Text on an accent-filled mark. */
|
|
29
|
+
onAccent: string;
|
|
30
|
+
/** The series colours, in order (the palette's eight `seriesColors`). */
|
|
31
|
+
colors: string[];
|
|
32
|
+
/** Tooltip fill, border and text. */
|
|
33
|
+
tooltipBg: string;
|
|
34
|
+
tooltipBorder: string;
|
|
35
|
+
tooltipText: string;
|
|
36
|
+
}
|
|
37
|
+
/** A swift-chart theme from a Cynosure palette. Build one per palette and register it again when the palette changes. */
|
|
38
|
+
export declare function swiftChartTheme(theme?: Theme, palette?: PaletteName): SwiftChartTheme;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mix as n } from "./color.js";
|
|
2
|
+
import { ACCENT_MIX as r, accentMixCss as a, createTheme as s } from "./create-theme.js";
|
|
3
|
+
function f(e = s(), c = "light") {
|
|
4
|
+
const t = e.palettes[c], o = a(t.accent, t.surface), i = Math.round(r.ring / 100 * 255).toString(16).padStart(2, "0");
|
|
5
|
+
return {
|
|
6
|
+
...t,
|
|
7
|
+
accentSoft: t.accentSoft === o.accentSoft ? n(t.accent, t.surface, r.accentSoft / 100) : t.accentSoft,
|
|
8
|
+
ring: t.ring === o.ring ? `${t.accent}${i}` : t.ring,
|
|
9
|
+
seriesColors: [...t.seriesColors]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function u(e = s(), c = "light") {
|
|
13
|
+
const t = f(e, c);
|
|
14
|
+
return {
|
|
15
|
+
bg: t.bg,
|
|
16
|
+
surface: t.surface,
|
|
17
|
+
grid: n(t.line, t.surface, 0.5),
|
|
18
|
+
text: t.ink,
|
|
19
|
+
textMuted: t.muted,
|
|
20
|
+
axis: t.line,
|
|
21
|
+
positive: t.successText,
|
|
22
|
+
negative: t.dangerText,
|
|
23
|
+
onAccent: t.onAccent,
|
|
24
|
+
colors: t.seriesColors,
|
|
25
|
+
tooltipBg: t.surfaceRaised,
|
|
26
|
+
tooltipBorder: t.line,
|
|
27
|
+
tooltipText: t.ink
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
f as resolveColors,
|
|
32
|
+
u as swiftChartTheme
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=chart-themes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-themes.js","names":["mix","ACCENT_MIX","accentMixCss","createTheme","resolveColors","theme","palette","p","css","alpha","swiftChartTheme"],"sources":["../../src/tokens/chart-themes.ts"],"sourcesContent":["/**\n * Colours for canvas engines and chart libraries, which cannot read `var(--…)` or `color-mix()`: a palette resolved to\n * plain hex, and a theme object for swift-chart. Nothing here imports a chart library, so Cynosure gains no dependency.\n */\nimport { mix } from \"./color.js\";\nimport { ACCENT_MIX, accentMixCss, createTheme } from \"./create-theme.js\";\nimport type { ColorTokens, PaletteName, Theme } from \"./schema.js\";\n\n/**\n * Every colour of one palette as a concrete value (hex, or 8-digit hex where the colour is translucent), for a canvas\n * `fillStyle` or a chart library's theme.\n */\nexport function resolveColors(theme: Theme = createTheme(), palette: PaletteName = \"light\"): ColorTokens {\n const p = theme.palettes[palette];\n const css = accentMixCss(p.accent, p.surface);\n const alpha = Math.round((ACCENT_MIX.ring / 100) * 255)\n .toString(16)\n .padStart(2, \"0\");\n // Only the mixes createTheme wrote are swapped: a palette that sets its own accentSoft or ring already has hex.\n return {\n ...p,\n accentSoft:\n p.accentSoft === css.accentSoft ? mix(p.accent, p.surface, ACCENT_MIX.accentSoft / 100) : p.accentSoft,\n ring: p.ring === css.ring ? `${p.accent}${alpha}` : p.ring,\n seriesColors: [...p.seriesColors],\n };\n}\n\n/**\n * swift-chart's theme shape (`addTheme(name, swiftChartTheme(…))` from `@arshad-shah/swift-chart`), written out so the\n * library is not imported.\n */\nexport interface SwiftChartTheme {\n /** The chart's page background. */\n bg: string;\n /** Panels and plot areas. */\n surface: string;\n /** Gridlines: quieter than the axis. */\n grid: string;\n /** Labels and values. */\n text: string;\n /** Axis ticks and secondary labels. */\n textMuted: string;\n /** Axis lines. */\n axis: string;\n /** Gains (up candles, positive bars). */\n positive: string;\n /** Losses. */\n negative: string;\n /** Text on an accent-filled mark. */\n onAccent: string;\n /** The series colours, in order (the palette's eight `seriesColors`). */\n colors: string[];\n /** Tooltip fill, border and text. */\n tooltipBg: string;\n tooltipBorder: string;\n tooltipText: string;\n}\n\n/** A swift-chart theme from a Cynosure palette. Build one per palette and register it again when the palette changes. */\nexport function swiftChartTheme(\n theme: Theme = createTheme(),\n palette: PaletteName = \"light\",\n): SwiftChartTheme {\n const p = resolveColors(theme, palette);\n return {\n bg: p.bg,\n surface: p.surface,\n grid: mix(p.line, p.surface, 0.5),\n text: p.ink,\n textMuted: p.muted,\n axis: p.line,\n positive: p.successText,\n negative: p.dangerText,\n onAccent: p.onAccent,\n colors: p.seriesColors,\n tooltipBg: p.surfaceRaised,\n tooltipBorder: p.line,\n tooltipText: p.ink,\n };\n}\n"],"mappings":";;AAYA,SAAgBI,EAAcC,IAAeF,EAAY,GAAGG,IAAuB,SAAsB;AACvG,QAAMC,IAAIF,EAAM,SAASC,CAAA,GACnBE,IAAMN,EAAaK,EAAE,QAAQA,EAAE,OAAO,GACtCE,IAAQ,KAAK,MAAOR,EAAW,OAAO,MAAO,GAAG,EACnD,SAAS,EAAE,EACX,SAAS,GAAG,GAAG;AAElB,SAAO;AAAA,IACL,GAAGM;AAAA,IACH,YACEA,EAAE,eAAeC,EAAI,aAAaR,EAAIO,EAAE,QAAQA,EAAE,SAASN,EAAW,aAAa,GAAG,IAAIM,EAAE;AAAA,IAC9F,MAAMA,EAAE,SAASC,EAAI,OAAO,GAAGD,EAAE,MAAA,GAASE,CAAA,KAAUF,EAAE;AAAA,IACtD,cAAc,CAAC,GAAGA,EAAE,YAAY;AAAA,EAClC;AACF;AAkCA,SAAgBG,EACdL,IAAeF,EAAY,GAC3BG,IAAuB,SACN;AACjB,QAAMC,IAAIH,EAAcC,GAAOC,CAAO;AACtC,SAAO;AAAA,IACL,IAAIC,EAAE;AAAA,IACN,SAASA,EAAE;AAAA,IACX,MAAMP,EAAIO,EAAE,MAAMA,EAAE,SAAS,GAAG;AAAA,IAChC,MAAMA,EAAE;AAAA,IACR,WAAWA,EAAE;AAAA,IACb,MAAMA,EAAE;AAAA,IACR,UAAUA,EAAE;AAAA,IACZ,UAAUA,EAAE;AAAA,IACZ,UAAUA,EAAE;AAAA,IACZ,QAAQA,EAAE;AAAA,IACV,WAAWA,EAAE;AAAA,IACb,eAAeA,EAAE;AAAA,IACjB,aAAaA,EAAE;AAAA,EACjB;AACF"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import type { Theme, ThemeInput } from "./schema.js";
|
|
1
|
+
import type { ColorTokens, Theme, ThemeInput } from "./schema.js";
|
|
2
|
+
/** How much accent (in percent) the soft tint takes over the surface and the focus ring over transparency. */
|
|
3
|
+
export declare const ACCENT_MIX: {
|
|
4
|
+
readonly accentSoft: 18;
|
|
5
|
+
readonly ring: 28;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The accent's two mixed colours as CSS (`color-mix()`, which the stylesheet resolves). `resolveColors` works out the
|
|
9
|
+
* same colours as hex from `ACCENT_MIX`, and recognises these values by building them again, never by parsing them.
|
|
10
|
+
*/
|
|
11
|
+
export declare const accentMixCss: (accent: string, surface: string) => Pick<ColorTokens, "accentSoft" | "ring">;
|
|
2
12
|
/** Builds a complete theme from a product's partial input. Throws CynosureThemeError for invalid colours. */
|
|
3
13
|
export declare function createTheme(input?: ThemeInput): Theme;
|