@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":"ink.js","names":["clamp","INK_WEIGHTS","STEADY_PRESSURE","penPressure","raw","previous","curved","inkPoint","event","rect","scale","x","y","CAP_STEPS","inkOutline","stroke","weight","tilt","sum","p","size","pts","i","r","a","b","first","arc","cx","cy","from","_","k","left","right","angles","len","nx","ny","last","endCap","startCap","f","n","outlineToPath","outline","mid","current","d","q","end","c1","c2","inkPath","inkToSvg","strokes","options","paths","s","fill"],"sources":["../../../src/components/SignaturePad/ink.ts"],"sourcesContent":["import { clamp } from \"../../foundations/math.js\";\n/**\n * Ink geometry for SignaturePad: pressure from the pen (constant for a mouse or finger), a filled, round-capped\n * outline per stroke, and SVG path data that a canvas (Path2D) and a PDF writer both read the same way. No\n * dependencies: the outline is the offset of a lightly smoothed centre line, which is all a signature needs.\n */\n\n/** One sample: pad units (y down), pressure 0..1, tilt in degrees, time in ms. */\nexport interface InkPoint {\n x: number;\n y: number;\n pressure: number;\n tiltX: number;\n tiltY: number;\n t: number;\n}\nexport type InkStroke = InkPoint[];\nexport type InkWeight = \"thin\" | \"medium\" | \"bold\";\n\n/** Nib diameter in pad units at pressure 0.5. */\nexport const INK_WEIGHTS: Record<InkWeight, number> = { thin: 2.2, medium: 3.4, bold: 5 };\n\n/**\n * Pressure for a mouse or finger, which report none. Constant, like a ballpoint: pressure simulated from speed makes\n * the line wobble as the hand speeds up and slows down, which no real pen does.\n */\nexport const STEADY_PRESSURE = 0.5;\n\n/**\n * A pen's raw pressure through a response curve, eased against the last sample. Pens report light writing as\n * 0.1–0.3, a hairline if used raw, so the curve lifts the low end; easing hides the digitiser's jitter.\n */\nexport function penPressure(raw: number, previous: number | null): number {\n const curved = 0.15 + 0.85 * clamp(raw, 0, 1) ** 0.65;\n return previous === null ? curved : previous + (curved - previous) * 0.5;\n}\n\n/** A sample from a pointer event. `scale` maps shown CSS pixels to the pad's coordinate space. */\nexport function inkPoint(\n event: PointerEvent,\n rect: DOMRect,\n previous: InkPoint | null,\n scale = { x: 1, y: 1 },\n): InkPoint {\n const x = (event.clientX - rect.left) * scale.x;\n const y = (event.clientY - rect.top) * scale.y;\n if (event.pointerType !== \"pen\")\n return { x, y, pressure: STEADY_PRESSURE, tiltX: 0, tiltY: 0, t: event.timeStamp };\n // A pen reports 0 as it lifts off: keep the last pressure, or each stroke would end in a blob or a dot.\n const pressure =\n event.pressure > 0\n ? penPressure(event.pressure, previous?.pressure ?? null)\n : (previous?.pressure ?? STEADY_PRESSURE);\n return { x, y, pressure, tiltX: event.tiltX || 0, tiltY: event.tiltY || 0, t: event.timeStamp };\n}\n\ntype Vec = [number, number];\nconst CAP_STEPS = 8;\n\n/** The filled outline of one stroke: a closed polygon in pad units. */\nexport function inkOutline(stroke: InkStroke, weight: InkWeight, scale = 1): Vec[] {\n if (stroke.length === 0) return [];\n const tilt = stroke.reduce((sum, p) => sum + Math.hypot(p.tiltX, p.tiltY), 0) / stroke.length;\n const size = INK_WEIGHTS[weight] * scale * (1 + 0.25 * Math.min(1, tilt / 60));\n // Light smoothing (1-2-1) takes the jitter out of the centre line without rounding off corners. The ends stay where\n // they were drawn, or every stroke would come up short.\n const pts = stroke.map((p, i) => {\n const r = (size / 2) * (0.4 + 1.2 * p.pressure);\n const a = stroke[i - 1];\n const b = stroke[i + 1];\n if (!a || !b) return { x: p.x, y: p.y, r };\n return { x: (a.x + 2 * p.x + b.x) / 4, y: (a.y + 2 * p.y + b.y) / 4, r };\n });\n const first = pts[0] as (typeof pts)[number];\n const arc = (cx: number, cy: number, r: number, from: number): Vec[] =>\n Array.from({ length: CAP_STEPS + 1 }, (_, k) => {\n const a = from - (Math.PI * k) / CAP_STEPS;\n return [cx + r * Math.cos(a), cy + r * Math.sin(a)];\n });\n if (pts.length === 1)\n return arc(first.x, first.y, first.r, 0).concat(arc(first.x, first.y, first.r, Math.PI));\n const left: Vec[] = [];\n const right: Vec[] = [];\n const angles: number[] = [];\n pts.forEach((p, i) => {\n const a = pts[Math.max(0, i - 1)] as typeof p;\n const b = pts[Math.min(pts.length - 1, i + 1)] as typeof p;\n const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;\n // The normal to the direction of travel: the left side of the stroke.\n const nx = -(b.y - a.y) / len;\n const ny = (b.x - a.x) / len;\n left.push([p.x + nx * p.r, p.y + ny * p.r]);\n right.push([p.x - nx * p.r, p.y - ny * p.r]);\n angles.push(Math.atan2(ny, nx));\n });\n const last = pts[pts.length - 1] as typeof first;\n // Round caps: from the left side round the end to the right side, then back round the start.\n const endCap = arc(last.x, last.y, last.r, angles[angles.length - 1] as number);\n const startCap = arc(first.x, first.y, first.r, (angles[0] as number) + Math.PI);\n return [...left, ...endCap, ...right.reverse(), ...startCap];\n}\n\nconst f = (n: number) => Math.round(n * 100) / 100;\n\n/**\n * SVG path data for a closed outline: smooth quadratics through the midpoints, written as the equivalent cubics, so the\n * path uses only M, C and Z (what Path2D and PDF writers read alike).\n */\nexport function outlineToPath(outline: Vec[]): string {\n const n = outline.length;\n if (n < 2) return \"\";\n const mid = (a: Vec, b: Vec): Vec => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];\n let current = mid(outline[n - 1] as Vec, outline[0] as Vec);\n let d = `M${f(current[0])} ${f(current[1])}`;\n for (let i = 0; i < n; i++) {\n const q = outline[i] as Vec;\n const end = mid(q, outline[(i + 1) % n] as Vec);\n const c1 = [current[0] + (2 / 3) * (q[0] - current[0]), current[1] + (2 / 3) * (q[1] - current[1])];\n const c2 = [end[0] + (2 / 3) * (q[0] - end[0]), end[1] + (2 / 3) * (q[1] - end[1])];\n d += `C${f(c1[0] as number)} ${f(c1[1] as number)} ${f(c2[0] as number)} ${f(c2[1] as number)} ${f(end[0])} ${f(end[1])}`;\n current = end;\n }\n return `${d}Z`;\n}\n\n/** Path data for one stroke. */\nexport const inkPath = (stroke: InkStroke, weight: InkWeight) => outlineToPath(inkOutline(stroke, weight));\n\n/** A standalone SVG of the strokes, for saving or placing in a PDF. `width` and `height` are the pad's space. */\nexport function inkToSvg(\n strokes: InkStroke[],\n options: { width: number; height: number; ink: string; weight: InkWeight },\n): string {\n const paths = strokes\n .map((s) => inkPath(s, options.weight))\n .filter(Boolean)\n .map((d) => `<path d=\"${d}\"/>`)\n .join(\"\");\n const fill = options.ink.replace(/[<>\"&]/g, \"\");\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${options.width} ${options.height}\" width=\"${options.width}\" height=\"${options.height}\"><g fill=\"${fill}\">${paths}</g></svg>`;\n}\n"],"mappings":";;AAoBA,IAAaC,IAAyC;AAAA,EAAE,MAAM;AAAA,EAAK,QAAQ;AAAA,EAAK,MAAM;AAAE,GAM3EC,IAAkB;AAM/B,SAAgBC,EAAYC,GAAaC,GAAiC;AACxE,QAAMC,IAAS,OAAO,OAAON,EAAMI,GAAK,GAAG,CAAC,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AME,EAAE,CAAA,IAAKF,EAAQ,CAAA,EAAG,GAC5FK,IAAK,CAACF,EAAI,CAAA,IAAM,IAAI,KAAMD,EAAE,CAAA,IAAKC,EAAI,CAAA,IAAKA,EAAI,CAAA,IAAM,IAAI,KAAMD,EAAE,CAAA,IAAKC,EAAI,CAAA,EAAG;AAClF,IAAAF,KAAK,IAAIN,EAAES,EAAG,CAAA,CAAY,CAAA,IAAKT,EAAES,EAAG,CAAA,CAAY,CAAA,IAAKT,EAAEU,EAAG,CAAA,CAAY,CAAA,IAAKV,EAAEU,EAAG,CAAA,CAAY,CAAA,IAAKV,EAAEQ,EAAI,CAAA,CAAE,CAAA,IAAKR,EAAEQ,EAAI,CAAA,CAAE,CAAA,IACtHH,IAAUG;AAAA,EACZ;AACA,SAAO,GAAGF,CAAA;AACZ;AAGA,IAAaK,IAAA,CAAWtC,GAAmBC,MAAsB4B,EAAc9B,EAAWC,GAAQC,CAAM,CAAC;AAGzG,SAAgBsC,EACdC,GACAC,GACQ;AACR,QAAMC,IAAQF,EACX,IAAA,CAAKG,MAAML,EAAQK,GAAGF,EAAQ,MAAM,CAAC,EACrC,OAAO,OAAO,EACd,IAAA,CAAKR,MAAM,YAAYA,CAAA,KAAM,EAC7B,KAAK,EAAE,GACJW,IAAOH,EAAQ,IAAI,QAAQ,WAAW,EAAE;AAC9C,SAAO,wDAAwDA,EAAQ,KAAA,IAASA,EAAQ,MAAA,YAAkBA,EAAQ,KAAA,aAAkBA,EAAQ,MAAA,cAAoBG,CAAA,KAASF,CAAA;AAC3K"}
|
|
1
|
+
{"version":3,"file":"ink.js","names":["clamp","INK_WEIGHTS","STEADY_PRESSURE","penPressure","raw","previous","curved","inkPoint","event","rect","scale","x","y","CAP_STEPS","inkOutline","stroke","weight","tilt","sum","p","size","pts","i","r","a","b","first","arc","cx","cy","from","_","k","left","right","angles","len","nx","ny","last","endCap","startCap","f","n","outlineToPath","outline","mid","current","d","q","end","c1","c2","inkPath","inkToSvg","strokes","options","paths","s","fill"],"sources":["../../../src/components/SignaturePad/ink.ts"],"sourcesContent":["import { clamp } from \"../../foundations/math.js\";\n/**\n * Ink geometry for SignaturePad: pressure from the pen (constant for a mouse or finger), a filled, round-capped\n * outline per stroke, and SVG path data that a canvas (Path2D) and a PDF writer both read the same way. No\n * dependencies: the outline is the offset of a lightly smoothed centre line, which is all a signature needs.\n */\n\n/** One sample: pad units (y down), pressure 0..1, tilt in degrees, time in ms. */\nexport interface InkPoint {\n x: number;\n y: number;\n pressure: number;\n tiltX: number;\n tiltY: number;\n t: number;\n}\nexport type InkStroke = InkPoint[];\nexport type InkWeight = \"thin\" | \"medium\" | \"bold\";\n\n/** Nib diameter in pad units at pressure 0.5. */\nexport const INK_WEIGHTS: Record<InkWeight, number> = { thin: 2.2, medium: 3.4, bold: 5 };\n\n/**\n * Pressure for a mouse or finger, which report none. Constant, like a ballpoint: pressure simulated from speed makes\n * the line wobble as the hand speeds up and slows down, which no real pen does.\n */\nexport const STEADY_PRESSURE = 0.5;\n\n/**\n * A pen's raw pressure through a response curve, eased against the last sample. Pens report light writing as\n * 0.1–0.3, a hairline if used raw, so the curve lifts the low end; easing hides the digitiser's jitter.\n */\nexport function penPressure(raw: number, previous: number | null): number {\n const curved = 0.15 + 0.85 * clamp(raw, 0, 1) ** 0.65;\n return previous === null ? curved : previous + (curved - previous) * 0.5;\n}\n\n/** A sample from a pointer event. `scale` maps shown CSS pixels to the pad's coordinate space. */\nexport function inkPoint(\n event: PointerEvent,\n rect: DOMRect,\n previous: InkPoint | null,\n scale = { x: 1, y: 1 },\n): InkPoint {\n const x = (event.clientX - rect.left) * scale.x;\n const y = (event.clientY - rect.top) * scale.y;\n if (event.pointerType !== \"pen\")\n return { x, y, pressure: STEADY_PRESSURE, tiltX: 0, tiltY: 0, t: event.timeStamp };\n // A pen reports 0 as it lifts off: keep the last pressure, or each stroke would end in a blob or a dot.\n const pressure =\n event.pressure > 0\n ? penPressure(event.pressure, previous?.pressure ?? null)\n : (previous?.pressure ?? STEADY_PRESSURE);\n return { x, y, pressure, tiltX: event.tiltX || 0, tiltY: event.tiltY || 0, t: event.timeStamp };\n}\n\ntype Vec = [number, number];\nconst CAP_STEPS = 8;\n\n/** The filled outline of one stroke: a closed polygon in pad units. */\nexport function inkOutline(stroke: InkStroke, weight: InkWeight, scale = 1): Vec[] {\n if (stroke.length === 0) return [];\n const tilt = stroke.reduce((sum, p) => sum + Math.hypot(p.tiltX, p.tiltY), 0) / stroke.length;\n const size = INK_WEIGHTS[weight] * scale * (1 + 0.25 * Math.min(1, tilt / 60));\n // Light smoothing (1-2-1) takes the jitter out of the centre line without rounding off corners. The ends stay where\n // they were drawn, or every stroke would come up short.\n const pts = stroke.map((p, i) => {\n const r = (size / 2) * (0.4 + 1.2 * p.pressure);\n const a = stroke[i - 1];\n const b = stroke[i + 1];\n if (!a || !b) return { x: p.x, y: p.y, r };\n return { x: (a.x + 2 * p.x + b.x) / 4, y: (a.y + 2 * p.y + b.y) / 4, r };\n });\n const first = pts[0] as (typeof pts)[number];\n const arc = (cx: number, cy: number, r: number, from: number): Vec[] =>\n Array.from({ length: CAP_STEPS + 1 }, (_, k) => {\n const a = from - (Math.PI * k) / CAP_STEPS;\n return [cx + r * Math.cos(a), cy + r * Math.sin(a)];\n });\n if (pts.length === 1)\n return arc(first.x, first.y, first.r, 0).concat(arc(first.x, first.y, first.r, Math.PI));\n const left: Vec[] = [];\n const right: Vec[] = [];\n const angles: number[] = [];\n pts.forEach((p, i) => {\n const a = pts[Math.max(0, i - 1)] as typeof p;\n const b = pts[Math.min(pts.length - 1, i + 1)] as typeof p;\n const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;\n // The normal to the direction of travel: the left side of the stroke.\n const nx = -(b.y - a.y) / len;\n const ny = (b.x - a.x) / len;\n left.push([p.x + nx * p.r, p.y + ny * p.r]);\n right.push([p.x - nx * p.r, p.y - ny * p.r]);\n angles.push(Math.atan2(ny, nx));\n });\n const last = pts[pts.length - 1] as typeof first;\n // Round caps: from the left side round the end to the right side, then back round the start.\n const endCap = arc(last.x, last.y, last.r, angles[angles.length - 1] as number);\n const startCap = arc(first.x, first.y, first.r, (angles[0] as number) + Math.PI);\n return [...left, ...endCap, ...right.reverse(), ...startCap];\n}\n\nconst f = (n: number) => Math.round(n * 100) / 100;\n\n/**\n * SVG path data for a closed outline: smooth quadratics through the midpoints, written as the equivalent cubics, so the\n * path uses only M, C and Z (what Path2D and PDF writers read alike).\n */\nexport function outlineToPath(outline: Vec[]): string {\n const n = outline.length;\n if (n < 2) return \"\";\n const mid = (a: Vec, b: Vec): Vec => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];\n let current = mid(outline[n - 1] as Vec, outline[0] as Vec);\n let d = `M${f(current[0])} ${f(current[1])}`;\n for (let i = 0; i < n; i++) {\n const q = outline[i] as Vec;\n const end = mid(q, outline[(i + 1) % n] as Vec);\n const c1 = [current[0] + (2 / 3) * (q[0] - current[0]), current[1] + (2 / 3) * (q[1] - current[1])];\n const c2 = [end[0] + (2 / 3) * (q[0] - end[0]), end[1] + (2 / 3) * (q[1] - end[1])];\n d += `C${f(c1[0] as number)} ${f(c1[1] as number)} ${f(c2[0] as number)} ${f(c2[1] as number)} ${f(end[0])} ${f(end[1])}`;\n current = end;\n }\n return `${d}Z`;\n}\n\n/** Path data for one stroke. */\nexport const inkPath = (stroke: InkStroke, weight: InkWeight) => outlineToPath(inkOutline(stroke, weight));\n\n/** A standalone SVG of the strokes, for saving or placing in a PDF. `width` and `height` are the pad's space. */\nexport function inkToSvg(\n strokes: InkStroke[],\n options: { width: number; height: number; ink: string; weight: InkWeight },\n): string {\n const paths = strokes\n .map((s) => inkPath(s, options.weight))\n .filter(Boolean)\n .map((d) => `<path d=\"${d}\"/>`)\n .join(\"\");\n const fill = options.ink.replace(/[<>\"&]/g, \"\");\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${options.width} ${options.height}\" width=\"${options.width}\" height=\"${options.height}\"><g fill=\"${fill}\">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ties, type ReactNode } from "react";
|
|
2
|
+
import { type ContainerProps } from "../Container/Container.js";
|
|
3
|
+
export interface SiteFooterTokens {
|
|
4
|
+
/** Background of the footer. */
|
|
5
|
+
background: string;
|
|
6
|
+
/** Colour of the hairline above the footer and above its bottom row. */
|
|
7
|
+
border: string;
|
|
8
|
+
/** Space above and below the footer's content, and between its rows. */
|
|
9
|
+
paddingBlock: string;
|
|
10
|
+
/** Least width of a link column before the columns wrap onto another row. */
|
|
11
|
+
columnMinWidth: string;
|
|
12
|
+
}
|
|
13
|
+
declare module "../../tokens/schema.js" {
|
|
14
|
+
interface ComponentTokens {
|
|
15
|
+
siteFooter: SiteFooterTokens;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** A column of footer links under a heading. */
|
|
19
|
+
export interface SiteFooterColumn {
|
|
20
|
+
/** The column's heading, e.g. "Product". */
|
|
21
|
+
title: string;
|
|
22
|
+
/** The column's links, in order. */
|
|
23
|
+
links: {
|
|
24
|
+
/** The link text. */
|
|
25
|
+
label: string;
|
|
26
|
+
/** Where it goes. */
|
|
27
|
+
href: string;
|
|
28
|
+
/** Opens in a new tab, with an icon and announced text. */
|
|
29
|
+
external?: boolean;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
export interface SiteFooterLabels {
|
|
33
|
+
/** Name of the navigation landmark that holds the link columns. Default: "Footer". */
|
|
34
|
+
nav: string;
|
|
35
|
+
}
|
|
36
|
+
export interface SiteFooterProps {
|
|
37
|
+
/** The logo or the site's name, at the top of the inline start. */
|
|
38
|
+
brand?: ReactNode;
|
|
39
|
+
/** A sentence under the brand about the site or the company. */
|
|
40
|
+
tagline?: ReactNode;
|
|
41
|
+
/** Link columns, as data: a heading and its links. They sit side by side and wrap onto more rows when narrow. */
|
|
42
|
+
columns?: SiteFooterColumn[];
|
|
43
|
+
/** Heading level of the column titles, to fit the page outline. Default 2. */
|
|
44
|
+
headingLevel?: 2 | 3 | 4;
|
|
45
|
+
/** The bottom row's start: copyright and legal links. */
|
|
46
|
+
legal?: ReactNode;
|
|
47
|
+
/** The bottom row's end: links to the site's social accounts, usually IconButtons with `href`. */
|
|
48
|
+
social?: ReactNode;
|
|
49
|
+
/** Widest the content gets: the `size` of its Container, to line up with the page. Default "lg". */
|
|
50
|
+
size?: ContainerProps["size"];
|
|
51
|
+
/** Replace the built-in English text: `nav`, the name of the links' navigation landmark. */
|
|
52
|
+
labels?: Partial<SiteFooterLabels>;
|
|
53
|
+
/** Set on the `footer` element. */
|
|
54
|
+
id?: string | undefined;
|
|
55
|
+
/** Names the footer, when a page has more than one. */
|
|
56
|
+
"aria-label"?: string | undefined;
|
|
57
|
+
/** Added to the `footer` element, for layout. */
|
|
58
|
+
className?: string | undefined;
|
|
59
|
+
/** Layout only. Restyle through --cy-site-footer-* tokens. */
|
|
60
|
+
style?: CSSProperties;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The bottom of a website: the brand and a tagline, columns of links, and a bottom row for the copyright, legal links
|
|
64
|
+
* and social links. Columns and rows stack on narrow screens.
|
|
65
|
+
*/
|
|
66
|
+
export declare const SiteFooter: import("react").ForwardRefExoticComponent<SiteFooterProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Link as u } from "../Link/Link.js";
|
|
3
|
+
import { Container as F } from "../Container/Container.js";
|
|
4
|
+
import { Heading as L } from "../Heading/Heading.js";
|
|
5
|
+
import { Text as b } from "../Text/Text.js";
|
|
6
|
+
import { forwardRef as S, useId as g } from "react";
|
|
7
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
8
|
+
var j = { nav: "Footer" }, C = S(function({ brand: r, tagline: s, columns: i = [], headingLevel: y = 2, legal: c, social: a, size: h = "lg", labels: v, className: d, style: N, ...p }, x) {
|
|
9
|
+
const $ = {
|
|
10
|
+
...j,
|
|
11
|
+
...v
|
|
12
|
+
}, n = g(), f = r || s || i.length > 0;
|
|
13
|
+
return /* @__PURE__ */ e("footer", {
|
|
14
|
+
ref: x,
|
|
15
|
+
...p,
|
|
16
|
+
className: `cy-site-footer${d ? ` ${d}` : ""}`,
|
|
17
|
+
style: N,
|
|
18
|
+
children: /* @__PURE__ */ t(F, {
|
|
19
|
+
size: h,
|
|
20
|
+
className: "cy-site-footer-inner",
|
|
21
|
+
children: [f && /* @__PURE__ */ t("div", {
|
|
22
|
+
className: "cy-site-footer-top cy-reset",
|
|
23
|
+
children: [(r || s) && /* @__PURE__ */ t("div", {
|
|
24
|
+
className: "cy-site-footer-brand cy-reset",
|
|
25
|
+
children: [r && /* @__PURE__ */ e("div", {
|
|
26
|
+
className: "cy-site-footer-logo",
|
|
27
|
+
children: r
|
|
28
|
+
}), s && /* @__PURE__ */ e(b, {
|
|
29
|
+
as: "p",
|
|
30
|
+
tone: "muted",
|
|
31
|
+
className: "cy-site-footer-tagline",
|
|
32
|
+
children: s
|
|
33
|
+
})]
|
|
34
|
+
}), i.length > 0 && /* @__PURE__ */ e("nav", {
|
|
35
|
+
"aria-label": $.nav,
|
|
36
|
+
className: "cy-site-footer-nav cy-reset",
|
|
37
|
+
children: i.map((l, m) => /* @__PURE__ */ t("div", {
|
|
38
|
+
className: "cy-site-footer-column cy-reset",
|
|
39
|
+
children: [/* @__PURE__ */ e(L, {
|
|
40
|
+
level: y,
|
|
41
|
+
size: "xs",
|
|
42
|
+
id: `${n}-${m}`,
|
|
43
|
+
className: "cy-site-footer-title",
|
|
44
|
+
children: l.title
|
|
45
|
+
}), /* @__PURE__ */ e("ul", {
|
|
46
|
+
"aria-labelledby": `${n}-${m}`,
|
|
47
|
+
className: "cy-site-footer-links cy-reset",
|
|
48
|
+
children: l.links.map((o) => /* @__PURE__ */ e("li", {
|
|
49
|
+
className: "cy-site-footer-item cy-reset",
|
|
50
|
+
children: /* @__PURE__ */ e(u, {
|
|
51
|
+
href: o.href,
|
|
52
|
+
tone: "neutral",
|
|
53
|
+
size: "md",
|
|
54
|
+
external: o.external ?? !1,
|
|
55
|
+
className: "cy-site-footer-link",
|
|
56
|
+
children: o.label
|
|
57
|
+
})
|
|
58
|
+
}, o.href))
|
|
59
|
+
})]
|
|
60
|
+
}, l.title))
|
|
61
|
+
})]
|
|
62
|
+
}), (c || a) && /* @__PURE__ */ t("div", {
|
|
63
|
+
className: "cy-site-footer-bottom cy-reset",
|
|
64
|
+
"data-divided": f ? "" : void 0,
|
|
65
|
+
children: [c && /* @__PURE__ */ e("div", {
|
|
66
|
+
className: "cy-site-footer-legal",
|
|
67
|
+
children: c
|
|
68
|
+
}), a && /* @__PURE__ */ e("div", {
|
|
69
|
+
className: "cy-site-footer-social cy-reset",
|
|
70
|
+
children: a
|
|
71
|
+
})]
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
export {
|
|
77
|
+
C as SiteFooter
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=SiteFooter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteFooter.js","names":["Link","Container","Heading","Text","forwardRef","useId","jsx","jsxs","DEFAULT_LABELS","SiteFooter","brand","tagline","columns","headingLevel","legal","social","size","labels","className","style","rest","ref","text","id","top","column","i","link"],"sources":["../../../src/components/SiteFooter/SiteFooter.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode, useId } from \"react\";\nimport { Container, type ContainerProps } from \"../Container/Container.js\";\nimport { Heading } from \"../Heading/Heading.js\";\nimport { Link } from \"../Link/Link.js\";\nimport { Text } from \"../Text/Text.js\";\n\nexport interface SiteFooterTokens {\n /** Background of the footer. */\n background: string;\n /** Colour of the hairline above the footer and above its bottom row. */\n border: string;\n /** Space above and below the footer's content, and between its rows. */\n paddingBlock: string;\n /** Least width of a link column before the columns wrap onto another row. */\n columnMinWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n siteFooter: SiteFooterTokens;\n }\n}\n\n/** A column of footer links under a heading. */\nexport interface SiteFooterColumn {\n /** The column's heading, e.g. \"Product\". */\n title: string;\n /** The column's links, in order. */\n links: {\n /** The link text. */\n label: string;\n /** Where it goes. */\n href: string;\n /** Opens in a new tab, with an icon and announced text. */\n external?: boolean;\n }[];\n}\n\nexport interface SiteFooterLabels {\n /** Name of the navigation landmark that holds the link columns. Default: \"Footer\". */\n nav: string;\n}\n\nexport interface SiteFooterProps {\n /** The logo or the site's name, at the top of the inline start. */\n brand?: ReactNode;\n /** A sentence under the brand about the site or the company. */\n tagline?: ReactNode;\n /** Link columns, as data: a heading and its links. They sit side by side and wrap onto more rows when narrow. */\n columns?: SiteFooterColumn[];\n /** Heading level of the column titles, to fit the page outline. Default 2. */\n headingLevel?: 2 | 3 | 4;\n /** The bottom row's start: copyright and legal links. */\n legal?: ReactNode;\n /** The bottom row's end: links to the site's social accounts, usually IconButtons with `href`. */\n social?: ReactNode;\n /** Widest the content gets: the `size` of its Container, to line up with the page. Default \"lg\". */\n size?: ContainerProps[\"size\"];\n /** Replace the built-in English text: `nav`, the name of the links' navigation landmark. */\n labels?: Partial<SiteFooterLabels>;\n /** Set on the `footer` element. */\n id?: string | undefined;\n /** Names the footer, when a page has more than one. */\n \"aria-label\"?: string | undefined;\n /** Added to the `footer` element, for layout. */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-site-footer-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: SiteFooterLabels = { nav: \"Footer\" };\n\n/**\n * The bottom of a website: the brand and a tagline, columns of links, and a bottom row for the copyright, legal links\n * and social links. Columns and rows stack on narrow screens.\n */\nexport const SiteFooter = forwardRef<HTMLElement, SiteFooterProps>(function SiteFooter(\n {\n brand,\n tagline,\n columns = [],\n headingLevel = 2,\n legal,\n social,\n size = \"lg\",\n labels,\n className,\n style,\n ...rest\n },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const id = useId();\n const top = brand || tagline || columns.length > 0;\n return (\n <footer ref={ref} {...rest} className={`cy-site-footer${className ? ` ${className}` : \"\"}`} style={style}>\n <Container size={size} className=\"cy-site-footer-inner\">\n {top && (\n <div className=\"cy-site-footer-top cy-reset\">\n {(brand || tagline) && (\n <div className=\"cy-site-footer-brand cy-reset\">\n {brand && <div className=\"cy-site-footer-logo\">{brand}</div>}\n {tagline && (\n <Text as=\"p\" tone=\"muted\" className=\"cy-site-footer-tagline\">\n {tagline}\n </Text>\n )}\n </div>\n )}\n {columns.length > 0 && (\n <nav aria-label={text.nav} className=\"cy-site-footer-nav cy-reset\">\n {columns.map((column, i) => (\n <div key={column.title} className=\"cy-site-footer-column cy-reset\">\n <Heading\n level={headingLevel}\n size=\"xs\"\n id={`${id}-${i}`}\n className=\"cy-site-footer-title\"\n >\n {column.title}\n </Heading>\n <ul aria-labelledby={`${id}-${i}`} className=\"cy-site-footer-links cy-reset\">\n {column.links.map((link) => (\n <li key={link.href} className=\"cy-site-footer-item cy-reset\">\n <Link\n href={link.href}\n tone=\"neutral\"\n size=\"md\"\n external={link.external ?? false}\n className=\"cy-site-footer-link\"\n >\n {link.label}\n </Link>\n </li>\n ))}\n </ul>\n </div>\n ))}\n </nav>\n )}\n </div>\n )}\n {(legal || social) && (\n <div className=\"cy-site-footer-bottom cy-reset\" data-divided={top ? \"\" : undefined}>\n {legal && <div className=\"cy-site-footer-legal\">{legal}</div>}\n {social && <div className=\"cy-site-footer-social cy-reset\">{social}</div>}\n </div>\n )}\n </Container>\n </footer>\n );\n});\n"],"mappings":";;;;;;;AAsEA,IAAMQ,IAAmC,EAAE,KAAK,SAAS,GAM5CC,IAAaL,EAAyC,SACjE,EACE,OAAAM,GACA,SAAAC,GACA,SAAAC,IAAU,CAAC,GACX,cAAAC,IAAe,GACf,OAAAC,GACA,QAAAC,GACA,MAAAC,IAAO,MACP,QAAAC,GACA,WAAAC,GACA,OAAAC,GACA,GAAGC,EAAA,GAELC,GACA;AACA,QAAMC,IAAO;AAAA,IAAE,GAAGd;AAAA,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AAArB,EAAC,MAAD;AAAA,gBAAoB,WAAU;AAAA,gBAC5B,UAAA,gBAAAA,EAACN,GAAD;AAAA,kBACE,MAAM2B,EAAK;AAAA,kBACX,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,UAAUA,EAAK,YAAY;AAAA,kBAC3B,WAAU;AAAA,kBAET,UAAAA,EAAK;AAAA,gBACF,CAAA;AAAA,cACJ,GAVKA,EAAK,IAUV,CACL;AAAA,YACC,CAAA,CACD;AAAA,UAxBK,GAAAF,EAAO,KAwBZ,CACN;AAAA,QACE,CAAA,CAEJ;AAAA,MAEL,CAAA,IAAAX,KAASC,MACT,gBAAAR,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAiC,gBAAciB,IAAM,KAAK;AAAA,QAAzE,UAAA,CACGV,KAAS,gBAAAR,EAAC,OAAD;AAAA,UAAK,WAAU;AAAA,UAAwB,UAAAQ;AAAA,QAAW,CAAA,GAC3DC,KAAU,gBAAAT,EAAC,OAAD;AAAA,UAAK,WAAU;AAAA,UAAkC,UAAAS;AAAA,QAAY,CAAA,CACrE;AAAA,MAEE,CAAA,CAAA;AAAA,I;A,EACL,CAAA;AAEZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SiteFooter, type SiteFooterColumn, type SiteFooterLabels, type SiteFooterProps, type SiteFooterTokens, } from "./SiteFooter.js";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type ContainerProps } from "../Container/Container.js";
|
|
3
|
+
export interface SiteHeaderTokens {
|
|
4
|
+
/** Least height of the bar. */
|
|
5
|
+
height: string;
|
|
6
|
+
/** Background of the bar. A sticky bar mixes it with some transparency and blurs the page behind. */
|
|
7
|
+
background: string;
|
|
8
|
+
/** Colour of the hairline under the bar. */
|
|
9
|
+
border: string;
|
|
10
|
+
/** Blur of the page seen through a sticky bar. */
|
|
11
|
+
blur: string;
|
|
12
|
+
/** Text colour of the navigation links. */
|
|
13
|
+
linkColor: string;
|
|
14
|
+
/** Text colour of the link to the current page. */
|
|
15
|
+
linkCurrentColor: string;
|
|
16
|
+
/** Background of a hovered link and of the link to the current page. */
|
|
17
|
+
linkHighlight: string;
|
|
18
|
+
}
|
|
19
|
+
declare module "../../tokens/schema.js" {
|
|
20
|
+
interface ComponentTokens {
|
|
21
|
+
siteHeader: SiteHeaderTokens;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** One link of the site navigation. */
|
|
25
|
+
export interface SiteHeaderLink {
|
|
26
|
+
/** The link text. */
|
|
27
|
+
label: string;
|
|
28
|
+
/** Where it goes. */
|
|
29
|
+
href: string;
|
|
30
|
+
/** This link is the page being shown: it is marked `aria-current="page"`. */
|
|
31
|
+
current?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface SiteHeaderLabels {
|
|
34
|
+
/** Name of the navigation landmark, in the bar and in the menu. Default: "Main". */
|
|
35
|
+
nav: string;
|
|
36
|
+
/** The menu button shown on narrow screens. Default: "Open menu". */
|
|
37
|
+
openMenu: string;
|
|
38
|
+
/** Title of the menu sheet. Default: "Menu". */
|
|
39
|
+
menu: string;
|
|
40
|
+
/** The skip link. Default: "Skip to content". */
|
|
41
|
+
skip: string;
|
|
42
|
+
}
|
|
43
|
+
export interface SiteHeaderProps {
|
|
44
|
+
/** The logo or the site's name, at the inline start. Give a logo image its text alternative. */
|
|
45
|
+
brand?: ReactNode;
|
|
46
|
+
/** Where the brand links to. `false` shows the brand without a link. Default "/". */
|
|
47
|
+
brandHref?: string | false;
|
|
48
|
+
/** The site navigation, as data. Each link is a real link; the `current` one is marked for assistive technology. */
|
|
49
|
+
nav?: SiteHeaderLink[];
|
|
50
|
+
/** Controls at the inline end, such as a ThemeToggle, a search button or a sign-in Button. They stay in the bar. */
|
|
51
|
+
actions?: ReactNode;
|
|
52
|
+
/** Keep the bar at the top of the window while the page scrolls, over a blurred view of the page. Default true. */
|
|
53
|
+
sticky?: boolean;
|
|
54
|
+
/** Render a SkipLink before the bar, the first stop of the Tab order. Default true. */
|
|
55
|
+
skipLink?: boolean;
|
|
56
|
+
/** Where the skip link goes: `#` and the id of the page's main content. Default "#main". */
|
|
57
|
+
skipTo?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Width of the header below which the navigation moves into a menu opened from a button: `sm` 40rem, `md` 48rem,
|
|
60
|
+
* `lg` 64rem. CSS only, so the right layout shows before any script runs. Default "md".
|
|
61
|
+
*/
|
|
62
|
+
collapseBelow?: "sm" | "md" | "lg";
|
|
63
|
+
/** Widest the bar's content gets: the `size` of its Container, to line up with the page. Default "lg". */
|
|
64
|
+
size?: ContainerProps["size"];
|
|
65
|
+
/** Replace the built-in English text: the landmark name, the menu button, the menu title and the skip link. */
|
|
66
|
+
labels?: Partial<SiteHeaderLabels>;
|
|
67
|
+
/** Set on the `header` element. */
|
|
68
|
+
id?: string | undefined;
|
|
69
|
+
/** Added to the `header` element, for layout. */
|
|
70
|
+
className?: string | undefined;
|
|
71
|
+
/** Layout only. Restyle through --cy-site-header-* tokens. */
|
|
72
|
+
style?: CSSProperties;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The top bar of a website that scrolls as a document: a skip link, the brand, the site navigation and actions. On
|
|
76
|
+
* narrow screens the navigation moves into a menu sheet. For an app frame with a side navigation, use AppShell.
|
|
77
|
+
*/
|
|
78
|
+
export declare const SiteHeader: import("react").ForwardRefExoticComponent<SiteHeaderProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { menu as x } from "../../icons/menu.js";
|
|
3
|
+
import { IconButton as L } from "../IconButton/IconButton.js";
|
|
4
|
+
import { Sheet as M } from "../Sheet/Sheet.js";
|
|
5
|
+
import { SkipLink as C } from "../SkipLink/SkipLink.js";
|
|
6
|
+
import { Link as h } from "../Link/Link.js";
|
|
7
|
+
import { Container as F } from "../Container/Container.js";
|
|
8
|
+
import { SideNav as O } from "../SideNav/SideNav.js";
|
|
9
|
+
import { forwardRef as $, useState as j } from "react";
|
|
10
|
+
import { Fragment as A, jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
11
|
+
var B = {
|
|
12
|
+
nav: "Main",
|
|
13
|
+
openMenu: "Open menu",
|
|
14
|
+
menu: "Menu",
|
|
15
|
+
skip: "Skip to content"
|
|
16
|
+
}, _ = $(function({ brand: t, brandHref: s = "/", nav: a = [], actions: l, sticky: p = !0, skipLink: u = !0, skipTo: f = "#main", collapseBelow: y = "md", size: N = "lg", labels: g, id: k, className: c, style: v }, S) {
|
|
17
|
+
const n = {
|
|
18
|
+
...B,
|
|
19
|
+
...g
|
|
20
|
+
}, [o, i] = j(!1), d = a.findIndex((r) => r.current);
|
|
21
|
+
return /* @__PURE__ */ m(A, { children: [
|
|
22
|
+
u && /* @__PURE__ */ e(C, {
|
|
23
|
+
href: f,
|
|
24
|
+
labels: { skip: n.skip }
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ e("header", {
|
|
27
|
+
ref: S,
|
|
28
|
+
id: k,
|
|
29
|
+
className: `cy-site-header${c ? ` ${c}` : ""}`,
|
|
30
|
+
"data-sticky": p ? "" : void 0,
|
|
31
|
+
"data-collapse": y,
|
|
32
|
+
style: v,
|
|
33
|
+
children: /* @__PURE__ */ m(F, {
|
|
34
|
+
size: N,
|
|
35
|
+
className: "cy-site-header-bar",
|
|
36
|
+
children: [
|
|
37
|
+
t && (s === !1 ? /* @__PURE__ */ e("div", {
|
|
38
|
+
className: "cy-site-header-brand",
|
|
39
|
+
children: t
|
|
40
|
+
}) : /* @__PURE__ */ e(h, {
|
|
41
|
+
href: s,
|
|
42
|
+
tone: "neutral",
|
|
43
|
+
underline: "none",
|
|
44
|
+
className: "cy-site-header-brand-link",
|
|
45
|
+
children: /* @__PURE__ */ e("span", {
|
|
46
|
+
className: "cy-site-header-brand",
|
|
47
|
+
children: t
|
|
48
|
+
})
|
|
49
|
+
})),
|
|
50
|
+
a.length > 0 && /* @__PURE__ */ e("nav", {
|
|
51
|
+
"aria-label": n.nav,
|
|
52
|
+
className: "cy-site-header-nav cy-reset",
|
|
53
|
+
children: /* @__PURE__ */ e("ul", {
|
|
54
|
+
className: "cy-site-header-list cy-reset",
|
|
55
|
+
children: a.map((r) => /* @__PURE__ */ e("li", {
|
|
56
|
+
className: "cy-site-header-item cy-reset",
|
|
57
|
+
children: /* @__PURE__ */ e(h, {
|
|
58
|
+
href: r.href,
|
|
59
|
+
tone: "neutral",
|
|
60
|
+
underline: "none",
|
|
61
|
+
"aria-current": r.current ? "page" : void 0,
|
|
62
|
+
className: "cy-site-header-link-anchor",
|
|
63
|
+
children: /* @__PURE__ */ e("span", {
|
|
64
|
+
className: "cy-site-header-link",
|
|
65
|
+
children: r.label
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}, r.href))
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
l && /* @__PURE__ */ e("div", {
|
|
72
|
+
className: "cy-site-header-actions cy-reset",
|
|
73
|
+
children: l
|
|
74
|
+
}),
|
|
75
|
+
a.length > 0 && /* @__PURE__ */ e("div", {
|
|
76
|
+
className: "cy-site-header-menu cy-reset",
|
|
77
|
+
children: /* @__PURE__ */ e(L, {
|
|
78
|
+
icon: x,
|
|
79
|
+
label: n.openMenu,
|
|
80
|
+
variant: "ghost",
|
|
81
|
+
tone: "neutral",
|
|
82
|
+
tooltipPlacement: "bottom",
|
|
83
|
+
"aria-expanded": o,
|
|
84
|
+
onClick: () => i(!0)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
a.length > 0 && /* @__PURE__ */ e(M, {
|
|
91
|
+
open: o,
|
|
92
|
+
onOpenChange: i,
|
|
93
|
+
side: "end",
|
|
94
|
+
size: "sm",
|
|
95
|
+
title: n.menu,
|
|
96
|
+
children: /* @__PURE__ */ e(O, {
|
|
97
|
+
label: n.nav,
|
|
98
|
+
items: a.map((r, b) => ({
|
|
99
|
+
id: String(b),
|
|
100
|
+
label: r.label,
|
|
101
|
+
href: r.href
|
|
102
|
+
})),
|
|
103
|
+
current: d < 0 ? void 0 : String(d),
|
|
104
|
+
onNavigate: () => i(!1),
|
|
105
|
+
className: "cy-site-header-sheet-nav"
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
] });
|
|
109
|
+
});
|
|
110
|
+
export {
|
|
111
|
+
_ as SiteHeader
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=SiteHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteHeader.js","names":["_Fragment","menu","IconButton","Sheet","SkipLink","Link","Container","SideNav","forwardRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","SiteHeader","brand","brandHref","nav","actions","sticky","skipLink","skipTo","collapseBelow","size","labels","id","className","style","ref","text","open","setOpen","current","item","i"],"sources":["../../../src/components/SiteHeader/SiteHeader.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode, useState } from \"react\";\nimport { menu } from \"../../icons/menu.js\";\nimport { Container, type ContainerProps } from \"../Container/Container.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Link } from \"../Link/Link.js\";\nimport { Sheet } from \"../Sheet/Sheet.js\";\nimport { SideNav } from \"../SideNav/SideNav.js\";\nimport { SkipLink } from \"../SkipLink/SkipLink.js\";\n\nexport interface SiteHeaderTokens {\n /** Least height of the bar. */\n height: string;\n /** Background of the bar. A sticky bar mixes it with some transparency and blurs the page behind. */\n background: string;\n /** Colour of the hairline under the bar. */\n border: string;\n /** Blur of the page seen through a sticky bar. */\n blur: string;\n /** Text colour of the navigation links. */\n linkColor: string;\n /** Text colour of the link to the current page. */\n linkCurrentColor: string;\n /** Background of a hovered link and of the link to the current page. */\n linkHighlight: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n siteHeader: SiteHeaderTokens;\n }\n}\n\n/** One link of the site navigation. */\nexport interface SiteHeaderLink {\n /** The link text. */\n label: string;\n /** Where it goes. */\n href: string;\n /** This link is the page being shown: it is marked `aria-current=\"page\"`. */\n current?: boolean;\n}\n\nexport interface SiteHeaderLabels {\n /** Name of the navigation landmark, in the bar and in the menu. Default: \"Main\". */\n nav: string;\n /** The menu button shown on narrow screens. Default: \"Open menu\". */\n openMenu: string;\n /** Title of the menu sheet. Default: \"Menu\". */\n menu: string;\n /** The skip link. Default: \"Skip to content\". */\n skip: string;\n}\n\nexport interface SiteHeaderProps {\n /** The logo or the site's name, at the inline start. Give a logo image its text alternative. */\n brand?: ReactNode;\n /** Where the brand links to. `false` shows the brand without a link. Default \"/\". */\n brandHref?: string | false;\n /** The site navigation, as data. Each link is a real link; the `current` one is marked for assistive technology. */\n nav?: SiteHeaderLink[];\n /** Controls at the inline end, such as a ThemeToggle, a search button or a sign-in Button. They stay in the bar. */\n actions?: ReactNode;\n /** Keep the bar at the top of the window while the page scrolls, over a blurred view of the page. Default true. */\n sticky?: boolean;\n /** Render a SkipLink before the bar, the first stop of the Tab order. Default true. */\n skipLink?: boolean;\n /** Where the skip link goes: `#` and the id of the page's main content. Default \"#main\". */\n skipTo?: string;\n /**\n * Width of the header below which the navigation moves into a menu opened from a button: `sm` 40rem, `md` 48rem,\n * `lg` 64rem. CSS only, so the right layout shows before any script runs. Default \"md\".\n */\n collapseBelow?: \"sm\" | \"md\" | \"lg\";\n /** Widest the bar's content gets: the `size` of its Container, to line up with the page. Default \"lg\". */\n size?: ContainerProps[\"size\"];\n /** Replace the built-in English text: the landmark name, the menu button, the menu title and the skip link. */\n labels?: Partial<SiteHeaderLabels>;\n /** Set on the `header` element. */\n id?: string | undefined;\n /** Added to the `header` element, for layout. */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-site-header-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: SiteHeaderLabels = {\n nav: \"Main\",\n openMenu: \"Open menu\",\n menu: \"Menu\",\n skip: \"Skip to content\",\n};\n\n/**\n * The top bar of a website that scrolls as a document: a skip link, the brand, the site navigation and actions. On\n * narrow screens the navigation moves into a menu sheet. For an app frame with a side navigation, use AppShell.\n */\nexport const SiteHeader = forwardRef<HTMLElement, SiteHeaderProps>(function SiteHeader(\n {\n brand,\n brandHref = \"/\",\n nav = [],\n actions,\n sticky = true,\n skipLink = true,\n skipTo = \"#main\",\n collapseBelow = \"md\",\n size = \"lg\",\n labels,\n id,\n className,\n style,\n },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [open, setOpen] = useState(false);\n const current = nav.findIndex((item) => item.current);\n\n return (\n <>\n {/* Before the header, not in it: a sticky header's blur would make the link's fixed position relative to it. */}\n {skipLink && <SkipLink href={skipTo} labels={{ skip: text.skip }} />}\n <header\n ref={ref}\n id={id}\n className={`cy-site-header${className ? ` ${className}` : \"\"}`}\n data-sticky={sticky ? \"\" : undefined}\n data-collapse={collapseBelow}\n style={style}\n >\n <Container size={size} className=\"cy-site-header-bar\">\n {brand &&\n (brandHref === false ? (\n <div className=\"cy-site-header-brand\">{brand}</div>\n ) : (\n // A Link (its focus ring and colour), drawn as the brand by the span inside it.\n <Link href={brandHref} tone=\"neutral\" underline=\"none\" className=\"cy-site-header-brand-link\">\n <span className=\"cy-site-header-brand\">{brand}</span>\n </Link>\n ))}\n {nav.length > 0 && (\n <nav aria-label={text.nav} className=\"cy-site-header-nav cy-reset\">\n <ul className=\"cy-site-header-list cy-reset\">\n {nav.map((item) => (\n <li key={item.href} className=\"cy-site-header-item cy-reset\">\n {/* A Link, drawn as a pill by the span inside it. */}\n <Link\n href={item.href}\n tone=\"neutral\"\n underline=\"none\"\n aria-current={item.current ? \"page\" : undefined}\n className=\"cy-site-header-link-anchor\"\n >\n <span className=\"cy-site-header-link\">{item.label}</span>\n </Link>\n </li>\n ))}\n </ul>\n </nav>\n )}\n {actions && <div className=\"cy-site-header-actions cy-reset\">{actions}</div>}\n {nav.length > 0 && (\n <div className=\"cy-site-header-menu cy-reset\">\n <IconButton\n icon={menu}\n label={text.openMenu}\n variant=\"ghost\"\n tone=\"neutral\"\n tooltipPlacement=\"bottom\"\n aria-expanded={open}\n onClick={() => setOpen(true)}\n />\n </div>\n )}\n </Container>\n </header>\n {nav.length > 0 && (\n <Sheet open={open} onOpenChange={setOpen} side=\"end\" size=\"sm\" title={text.menu}>\n <SideNav\n label={text.nav}\n items={nav.map((item, i) => ({ id: String(i), label: item.label, href: item.href }))}\n current={current < 0 ? undefined : String(current)}\n // Choosing a link closes the menu; the browser then follows it.\n onNavigate={() => setOpen(false)}\n className=\"cy-site-header-sheet-nav\"\n />\n </Sheet>\n )}\n </>\n );\n});\n"],"mappings":";;;;;;;;;;AAqFA,IAAMa,IAAmC;AAAA,EACvC,KAAK;AAAA,EACL,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AACR,GAMaC,IAAaN,EAAyC,SACjE,EACE,OAAAO,GACA,WAAAC,IAAY,KACZ,KAAAC,IAAM,CAAC,GACP,SAAAC,GACA,QAAAC,IAAS,IACT,UAAAC,IAAW,IACX,QAAAC,IAAS,SACT,eAAAC,IAAgB,MAChB,MAAAC,IAAO,MACP,QAAAC,GACA,IAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GAEFC,GACA;AACA,QAAMC,IAAO;AAAA,IAAE,GAAGhB;AAAA,IAAgB,GAAGW;AAAA,EAAO,GACtC,CAACM,GAAMC,CAAA,IAAWtB,EAAS,EAAK,GAChCuB,IAAUf,EAAI,UAAA,CAAWgB,MAASA,EAAK,OAAO;AAEpD,SACE,gBAAArB,EAAAZ,GAAA,EAAA,UAAA;AAAA,IAEGoB,KAAY,gBAAAT,EAACP,GAAD;AAAA,MAAU,MAAMiB;AAAA,MAAQ,QAAQ,EAAE,MAAMQ,EAAK,KAAK;AAAA,IAAI,CAAA;AAAA,IACnE,gBAAAlB,EAAC,UAAD;AAAA,MACO,KAAAiB;AAAA,MACD,IAAAH;AAAA,M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AA;AAAA,UAC1ED,EAAI,SAAS,KACZ,gBAAAN,EAAC,OAAD;AAAA,YAAK,WAAU;AAAA,YACb,UAAA,gBAAAA,EAACT,GAAD;AAAA,cACE,MAAMD;AAAA,cACN,OAAO4B,EAAK;AAAA,cACZ,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,kBAAiB;AAAA,cACjB,iBAAeC;AAAA,cACf,SAAA,MAAeC,EAAQ,EAAI;AAAA,YAC5B,CAAA;AAAA,UACE,CAAA;AAAA,QAEE;AAAA,M;A,IACL,CAAA;AAAA,IACPd,EAAI,SAAS,KACZ,gBAAAN,EAACR,GAAD;AAAA,MAAa,MAAA2B;AAAA,MAAM,cAAcC;AAAA,MAAS,MAAK;AAAA,MAAM,MAAK;AAAA,MAAK,OAAOF,EAAK;AAAA,MACzE,UAAA,gBAAAlB,EAACJ,GAAD;AAAA,QACE,OAAOsB,EAAK;AAAA,QACZ,OAAOZ,EAAI,IAAA,CAAKgB,GAAMC,OAAO;AAAA,UAAE,IAAI,OAAOA,CAAC;AAAA,UAAG,OAAOD,EAAK;AAAA,UAAO,MAAMA,EAAK;AAAA,QAAK,EAAE;AAAA,QACnF,SAASD,IAAU,IAAI,SAAY,OAAOA,CAAO;AAAA,QAEjD,YAAA,MAAkBD,EAAQ,EAAK;AAAA,QAC/B,WAAU;AAAA,MACX,CAAA;AAAA,IACI,CAAA;AAAA,EAET,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SiteHeader, type SiteHeaderLabels, type SiteHeaderLink, type SiteHeaderProps, type SiteHeaderTokens, } from "./SiteHeader.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
export interface SkipLinkTokens {
|
|
3
|
+
/** Distance of the shown link from the top and inline-start edges of the window. */
|
|
4
|
+
offset: string;
|
|
5
|
+
/** Corner radius of the shown link. */
|
|
6
|
+
radius: string;
|
|
7
|
+
}
|
|
8
|
+
declare module "../../tokens/schema.js" {
|
|
9
|
+
interface ComponentTokens {
|
|
10
|
+
skipLink: SkipLinkTokens;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface SkipLinkLabels {
|
|
14
|
+
/** The link text. Default: "Skip to content". */
|
|
15
|
+
skip: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SkipLinkProps {
|
|
18
|
+
/**
|
|
19
|
+
* Where the link goes: `#` and the id of the page's main content. Default "#main". Without JavaScript it is a plain
|
|
20
|
+
* in-page link; with it, focus moves to the target too.
|
|
21
|
+
*/
|
|
22
|
+
href?: string;
|
|
23
|
+
/** Replace the built-in English text: `skip`, the link text. */
|
|
24
|
+
labels?: Partial<SkipLinkLabels>;
|
|
25
|
+
/** Set on the link element. */
|
|
26
|
+
id?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Show at the top-start corner of the nearest positioned ancestor instead of the window's, so the link stays inside
|
|
29
|
+
* a frame such as a side panel (AppShell sets it). Default false.
|
|
30
|
+
*/
|
|
31
|
+
contained?: boolean;
|
|
32
|
+
/** Added to the link, for layout (e.g. to place it inside a positioned frame). */
|
|
33
|
+
className?: string | undefined;
|
|
34
|
+
/** Layout only. Restyle through --cy-skip-link-* tokens. */
|
|
35
|
+
style?: CSSProperties;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* "Skip to content": the first stop of the Tab order, hidden until it has focus and then shown at the top-start corner
|
|
39
|
+
* of the window as a Button. It is a real link, so it works before or without JavaScript; with it, focus also moves to
|
|
40
|
+
* the target.
|
|
41
|
+
*/
|
|
42
|
+
export declare const SkipLink: import("react").ForwardRefExoticComponent<SkipLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button as u } from "../Button/Button.js";
|
|
3
|
+
import { forwardRef as d } from "react";
|
|
4
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
5
|
+
var k = { skip: "Skip to content" };
|
|
6
|
+
function p(i, e) {
|
|
7
|
+
if (!e.startsWith("#") || e.length < 2) return !1;
|
|
8
|
+
let n = e.slice(1);
|
|
9
|
+
try {
|
|
10
|
+
n = decodeURIComponent(n);
|
|
11
|
+
} catch {
|
|
12
|
+
}
|
|
13
|
+
const t = i.getRootNode().getElementById?.(n) ?? document.getElementById(n);
|
|
14
|
+
return t ? (t.tabIndex < 0 && !t.hasAttribute("tabindex") && t.setAttribute("tabindex", "-1"), t.focus(), !0) : !1;
|
|
15
|
+
}
|
|
16
|
+
var b = d(function({ href: e = "#main", labels: n, id: t, contained: a = !1, className: c, style: o }, l) {
|
|
17
|
+
const s = {
|
|
18
|
+
...k,
|
|
19
|
+
...n
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ f(u, {
|
|
22
|
+
href: e,
|
|
23
|
+
linkRef: l,
|
|
24
|
+
id: t,
|
|
25
|
+
variant: "outline",
|
|
26
|
+
tone: "accent",
|
|
27
|
+
onClick: (r) => {
|
|
28
|
+
p(r.currentTarget, e) && r.preventDefault();
|
|
29
|
+
},
|
|
30
|
+
className: [
|
|
31
|
+
"cy-skip-link cy-visually-hidden",
|
|
32
|
+
a ? "cy-skip-link-contained" : void 0,
|
|
33
|
+
c
|
|
34
|
+
].filter(Boolean).join(" "),
|
|
35
|
+
...o ? { style: o } : {},
|
|
36
|
+
children: s.skip
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
b as SkipLink
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=SkipLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkipLink.js","names":["Button","forwardRef","jsx","DEFAULT_LABELS","focusTarget","link","href","id","target","SkipLink","labels","contained","className","style","ref","text","event"],"sources":["../../../src/components/SkipLink/SkipLink.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type MouseEvent } from \"react\";\nimport { Button } from \"../Button/Button.js\";\n\nexport interface SkipLinkTokens {\n /** Distance of the shown link from the top and inline-start edges of the window. */\n offset: string;\n /** Corner radius of the shown link. */\n radius: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n skipLink: SkipLinkTokens;\n }\n}\n\nexport interface SkipLinkLabels {\n /** The link text. Default: \"Skip to content\". */\n skip: string;\n}\n\nexport interface SkipLinkProps {\n /**\n * Where the link goes: `#` and the id of the page's main content. Default \"#main\". Without JavaScript it is a plain\n * in-page link; with it, focus moves to the target too.\n */\n href?: string;\n /** Replace the built-in English text: `skip`, the link text. */\n labels?: Partial<SkipLinkLabels>;\n /** Set on the link element. */\n id?: string | undefined;\n /**\n * Show at the top-start corner of the nearest positioned ancestor instead of the window's, so the link stays inside\n * a frame such as a side panel (AppShell sets it). Default false.\n */\n contained?: boolean;\n /** Added to the link, for layout (e.g. to place it inside a positioned frame). */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-skip-link-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: SkipLinkLabels = { skip: \"Skip to content\" };\n\n/** Moves focus to an in-page target; returns false when there is none, so the browser follows the link. */\nfunction focusTarget(link: HTMLAnchorElement, href: string): boolean {\n if (!href.startsWith(\"#\") || href.length < 2) return false;\n let id = href.slice(1);\n try {\n id = decodeURIComponent(id);\n } catch {\n // Not percent-encoded: use it as written.\n }\n // Look in the link's own shadow root first, where a hash link cannot reach.\n const root = link.getRootNode() as Document | ShadowRoot;\n const target = root.getElementById?.(id) ?? document.getElementById(id);\n if (!target) return false;\n // Not focusable on its own (a `main` or a `div`): focusable from script only, so Tab order does not change.\n if (target.tabIndex < 0 && !target.hasAttribute(\"tabindex\")) target.setAttribute(\"tabindex\", \"-1\");\n target.focus();\n return true;\n}\n\n/**\n * \"Skip to content\": the first stop of the Tab order, hidden until it has focus and then shown at the top-start corner\n * of the window as a Button. It is a real link, so it works before or without JavaScript; with it, focus also moves to\n * the target.\n */\nexport const SkipLink = forwardRef<HTMLAnchorElement, SkipLinkProps>(function SkipLink(\n { href = \"#main\", labels, id, contained = false, className, style },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const onClick = (event: MouseEvent<HTMLElement>) => {\n // Focus moves without touching the URL (a client-side router may own it).\n if (focusTarget(event.currentTarget as HTMLAnchorElement, href)) event.preventDefault();\n };\n return (\n <Button\n href={href}\n linkRef={ref}\n id={id}\n variant=\"outline\"\n tone=\"accent\"\n onClick={onClick}\n // Hidden from sight (.cy-visually-hidden) until it has focus; skip-link.css shows it then, without script.\n className={[\n \"cy-skip-link cy-visually-hidden\",\n contained ? \"cy-skip-link-contained\" : undefined,\n className,\n ]\n .filter(Boolean)\n .join(\" \")}\n {...(style ? { style } : {})}\n >\n {text.skip}\n </Button>\n );\n});\n"],"mappings":";;;;AA0CA,IAAMG,IAAiC,EAAE,MAAM,kBAAkB;AAGjE,SAASC,EAAYC,GAAyBC,GAAuB;AACnE,MAAI,CAACA,EAAK,WAAW,GAAG,KAAKA,EAAK,SAAS,EAAG,QAAO;AACrD,MAAIC,IAAKD,EAAK,MAAM,CAAC;AACrB,MAAI;AACF,IAAAC,IAAK,mBAAmBA,CAAE;AAAA,EAC5B,QAAQ;AAAA,EAER;AAGA,QAAMC,IADOH,EAAK,YACH,EAAK,iBAAiBE,CAAE,KAAK,SAAS,eAAeA,CAAE;AACtE,SAAKC,KAEDA,EAAO,WAAW,KAAK,CAACA,EAAO,aAAa,UAAU,KAAGA,EAAO,aAAa,YAAY,IAAI,GACjGA,EAAO,MAAM,GACN,MAJa;AAKtB;AAOA,IAAaC,IAAWR,EAA6C,SACnE,EAAE,MAAAK,IAAO,SAAS,QAAAI,GAAQ,IAAAH,GAAI,WAAAI,IAAY,IAAO,WAAAC,GAAW,OAAAC,EAAA,GAC5DC,GACA;AACA,QAAMC,IAAO;AAAA,IAAE,GAAGZ;AAAA,IAAgB,GAAGO;AAAA,EAAO;AAK5C,SACE,gBAAAR,EAACF,GAAD;AAAA,IACQ,MAA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