@arshad-shah/cynosure 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/adapters/astro/index.d.ts +52 -0
- package/dist/adapters/astro/index.js +27 -0
- package/dist/adapters/astro/index.js.map +1 -0
- package/dist/adapters/vite/index.d.ts +11 -0
- package/dist/adapters/vite/index.js +33 -12
- package/dist/adapters/vite/index.js.map +1 -1
- package/dist/brands/googleplay.d.ts +2 -0
- package/dist/brands/googleplay.js +17 -0
- package/dist/brands/googleplay.js.map +1 -0
- package/dist/brands/index.d.ts +1 -0
- package/dist/brands/index.js +132 -130
- package/dist/components/Announcer/Announcer.js +5 -5
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.js +50 -53
- 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/Button/Button.d.ts +17 -3
- package/dist/components/Button/Button.js +51 -44
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.js +69 -69
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Card/Card.d.ts +8 -1
- package/dist/components/Card/Card.js.map +1 -1
- 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/ColorField/ColorField.js +198 -207
- package/dist/components/ColorField/ColorField.js.map +1 -1
- package/dist/components/Combobox/Combobox.js +86 -115
- package/dist/components/Combobox/Combobox.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/CopyButton/CopyButton.js +29 -28
- package/dist/components/CopyButton/CopyButton.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 -77
- package/dist/components/Dialog/Dialog.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/Field/Field.js +31 -33
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/FileDrop/FileDrop.js +14 -14
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.js +7 -6
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +32 -11
- package/dist/components/Grid/Grid.js +68 -46
- 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/IconButton/IconButton.d.ts +16 -1
- package/dist/components/IconButton/IconButton.js +14 -10
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/IconTile/IconTile.d.ts +45 -0
- package/dist/components/IconTile/IconTile.js +25 -0
- package/dist/components/IconTile/IconTile.js.map +1 -0
- package/dist/components/IconTile/index.d.ts +1 -0
- package/dist/components/Image/Image.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/KeyValueEditor/KeyValueEditor.js +37 -36
- package/dist/components/KeyValueEditor/KeyValueEditor.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/Notice/Notice.js +12 -11
- package/dist/components/Notice/Notice.js.map +1 -1
- package/dist/components/OptionList/OptionList.d.ts +69 -0
- package/dist/components/OptionList/OptionList.js +75 -0
- package/dist/components/OptionList/OptionList.js.map +1 -0
- package/dist/components/OptionList/index.d.ts +1 -0
- package/dist/components/PageHeader/PageHeader.d.ts +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/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/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.js +12 -12
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.js +106 -133
- package/dist/components/Select/Select.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.js +55 -53
- package/dist/components/SideNav/SideNav.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/SortableList/SortableList.js +13 -13
- package/dist/components/SortableList/SortableList.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +16 -7
- package/dist/components/Stack/Stack.js +25 -18
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -1
- package/dist/components/Stack/space.d.ts +29 -0
- package/dist/components/Stack/space.js +16 -5
- package/dist/components/Stack/space.js.map +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/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.js +11 -12
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -1
- package/dist/components/Tabs/Tabs.js +71 -70
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.js +76 -97
- package/dist/components/TagInput/TagInput.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +4 -0
- package/dist/components/TextField/TextField.js +30 -29
- 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/Toast/Toast.js +22 -20
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +6 -1
- package/dist/components/Tooltip/Tooltip.js +19 -19
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +17 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/components/VisuallyHidden/index.d.ts +1 -0
- package/dist/foundations/ChoiceBase/ChoiceBase.js +8 -8
- 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/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/printing.d.ts +6 -0
- package/dist/foundations/printing.js +17 -0
- package/dist/foundations/printing.js.map +1 -0
- package/dist/foundations/qr.d.ts +42 -0
- package/dist/foundations/qr.js +246 -0
- package/dist/foundations/qr.js.map +1 -0
- package/dist/icons/book-marked.d.ts +2 -0
- package/dist/icons/book-marked.js +14 -0
- package/dist/icons/book-marked.js.map +1 -0
- package/dist/icons/calendar-days.d.ts +2 -0
- package/dist/icons/calendar-days.js +24 -0
- package/dist/icons/calendar-days.js.map +1 -0
- package/dist/icons/check-square.d.ts +2 -0
- package/dist/icons/check-square.js +14 -0
- package/dist/icons/check-square.js.map +1 -0
- package/dist/icons/crescent.d.ts +2 -0
- package/dist/icons/crescent.js +14 -0
- package/dist/icons/crescent.js.map +1 -0
- package/dist/icons/index.d.ts +10 -0
- package/dist/icons/index.js +436 -416
- 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 +11 -1
- package/dist/icons/keywords.js +89 -1
- package/dist/icons/keywords.js.map +1 -1
- package/dist/icons/list-tree.d.ts +2 -0
- package/dist/icons/list-tree.js +14 -0
- package/dist/icons/list-tree.js.map +1 -0
- package/dist/icons/mosque.d.ts +2 -0
- package/dist/icons/mosque.js +14 -0
- package/dist/icons/mosque.js.map +1 -0
- package/dist/icons/prayer-beads.d.ts +2 -0
- package/dist/icons/prayer-beads.js +67 -0
- package/dist/icons/prayer-beads.js.map +1 -0
- package/dist/icons/qr-code.d.ts +2 -0
- package/dist/icons/qr-code.js +38 -0
- package/dist/icons/qr-code.js.map +1 -0
- package/dist/icons/refresh-cw.d.ts +2 -0
- package/dist/icons/refresh-cw.js +14 -0
- package/dist/icons/refresh-cw.js.map +1 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/icons/types.js +2 -1
- package/dist/icons/types.js.map +1 -1
- package/dist/index.d.ts +16 -2
- package/dist/index.js +274 -241
- 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/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/checkbox.css +1 -1
- package/dist/styles/choice-base.css +1 -0
- package/dist/styles/choice.css +1 -1
- package/dist/styles/color-field.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/copy-button.css +1 -1
- package/dist/styles/date-field.css +1 -1
- package/dist/styles/device-frame.css +1 -0
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/disclosure.css +1 -1
- package/dist/styles/field.css +1 -1
- package/dist/styles/file-drop.css +1 -1
- package/dist/styles/floating-toolbar.css +1 -1
- package/dist/styles/generated-css.d.ts +1 -1
- package/dist/styles/generated-css.js +1 -1
- package/dist/styles/generated-css.js.map +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heading.css +1 -1
- 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.css +1 -0
- package/dist/styles/manifest.json +715 -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/pagination.css +1 -1
- package/dist/styles/qr-code.css +1 -0
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/section.css +1 -0
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sheet.css +1 -1
- package/dist/styles/side-nav.css +1 -1
- package/dist/styles/site-footer.css +1 -0
- package/dist/styles/site-header.css +1 -0
- package/dist/styles/skip-link.css +1 -0
- package/dist/styles/sortable-list.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/stat.css +1 -0
- package/dist/styles/steps.css +1 -1
- package/dist/styles/switch.css +1 -0
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/tag-input.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/time-field.css +1 -1
- package/dist/styles/toast.css +1 -1
- package/dist/styles/visually-hidden.css +1 -0
- package/dist/styles.css +1 -1
- package/dist/tokens/create-theme.js +137 -108
- package/dist/tokens/create-theme.js.map +1 -1
- package/package.json +6 -1
- 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/styles/hidden-value.css +0 -1
- package/dist/styles/iconbutton.css +0 -1
- package/dist/styles/search-field.css +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ One small, themeable, accessible UI system, used by all my projects: browser ext
|
|
|
7
7
|
- **Tiny and tree-shaken**: one module per component and icon, and one small runtime dependency ([Detent](https://github.com/arshad-shah/detent), for dragging).
|
|
8
8
|
- **Looks identical anywhere**: pages, iframes, extension popups and shadow roots; host CSS can't break it.
|
|
9
9
|
- **Every property is a token**: `createTheme({ accent, scale, radius, font, tokens, components })`.
|
|
10
|
-
- **Icons**:
|
|
10
|
+
- **Icons**: 250 Facet stroke icons in 17 categories (softened-square geometry, built-in micro-animations), 98 official brand marks, and `iconToSvg` for pages without React.
|
|
11
11
|
- **One prop vocabulary**: `size`, `tone`, `variant`, `color` on every component, so control is consistent.
|
|
12
12
|
- **Tested in real browsers**: every story is a behavioural, accessibility and touch test on Chromium, Firefox and WebKit.
|
|
13
13
|
|
|
@@ -51,11 +51,11 @@ export const App = () => (
|
|
|
51
51
|
|
|
52
52
|
## Components
|
|
53
53
|
|
|
54
|
-
- **Foundations:** ButtonBase, LinkBase, InputBase, FileInputBase, TextAreaBase, ChoiceBase, HiddenValue, DialogBase, Icon (
|
|
54
|
+
- **Foundations:** ButtonBase, LinkBase, InputBase, FileInputBase, TextAreaBase, ChoiceBase, HiddenValue, DialogBase, Icon (250 Facet icons and 98 brand marks); hooks `useRovingFocus`, `useDismiss`, `useDrag` (pointer dragging through Detent), `useControllableState`.
|
|
55
55
|
- **Controls:** Button, IconButton, CopyButton, Link, TextField, NumberField, SearchField, TextArea, Select, Combobox, TagInput, Checkbox, Switch, RadioGroup, SegmentedControl, Slider, DateField, TimeField, Checklist, Pagination, ColorField, ColorSwatches, KeyValueEditor, FileDrop, SignaturePad, SelectionFrame, CompareSlider, ThemeToggle.
|
|
56
56
|
- **Structure:** AppShell (`useAppShell`), Container, PageHeader, Stack, Inline, Grid, Divider, AspectRatio, Breadcrumbs, SideNav, SplitPane, Card, Toolbar, Tabs, Disclosure, Accordion, Tree, SortableList, VirtualList, Calendar, DocumentViewport, PanZoomCanvas, ZoomControls.
|
|
57
57
|
- **Overlays:** Tooltip, HoverCard, Popover, FloatingToolbar (`DockedToolbar`), Menu, ContextMenu, Dialog, ProgressOverlay, Sheet, CommandPalette (`useHotkey`), Toast (`Toaster`, `useToast`).
|
|
58
|
-
- **Feedback and display:** Notice, EmptyState, ProgressBar, Steps, LoadingDots, Skeleton, DescriptionList, Table, Text, Heading, Prose, Avatar (`AvatarGroup`), Image, CodeBlock, Announcer (`useAnnounce`), Badge, Kbd, Field. **Theme:** CynosureTheme, useColorMode, themeInitScript, createTheme.
|
|
58
|
+
- **Feedback and display:** Notice, EmptyState, ProgressBar, Steps, LoadingDots, Skeleton, DescriptionList, Stat, List, Table, Text, Heading, Prose, Avatar (`AvatarGroup`), IconTile, Image, CodeBlock, Announcer (`useAnnounce`), Badge, Kbd, Field. **Theme:** CynosureTheme, useColorMode, themeInitScript, createTheme.
|
|
59
59
|
- **Build:** optional Vite adapter (`@arshad-shah/cynosure/vite`), React-free tokens (`@arshad-shah/cynosure/tokens`) and self-hosted Hanken Grotesk (`fonts/hanken.css`).
|
|
60
60
|
|
|
61
61
|
> Status: pre-release (`0.x`), developed on `next`. Releases publish to npm from `main` through GitHub Actions (see [Release](docs/release.md)).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional Astro adapter. Astro renders pages on the server, where React's CynosureTheme (`target="document"`) never
|
|
3
|
+
* runs, so `<html>` would get no theme until a script did. This themes the page in the HTML itself:
|
|
4
|
+
* - the product theme as CSS on `:root` (the Vite adapter's `virtual:cynosure/theme.css`), and Cynosure's stylesheet,
|
|
5
|
+
* added to every page;
|
|
6
|
+
* - `htmlAttributes()`, the colour mode and contrast attributes to spread on `<html>` in your layout;
|
|
7
|
+
* - the saved-mode script inline in `<head>`, so a visitor's own choice applies before the first paint.
|
|
8
|
+
*/
|
|
9
|
+
import { type ThemeInitScriptOptions } from "../../theme/theme-init-script.js";
|
|
10
|
+
import { type CynosureViteOptions, type CynosureVitePlugin } from "../vite/index.js";
|
|
11
|
+
export interface CynosureAstroOptions extends Omit<CynosureViteOptions, "styles"> {
|
|
12
|
+
/**
|
|
13
|
+
* `true` (default): add all of `styles.css` to every page. `"imports"`: only the stylesheets the components each
|
|
14
|
+
* page and island imports need (the Vite adapter's `styles: "imports"`). `false`: you import styles yourself.
|
|
15
|
+
*/
|
|
16
|
+
styles?: boolean | "imports";
|
|
17
|
+
/**
|
|
18
|
+
* Apply the visitor's saved colour mode before the first paint (`themeInitScript`, inline in `<head>`): `false` to
|
|
19
|
+
* leave it out (pages with a content security policy that forbids inline scripts), or its options (`key` must match
|
|
20
|
+
* ThemeToggle's `storageKey`). Default true.
|
|
21
|
+
*/
|
|
22
|
+
initScript?: boolean | ThemeInitScriptOptions;
|
|
23
|
+
}
|
|
24
|
+
/** The parts of Astro's `astro:config:setup` hook this adapter uses (no dependency on Astro's types). */
|
|
25
|
+
export interface CynosureAstroSetup {
|
|
26
|
+
updateConfig(config: {
|
|
27
|
+
vite: {
|
|
28
|
+
plugins: CynosureVitePlugin[];
|
|
29
|
+
};
|
|
30
|
+
}): unknown;
|
|
31
|
+
injectScript(stage: "head-inline" | "page-ssr", content: string): void;
|
|
32
|
+
}
|
|
33
|
+
/** The subset of the Astro integration contract this adapter uses. */
|
|
34
|
+
export interface CynosureAstroIntegration {
|
|
35
|
+
name: "@arshad-shah/cynosure";
|
|
36
|
+
hooks: {
|
|
37
|
+
"astro:config:setup": (setup: CynosureAstroSetup) => void;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The Astro integration: `integrations: [cynosure({ theme })]` in `astro.config.mjs`. */
|
|
41
|
+
export declare function cynosure(options?: CynosureAstroOptions): CynosureAstroIntegration;
|
|
42
|
+
export interface HtmlAttributesOptions {
|
|
43
|
+
/** The colour mode the page starts in, before any saved choice is read. Default "system" (follows the device). */
|
|
44
|
+
mode?: "light" | "dark" | "system";
|
|
45
|
+
/** `more` uses the higher-contrast palettes; `system` (the default) follows the device setting. */
|
|
46
|
+
contrast?: "normal" | "more" | "system";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Attributes for `<html>`, rendered on the server: `<html lang="en" {...htmlAttributes({ mode: "system" })}>`. They
|
|
50
|
+
* switch Cynosure's colour mode and contrast for the whole page with no script.
|
|
51
|
+
*/
|
|
52
|
+
export declare function htmlAttributes({ mode, contrast, }?: HtmlAttributesOptions): Record<string, string>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { themeInitScript as u } from "../../theme/theme-init-script.js";
|
|
2
|
+
import { cynosure as a } from "../vite/index.js";
|
|
3
|
+
function p(s = {}) {
|
|
4
|
+
const { styles: t = !0, initScript: r = !0, ...e } = s, n = a(t === "imports" ? {
|
|
5
|
+
...e,
|
|
6
|
+
styles: "imports"
|
|
7
|
+
} : e);
|
|
8
|
+
return {
|
|
9
|
+
name: "@arshad-shah/cynosure",
|
|
10
|
+
hooks: { "astro:config:setup": ({ updateConfig: i, injectScript: o }) => {
|
|
11
|
+
i({ vite: { plugins: [n] } }), o("page-ssr", [...t === !0 ? ['import "@arshad-shah/cynosure/styles.css";'] : [], 'import "virtual:cynosure/theme.css";'].join(`
|
|
12
|
+
`)), r && o("head-inline", u(r === !0 ? {} : r));
|
|
13
|
+
} }
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function y({ mode: s = "system", contrast: t } = {}) {
|
|
17
|
+
return {
|
|
18
|
+
"data-cy-mode": s,
|
|
19
|
+
...t ? { "data-cy-contrast": t } : {}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
p as cynosure,
|
|
24
|
+
y as htmlAttributes
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["vitePlugin","themeInitScript","cynosure$1","cynosure","options","styles","initScript","vite","plugin","updateConfig","injectScript","htmlAttributes","mode","contrast"],"sources":["../../../src/adapters/astro/index.ts"],"sourcesContent":["/**\n * Optional Astro adapter. Astro renders pages on the server, where React's CynosureTheme (`target=\"document\"`) never\n * runs, so `<html>` would get no theme until a script did. This themes the page in the HTML itself:\n * - the product theme as CSS on `:root` (the Vite adapter's `virtual:cynosure/theme.css`), and Cynosure's stylesheet,\n * added to every page;\n * - `htmlAttributes()`, the colour mode and contrast attributes to spread on `<html>` in your layout;\n * - the saved-mode script inline in `<head>`, so a visitor's own choice applies before the first paint.\n */\nimport { type ThemeInitScriptOptions, themeInitScript } from \"../../theme/theme-init-script.js\";\nimport { type CynosureViteOptions, type CynosureVitePlugin, cynosure as vitePlugin } from \"../vite/index.js\";\n\nexport interface CynosureAstroOptions extends Omit<CynosureViteOptions, \"styles\"> {\n /**\n * `true` (default): add all of `styles.css` to every page. `\"imports\"`: only the stylesheets the components each\n * page and island imports need (the Vite adapter's `styles: \"imports\"`). `false`: you import styles yourself.\n */\n styles?: boolean | \"imports\";\n /**\n * Apply the visitor's saved colour mode before the first paint (`themeInitScript`, inline in `<head>`): `false` to\n * leave it out (pages with a content security policy that forbids inline scripts), or its options (`key` must match\n * ThemeToggle's `storageKey`). Default true.\n */\n initScript?: boolean | ThemeInitScriptOptions;\n}\n\n/** The parts of Astro's `astro:config:setup` hook this adapter uses (no dependency on Astro's types). */\nexport interface CynosureAstroSetup {\n updateConfig(config: { vite: { plugins: CynosureVitePlugin[] } }): unknown;\n injectScript(stage: \"head-inline\" | \"page-ssr\", content: string): void;\n}\n\n/** The subset of the Astro integration contract this adapter uses. */\nexport interface CynosureAstroIntegration {\n name: \"@arshad-shah/cynosure\";\n hooks: { \"astro:config:setup\": (setup: CynosureAstroSetup) => void };\n}\n\n/** The Astro integration: `integrations: [cynosure({ theme })]` in `astro.config.mjs`. */\nexport function cynosure(options: CynosureAstroOptions = {}): CynosureAstroIntegration {\n const { styles = true, initScript = true, ...vite } = options;\n // Built eagerly (by the Vite adapter), so an invalid theme fails the build at once.\n const plugin = vitePlugin(styles === \"imports\" ? { ...vite, styles: \"imports\" } : vite);\n return {\n name: \"@arshad-shah/cynosure\",\n hooks: {\n \"astro:config:setup\": ({ updateConfig, injectScript }) => {\n updateConfig({ vite: { plugins: [plugin] } });\n const imports = [\n ...(styles === true ? ['import \"@arshad-shah/cynosure/styles.css\";'] : []),\n 'import \"virtual:cynosure/theme.css\";',\n ];\n injectScript(\"page-ssr\", imports.join(\"\\n\"));\n if (initScript) injectScript(\"head-inline\", themeInitScript(initScript === true ? {} : initScript));\n },\n },\n };\n}\n\nexport interface HtmlAttributesOptions {\n /** The colour mode the page starts in, before any saved choice is read. Default \"system\" (follows the device). */\n mode?: \"light\" | \"dark\" | \"system\";\n /** `more` uses the higher-contrast palettes; `system` (the default) follows the device setting. */\n contrast?: \"normal\" | \"more\" | \"system\";\n}\n\n/**\n * Attributes for `<html>`, rendered on the server: `<html lang=\"en\" {...htmlAttributes({ mode: \"system\" })}>`. They\n * switch Cynosure's colour mode and contrast for the whole page with no script.\n */\nexport function htmlAttributes({\n mode = \"system\",\n contrast,\n}: HtmlAttributesOptions = {}): Record<string, string> {\n return { \"data-cy-mode\": mode, ...(contrast ? { \"data-cy-contrast\": contrast } : {}) };\n}\n"],"mappings":";;AAsCA,SAAgBG,EAASC,IAAgC,CAAC,GAA6B;AACrF,QAAM,EAAE,QAAAC,IAAS,IAAM,YAAAC,IAAa,IAAM,GAAGC,EAAA,IAASH,GAEhDI,IAASR,EAAWK,MAAW,YAAY;AAAA,IAAE,GAAGE;AAAA,IAAM,QAAQ;AAAA,EAAU,IAAIA,CAAI;AACtF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO,EACL,sBAAA,CAAuB,EAAE,cAAAE,GAAc,cAAAC,EAAA,MAAmB;AACxD,MAAAD,EAAa,EAAE,MAAM,EAAE,SAAS,CAACD,CAAM,EAAE,EAAE,CAAC,GAK5CE,EAAa,YAAY,CAHvB,GAAIL,MAAW,KAAO,CAAC,4CAA4C,IAAI,CAAC,GACxE,sCAEuB,EAAQ,KAAK;AAAA,CAAI,CAAC,GACvCC,KAAYI,EAAa,eAAeT,EAAgBK,MAAe,KAAO,CAAC,IAAIA,CAAU,CAAC;AAAA,IACpG,EACF;AAAA,EACF;AACF;AAaA,SAAgBK,EAAe,EAC7B,MAAAC,IAAO,UACP,UAAAC,EAAA,IACyB,CAAC,GAA2B;AACrD,SAAO;AAAA,IAAE,gBAAgBD;AAAA,IAAM,GAAIC,IAAW,EAAE,oBAAoBA,EAAS,IAAI,CAAC;AAAA,EAAG;AACvF"}
|
|
@@ -5,6 +5,14 @@ export interface CynosureViteOptions {
|
|
|
5
5
|
selector?: string;
|
|
6
6
|
/** Path to Cynosure's compiled stylesheet (defaults to the installed package's styles.css). */
|
|
7
7
|
stylesheet?: string;
|
|
8
|
+
/**
|
|
9
|
+
* `"imports"`: add only the stylesheets the components you import need, worked out from each module's
|
|
10
|
+
* `import { … } from "@arshad-shah/cynosure"` and the package's `styles/manifest.json`, plus the default tokens when
|
|
11
|
+
* no `theme` is given (with a theme, import `virtual:cynosure/theme.css`). Leave it out to import `styles.css` yourself.
|
|
12
|
+
*/
|
|
13
|
+
styles?: "imports" | undefined;
|
|
14
|
+
/** Path to `styles/manifest.json` (defaults to the installed package's). */
|
|
15
|
+
manifest?: string;
|
|
8
16
|
}
|
|
9
17
|
/** The subset of the Vite plugin contract this adapter uses (no dependency on Vite's types). */
|
|
10
18
|
export interface CynosureVitePlugin {
|
|
@@ -12,5 +20,8 @@ export interface CynosureVitePlugin {
|
|
|
12
20
|
enforce: "pre";
|
|
13
21
|
resolveId(id: string): string | undefined;
|
|
14
22
|
load(id: string): string | undefined;
|
|
23
|
+
transform(code: string, id: string): string | undefined;
|
|
15
24
|
}
|
|
25
|
+
/** The stylesheet imports a module needs for the Cynosure components it imports (none if it imports none). */
|
|
26
|
+
export declare function stylesForImports(code: string, manifest: Record<string, string[]>, tokens: boolean): string[];
|
|
16
27
|
export declare function cynosure(options?: CynosureViteOptions): CynosureVitePlugin;
|
|
@@ -1,25 +1,46 @@
|
|
|
1
|
-
import { createTheme as
|
|
2
|
-
import { themeToCss as
|
|
3
|
-
import { readFileSync as
|
|
4
|
-
import { fileURLToPath as
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
const
|
|
1
|
+
import { createTheme as h } from "../../tokens/create-theme.js";
|
|
2
|
+
import { themeToCss as y } from "../../tokens/to-css.js";
|
|
3
|
+
import { readFileSync as i } from "node:fs";
|
|
4
|
+
import { fileURLToPath as f } from "node:url";
|
|
5
|
+
var p = /import\s*\{([^}]*)\}\s*from\s*["']@arshad-shah\/cynosure["']/g;
|
|
6
|
+
function d(t, o, a) {
|
|
7
|
+
const r = /* @__PURE__ */ new Set();
|
|
8
|
+
for (const n of t.matchAll(p)) for (const e of (n[1] ?? "").split(",")) {
|
|
9
|
+
const s = e.trim().split(/\s+as\s+/)[0];
|
|
10
|
+
if (!(!s || s.startsWith("type ")))
|
|
11
|
+
for (const m of o[s] ?? []) r.add(m);
|
|
12
|
+
}
|
|
13
|
+
return r.size === 0 ? [] : [...a ? ["tokens.css"] : [], ...r].map((n) => `@arshad-shah/cynosure/styles/${n}`);
|
|
14
|
+
}
|
|
15
|
+
var c = "virtual:cynosure/theme.css", l = "virtual:cynosure/inline";
|
|
16
|
+
function S(t = {}) {
|
|
17
|
+
const o = y(h(t.theme), t.selector), a = () => i(t.stylesheet ?? f(new URL("../../styles.css", "" + import.meta.url)), "utf8");
|
|
18
|
+
let r;
|
|
19
|
+
const n = () => r ??= JSON.parse(i(t.manifest ?? f(new URL("../../styles/manifest.json", "" + import.meta.url)), "utf8"));
|
|
8
20
|
return {
|
|
9
21
|
name: "cynosure",
|
|
10
22
|
enforce: "pre",
|
|
11
23
|
resolveId(e) {
|
|
12
|
-
return e ===
|
|
24
|
+
return e === c || e === l ? `\0${e}` : void 0;
|
|
25
|
+
},
|
|
26
|
+
transform(e, s) {
|
|
27
|
+
if (t.styles !== "imports" || s.startsWith("\0") || s.includes("/node_modules/")) return;
|
|
28
|
+
const m = d(e, n(), !t.theme);
|
|
29
|
+
return m.length ? `${e}
|
|
30
|
+
${m.map((u) => `import ${JSON.stringify(u)};`).join(`
|
|
31
|
+
`)}
|
|
32
|
+
` : void 0;
|
|
13
33
|
},
|
|
14
34
|
load(e) {
|
|
15
|
-
if (e === `\0${
|
|
16
|
-
if (e === `\0${
|
|
17
|
-
${
|
|
35
|
+
if (e === `\0${c}`) return o;
|
|
36
|
+
if (e === `\0${l}`) return `export default ${JSON.stringify(`${a()}
|
|
37
|
+
${o}`)};`;
|
|
18
38
|
}
|
|
19
39
|
};
|
|
20
40
|
}
|
|
21
41
|
export {
|
|
22
|
-
|
|
42
|
+
S as cynosure,
|
|
43
|
+
d as stylesForImports
|
|
23
44
|
};
|
|
24
45
|
|
|
25
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createTheme","themeToCss","readFileSync","fileURLToPath","THEME","INLINE","cynosure","options","themeCss","stylesheet","id"],"sources":["../../../src/adapters/vite/index.ts"],"sourcesContent":["/**\n * Optional Vite adapter. The package works without it; this adds build-time conveniences:\n * - `virtual:cynosure/theme.css`: the product theme as CSS (import it once next to styles.css)\n * - `virtual:cynosure/inline`: all Cynosure CSS plus the theme as a string (shadow roots, extension getStyle())\n */\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { createTheme, type ThemeInput, themeToCss } from \"../../tokens/index.js\";\n\nexport interface CynosureViteOptions {\n theme?: ThemeInput;\n /** Selector the theme is declared on (default: :root and :host). */\n selector?: string;\n /** Path to Cynosure's compiled stylesheet (defaults to the installed package's styles.css). */\n stylesheet?: string;\n}\n\n/** The subset of the Vite plugin contract this adapter uses (no dependency on Vite's types). */\nexport interface CynosureVitePlugin {\n name: \"cynosure\";\n enforce: \"pre\";\n resolveId(id: string): string | undefined;\n load(id: string): string | undefined;\n}\n\nconst THEME = \"virtual:cynosure/theme.css\";\nconst INLINE = \"virtual:cynosure/inline\";\n\nexport function cynosure(options: CynosureViteOptions = {}): CynosureVitePlugin {\n // Built eagerly so an invalid theme fails the build immediately.\n const themeCss = themeToCss(createTheme(options.theme), options.selector);\n const stylesheet = () =>\n readFileSync(options.stylesheet ?? fileURLToPath(new URL(\"../../styles.css\", import.meta.url)), \"utf8\");\n return {\n name: \"cynosure\",\n enforce: \"pre\",\n resolveId(id) {\n return id === THEME || id === INLINE ? `\\0${id}` : undefined;\n },\n load(id) {\n if (id === `\\0${THEME}`) return themeCss;\n if (id === `\\0${INLINE}`) return `export default ${JSON.stringify(`${stylesheet()}\\n${themeCss}`)};`;\n return undefined;\n },\n };\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["createTheme","themeToCss","readFileSync","fileURLToPath","IMPORT","stylesForImports","code","manifest","tokens","files","m","raw","name","css","THEME","INLINE","cynosure","options","themeCss","stylesheet","read","id","imports","i"],"sources":["../../../src/adapters/vite/index.ts"],"sourcesContent":["/**\n * Optional Vite adapter. The package works without it; this adds build-time conveniences:\n * - `virtual:cynosure/theme.css`: the product theme as CSS (import it once next to styles.css)\n * - `virtual:cynosure/inline`: all Cynosure CSS plus the theme as a string (shadow roots, extension getStyle())\n * - `styles: \"imports\"`: each module that imports components from the package also imports the stylesheets those\n * components need (from `styles/manifest.json`), instead of all of `styles.css`\n */\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { createTheme, type ThemeInput, themeToCss } from \"../../tokens/index.js\";\n\nexport interface CynosureViteOptions {\n theme?: ThemeInput;\n /** Selector the theme is declared on (default: :root and :host). */\n selector?: string;\n /** Path to Cynosure's compiled stylesheet (defaults to the installed package's styles.css). */\n stylesheet?: string;\n /**\n * `\"imports\"`: add only the stylesheets the components you import need, worked out from each module's\n * `import { … } from \"@arshad-shah/cynosure\"` and the package's `styles/manifest.json`, plus the default tokens when\n * no `theme` is given (with a theme, import `virtual:cynosure/theme.css`). Leave it out to import `styles.css` yourself.\n */\n styles?: \"imports\" | undefined;\n /** Path to `styles/manifest.json` (defaults to the installed package's). */\n manifest?: string;\n}\n\n/** The subset of the Vite plugin contract this adapter uses (no dependency on Vite's types). */\nexport interface CynosureVitePlugin {\n name: \"cynosure\";\n enforce: \"pre\";\n resolveId(id: string): string | undefined;\n load(id: string): string | undefined;\n transform(code: string, id: string): string | undefined;\n}\n\nconst IMPORT = /import\\s*\\{([^}]*)\\}\\s*from\\s*[\"']@arshad-shah\\/cynosure[\"']/g;\n\n/** The stylesheet imports a module needs for the Cynosure components it imports (none if it imports none). */\nexport function stylesForImports(\n code: string,\n manifest: Record<string, string[]>,\n tokens: boolean,\n): string[] {\n const files = new Set<string>();\n for (const m of code.matchAll(IMPORT))\n for (const raw of (m[1] ?? \"\").split(\",\")) {\n const name = raw.trim().split(/\\s+as\\s+/)[0] as string;\n if (!name || name.startsWith(\"type \")) continue;\n for (const css of manifest[name] ?? []) files.add(css);\n }\n if (files.size === 0) return [];\n const list = [...(tokens ? [\"tokens.css\"] : []), ...files];\n return list.map((css) => `@arshad-shah/cynosure/styles/${css}`);\n}\n\nconst THEME = \"virtual:cynosure/theme.css\";\nconst INLINE = \"virtual:cynosure/inline\";\n\nexport function cynosure(options: CynosureViteOptions = {}): CynosureVitePlugin {\n // Built eagerly so an invalid theme fails the build immediately.\n const themeCss = themeToCss(createTheme(options.theme), options.selector);\n const stylesheet = () =>\n readFileSync(options.stylesheet ?? fileURLToPath(new URL(\"../../styles.css\", import.meta.url)), \"utf8\");\n let read: Record<string, string[]> | undefined;\n const manifest = () =>\n (read ??= JSON.parse(\n readFileSync(\n options.manifest ?? fileURLToPath(new URL(\"../../styles/manifest.json\", import.meta.url)),\n \"utf8\",\n ),\n ) as Record<string, string[]>);\n return {\n name: \"cynosure\",\n enforce: \"pre\",\n resolveId(id) {\n return id === THEME || id === INLINE ? `\\0${id}` : undefined;\n },\n transform(code, id) {\n if (options.styles !== \"imports\" || id.startsWith(\"\\0\") || id.includes(\"/node_modules/\"))\n return undefined;\n const imports = stylesForImports(code, manifest(), !options.theme);\n // Appended: imports are hoisted, and Vite loads each stylesheet once however many modules ask for it.\n return imports.length\n ? `${code}\\n${imports.map((i) => `import ${JSON.stringify(i)};`).join(\"\\n\")}\\n`\n : undefined;\n },\n load(id) {\n if (id === `\\0${THEME}`) return themeCss;\n if (id === `\\0${INLINE}`) return `export default ${JSON.stringify(`${stylesheet()}\\n${themeCss}`)};`;\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAoCA,IAAMI,IAAS;AAGf,SAAgBC,EACdC,GACAC,GACAC,GACU;AACV,QAAMC,IAAQ,oBAAI,IAAY;AAC9B,aAAWC,KAAKJ,EAAK,SAASF,CAAM,EAClC,YAAWO,MAAQD,EAAE,CAAA,KAAM,IAAI,MAAM,GAAG,GAAG;AACzC,UAAME,IAAOD,EAAI,KAAK,EAAE,MAAM,UAAU,EAAE,CAAA;AAC1C,QAAI,GAACC,KAAQA,EAAK,WAAW,OAAO;AACpC,iBAAWC,KAAON,EAASK,CAAA,KAAS,CAAC,EAAG,CAAAH,EAAM,IAAII,CAAG;AAAA,EACvD;AACF,SAAIJ,EAAM,SAAS,IAAU,CAAC,IAEvB,CADO,GAAID,IAAS,CAAC,YAAY,IAAI,CAAC,GAAI,GAAGC,CAC7C,EAAK,IAAA,CAAKI,MAAQ,gCAAgCA,CAAA,EAAK;AAChE;AAEA,IAAMC,IAAQ,8BACRC,IAAS;AAEf,SAAgBC,EAASC,IAA+B,CAAC,GAAuB;AAE9E,QAAMC,IAAWjB,EAAWD,EAAYiB,EAAQ,KAAK,GAAGA,EAAQ,QAAQ,GAClEE,IAAA,MACJjB,EAAae,EAAQ,cAAcd,EAAc,IAAA,IAAA,oBAAA,KAAA,YAAA,GAAA,CAA4C,GAAG,MAAM;AACxG,MAAIiB;AACJ,QAAMb,IAAA,MACHa,MAAS,KAAK,MACblB,EACEe,EAAQ,YAAYd,EAAc,IAAA,IAAA,8BAAA,KAAA,YAAA,GAAA,CAAsD,GACxF,MACF,CACF;AACF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAUkB,GAAI;AACZ,aAAOA,MAAOP,KAASO,MAAON,IAAS,KAAKM,CAAA,KAAO;AAAA,IACrD;AAAA,IACA,UAAUf,GAAMe,GAAI;AAClB,UAAIJ,EAAQ,WAAW,aAAaI,EAAG,WAAW,IAAI,KAAKA,EAAG,SAAS,gBAAgB,EACrF;AACF,YAAMC,IAAUjB,EAAiBC,GAAMC,EAAS,GAAG,CAACU,EAAQ,KAAK;AAEjE,aAAOK,EAAQ,SACX,GAAGhB,CAAA;AAAA,EAASgB,EAAQ,IAAA,CAAKC,MAAM,UAAU,KAAK,UAAUA,CAAC,CAAA,GAAI,EAAE,KAAK;AAAA,CAAI,CAAA;AAAA,IACxE;AAAA,IACN;AAAA,IACA,KAAKF,GAAI;AACP,UAAIA,MAAO,KAAKP,CAAA,GAAS,QAAOI;AAChC,UAAIG,MAAO,KAAKN,CAAA,GAAU,QAAO,kBAAkB,KAAK,UAAU,GAAGI,EAAW,CAAA;AAAA,EAAMD,CAAA,EAAU,CAAA;AAAA,IAElG;AAAA,EACF;AACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var l = {
|
|
2
|
+
name: "googleplay",
|
|
3
|
+
category: "brands",
|
|
4
|
+
fill: !0,
|
|
5
|
+
brand: {
|
|
6
|
+
title: "Google Play",
|
|
7
|
+
hex: "414141",
|
|
8
|
+
guidelines: "https://partnermarketinghub.withgoogle.com/brands/google-play/visual-identity/primary-logos/",
|
|
9
|
+
source: "https://partnermarketinghub.withgoogle.com/brands/google-play/visual-identity/primary-logos/"
|
|
10
|
+
},
|
|
11
|
+
body: [["path", { d: "M22.018 13.298l-3.919 2.218-3.515-3.493 3.543-3.521 3.891 2.202a1.49 1.49 0 0 1 0 2.594zM1.337.924a1.486 1.486 0 0 0-.112.568v21.017c0 .217.045.419.124.6l11.155-11.087L1.337.924zm12.207 10.065l3.258-3.238L3.45.195a1.466 1.466 0 0 0-.946-.179l11.04 10.973zm0 2.067l-11 10.933c.298.036.612-.016.906-.183l13.324-7.54-3.23-3.21z" }]]
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
l as googleplay
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=googleplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"googleplay.js","names":["googleplay"],"sources":["../../src/brands/googleplay.ts"],"sourcesContent":["// Generated by tools/brands.ts from Simple Icons 16.37.0. Do not edit: the mark is the brand's own.\nimport type { IconData } from \"../icons/types.js\";\n\nexport const googleplay: IconData = {\n name: \"googleplay\",\n category: \"brands\",\n fill: true,\n brand: {\n title: \"Google Play\",\n hex: \"414141\",\n guidelines:\n \"https://partnermarketinghub.withgoogle.com/brands/google-play/visual-identity/primary-logos/\",\n source: \"https://partnermarketinghub.withgoogle.com/brands/google-play/visual-identity/primary-logos/\",\n },\n body: [\n [\n \"path\",\n {\n d: \"M22.018 13.298l-3.919 2.218-3.515-3.493 3.543-3.521 3.891 2.202a1.49 1.49 0 0 1 0 2.594zM1.337.924a1.486 1.486 0 0 0-.112.568v21.017c0 .217.045.419.124.6l11.155-11.087L1.337.924zm12.207 10.065l3.258-3.238L3.45.195a1.466 1.466 0 0 0-.946-.179l11.04 10.973zm0 2.067l-11 10.933c.298.036.612-.016.906-.183l13.324-7.54-3.23-3.21z\",\n },\n ],\n ],\n};\n"],"mappings":"AAGA,IAAaA,IAAuB;AAAA,EAClC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,IACL,OAAO;AAAA,IACP,KAAK;AAAA,IACL,YACE;AAAA,IACF,QAAQ;AAAA,EACV;AAAA,EACA,MAAM,CACJ,CACE,QACA,EACE,GAAG,uUACL,CACF,CACF;AACF"}
|
package/dist/brands/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { google } from "./google.js";
|
|
|
34
34
|
export { googlechrome } from "./googlechrome.js";
|
|
35
35
|
export { googlecloud } from "./googlecloud.js";
|
|
36
36
|
export { googledrive } from "./googledrive.js";
|
|
37
|
+
export { googleplay } from "./googleplay.js";
|
|
37
38
|
export { gravatar } from "./gravatar.js";
|
|
38
39
|
export { html5 } from "./html5.js";
|
|
39
40
|
export { instagram } from "./instagram.js";
|
package/dist/brands/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { apple as e } from "./apple.js";
|
|
|
5
5
|
import { applemusic as s } from "./applemusic.js";
|
|
6
6
|
import { astro as d } from "./astro.js";
|
|
7
7
|
import { biome as c } from "./biome.js";
|
|
8
|
-
import { bitbucket as
|
|
9
|
-
import { bluesky as
|
|
8
|
+
import { bitbucket as g } from "./bitbucket.js";
|
|
9
|
+
import { bluesky as y } from "./bluesky.js";
|
|
10
10
|
import { bun as h } from "./bun.js";
|
|
11
11
|
import { buymeacoffee as w } from "./buymeacoffee.js";
|
|
12
12
|
import { chromewebstore as j } from "./chromewebstore.js";
|
|
@@ -32,69 +32,70 @@ import { gitlab as eo } from "./gitlab.js";
|
|
|
32
32
|
import { gmail as so } from "./gmail.js";
|
|
33
33
|
import { google as no } from "./google.js";
|
|
34
34
|
import { googlechrome as uo } from "./googlechrome.js";
|
|
35
|
-
import { googlecloud as
|
|
36
|
-
import { googledrive as
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
90
|
-
import {
|
|
91
|
-
import {
|
|
92
|
-
import {
|
|
93
|
-
import {
|
|
94
|
-
import {
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
35
|
+
import { googlecloud as bo } from "./googlecloud.js";
|
|
36
|
+
import { googledrive as ko } from "./googledrive.js";
|
|
37
|
+
import { googleplay as vo } from "./googleplay.js";
|
|
38
|
+
import { gravatar as xo } from "./gravatar.js";
|
|
39
|
+
import { html5 as qo } from "./html5.js";
|
|
40
|
+
import { instagram as Ao } from "./instagram.js";
|
|
41
|
+
import { javascript as Co } from "./javascript.js";
|
|
42
|
+
import { jira as Eo } from "./jira.js";
|
|
43
|
+
import { kofi as Go } from "./kofi.js";
|
|
44
|
+
import { kubernetes as Io } from "./kubernetes.js";
|
|
45
|
+
import { linear as Ko } from "./linear.js";
|
|
46
|
+
import { linux as Mo } from "./linux.js";
|
|
47
|
+
import { mastodon as Oo } from "./mastodon.js";
|
|
48
|
+
import { medium as Qo } from "./medium.js";
|
|
49
|
+
import { mongodb as So } from "./mongodb.js";
|
|
50
|
+
import { mozilla as Uo } from "./mozilla.js";
|
|
51
|
+
import { mysql as Wo } from "./mysql.js";
|
|
52
|
+
import { netlify as Yo } from "./netlify.js";
|
|
53
|
+
import { nextdotjs as _o } from "./nextdotjs.js";
|
|
54
|
+
import { nodedotjs as or } from "./nodedotjs.js";
|
|
55
|
+
import { notion as mr } from "./notion.js";
|
|
56
|
+
import { npm as ir } from "./npm.js";
|
|
57
|
+
import { opensourceinitiative as fr } from "./opensourceinitiative.js";
|
|
58
|
+
import { patreon as ar } from "./patreon.js";
|
|
59
|
+
import { paypal as lr } from "./paypal.js";
|
|
60
|
+
import { pnpm as nr } from "./pnpm.js";
|
|
61
|
+
import { postgresql as ur } from "./postgresql.js";
|
|
62
|
+
import { preact as br } from "./preact.js";
|
|
63
|
+
import { producthunt as kr } from "./producthunt.js";
|
|
64
|
+
import { react as vr } from "./react.js";
|
|
65
|
+
import { reddit as xr } from "./reddit.js";
|
|
66
|
+
import { redis as qr } from "./redis.js";
|
|
67
|
+
import { rss as Ar } from "./rss.js";
|
|
68
|
+
import { safari as Cr } from "./safari.js";
|
|
69
|
+
import { shopify as Er } from "./shopify.js";
|
|
70
|
+
import { signal as Gr } from "./signal.js";
|
|
71
|
+
import { soundcloud as Ir } from "./soundcloud.js";
|
|
72
|
+
import { spotify as Kr } from "./spotify.js";
|
|
73
|
+
import { sqlite as Mr } from "./sqlite.js";
|
|
74
|
+
import { stackoverflow as Or } from "./stackoverflow.js";
|
|
75
|
+
import { storybook as Qr } from "./storybook.js";
|
|
76
|
+
import { stripe as Sr } from "./stripe.js";
|
|
77
|
+
import { supabase as Ur } from "./supabase.js";
|
|
78
|
+
import { svelte as Wr } from "./svelte.js";
|
|
79
|
+
import { tailwindcss as Yr } from "./tailwindcss.js";
|
|
80
|
+
import { telegram as _r } from "./telegram.js";
|
|
81
|
+
import { threads as om } from "./threads.js";
|
|
82
|
+
import { tiktok as mm } from "./tiktok.js";
|
|
83
|
+
import { trello as im } from "./trello.js";
|
|
84
|
+
import { twitch as fm } from "./twitch.js";
|
|
85
|
+
import { typescript as am } from "./typescript.js";
|
|
86
|
+
import { ubuntu as lm } from "./ubuntu.js";
|
|
87
|
+
import { vercel as nm } from "./vercel.js";
|
|
88
|
+
import { vite as um } from "./vite.js";
|
|
89
|
+
import { vitest as bm } from "./vitest.js";
|
|
90
|
+
import { vuedotjs as km } from "./vuedotjs.js";
|
|
91
|
+
import { whatsapp as vm } from "./whatsapp.js";
|
|
92
|
+
import { wikipedia as xm } from "./wikipedia.js";
|
|
93
|
+
import { wordpress as qm } from "./wordpress.js";
|
|
94
|
+
import { x as Am } from "./x.js";
|
|
95
|
+
import { yarn as Cm } from "./yarn.js";
|
|
96
|
+
import { ycombinator as Em } from "./ycombinator.js";
|
|
97
|
+
import { youtube as Gm } from "./youtube.js";
|
|
98
|
+
import { zoom as Im } from "./zoom.js";
|
|
98
99
|
export {
|
|
99
100
|
r as android,
|
|
100
101
|
t as angular,
|
|
@@ -103,8 +104,8 @@ export {
|
|
|
103
104
|
s as applemusic,
|
|
104
105
|
d as astro,
|
|
105
106
|
c as biome,
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
g as bitbucket,
|
|
108
|
+
y as bluesky,
|
|
108
109
|
h as bun,
|
|
109
110
|
w as buymeacoffee,
|
|
110
111
|
j as chromewebstore,
|
|
@@ -130,67 +131,68 @@ export {
|
|
|
130
131
|
so as gmail,
|
|
131
132
|
no as google,
|
|
132
133
|
uo as googlechrome,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
vo as
|
|
136
|
-
xo as
|
|
137
|
-
qo as
|
|
138
|
-
Ao as
|
|
139
|
-
Co as
|
|
140
|
-
Eo as
|
|
141
|
-
Go as
|
|
142
|
-
Io as
|
|
143
|
-
Ko as
|
|
144
|
-
Mo as
|
|
145
|
-
Oo as
|
|
146
|
-
Qo as
|
|
147
|
-
So as
|
|
148
|
-
Uo as
|
|
149
|
-
Wo as
|
|
150
|
-
Yo as
|
|
151
|
-
_o as
|
|
152
|
-
or as
|
|
153
|
-
mr as
|
|
154
|
-
ir as
|
|
155
|
-
fr as
|
|
156
|
-
ar as
|
|
157
|
-
lr as
|
|
158
|
-
nr as
|
|
159
|
-
ur as
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
vr as
|
|
163
|
-
xr as
|
|
164
|
-
qr as
|
|
165
|
-
Ar as
|
|
166
|
-
Cr as
|
|
167
|
-
Er as
|
|
168
|
-
Gr as
|
|
169
|
-
Ir as
|
|
170
|
-
Kr as
|
|
171
|
-
Mr as
|
|
172
|
-
Or as
|
|
173
|
-
Qr as
|
|
174
|
-
Sr as
|
|
175
|
-
Ur as
|
|
176
|
-
Wr as
|
|
177
|
-
Yr as
|
|
178
|
-
_r as
|
|
179
|
-
om as
|
|
180
|
-
mm as
|
|
181
|
-
im as
|
|
182
|
-
fm as
|
|
183
|
-
am as
|
|
184
|
-
lm as
|
|
185
|
-
nm as
|
|
186
|
-
um as
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
vm as
|
|
190
|
-
xm as
|
|
191
|
-
qm as
|
|
192
|
-
Am as
|
|
193
|
-
Cm as
|
|
194
|
-
Em as
|
|
195
|
-
Gm as
|
|
134
|
+
bo as googlecloud,
|
|
135
|
+
ko as googledrive,
|
|
136
|
+
vo as googleplay,
|
|
137
|
+
xo as gravatar,
|
|
138
|
+
qo as html5,
|
|
139
|
+
Ao as instagram,
|
|
140
|
+
Co as javascript,
|
|
141
|
+
Eo as jira,
|
|
142
|
+
Go as kofi,
|
|
143
|
+
Io as kubernetes,
|
|
144
|
+
Ko as linear,
|
|
145
|
+
Mo as linux,
|
|
146
|
+
Oo as mastodon,
|
|
147
|
+
Qo as medium,
|
|
148
|
+
So as mongodb,
|
|
149
|
+
Uo as mozilla,
|
|
150
|
+
Wo as mysql,
|
|
151
|
+
Yo as netlify,
|
|
152
|
+
_o as nextdotjs,
|
|
153
|
+
or as nodedotjs,
|
|
154
|
+
mr as notion,
|
|
155
|
+
ir as npm,
|
|
156
|
+
fr as opensourceinitiative,
|
|
157
|
+
ar as patreon,
|
|
158
|
+
lr as paypal,
|
|
159
|
+
nr as pnpm,
|
|
160
|
+
ur as postgresql,
|
|
161
|
+
br as preact,
|
|
162
|
+
kr as producthunt,
|
|
163
|
+
vr as react,
|
|
164
|
+
xr as reddit,
|
|
165
|
+
qr as redis,
|
|
166
|
+
Ar as rss,
|
|
167
|
+
Cr as safari,
|
|
168
|
+
Er as shopify,
|
|
169
|
+
Gr as signal,
|
|
170
|
+
Ir as soundcloud,
|
|
171
|
+
Kr as spotify,
|
|
172
|
+
Mr as sqlite,
|
|
173
|
+
Or as stackoverflow,
|
|
174
|
+
Qr as storybook,
|
|
175
|
+
Sr as stripe,
|
|
176
|
+
Ur as supabase,
|
|
177
|
+
Wr as svelte,
|
|
178
|
+
Yr as tailwindcss,
|
|
179
|
+
_r as telegram,
|
|
180
|
+
om as threads,
|
|
181
|
+
mm as tiktok,
|
|
182
|
+
im as trello,
|
|
183
|
+
fm as twitch,
|
|
184
|
+
am as typescript,
|
|
185
|
+
lm as ubuntu,
|
|
186
|
+
nm as vercel,
|
|
187
|
+
um as vite,
|
|
188
|
+
bm as vitest,
|
|
189
|
+
km as vuedotjs,
|
|
190
|
+
vm as whatsapp,
|
|
191
|
+
xm as wikipedia,
|
|
192
|
+
qm as wordpress,
|
|
193
|
+
Am as x,
|
|
194
|
+
Cm as yarn,
|
|
195
|
+
Em as ycombinator,
|
|
196
|
+
Gm as youtube,
|
|
197
|
+
Im as zoom
|
|
196
198
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext as y, useCallback as A, useContext as C, useEffect as g, useMemo as T, useRef as w, useState as u } from "react";
|
|
3
3
|
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
4
|
-
var v = y(null),
|
|
5
|
-
function j({ clearAfter: e = 5e3, children:
|
|
4
|
+
var v = y(null), d = !1;
|
|
5
|
+
function j({ clearAfter: e = 5e3, children: m }) {
|
|
6
6
|
const [r, x] = u({
|
|
7
7
|
text: "",
|
|
8
8
|
n: 0
|
|
@@ -26,8 +26,8 @@ function j({ clearAfter: e = 5e3, children: d }) {
|
|
|
26
26
|
};
|
|
27
27
|
}, []), /* @__PURE__ */ l(v.Provider, {
|
|
28
28
|
value: f,
|
|
29
|
-
children: [
|
|
30
|
-
className: "cy-announcer",
|
|
29
|
+
children: [m, /* @__PURE__ */ l("div", {
|
|
30
|
+
className: "cy-announcer cy-visually-hidden",
|
|
31
31
|
children: [/* @__PURE__ */ t("div", {
|
|
32
32
|
className: "cy-announcer-region cy-reset",
|
|
33
33
|
role: "status",
|
|
@@ -47,7 +47,7 @@ function j({ clearAfter: e = 5e3, children: d }) {
|
|
|
47
47
|
function P() {
|
|
48
48
|
const e = C(v);
|
|
49
49
|
return T(() => e ?? (() => {
|
|
50
|
-
|
|
50
|
+
d || (d = !0, console.warn("Cynosure: useAnnounce() needs an <Announcer> above it; nothing was announced."));
|
|
51
51
|
}), [e]);
|
|
52
52
|
}
|
|
53
53
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Announcer.js","names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","jsx","jsxs","AnnounceContext","warned","Announcer","clearAfter","children","polite","setPolite","assertive","setAssertive","timers","announce","message","options","politeness","set","said","pending","useAnnounce"],"sources":["../../../src/components/Announcer/Announcer.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nexport type Politeness = \"polite\" | \"assertive\";\n\nexport interface AnnounceOptions {\n /** `polite` (default) waits for the screen reader to finish; `assertive` interrupts. Keep assertive for errors. */\n politeness?: Politeness;\n}\n\nexport type Announce = (message: string, options?: AnnounceOptions) => void;\n\nexport interface AnnouncerProps {\n /** Milliseconds before an announcement is cleared from the hidden region. Default: 5000. */\n clearAfter?: number;\n /** Your app. Anything inside can announce through `useAnnounce()`. */\n children?: ReactNode;\n}\n\ninterface Said {\n text: string;\n /** Changes on every announcement, so the same text twice is a new node and is read again. */\n n: number;\n}\n\nconst AnnounceContext = createContext<Announce | null>(null);\nlet warned = false;\n\n/**\n * Hidden live regions for screen reader announcements, rendered where you put it (inside your app, never in `<body>`).\n * Render one near the root; `useAnnounce()` below it speaks through it.\n */\nexport function Announcer({ clearAfter = 5000, children }: AnnouncerProps) {\n const [polite, setPolite] = useState<Said>({ text: \"\", n: 0 });\n const [assertive, setAssertive] = useState<Said>({ text: \"\", n: 0 });\n const timers = useRef<Partial<Record<Politeness, ReturnType<typeof setTimeout>>>>({});\n\n const announce = useCallback<Announce>(\n (message, options) => {\n const politeness = options?.politeness ?? \"polite\";\n const set = politeness === \"assertive\" ? setAssertive : setPolite;\n set((said) => ({ text: message, n: said.n + 1 }));\n clearTimeout(timers.current[politeness]);\n timers.current[politeness] = setTimeout(() => set((said) => ({ ...said, text: \"\" })), clearAfter);\n },\n [clearAfter],\n );\n\n useEffect(() => {\n const pending = timers.current;\n return () => {\n clearTimeout(pending.polite);\n clearTimeout(pending.assertive);\n };\n }, []);\n\n return (\n <AnnounceContext.Provider value={announce}>\n {children}\n <div className=\"cy-announcer\">\n <div className=\"cy-announcer-region cy-reset\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite.text && <span key={polite.n}>{polite.text}</span>}\n </div>\n <div className=\"cy-announcer-region cy-reset\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n {assertive.text && <span key={assertive.n}>{assertive.text}</span>}\n </div>\n </div>\n </AnnounceContext.Provider>\n );\n}\n\n/** Returns `announce(message, { politeness })`, spoken through the nearest `<Announcer>`. */\nexport function useAnnounce(): Announce {\n const announce = useContext(AnnounceContext);\n return useMemo(\n () =>\n announce ??\n (() => {\n if (warned) return;\n warned = true;\n console.warn(\"Cynosure: useAnnounce() needs an <Announcer> above it; nothing was announced.\");\n }),\n [announce],\n );\n}\n"],"mappings":";;;AAiCA,IAAMS,IAAkBT,EAA+B,IAAI,GACvDU,IAAS;AAMb,SAAgBC,EAAU,EAAE,YAAAC,IAAa,KAAM,UAAAC,EAAA,GAA4B;AACzE,QAAM,CAACC,GAAQC,CAAA,IAAaT,EAAe;AAAA,IAAE,MAAM;AAAA,IAAI,GAAG;AAAA,EAAE,CAAC,GACvD,CAACU,GAAWC,CAAA,IAAgBX,EAAe;AAAA,IAAE,MAAM;AAAA,IAAI,GAAG;AAAA,EAAE,CAAC,GAC7DY,IAASb,EAAmE,CAAC,CAAC,GAE9Ec,IAAWlB,EAAA,CACdmB,GAASC,MAAY;AACpB,UAAMC,IAAaD,GAAS,cAAc,UACpCE,IAAMD,MAAe,cAAcL,IAAeF;AACxD,IAAAQ,EAAA,CAAKC,OAAU;AAAA,MAAE,MAAMJ;AAAA,MAAS,GAAGI,EAAK,IAAI;AAAA,IAAE,EAAE,GAChD,aAAaN,EAAO,QAAQI,CAAA,CAAW,GACvCJ,EAAO,QAAQI,CAAA,IAAc,WAAA,MAAiBC,EAAA,CAAKC,OAAU;AAAA,MAAE,GAAGA;AAAA,MAAM,MAAM;AAAA,IAAG,EAAE,GAAGZ,CAAU;AAAA,EAClG,GACA,CAACA,CAAU,CACb;AAEA,SAAAT,EAAA,MAAgB;AACd,UAAMsB,IAAUP,EAAO;AACvB,WAAA,MAAa;AACX,mBAAaO,EAAQ,MAAM,GAC3B,aAAaA,EAAQ,SAAS;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,CAAC,GAGH,gBAAAjB,EAACC,EAAgB,UAAjB;AAAA,IAA0B,OAAOU;AAAA,IAAjC,UAAA,CACGN,GACD,gBAAAL,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAf,UAAA,CACE,gBAAAD,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAA+B,MAAK;AAAA,QAAS,aAAU;AAAA,QAAS,eAAY;AAAA,QACxF,UAAAO,EAAO,QAAQ,gBAAAP,EAAC,QAAD,EAAA,UAAsBO,EAAO,KAAW,GAA7BA,EAAO,CAAsB;AAAA,MACrD,CAAA,GACL,gBAAAP,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAA+B,MAAK;AAAA,QAAQ,aAAU;AAAA,QAAY,eAAY;AAAA,QAC1F,UAAAS,EAAU,QAAQ,gBAAAT,EAAC,QAAD,EAAA,UAAyBS,EAAU,KAAW,GAAnCA,EAAU,CAAyB;AAAA,MAC9D,CAAA,CACF;AAAA,IACmB,CAAA,CAAA;AAAA,E;AAE9B;AAGA,SAAgBU,IAAwB;AACtC,QAAMP,IAAWjB,EAAWO,CAAe;AAC3C,SAAOL,EAAA,MAEHe,MAAA,MACO;AACL,IAAIT,MACJA,IAAS,IACT,QAAQ,KAAK,+EAA+E;AAAA,EAC9F,IACF,CAACS,CAAQ,CACX;AACF"}
|
|
1
|
+
{"version":3,"file":"Announcer.js","names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","jsx","jsxs","AnnounceContext","warned","Announcer","clearAfter","children","polite","setPolite","assertive","setAssertive","timers","announce","message","options","politeness","set","said","pending","useAnnounce"],"sources":["../../../src/components/Announcer/Announcer.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nexport type Politeness = \"polite\" | \"assertive\";\n\nexport interface AnnounceOptions {\n /** `polite` (default) waits for the screen reader to finish; `assertive` interrupts. Keep assertive for errors. */\n politeness?: Politeness;\n}\n\nexport type Announce = (message: string, options?: AnnounceOptions) => void;\n\nexport interface AnnouncerProps {\n /** Milliseconds before an announcement is cleared from the hidden region. Default: 5000. */\n clearAfter?: number;\n /** Your app. Anything inside can announce through `useAnnounce()`. */\n children?: ReactNode;\n}\n\ninterface Said {\n text: string;\n /** Changes on every announcement, so the same text twice is a new node and is read again. */\n n: number;\n}\n\nconst AnnounceContext = createContext<Announce | null>(null);\nlet warned = false;\n\n/**\n * Hidden live regions for screen reader announcements, rendered where you put it (inside your app, never in `<body>`).\n * Render one near the root; `useAnnounce()` below it speaks through it.\n */\nexport function Announcer({ clearAfter = 5000, children }: AnnouncerProps) {\n const [polite, setPolite] = useState<Said>({ text: \"\", n: 0 });\n const [assertive, setAssertive] = useState<Said>({ text: \"\", n: 0 });\n const timers = useRef<Partial<Record<Politeness, ReturnType<typeof setTimeout>>>>({});\n\n const announce = useCallback<Announce>(\n (message, options) => {\n const politeness = options?.politeness ?? \"polite\";\n const set = politeness === \"assertive\" ? setAssertive : setPolite;\n set((said) => ({ text: message, n: said.n + 1 }));\n clearTimeout(timers.current[politeness]);\n timers.current[politeness] = setTimeout(() => set((said) => ({ ...said, text: \"\" })), clearAfter);\n },\n [clearAfter],\n );\n\n useEffect(() => {\n const pending = timers.current;\n return () => {\n clearTimeout(pending.polite);\n clearTimeout(pending.assertive);\n };\n }, []);\n\n return (\n <AnnounceContext.Provider value={announce}>\n {children}\n <div className=\"cy-announcer cy-visually-hidden\">\n <div className=\"cy-announcer-region cy-reset\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite.text && <span key={polite.n}>{polite.text}</span>}\n </div>\n <div className=\"cy-announcer-region cy-reset\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n {assertive.text && <span key={assertive.n}>{assertive.text}</span>}\n </div>\n </div>\n </AnnounceContext.Provider>\n );\n}\n\n/** Returns `announce(message, { politeness })`, spoken through the nearest `<Announcer>`. */\nexport function useAnnounce(): Announce {\n const announce = useContext(AnnounceContext);\n return useMemo(\n () =>\n announce ??\n (() => {\n if (warned) return;\n warned = true;\n console.warn(\"Cynosure: useAnnounce() needs an <Announcer> above it; nothing was announced.\");\n }),\n [announce],\n );\n}\n"],"mappings":";;;AAiCA,IAAMS,IAAkBT,EAA+B,IAAI,GACvDU,IAAS;AAMb,SAAgBC,EAAU,EAAE,YAAAC,IAAa,KAAM,UAAAC,EAAA,GAA4B;AACzE,QAAM,CAACC,GAAQC,CAAA,IAAaT,EAAe;AAAA,IAAE,MAAM;AAAA,IAAI,GAAG;AAAA,EAAE,CAAC,GACvD,CAACU,GAAWC,CAAA,IAAgBX,EAAe;AAAA,IAAE,MAAM;AAAA,IAAI,GAAG;AAAA,EAAE,CAAC,GAC7DY,IAASb,EAAmE,CAAC,CAAC,GAE9Ec,IAAWlB,EAAA,CACdmB,GAASC,MAAY;AACpB,UAAMC,IAAaD,GAAS,cAAc,UACpCE,IAAMD,MAAe,cAAcL,IAAeF;AACxD,IAAAQ,EAAA,CAAKC,OAAU;AAAA,MAAE,MAAMJ;AAAA,MAAS,GAAGI,EAAK,IAAI;AAAA,IAAE,EAAE,GAChD,aAAaN,EAAO,QAAQI,CAAA,CAAW,GACvCJ,EAAO,QAAQI,CAAA,IAAc,WAAA,MAAiBC,EAAA,CAAKC,OAAU;AAAA,MAAE,GAAGA;AAAA,MAAM,MAAM;AAAA,IAAG,EAAE,GAAGZ,CAAU;AAAA,EAClG,GACA,CAACA,CAAU,CACb;AAEA,SAAAT,EAAA,MAAgB;AACd,UAAMsB,IAAUP,EAAO;AACvB,WAAA,MAAa;AACX,mBAAaO,EAAQ,MAAM,GAC3B,aAAaA,EAAQ,SAAS;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,CAAC,GAGH,gBAAAjB,EAACC,EAAgB,UAAjB;AAAA,IAA0B,OAAOU;AAAA,IAAjC,UAAA,CACGN,GACD,gBAAAL,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAf,UAAA,CACE,gBAAAD,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAA+B,MAAK;AAAA,QAAS,aAAU;AAAA,QAAS,eAAY;AAAA,QACxF,UAAAO,EAAO,QAAQ,gBAAAP,EAAC,QAAD,EAAA,UAAsBO,EAAO,KAAW,GAA7BA,EAAO,CAAsB;AAAA,MACrD,CAAA,GACL,gBAAAP,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAA+B,MAAK;AAAA,QAAQ,aAAU;AAAA,QAAY,eAAY;AAAA,QAC1F,UAAAS,EAAU,QAAQ,gBAAAT,EAAC,QAAD,EAAA,UAAyBS,EAAU,KAAW,GAAnCA,EAAU,CAAyB;AAAA,MAC9D,CAAA,CACF;AAAA,IACmB,CAAA,CAAA;AAAA,E;AAE9B;AAGA,SAAgBU,IAAwB;AACtC,QAAMP,IAAWjB,EAAWO,CAAe;AAC3C,SAAOL,EAAA,MAEHe,MAAA,MACO;AACL,IAAIT,MACJA,IAAS,IACT,QAAQ,KAAK,+EAA+E;AAAA,EAC9F,IACF,CAACS,CAAQ,CACX;AACF"}
|