@kushagradhawan/kookie-ui 0.12.0 → 0.13.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/cjs/hooks/appearance-script.d.ts +16 -0
- package/dist/cjs/hooks/appearance-script.d.ts.map +1 -0
- package/dist/cjs/hooks/appearance-script.js +12 -0
- package/dist/cjs/hooks/appearance-script.js.map +7 -0
- package/dist/cjs/hooks/index.d.ts +3 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +12 -2
- package/dist/cjs/hooks/index.js.map +4 -4
- package/dist/cjs/hooks/use-appearance.d.ts +30 -0
- package/dist/cjs/hooks/use-appearance.d.ts.map +1 -0
- package/dist/cjs/hooks/use-appearance.js +12 -0
- package/dist/cjs/hooks/use-appearance.js.map +7 -0
- package/dist/cjs/index.js +15 -5
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/chunk-2KZ4NI3X.js +1 -0
- package/dist/esm/chunk-HT7RFHLW.js +2 -0
- package/dist/esm/chunk-HT7RFHLW.js.map +7 -0
- package/dist/esm/chunk-IUER6BNH.js +12 -0
- package/dist/esm/chunk-IUER6BNH.js.map +7 -0
- package/dist/esm/hooks/appearance-script.d.ts +16 -0
- package/dist/esm/hooks/appearance-script.d.ts.map +1 -0
- package/dist/esm/hooks/appearance-script.js +2 -0
- package/dist/esm/hooks/appearance-script.js.map +7 -0
- package/dist/esm/hooks/index.d.ts +3 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/use-appearance.d.ts +30 -0
- package/dist/esm/hooks/use-appearance.d.ts.map +1 -0
- package/dist/esm/hooks/use-appearance.js +2 -0
- package/dist/esm/hooks/use-appearance.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/package.json +11 -1
- package/src/hooks/appearance-script.ts +28 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/use-appearance.ts +119 -0
- package/dist/esm/chunk-EL7YGOTY.js +0 -1
- /package/dist/esm/{chunk-EL7YGOTY.js.map → chunk-2KZ4NI3X.js.map} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pre-paint half of light and dark mode (see `use-appearance.ts`). Kept in its own module
|
|
3
|
+
* with no client directive, so a server component such as a Next.js root layout can import the
|
|
4
|
+
* string and inline it in `<head>`.
|
|
5
|
+
*/
|
|
6
|
+
declare const APPEARANCE_STORAGE_KEY = "kookie-appearance";
|
|
7
|
+
/**
|
|
8
|
+
* Inline this in `<head>`, before any stylesheet paints, e.g.
|
|
9
|
+
* `<script dangerouslySetInnerHTML={{ __html: appearanceScript }} />`.
|
|
10
|
+
*
|
|
11
|
+
* Storage is read inside its own try/catch: browsers that block site data throw on access,
|
|
12
|
+
* and that must not skip the stamp. `matchMedia` always answers.
|
|
13
|
+
*/
|
|
14
|
+
declare const appearanceScript: string;
|
|
15
|
+
export { appearanceScript, APPEARANCE_STORAGE_KEY };
|
|
16
|
+
//# sourceMappingURL=appearance-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appearance-script.d.ts","sourceRoot":"","sources":["../../../src/hooks/appearance-script.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,QAAA,MAAM,sBAAsB,sBAAsB,CAAC;AAEnD;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,QAUhB,CAAC;AAEP,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var i=(a,e)=>{for(var r in e)c(a,r,{get:e[r],enumerable:!0})},n=(a,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!m.call(a,t)&&t!==r&&c(a,t,{get:()=>e[t],enumerable:!(o=s(e,t))||o.enumerable});return a};var p=a=>n(c({},"__esModule",{value:!0}),a);var k={};i(k,{APPEARANCE_STORAGE_KEY:()=>d,appearanceScript:()=>h});module.exports=p(k);var d="kookie-appearance",h=`(function () {
|
|
2
|
+
var e = document.documentElement;
|
|
3
|
+
var a = null;
|
|
4
|
+
try { a = localStorage.getItem(${JSON.stringify(d)}); } catch (err) {}
|
|
5
|
+
var dark = a === "light" ? false : a === "dark" ? true : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
6
|
+
var mode = dark ? "dark" : "light";
|
|
7
|
+
e.classList.remove("light", "dark");
|
|
8
|
+
e.classList.add(mode);
|
|
9
|
+
e.setAttribute("data-appearance", mode);
|
|
10
|
+
e.style.colorScheme = mode;
|
|
11
|
+
})();`;
|
|
12
|
+
//# sourceMappingURL=appearance-script.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/appearance-script.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The pre-paint half of light and dark mode (see `use-appearance.ts`). Kept in its own module\n * with no client directive, so a server component such as a Next.js root layout can import the\n * string and inline it in `<head>`.\n */\n\nconst APPEARANCE_STORAGE_KEY = 'kookie-appearance';\n\n/**\n * Inline this in `<head>`, before any stylesheet paints, e.g.\n * `<script dangerouslySetInnerHTML={{ __html: appearanceScript }} />`.\n *\n * Storage is read inside its own try/catch: browsers that block site data throw on access,\n * and that must not skip the stamp. `matchMedia` always answers.\n */\nconst appearanceScript = `(function () {\n var e = document.documentElement;\n var a = null;\n try { a = localStorage.getItem(${JSON.stringify(APPEARANCE_STORAGE_KEY)}); } catch (err) {}\n var dark = a === \"light\" ? false : a === \"dark\" ? true : matchMedia(\"(prefers-color-scheme: dark)\").matches;\n var mode = dark ? \"dark\" : \"light\";\n e.classList.remove(\"light\", \"dark\");\n e.classList.add(mode);\n e.setAttribute(\"data-appearance\", mode);\n e.style.colorScheme = mode;\n})();`;\n\nexport { appearanceScript, APPEARANCE_STORAGE_KEY };\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,qBAAAC,IAAA,eAAAC,EAAAJ,GAMA,IAAME,EAAyB,oBASzBC,EAAmB;AAAA;AAAA;AAAA,mCAGU,KAAK,UAAUD,CAAsB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": ["appearance_script_exports", "__export", "APPEARANCE_STORAGE_KEY", "appearanceScript", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -2,4 +2,7 @@ export { useLiveAnnouncer } from './use-live-announcer.js';
|
|
|
2
2
|
export { useBodyPointerEventsCleanup } from './use-body-pointer-events-cleanup.js';
|
|
3
3
|
export { useTooltipWrapper } from './use-tooltip-wrapper.js';
|
|
4
4
|
export { useToggleState } from './use-toggle-state.js';
|
|
5
|
+
export { useAppearance, setAppearance } from './use-appearance.js';
|
|
6
|
+
export { appearanceScript, APPEARANCE_STORAGE_KEY } from './appearance-script.js';
|
|
7
|
+
export type { AppearanceChoice, ResolvedAppearance } from './use-appearance.js';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var M=Object.create;var h=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},x=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Y(t))!D.call(e,r)&&r!==n&&h(e,r,{get:()=>t[r],enumerable:!(o=U(t,r))||o.enumerable});return e};var p=(e,t,n)=>(n=e!=null?M($(e)):{},x(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),q=e=>x(h({},"__esModule",{value:!0}),e);var V={};G(V,{APPEARANCE_STORAGE_KEY:()=>s,appearanceScript:()=>O,setAppearance:()=>C,useAppearance:()=>_,useBodyPointerEventsCleanup:()=>I,useLiveAnnouncer:()=>y,useToggleState:()=>N,useTooltipWrapper:()=>P});module.exports=q(V);var l=p(require("react")),R=0;function y(){let e=l.useRef(void 0);return l.useEffect(()=>{let n=document.getElementById("rt-live-announcer");return n||(n=document.createElement("div"),n.id="rt-live-announcer",n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.style.cssText=`
|
|
2
2
|
position: absolute;
|
|
3
3
|
left: -10000px;
|
|
4
4
|
width: 1px;
|
|
@@ -6,5 +6,15 @@
|
|
|
6
6
|
overflow: hidden;
|
|
7
7
|
clip: rect(0, 0, 0, 0);
|
|
8
8
|
white-space: nowrap;
|
|
9
|
-
`,document.body.appendChild(
|
|
9
|
+
`,document.body.appendChild(n)),R++,()=>{if(R--,e.current&&clearTimeout(e.current),R===0){let o=document.getElementById("rt-live-announcer");o&&o.remove()}}},[]),l.useCallback(n=>{let o=document.getElementById("rt-live-announcer");o&&(e.current&&clearTimeout(e.current),o.textContent="",e.current=setTimeout(()=>{o.textContent=n},100))},[])}var T=p(require("react")),b=!1;function I(){T.useEffect(()=>{if(typeof document>"u"||b)return;b=!0;let e=new Set,t=(c,d)=>{let w=setTimeout(()=>{e.delete(w),c()},d);e.add(w)},n=()=>{let c=!!document.querySelector('[role="dialog"][aria-modal="true"], [role="alertdialog"][aria-modal="true"]'),d=!!document.querySelector('[data-radix-popper-content-wrapper], [data-state="open"]');return c||d},o=()=>{document.body.style.pointerEvents==="none"&&(console.log("[KookieUI] Force cleaning stuck pointer-events: none from body"),document.body.style.pointerEvents="",document.body.removeAttribute("data-scroll-locked"),document.body.removeAttribute("data-remove-scroll"),document.body.classList.remove("ReactModal__Body--open"))},r=()=>{document.body.style.pointerEvents==="none"&&!n()&&(console.log("[KookieUI] Safe cleaning stuck pointer-events: none from body"),document.body.style.pointerEvents="")},i=c=>{let d=c.target;d&&!d.closest('[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper]')&&t(o,100)},v=c=>{c.key==="Escape"&&t(o,200)},a=()=>{t(r,50)};document.addEventListener("click",i,!0),document.addEventListener("keydown",v,!0),document.addEventListener("pointerup",a,!0),document.addEventListener("transitionend",a,!0),document.addEventListener("animationend",a,!0);let f=new MutationObserver(()=>{t(r,0)});f.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let K=setInterval(()=>{document.body.style.pointerEvents==="none"&&!n()&&(console.log("[KookieUI] Periodic cleanup of stuck pointer-events"),document.body.style.pointerEvents="")},1e3);return t(r,100),()=>{clearInterval(K),e.forEach(clearTimeout),e.clear(),f.disconnect(),document.removeEventListener("click",i,!0),document.removeEventListener("keydown",v,!0),document.removeEventListener("pointerup",a,!0),document.removeEventListener("transitionend",a,!0),document.removeEventListener("animationend",a,!0),b=!1}},[])}var g=p(require("react"));function P(e){let t=g.useId(),n=!!e,o=g.useMemo(()=>n?{"aria-describedby":t}:{},[n,t]);return{tooltipId:t,hasTooltip:n,accessibilityProps:o}}var u=p(require("react"));function N({pressed:e,onPressedChange:t,getAccessibleName:n,componentName:o}){let r=y(),i=u.useRef(!1),v=u.useCallback(a=>{let f=n();r(`${f} ${a?"pressed":"unpressed"}`),t?.(a)},[r,t,n]);return u.useEffect(()=>{},[e,t,o]),{handlePressedChange:v}}var B=p(require("react"));var s="kookie-appearance",O=`(function () {
|
|
10
|
+
var e = document.documentElement;
|
|
11
|
+
var a = null;
|
|
12
|
+
try { a = localStorage.getItem(${JSON.stringify(s)}); } catch (err) {}
|
|
13
|
+
var dark = a === "light" ? false : a === "dark" ? true : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
14
|
+
var mode = dark ? "dark" : "light";
|
|
15
|
+
e.classList.remove("light", "dark");
|
|
16
|
+
e.classList.add(mode);
|
|
17
|
+
e.setAttribute("data-appearance", mode);
|
|
18
|
+
e.style.colorScheme = mode;
|
|
19
|
+
})();`;var A=new Set;function k(){for(let e of A)e()}function S(){try{let e=globalThis.localStorage?.getItem(s);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function E(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function L(e){let t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e),t.setAttribute("data-appearance",e),t.style.colorScheme=e}function W(){let e=document.documentElement;return e.classList.contains("dark")||e.classList.contains("dark-theme")?"dark":e.classList.contains("light")||e.classList.contains("light-theme")?"light":E()}var m=null;function j(){let e=S(),t=W();return(!m||m.choice!==e||m.resolved!==t)&&(m={choice:e,resolved:t}),m}var F={choice:"system",resolved:"light"};function J(e){A.add(e);let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{S()==="system"&&(L(E()),k())},o=r=>{if(r.key!==s)return;let i=S();L(i==="system"?E():i),k()};return t.addEventListener("change",n),window.addEventListener("storage",o),()=>{A.delete(e),t.removeEventListener("change",n),window.removeEventListener("storage",o)}}function C(e){try{e==="system"?localStorage.removeItem(s):localStorage.setItem(s,e)}catch{}L(e==="system"?E():e),k()}function _(){let{choice:e,resolved:t}=B.useSyncExternalStore(J,j,()=>F);return{choice:e,appearance:t,setAppearance:C}}
|
|
10
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/index.ts", "../../../src/hooks/use-live-announcer.ts", "../../../src/hooks/use-body-pointer-events-cleanup.ts", "../../../src/hooks/use-tooltip-wrapper.ts", "../../../src/hooks/use-toggle-state.ts"],
|
|
4
|
-
"sourcesContent": ["export { useLiveAnnouncer } from './use-live-announcer.js';\nexport { useBodyPointerEventsCleanup } from './use-body-pointer-events-cleanup.js';\nexport { useTooltipWrapper } from './use-tooltip-wrapper.js';\nexport { useToggleState } from './use-toggle-state.js';\n", "import * as React from 'react';\n\n/**\n * Reference counter to track how many components are using the live region.\n * Only remove the live region when no components are using it.\n */\nlet liveRegionRefCount = 0;\n\n/**\n * Hook for making live announcements to screen readers\n * Creates a hidden aria-live region for announcing dynamic content changes\n */\nexport function useLiveAnnouncer() {\n // Track the timeout so we can clean it up on unmount\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // Create aria-live region if it doesn't exist\n React.useEffect(() => {\n let liveRegion = document.getElementById('rt-live-announcer');\n\n if (!liveRegion) {\n liveRegion = document.createElement('div');\n liveRegion.id = 'rt-live-announcer';\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute('aria-atomic', 'true');\n liveRegion.style.cssText = `\n position: absolute;\n left: -10000px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n `;\n document.body.appendChild(liveRegion);\n }\n\n // Increment ref count when component mounts\n liveRegionRefCount++;\n\n return () => {\n // Decrement ref count when component unmounts\n liveRegionRefCount--;\n\n // Clean up timeout on unmount\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n // Only remove the live region if no components are using it\n if (liveRegionRefCount === 0) {\n const region = document.getElementById('rt-live-announcer');\n if (region) {\n region.remove();\n }\n }\n };\n }, []);\n\n const announce = React.useCallback((message: string) => {\n const liveRegion = document.getElementById('rt-live-announcer');\n if (liveRegion) {\n // Clear any pending timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n // Clear previous announcements\n liveRegion.textContent = '';\n\n // Add new announcement with a small delay to ensure it's announced\n timeoutRef.current = setTimeout(() => {\n liveRegion.textContent = message;\n }, 100);\n }\n }, []);\n\n return announce;\n}\n", "import * as React from 'react';\n\nlet cleanupInstalled = false;\n\n/**\n * Hook to cleanup stuck pointer-events: none on document.body\n *\n * This addresses an issue where react-remove-scroll (used by Radix UI Dialog)\n * sometimes fails to restore body pointer-events after dialog closes,\n * leaving the page unclickable.\n */\nexport function useBodyPointerEventsCleanup() {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (cleanupInstalled) return;\n\n cleanupInstalled = true;\n\n // Deferred cleanups are tracked so unmount can cancel the ones still\n // queued. A timer that outlives the document reaches for `document.body`\n // after it is gone; under jsdom that surfaces as an unhandled\n // ReferenceError attributed to whichever test happened to be running.\n const pending = new Set<ReturnType<typeof setTimeout>>();\n\n const defer = (fn: () => void, delay: number) => {\n const id = setTimeout(() => {\n pending.delete(id);\n fn();\n }, delay);\n pending.add(id);\n };\n\n const hasOpenModal = (): boolean => {\n // Check for open dialogs/alertdialogs\n const hasDialogs = Boolean(\n document.querySelector(\n '[role=\"dialog\"][aria-modal=\"true\"], [role=\"alertdialog\"][aria-modal=\"true\"]',\n ),\n );\n\n // Also check for any Radix overlays that are still mounted\n const hasRadixOverlays = Boolean(\n document.querySelector('[data-radix-popper-content-wrapper], [data-state=\"open\"]'),\n );\n\n return hasDialogs || hasRadixOverlays;\n };\n\n const forceCleanup = () => {\n // Aggressive cleanup - remove pointer-events regardless\n if (document.body.style.pointerEvents === 'none') {\n console.log('[KookieUI] Force cleaning stuck pointer-events: none from body');\n document.body.style.pointerEvents = '';\n\n // Also remove any scroll-lock related attributes\n document.body.removeAttribute('data-scroll-locked');\n document.body.removeAttribute('data-remove-scroll');\n\n // Remove any classes that might be causing issues\n document.body.classList.remove('ReactModal__Body--open');\n }\n };\n\n const safeCleanup = () => {\n if (document.body.style.pointerEvents === 'none' && !hasOpenModal()) {\n console.log('[KookieUI] Safe cleaning stuck pointer-events: none from body');\n document.body.style.pointerEvents = '';\n }\n };\n\n // Force cleanup on any click outside modal content\n const onDocumentClick = (event: Event) => {\n const target = event.target as Element;\n if (\n target &&\n !target.closest(\n '[role=\"dialog\"], [role=\"alertdialog\"], [data-radix-popper-content-wrapper]',\n )\n ) {\n // Clicked outside any modal - force cleanup after a short delay\n defer(forceCleanup, 100);\n }\n };\n\n // Force cleanup on ESC key\n const onEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n defer(forceCleanup, 200);\n }\n };\n\n // Safe cleanup on other interactions\n const onInteraction = () => {\n defer(safeCleanup, 50);\n };\n\n // Install global listeners\n document.addEventListener('click', onDocumentClick, true);\n document.addEventListener('keydown', onEscapeKey, true);\n document.addEventListener('pointerup', onInteraction, true);\n document.addEventListener('transitionend', onInteraction, true);\n document.addEventListener('animationend', onInteraction, true);\n\n // Watch for DOM changes that might indicate overlay removal\n const observer = new MutationObserver(() => {\n defer(safeCleanup, 0);\n });\n observer.observe(document.body, { childList: true, subtree: true, attributes: true });\n\n // Fallback periodic cleanup\n const intervalId = setInterval(() => {\n if (document.body.style.pointerEvents === 'none' && !hasOpenModal()) {\n console.log('[KookieUI] Periodic cleanup of stuck pointer-events');\n document.body.style.pointerEvents = '';\n }\n }, 1000);\n\n // Initial cleanup\n defer(safeCleanup, 100);\n\n // Tear everything down together. The observer is the important one: it\n // fires while React unmounts the tree, so leaving it connected keeps\n // queueing work against a document that is about to go away. Releasing the\n // latch lets a later mount reinstall.\n return () => {\n clearInterval(intervalId);\n\n pending.forEach(clearTimeout);\n pending.clear();\n\n observer.disconnect();\n\n document.removeEventListener('click', onDocumentClick, true);\n document.removeEventListener('keydown', onEscapeKey, true);\n document.removeEventListener('pointerup', onInteraction, true);\n document.removeEventListener('transitionend', onInteraction, true);\n document.removeEventListener('animationend', onInteraction, true);\n\n cleanupInstalled = false;\n };\n }, []);\n}\n", "import * as React from 'react';\n\n/**\n * Hook for managing tooltip accessibility props and conditional rendering.\n * Encapsulates tooltip ID generation and aria-describedby binding.\n *\n * @param tooltip - The tooltip content (if any)\n * @returns Object containing tooltipId, hasTooltip flag, and accessibility props\n *\n * @example\n * ```tsx\n * const { tooltipId, hasTooltip, accessibilityProps } = useTooltipWrapper(tooltip);\n *\n * const button = <button {...accessibilityProps}>Click me</button>;\n *\n * if (!hasTooltip) return button;\n *\n * return <Tooltip id={tooltipId} content={tooltip}>{button}</Tooltip>;\n * ```\n */\nexport function useTooltipWrapper(tooltip: React.ReactNode) {\n const tooltipId = React.useId();\n const hasTooltip = Boolean(tooltip);\n\n const accessibilityProps = React.useMemo(() => (hasTooltip ? { 'aria-describedby': tooltipId } : {}), [hasTooltip, tooltipId]);\n\n return { tooltipId, hasTooltip, accessibilityProps };\n}\n", "import * as React from 'react';\nimport { useLiveAnnouncer } from './use-live-announcer.js';\n\n/**\n * Options for the useToggleState hook\n */\ninterface UseToggleStateOptions {\n /** Controlled pressed state */\n pressed?: boolean;\n /** Callback when pressed state changes */\n onPressedChange?: (pressed: boolean) => void;\n /** Function to get the accessible name for announcements */\n getAccessibleName: () => string;\n /** Component name for warning messages */\n componentName: string;\n}\n\n/**\n * Hook for shared toggle button state management.\n * Provides accessibility announcements and controlled/uncontrolled warnings.\n *\n * @param options - Configuration options for the toggle state\n * @returns Object containing the handlePressedChange callback\n *\n * @example\n * ```tsx\n * const getAccessibleName = React.useCallback(() => 'Toggle button', []);\n *\n * const { handlePressedChange } = useToggleState({\n * pressed,\n * onPressedChange,\n * getAccessibleName,\n * componentName: 'ToggleButton',\n * });\n * ```\n */\nexport function useToggleState({ pressed, onPressedChange, getAccessibleName, componentName }: UseToggleStateOptions) {\n const announce = useLiveAnnouncer();\n\n // Track if we've already warned about controlled without handler\n const warnedRef = React.useRef(false);\n\n /**\n * Memoized handler for state changes with accessibility announcements.\n * Announces the new state immediately for screen readers.\n */\n const handlePressedChange = React.useCallback(\n (newPressed: boolean) => {\n const accessibleName = getAccessibleName();\n // Announce the state change for screen readers\n announce(`${accessibleName} ${newPressed ? 'pressed' : 'unpressed'}`);\n // Call the user's change handler\n onPressedChange?.(newPressed);\n },\n [announce, onPressedChange, getAccessibleName],\n );\n\n // Development-only warning for controlled/uncontrolled pattern\n // Only warns once to avoid console spam\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'development' && pressed !== undefined && onPressedChange === undefined && !warnedRef.current) {\n warnedRef.current = true;\n console.warn(\n `${componentName}: You provided a \\`pressed\\` prop without an \\`onPressedChange\\` handler. ` +\n 'This will result in a read-only toggle button. If you want the button to be interactive, ' +\n 'you should provide an `onPressedChange` handler.',\n );\n }\n }, [pressed, onPressedChange, componentName]);\n\n return { handlePressedChange };\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
6
|
-
"names": ["hooks_exports", "__export", "useBodyPointerEventsCleanup", "useLiveAnnouncer", "useToggleState", "useTooltipWrapper", "__toCommonJS", "React", "liveRegionRefCount", "useLiveAnnouncer", "timeoutRef", "liveRegion", "region", "message", "React", "cleanupInstalled", "useBodyPointerEventsCleanup", "pending", "defer", "fn", "delay", "id", "hasOpenModal", "hasDialogs", "hasRadixOverlays", "forceCleanup", "safeCleanup", "onDocumentClick", "event", "target", "onEscapeKey", "onInteraction", "observer", "intervalId", "React", "useTooltipWrapper", "tooltip", "tooltipId", "hasTooltip", "accessibilityProps", "React", "useToggleState", "pressed", "onPressedChange", "getAccessibleName", "componentName", "announce", "useLiveAnnouncer", "warnedRef", "handlePressedChange", "newPressed", "accessibleName"]
|
|
3
|
+
"sources": ["../../../src/hooks/index.ts", "../../../src/hooks/use-live-announcer.ts", "../../../src/hooks/use-body-pointer-events-cleanup.ts", "../../../src/hooks/use-tooltip-wrapper.ts", "../../../src/hooks/use-toggle-state.ts", "../../../src/hooks/use-appearance.ts", "../../../src/hooks/appearance-script.ts"],
|
|
4
|
+
"sourcesContent": ["export { useLiveAnnouncer } from './use-live-announcer.js';\nexport { useBodyPointerEventsCleanup } from './use-body-pointer-events-cleanup.js';\nexport { useTooltipWrapper } from './use-tooltip-wrapper.js';\nexport { useToggleState } from './use-toggle-state.js';\nexport { useAppearance, setAppearance } from './use-appearance.js';\nexport { appearanceScript, APPEARANCE_STORAGE_KEY } from './appearance-script.js';\nexport type { AppearanceChoice, ResolvedAppearance } from './use-appearance.js';\n", "import * as React from 'react';\n\n/**\n * Reference counter to track how many components are using the live region.\n * Only remove the live region when no components are using it.\n */\nlet liveRegionRefCount = 0;\n\n/**\n * Hook for making live announcements to screen readers\n * Creates a hidden aria-live region for announcing dynamic content changes\n */\nexport function useLiveAnnouncer() {\n // Track the timeout so we can clean it up on unmount\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // Create aria-live region if it doesn't exist\n React.useEffect(() => {\n let liveRegion = document.getElementById('rt-live-announcer');\n\n if (!liveRegion) {\n liveRegion = document.createElement('div');\n liveRegion.id = 'rt-live-announcer';\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute('aria-atomic', 'true');\n liveRegion.style.cssText = `\n position: absolute;\n left: -10000px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n `;\n document.body.appendChild(liveRegion);\n }\n\n // Increment ref count when component mounts\n liveRegionRefCount++;\n\n return () => {\n // Decrement ref count when component unmounts\n liveRegionRefCount--;\n\n // Clean up timeout on unmount\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n // Only remove the live region if no components are using it\n if (liveRegionRefCount === 0) {\n const region = document.getElementById('rt-live-announcer');\n if (region) {\n region.remove();\n }\n }\n };\n }, []);\n\n const announce = React.useCallback((message: string) => {\n const liveRegion = document.getElementById('rt-live-announcer');\n if (liveRegion) {\n // Clear any pending timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n // Clear previous announcements\n liveRegion.textContent = '';\n\n // Add new announcement with a small delay to ensure it's announced\n timeoutRef.current = setTimeout(() => {\n liveRegion.textContent = message;\n }, 100);\n }\n }, []);\n\n return announce;\n}\n", "import * as React from 'react';\n\nlet cleanupInstalled = false;\n\n/**\n * Hook to cleanup stuck pointer-events: none on document.body\n *\n * This addresses an issue where react-remove-scroll (used by Radix UI Dialog)\n * sometimes fails to restore body pointer-events after dialog closes,\n * leaving the page unclickable.\n */\nexport function useBodyPointerEventsCleanup() {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (cleanupInstalled) return;\n\n cleanupInstalled = true;\n\n // Deferred cleanups are tracked so unmount can cancel the ones still\n // queued. A timer that outlives the document reaches for `document.body`\n // after it is gone; under jsdom that surfaces as an unhandled\n // ReferenceError attributed to whichever test happened to be running.\n const pending = new Set<ReturnType<typeof setTimeout>>();\n\n const defer = (fn: () => void, delay: number) => {\n const id = setTimeout(() => {\n pending.delete(id);\n fn();\n }, delay);\n pending.add(id);\n };\n\n const hasOpenModal = (): boolean => {\n // Check for open dialogs/alertdialogs\n const hasDialogs = Boolean(\n document.querySelector(\n '[role=\"dialog\"][aria-modal=\"true\"], [role=\"alertdialog\"][aria-modal=\"true\"]',\n ),\n );\n\n // Also check for any Radix overlays that are still mounted\n const hasRadixOverlays = Boolean(\n document.querySelector('[data-radix-popper-content-wrapper], [data-state=\"open\"]'),\n );\n\n return hasDialogs || hasRadixOverlays;\n };\n\n const forceCleanup = () => {\n // Aggressive cleanup - remove pointer-events regardless\n if (document.body.style.pointerEvents === 'none') {\n console.log('[KookieUI] Force cleaning stuck pointer-events: none from body');\n document.body.style.pointerEvents = '';\n\n // Also remove any scroll-lock related attributes\n document.body.removeAttribute('data-scroll-locked');\n document.body.removeAttribute('data-remove-scroll');\n\n // Remove any classes that might be causing issues\n document.body.classList.remove('ReactModal__Body--open');\n }\n };\n\n const safeCleanup = () => {\n if (document.body.style.pointerEvents === 'none' && !hasOpenModal()) {\n console.log('[KookieUI] Safe cleaning stuck pointer-events: none from body');\n document.body.style.pointerEvents = '';\n }\n };\n\n // Force cleanup on any click outside modal content\n const onDocumentClick = (event: Event) => {\n const target = event.target as Element;\n if (\n target &&\n !target.closest(\n '[role=\"dialog\"], [role=\"alertdialog\"], [data-radix-popper-content-wrapper]',\n )\n ) {\n // Clicked outside any modal - force cleanup after a short delay\n defer(forceCleanup, 100);\n }\n };\n\n // Force cleanup on ESC key\n const onEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n defer(forceCleanup, 200);\n }\n };\n\n // Safe cleanup on other interactions\n const onInteraction = () => {\n defer(safeCleanup, 50);\n };\n\n // Install global listeners\n document.addEventListener('click', onDocumentClick, true);\n document.addEventListener('keydown', onEscapeKey, true);\n document.addEventListener('pointerup', onInteraction, true);\n document.addEventListener('transitionend', onInteraction, true);\n document.addEventListener('animationend', onInteraction, true);\n\n // Watch for DOM changes that might indicate overlay removal\n const observer = new MutationObserver(() => {\n defer(safeCleanup, 0);\n });\n observer.observe(document.body, { childList: true, subtree: true, attributes: true });\n\n // Fallback periodic cleanup\n const intervalId = setInterval(() => {\n if (document.body.style.pointerEvents === 'none' && !hasOpenModal()) {\n console.log('[KookieUI] Periodic cleanup of stuck pointer-events');\n document.body.style.pointerEvents = '';\n }\n }, 1000);\n\n // Initial cleanup\n defer(safeCleanup, 100);\n\n // Tear everything down together. The observer is the important one: it\n // fires while React unmounts the tree, so leaving it connected keeps\n // queueing work against a document that is about to go away. Releasing the\n // latch lets a later mount reinstall.\n return () => {\n clearInterval(intervalId);\n\n pending.forEach(clearTimeout);\n pending.clear();\n\n observer.disconnect();\n\n document.removeEventListener('click', onDocumentClick, true);\n document.removeEventListener('keydown', onEscapeKey, true);\n document.removeEventListener('pointerup', onInteraction, true);\n document.removeEventListener('transitionend', onInteraction, true);\n document.removeEventListener('animationend', onInteraction, true);\n\n cleanupInstalled = false;\n };\n }, []);\n}\n", "import * as React from 'react';\n\n/**\n * Hook for managing tooltip accessibility props and conditional rendering.\n * Encapsulates tooltip ID generation and aria-describedby binding.\n *\n * @param tooltip - The tooltip content (if any)\n * @returns Object containing tooltipId, hasTooltip flag, and accessibility props\n *\n * @example\n * ```tsx\n * const { tooltipId, hasTooltip, accessibilityProps } = useTooltipWrapper(tooltip);\n *\n * const button = <button {...accessibilityProps}>Click me</button>;\n *\n * if (!hasTooltip) return button;\n *\n * return <Tooltip id={tooltipId} content={tooltip}>{button}</Tooltip>;\n * ```\n */\nexport function useTooltipWrapper(tooltip: React.ReactNode) {\n const tooltipId = React.useId();\n const hasTooltip = Boolean(tooltip);\n\n const accessibilityProps = React.useMemo(() => (hasTooltip ? { 'aria-describedby': tooltipId } : {}), [hasTooltip, tooltipId]);\n\n return { tooltipId, hasTooltip, accessibilityProps };\n}\n", "import * as React from 'react';\nimport { useLiveAnnouncer } from './use-live-announcer.js';\n\n/**\n * Options for the useToggleState hook\n */\ninterface UseToggleStateOptions {\n /** Controlled pressed state */\n pressed?: boolean;\n /** Callback when pressed state changes */\n onPressedChange?: (pressed: boolean) => void;\n /** Function to get the accessible name for announcements */\n getAccessibleName: () => string;\n /** Component name for warning messages */\n componentName: string;\n}\n\n/**\n * Hook for shared toggle button state management.\n * Provides accessibility announcements and controlled/uncontrolled warnings.\n *\n * @param options - Configuration options for the toggle state\n * @returns Object containing the handlePressedChange callback\n *\n * @example\n * ```tsx\n * const getAccessibleName = React.useCallback(() => 'Toggle button', []);\n *\n * const { handlePressedChange } = useToggleState({\n * pressed,\n * onPressedChange,\n * getAccessibleName,\n * componentName: 'ToggleButton',\n * });\n * ```\n */\nexport function useToggleState({ pressed, onPressedChange, getAccessibleName, componentName }: UseToggleStateOptions) {\n const announce = useLiveAnnouncer();\n\n // Track if we've already warned about controlled without handler\n const warnedRef = React.useRef(false);\n\n /**\n * Memoized handler for state changes with accessibility announcements.\n * Announces the new state immediately for screen readers.\n */\n const handlePressedChange = React.useCallback(\n (newPressed: boolean) => {\n const accessibleName = getAccessibleName();\n // Announce the state change for screen readers\n announce(`${accessibleName} ${newPressed ? 'pressed' : 'unpressed'}`);\n // Call the user's change handler\n onPressedChange?.(newPressed);\n },\n [announce, onPressedChange, getAccessibleName],\n );\n\n // Development-only warning for controlled/uncontrolled pattern\n // Only warns once to avoid console spam\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'development' && pressed !== undefined && onPressedChange === undefined && !warnedRef.current) {\n warnedRef.current = true;\n console.warn(\n `${componentName}: You provided a \\`pressed\\` prop without an \\`onPressedChange\\` handler. ` +\n 'This will result in a read-only toggle button. If you want the button to be interactive, ' +\n 'you should provide an `onPressedChange` handler.',\n );\n }\n }, [pressed, onPressedChange, componentName]);\n\n return { handlePressedChange };\n}\n", "'use client';\n\nimport * as React from 'react';\nimport { APPEARANCE_STORAGE_KEY } from './appearance-script.js';\n\n/**\n * Light and dark mode, decided before the first paint and kept on `<html>`.\n *\n * The server cannot know the visitor's mode, so `appearanceScript` runs synchronously in\n * `<head>`: the stored choice first, `prefers-color-scheme` otherwise. It writes the `light`\n * or `dark` class (which every token and component stylesheet already keys off) and\n * `data-appearance` on `<html>`. The root `<Theme>` keeps `appearance=\"inherit\"`, so it\n * writes no class of its own and `<html>` is the one source of truth. Nested themes and\n * portals inherit it from there.\n *\n * `useAppearance` is the client half: an external store over `<html>` and the same storage\n * key. It never mirrors the mode into React state that could disagree with the DOM.\n */\n\ntype AppearanceChoice = 'system' | 'light' | 'dark';\ntype ResolvedAppearance = 'light' | 'dark';\n\nconst listeners = new Set<() => void>();\n\nfunction emit() {\n for (const listener of listeners) listener();\n}\n\nfunction readChoice(): AppearanceChoice {\n try {\n const value = globalThis.localStorage?.getItem(APPEARANCE_STORAGE_KEY);\n return value === 'light' || value === 'dark' ? value : 'system';\n } catch {\n return 'system';\n }\n}\n\nfunction systemAppearance(): ResolvedAppearance {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n}\n\nfunction stamp(mode: ResolvedAppearance) {\n const root = document.documentElement;\n root.classList.remove('light', 'dark');\n root.classList.add(mode);\n root.setAttribute('data-appearance', mode);\n root.style.colorScheme = mode;\n}\n\nfunction readResolved(): ResolvedAppearance {\n const root = document.documentElement;\n if (root.classList.contains('dark') || root.classList.contains('dark-theme')) return 'dark';\n if (root.classList.contains('light') || root.classList.contains('light-theme')) return 'light';\n return systemAppearance();\n}\n\nlet snapshot: { choice: AppearanceChoice; resolved: ResolvedAppearance } | null = null;\n\nfunction getSnapshot() {\n const choice = readChoice();\n const resolved = readResolved();\n if (!snapshot || snapshot.choice !== choice || snapshot.resolved !== resolved) {\n snapshot = { choice, resolved };\n }\n return snapshot;\n}\n\nconst serverSnapshot = { choice: 'system' as AppearanceChoice, resolved: 'light' as ResolvedAppearance };\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener);\n const media = window.matchMedia('(prefers-color-scheme: dark)');\n // With no stored choice, follow the system as it changes.\n const onSystemChange = () => {\n if (readChoice() === 'system') {\n stamp(systemAppearance());\n emit();\n }\n };\n // Another tab changed the choice.\n const onStorage = (event: StorageEvent) => {\n if (event.key !== APPEARANCE_STORAGE_KEY) return;\n const choice = readChoice();\n stamp(choice === 'system' ? systemAppearance() : choice);\n emit();\n };\n media.addEventListener('change', onSystemChange);\n window.addEventListener('storage', onStorage);\n return () => {\n listeners.delete(listener);\n media.removeEventListener('change', onSystemChange);\n window.removeEventListener('storage', onStorage);\n };\n}\n\n/** Applies a choice to `<html>` and stores it. The change applies even if storage is blocked. */\nfunction setAppearance(choice: AppearanceChoice) {\n try {\n if (choice === 'system') localStorage.removeItem(APPEARANCE_STORAGE_KEY);\n else localStorage.setItem(APPEARANCE_STORAGE_KEY, choice);\n } catch {\n // Storage is blocked: the mode still changes for this page.\n }\n stamp(choice === 'system' ? systemAppearance() : choice);\n emit();\n}\n\n/**\n * The page's light or dark mode. `choice` is what the person picked (`system` when they\n * haven't); `appearance` is what is showing. On the server and in the first client render it\n * reports `system` / `light`, then corrects without a hydration mismatch.\n */\nfunction useAppearance() {\n const { choice, resolved } = React.useSyncExternalStore(subscribe, getSnapshot, () => serverSnapshot);\n return { choice, appearance: resolved, setAppearance } as const;\n}\n\nexport { useAppearance, setAppearance };\nexport type { AppearanceChoice, ResolvedAppearance };\n", "/**\n * The pre-paint half of light and dark mode (see `use-appearance.ts`). Kept in its own module\n * with no client directive, so a server component such as a Next.js root layout can import the\n * string and inline it in `<head>`.\n */\n\nconst APPEARANCE_STORAGE_KEY = 'kookie-appearance';\n\n/**\n * Inline this in `<head>`, before any stylesheet paints, e.g.\n * `<script dangerouslySetInnerHTML={{ __html: appearanceScript }} />`.\n *\n * Storage is read inside its own try/catch: browsers that block site data throw on access,\n * and that must not skip the stamp. `matchMedia` always answers.\n */\nconst appearanceScript = `(function () {\n var e = document.documentElement;\n var a = null;\n try { a = localStorage.getItem(${JSON.stringify(APPEARANCE_STORAGE_KEY)}); } catch (err) {}\n var dark = a === \"light\" ? false : a === \"dark\" ? true : matchMedia(\"(prefers-color-scheme: dark)\").matches;\n var mode = dark ? \"dark\" : \"light\";\n e.classList.remove(\"light\", \"dark\");\n e.classList.add(mode);\n e.setAttribute(\"data-appearance\", mode);\n e.style.colorScheme = mode;\n})();`;\n\nexport { appearanceScript, APPEARANCE_STORAGE_KEY };\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAA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D,EAAiB,CAAC,EACxBL,EAAK,EAET,EAEMkB,EAAaC,GAAwB,CACzC,GAAIA,EAAM,MAAQf,EAAwB,OAC1C,IAAMQ,EAASV,EAAW,EAC1BI,EAAMM,IAAW,SAAWP,EAAiB,EAAIO,CAAM,EACvDZ,EAAK,CACP,EACA,OAAAgB,EAAM,iBAAiB,SAAUC,CAAc,EAC/C,OAAO,iBAAiB,UAAWC,CAAS,EACrC,IAAM,CACXnB,EAAU,OAAOE,CAAQ,EACzBe,EAAM,oBAAoB,SAAUC,CAAc,EAClD,OAAO,oBAAoB,UAAWC,CAAS,CACjD,CACF,CAGA,SAASE,EAAcR,EAA0B,CAC/C,GAAI,CACEA,IAAW,SAAU,aAAa,WAAWR,CAAsB,EAClE,aAAa,QAAQA,EAAwBQ,CAAM,CAC1D,MAAQ,CAER,CACAN,EAAMM,IAAW,SAAWP,EAAiB,EAAIO,CAAM,EACvDZ,EAAK,CACP,CAOA,SAASqB,GAAgB,CACvB,GAAM,CAAE,OAAAT,EAAQ,SAAAC,CAAS,EAAU,uBAAqBE,EAAWJ,EAAa,IAAMG,CAAc,EACpG,MAAO,CAAE,OAAAF,EAAQ,WAAYC,EAAU,cAAAO,CAAc,CACvD",
|
|
6
|
+
"names": ["hooks_exports", "__export", "APPEARANCE_STORAGE_KEY", "appearanceScript", "setAppearance", "useAppearance", "useBodyPointerEventsCleanup", "useLiveAnnouncer", "useToggleState", "useTooltipWrapper", "__toCommonJS", "React", "liveRegionRefCount", "useLiveAnnouncer", "timeoutRef", "liveRegion", "region", "message", "React", "cleanupInstalled", "useBodyPointerEventsCleanup", "pending", "defer", "fn", "delay", "id", "hasOpenModal", "hasDialogs", "hasRadixOverlays", "forceCleanup", "safeCleanup", "onDocumentClick", "event", "target", "onEscapeKey", "onInteraction", "observer", "intervalId", "React", "useTooltipWrapper", "tooltip", "tooltipId", "hasTooltip", "accessibilityProps", "React", "useToggleState", "pressed", "onPressedChange", "getAccessibleName", "componentName", "announce", "useLiveAnnouncer", "warnedRef", "handlePressedChange", "newPressed", "accessibleName", "React", "APPEARANCE_STORAGE_KEY", "appearanceScript", "listeners", "emit", "listener", "readChoice", "value", "APPEARANCE_STORAGE_KEY", "systemAppearance", "stamp", "mode", "root", "readResolved", "snapshot", "getSnapshot", "choice", "resolved", "serverSnapshot", "subscribe", "media", "onSystemChange", "onStorage", "event", "setAppearance", "useAppearance"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light and dark mode, decided before the first paint and kept on `<html>`.
|
|
3
|
+
*
|
|
4
|
+
* The server cannot know the visitor's mode, so `appearanceScript` runs synchronously in
|
|
5
|
+
* `<head>`: the stored choice first, `prefers-color-scheme` otherwise. It writes the `light`
|
|
6
|
+
* or `dark` class (which every token and component stylesheet already keys off) and
|
|
7
|
+
* `data-appearance` on `<html>`. The root `<Theme>` keeps `appearance="inherit"`, so it
|
|
8
|
+
* writes no class of its own and `<html>` is the one source of truth. Nested themes and
|
|
9
|
+
* portals inherit it from there.
|
|
10
|
+
*
|
|
11
|
+
* `useAppearance` is the client half: an external store over `<html>` and the same storage
|
|
12
|
+
* key. It never mirrors the mode into React state that could disagree with the DOM.
|
|
13
|
+
*/
|
|
14
|
+
type AppearanceChoice = 'system' | 'light' | 'dark';
|
|
15
|
+
type ResolvedAppearance = 'light' | 'dark';
|
|
16
|
+
/** Applies a choice to `<html>` and stores it. The change applies even if storage is blocked. */
|
|
17
|
+
declare function setAppearance(choice: AppearanceChoice): void;
|
|
18
|
+
/**
|
|
19
|
+
* The page's light or dark mode. `choice` is what the person picked (`system` when they
|
|
20
|
+
* haven't); `appearance` is what is showing. On the server and in the first client render it
|
|
21
|
+
* reports `system` / `light`, then corrects without a hydration mismatch.
|
|
22
|
+
*/
|
|
23
|
+
declare function useAppearance(): {
|
|
24
|
+
readonly choice: AppearanceChoice;
|
|
25
|
+
readonly appearance: ResolvedAppearance;
|
|
26
|
+
readonly setAppearance: typeof setAppearance;
|
|
27
|
+
};
|
|
28
|
+
export { useAppearance, setAppearance };
|
|
29
|
+
export type { AppearanceChoice, ResolvedAppearance };
|
|
30
|
+
//# sourceMappingURL=use-appearance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-appearance.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-appearance.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AAEH,KAAK,gBAAgB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AACpD,KAAK,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAC;AA2E3C,iGAAiG;AACjG,iBAAS,aAAa,CAAC,MAAM,EAAE,gBAAgB,QAS9C;AAED;;;;GAIG;AACH,iBAAS,aAAa;;;;EAGrB;AAED,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";"use client";var A=Object.create;var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var a in t)c(e,a,{get:t[a],enumerable:!0})},u=(e,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of y(t))!S.call(e,r)&&r!==a&&c(e,r,{get:()=>t[r],enumerable:!(o=f(t,r))||o.enumerable});return e};var R=(e,t,a)=>(a=e!=null?A(k(e)):{},u(t||!e||!e.__esModule?c(a,"default",{value:e,enumerable:!0}):a,e)),L=e=>u(c({},"__esModule",{value:!0}),e);var P={};E(P,{setAppearance:()=>g,useAppearance:()=>I});module.exports=L(P);var v=R(require("react"));var s="kookie-appearance",M=`(function () {
|
|
2
|
+
var e = document.documentElement;
|
|
3
|
+
var a = null;
|
|
4
|
+
try { a = localStorage.getItem(${JSON.stringify(s)}); } catch (err) {}
|
|
5
|
+
var dark = a === "light" ? false : a === "dark" ? true : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
6
|
+
var mode = dark ? "dark" : "light";
|
|
7
|
+
e.classList.remove("light", "dark");
|
|
8
|
+
e.classList.add(mode);
|
|
9
|
+
e.setAttribute("data-appearance", mode);
|
|
10
|
+
e.style.colorScheme = mode;
|
|
11
|
+
})();`;var l=new Set;function d(){for(let e of l)e()}function p(){try{let e=globalThis.localStorage?.getItem(s);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function i(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function m(e){let t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e),t.setAttribute("data-appearance",e),t.style.colorScheme=e}function C(){let e=document.documentElement;return e.classList.contains("dark")||e.classList.contains("dark-theme")?"dark":e.classList.contains("light")||e.classList.contains("light-theme")?"light":i()}var n=null;function w(){let e=p(),t=C();return(!n||n.choice!==e||n.resolved!==t)&&(n={choice:e,resolved:t}),n}var b={choice:"system",resolved:"light"};function x(e){l.add(e);let t=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>{p()==="system"&&(m(i()),d())},o=r=>{if(r.key!==s)return;let h=p();m(h==="system"?i():h),d()};return t.addEventListener("change",a),window.addEventListener("storage",o),()=>{l.delete(e),t.removeEventListener("change",a),window.removeEventListener("storage",o)}}function g(e){try{e==="system"?localStorage.removeItem(s):localStorage.setItem(s,e)}catch{}m(e==="system"?i():e),d()}function I(){let{choice:e,resolved:t}=v.useSyncExternalStore(x,w,()=>b);return{choice:e,appearance:t,setAppearance:g}}
|
|
12
|
+
//# sourceMappingURL=use-appearance.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/use-appearance.ts", "../../../src/hooks/appearance-script.ts"],
|
|
4
|
+
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport { APPEARANCE_STORAGE_KEY } from './appearance-script.js';\n\n/**\n * Light and dark mode, decided before the first paint and kept on `<html>`.\n *\n * The server cannot know the visitor's mode, so `appearanceScript` runs synchronously in\n * `<head>`: the stored choice first, `prefers-color-scheme` otherwise. It writes the `light`\n * or `dark` class (which every token and component stylesheet already keys off) and\n * `data-appearance` on `<html>`. The root `<Theme>` keeps `appearance=\"inherit\"`, so it\n * writes no class of its own and `<html>` is the one source of truth. Nested themes and\n * portals inherit it from there.\n *\n * `useAppearance` is the client half: an external store over `<html>` and the same storage\n * key. It never mirrors the mode into React state that could disagree with the DOM.\n */\n\ntype AppearanceChoice = 'system' | 'light' | 'dark';\ntype ResolvedAppearance = 'light' | 'dark';\n\nconst listeners = new Set<() => void>();\n\nfunction emit() {\n for (const listener of listeners) listener();\n}\n\nfunction readChoice(): AppearanceChoice {\n try {\n const value = globalThis.localStorage?.getItem(APPEARANCE_STORAGE_KEY);\n return value === 'light' || value === 'dark' ? value : 'system';\n } catch {\n return 'system';\n }\n}\n\nfunction systemAppearance(): ResolvedAppearance {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n}\n\nfunction stamp(mode: ResolvedAppearance) {\n const root = document.documentElement;\n root.classList.remove('light', 'dark');\n root.classList.add(mode);\n root.setAttribute('data-appearance', mode);\n root.style.colorScheme = mode;\n}\n\nfunction readResolved(): ResolvedAppearance {\n const root = document.documentElement;\n if (root.classList.contains('dark') || root.classList.contains('dark-theme')) return 'dark';\n if (root.classList.contains('light') || root.classList.contains('light-theme')) return 'light';\n return systemAppearance();\n}\n\nlet snapshot: { choice: AppearanceChoice; resolved: ResolvedAppearance } | null = null;\n\nfunction getSnapshot() {\n const choice = readChoice();\n const resolved = readResolved();\n if (!snapshot || snapshot.choice !== choice || snapshot.resolved !== resolved) {\n snapshot = { choice, resolved };\n }\n return snapshot;\n}\n\nconst serverSnapshot = { choice: 'system' as AppearanceChoice, resolved: 'light' as ResolvedAppearance };\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener);\n const media = window.matchMedia('(prefers-color-scheme: dark)');\n // With no stored choice, follow the system as it changes.\n const onSystemChange = () => {\n if (readChoice() === 'system') {\n stamp(systemAppearance());\n emit();\n }\n };\n // Another tab changed the choice.\n const onStorage = (event: StorageEvent) => {\n if (event.key !== APPEARANCE_STORAGE_KEY) return;\n const choice = readChoice();\n stamp(choice === 'system' ? systemAppearance() : choice);\n emit();\n };\n media.addEventListener('change', onSystemChange);\n window.addEventListener('storage', onStorage);\n return () => {\n listeners.delete(listener);\n media.removeEventListener('change', onSystemChange);\n window.removeEventListener('storage', onStorage);\n };\n}\n\n/** Applies a choice to `<html>` and stores it. The change applies even if storage is blocked. */\nfunction setAppearance(choice: AppearanceChoice) {\n try {\n if (choice === 'system') localStorage.removeItem(APPEARANCE_STORAGE_KEY);\n else localStorage.setItem(APPEARANCE_STORAGE_KEY, choice);\n } catch {\n // Storage is blocked: the mode still changes for this page.\n }\n stamp(choice === 'system' ? systemAppearance() : choice);\n emit();\n}\n\n/**\n * The page's light or dark mode. `choice` is what the person picked (`system` when they\n * haven't); `appearance` is what is showing. On the server and in the first client render it\n * reports `system` / `light`, then corrects without a hydration mismatch.\n */\nfunction useAppearance() {\n const { choice, resolved } = React.useSyncExternalStore(subscribe, getSnapshot, () => serverSnapshot);\n return { choice, appearance: resolved, setAppearance } as const;\n}\n\nexport { useAppearance, setAppearance };\nexport type { AppearanceChoice, ResolvedAppearance };\n", "/**\n * The pre-paint half of light and dark mode (see `use-appearance.ts`). Kept in its own module\n * with no client directive, so a server component such as a Next.js root layout can import the\n * string and inline it in `<head>`.\n */\n\nconst APPEARANCE_STORAGE_KEY = 'kookie-appearance';\n\n/**\n * Inline this in `<head>`, before any stylesheet paints, e.g.\n * `<script dangerouslySetInnerHTML={{ __html: appearanceScript }} />`.\n *\n * Storage is read inside its own try/catch: browsers that block site data throw on access,\n * and that must not skip the stamp. `matchMedia` always answers.\n */\nconst appearanceScript = `(function () {\n var e = document.documentElement;\n var a = null;\n try { a = localStorage.getItem(${JSON.stringify(APPEARANCE_STORAGE_KEY)}); } catch (err) {}\n var dark = a === \"light\" ? false : a === \"dark\" ? true : matchMedia(\"(prefers-color-scheme: dark)\").matches;\n var mode = dark ? \"dark\" : \"light\";\n e.classList.remove(\"light\", \"dark\");\n e.classList.add(mode);\n e.setAttribute(\"data-appearance\", mode);\n e.style.colorScheme = mode;\n})();`;\n\nexport { appearanceScript, APPEARANCE_STORAGE_KEY };\n"],
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,kBAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAuB,oBCIvB,IAAMC,EAAyB,oBASzBC,EAAmB;AAAA;AAAA;AAAA,mCAGU,KAAK,UAAUD,CAAsB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ODIzE,IAAME,EAAY,IAAI,IAEtB,SAASC,GAAO,CACd,QAAWC,KAAYF,EAAWE,EAAS,CAC7C,CAEA,SAASC,GAA+B,CACtC,GAAI,CACF,IAAMC,EAAQ,WAAW,cAAc,QAAQC,CAAsB,EACrE,OAAOD,IAAU,SAAWA,IAAU,OAASA,EAAQ,QACzD,MAAQ,CACN,MAAO,QACT,CACF,CAEA,SAASE,GAAuC,CAC9C,OAAO,OAAO,WAAW,8BAA8B,EAAE,QAAU,OAAS,OAC9E,CAEA,SAASC,EAAMC,EAA0B,CACvC,IAAMC,EAAO,SAAS,gBACtBA,EAAK,UAAU,OAAO,QAAS,MAAM,EACrCA,EAAK,UAAU,IAAID,CAAI,EACvBC,EAAK,aAAa,kBAAmBD,CAAI,EACzCC,EAAK,MAAM,YAAcD,CAC3B,CAEA,SAASE,GAAmC,CAC1C,IAAMD,EAAO,SAAS,gBACtB,OAAIA,EAAK,UAAU,SAAS,MAAM,GAAKA,EAAK,UAAU,SAAS,YAAY,EAAU,OACjFA,EAAK,UAAU,SAAS,OAAO,GAAKA,EAAK,UAAU,SAAS,aAAa,EAAU,QAChFH,EAAiB,CAC1B,CA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ANCE_STORAGE_KEY", "appearanceScript", "listeners", "emit", "listener", "readChoice", "value", "APPEARANCE_STORAGE_KEY", "systemAppearance", "stamp", "mode", "root", "readResolved", "snapshot", "getSnapshot", "choice", "resolved", "serverSnapshot", "subscribe", "media", "onSystemChange", "onStorage", "event", "setAppearance", "useAppearance"]
|
|
7
|
+
}
|