@maz-ui/themes 5.0.0-beta.11 → 5.0.0-beta.16
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,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Read a cookie by key.
|
|
3
|
+
*
|
|
4
|
+
* - On the client, the cookie is read from `document.cookie`.
|
|
5
|
+
* - On the server, pass the raw `Cookie` request header via `cookieHeader`
|
|
6
|
+
* (e.g. from `useSSRContext().event.node.req.headers.cookie` in Nuxt) to
|
|
7
|
+
* resolve the value during SSR. Without it, the function returns `null`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCookie(key: string, cookieHeader?: string): string | null;
|
|
2
10
|
export declare function setCookie(key: string, value: string): void;
|
|
3
11
|
/** Persisted preset name from `maz-preset` cookie, or `null`. */
|
|
4
12
|
export declare function getSavedPresetName(): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-storage.d.ts","sourceRoot":"","sources":["../../src/utils/cookie-storage.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"cookie-storage.d.ts","sourceRoot":"","sources":["../../src/utils/cookie-storage.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc3E;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAK1D;AAED,iEAAiE;AACjE,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAElD;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIzD;AAED,oEAAoE;AACpE,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isServer}from"@maz-ui/utils/helpers/isServer";var PRESET_COOKIE=`maz-preset`;function getCookie(key){
|
|
1
|
+
import{isServer}from"@maz-ui/utils/helpers/isServer";var PRESET_COOKIE=`maz-preset`;function getCookie(key,cookieHeader){let source=isServer()?cookieHeader:typeof document<`u`?document.cookie:void 0;if(!source)return null;let cookie=source.split(`;`).find(c=>c.trim().startsWith(`${key}=`));return cookie?decodeURIComponent(cookie.split(`=`)[1]):null}function setCookie(key,value){isServer()||(document.cookie=`${key}=${encodeURIComponent(value)}; path=/; max-age=${3600*24*365}; SameSite=Lax`)}function getSavedPresetName(){return getCookie(PRESET_COOKIE)}function saveResolvedPresetName(name){!name||getCookie(PRESET_COOKIE)===name||setCookie(PRESET_COOKIE,name)}function clearSavedPresetName(){isServer()||(document.cookie=`${PRESET_COOKIE}=; path=/; max-age=0; SameSite=Lax`)}export{clearSavedPresetName,getCookie,getSavedPresetName,saveResolvedPresetName,setCookie};
|
package/package.json
CHANGED