@logicplanes/kaeso-ui 0.7.5 → 0.7.6

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.
@@ -1,6 +1,6 @@
1
1
  # @logicplanes/kaeso-ui component guides
2
2
 
3
- Version 0.7.5. Generated from the showcase's demo modules (apps/showcase/src/demos); do not edit. For each component: what it is for, its import, keyboard, accessibility, do and don't, and every example's code. Props and variants: `component-registry.md`.
3
+ Version 0.7.6. Generated from the showcase's demo modules (apps/showcase/src/demos); do not edit. For each component: what it is for, its import, keyboard, accessibility, do and don't, and every example's code. Props and variants: `component-registry.md`.
4
4
 
5
5
  ## AlertDialog
6
6
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@logicplanes/kaeso-ui",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "components": [
5
5
  {
6
6
  "entry": "app-frame",
@@ -1,6 +1,6 @@
1
1
  # @logicplanes/kaeso-ui component registry
2
2
 
3
- Version 0.7.5. Generated from the component types, their descriptions and variants; do not edit.
3
+ Version 0.7.6. Generated from the component types, their descriptions and variants; do not edit.
4
4
 
5
5
  ## app-frame
6
6
 
package/ai/icons.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Icon vocabulary
2
2
 
3
- Version 0.7.5. Generated from `src/icons/vocabulary.ts`; do not edit. Use the name, never an icon picked by look: `icons.key` always means a key. Octicons. Rules: `foundations/icons.md`.
3
+ Version 0.7.6. Generated from `src/icons/vocabulary.ts`; do not edit. Use the name, never an icon picked by look: `icons.key` always means a key. Octicons. Rules: `foundations/icons.md`.
4
4
 
5
5
  ## Kaeso objects
6
6
 
package/ai/tokens.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @logicplanes/kaeso-ui tokens
2
2
 
3
- Version 0.7.5. Generated from `@logicplanes/kaeso-tokens`; do not edit. Components use these through role names (`bg-panel`, `text-fg-secondary`, `h-36`, `rounded-pill`); a raw value never appears in a component. How to use them: `foundations/*.md`.
3
+ Version 0.7.6. Generated from `@logicplanes/kaeso-tokens`; do not edit. Components use these through role names (`bg-panel`, `text-fg-secondary`, `h-36`, `rounded-pill`); a raw value never appears in a component. How to use them: `foundations/*.md`.
4
4
 
5
5
  ## Neutrals
6
6
 
@@ -2,7 +2,7 @@
2
2
  import { DeviceDesktop as e } from "../icons/device-desktop.js";
3
3
  import { Sun as t } from "../icons/sun.js";
4
4
  import { Moon as n } from "../icons/moon.js";
5
- import { a as r } from "./theme-provider-DaD8hlXu.js";
5
+ import { a as r } from "./theme-provider-CD0AF5UZ.js";
6
6
  import { n as i } from "./button-CXdEDVSI.js";
7
7
  import { o as a } from "./menu-CKlz_Dp4.js";
8
8
  import { r as o } from "./segmented-UnR1L-kk.js";
@@ -78,4 +78,4 @@ var d = { variant: {
78
78
  process.env.NODE_ENV !== "production" && (p.displayName = "ThemeMenu");
79
79
  export { d as n, p as r, f as t };
80
80
 
81
- //# sourceMappingURL=theme-menu-Bm8d9ooS.js.map
81
+ //# sourceMappingURL=theme-menu-Tdl7fdTt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-menu-Bm8d9ooS.js","names":["_jsx","__icon_DeviceDesktop","__icon_Sun","__icon_Moon","_jsxs","DeviceDesktop","Sun","Moon","useTheme","Button","Menu","Segmented","useUiText","forwardRef","jsx","jsxs","KAESO_THEME_MENU_VARIANTS","KAESO_THEME_MENU_DEFAULT_VARIANTS","ThemeMenu","display","variant","size","side","align","force","ref","theme","resolvedTheme","setTheme","t","v"],"sources":["../../src/components/theme-menu/theme-menu.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { DeviceDesktop as __icon_DeviceDesktop } from \"../../icons/octicons/device-desktop.js\";\nimport { Sun as __icon_Sun } from \"../../icons/octicons/sun.js\";\nimport { Moon as __icon_Moon } from \"../../icons/octicons/moon.js\";\nimport { useTheme, type ThemePreference } from \"../../theme/theme-provider.js\";\nimport { Button } from \"../button/button.js\";\nimport { Menu } from \"../menu/menu.js\";\nimport { Segmented } from \"../segmented/segmented.js\";\nimport { useUiText } from \"../../i18n/context.js\";\n\nexport const KAESO_THEME_MENU_VARIANTS = {\n variant: {\n ghost: { classes: \"\" },\n secondary: { classes: \"\" },\n },\n} as const;\nexport const KAESO_THEME_MENU_DEFAULT_VARIANTS = { variant: \"ghost\" } as const;\n\nexport interface ThemeMenuProps {\n display?: \"menu\" | \"segmented\" | undefined;\n variant?: keyof typeof KAESO_THEME_MENU_VARIANTS.variant | undefined;\n size?: \"sm\" | \"md\" | undefined;\n side?: \"top\" | \"bottom\" | undefined;\n align?: \"start\" | \"end\" | undefined;\n \"data-force\"?: string | undefined;\n}\n\nexport const ThemeMenu = /* @__PURE__ */ forwardRef<HTMLButtonElement, ThemeMenuProps>(function ThemeMenu(\n { display = \"menu\", variant = \"ghost\", size = \"sm\", side = \"bottom\", align = \"end\", \"data-force\": force },\n ref,\n) {\n const { theme, resolvedTheme, setTheme } = useTheme();\n const t = useUiText();\n if (display === \"segmented\")\n return (\n <Segmented\n aria-label={t(\"themeMenu.theme\", \"Theme\")}\n size={size}\n value={theme}\n onValueChange={(v) => setTheme(v as ThemePreference)}\n data-force={force}\n options={[\n { value: \"system\", icon: __icon_DeviceDesktop, \"aria-label\": t(\"themeMenu.system\", \"System\") },\n { value: \"light\", icon: __icon_Sun, \"aria-label\": t(\"themeMenu.light\", \"Light\") },\n { value: \"dark\", icon: __icon_Moon, \"aria-label\": t(\"themeMenu.dark\", \"Dark\") },\n ]}\n />\n );\n return (\n <Menu>\n <Menu.Trigger>\n <Button\n ref={ref}\n icon={resolvedTheme === \"dark\" ? __icon_Moon : __icon_Sun}\n aria-label={t(\"themeMenu.theme\", \"Theme\")}\n variant={variant}\n size={size}\n data-force={force}\n />\n </Menu.Trigger>\n <Menu.Content side={side} align={align} className=\"min-w-180\">\n <Menu.RadioGroup value={theme} onValueChange={(v) => setTheme(v as ThemePreference)}>\n <Menu.RadioItem value=\"system\" closeOnClick icon={__icon_DeviceDesktop}>\n {t(\"themeMenu.system\", \"System\")}\n </Menu.RadioItem>\n <Menu.RadioItem value=\"light\" closeOnClick icon={__icon_Sun}>\n {t(\"themeMenu.light\", \"Light\")}\n </Menu.RadioItem>\n <Menu.RadioItem value=\"dark\" closeOnClick icon={__icon_Moon}>\n {t(\"themeMenu.dark\", \"Dark\")}\n </Menu.RadioItem>\n </Menu.RadioGroup>\n </Menu.Content>\n </Menu>\n );\n});\nif (process.env.NODE_ENV !== \"production\") ThemeMenu.displayName = \"ThemeMenu\";\n"],"mappings":";;;;;;;;;;;;AAUA,IAAagB,IAA4B,EACvC,SAAS;CACP,OAAO,EAAE,SAAS,GAAG;CACrB,WAAW,EAAE,SAAS,GAAG;AAC3B,EACF,GACaC,IAAoC,EAAE,SAAS,QAAQ,GAWvDC,IAA4BL,kBAA8C,SACrF,EAAEM,aAAU,QAAQC,aAAU,SAASC,UAAO,MAAMC,UAAO,UAAUC,WAAQ,OAAO,cAAcC,KAClGC,GACA;CACA,IAAM,EAAEC,UAAOC,kBAAeC,gBAAapB,EAAS,GAC9CqB,IAAIjB,EAAU;CAgBpB,OAfIO,MAAY,cAEZnB,kBAACW,GAAD;EACE,cAAYkB,EAAE,mBAAmB,OAAO;EAClCR;EACN,OAAOK;EACP,gBAAgBI,MAAMF,EAASE,CAAoB;EACnD,cAAYN;EACZ,SAAS;GACP;IAAE,OAAO;IAAU,MAAMvB;IAAsB,cAAc4B,EAAE,oBAAoB,QAAQ;GAAE;GAC7F;IAAE,OAAO;IAAS,MAAM3B;IAAY,cAAc2B,EAAE,mBAAmB,OAAO;GAAE;GAChF;IAAE,OAAO;IAAQ,MAAM1B;IAAa,cAAc0B,EAAE,kBAAkB,MAAM;GAAE;EAChF;CACD,CAAA,IAGHzB,kBAACM,GAAD,EAAA,UAAA,CACEV,kBAACU,EAAK,SAAN,EAAA,UACEV,kBAACS,GAAD;EACOgB;EACL,MAAME,MAAkB,SAASxB,IAAcD;EAC/C,cAAY2B,EAAE,mBAAmB,OAAO;EAC/BT;EACHC;EACN,cAAYG;CACb,CAAA,EACW,CAAA,GACdxB,kBAACU,EAAK,SAAN;EAAoBY;EAAaC;EAAO,WAAU;EAChD,UAAAnB,kBAACM,EAAK,YAAN;GAAiB,OAAOgB;GAAO,gBAAgBI,MAAMF,EAASE,CAAoB;GAAlF,UAAA;IACE9B,kBAACU,EAAK,WAAN;KAAgB,OAAM;KAAS,cAAA;KAAa,MAAMT;KAC/C,UAAA4B,EAAE,oBAAoB,QAAQ;IACjB,CAAA;IAChB7B,kBAACU,EAAK,WAAN;KAAgB,OAAM;KAAQ,cAAA;KAAa,MAAMR;KAC9C,UAAA2B,EAAE,mBAAmB,OAAO;IACf,CAAA;IAChB7B,kBAACU,EAAK,WAAN;KAAgB,OAAM;KAAO,cAAA;KAAa,MAAMP;KAC7C,UAAA0B,EAAE,kBAAkB,MAAM;IACb,CAAA;GACD;;CACL,CAAA,CACV,EAAA,CAAA;AAEV,CAAC;AACD,QAAA,IAAA,aAA6B,iBAAcX,EAAU,cAAc"}
1
+ {"version":3,"file":"theme-menu-Tdl7fdTt.js","names":["_jsx","__icon_DeviceDesktop","__icon_Sun","__icon_Moon","_jsxs","DeviceDesktop","Sun","Moon","useTheme","Button","Menu","Segmented","useUiText","forwardRef","jsx","jsxs","KAESO_THEME_MENU_VARIANTS","KAESO_THEME_MENU_DEFAULT_VARIANTS","ThemeMenu","display","variant","size","side","align","force","ref","theme","resolvedTheme","setTheme","t","v"],"sources":["../../src/components/theme-menu/theme-menu.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { DeviceDesktop as __icon_DeviceDesktop } from \"../../icons/octicons/device-desktop.js\";\nimport { Sun as __icon_Sun } from \"../../icons/octicons/sun.js\";\nimport { Moon as __icon_Moon } from \"../../icons/octicons/moon.js\";\nimport { useTheme, type ThemePreference } from \"../../theme/theme-provider.js\";\nimport { Button } from \"../button/button.js\";\nimport { Menu } from \"../menu/menu.js\";\nimport { Segmented } from \"../segmented/segmented.js\";\nimport { useUiText } from \"../../i18n/context.js\";\n\nexport const KAESO_THEME_MENU_VARIANTS = {\n variant: {\n ghost: { classes: \"\" },\n secondary: { classes: \"\" },\n },\n} as const;\nexport const KAESO_THEME_MENU_DEFAULT_VARIANTS = { variant: \"ghost\" } as const;\n\nexport interface ThemeMenuProps {\n display?: \"menu\" | \"segmented\" | undefined;\n variant?: keyof typeof KAESO_THEME_MENU_VARIANTS.variant | undefined;\n size?: \"sm\" | \"md\" | undefined;\n side?: \"top\" | \"bottom\" | undefined;\n align?: \"start\" | \"end\" | undefined;\n \"data-force\"?: string | undefined;\n}\n\nexport const ThemeMenu = /* @__PURE__ */ forwardRef<HTMLButtonElement, ThemeMenuProps>(function ThemeMenu(\n { display = \"menu\", variant = \"ghost\", size = \"sm\", side = \"bottom\", align = \"end\", \"data-force\": force },\n ref,\n) {\n const { theme, resolvedTheme, setTheme } = useTheme();\n const t = useUiText();\n if (display === \"segmented\")\n return (\n <Segmented\n aria-label={t(\"themeMenu.theme\", \"Theme\")}\n size={size}\n value={theme}\n onValueChange={(v) => setTheme(v as ThemePreference)}\n data-force={force}\n options={[\n { value: \"system\", icon: __icon_DeviceDesktop, \"aria-label\": t(\"themeMenu.system\", \"System\") },\n { value: \"light\", icon: __icon_Sun, \"aria-label\": t(\"themeMenu.light\", \"Light\") },\n { value: \"dark\", icon: __icon_Moon, \"aria-label\": t(\"themeMenu.dark\", \"Dark\") },\n ]}\n />\n );\n return (\n <Menu>\n <Menu.Trigger>\n <Button\n ref={ref}\n icon={resolvedTheme === \"dark\" ? __icon_Moon : __icon_Sun}\n aria-label={t(\"themeMenu.theme\", \"Theme\")}\n variant={variant}\n size={size}\n data-force={force}\n />\n </Menu.Trigger>\n <Menu.Content side={side} align={align} className=\"min-w-180\">\n <Menu.RadioGroup value={theme} onValueChange={(v) => setTheme(v as ThemePreference)}>\n <Menu.RadioItem value=\"system\" closeOnClick icon={__icon_DeviceDesktop}>\n {t(\"themeMenu.system\", \"System\")}\n </Menu.RadioItem>\n <Menu.RadioItem value=\"light\" closeOnClick icon={__icon_Sun}>\n {t(\"themeMenu.light\", \"Light\")}\n </Menu.RadioItem>\n <Menu.RadioItem value=\"dark\" closeOnClick icon={__icon_Moon}>\n {t(\"themeMenu.dark\", \"Dark\")}\n </Menu.RadioItem>\n </Menu.RadioGroup>\n </Menu.Content>\n </Menu>\n );\n});\nif (process.env.NODE_ENV !== \"production\") ThemeMenu.displayName = \"ThemeMenu\";\n"],"mappings":";;;;;;;;;;;;AAUA,IAAagB,IAA4B,EACvC,SAAS;CACP,OAAO,EAAE,SAAS,GAAG;CACrB,WAAW,EAAE,SAAS,GAAG;AAC3B,EACF,GACaC,IAAoC,EAAE,SAAS,QAAQ,GAWvDC,IAA4BL,kBAA8C,SACrF,EAAEM,aAAU,QAAQC,aAAU,SAASC,UAAO,MAAMC,UAAO,UAAUC,WAAQ,OAAO,cAAcC,KAClGC,GACA;CACA,IAAM,EAAEC,UAAOC,kBAAeC,gBAAapB,EAAS,GAC9CqB,IAAIjB,EAAU;CAgBpB,OAfIO,MAAY,cAEZnB,kBAACW,GAAD;EACE,cAAYkB,EAAE,mBAAmB,OAAO;EAClCR;EACN,OAAOK;EACP,gBAAgBI,MAAMF,EAASE,CAAoB;EACnD,cAAYN;EACZ,SAAS;GACP;IAAE,OAAO;IAAU,MAAMvB;IAAsB,cAAc4B,EAAE,oBAAoB,QAAQ;GAAE;GAC7F;IAAE,OAAO;IAAS,MAAM3B;IAAY,cAAc2B,EAAE,mBAAmB,OAAO;GAAE;GAChF;IAAE,OAAO;IAAQ,MAAM1B;IAAa,cAAc0B,EAAE,kBAAkB,MAAM;GAAE;EAChF;CACD,CAAA,IAGHzB,kBAACM,GAAD,EAAA,UAAA,CACEV,kBAACU,EAAK,SAAN,EAAA,UACEV,kBAACS,GAAD;EACOgB;EACL,MAAME,MAAkB,SAASxB,IAAcD;EAC/C,cAAY2B,EAAE,mBAAmB,OAAO;EAC/BT;EACHC;EACN,cAAYG;CACb,CAAA,EACW,CAAA,GACdxB,kBAACU,EAAK,SAAN;EAAoBY;EAAaC;EAAO,WAAU;EAChD,UAAAnB,kBAACM,EAAK,YAAN;GAAiB,OAAOgB;GAAO,gBAAgBI,MAAMF,EAASE,CAAoB;GAAlF,UAAA;IACE9B,kBAACU,EAAK,WAAN;KAAgB,OAAM;KAAS,cAAA;KAAa,MAAMT;KAC/C,UAAA4B,EAAE,oBAAoB,QAAQ;IACjB,CAAA;IAChB7B,kBAACU,EAAK,WAAN;KAAgB,OAAM;KAAQ,cAAA;KAAa,MAAMR;KAC9C,UAAA2B,EAAE,mBAAmB,OAAO;IACf,CAAA;IAChB7B,kBAACU,EAAK,WAAN;KAAgB,OAAM;KAAO,cAAA;KAAa,MAAMP;KAC7C,UAAA0B,EAAE,kBAAkB,MAAM;IACb,CAAA;GACD;;CACL,CAAA,CACV,EAAA,CAAA;AAEV,CAAC;AACD,QAAA,IAAA,aAA6B,iBAAcX,EAAU,cAAc"}
@@ -44,8 +44,10 @@ function _({ children: e, defaultTheme: n = "system", target: u }) {
44
44
  };
45
45
  }, [n]), r(() => {
46
46
  if (f === null) return;
47
- let e = u ? u() : document.documentElement, t = g(e);
48
- return f === "system" ? e.removeAttribute("data-theme") : e.setAttribute("data-theme", f), t;
47
+ let e = u ? u() : document.documentElement, t = f === "system" ? null : f;
48
+ if (e.getAttribute("data-theme") === t) return;
49
+ let n = g(e);
50
+ return t === null ? e.removeAttribute("data-theme") : e.setAttribute("data-theme", t), n;
49
51
  }, [f, u]);
50
52
  let S = t((e) => {
51
53
  _(e);
@@ -77,4 +79,4 @@ function v() {
77
79
  }
78
80
  export { v as a, f as i, _ as n, d as r, c as t };
79
81
 
80
- //# sourceMappingURL=theme-provider-DaD8hlXu.js.map
82
+ //# sourceMappingURL=theme-provider-CD0AF5UZ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-provider-DaD8hlXu.js","names":["_jsx","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","jsx","THEME_STORAGE_KEY","THEME_EVENT","modalitySource","installFocusModality","w","d","themeScript","key","ThemeContext","readStored","fallback","v","systemTheme","holdTransitions","el","settled","ThemeProvider","children","defaultTheme","target","chosen","setThemeState","system","setSystem","theme","root","mq","onChange","follow","event","release","setTheme","next","value","useTheme"],"sources":["../../src/theme/theme-provider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\n\nexport type ThemePreference = \"system\" | \"light\" | \"dark\";\nexport type ResolvedTheme = \"light\" | \"dark\";\n\nexport const THEME_STORAGE_KEY = \"kaeso:theme\";\nconst THEME_EVENT = \"kaeso:theme-change\";\n\nconst modalitySource = `if(!window.__kModality){window.__kModality=1;document.addEventListener(\"pointerdown\",function(){d.setAttribute(\"data-k-pointer\",\"\")},true);document.addEventListener(\"keydown\",function(e){if(!e.metaKey&&!e.ctrlKey&&!e.altKey){d.removeAttribute(\"data-k-pointer\")}},true)}`;\n\nexport function installFocusModality(): void {\n if (typeof document === \"undefined\") return;\n const w = window as unknown as { __kModality?: number | undefined };\n if (w.__kModality) return;\n w.__kModality = 1;\n const d = document.documentElement;\n document.addEventListener(\"pointerdown\", () => d.setAttribute(\"data-k-pointer\", \"\"), true);\n document.addEventListener(\n \"keydown\",\n (e) => {\n if (!e.metaKey && !e.ctrlKey && !e.altKey) d.removeAttribute(\"data-k-pointer\");\n },\n true,\n );\n}\n\nconst themeScriptFor = (key: string) =>\n `(function(){var d=document.documentElement;try{var t=localStorage.getItem(\"${key}\");if(t===\"light\"||t===\"dark\"){d.setAttribute(\"data-theme\",t)}}catch(e){}${modalitySource}})();`;\n\nexport const themeScript = /* @__PURE__ */ themeScriptFor(THEME_STORAGE_KEY);\n\ninterface ThemeContextValue {\n theme: ThemePreference;\n resolvedTheme: ResolvedTheme;\n setTheme: (theme: ThemePreference) => void;\n}\n\nconst ThemeContext = /* @__PURE__ */ createContext<ThemeContextValue | null>(null);\n\nfunction readStored(fallback: ThemePreference): ThemePreference {\n try {\n const v = localStorage.getItem(THEME_STORAGE_KEY);\n return v === \"light\" || v === \"dark\" ? v : fallback;\n } catch {\n return fallback;\n }\n}\n\nfunction systemTheme(): ResolvedTheme {\n if (typeof window === \"undefined\" || !window.matchMedia) return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n defaultTheme?: ThemePreference | undefined;\n target?: (() => HTMLElement) | undefined;\n}\n\n// Every color changes at once; without this, each control's color transition replays the switch on its own,\n// showing light controls on a dark page for a moment.\nfunction holdTransitions(el: HTMLElement): () => void {\n el.setAttribute(\"data-k-theming\", \"\");\n void getComputedStyle(el).color;\n const settled = requestAnimationFrame(() => el.removeAttribute(\"data-k-theming\"));\n return () => {\n cancelAnimationFrame(settled);\n el.removeAttribute(\"data-k-theming\");\n };\n}\n\nexport function ThemeProvider({ children, defaultTheme = \"system\", target }: ThemeProviderProps) {\n const [chosen, setThemeState] = useState<ThemePreference | null>(null);\n const [system, setSystem] = useState<ResolvedTheme>(\"light\");\n const theme = chosen ?? defaultTheme;\n const root = useRef(target);\n root.current = target;\n\n useEffect(() => {\n installFocusModality();\n setThemeState(readStored(defaultTheme));\n setSystem(systemTheme());\n const mq = window.matchMedia?.(\"(prefers-color-scheme: dark)\");\n const onChange = () => {\n holdTransitions(root.current ? root.current() : document.documentElement);\n setSystem(mq.matches ? \"dark\" : \"light\");\n };\n const follow = (event: Event) => setThemeState((event as CustomEvent<ThemePreference>).detail);\n mq?.addEventListener(\"change\", onChange);\n window.addEventListener(THEME_EVENT, follow);\n return () => {\n mq?.removeEventListener(\"change\", onChange);\n window.removeEventListener(THEME_EVENT, follow);\n };\n }, [defaultTheme]);\n\n useEffect(() => {\n if (chosen === null) return;\n const el = target ? target() : document.documentElement;\n const release = holdTransitions(el);\n if (chosen === \"system\") el.removeAttribute(\"data-theme\");\n else el.setAttribute(\"data-theme\", chosen);\n return release;\n }, [chosen, target]);\n\n const setTheme = useCallback((next: ThemePreference) => {\n setThemeState(next);\n try {\n if (next === \"system\") localStorage.removeItem(THEME_STORAGE_KEY);\n else localStorage.setItem(THEME_STORAGE_KEY, next);\n } catch {}\n window.dispatchEvent(new CustomEvent<ThemePreference>(THEME_EVENT, { detail: next }));\n }, []);\n\n const value = useMemo<ThemeContextValue>(() => ({ theme, resolvedTheme: theme === \"system\" ? system : theme, setTheme }), [theme, system, setTheme]);\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\nif (process.env.NODE_ENV !== \"production\") ThemeProvider.displayName = \"ThemeProvider\";\n\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) {\n return { theme: \"system\", resolvedTheme: \"light\", setTheme: () => undefined };\n }\n return ctx;\n}\n"],"mappings":";;;;AAKA,IAAaS,IAAoB,eAC3BC,IAAc,sBAEdC,IAAiB;AAEvB,SAAgBC,IAA6B;CAC3C,IAAI,OAAO,WAAa,KAAa;CACrC,IAAMC,IAAI;CACV,IAAIA,EAAE,aAAa;CACnBA,EAAE,cAAc;CAChB,IAAMC,IAAI,SAAS;CACnB,SAAS,iBAAiB,qBAAqBA,EAAE,aAAa,kBAAkB,EAAE,GAAG,EAAI,GACzF,SAAS,iBACP,YACC,MAAM;EACA,EAAE,WAAY,EAAE,WAAY,EAAE,UAAQA,EAAE,gBAAgB,gBAAgB;CAC/E,GACA,EACF;AACF;AAKA,IAAaC,IAA8B,kBAHnBC,MACtB,8EAA8EA,EAAI,2EAA2EL,EAAe,OAEnI,CAAeF,CAAiB,GAQrEQ,IAA+BhB,kBAAwC,IAAI;AAEjF,SAASiB,EAAWC,GAA4C;CAC9D,IAAI;EACF,IAAMC,IAAI,aAAa,QAAQX,CAAiB;EAChD,OAAOW,MAAM,WAAWA,MAAM,SAASA,IAAID;CAC7C,QAAQ;EACN,OAAOA;CACT;AACF;AAEA,SAASE,IAA6B;CAEpC,OADI,OAAO,SAAW,OAAe,CAAC,OAAO,aAAmB,UACzD,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AAC;CAEnB,IAAMY,IAAWtC,GAAauC,MAA0B;EACtDX,EAAcW,CAAI;EAClB,IAAI;GACEA,MAAS,WAAU,aAAa,WAAWhC,CAAiB,IAC3D,aAAa,QAAQA,GAAmBgC,CAAI;EACnD,QAAQ,CAAC;EACT,OAAO,cAAc,IAAI,YAA6B/B,GAAa,EAAE,QAAQ+B,EAAK,CAAC,CAAC;CACtF,GAAG,CAAC,CAAC,GAECC,IAAQrC,SAAkC;EAAE4B;EAAO,eAAeA,MAAU,WAAWF,IAASE;EAAOO;CAAS,IAAI;EAACP;EAAOF;EAAQS;CAAQ,CAAC;CACnJ,OAAOxC,kBAACiB,EAAa,UAAd;EAA8ByB;EAAQhB;CAAgC,CAAA;AAC/E;AACA,QAAA,IAAA,aAA6B,iBAAcD,EAAc,cAAc;AAEvE,SAAgBkB,IAA8B;CAK5C,OAJYxC,EAAWc,CAClB,KACI;EAAE,OAAO;EAAU,eAAe;EAAS,gBAAgB,KAAA;CAAU;AAGhF"}
1
+ {"version":3,"file":"theme-provider-CD0AF5UZ.js","names":["_jsx","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","jsx","THEME_STORAGE_KEY","THEME_EVENT","modalitySource","installFocusModality","w","d","themeScript","key","ThemeContext","readStored","fallback","v","systemTheme","holdTransitions","el","settled","ThemeProvider","children","defaultTheme","target","chosen","setThemeState","system","setSystem","theme","root","mq","onChange","follow","event","next","release","setTheme","value","useTheme"],"sources":["../../src/theme/theme-provider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\n\nexport type ThemePreference = \"system\" | \"light\" | \"dark\";\nexport type ResolvedTheme = \"light\" | \"dark\";\n\nexport const THEME_STORAGE_KEY = \"kaeso:theme\";\nconst THEME_EVENT = \"kaeso:theme-change\";\n\nconst modalitySource = `if(!window.__kModality){window.__kModality=1;document.addEventListener(\"pointerdown\",function(){d.setAttribute(\"data-k-pointer\",\"\")},true);document.addEventListener(\"keydown\",function(e){if(!e.metaKey&&!e.ctrlKey&&!e.altKey){d.removeAttribute(\"data-k-pointer\")}},true)}`;\n\nexport function installFocusModality(): void {\n if (typeof document === \"undefined\") return;\n const w = window as unknown as { __kModality?: number | undefined };\n if (w.__kModality) return;\n w.__kModality = 1;\n const d = document.documentElement;\n document.addEventListener(\"pointerdown\", () => d.setAttribute(\"data-k-pointer\", \"\"), true);\n document.addEventListener(\n \"keydown\",\n (e) => {\n if (!e.metaKey && !e.ctrlKey && !e.altKey) d.removeAttribute(\"data-k-pointer\");\n },\n true,\n );\n}\n\nconst themeScriptFor = (key: string) =>\n `(function(){var d=document.documentElement;try{var t=localStorage.getItem(\"${key}\");if(t===\"light\"||t===\"dark\"){d.setAttribute(\"data-theme\",t)}}catch(e){}${modalitySource}})();`;\n\nexport const themeScript = /* @__PURE__ */ themeScriptFor(THEME_STORAGE_KEY);\n\ninterface ThemeContextValue {\n theme: ThemePreference;\n resolvedTheme: ResolvedTheme;\n setTheme: (theme: ThemePreference) => void;\n}\n\nconst ThemeContext = /* @__PURE__ */ createContext<ThemeContextValue | null>(null);\n\nfunction readStored(fallback: ThemePreference): ThemePreference {\n try {\n const v = localStorage.getItem(THEME_STORAGE_KEY);\n return v === \"light\" || v === \"dark\" ? v : fallback;\n } catch {\n return fallback;\n }\n}\n\nfunction systemTheme(): ResolvedTheme {\n if (typeof window === \"undefined\" || !window.matchMedia) return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n defaultTheme?: ThemePreference | undefined;\n target?: (() => HTMLElement) | undefined;\n}\n\n// Every color changes at once; without this, each control's color transition replays the switch on its own,\n// showing light controls on a dark page for a moment.\nfunction holdTransitions(el: HTMLElement): () => void {\n el.setAttribute(\"data-k-theming\", \"\");\n void getComputedStyle(el).color;\n const settled = requestAnimationFrame(() => el.removeAttribute(\"data-k-theming\"));\n return () => {\n cancelAnimationFrame(settled);\n el.removeAttribute(\"data-k-theming\");\n };\n}\n\nexport function ThemeProvider({ children, defaultTheme = \"system\", target }: ThemeProviderProps) {\n const [chosen, setThemeState] = useState<ThemePreference | null>(null);\n const [system, setSystem] = useState<ResolvedTheme>(\"light\");\n const theme = chosen ?? defaultTheme;\n const root = useRef(target);\n root.current = target;\n\n useEffect(() => {\n installFocusModality();\n setThemeState(readStored(defaultTheme));\n setSystem(systemTheme());\n const mq = window.matchMedia?.(\"(prefers-color-scheme: dark)\");\n const onChange = () => {\n holdTransitions(root.current ? root.current() : document.documentElement);\n setSystem(mq.matches ? \"dark\" : \"light\");\n };\n const follow = (event: Event) => setThemeState((event as CustomEvent<ThemePreference>).detail);\n mq?.addEventListener(\"change\", onChange);\n window.addEventListener(THEME_EVENT, follow);\n return () => {\n mq?.removeEventListener(\"change\", onChange);\n window.removeEventListener(THEME_EVENT, follow);\n };\n }, [defaultTheme]);\n\n useEffect(() => {\n if (chosen === null) return;\n const el = target ? target() : document.documentElement;\n const next = chosen === \"system\" ? null : chosen;\n // On mount the head script has usually applied this theme already. Holding transitions then would restyle the\n // whole page twice for nothing, which on a large page is the longest task of its load.\n if (el.getAttribute(\"data-theme\") === next) return;\n const release = holdTransitions(el);\n if (next === null) el.removeAttribute(\"data-theme\");\n else el.setAttribute(\"data-theme\", next);\n return release;\n }, [chosen, target]);\n\n const setTheme = useCallback((next: ThemePreference) => {\n setThemeState(next);\n try {\n if (next === \"system\") localStorage.removeItem(THEME_STORAGE_KEY);\n else localStorage.setItem(THEME_STORAGE_KEY, next);\n } catch {}\n window.dispatchEvent(new CustomEvent<ThemePreference>(THEME_EVENT, { detail: next }));\n }, []);\n\n const value = useMemo<ThemeContextValue>(() => ({ theme, resolvedTheme: theme === \"system\" ? system : theme, setTheme }), [theme, system, setTheme]);\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\nif (process.env.NODE_ENV !== \"production\") ThemeProvider.displayName = \"ThemeProvider\";\n\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) {\n return { theme: \"system\", resolvedTheme: \"light\", setTheme: () => undefined };\n }\n return ctx;\n}\n"],"mappings":";;;;AAKA,IAAaS,IAAoB,eAC3BC,IAAc,sBAEdC,IAAiB;AAEvB,SAAgBC,IAA6B;CAC3C,IAAI,OAAO,WAAa,KAAa;CACrC,IAAMC,IAAI;CACV,IAAIA,EAAE,aAAa;CACnBA,EAAE,cAAc;CAChB,IAAMC,IAAI,SAAS;CACnB,SAAS,iBAAiB,qBAAqBA,EAAE,aAAa,kBAAkB,EAAE,GAAG,EAAI,GACzF,SAAS,iBACP,YACC,MAAM;EACA,EAAE,WAAY,EAAE,WAAY,EAAE,UAAQA,EAAE,gBAAgB,gBAAgB;CAC/E,GACA,EACF;AACF;AAKA,IAAaC,IAA8B,kBAHnBC,MACtB,8EAA8EA,EAAI,2EAA2EL,EAAe,OAEnI,CAAeF,CAAiB,GAQrEQ,IAA+BhB,kBAAwC,IAAI;AAEjF,SAASiB,EAAWC,GAA4C;CAC9D,IAAI;EACF,IAAMC,IAAI,aAAa,QAAQX,CAAiB;EAChD,OAAOW,MAAM,WAAWA,MAAM,SAASA,IAAID;CAC7C,QAAQ;EACN,OAAOA;CACT;AACF;AAEA,SAASE,IAA6B;CAEpC,OADI,OAAO,SAAW,OAAe,CAAC,OAAO,aAAmB,UACzD,OAAO,WAAW,8BAA8B,CAAC,CAAC,UAAU,SAAS;AAC9E;AAUA,SAASC,EAAgBC,GAA6B;CACpDA,EAAG,aAAa,kBAAkB,EAAE,GAC/B,iBAAiBA,CAAE,CAAC,CAAC;CAC1B,IAAMC,IAAU,4BAA4BD,EAAG,gBAAgB,gBAAgB,CAAC;CAChF,aAAa;EACX,qBAAqBC,CAAO,GAC5BD,EAAG,gBAAgB,gBAAgB;CACrC;AACF;AAEA,SAAgBE,EAAc,EAAEC,aAAUC,kBAAe,UAAUC,aAA8B;CAC/F,IAAM,CAACC,GAAQC,KAAiBvB,EAAiC,IAA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E4B;EAAO,eAAeA,MAAU,WAAWF,IAASE;EAAOQ;CAAS,IAAI;EAACR;EAAOF;EAAQU;CAAQ,CAAC;CACnJ,OAAOzC,kBAACiB,EAAa,UAAd;EAA8ByB;EAAQhB;CAAgC,CAAA;AAC/E;AACA,QAAA,IAAA,aAA6B,iBAAcD,EAAc,cAAc;AAEvE,SAAgBkB,IAA8B;CAK5C,OAJYxC,EAAWc,CAClB,KACI;EAAE,OAAO;EAAU,eAAe;EAAS,gBAAgB,KAAA;CAAU;AAGhF"}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export { t as KAESO_THEME_MENU_DEFAULT_VARIANTS, n as KAESO_THEME_MENU_VARIANTS, r as ThemeMenu } from "../chunks/theme-menu-Bm8d9ooS.js";
2
+ export { t as KAESO_THEME_MENU_DEFAULT_VARIANTS, n as KAESO_THEME_MENU_VARIANTS, r as ThemeMenu } from "../chunks/theme-menu-Tdl7fdTt.js";
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import { UI_LOCALES as h, matchUiLocale as g, preferredUiLocale as _ } from "./i
12
12
  import { LocaleProvider as v, loadUiMessages as y, resolveUiLocale as b } from "./i18n-provider.js";
13
13
  import { t as x } from "./chunks/formatters-Be5AdLB2.js";
14
14
  import { t as S } from "./chunks/i18n-DA-5LboH.js";
15
- import { a as C, i as w, n as T, r as E, t as D } from "./chunks/theme-provider-DaD8hlXu.js";
15
+ import { a as C, i as w, n as T, r as E, t as D } from "./chunks/theme-provider-CD0AF5UZ.js";
16
16
  import "./theme.js";
17
17
  import { n as O, r as k, t as A } from "./chunks/icon-B9UXhFTF.js";
18
18
  import { t as j } from "./chunks/icon-DOwC1bbC.js";
@@ -79,7 +79,7 @@ import { a as Xt, i as Zt, n as Qt, r as $t } from "./chunks/sidebar-Cz0KdApZ.js
79
79
  import "./components/sidebar.js";
80
80
  import { a as en, i as tn, n as nn, o as rn, r as an, t as on } from "./chunks/app-frame-COfWg7wS.js";
81
81
  import "./components/app-frame.js";
82
- import { n as sn, r as cn, t as ln } from "./chunks/theme-menu-Bm8d9ooS.js";
82
+ import { n as sn, r as cn, t as ln } from "./chunks/theme-menu-Tdl7fdTt.js";
83
83
  import { n as un, r as dn, t as fn } from "./chunks/theme-image-C9p959Kv.js";
84
84
  import { n as pn, r as mn, t as hn } from "./chunks/figure-BI0eP7S-.js";
85
85
  import { n as gn, r as _n, t as vn } from "./chunks/thumbnail-KtBHleQk.js";
package/dist/theme.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export { t as THEME_STORAGE_KEY, n as ThemeProvider, r as installFocusModality, i as themeScript, a as useTheme } from "./chunks/theme-provider-DaD8hlXu.js";
2
+ export { t as THEME_STORAGE_KEY, n as ThemeProvider, r as installFocusModality, i as themeScript, a as useTheme } from "./chunks/theme-provider-CD0AF5UZ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicplanes/kaeso-ui",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "UI library for the Kaeso open-source AI gateway: React components on Base UI, Tailwind CSS v4 and the Kaeso tokens.",
5
5
  "license": "MIT",
6
6
  "author": "Devin Oldenburg",
@@ -101,7 +101,7 @@
101
101
  "shiki": "4.6.0",
102
102
  "tailwind-merge": "3.7.1",
103
103
  "uqr": "0.1.3",
104
- "@logicplanes/kaeso-tokens": "0.7.5"
104
+ "@logicplanes/kaeso-tokens": "0.7.6"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@tailwindcss/node": "4.3.5",