@maz-ui/utils 5.0.0-beta.11 → 5.0.0-beta.17

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.
@@ -0,0 +1,38 @@
1
+ export type CookieSameSite = 'Lax' | 'Strict' | 'None' | 'lax' | 'strict' | 'none';
2
+ export interface CookieOptions {
3
+ /** Path attribute. Defaults to `'/'`. Pass `null` to omit. */
4
+ path?: string | null;
5
+ /** Domain attribute. */
6
+ domain?: string;
7
+ /** Lifetime in seconds. Defaults to one year. Pass `null` to omit (session cookie). */
8
+ maxAge?: number | null;
9
+ /** Explicit expiration date. Takes precedence over `maxAge` when both are set. */
10
+ expires?: Date;
11
+ /** Restrict the cookie to HTTPS connections. */
12
+ secure?: boolean;
13
+ /** Same-site policy. Defaults to `'Lax'`. Pass `null` to omit. */
14
+ sameSite?: CookieSameSite | null;
15
+ /** Mark the cookie as partitioned (CHIPS). */
16
+ partitioned?: boolean;
17
+ }
18
+ /**
19
+ * Read a cookie by key.
20
+ *
21
+ * - On the client, the cookie is read from `document.cookie`.
22
+ * - On the server, pass the raw `Cookie` request header via `cookieHeader`
23
+ * (e.g. from `useSSRContext().event.node.req.headers.cookie` in Nuxt) to
24
+ * resolve the value during SSR. Without it, the function returns `null`.
25
+ */
26
+ export declare function getCookie(key: string, cookieHeader?: string): string | null;
27
+ /**
28
+ * Write a cookie via `document.cookie` with full attribute support.
29
+ *
30
+ * No-op on the server. `HttpOnly` is intentionally omitted as it cannot be set
31
+ * from `document.cookie` (browsers reject it).
32
+ */
33
+ export declare function setCookie(key: string, value: string, options?: CookieOptions): void;
34
+ /**
35
+ * Delete a cookie by writing `max-age=0`. `path` and `domain` must match the
36
+ * cookie's original attributes for the browser to actually drop it.
37
+ */
38
+ export declare function deleteCookie(key: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
@@ -0,0 +1 @@
1
+ import{isServer}from"./isServer.js";var ONE_YEAR_SECONDS=3600*24*365;function getCookie(key,cookieHeader){let source=isServer()?cookieHeader:document.cookie;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,options={}){if(isServer())return;let{path=`/`,domain,maxAge=ONE_YEAR_SECONDS,expires,secure,sameSite=`Lax`,partitioned}=options;let parts=[`${key}=${encodeURIComponent(value)}`];path!=null&&parts.push(`path=${path}`),domain&&parts.push(`domain=${domain}`),maxAge!=null&&parts.push(`max-age=${maxAge}`),expires&&parts.push(`expires=${expires.toUTCString()}`),secure&&parts.push(`secure`),sameSite!=null&&parts.push(`SameSite=${sameSite}`),partitioned&&parts.push(`partitioned`),document.cookie=parts.join(`; `)}function deleteCookie(key,options={}){setCookie(key,``,{...options,maxAge:0})}export{deleteCookie,getCookie,setCookie};
@@ -1,6 +1,7 @@
1
1
  export * from './camelCase';
2
2
  export * from './capitalize';
3
3
  export * from './checkAvailability';
4
+ export * from './cookie';
4
5
  export * from './countryCodeToUnicodeFlag';
5
6
  export * from './debounce';
6
7
  export * from './debounceCallback';
@@ -1 +1 @@
1
- import{camelCase}from"./camelCase.js";import{capitalize}from"./capitalize.js";import{checkAvailability}from"./checkAvailability.js";import{truthyFilter}from"./truthyFilter.js";import{countryCodeToUnicodeFlag}from"./countryCodeToUnicodeFlag.js";import{debounce}from"./debounce.js";import{debounceCallback}from"./debounceCallback.js";import{debounceId}from"./debounceId.js";import{formatCurrency}from"./formatCurrency.js";import{formatDate}from"./formatDate.js";import{formatJson}from"./formatJson.js";import{formatNumber}from"./formatNumber.js";import{getCountryFlagUrl}from"./getCountryFlagUrl.js";import{getErrorMessage}from"./getErrorMessage.js";import{isClient}from"./isClient.js";import{IdleTimeout}from"./idleTimeout.js";import{isEqual}from"./isEqual.js";import{isServer}from"./isServer.js";import{isStandaloneMode}from"./isStandaloneMode.js";import{kebabCase}from"./kebabCase.js";import{pascalCase}from"./pascalCase.js";import{snakeCase}from"./snakeCase.js";import{normalizeString}from"./normalizeString.js";import{ScriptLoader}from"./scriptLoader.js";import{sleep}from"./sleep.js";import{Swipe}from"./swipeHandler.js";import{TextareaAutogrow}from"./TextareaAutogrow.js";import{throttle}from"./throttle.js";import{throttleId}from"./throttleId.js";import{upperFirst}from"./upperFirst.js";import{UserVisibility}from"./userVisibility.js";export{IdleTimeout,ScriptLoader,Swipe,TextareaAutogrow,UserVisibility,camelCase,capitalize,checkAvailability,countryCodeToUnicodeFlag,debounce,debounceCallback,debounceId,formatCurrency,formatDate,formatJson,formatNumber,getCountryFlagUrl,getErrorMessage,isClient,isEqual,isServer,isStandaloneMode,kebabCase,normalizeString,pascalCase,sleep,snakeCase,throttle,throttleId,truthyFilter,upperFirst};
1
+ import{camelCase}from"./camelCase.js";import{capitalize}from"./capitalize.js";import{checkAvailability}from"./checkAvailability.js";import{isServer}from"./isServer.js";import{deleteCookie,getCookie,setCookie}from"./cookie.js";import{truthyFilter}from"./truthyFilter.js";import{countryCodeToUnicodeFlag}from"./countryCodeToUnicodeFlag.js";import{debounce}from"./debounce.js";import{debounceCallback}from"./debounceCallback.js";import{debounceId}from"./debounceId.js";import{formatCurrency}from"./formatCurrency.js";import{formatDate}from"./formatDate.js";import{formatJson}from"./formatJson.js";import{formatNumber}from"./formatNumber.js";import{getCountryFlagUrl}from"./getCountryFlagUrl.js";import{getErrorMessage}from"./getErrorMessage.js";import{isClient}from"./isClient.js";import{IdleTimeout}from"./idleTimeout.js";import{isEqual}from"./isEqual.js";import{isStandaloneMode}from"./isStandaloneMode.js";import{kebabCase}from"./kebabCase.js";import{pascalCase}from"./pascalCase.js";import{snakeCase}from"./snakeCase.js";import{normalizeString}from"./normalizeString.js";import{ScriptLoader}from"./scriptLoader.js";import{sleep}from"./sleep.js";import{Swipe}from"./swipeHandler.js";import{TextareaAutogrow}from"./TextareaAutogrow.js";import{throttle}from"./throttle.js";import{throttleId}from"./throttleId.js";import{upperFirst}from"./upperFirst.js";import{UserVisibility}from"./userVisibility.js";export{IdleTimeout,ScriptLoader,Swipe,TextareaAutogrow,UserVisibility,camelCase,capitalize,checkAvailability,countryCodeToUnicodeFlag,debounce,debounceCallback,debounceId,deleteCookie,formatCurrency,formatDate,formatJson,formatNumber,getCookie,getCountryFlagUrl,getErrorMessage,isClient,isEqual,isServer,isStandaloneMode,kebabCase,normalizeString,pascalCase,setCookie,sleep,snakeCase,throttle,throttleId,truthyFilter,upperFirst};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{camelCase}from"./helpers/camelCase.js";import{capitalize}from"./helpers/capitalize.js";import{checkAvailability}from"./helpers/checkAvailability.js";import{truthyFilter}from"./helpers/truthyFilter.js";import{countryCodeToUnicodeFlag}from"./helpers/countryCodeToUnicodeFlag.js";import{debounce}from"./helpers/debounce.js";import{debounceCallback}from"./helpers/debounceCallback.js";import{debounceId}from"./helpers/debounceId.js";import{formatCurrency}from"./helpers/formatCurrency.js";import{formatDate}from"./helpers/formatDate.js";import{formatJson}from"./helpers/formatJson.js";import{formatNumber}from"./helpers/formatNumber.js";import{getCountryFlagUrl}from"./helpers/getCountryFlagUrl.js";import{getErrorMessage}from"./helpers/getErrorMessage.js";import{isClient}from"./helpers/isClient.js";import{IdleTimeout}from"./helpers/idleTimeout.js";import{isEqual}from"./helpers/isEqual.js";import{isServer}from"./helpers/isServer.js";import{isStandaloneMode}from"./helpers/isStandaloneMode.js";import{kebabCase}from"./helpers/kebabCase.js";import{pascalCase}from"./helpers/pascalCase.js";import{snakeCase}from"./helpers/snakeCase.js";import{normalizeString}from"./helpers/normalizeString.js";import{ScriptLoader}from"./helpers/scriptLoader.js";import{sleep}from"./helpers/sleep.js";import{Swipe}from"./helpers/swipeHandler.js";import{TextareaAutogrow}from"./helpers/TextareaAutogrow.js";import{throttle}from"./helpers/throttle.js";import{throttleId}from"./helpers/throttleId.js";import{upperFirst}from"./helpers/upperFirst.js";import{UserVisibility}from"./helpers/userVisibility.js";import"./helpers/index.js";export{IdleTimeout,ScriptLoader,Swipe,TextareaAutogrow,UserVisibility,camelCase,capitalize,checkAvailability,countryCodeToUnicodeFlag,debounce,debounceCallback,debounceId,formatCurrency,formatDate,formatJson,formatNumber,getCountryFlagUrl,getErrorMessage,isClient,isEqual,isServer,isStandaloneMode,kebabCase,normalizeString,pascalCase,sleep,snakeCase,throttle,throttleId,truthyFilter,upperFirst};
1
+ import{camelCase}from"./helpers/camelCase.js";import{capitalize}from"./helpers/capitalize.js";import{checkAvailability}from"./helpers/checkAvailability.js";import{isServer}from"./helpers/isServer.js";import{deleteCookie,getCookie,setCookie}from"./helpers/cookie.js";import{truthyFilter}from"./helpers/truthyFilter.js";import{countryCodeToUnicodeFlag}from"./helpers/countryCodeToUnicodeFlag.js";import{debounce}from"./helpers/debounce.js";import{debounceCallback}from"./helpers/debounceCallback.js";import{debounceId}from"./helpers/debounceId.js";import{formatCurrency}from"./helpers/formatCurrency.js";import{formatDate}from"./helpers/formatDate.js";import{formatJson}from"./helpers/formatJson.js";import{formatNumber}from"./helpers/formatNumber.js";import{getCountryFlagUrl}from"./helpers/getCountryFlagUrl.js";import{getErrorMessage}from"./helpers/getErrorMessage.js";import{isClient}from"./helpers/isClient.js";import{IdleTimeout}from"./helpers/idleTimeout.js";import{isEqual}from"./helpers/isEqual.js";import{isStandaloneMode}from"./helpers/isStandaloneMode.js";import{kebabCase}from"./helpers/kebabCase.js";import{pascalCase}from"./helpers/pascalCase.js";import{snakeCase}from"./helpers/snakeCase.js";import{normalizeString}from"./helpers/normalizeString.js";import{ScriptLoader}from"./helpers/scriptLoader.js";import{sleep}from"./helpers/sleep.js";import{Swipe}from"./helpers/swipeHandler.js";import{TextareaAutogrow}from"./helpers/TextareaAutogrow.js";import{throttle}from"./helpers/throttle.js";import{throttleId}from"./helpers/throttleId.js";import{upperFirst}from"./helpers/upperFirst.js";import{UserVisibility}from"./helpers/userVisibility.js";import"./helpers/index.js";export{IdleTimeout,ScriptLoader,Swipe,TextareaAutogrow,UserVisibility,camelCase,capitalize,checkAvailability,countryCodeToUnicodeFlag,debounce,debounceCallback,debounceId,deleteCookie,formatCurrency,formatDate,formatJson,formatNumber,getCookie,getCountryFlagUrl,getErrorMessage,isClient,isEqual,isServer,isStandaloneMode,kebabCase,normalizeString,pascalCase,setCookie,sleep,snakeCase,throttle,throttleId,truthyFilter,upperFirst};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/utils",
3
3
  "type": "module",
4
- "version": "5.0.0-beta.11",
4
+ "version": "5.0.0-beta.17",
5
5
  "description": "Utils of maz-ui for JavaScript/TypeScript users",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",