@greese/ui 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +55 -2
- package/bin/greese-utilities.mjs +56 -0
- package/dist/_layers.scss +2 -0
- package/dist/_maps.scss +1884 -0
- package/dist/_tokens-base.scss +174 -0
- package/dist/_tokens.scss +2140 -0
- package/dist/base.css +67 -0
- package/dist/colorScheme.d.ts +16 -0
- package/dist/colorScheme.js +13 -0
- package/dist/contrast.d.ts +15 -0
- package/dist/contrast.js +43 -0
- package/dist/css/Accordion.css +9 -0
- package/dist/css/ActionSelect.css +6 -0
- package/dist/css/Alert.css +84 -0
- package/dist/css/AppBar.css +35 -0
- package/dist/css/AspectRatio.css +40 -0
- package/dist/css/AutoLayout.css +508 -0
- package/dist/css/Avatar.css +88 -0
- package/dist/css/Badge.css +66 -0
- package/dist/css/Box.css +640 -0
- package/dist/css/Breadcrumbs.css +57 -0
- package/dist/css/Button.css +275 -0
- package/dist/css/ButtonGroup.css +40 -0
- package/dist/css/Card.css +101 -0
- package/dist/css/Carousel.css +170 -0
- package/dist/css/Center.css +11 -0
- package/dist/css/ChatBubble.css +128 -0
- package/dist/css/Checkbox.css +65 -0
- package/dist/css/Chip.css +124 -0
- package/dist/css/ChoiceGroup.css +57 -0
- package/dist/css/Code.css +29 -0
- package/dist/css/Collapsible.css +126 -0
- package/dist/css/ColorPicker.css +191 -0
- package/dist/css/Combobox.css +90 -0
- package/dist/css/Container.css +30 -0
- package/dist/css/Countdown.css +25 -0
- package/dist/css/DateField.css +15 -0
- package/dist/css/Dialog.css +640 -0
- package/dist/css/Diff.css +103 -0
- package/dist/css/Divider.css +19 -0
- package/dist/css/Dock.css +91 -0
- package/dist/css/Field.css +33 -0
- package/dist/css/Fieldset.css +54 -0
- package/dist/css/FileInput.css +65 -0
- package/dist/css/Footer.css +72 -0
- package/dist/css/Grid.css +998 -0
- package/dist/css/Header.css +89 -0
- package/dist/css/Heading.css +6 -0
- package/dist/css/Icon.css +12 -0
- package/dist/css/IconButton.css +7 -0
- package/dist/css/Image.css +69 -0
- package/dist/css/Indicator.css +41 -0
- package/dist/css/Input.css +115 -0
- package/dist/css/Key.css +42 -0
- package/dist/css/Link.css +72 -0
- package/dist/css/List.css +52 -0
- package/dist/css/Media.css +8 -0
- package/dist/css/Menu.css +161 -0
- package/dist/css/Motion.css +1356 -0
- package/dist/css/NumberField.css +49 -0
- package/dist/css/OtpField.css +90 -0
- package/dist/css/PageTransition.css +979 -0
- package/dist/css/Pagination.css +43 -0
- package/dist/css/Popover.css +93 -0
- package/dist/css/Progress.css +101 -0
- package/dist/css/RadialProgress.css +44 -0
- package/dist/css/Radio.css +41 -0
- package/dist/css/Rating.css +100 -0
- package/dist/css/ScrollSpy.css +6 -0
- package/dist/css/SegmentedControl.css +101 -0
- package/dist/css/Select.css +115 -0
- package/dist/css/Sidebar.css +207 -0
- package/dist/css/Skeleton.css +48 -0
- package/dist/css/Slider.css +75 -0
- package/dist/css/Spacer.css +34 -0
- package/dist/css/SpeedDial.css +165 -0
- package/dist/css/Spinner.css +44 -0
- package/dist/css/Stack.css +528 -0
- package/dist/css/Stat.css +107 -0
- package/dist/css/Status.css +86 -0
- package/dist/css/Steps.css +201 -0
- package/dist/css/Swap.css +49 -0
- package/dist/css/Switch.css +66 -0
- package/dist/css/Table.css +269 -0
- package/dist/css/Tabs.css +119 -0
- package/dist/css/Text.css +60 -0
- package/dist/css/TextRotate.css +147 -0
- package/dist/css/Textarea.css +107 -0
- package/dist/css/ThemeProvider.css +6 -0
- package/dist/css/Tile.css +18 -0
- package/dist/css/Toast.css +110 -0
- package/dist/css/ToggleButton.css +20 -0
- package/dist/css/Tooltip.css +94 -0
- package/dist/css/Type.css +211 -0
- package/dist/css/Visibility.css +78 -0
- package/dist/css/VisuallyHidden.css +15 -0
- package/dist/css/core.css +251 -0
- package/dist/css.d.ts +29 -0
- package/dist/css.js +28 -0
- package/dist/effect-classes.d.ts +8 -0
- package/dist/effect-classes.js +5 -0
- package/dist/effects/css.d.ts +71 -0
- package/dist/effects/css.js +184 -0
- package/dist/effects/definitions.d.ts +555 -0
- package/dist/effects/definitions.js +379 -0
- package/dist/effects/frames.d.ts +18 -0
- package/dist/effects/frames.js +68 -0
- package/dist/effects/sequence.d.ts +33 -0
- package/dist/effects/sequence.js +106 -0
- package/dist/effects.d.ts +30 -0
- package/dist/effects.js +30 -0
- package/dist/greese.css +11907 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/kebab.d.ts +2 -0
- package/dist/kebab.js +2 -0
- package/dist/palette.css +249 -0
- package/dist/palette.d.ts +599 -0
- package/dist/palette.js +334 -0
- package/dist/shapes.d.ts +193 -0
- package/dist/shapes.js +852 -0
- package/dist/storage.d.ts +47 -0
- package/dist/storage.js +118 -0
- package/dist/style-manifest.json +3010 -0
- package/dist/theme.d.ts +71 -0
- package/dist/theme.js +180 -0
- package/dist/tokens.css +253 -0
- package/dist/tokens.d.ts +343 -0
- package/dist/tokens.js +179 -0
- package/dist/typography.d.ts +55 -0
- package/dist/typography.js +144 -0
- package/dist/utilities.css +6975 -0
- package/dist/utilities.d.ts +82 -0
- package/dist/utilities.js +636 -0
- package/dist/utilitiesFiles.d.ts +18 -0
- package/dist/utilitiesFiles.js +26 -0
- package/dist/vite.d.ts +40 -0
- package/dist/vite.js +43 -0
- package/package.json +131 -4
- package/src/components/Accordion/Accordion.scss +9 -0
- package/src/components/ActionSelect/ActionSelect.scss +6 -0
- package/src/components/Alert/Alert.scss +71 -0
- package/src/components/AppBar/AppBar.scss +43 -0
- package/src/components/AspectRatio/AspectRatio.scss +22 -0
- package/src/components/AutoLayout/AutoLayout.scss +90 -0
- package/src/components/Avatar/Avatar.scss +91 -0
- package/src/components/Badge/Badge.scss +52 -0
- package/src/components/Box/Box.scss +63 -0
- package/src/components/Breadcrumbs/Breadcrumbs.scss +59 -0
- package/src/components/Button/Button.scss +231 -0
- package/src/components/ButtonGroup/ButtonGroup.scss +56 -0
- package/src/components/Card/Card.scss +99 -0
- package/src/components/Carousel/Carousel.scss +161 -0
- package/src/components/Center/Center.scss +11 -0
- package/src/components/ChatBubble/ChatBubble.scss +119 -0
- package/src/components/Checkbox/Checkbox.scss +66 -0
- package/src/components/Chip/Chip.scss +119 -0
- package/src/components/ChoiceGroup/ChoiceGroup.scss +69 -0
- package/src/components/Code/Code.scss +28 -0
- package/src/components/Collapsible/Collapsible.scss +136 -0
- package/src/components/ColorPicker/ColorPicker.scss +235 -0
- package/src/components/Combobox/Combobox.scss +83 -0
- package/src/components/Container/Container.scss +28 -0
- package/src/components/Countdown/Countdown.scss +28 -0
- package/src/components/DateField/DateField.scss +19 -0
- package/src/components/Dialog/Dialog.scss +268 -0
- package/src/components/Diff/Diff.scss +125 -0
- package/src/components/Divider/Divider.scss +22 -0
- package/src/components/Dock/Dock.scss +86 -0
- package/src/components/Field/Field.scss +38 -0
- package/src/components/Fieldset/Fieldset.scss +63 -0
- package/src/components/FileInput/FileInput.scss +66 -0
- package/src/components/Footer/Footer.scss +79 -0
- package/src/components/Grid/Grid.scss +86 -0
- package/src/components/Header/Header.scss +111 -0
- package/src/components/Heading/Heading.scss +7 -0
- package/src/components/Icon/Icon.scss +12 -0
- package/src/components/IconButton/IconButton.scss +6 -0
- package/src/components/Image/Image.scss +46 -0
- package/src/components/Indicator/Indicator.scss +48 -0
- package/src/components/Input/Input.scss +58 -0
- package/src/components/Key/Key.scss +48 -0
- package/src/components/Link/Link.scss +50 -0
- package/src/components/List/List.scss +62 -0
- package/src/components/Media/Media.scss +7 -0
- package/src/components/Menu/Menu.scss +91 -0
- package/src/components/Motion/Motion.scss +106 -0
- package/src/components/NumberField/NumberField.scss +44 -0
- package/src/components/OtpField/OtpField.scss +91 -0
- package/src/components/PageTransition/PageTransition.scss +168 -0
- package/src/components/Pagination/Pagination.scss +55 -0
- package/src/components/Popover/Popover.scss +13 -0
- package/src/components/Progress/Progress.scss +126 -0
- package/src/components/RadialProgress/RadialProgress.scss +65 -0
- package/src/components/Radio/Radio.scss +36 -0
- package/src/components/Rating/Rating.scss +121 -0
- package/src/components/ScrollSpy/ScrollSpy.scss +6 -0
- package/src/components/SegmentedControl/SegmentedControl.scss +107 -0
- package/src/components/Select/Select.scss +59 -0
- package/src/components/Sidebar/Sidebar.scss +88 -0
- package/src/components/Skeleton/Skeleton.scss +60 -0
- package/src/components/Slider/Slider.scss +96 -0
- package/src/components/Spacer/Spacer.scss +15 -0
- package/src/components/SpeedDial/SpeedDial.scss +109 -0
- package/src/components/Spinner/Spinner.scss +43 -0
- package/src/components/Stack/Stack.scss +57 -0
- package/src/components/Stat/Stat.scss +96 -0
- package/src/components/Status/Status.scss +60 -0
- package/src/components/Steps/Steps.scss +216 -0
- package/src/components/Swap/Swap.scss +62 -0
- package/src/components/Switch/Switch.scss +63 -0
- package/src/components/Table/Table.scss +183 -0
- package/src/components/Tabs/Tabs.scss +108 -0
- package/src/components/Text/Text.scss +34 -0
- package/src/components/TextRotate/TextRotate.scss +51 -0
- package/src/components/Textarea/Textarea.scss +56 -0
- package/src/components/ThemeProvider/ThemeProvider.scss +7 -0
- package/src/components/Tile/Tile.scss +23 -0
- package/src/components/Toast/Toast.scss +93 -0
- package/src/components/ToggleButton/ToggleButton.scss +23 -0
- package/src/components/Tooltip/Tooltip.scss +21 -0
- package/src/components/Type/Type.scss +35 -0
- package/src/components/Visibility/Visibility.scss +39 -0
- package/src/components/VisuallyHidden/VisuallyHidden.scss +17 -0
- package/src/styles/_breakpoint-vars.scss +16 -0
- package/src/styles/_config.scss +48 -0
- package/src/styles/_controls.scss +88 -0
- package/src/styles/_core.scss +4 -0
- package/src/styles/_effect.scss +51 -0
- package/src/styles/_floating.scss +141 -0
- package/src/styles/_kit.scss +1548 -0
- package/src/styles/_manifest.scss +670 -0
- package/src/styles/_mixins.scss +261 -0
- package/src/styles/_tones.scss +63 -0
- package/src/styles/_type-emit.scss +76 -0
- package/src/styles/_typography-vars.scss +8 -0
- package/src/styles/base.scss +80 -0
- package/src/styles/breakpoints.test.ts +73 -0
- package/src/styles/entryPoints.test.ts +68 -0
- package/src/styles/index.scss +93 -0
- package/src/styles/kit.test.ts +754 -0
- package/src/styles/public/_controls.scss +3 -0
- package/src/styles/public/_floating.scss +3 -0
- package/src/styles/public/_mixins.scss +5 -0
- package/src/styles/public/_tones.scss +4 -0
- package/themes/bevel.css +1077 -0
- package/themes/bevel.scss +1166 -0
- package/themes/depth.css +123 -0
- package/themes/depth.scss +46 -0
- package/themes/extrude.css +219 -0
- package/themes/extrude.scss +255 -0
- package/themes/folio.css +986 -0
- package/themes/folio.scss +1047 -0
- package/themes/gentle.css +66 -0
- package/themes/gentle.scss +39 -0
- package/themes/outline.css +127 -0
- package/themes/outline.scss +126 -0
- package/themes/pebble.css +65 -0
- package/themes/pebble.scss +69 -0
- package/themes/pocket.css +137 -0
- package/themes/pocket.scss +45 -0
- package/themes/ridge.css +927 -0
- package/themes/ridge.scss +998 -0
- package/themes/snappy.css +82 -0
- package/themes/snappy.scss +40 -0
- package/themes/soft.css +79 -0
- package/themes/soft.scss +84 -0
- package/themes/ticket.css +960 -0
- package/themes/ticket.scss +1031 -0
- package/themes/tilt.css +148 -0
- package/themes/tilt.scss +169 -0
- package/themes/wipe.css +186 -0
- package/themes/wipe.scss +46 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values kept in the browser's storage, safely. Storage can be missing (on
|
|
3
|
+
* the server), blocked (private browsing, site data turned off), full, or
|
|
4
|
+
* hold something another version wrote; none of that should break a page. A
|
|
5
|
+
* stored value:
|
|
6
|
+
*
|
|
7
|
+
* - falls back to an in-memory copy when storage can't be used, so the value
|
|
8
|
+
* still works for this page view;
|
|
9
|
+
* - parses what it reads, and with `validate` refuses what isn't its shape,
|
|
10
|
+
* reading the fallback instead;
|
|
11
|
+
* - tells its subscribers when it changes, in this tab (through any handle
|
|
12
|
+
* on the same key) and in other tabs (the `storage` event).
|
|
13
|
+
*
|
|
14
|
+
* Framework-free; `useStoredState()` in @greese/react is the React side.
|
|
15
|
+
*/
|
|
16
|
+
export interface StoredValueOptions<T> {
|
|
17
|
+
/** `local` persists; `session` lasts for the tab. @default 'local' */
|
|
18
|
+
area?: 'local' | 'session';
|
|
19
|
+
/** Turns the value into stored text. @default JSON.stringify */
|
|
20
|
+
serialize?: (value: T) => string;
|
|
21
|
+
/** Turns stored text back into a value. @default JSON.parse */
|
|
22
|
+
parse?: (text: string) => unknown;
|
|
23
|
+
/** Whether what was read is a value of this shape; when not, the fallback is read instead. */
|
|
24
|
+
validate?: (value: unknown) => value is T;
|
|
25
|
+
}
|
|
26
|
+
export interface StoredValue<T> {
|
|
27
|
+
readonly key: string;
|
|
28
|
+
/** The value: what's stored, or the fallback. The same object until it changes. */
|
|
29
|
+
get(): T;
|
|
30
|
+
/** Stores a value, or a function of the current one. */
|
|
31
|
+
set(value: T | ((current: T) => T)): void;
|
|
32
|
+
/** Forgets the stored value: `get()` reads the fallback again. */
|
|
33
|
+
remove(): void;
|
|
34
|
+
/** Calls `listener` whenever the value changes, here or in another tab. Returns the unsubscribe. */
|
|
35
|
+
subscribe(listener: () => void): () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A value kept in localStorage (or sessionStorage) under `key`.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const theme = createStoredValue('app-theme', { accent: 'blue' }, {
|
|
42
|
+
* validate: (v): v is { accent: string } => typeof (v as any)?.accent === 'string',
|
|
43
|
+
* })
|
|
44
|
+
* theme.set((t) => ({ ...t, accent: 'pink' }))
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const createStoredValue: <T>(key: string, fallback: T, { area, serialize, parse, validate, }?: StoredValueOptions<T>) => StoredValue<T>;
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values kept in the browser's storage, safely. Storage can be missing (on
|
|
3
|
+
* the server), blocked (private browsing, site data turned off), full, or
|
|
4
|
+
* hold something another version wrote; none of that should break a page. A
|
|
5
|
+
* stored value:
|
|
6
|
+
*
|
|
7
|
+
* - falls back to an in-memory copy when storage can't be used, so the value
|
|
8
|
+
* still works for this page view;
|
|
9
|
+
* - parses what it reads, and with `validate` refuses what isn't its shape,
|
|
10
|
+
* reading the fallback instead;
|
|
11
|
+
* - tells its subscribers when it changes, in this tab (through any handle
|
|
12
|
+
* on the same key) and in other tabs (the `storage` event).
|
|
13
|
+
*
|
|
14
|
+
* Framework-free; `useStoredState()` in @greese/react is the React side.
|
|
15
|
+
*/
|
|
16
|
+
/** Listeners by area and key, so every handle on a key hears every write in this tab. */
|
|
17
|
+
const listeners = new Map();
|
|
18
|
+
/** What was written when storage couldn't take it, by area and key. */
|
|
19
|
+
const memory = new Map();
|
|
20
|
+
const slot = (area, key) => `${area}:${key}`;
|
|
21
|
+
const storageOf = (area) => {
|
|
22
|
+
try {
|
|
23
|
+
return area === 'session' ? globalThis.sessionStorage : globalThis.localStorage;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Reading the property itself throws when site data is blocked.
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const readText = (area, key) => {
|
|
31
|
+
const id = slot(area, key);
|
|
32
|
+
if (memory.has(id))
|
|
33
|
+
return memory.get(id);
|
|
34
|
+
try {
|
|
35
|
+
return storageOf(area)?.getItem(key) ?? null;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const writeText = (area, key, text) => {
|
|
42
|
+
const id = slot(area, key);
|
|
43
|
+
try {
|
|
44
|
+
const store = storageOf(area);
|
|
45
|
+
if (!store)
|
|
46
|
+
throw new Error('no storage');
|
|
47
|
+
if (text === null)
|
|
48
|
+
store.removeItem(key);
|
|
49
|
+
else
|
|
50
|
+
store.setItem(key, text);
|
|
51
|
+
memory.delete(id);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Unavailable or full: keep it for this page view.
|
|
55
|
+
memory.set(id, text);
|
|
56
|
+
}
|
|
57
|
+
listeners.get(id)?.forEach((listener) => listener());
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A value kept in localStorage (or sessionStorage) under `key`.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* const theme = createStoredValue('app-theme', { accent: 'blue' }, {
|
|
64
|
+
* validate: (v): v is { accent: string } => typeof (v as any)?.accent === 'string',
|
|
65
|
+
* })
|
|
66
|
+
* theme.set((t) => ({ ...t, accent: 'pink' }))
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export const createStoredValue = (key, fallback, { area = 'local', serialize = JSON.stringify, parse = JSON.parse, validate, } = {}) => {
|
|
70
|
+
// The last text read and its value: `get()` returns the same object while
|
|
71
|
+
// the text is unchanged, which useSyncExternalStore needs.
|
|
72
|
+
let cachedText;
|
|
73
|
+
let cached = fallback;
|
|
74
|
+
const get = () => {
|
|
75
|
+
const text = readText(area, key);
|
|
76
|
+
if (text === cachedText)
|
|
77
|
+
return cached;
|
|
78
|
+
cachedText = text;
|
|
79
|
+
if (text === null)
|
|
80
|
+
return (cached = fallback);
|
|
81
|
+
try {
|
|
82
|
+
const value = parse(text);
|
|
83
|
+
cached = !validate || validate(value) ? value : fallback;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
cached = fallback;
|
|
87
|
+
}
|
|
88
|
+
return cached;
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
key,
|
|
92
|
+
get,
|
|
93
|
+
set: (value) => {
|
|
94
|
+
const next = typeof value === 'function' ? value(get()) : value;
|
|
95
|
+
writeText(area, key, serialize(next));
|
|
96
|
+
},
|
|
97
|
+
remove: () => writeText(area, key, null),
|
|
98
|
+
subscribe: (listener) => {
|
|
99
|
+
const id = slot(area, key);
|
|
100
|
+
const set = listeners.get(id) ?? new Set();
|
|
101
|
+
set.add(listener);
|
|
102
|
+
listeners.set(id, set);
|
|
103
|
+
// Another tab's write (the event never fires in the tab that wrote).
|
|
104
|
+
const onStorage = (event) => {
|
|
105
|
+
// The other area's writes (session vs local) aren't this value's.
|
|
106
|
+
if (event.storageArea && event.storageArea !== storageOf(area))
|
|
107
|
+
return;
|
|
108
|
+
if (event.key === key || event.key === null)
|
|
109
|
+
listener();
|
|
110
|
+
};
|
|
111
|
+
globalThis.addEventListener?.('storage', onStorage);
|
|
112
|
+
return () => {
|
|
113
|
+
set.delete(listener);
|
|
114
|
+
globalThis.removeEventListener?.('storage', onStorage);
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
};
|