@irisui/ui 0.0.0-stage → 0.1.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/dist/index.cjs ADDED
@@ -0,0 +1,182 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ DEFAULT_MODE: () => DEFAULT_MODE,
25
+ DEFAULT_PALETTE: () => DEFAULT_PALETTE,
26
+ DEFAULT_STORAGE_KEY: () => DEFAULT_STORAGE_KEY,
27
+ MODES: () => MODES,
28
+ PALETTES: () => PALETTES,
29
+ ThemeProvider: () => ThemeProvider,
30
+ ThemeScript: () => ThemeScript,
31
+ getThemeScript: () => getThemeScript,
32
+ useTheme: () => useTheme
33
+ });
34
+ module.exports = __toCommonJS(src_exports);
35
+
36
+ // src/theme/theme-provider.tsx
37
+ var import_react = require("react");
38
+
39
+ // src/theme/constants.ts
40
+ var PALETTES = ["nacre", "aurore", "couchant", "glacier"];
41
+ var MODES = ["light", "dark", "system"];
42
+ var DEFAULT_PALETTE = "nacre";
43
+ var DEFAULT_MODE = "system";
44
+ var DEFAULT_STORAGE_KEY = "@irisui/theme";
45
+ var isPalette = (value) => PALETTES.includes(value);
46
+ var isMode = (value) => MODES.includes(value);
47
+
48
+ // src/theme/theme-script.ts
49
+ function getThemeScript({
50
+ storageKey = DEFAULT_STORAGE_KEY,
51
+ defaultPalette = DEFAULT_PALETTE,
52
+ defaultMode = DEFAULT_MODE
53
+ } = {}) {
54
+ const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode].map((arg) => JSON.stringify(arg)).join(",");
55
+ return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||"{}")||{}}catch(e){}d.setAttribute("data-palette",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute("data-mode",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;
56
+ }
57
+
58
+ // src/theme/theme-provider.tsx
59
+ var import_jsx_runtime = require("react/jsx-runtime");
60
+ var useIsomorphicLayoutEffect = typeof window === "undefined" ? import_react.useEffect : import_react.useLayoutEffect;
61
+ var ThemeContext = (0, import_react.createContext)(null);
62
+ function readStorage(key) {
63
+ try {
64
+ const parsed = JSON.parse(window.localStorage.getItem(key) ?? "{}");
65
+ return parsed && typeof parsed === "object" ? parsed : {};
66
+ } catch {
67
+ return {};
68
+ }
69
+ }
70
+ function writeStorage(key, value) {
71
+ try {
72
+ window.localStorage.setItem(key, JSON.stringify(value));
73
+ } catch {
74
+ }
75
+ }
76
+ var DARK_QUERY = "(prefers-color-scheme: dark)";
77
+ function subscribeColorScheme(onChange) {
78
+ const media = window.matchMedia(DARK_QUERY);
79
+ media.addEventListener("change", onChange);
80
+ return () => media.removeEventListener("change", onChange);
81
+ }
82
+ function useSystemMode() {
83
+ return (0, import_react.useSyncExternalStore)(
84
+ subscribeColorScheme,
85
+ () => window.matchMedia(DARK_QUERY).matches ? "dark" : "light",
86
+ () => "light"
87
+ );
88
+ }
89
+ function ThemeProvider({
90
+ children,
91
+ palette: paletteProp,
92
+ defaultPalette = DEFAULT_PALETTE,
93
+ onPaletteChange,
94
+ mode: modeProp,
95
+ defaultMode = DEFAULT_MODE,
96
+ onModeChange,
97
+ storageKey = DEFAULT_STORAGE_KEY
98
+ }) {
99
+ const [paletteState, setPaletteState] = (0, import_react.useState)(defaultPalette);
100
+ const [modeState, setModeState] = (0, import_react.useState)(defaultMode);
101
+ const [restored, setRestored] = (0, import_react.useState)(false);
102
+ const palette = paletteProp ?? paletteState;
103
+ const mode = modeProp ?? modeState;
104
+ const systemMode = useSystemMode();
105
+ const resolvedMode = mode === "system" ? systemMode : mode;
106
+ useIsomorphicLayoutEffect(() => {
107
+ if (storageKey !== null) {
108
+ const stored = readStorage(storageKey);
109
+ if (isPalette(stored.palette)) setPaletteState(stored.palette);
110
+ if (isMode(stored.mode)) setModeState(stored.mode);
111
+ }
112
+ setRestored(true);
113
+ }, [storageKey]);
114
+ useIsomorphicLayoutEffect(() => {
115
+ if (!restored) return;
116
+ const root = document.documentElement;
117
+ root.setAttribute("data-palette", palette);
118
+ root.setAttribute("data-mode", mode);
119
+ }, [restored, palette, mode]);
120
+ (0, import_react.useEffect)(() => {
121
+ if (storageKey === null) return;
122
+ const onStorage = (event) => {
123
+ if (event.key !== storageKey) return;
124
+ const stored = readStorage(storageKey);
125
+ if (isPalette(stored.palette)) setPaletteState(stored.palette);
126
+ if (isMode(stored.mode)) setModeState(stored.mode);
127
+ };
128
+ window.addEventListener("storage", onStorage);
129
+ return () => window.removeEventListener("storage", onStorage);
130
+ }, [storageKey]);
131
+ const setPalette = (0, import_react.useCallback)(
132
+ (next) => {
133
+ if (paletteProp === void 0) setPaletteState(next);
134
+ if (storageKey !== null) writeStorage(storageKey, { palette: next, mode });
135
+ onPaletteChange?.(next);
136
+ },
137
+ [paletteProp, storageKey, mode, onPaletteChange]
138
+ );
139
+ const setMode = (0, import_react.useCallback)(
140
+ (next) => {
141
+ if (modeProp === void 0) setModeState(next);
142
+ if (storageKey !== null) writeStorage(storageKey, { palette, mode: next });
143
+ onModeChange?.(next);
144
+ },
145
+ [modeProp, storageKey, palette, onModeChange]
146
+ );
147
+ const value = (0, import_react.useMemo)(
148
+ () => ({ palette, mode, resolvedMode, setPalette, setMode }),
149
+ [palette, mode, resolvedMode, setPalette, setMode]
150
+ );
151
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value, children });
152
+ }
153
+ function useTheme() {
154
+ const context = (0, import_react.useContext)(ThemeContext);
155
+ if (context === null) {
156
+ throw new Error("useTheme must be used within a <ThemeProvider>.");
157
+ }
158
+ return context;
159
+ }
160
+ function ThemeScript({ nonce, ...options }) {
161
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
162
+ "script",
163
+ {
164
+ nonce,
165
+ suppressHydrationWarning: true,
166
+ dangerouslySetInnerHTML: { __html: getThemeScript(options) }
167
+ }
168
+ );
169
+ }
170
+ // Annotate the CommonJS export names for ESM import in node:
171
+ 0 && (module.exports = {
172
+ DEFAULT_MODE,
173
+ DEFAULT_PALETTE,
174
+ DEFAULT_STORAGE_KEY,
175
+ MODES,
176
+ PALETTES,
177
+ ThemeProvider,
178
+ ThemeScript,
179
+ getThemeScript,
180
+ useTheme
181
+ });
182
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/theme/theme-provider.tsx","../src/theme/constants.ts","../src/theme/theme-script.ts"],"sourcesContent":["export * from \"./theme\";\r\n","import {\r\n createContext,\r\n useCallback,\r\n useContext,\r\n useEffect,\r\n useLayoutEffect,\r\n useMemo,\r\n useState,\r\n useSyncExternalStore,\r\n type ReactNode,\r\n} from \"react\";\r\nimport {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n isMode,\r\n isPalette,\r\n type Mode,\r\n type Palette,\r\n type ResolvedMode,\r\n} from \"./constants\";\r\nimport { getThemeScript, type ThemeScriptOptions } from \"./theme-script\";\r\n\r\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\r\n\r\nexport interface ThemeContextValue {\r\n palette: Palette;\r\n /** Mode as chosen: `light`, `dark` or `system`. */\r\n mode: Mode;\r\n /** Mode actually displayed, `system` resolved through `prefers-color-scheme`. */\r\n resolvedMode: ResolvedMode;\r\n setPalette: (palette: Palette) => void;\r\n setMode: (mode: Mode) => void;\r\n}\r\n\r\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\r\n\r\nexport interface ThemeProviderProps {\r\n children?: ReactNode;\r\n /** Controlled palette. */\r\n palette?: Palette;\r\n /** Initial palette when uncontrolled and nothing is stored. */\r\n defaultPalette?: Palette;\r\n onPaletteChange?: (palette: Palette) => void;\r\n /** Controlled mode. */\r\n mode?: Mode;\r\n /** Initial mode when uncontrolled and nothing is stored. */\r\n defaultMode?: Mode;\r\n onModeChange?: (mode: Mode) => void;\r\n /** localStorage key used to remember the user's choice. `null` disables persistence. */\r\n storageKey?: string | null;\r\n}\r\n\r\ninterface StoredTheme {\r\n palette?: unknown;\r\n mode?: unknown;\r\n}\r\n\r\nfunction readStorage(key: string): StoredTheme {\r\n try {\r\n const parsed: unknown = JSON.parse(window.localStorage.getItem(key) ?? \"{}\");\r\n return parsed && typeof parsed === \"object\" ? (parsed as StoredTheme) : {};\r\n } catch {\r\n return {};\r\n }\r\n}\r\n\r\nfunction writeStorage(key: string, value: { palette: Palette; mode: Mode }): void {\r\n try {\r\n window.localStorage.setItem(key, JSON.stringify(value));\r\n } catch {\r\n // Storage unavailable (private mode, quota): the choice is simply not remembered.\r\n }\r\n}\r\n\r\nconst DARK_QUERY = \"(prefers-color-scheme: dark)\";\r\n\r\nfunction subscribeColorScheme(onChange: () => void): () => void {\r\n const media = window.matchMedia(DARK_QUERY);\r\n media.addEventListener(\"change\", onChange);\r\n return () => media.removeEventListener(\"change\", onChange);\r\n}\r\n\r\nfunction useSystemMode(): ResolvedMode {\r\n return useSyncExternalStore(\r\n subscribeColorScheme,\r\n () => (window.matchMedia(DARK_QUERY).matches ? \"dark\" : \"light\"),\r\n () => \"light\",\r\n );\r\n}\r\n\r\n/**\r\n * Optional. Sets `data-palette` and `data-mode` on `<html>` and remembers the\r\n * user's choice. Without it, the HTML attributes alone are enough: the\r\n * `system` mode is handled in CSS by the tokens.\r\n */\r\nexport function ThemeProvider({\r\n children,\r\n palette: paletteProp,\r\n defaultPalette = DEFAULT_PALETTE,\r\n onPaletteChange,\r\n mode: modeProp,\r\n defaultMode = DEFAULT_MODE,\r\n onModeChange,\r\n storageKey = DEFAULT_STORAGE_KEY,\r\n}: ThemeProviderProps) {\r\n const [paletteState, setPaletteState] = useState<Palette>(defaultPalette);\r\n const [modeState, setModeState] = useState<Mode>(defaultMode);\r\n // Stored values are read after mount so that server and client render the same tree.\r\n const [restored, setRestored] = useState(false);\r\n\r\n const palette = paletteProp ?? paletteState;\r\n const mode = modeProp ?? modeState;\r\n const systemMode = useSystemMode();\r\n const resolvedMode: ResolvedMode = mode === \"system\" ? systemMode : mode;\r\n\r\n useIsomorphicLayoutEffect(() => {\r\n if (storageKey !== null) {\r\n const stored = readStorage(storageKey);\r\n if (isPalette(stored.palette)) setPaletteState(stored.palette);\r\n if (isMode(stored.mode)) setModeState(stored.mode);\r\n }\r\n setRestored(true);\r\n }, [storageKey]);\r\n\r\n useIsomorphicLayoutEffect(() => {\r\n if (!restored) return;\r\n const root = document.documentElement;\r\n root.setAttribute(\"data-palette\", palette);\r\n root.setAttribute(\"data-mode\", mode);\r\n }, [restored, palette, mode]);\r\n\r\n // Keep several tabs in sync.\r\n useEffect(() => {\r\n if (storageKey === null) return;\r\n const onStorage = (event: StorageEvent) => {\r\n if (event.key !== storageKey) return;\r\n const stored = readStorage(storageKey);\r\n if (isPalette(stored.palette)) setPaletteState(stored.palette);\r\n if (isMode(stored.mode)) setModeState(stored.mode);\r\n };\r\n window.addEventListener(\"storage\", onStorage);\r\n return () => window.removeEventListener(\"storage\", onStorage);\r\n }, [storageKey]);\r\n\r\n const setPalette = useCallback(\r\n (next: Palette) => {\r\n if (paletteProp === undefined) setPaletteState(next);\r\n if (storageKey !== null) writeStorage(storageKey, { palette: next, mode });\r\n onPaletteChange?.(next);\r\n },\r\n [paletteProp, storageKey, mode, onPaletteChange],\r\n );\r\n\r\n const setMode = useCallback(\r\n (next: Mode) => {\r\n if (modeProp === undefined) setModeState(next);\r\n if (storageKey !== null) writeStorage(storageKey, { palette, mode: next });\r\n onModeChange?.(next);\r\n },\r\n [modeProp, storageKey, palette, onModeChange],\r\n );\r\n\r\n const value = useMemo<ThemeContextValue>(\r\n () => ({ palette, mode, resolvedMode, setPalette, setMode }),\r\n [palette, mode, resolvedMode, setPalette, setMode],\r\n );\r\n\r\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\r\n}\r\n\r\n/** Reads and changes the current theme. Must be used inside `ThemeProvider`. */\r\nexport function useTheme(): ThemeContextValue {\r\n const context = useContext(ThemeContext);\r\n if (context === null) {\r\n throw new Error(\"useTheme must be used within a <ThemeProvider>.\");\r\n }\r\n return context;\r\n}\r\n\r\nexport interface ThemeScriptProps extends ThemeScriptOptions {\r\n nonce?: string;\r\n}\r\n\r\n/** Renders the anti-flash script; place it in `<head>`. */\r\nexport function ThemeScript({ nonce, ...options }: ThemeScriptProps) {\r\n return (\r\n <script\r\n nonce={nonce}\r\n suppressHydrationWarning\r\n dangerouslySetInnerHTML={{ __html: getThemeScript(options) }}\r\n />\r\n );\r\n}\r\n","export const PALETTES = [\"nacre\", \"aurore\", \"couchant\", \"glacier\"] as const;\r\nexport const MODES = [\"light\", \"dark\", \"system\"] as const;\r\n\r\nexport type Palette = (typeof PALETTES)[number];\r\nexport type Mode = (typeof MODES)[number];\r\nexport type ResolvedMode = Exclude<Mode, \"system\">;\r\n\r\nexport const DEFAULT_PALETTE: Palette = \"nacre\";\r\nexport const DEFAULT_MODE: Mode = \"system\";\r\nexport const DEFAULT_STORAGE_KEY = \"@irisui/theme\";\r\n\r\nexport const isPalette = (value: unknown): value is Palette =>\r\n (PALETTES as readonly unknown[]).includes(value);\r\nexport const isMode = (value: unknown): value is Mode =>\r\n (MODES as readonly unknown[]).includes(value);\r\n","import {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n} from \"./constants\";\r\n\r\nexport interface ThemeScriptOptions {\r\n storageKey?: string;\r\n defaultPalette?: Palette;\r\n defaultMode?: Mode;\r\n}\r\n\r\n/**\r\n * Returns an inline script that applies the stored palette and mode to\r\n * `<html>` before the first paint, to avoid a flash of the default theme.\r\n * Optional: without it the theme still works from the HTML attributes alone.\r\n */\r\nexport function getThemeScript({\r\n storageKey = DEFAULT_STORAGE_KEY,\r\n defaultPalette = DEFAULT_PALETTE,\r\n defaultMode = DEFAULT_MODE,\r\n}: ThemeScriptOptions = {}): string {\r\n const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode]\r\n .map((arg) => JSON.stringify(arg))\r\n .join(\",\");\r\n return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||\"{}\")||{}}catch(e){}d.setAttribute(\"data-palette\",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute(\"data-mode\",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;\r\n}\r\n\r\nexport {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n type ResolvedMode,\r\n} from \"./constants\";\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAUO;;;ACVA,IAAM,WAAW,CAAC,SAAS,UAAU,YAAY,SAAS;AAC1D,IAAM,QAAQ,CAAC,SAAS,QAAQ,QAAQ;AAMxC,IAAM,kBAA2B;AACjC,IAAM,eAAqB;AAC3B,IAAM,s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S,MAAM,KAAK,CAAC;AACzE,wBAAkB,IAAI;AAAA,IACxB;AAAA,IACA,CAAC,aAAa,YAAY,MAAM,eAAe;AAAA,EACjD;AAEA,QAAM,cAAU;AAAA,IACd,CAAC,SAAe;AACd,UAAI,aAAa,OAAW,cAAa,IAAI;AAC7C,UAAI,eAAe,KAAM,cAAa,YAAY,EAAE,SAAS,MAAM,KAAK,CAAC;AACzE,qBAAe,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,UAAU,YAAY,SAAS,YAAY;AAAA,EAC9C;AAEA,QAAM,YAAQ;AAAA,IACZ,OAAO,EAAE,SAAS,MAAM,cAAc,YAAY,QAAQ;AAAA,IAC1D,CAAC,SAAS,MAAM,cAAc,YAAY,OAAO;AAAA,EACnD;AAEA,SAAO,4CAAC,aAAa,UAAb,EAAsB,OAAe,UAAS;AACxD;AAGO,SAAS,WAA8B;AAC5C,QAAM,cAAU,yBAAW,YAAY;AACvC,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,iDAAiD;AAAA,EACnE;AACA,SAAO;AACT;AAOO,SAAS,YAAY,EAAE,OAAO,GAAG,QAAQ,GAAqB;AACnE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,0BAAwB;AAAA,MACxB,yBAAyB,EAAE,QAAQ,eAAe,OAAO,EAAE;AAAA;AAAA,EAC7D;AAEJ;","names":[]}
@@ -0,0 +1,63 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare const PALETTES: readonly ["nacre", "aurore", "couchant", "glacier"];
5
+ declare const MODES: readonly ["light", "dark", "system"];
6
+ type Palette = (typeof PALETTES)[number];
7
+ type Mode = (typeof MODES)[number];
8
+ type ResolvedMode = Exclude<Mode, "system">;
9
+ declare const DEFAULT_PALETTE: Palette;
10
+ declare const DEFAULT_MODE: Mode;
11
+ declare const DEFAULT_STORAGE_KEY = "@irisui/theme";
12
+
13
+ interface ThemeScriptOptions {
14
+ storageKey?: string;
15
+ defaultPalette?: Palette;
16
+ defaultMode?: Mode;
17
+ }
18
+ /**
19
+ * Returns an inline script that applies the stored palette and mode to
20
+ * `<html>` before the first paint, to avoid a flash of the default theme.
21
+ * Optional: without it the theme still works from the HTML attributes alone.
22
+ */
23
+ declare function getThemeScript({ storageKey, defaultPalette, defaultMode, }?: ThemeScriptOptions): string;
24
+
25
+ interface ThemeContextValue {
26
+ palette: Palette;
27
+ /** Mode as chosen: `light`, `dark` or `system`. */
28
+ mode: Mode;
29
+ /** Mode actually displayed, `system` resolved through `prefers-color-scheme`. */
30
+ resolvedMode: ResolvedMode;
31
+ setPalette: (palette: Palette) => void;
32
+ setMode: (mode: Mode) => void;
33
+ }
34
+ interface ThemeProviderProps {
35
+ children?: ReactNode;
36
+ /** Controlled palette. */
37
+ palette?: Palette;
38
+ /** Initial palette when uncontrolled and nothing is stored. */
39
+ defaultPalette?: Palette;
40
+ onPaletteChange?: (palette: Palette) => void;
41
+ /** Controlled mode. */
42
+ mode?: Mode;
43
+ /** Initial mode when uncontrolled and nothing is stored. */
44
+ defaultMode?: Mode;
45
+ onModeChange?: (mode: Mode) => void;
46
+ /** localStorage key used to remember the user's choice. `null` disables persistence. */
47
+ storageKey?: string | null;
48
+ }
49
+ /**
50
+ * Optional. Sets `data-palette` and `data-mode` on `<html>` and remembers the
51
+ * user's choice. Without it, the HTML attributes alone are enough: the
52
+ * `system` mode is handled in CSS by the tokens.
53
+ */
54
+ declare function ThemeProvider({ children, palette: paletteProp, defaultPalette, onPaletteChange, mode: modeProp, defaultMode, onModeChange, storageKey, }: ThemeProviderProps): react.JSX.Element;
55
+ /** Reads and changes the current theme. Must be used inside `ThemeProvider`. */
56
+ declare function useTheme(): ThemeContextValue;
57
+ interface ThemeScriptProps extends ThemeScriptOptions {
58
+ nonce?: string;
59
+ }
60
+ /** Renders the anti-flash script; place it in `<head>`. */
61
+ declare function ThemeScript({ nonce, ...options }: ThemeScriptProps): react.JSX.Element;
62
+
63
+ export { DEFAULT_MODE, DEFAULT_PALETTE, DEFAULT_STORAGE_KEY, MODES, type Mode, PALETTES, type Palette, type ResolvedMode, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, ThemeScript, type ThemeScriptOptions, type ThemeScriptProps, getThemeScript, useTheme };
@@ -0,0 +1,63 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare const PALETTES: readonly ["nacre", "aurore", "couchant", "glacier"];
5
+ declare const MODES: readonly ["light", "dark", "system"];
6
+ type Palette = (typeof PALETTES)[number];
7
+ type Mode = (typeof MODES)[number];
8
+ type ResolvedMode = Exclude<Mode, "system">;
9
+ declare const DEFAULT_PALETTE: Palette;
10
+ declare const DEFAULT_MODE: Mode;
11
+ declare const DEFAULT_STORAGE_KEY = "@irisui/theme";
12
+
13
+ interface ThemeScriptOptions {
14
+ storageKey?: string;
15
+ defaultPalette?: Palette;
16
+ defaultMode?: Mode;
17
+ }
18
+ /**
19
+ * Returns an inline script that applies the stored palette and mode to
20
+ * `<html>` before the first paint, to avoid a flash of the default theme.
21
+ * Optional: without it the theme still works from the HTML attributes alone.
22
+ */
23
+ declare function getThemeScript({ storageKey, defaultPalette, defaultMode, }?: ThemeScriptOptions): string;
24
+
25
+ interface ThemeContextValue {
26
+ palette: Palette;
27
+ /** Mode as chosen: `light`, `dark` or `system`. */
28
+ mode: Mode;
29
+ /** Mode actually displayed, `system` resolved through `prefers-color-scheme`. */
30
+ resolvedMode: ResolvedMode;
31
+ setPalette: (palette: Palette) => void;
32
+ setMode: (mode: Mode) => void;
33
+ }
34
+ interface ThemeProviderProps {
35
+ children?: ReactNode;
36
+ /** Controlled palette. */
37
+ palette?: Palette;
38
+ /** Initial palette when uncontrolled and nothing is stored. */
39
+ defaultPalette?: Palette;
40
+ onPaletteChange?: (palette: Palette) => void;
41
+ /** Controlled mode. */
42
+ mode?: Mode;
43
+ /** Initial mode when uncontrolled and nothing is stored. */
44
+ defaultMode?: Mode;
45
+ onModeChange?: (mode: Mode) => void;
46
+ /** localStorage key used to remember the user's choice. `null` disables persistence. */
47
+ storageKey?: string | null;
48
+ }
49
+ /**
50
+ * Optional. Sets `data-palette` and `data-mode` on `<html>` and remembers the
51
+ * user's choice. Without it, the HTML attributes alone are enough: the
52
+ * `system` mode is handled in CSS by the tokens.
53
+ */
54
+ declare function ThemeProvider({ children, palette: paletteProp, defaultPalette, onPaletteChange, mode: modeProp, defaultMode, onModeChange, storageKey, }: ThemeProviderProps): react.JSX.Element;
55
+ /** Reads and changes the current theme. Must be used inside `ThemeProvider`. */
56
+ declare function useTheme(): ThemeContextValue;
57
+ interface ThemeScriptProps extends ThemeScriptOptions {
58
+ nonce?: string;
59
+ }
60
+ /** Renders the anti-flash script; place it in `<head>`. */
61
+ declare function ThemeScript({ nonce, ...options }: ThemeScriptProps): react.JSX.Element;
62
+
63
+ export { DEFAULT_MODE, DEFAULT_PALETTE, DEFAULT_STORAGE_KEY, MODES, type Mode, PALETTES, type Palette, type ResolvedMode, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, ThemeScript, type ThemeScriptOptions, type ThemeScriptProps, getThemeScript, useTheme };
package/dist/index.js ADDED
@@ -0,0 +1,157 @@
1
+ "use client";
2
+
3
+ // src/theme/theme-provider.tsx
4
+ import {
5
+ createContext,
6
+ useCallback,
7
+ useContext,
8
+ useEffect,
9
+ useLayoutEffect,
10
+ useMemo,
11
+ useState,
12
+ useSyncExternalStore
13
+ } from "react";
14
+
15
+ // src/theme/constants.ts
16
+ var PALETTES = ["nacre", "aurore", "couchant", "glacier"];
17
+ var MODES = ["light", "dark", "system"];
18
+ var DEFAULT_PALETTE = "nacre";
19
+ var DEFAULT_MODE = "system";
20
+ var DEFAULT_STORAGE_KEY = "@irisui/theme";
21
+ var isPalette = (value) => PALETTES.includes(value);
22
+ var isMode = (value) => MODES.includes(value);
23
+
24
+ // src/theme/theme-script.ts
25
+ function getThemeScript({
26
+ storageKey = DEFAULT_STORAGE_KEY,
27
+ defaultPalette = DEFAULT_PALETTE,
28
+ defaultMode = DEFAULT_MODE
29
+ } = {}) {
30
+ const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode].map((arg) => JSON.stringify(arg)).join(",");
31
+ return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||"{}")||{}}catch(e){}d.setAttribute("data-palette",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute("data-mode",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;
32
+ }
33
+
34
+ // src/theme/theme-provider.tsx
35
+ import { jsx } from "react/jsx-runtime";
36
+ var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
37
+ var ThemeContext = createContext(null);
38
+ function readStorage(key) {
39
+ try {
40
+ const parsed = JSON.parse(window.localStorage.getItem(key) ?? "{}");
41
+ return parsed && typeof parsed === "object" ? parsed : {};
42
+ } catch {
43
+ return {};
44
+ }
45
+ }
46
+ function writeStorage(key, value) {
47
+ try {
48
+ window.localStorage.setItem(key, JSON.stringify(value));
49
+ } catch {
50
+ }
51
+ }
52
+ var DARK_QUERY = "(prefers-color-scheme: dark)";
53
+ function subscribeColorScheme(onChange) {
54
+ const media = window.matchMedia(DARK_QUERY);
55
+ media.addEventListener("change", onChange);
56
+ return () => media.removeEventListener("change", onChange);
57
+ }
58
+ function useSystemMode() {
59
+ return useSyncExternalStore(
60
+ subscribeColorScheme,
61
+ () => window.matchMedia(DARK_QUERY).matches ? "dark" : "light",
62
+ () => "light"
63
+ );
64
+ }
65
+ function ThemeProvider({
66
+ children,
67
+ palette: paletteProp,
68
+ defaultPalette = DEFAULT_PALETTE,
69
+ onPaletteChange,
70
+ mode: modeProp,
71
+ defaultMode = DEFAULT_MODE,
72
+ onModeChange,
73
+ storageKey = DEFAULT_STORAGE_KEY
74
+ }) {
75
+ const [paletteState, setPaletteState] = useState(defaultPalette);
76
+ const [modeState, setModeState] = useState(defaultMode);
77
+ const [restored, setRestored] = useState(false);
78
+ const palette = paletteProp ?? paletteState;
79
+ const mode = modeProp ?? modeState;
80
+ const systemMode = useSystemMode();
81
+ const resolvedMode = mode === "system" ? systemMode : mode;
82
+ useIsomorphicLayoutEffect(() => {
83
+ if (storageKey !== null) {
84
+ const stored = readStorage(storageKey);
85
+ if (isPalette(stored.palette)) setPaletteState(stored.palette);
86
+ if (isMode(stored.mode)) setModeState(stored.mode);
87
+ }
88
+ setRestored(true);
89
+ }, [storageKey]);
90
+ useIsomorphicLayoutEffect(() => {
91
+ if (!restored) return;
92
+ const root = document.documentElement;
93
+ root.setAttribute("data-palette", palette);
94
+ root.setAttribute("data-mode", mode);
95
+ }, [restored, palette, mode]);
96
+ useEffect(() => {
97
+ if (storageKey === null) return;
98
+ const onStorage = (event) => {
99
+ if (event.key !== storageKey) return;
100
+ const stored = readStorage(storageKey);
101
+ if (isPalette(stored.palette)) setPaletteState(stored.palette);
102
+ if (isMode(stored.mode)) setModeState(stored.mode);
103
+ };
104
+ window.addEventListener("storage", onStorage);
105
+ return () => window.removeEventListener("storage", onStorage);
106
+ }, [storageKey]);
107
+ const setPalette = useCallback(
108
+ (next) => {
109
+ if (paletteProp === void 0) setPaletteState(next);
110
+ if (storageKey !== null) writeStorage(storageKey, { palette: next, mode });
111
+ onPaletteChange?.(next);
112
+ },
113
+ [paletteProp, storageKey, mode, onPaletteChange]
114
+ );
115
+ const setMode = useCallback(
116
+ (next) => {
117
+ if (modeProp === void 0) setModeState(next);
118
+ if (storageKey !== null) writeStorage(storageKey, { palette, mode: next });
119
+ onModeChange?.(next);
120
+ },
121
+ [modeProp, storageKey, palette, onModeChange]
122
+ );
123
+ const value = useMemo(
124
+ () => ({ palette, mode, resolvedMode, setPalette, setMode }),
125
+ [palette, mode, resolvedMode, setPalette, setMode]
126
+ );
127
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
128
+ }
129
+ function useTheme() {
130
+ const context = useContext(ThemeContext);
131
+ if (context === null) {
132
+ throw new Error("useTheme must be used within a <ThemeProvider>.");
133
+ }
134
+ return context;
135
+ }
136
+ function ThemeScript({ nonce, ...options }) {
137
+ return /* @__PURE__ */ jsx(
138
+ "script",
139
+ {
140
+ nonce,
141
+ suppressHydrationWarning: true,
142
+ dangerouslySetInnerHTML: { __html: getThemeScript(options) }
143
+ }
144
+ );
145
+ }
146
+ export {
147
+ DEFAULT_MODE,
148
+ DEFAULT_PALETTE,
149
+ DEFAULT_STORAGE_KEY,
150
+ MODES,
151
+ PALETTES,
152
+ ThemeProvider,
153
+ ThemeScript,
154
+ getThemeScript,
155
+ useTheme
156
+ };
157
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/theme/theme-provider.tsx","../src/theme/constants.ts","../src/theme/theme-script.ts"],"sourcesContent":["import {\r\n createContext,\r\n useCallback,\r\n useContext,\r\n useEffect,\r\n useLayoutEffect,\r\n useMemo,\r\n useState,\r\n useSyncExternalStore,\r\n type ReactNode,\r\n} from \"react\";\r\nimport {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n isMode,\r\n isPalette,\r\n type Mode,\r\n type Palette,\r\n type ResolvedMode,\r\n} from \"./constants\";\r\nimport { getThemeScript, type ThemeScriptOptions } from \"./theme-script\";\r\n\r\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\r\n\r\nexport interface ThemeContextValue {\r\n palette: Palette;\r\n /** Mode as chosen: `light`, `dark` or `system`. */\r\n mode: Mode;\r\n /** Mode actually displayed, `system` resolved through `prefers-color-scheme`. */\r\n resolvedMode: ResolvedMode;\r\n setPalette: (palette: Palette) => void;\r\n setMode: (mode: Mode) => void;\r\n}\r\n\r\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\r\n\r\nexport interface ThemeProviderProps {\r\n children?: ReactNode;\r\n /** Controlled palette. */\r\n palette?: Palette;\r\n /** Initial palette when uncontrolled and nothing is stored. */\r\n defaultPalette?: Palette;\r\n onPaletteChange?: (palette: Palette) => void;\r\n /** Controlled mode. */\r\n mode?: Mode;\r\n /** Initial mode when uncontrolled and nothing is stored. */\r\n defaultMode?: Mode;\r\n onModeChange?: (mode: Mode) => void;\r\n /** localStorage key used to remember the user's choice. `null` disables persistence. */\r\n storageKey?: string | null;\r\n}\r\n\r\ninterface StoredTheme {\r\n palette?: unknown;\r\n mode?: unknown;\r\n}\r\n\r\nfunction readStorage(key: string): StoredTheme {\r\n try {\r\n const parsed: unknown = JSON.parse(window.localStorage.getItem(key) ?? \"{}\");\r\n return parsed && typeof parsed === \"object\" ? (parsed as StoredTheme) : {};\r\n } catch {\r\n return {};\r\n }\r\n}\r\n\r\nfunction writeStorage(key: string, value: { palette: Palette; mode: Mode }): void {\r\n try {\r\n window.localStorage.setItem(key, JSON.stringify(value));\r\n } catch {\r\n // Storage unavailable (private mode, quota): the choice is simply not remembered.\r\n }\r\n}\r\n\r\nconst DARK_QUERY = \"(prefers-color-scheme: dark)\";\r\n\r\nfunction subscribeColorScheme(onChange: () => void): () => void {\r\n const media = window.matchMedia(DARK_QUERY);\r\n media.addEventListener(\"change\", onChange);\r\n return () => media.removeEventListener(\"change\", onChange);\r\n}\r\n\r\nfunction useSystemMode(): ResolvedMode {\r\n return useSyncExternalStore(\r\n subscribeColorScheme,\r\n () => (window.matchMedia(DARK_QUERY).matches ? \"dark\" : \"light\"),\r\n () => \"light\",\r\n );\r\n}\r\n\r\n/**\r\n * Optional. Sets `data-palette` and `data-mode` on `<html>` and remembers the\r\n * user's choice. Without it, the HTML attributes alone are enough: the\r\n * `system` mode is handled in CSS by the tokens.\r\n */\r\nexport function ThemeProvider({\r\n children,\r\n palette: paletteProp,\r\n defaultPalette = DEFAULT_PALETTE,\r\n onPaletteChange,\r\n mode: modeProp,\r\n defaultMode = DEFAULT_MODE,\r\n onModeChange,\r\n storageKey = DEFAULT_STORAGE_KEY,\r\n}: ThemeProviderProps) {\r\n const [paletteState, setPaletteState] = useState<Palette>(defaultPalette);\r\n const [modeState, setModeState] = useState<Mode>(defaultMode);\r\n // Stored values are read after mount so that server and client render the same tree.\r\n const [restored, setRestored] = useState(false);\r\n\r\n const palette = paletteProp ?? paletteState;\r\n const mode = modeProp ?? modeState;\r\n const systemMode = useSystemMode();\r\n const resolvedMode: ResolvedMode = mode === \"system\" ? systemMode : mode;\r\n\r\n useIsomorphicLayoutEffect(() => {\r\n if (storageKey !== null) {\r\n const stored = readStorage(storageKey);\r\n if (isPalette(stored.palette)) setPaletteState(stored.palette);\r\n if (isMode(stored.mode)) setModeState(stored.mode);\r\n }\r\n setRestored(true);\r\n }, [storageKey]);\r\n\r\n useIsomorphicLayoutEffect(() => {\r\n if (!restored) return;\r\n const root = document.documentElement;\r\n root.setAttribute(\"data-palette\", palette);\r\n root.setAttribute(\"data-mode\", mode);\r\n }, [restored, palette, mode]);\r\n\r\n // Keep several tabs in sync.\r\n useEffect(() => {\r\n if (storageKey === null) return;\r\n const onStorage = (event: StorageEvent) => {\r\n if (event.key !== storageKey) return;\r\n const stored = readStorage(storageKey);\r\n if (isPalette(stored.palette)) setPaletteState(stored.palette);\r\n if (isMode(stored.mode)) setModeState(stored.mode);\r\n };\r\n window.addEventListener(\"storage\", onStorage);\r\n return () => window.removeEventListener(\"storage\", onStorage);\r\n }, [storageKey]);\r\n\r\n const setPalette = useCallback(\r\n (next: Palette) => {\r\n if (paletteProp === undefined) setPaletteState(next);\r\n if (storageKey !== null) writeStorage(storageKey, { palette: next, mode });\r\n onPaletteChange?.(next);\r\n },\r\n [paletteProp, storageKey, mode, onPaletteChange],\r\n );\r\n\r\n const setMode = useCallback(\r\n (next: Mode) => {\r\n if (modeProp === undefined) setModeState(next);\r\n if (storageKey !== null) writeStorage(storageKey, { palette, mode: next });\r\n onModeChange?.(next);\r\n },\r\n [modeProp, storageKey, palette, onModeChange],\r\n );\r\n\r\n const value = useMemo<ThemeContextValue>(\r\n () => ({ palette, mode, resolvedMode, setPalette, setMode }),\r\n [palette, mode, resolvedMode, setPalette, setMode],\r\n );\r\n\r\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\r\n}\r\n\r\n/** Reads and changes the current theme. Must be used inside `ThemeProvider`. */\r\nexport function useTheme(): ThemeContextValue {\r\n const context = useContext(ThemeContext);\r\n if (context === null) {\r\n throw new Error(\"useTheme must be used within a <ThemeProvider>.\");\r\n }\r\n return context;\r\n}\r\n\r\nexport interface ThemeScriptProps extends ThemeScriptOptions {\r\n nonce?: string;\r\n}\r\n\r\n/** Renders the anti-flash script; place it in `<head>`. */\r\nexport function ThemeScript({ nonce, ...options }: ThemeScriptProps) {\r\n return (\r\n <script\r\n nonce={nonce}\r\n suppressHydrationWarning\r\n dangerouslySetInnerHTML={{ __html: getThemeScript(options) }}\r\n />\r\n );\r\n}\r\n","export const PALETTES = [\"nacre\", \"aurore\", \"couchant\", \"glacier\"] as const;\r\nexport const MODES = [\"light\", \"dark\", \"system\"] as const;\r\n\r\nexport type Palette = (typeof PALETTES)[number];\r\nexport type Mode = (typeof MODES)[number];\r\nexport type ResolvedMode = Exclude<Mode, \"system\">;\r\n\r\nexport const DEFAULT_PALETTE: Palette = \"nacre\";\r\nexport const DEFAULT_MODE: Mode = \"system\";\r\nexport const DEFAULT_STORAGE_KEY = \"@irisui/theme\";\r\n\r\nexport const isPalette = (value: unknown): value is Palette =>\r\n (PALETTES as readonly unknown[]).includes(value);\r\nexport const isMode = (value: unknown): value is Mode =>\r\n (MODES as readonly unknown[]).includes(value);\r\n","import {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n} from \"./constants\";\r\n\r\nexport interface ThemeScriptOptions {\r\n storageKey?: string;\r\n defaultPalette?: Palette;\r\n defaultMode?: Mode;\r\n}\r\n\r\n/**\r\n * Returns an inline script that applies the stored palette and mode to\r\n * `<html>` before the first paint, to avoid a flash of the default theme.\r\n * Optional: without it the theme still works from the HTML attributes alone.\r\n */\r\nexport function getThemeScript({\r\n storageKey = DEFAULT_STORAGE_KEY,\r\n defaultPalette = DEFAULT_PALETTE,\r\n defaultMode = DEFAULT_MODE,\r\n}: ThemeScriptOptions = {}): string {\r\n const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode]\r\n .map((arg) => JSON.stringify(arg))\r\n .join(\",\");\r\n return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||\"{}\")||{}}catch(e){}d.setAttribute(\"data-palette\",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute(\"data-mode\",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;\r\n}\r\n\r\nexport {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n type ResolvedMode,\r\n} from \"./constants\";\r\n"],"mappings":";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACVA,IAAM,WAAW,CAAC,SAAS,UAAU,YAAY,SAAS;AAC1D,IAAM,QAAQ,CAAC,SAAS,QAAQ,QAAQ;AAMxC,IAAM,kBAA2B;AACjC,IAAM,eAAqB;AAC3B,IAAM,sBAAsB;AAE5B,IAAM,YAAY,CAAC,UACvB,SAAgC,SAAS,KAAK;AAC1C,IAAM,SAAS,CAAC,UACpB,MAA6B,SAAS,KAAK;;;ACOvC,SAAS,eAAe;AAAA,EAC7B,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,cAAc;AAChB,IAAwB,CAAC,GAAW;AAClC,QAAM,OAAO,CAAC,YAAY,UAAU,OAAO,gBAAgB,WAAW,EACnE,IAAI,CAAC,QAAQ,KAAK,UAAU,GAAG,CAAC,EAChC,KAAK,GAAG;AACX,SAAO,6PAA6P,IAAI;AAC1Q;;;AF0IS;AAjJT,IAAM,4BAA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;AAAA,IAC1D,CAAC,SAAS,MAAM,cAAc,YAAY,OAAO;AAAA,EACnD;AAEA,SAAO,oBAAC,aAAa,UAAb,EAAsB,OAAe,UAAS;AACxD;AAGO,SAAS,WAA8B;AAC5C,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,iDAAiD;AAAA,EACnE;AACA,SAAO;AACT;AAOO,SAAS,YAAY,EAAE,OAAO,GAAG,QAAQ,GAAqB;AACnE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,0BAAwB;AAAA,MACxB,yBAAyB,EAAE,QAAQ,eAAe,OAAO,EAAE;AAAA;AAAA,EAC7D;AAEJ;","names":[]}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/theme/theme-script.ts
21
+ var theme_script_exports = {};
22
+ __export(theme_script_exports, {
23
+ DEFAULT_MODE: () => DEFAULT_MODE,
24
+ DEFAULT_PALETTE: () => DEFAULT_PALETTE,
25
+ DEFAULT_STORAGE_KEY: () => DEFAULT_STORAGE_KEY,
26
+ MODES: () => MODES,
27
+ PALETTES: () => PALETTES,
28
+ getThemeScript: () => getThemeScript
29
+ });
30
+ module.exports = __toCommonJS(theme_script_exports);
31
+
32
+ // src/theme/constants.ts
33
+ var PALETTES = ["nacre", "aurore", "couchant", "glacier"];
34
+ var MODES = ["light", "dark", "system"];
35
+ var DEFAULT_PALETTE = "nacre";
36
+ var DEFAULT_MODE = "system";
37
+ var DEFAULT_STORAGE_KEY = "@irisui/theme";
38
+
39
+ // src/theme/theme-script.ts
40
+ function getThemeScript({
41
+ storageKey = DEFAULT_STORAGE_KEY,
42
+ defaultPalette = DEFAULT_PALETTE,
43
+ defaultMode = DEFAULT_MODE
44
+ } = {}) {
45
+ const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode].map((arg) => JSON.stringify(arg)).join(",");
46
+ return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||"{}")||{}}catch(e){}d.setAttribute("data-palette",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute("data-mode",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ DEFAULT_MODE,
51
+ DEFAULT_PALETTE,
52
+ DEFAULT_STORAGE_KEY,
53
+ MODES,
54
+ PALETTES,
55
+ getThemeScript
56
+ });
57
+ //# sourceMappingURL=theme-script.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/theme/theme-script.ts","../src/theme/constants.ts"],"sourcesContent":["import {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n} from \"./constants\";\r\n\r\nexport interface ThemeScriptOptions {\r\n storageKey?: string;\r\n defaultPalette?: Palette;\r\n defaultMode?: Mode;\r\n}\r\n\r\n/**\r\n * Returns an inline script that applies the stored palette and mode to\r\n * `<html>` before the first paint, to avoid a flash of the default theme.\r\n * Optional: without it the theme still works from the HTML attributes alone.\r\n */\r\nexport function getThemeScript({\r\n storageKey = DEFAULT_STORAGE_KEY,\r\n defaultPalette = DEFAULT_PALETTE,\r\n defaultMode = DEFAULT_MODE,\r\n}: ThemeScriptOptions = {}): string {\r\n const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode]\r\n .map((arg) => JSON.stringify(arg))\r\n .join(\",\");\r\n return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||\"{}\")||{}}catch(e){}d.setAttribute(\"data-palette\",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute(\"data-mode\",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;\r\n}\r\n\r\nexport {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n type ResolvedMode,\r\n} from \"./constants\";\r\n","export const PALETTES = [\"nacre\", \"aurore\", \"couchant\", \"glacier\"] as const;\r\nexport const MODES = [\"light\", \"dark\", \"system\"] as const;\r\n\r\nexport type Palette = (typeof PALETTES)[number];\r\nexport type Mode = (typeof MODES)[number];\r\nexport type ResolvedMode = Exclude<Mode, \"system\">;\r\n\r\nexport const DEFAULT_PALETTE: Palette = \"nacre\";\r\nexport const DEFAULT_MODE: Mode = \"system\";\r\nexport const DEFAULT_STORAGE_KEY = \"@irisui/theme\";\r\n\r\nexport const isPalette = (value: unknown): value is Palette =>\r\n (PALETTES as readonly unknown[]).includes(value);\r\nexport const isMode = (value: unknown): value is Mode =>\r\n (MODES as readonly unknown[]).includes(value);\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAW,CAAC,SAAS,UAAU,YAAY,SAAS;AAC1D,IAAM,QAAQ,CAAC,SAAS,QAAQ,QAAQ;AAMxC,IAAM,kBAA2B;AACjC,IAAM,eAAqB;AAC3B,IAAM,sBAAsB;;;ADY5B,SAAS,eAAe;AAAA,EAC7B,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,cAAc;AAChB,IAAwB,CAAC,GAAW;AAClC,QAAM,OAAO,CAAC,YAAY,UAAU,OAAO,gBAAgB,WAAW,EACnE,IAAI,CAAC,QAAQ,KAAK,UAAU,GAAG,CAAC,EAChC,KAAK,GAAG;AACX,SAAO,6PAA6P,IAAI;AAC1Q;","names":[]}
@@ -0,0 +1,22 @@
1
+ declare const PALETTES: readonly ["nacre", "aurore", "couchant", "glacier"];
2
+ declare const MODES: readonly ["light", "dark", "system"];
3
+ type Palette = (typeof PALETTES)[number];
4
+ type Mode = (typeof MODES)[number];
5
+ type ResolvedMode = Exclude<Mode, "system">;
6
+ declare const DEFAULT_PALETTE: Palette;
7
+ declare const DEFAULT_MODE: Mode;
8
+ declare const DEFAULT_STORAGE_KEY = "@irisui/theme";
9
+
10
+ interface ThemeScriptOptions {
11
+ storageKey?: string;
12
+ defaultPalette?: Palette;
13
+ defaultMode?: Mode;
14
+ }
15
+ /**
16
+ * Returns an inline script that applies the stored palette and mode to
17
+ * `<html>` before the first paint, to avoid a flash of the default theme.
18
+ * Optional: without it the theme still works from the HTML attributes alone.
19
+ */
20
+ declare function getThemeScript({ storageKey, defaultPalette, defaultMode, }?: ThemeScriptOptions): string;
21
+
22
+ export { DEFAULT_MODE, DEFAULT_PALETTE, DEFAULT_STORAGE_KEY, MODES, type Mode, PALETTES, type Palette, type ResolvedMode, type ThemeScriptOptions, getThemeScript };
@@ -0,0 +1,22 @@
1
+ declare const PALETTES: readonly ["nacre", "aurore", "couchant", "glacier"];
2
+ declare const MODES: readonly ["light", "dark", "system"];
3
+ type Palette = (typeof PALETTES)[number];
4
+ type Mode = (typeof MODES)[number];
5
+ type ResolvedMode = Exclude<Mode, "system">;
6
+ declare const DEFAULT_PALETTE: Palette;
7
+ declare const DEFAULT_MODE: Mode;
8
+ declare const DEFAULT_STORAGE_KEY = "@irisui/theme";
9
+
10
+ interface ThemeScriptOptions {
11
+ storageKey?: string;
12
+ defaultPalette?: Palette;
13
+ defaultMode?: Mode;
14
+ }
15
+ /**
16
+ * Returns an inline script that applies the stored palette and mode to
17
+ * `<html>` before the first paint, to avoid a flash of the default theme.
18
+ * Optional: without it the theme still works from the HTML attributes alone.
19
+ */
20
+ declare function getThemeScript({ storageKey, defaultPalette, defaultMode, }?: ThemeScriptOptions): string;
21
+
22
+ export { DEFAULT_MODE, DEFAULT_PALETTE, DEFAULT_STORAGE_KEY, MODES, type Mode, PALETTES, type Palette, type ResolvedMode, type ThemeScriptOptions, getThemeScript };
@@ -0,0 +1,25 @@
1
+ // src/theme/constants.ts
2
+ var PALETTES = ["nacre", "aurore", "couchant", "glacier"];
3
+ var MODES = ["light", "dark", "system"];
4
+ var DEFAULT_PALETTE = "nacre";
5
+ var DEFAULT_MODE = "system";
6
+ var DEFAULT_STORAGE_KEY = "@irisui/theme";
7
+
8
+ // src/theme/theme-script.ts
9
+ function getThemeScript({
10
+ storageKey = DEFAULT_STORAGE_KEY,
11
+ defaultPalette = DEFAULT_PALETTE,
12
+ defaultMode = DEFAULT_MODE
13
+ } = {}) {
14
+ const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode].map((arg) => JSON.stringify(arg)).join(",");
15
+ return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||"{}")||{}}catch(e){}d.setAttribute("data-palette",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute("data-mode",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;
16
+ }
17
+ export {
18
+ DEFAULT_MODE,
19
+ DEFAULT_PALETTE,
20
+ DEFAULT_STORAGE_KEY,
21
+ MODES,
22
+ PALETTES,
23
+ getThemeScript
24
+ };
25
+ //# sourceMappingURL=theme-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/theme/constants.ts","../src/theme/theme-script.ts"],"sourcesContent":["export const PALETTES = [\"nacre\", \"aurore\", \"couchant\", \"glacier\"] as const;\r\nexport const MODES = [\"light\", \"dark\", \"system\"] as const;\r\n\r\nexport type Palette = (typeof PALETTES)[number];\r\nexport type Mode = (typeof MODES)[number];\r\nexport type ResolvedMode = Exclude<Mode, \"system\">;\r\n\r\nexport const DEFAULT_PALETTE: Palette = \"nacre\";\r\nexport const DEFAULT_MODE: Mode = \"system\";\r\nexport const DEFAULT_STORAGE_KEY = \"@irisui/theme\";\r\n\r\nexport const isPalette = (value: unknown): value is Palette =>\r\n (PALETTES as readonly unknown[]).includes(value);\r\nexport const isMode = (value: unknown): value is Mode =>\r\n (MODES as readonly unknown[]).includes(value);\r\n","import {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n} from \"./constants\";\r\n\r\nexport interface ThemeScriptOptions {\r\n storageKey?: string;\r\n defaultPalette?: Palette;\r\n defaultMode?: Mode;\r\n}\r\n\r\n/**\r\n * Returns an inline script that applies the stored palette and mode to\r\n * `<html>` before the first paint, to avoid a flash of the default theme.\r\n * Optional: without it the theme still works from the HTML attributes alone.\r\n */\r\nexport function getThemeScript({\r\n storageKey = DEFAULT_STORAGE_KEY,\r\n defaultPalette = DEFAULT_PALETTE,\r\n defaultMode = DEFAULT_MODE,\r\n}: ThemeScriptOptions = {}): string {\r\n const args = [storageKey, PALETTES, MODES, defaultPalette, defaultMode]\r\n .map((arg) => JSON.stringify(arg))\r\n .join(\",\");\r\n return `(function(k,P,M,dp,dm){var d=document.documentElement,s={};try{s=JSON.parse(localStorage.getItem(k)||\"{}\")||{}}catch(e){}d.setAttribute(\"data-palette\",P.indexOf(s.palette)>-1?s.palette:dp);d.setAttribute(\"data-mode\",M.indexOf(s.mode)>-1?s.mode:dm)})(${args})`;\r\n}\r\n\r\nexport {\r\n DEFAULT_MODE,\r\n DEFAULT_PALETTE,\r\n DEFAULT_STORAGE_KEY,\r\n MODES,\r\n PALETTES,\r\n type Mode,\r\n type Palette,\r\n type ResolvedMode,\r\n} from \"./constants\";\r\n"],"mappings":";AAAO,IAAM,WAAW,CAAC,SAAS,UAAU,YAAY,SAAS;AAC1D,IAAM,QAAQ,CAAC,SAAS,QAAQ,QAAQ;AAMxC,IAAM,kBAA2B;AACjC,IAAM,eAAqB;AAC3B,IAAM,sBAAsB;;;ACY5B,SAAS,eAAe;AAAA,EAC7B,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,cAAc;AAChB,IAAwB,CAAC,GAAW;AAClC,QAAM,OAAO,CAAC,YAAY,UAAU,OAAO,gBAAgB,WAAW,EACnE,IAAI,CAAC,QAAQ,KAAK,UAAU,GAAG,CAAC,EAChC,KAAK,GAAG;AACX,SAAO,6PAA6P,IAAI;AAC1Q;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@irisui/ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Accessible React components in the Verre irisé style.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.cts",
22
+ "default": "./dist/index.cjs"
23
+ }
24
+ },
25
+ "./theme-script": {
26
+ "import": {
27
+ "types": "./dist/theme-script.d.ts",
28
+ "default": "./dist/theme-script.js"
29
+ },
30
+ "require": {
31
+ "types": "./dist/theme-script.d.cts",
32
+ "default": "./dist/theme-script.cjs"
33
+ }
34
+ }
35
+ },
36
+ "dependencies": {
37
+ "@irisui/utils": "0.1.0",
38
+ "@irisui/tokens": "0.1.0"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^18.2.0 || ^19.0.0",
42
+ "react-dom": "^18.2.0 || ^19.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/react": "19.3.0",
46
+ "@types/react-dom": "19.3.0",
47
+ "react": "19.3.0",
48
+ "react-dom": "19.3.0"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/theteqlab/iris-ui.git",
56
+ "directory": "packages/ui"
57
+ },
58
+ "homepage": "https://github.com/theteqlab/iris-ui#readme",
59
+ "bugs": {
60
+ "url": "https://github.com/theteqlab/iris-ui/issues"
61
+ },
62
+ "scripts": {
63
+ "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsup",
64
+ "dev": "tsup --watch",
65
+ "typecheck": "tsc -p tsconfig.json"
66
+ }
6
67
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.