@just-web/toolkits 2.0.0 → 3.0.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/attributes/get-attribute.cjs +1 -1
- package/dist/attributes/get-attribute.cjs.map +1 -1
- package/dist/attributes/get-attribute.d.cts +2 -2
- package/dist/attributes/get-attribute.d.cts.map +1 -1
- package/dist/attributes/get-attribute.d.mts +2 -2
- package/dist/attributes/get-attribute.d.mts.map +1 -1
- package/dist/attributes/get-attribute.mjs +1 -1
- package/dist/attributes/get-attribute.mjs.map +1 -1
- package/dist/attributes/get-data-attribute.cjs +1 -1
- package/dist/attributes/get-data-attribute.cjs.map +1 -1
- package/dist/attributes/get-data-attribute.d.cts +2 -2
- package/dist/attributes/get-data-attribute.d.cts.map +1 -1
- package/dist/attributes/get-data-attribute.d.mts +2 -2
- package/dist/attributes/get-data-attribute.d.mts.map +1 -1
- package/dist/attributes/get-data-attribute.mjs +1 -1
- package/dist/attributes/get-data-attribute.mjs.map +1 -1
- package/dist/attributes/observe-attribute.cjs +11 -8
- package/dist/attributes/observe-attribute.cjs.map +1 -1
- package/dist/attributes/observe-attribute.d.cts +7 -7
- package/dist/attributes/observe-attribute.d.cts.map +1 -1
- package/dist/attributes/observe-attribute.d.mts +7 -7
- package/dist/attributes/observe-attribute.d.mts.map +1 -1
- package/dist/attributes/observe-attribute.mjs +11 -8
- package/dist/attributes/observe-attribute.mjs.map +1 -1
- package/dist/attributes/observe-data-attribute.cjs +7 -10
- package/dist/attributes/observe-data-attribute.cjs.map +1 -1
- package/dist/attributes/observe-data-attribute.d.cts +8 -11
- package/dist/attributes/observe-data-attribute.d.cts.map +1 -1
- package/dist/attributes/observe-data-attribute.d.mts +8 -11
- package/dist/attributes/observe-data-attribute.d.mts.map +1 -1
- package/dist/attributes/observe-data-attribute.mjs +7 -10
- package/dist/attributes/observe-data-attribute.mjs.map +1 -1
- package/dist/color-scheme/color-scheme.types.d.cts +11 -0
- package/dist/color-scheme/color-scheme.types.d.cts.map +1 -0
- package/dist/color-scheme/color-scheme.types.d.mts +11 -0
- package/dist/color-scheme/color-scheme.types.d.mts.map +1 -0
- package/dist/color-scheme/get-prefers-color-scheme.cjs +3 -1
- package/dist/color-scheme/get-prefers-color-scheme.cjs.map +1 -1
- package/dist/color-scheme/get-prefers-color-scheme.d.cts +7 -2
- package/dist/color-scheme/get-prefers-color-scheme.d.cts.map +1 -1
- package/dist/color-scheme/get-prefers-color-scheme.d.mts +7 -2
- package/dist/color-scheme/get-prefers-color-scheme.d.mts.map +1 -1
- package/dist/color-scheme/get-prefers-color-scheme.mjs +3 -1
- package/dist/color-scheme/get-prefers-color-scheme.mjs.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.cjs.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.cts +4 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.cts.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.mts +4 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.mts.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.mjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/react/hooks/use-attribute.cjs +8 -9
- package/dist/react/hooks/use-attribute.cjs.map +1 -1
- package/dist/react/hooks/use-attribute.d.cts +4 -4
- package/dist/react/hooks/use-attribute.d.mts +4 -4
- package/dist/react/hooks/use-attribute.mjs +8 -9
- package/dist/react/hooks/use-attribute.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.cjs +1 -1
- package/dist/react/hooks/use-theme-by-class-name.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.d.cts +2 -2
- package/dist/react/hooks/use-theme-by-class-name.d.mts +2 -2
- package/dist/react/hooks/use-theme-by-class-name.mjs +1 -1
- package/dist/react/hooks/use-theme-by-class-name.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.cjs +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.d.cts +2 -2
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts +2 -2
- package/dist/react/hooks/use-theme-by-data-attribute.mjs +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.mjs.map +1 -1
- package/dist/react/theme/create-theme-hook.cjs.map +1 -1
- package/dist/react/theme/create-theme-hook.mjs.map +1 -1
- package/dist/theme/_utils/parse-stored-theme.cjs +1 -1
- package/dist/theme/_utils/parse-stored-theme.cjs.map +1 -1
- package/dist/theme/_utils/parse-stored-theme.mjs +1 -1
- package/dist/theme/_utils/parse-stored-theme.mjs.map +1 -1
- package/dist/theme/_utils/set-theme-to-stores.cjs +1 -1
- package/dist/theme/_utils/set-theme-to-stores.cjs.map +1 -1
- package/dist/theme/_utils/set-theme-to-stores.mjs +1 -1
- package/dist/theme/_utils/set-theme-to-stores.mjs.map +1 -1
- package/dist/theme/class-name/parse-class-name.cjs +1 -1
- package/dist/theme/class-name/parse-class-name.cjs.map +1 -1
- package/dist/theme/class-name/parse-class-name.d.cts +2 -2
- package/dist/theme/class-name/parse-class-name.d.cts.map +1 -1
- package/dist/theme/class-name/parse-class-name.d.mts +2 -2
- package/dist/theme/class-name/parse-class-name.d.mts.map +1 -1
- package/dist/theme/class-name/parse-class-name.mjs +1 -1
- package/dist/theme/class-name/parse-class-name.mjs.map +1 -1
- package/dist/theme/class-name/read-class-name.cjs +1 -1
- package/dist/theme/class-name/read-class-name.cjs.map +1 -1
- package/dist/theme/class-name/read-class-name.d.cts +2 -2
- package/dist/theme/class-name/read-class-name.d.cts.map +1 -1
- package/dist/theme/class-name/read-class-name.d.mts +2 -2
- package/dist/theme/class-name/read-class-name.d.mts.map +1 -1
- package/dist/theme/class-name/read-class-name.mjs +1 -1
- package/dist/theme/class-name/read-class-name.mjs.map +1 -1
- package/dist/theme/class-name/stringify-class-name.cjs +4 -4
- package/dist/theme/class-name/stringify-class-name.cjs.map +1 -1
- package/dist/theme/class-name/stringify-class-name.d.cts +3 -3
- package/dist/theme/class-name/stringify-class-name.d.cts.map +1 -1
- package/dist/theme/class-name/stringify-class-name.d.mts +3 -3
- package/dist/theme/class-name/stringify-class-name.d.mts.map +1 -1
- package/dist/theme/class-name/stringify-class-name.mjs +4 -4
- package/dist/theme/class-name/stringify-class-name.mjs.map +1 -1
- package/dist/theme/class-name/subscribe-class-name.cjs +2 -3
- package/dist/theme/class-name/subscribe-class-name.cjs.map +1 -1
- package/dist/theme/class-name/subscribe-class-name.d.cts +2 -2
- package/dist/theme/class-name/subscribe-class-name.d.cts.map +1 -1
- package/dist/theme/class-name/subscribe-class-name.d.mts +2 -2
- package/dist/theme/class-name/subscribe-class-name.d.mts.map +1 -1
- package/dist/theme/class-name/subscribe-class-name.mjs +2 -3
- package/dist/theme/class-name/subscribe-class-name.mjs.map +1 -1
- package/dist/theme/class-name/write-class-name.cjs +2 -2
- package/dist/theme/class-name/write-class-name.cjs.map +1 -1
- package/dist/theme/class-name/write-class-name.d.cts +4 -4
- package/dist/theme/class-name/write-class-name.d.cts.map +1 -1
- package/dist/theme/class-name/write-class-name.d.mts +4 -4
- package/dist/theme/class-name/write-class-name.d.mts.map +1 -1
- package/dist/theme/class-name/write-class-name.mjs +2 -2
- package/dist/theme/class-name/write-class-name.mjs.map +1 -1
- package/dist/theme/compose-theme-stores.cjs.map +1 -1
- package/dist/theme/compose-theme-stores.mjs.map +1 -1
- package/dist/theme/cookie/write-cookie-theme.cjs +2 -2
- package/dist/theme/cookie/write-cookie-theme.cjs.map +1 -1
- package/dist/theme/cookie/write-cookie-theme.d.cts +2 -2
- package/dist/theme/cookie/write-cookie-theme.d.cts.map +1 -1
- package/dist/theme/cookie/write-cookie-theme.d.mts +2 -2
- package/dist/theme/cookie/write-cookie-theme.d.mts.map +1 -1
- package/dist/theme/cookie/write-cookie-theme.mjs +2 -2
- package/dist/theme/cookie/write-cookie-theme.mjs.map +1 -1
- package/dist/theme/data-attribute/parse-data-attribute.cjs +1 -1
- package/dist/theme/data-attribute/parse-data-attribute.cjs.map +1 -1
- package/dist/theme/data-attribute/parse-data-attribute.d.cts +2 -2
- package/dist/theme/data-attribute/parse-data-attribute.d.mts +2 -2
- package/dist/theme/data-attribute/parse-data-attribute.mjs +1 -1
- package/dist/theme/data-attribute/parse-data-attribute.mjs.map +1 -1
- package/dist/theme/data-attribute/read-data-attribute.cjs +1 -1
- package/dist/theme/data-attribute/read-data-attribute.cjs.map +1 -1
- package/dist/theme/data-attribute/read-data-attribute.d.cts +2 -2
- package/dist/theme/data-attribute/read-data-attribute.d.cts.map +1 -1
- package/dist/theme/data-attribute/read-data-attribute.d.mts +2 -2
- package/dist/theme/data-attribute/read-data-attribute.d.mts.map +1 -1
- package/dist/theme/data-attribute/read-data-attribute.mjs +1 -1
- package/dist/theme/data-attribute/read-data-attribute.mjs.map +1 -1
- package/dist/theme/data-attribute/stringify-data-attribute.cjs +4 -4
- package/dist/theme/data-attribute/stringify-data-attribute.cjs.map +1 -1
- package/dist/theme/data-attribute/stringify-data-attribute.d.cts +3 -3
- package/dist/theme/data-attribute/stringify-data-attribute.d.cts.map +1 -1
- package/dist/theme/data-attribute/stringify-data-attribute.d.mts +3 -3
- package/dist/theme/data-attribute/stringify-data-attribute.d.mts.map +1 -1
- package/dist/theme/data-attribute/stringify-data-attribute.mjs +4 -4
- package/dist/theme/data-attribute/stringify-data-attribute.mjs.map +1 -1
- package/dist/theme/data-attribute/subscribe-data-attribute.cjs +2 -3
- package/dist/theme/data-attribute/subscribe-data-attribute.cjs.map +1 -1
- package/dist/theme/data-attribute/subscribe-data-attribute.d.cts +2 -2
- package/dist/theme/data-attribute/subscribe-data-attribute.d.cts.map +1 -1
- package/dist/theme/data-attribute/subscribe-data-attribute.d.mts +2 -2
- package/dist/theme/data-attribute/subscribe-data-attribute.d.mts.map +1 -1
- package/dist/theme/data-attribute/subscribe-data-attribute.mjs +2 -3
- package/dist/theme/data-attribute/subscribe-data-attribute.mjs.map +1 -1
- package/dist/theme/data-attribute/write-data-attribute.cjs +3 -3
- package/dist/theme/data-attribute/write-data-attribute.cjs.map +1 -1
- package/dist/theme/data-attribute/write-data-attribute.d.cts +4 -4
- package/dist/theme/data-attribute/write-data-attribute.d.cts.map +1 -1
- package/dist/theme/data-attribute/write-data-attribute.d.mts +4 -4
- package/dist/theme/data-attribute/write-data-attribute.d.mts.map +1 -1
- package/dist/theme/data-attribute/write-data-attribute.mjs +3 -3
- package/dist/theme/data-attribute/write-data-attribute.mjs.map +1 -1
- package/dist/theme/local-storage/write-local-storage.cjs +1 -1
- package/dist/theme/local-storage/write-local-storage.cjs.map +1 -1
- package/dist/theme/local-storage/write-local-storage.d.cts +2 -2
- package/dist/theme/local-storage/write-local-storage.d.mts +2 -2
- package/dist/theme/local-storage/write-local-storage.mjs +1 -1
- package/dist/theme/local-storage/write-local-storage.mjs.map +1 -1
- package/dist/theme/session-storage/write-session-storage.cjs +1 -1
- package/dist/theme/session-storage/write-session-storage.cjs.map +1 -1
- package/dist/theme/session-storage/write-session-storage.d.cts +2 -2
- package/dist/theme/session-storage/write-session-storage.d.mts +2 -2
- package/dist/theme/session-storage/write-session-storage.mjs +1 -1
- package/dist/theme/session-storage/write-session-storage.mjs.map +1 -1
- package/dist/theme/theme-entry.types.d.cts +4 -2
- package/dist/theme/theme-entry.types.d.cts.map +1 -1
- package/dist/theme/theme-entry.types.d.mts +4 -2
- package/dist/theme/theme-entry.types.d.mts.map +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.cts +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.cts.map +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.mts +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.mts.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts +2 -2
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts +2 -2
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts +3 -3
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts +3 -3
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.cjs +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.cts +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.mts +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.mjs +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts +1 -1
- package/dist/theme/theme-store/theme-store.types.d.cts +1 -1
- package/dist/theme/theme-store/theme-store.types.d.cts.map +1 -1
- package/dist/theme/theme-store/theme-store.types.d.mts +1 -1
- package/dist/theme/theme-store/theme-store.types.d.mts.map +1 -1
- package/dist/theme/web-storage/write-web-storage.cjs +3 -3
- package/dist/theme/web-storage/write-web-storage.cjs.map +1 -1
- package/dist/theme/web-storage/write-web-storage.d.cts +2 -2
- package/dist/theme/web-storage/write-web-storage.d.mts +2 -2
- package/dist/theme/web-storage/write-web-storage.mjs +3 -3
- package/dist/theme/web-storage/write-web-storage.mjs.map +1 -1
- package/dist/utils/append-id.cjs +2 -2
- package/dist/utils/append-id.cjs.map +1 -1
- package/dist/utils/append-id.d.cts +3 -3
- package/dist/utils/append-id.d.mts +3 -3
- package/dist/utils/append-id.mjs +2 -2
- package/dist/utils/append-id.mjs.map +1 -1
- package/package.json +1 -1
- package/src/attributes/get-attribute.ts +5 -2
- package/src/attributes/get-data-attribute.ts +5 -2
- package/src/attributes/observe-attribute.ts +15 -10
- package/src/attributes/observe-data-attribute.ts +8 -11
- package/src/color-scheme/color-scheme.types.ts +7 -0
- package/src/color-scheme/get-prefers-color-scheme.ts +6 -4
- package/src/color-scheme/observe-prefers-color-scheme.ts +3 -1
- package/src/index.ts +1 -0
- package/src/react/hooks/use-attribute.ts +12 -13
- package/src/react/hooks/use-theme-by-class-name.ts +2 -2
- package/src/react/hooks/use-theme-by-data-attribute.ts +2 -2
- package/src/react/theme/create-theme-hook.ts +4 -6
- package/src/theme/_utils/parse-stored-theme.ts +2 -2
- package/src/theme/_utils/set-theme-to-stores.ts +3 -3
- package/src/theme/class-name/parse-class-name.ts +2 -2
- package/src/theme/class-name/read-class-name.ts +2 -2
- package/src/theme/class-name/stringify-class-name.ts +6 -6
- package/src/theme/class-name/subscribe-class-name.ts +3 -4
- package/src/theme/class-name/write-class-name.ts +4 -4
- package/src/theme/compose-theme-stores.ts +1 -1
- package/src/theme/cookie/write-cookie-theme.ts +3 -3
- package/src/theme/data-attribute/parse-data-attribute.ts +2 -2
- package/src/theme/data-attribute/read-data-attribute.ts +2 -2
- package/src/theme/data-attribute/stringify-data-attribute.ts +6 -6
- package/src/theme/data-attribute/subscribe-data-attribute.ts +3 -4
- package/src/theme/data-attribute/write-data-attribute.ts +5 -5
- package/src/theme/local-storage/write-local-storage.ts +2 -2
- package/src/theme/session-storage/write-session-storage.ts +2 -2
- package/src/theme/theme-entry.types.ts +5 -3
- package/src/theme/theme-store/async-theme-store.types.ts +1 -3
- package/src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts +2 -2
- package/src/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts +2 -2
- package/src/theme/theme-store/in-memory-theme-store/in-memory-theme-store.ts +1 -1
- package/src/theme/theme-store/theme-store.types.ts +1 -3
- package/src/theme/web-storage/write-web-storage.ts +5 -5
- package/src/utils/append-id.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe-data-attribute.cjs","names":["parseDataAttribute","SEPARATOR_SPACE","observeDataAttributes"],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":["import { observeDataAttributes } from '../../attributes/observe-data-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { parseDataAttribute } from './parse-data-attribute.ts'\n\n/**\n * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param handler - Callback invoked when the attribute changes\n * @param options.element - Element to observe (
|
|
1
|
+
{"version":3,"file":"subscribe-data-attribute.cjs","names":["parseDataAttribute","SEPARATOR_SPACE","observeDataAttributes"],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":["import { observeDataAttributes } from '../../attributes/observe-data-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { parseDataAttribute } from './parse-data-attribute.ts'\n\n/**\n * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param handler - Callback invoked when the attribute changes\n * @param options.element - Element to observe (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.parse - Custom parser (default: parseDataAttribute with space separator)\n * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).\n */\nexport function subscribeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\thandler: (entry: ThemeEntry<Themes> | undefined) => void,\n\toptions?:\n\t\t| { element?: Element | null | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): () => void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return () => {}\n\tconst parse =\n\t\toptions?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }))\n\treturn observeDataAttributes<string, `data-${string}`>(\n\t\t{\n\t\t\t[attributeName]: (value) => {\n\t\t\t\tconst entry = parse(themes, value ?? undefined)\n\t\t\t\thandler(entry)\n\t\t\t}\n\t\t},\n\t\telement\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,QACA,eACA,SACA,SAGa;CACb,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,cAAa;CAC3B,MAAM,QACL,SAAS,WAAW,GAAG,MAAMA,gDAAmB,GAAG,GAAG,EAAE,WAAWC,mCAAiB,CAAC;AACtF,QAAOC,qDACN,GACE,iBAAiB,UAAU;AAE3B,UADc,MAAM,QAAQ,SAAS,OAAU,CACjC;IAEf,EACD,QACA"}
|
|
@@ -9,12 +9,12 @@ import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
9
9
|
* @param themes - Record mapping theme keys to attribute values
|
|
10
10
|
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
11
|
* @param handler - Callback invoked when the attribute changes
|
|
12
|
-
* @param options.element - Element to observe (
|
|
12
|
+
* @param options.element - Element to observe (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
14
14
|
* @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
|
|
15
15
|
*/
|
|
16
16
|
declare function subscribeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, handler: (entry: ThemeEntry<Themes> | undefined) => void, options?: {
|
|
17
|
-
element?: Element | undefined;
|
|
17
|
+
element?: Element | null | undefined;
|
|
18
18
|
parse?: ParseStoredTheme<Themes> | undefined;
|
|
19
19
|
} | undefined): () => void;
|
|
20
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;
|
|
1
|
+
{"version":3,"file":"subscribe-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;AAKoE,iBALpD,sBAKoD,CAAA,eALd,QAKc,CAAA,CAAA,MAAA,EAJ3D,MAI2D,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,OAAA,EAAA,CAAA,KAAA,EAFlD,UAEkD,CAFvC,MAEuC,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,QAAA,EAAA;YAApD;UAAoC,iBAAiB"}
|
|
@@ -9,12 +9,12 @@ import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
9
9
|
* @param themes - Record mapping theme keys to attribute values
|
|
10
10
|
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
11
|
* @param handler - Callback invoked when the attribute changes
|
|
12
|
-
* @param options.element - Element to observe (
|
|
12
|
+
* @param options.element - Element to observe (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
14
14
|
* @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
|
|
15
15
|
*/
|
|
16
16
|
declare function subscribeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, handler: (entry: ThemeEntry<Themes> | undefined) => void, options?: {
|
|
17
|
-
element?: Element | undefined;
|
|
17
|
+
element?: Element | null | undefined;
|
|
18
18
|
parse?: ParseStoredTheme<Themes> | undefined;
|
|
19
19
|
} | undefined): () => void;
|
|
20
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;
|
|
1
|
+
{"version":3,"file":"subscribe-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;AAKoE,iBALpD,sBAKoD,CAAA,eALd,QAKc,CAAA,CAAA,MAAA,EAJ3D,MAI2D,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,OAAA,EAAA,CAAA,KAAA,EAFlD,UAEkD,CAFvC,MAEuC,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,QAAA,EAAA;YAApD;UAAoC,iBAAiB"}
|
|
@@ -9,7 +9,7 @@ import { parseDataAttribute } from "./parse-data-attribute.mjs";
|
|
|
9
9
|
* @param themes - Record mapping theme keys to attribute values
|
|
10
10
|
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
11
|
* @param handler - Callback invoked when the attribute changes
|
|
12
|
-
* @param options.element - Element to observe (
|
|
12
|
+
* @param options.element - Element to observe (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
14
14
|
* @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
|
|
15
15
|
*/
|
|
@@ -17,10 +17,9 @@ function subscribeDataAttribute(themes, attributeName, handler, options) {
|
|
|
17
17
|
const element = options?.element ?? document?.documentElement;
|
|
18
18
|
if (!element) return () => {};
|
|
19
19
|
const parse = options?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }));
|
|
20
|
-
|
|
20
|
+
return observeDataAttributes({ [attributeName]: (value) => {
|
|
21
21
|
handler(parse(themes, value ?? void 0));
|
|
22
22
|
} }, element);
|
|
23
|
-
return () => observer.disconnect();
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":["import { observeDataAttributes } from '../../attributes/observe-data-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { parseDataAttribute } from './parse-data-attribute.ts'\n\n/**\n * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param handler - Callback invoked when the attribute changes\n * @param options.element - Element to observe (
|
|
1
|
+
{"version":3,"file":"subscribe-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":["import { observeDataAttributes } from '../../attributes/observe-data-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { parseDataAttribute } from './parse-data-attribute.ts'\n\n/**\n * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param handler - Callback invoked when the attribute changes\n * @param options.element - Element to observe (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.parse - Custom parser (default: parseDataAttribute with space separator)\n * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).\n */\nexport function subscribeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\thandler: (entry: ThemeEntry<Themes> | undefined) => void,\n\toptions?:\n\t\t| { element?: Element | null | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): () => void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return () => {}\n\tconst parse =\n\t\toptions?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }))\n\treturn observeDataAttributes<string, `data-${string}`>(\n\t\t{\n\t\t\t[attributeName]: (value) => {\n\t\t\t\tconst entry = parse(themes, value ?? undefined)\n\t\t\t\thandler(entry)\n\t\t\t}\n\t\t},\n\t\telement\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,QACA,eACA,SACA,SAGa;CACb,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,cAAa;CAC3B,MAAM,QACL,SAAS,WAAW,GAAG,MAAM,mBAAmB,GAAG,GAAG,EAAE,WAAW,iBAAiB,CAAC;AACtF,QAAO,sBACN,GACE,iBAAiB,UAAU;AAE3B,UADc,MAAM,QAAQ,SAAS,OAAU,CACjC;IAEf,EACD,QACA"}
|
|
@@ -8,15 +8,15 @@ const require_stringify_data_attribute = require('./stringify-data-attribute.cjs
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to attribute values
|
|
10
10
|
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
12
|
-
* @param options.element - Element to write to (
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove the theme
|
|
12
|
+
* @param options.element - Element to write to (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
|
|
14
14
|
*/
|
|
15
15
|
function writeDataAttribute(themes, attributeName, entry, options) {
|
|
16
16
|
const element = options?.element ?? document?.documentElement;
|
|
17
17
|
if (!element) return;
|
|
18
18
|
const stringify = options?.stringify ?? ((t, x, e) => require_stringify_data_attribute.stringifyDataAttribute(t, x, e, { separator: require__constant.SEPARATOR_SPACE }));
|
|
19
|
-
if (entry
|
|
19
|
+
if (entry == null) {
|
|
20
20
|
element.removeAttribute(attributeName);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-data-attribute.cjs","names":["stringifyDataAttribute","SEPARATOR_SPACE","getDataAttribute"],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { stringifyDataAttribute } from './stringify-data-attribute.ts'\n\n/**\n * Writes a theme entry to a data attribute on an element.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param entry - Theme entry to write, or undefined to remove the theme\n * @param options.element - Element to write to (
|
|
1
|
+
{"version":3,"file":"write-data-attribute.cjs","names":["stringifyDataAttribute","SEPARATOR_SPACE","getDataAttribute"],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { stringifyDataAttribute } from './stringify-data-attribute.ts'\n\n/**\n * Writes a theme entry to a data attribute on an element.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param entry - Theme entry to write, or null/undefined to remove the theme\n * @param options.element - Element to write to (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)\n */\nexport function writeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?:\n\t\t| { element?: Element | null | undefined; stringify?: StringifyStoredTheme<Themes> | undefined }\n\t\t| undefined\n): void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return\n\tconst stringify =\n\t\toptions?.stringify ??\n\t\t((t, x, e) => stringifyDataAttribute(t, x, e, { separator: SEPARATOR_SPACE }))\n\tif (entry == null) {\n\t\telement.removeAttribute(attributeName)\n\t\treturn\n\t}\n\tconst existing = getDataAttribute(attributeName, element) ?? undefined\n\tconst result = stringify(themes, existing, entry)\n\tif (result === '') {\n\t\telement.removeAttribute(attributeName)\n\t} else {\n\t\telement.setAttribute(attributeName, result)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,mBACf,QACA,eACA,OACA,SAGO;CACP,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS;CACd,MAAM,YACL,SAAS,eACP,GAAG,GAAG,MAAMA,wDAAuB,GAAG,GAAG,GAAG,EAAE,WAAWC,mCAAiB,CAAC;AAC9E,KAAI,SAAS,MAAM;AAClB,UAAQ,gBAAgB,cAAc;AACtC;;CAGD,MAAM,SAAS,UAAU,QADRC,4CAAiB,eAAe,QAAQ,IAAI,QAClB,MAAM;AACjD,KAAI,WAAW,GACd,SAAQ,gBAAgB,cAAc;KAEtC,SAAQ,aAAa,eAAe,OAAO"}
|
|
@@ -8,12 +8,12 @@ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to attribute values
|
|
10
10
|
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
12
|
-
* @param options.element - Element to write to (
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove the theme
|
|
12
|
+
* @param options.element - Element to write to (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
|
|
14
14
|
*/
|
|
15
|
-
declare function writeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
16
|
-
element?: Element | undefined;
|
|
15
|
+
declare function writeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
16
|
+
element?: Element | null | undefined;
|
|
17
17
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
18
18
|
} | undefined): void;
|
|
19
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;
|
|
1
|
+
{"version":3,"file":"write-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAKwD,iBALxC,kBAKwC,CAAA,eALN,QAKM,CAAA,CAAA,MAAA,EAJ/C,MAI+C,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,KAAA,EAFhD,UAEgD,CAFrC,MAEqC,CAAA,GAAA,IAAA,GAAA,SAAA,EAAA,QAAA,EAAA;EAAoB,OAAA,CAAA,EAA5D,OAA4D,GAAA,IAAA,GAAA,SAAA;cAApB,qBAAqB"}
|
|
@@ -8,12 +8,12 @@ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to attribute values
|
|
10
10
|
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
12
|
-
* @param options.element - Element to write to (
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove the theme
|
|
12
|
+
* @param options.element - Element to write to (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
|
|
14
14
|
*/
|
|
15
|
-
declare function writeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
16
|
-
element?: Element | undefined;
|
|
15
|
+
declare function writeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
16
|
+
element?: Element | null | undefined;
|
|
17
17
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
18
18
|
} | undefined): void;
|
|
19
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;
|
|
1
|
+
{"version":3,"file":"write-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAKwD,iBALxC,kBAKwC,CAAA,eALN,QAKM,CAAA,CAAA,MAAA,EAJ/C,MAI+C,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,KAAA,EAFhD,UAEgD,CAFrC,MAEqC,CAAA,GAAA,IAAA,GAAA,SAAA,EAAA,QAAA,EAAA;EAAoB,OAAA,CAAA,EAA5D,OAA4D,GAAA,IAAA,GAAA,SAAA;cAApB,qBAAqB"}
|
|
@@ -8,15 +8,15 @@ import { stringifyDataAttribute } from "./stringify-data-attribute.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to attribute values
|
|
10
10
|
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
12
|
-
* @param options.element - Element to write to (
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove the theme
|
|
12
|
+
* @param options.element - Element to write to (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
|
|
14
14
|
*/
|
|
15
15
|
function writeDataAttribute(themes, attributeName, entry, options) {
|
|
16
16
|
const element = options?.element ?? document?.documentElement;
|
|
17
17
|
if (!element) return;
|
|
18
18
|
const stringify = options?.stringify ?? ((t, x, e) => stringifyDataAttribute(t, x, e, { separator: SEPARATOR_SPACE }));
|
|
19
|
-
if (entry
|
|
19
|
+
if (entry == null) {
|
|
20
20
|
element.removeAttribute(attributeName);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { stringifyDataAttribute } from './stringify-data-attribute.ts'\n\n/**\n * Writes a theme entry to a data attribute on an element.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param entry - Theme entry to write, or undefined to remove the theme\n * @param options.element - Element to write to (
|
|
1
|
+
{"version":3,"file":"write-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { stringifyDataAttribute } from './stringify-data-attribute.ts'\n\n/**\n * Writes a theme entry to a data attribute on an element.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param entry - Theme entry to write, or null/undefined to remove the theme\n * @param options.element - Element to write to (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)\n */\nexport function writeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?:\n\t\t| { element?: Element | null | undefined; stringify?: StringifyStoredTheme<Themes> | undefined }\n\t\t| undefined\n): void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return\n\tconst stringify =\n\t\toptions?.stringify ??\n\t\t((t, x, e) => stringifyDataAttribute(t, x, e, { separator: SEPARATOR_SPACE }))\n\tif (entry == null) {\n\t\telement.removeAttribute(attributeName)\n\t\treturn\n\t}\n\tconst existing = getDataAttribute(attributeName, element) ?? undefined\n\tconst result = stringify(themes, existing, entry)\n\tif (result === '') {\n\t\telement.removeAttribute(attributeName)\n\t} else {\n\t\telement.setAttribute(attributeName, result)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,mBACf,QACA,eACA,OACA,SAGO;CACP,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS;CACd,MAAM,YACL,SAAS,eACP,GAAG,GAAG,MAAM,uBAAuB,GAAG,GAAG,GAAG,EAAE,WAAW,iBAAiB,CAAC;AAC9E,KAAI,SAAS,MAAM;AAClB,UAAQ,gBAAgB,cAAc;AACtC;;CAGD,MAAM,SAAS,UAAU,QADR,iBAAiB,eAAe,QAAQ,IAAI,QAClB,MAAM;AACjD,KAAI,WAAW,GACd,SAAQ,gBAAgB,cAAc;KAEtC,SAAQ,aAAa,eAAe,OAAO"}
|
|
@@ -8,7 +8,7 @@ const require_write_web_storage = require('../web-storage/write-web-storage.cjs'
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
10
10
|
* @param storageKey - localStorage key to write to
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
12
12
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
13
13
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-local-storage.cjs","names":[],"sources":["../../../src/theme/local-storage/write-local-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to localStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - localStorage key to write to\n * @param entry - Theme entry to write, or undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.localStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.localStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,kBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,aAAc;AAC3B,2CAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"write-local-storage.cjs","names":[],"sources":["../../../src/theme/local-storage/write-local-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to localStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - localStorage key to write to\n * @param entry - Theme entry to write, or null/undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.localStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.localStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,kBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,aAAc;AAC3B,2CAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
@@ -10,11 +10,11 @@ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
12
12
|
* @param storageKey - localStorage key to write to
|
|
13
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
13
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
14
14
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
15
15
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
16
16
|
*/
|
|
17
|
-
declare function writeLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
17
|
+
declare function writeLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
18
18
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
19
19
|
onError?: ((error: unknown) => void) | undefined;
|
|
20
20
|
}): void;
|
|
@@ -10,11 +10,11 @@ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
12
12
|
* @param storageKey - localStorage key to write to
|
|
13
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
13
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
14
14
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
15
15
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
16
16
|
*/
|
|
17
|
-
declare function writeLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
17
|
+
declare function writeLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
18
18
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
19
19
|
onError?: ((error: unknown) => void) | undefined;
|
|
20
20
|
}): void;
|
|
@@ -8,7 +8,7 @@ import { writeWebStorage } from "../web-storage/write-web-storage.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
10
10
|
* @param storageKey - localStorage key to write to
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
12
12
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
13
13
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-local-storage.mjs","names":[],"sources":["../../../src/theme/local-storage/write-local-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to localStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - localStorage key to write to\n * @param entry - Theme entry to write, or undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.localStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.localStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,kBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,aAAc;AAC3B,iBAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"write-local-storage.mjs","names":[],"sources":["../../../src/theme/local-storage/write-local-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to localStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - localStorage key to write to\n * @param entry - Theme entry to write, or null/undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.localStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.localStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,kBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,aAAc;AAC3B,iBAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
@@ -8,7 +8,7 @@ const require_write_web_storage = require('../web-storage/write-web-storage.cjs'
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
10
10
|
* @param storageKey - sessionStorage key to write to
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
12
12
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
13
13
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-session-storage.cjs","names":[],"sources":["../../../src/theme/session-storage/write-session-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to sessionStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - sessionStorage key to write to\n * @param entry - Theme entry to write, or undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeSessionStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.sessionStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.sessionStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,oBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,eAAgB;AAC7B,2CAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"write-session-storage.cjs","names":[],"sources":["../../../src/theme/session-storage/write-session-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to sessionStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - sessionStorage key to write to\n * @param entry - Theme entry to write, or null/undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeSessionStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.sessionStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.sessionStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,oBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,eAAgB;AAC7B,2CAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
@@ -10,11 +10,11 @@ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
12
12
|
* @param storageKey - sessionStorage key to write to
|
|
13
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
13
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
14
14
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
15
15
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
16
16
|
*/
|
|
17
|
-
declare function writeSessionStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
17
|
+
declare function writeSessionStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
18
18
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
19
19
|
onError?: ((error: unknown) => void) | undefined;
|
|
20
20
|
}): void;
|
|
@@ -10,11 +10,11 @@ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
12
12
|
* @param storageKey - sessionStorage key to write to
|
|
13
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
13
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
14
14
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
15
15
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
16
16
|
*/
|
|
17
|
-
declare function writeSessionStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
17
|
+
declare function writeSessionStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
18
18
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
19
19
|
onError?: ((error: unknown) => void) | undefined;
|
|
20
20
|
}): void;
|
|
@@ -8,7 +8,7 @@ import { writeWebStorage } from "../web-storage/write-web-storage.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
10
10
|
* @param storageKey - sessionStorage key to write to
|
|
11
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
11
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
12
12
|
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
13
13
|
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-session-storage.mjs","names":[],"sources":["../../../src/theme/session-storage/write-session-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to sessionStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - sessionStorage key to write to\n * @param entry - Theme entry to write, or undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeSessionStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.sessionStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.sessionStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,oBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,eAAgB;AAC7B,iBAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"write-session-storage.mjs","names":[],"sources":["../../../src/theme/session-storage/write-session-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to sessionStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - sessionStorage key to write to\n * @param entry - Theme entry to write, or null/undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeSessionStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.sessionStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.sessionStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,oBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,eAAgB;AAC7B,iBAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
|
|
@@ -14,13 +14,15 @@ interface ThemeEntry<Themes extends ThemeMap = ThemeMap> {
|
|
|
14
14
|
/**
|
|
15
15
|
* Function type for parsing stored string into ThemeEntry.
|
|
16
16
|
* Used as options.parse in persisting theme stores.
|
|
17
|
+
* Value accepts null (e.g. from getItem, getAttribute, cookie parsing).
|
|
17
18
|
*/
|
|
18
|
-
type ParseStoredTheme<Themes extends ThemeMap> = (themes: Themes, value: string | undefined) => ThemeEntry<Themes> | undefined;
|
|
19
|
+
type ParseStoredTheme<Themes extends ThemeMap> = (themes: Themes, value: string | null | undefined) => ThemeEntry<Themes> | undefined;
|
|
19
20
|
/**
|
|
20
21
|
* Function type for stringify ThemeEntry to a stored string.
|
|
21
22
|
* Used as options.stringify in persisting theme stores.
|
|
23
|
+
* Existing accepts null (e.g. from getAttribute, getItem); entry accepts null for remove/clear.
|
|
22
24
|
*/
|
|
23
|
-
type StringifyStoredTheme<Themes extends ThemeMap> = (themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined) => string;
|
|
25
|
+
type StringifyStoredTheme<Themes extends ThemeMap> = (themes: Themes, existing: string | null | undefined, entry: ThemeEntry<Themes> | null | undefined) => string;
|
|
24
26
|
//#endregion
|
|
25
27
|
export { ParseStoredTheme, StringifyStoredTheme, ThemeEntry };
|
|
26
28
|
//# sourceMappingURL=theme-entry.types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-entry.types.d.cts","names":[],"sources":["../../src/theme/theme-entry.types.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;AACc,UADG,UACH,CAAA,eAD6B,QAC7B,GADwC,QACxC,CAAA,CAAA;EACN,KAAA,EAAA,MADM,MACN;EAAa,KAAA,EAAb,MAAa,CAAA,MAAA,MAAA,CAAA;;
|
|
1
|
+
{"version":3,"file":"theme-entry.types.d.cts","names":[],"sources":["../../src/theme/theme-entry.types.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;AACc,UADG,UACH,CAAA,eAD6B,QAC7B,GADwC,QACxC,CAAA,CAAA;EACN,KAAA,EAAA,MADM,MACN;EAAa,KAAA,EAAb,MAAa,CAAA,MAAA,MAAA,CAAA;;AAQrB;;;;;AAGe,KAHH,gBAGG,CAAA,eAH6B,QAG7B,CAAA,GAAA,CAAA,MAAA,EAFN,MAEM,EAAA,KAAA,EAAA,MAAA,GAAA,IAAA,GAAA,SAAA,EAAA,GAAV,UAAU,CAAC,MAAD,CAAA,GAAA,SAAA;AAOf;;;;;AAGkB,KAHN,oBAGM,CAAA,eAH8B,QAG9B,CAAA,GAAA,CAAA,MAAA,EAFT,MAES,EAAA,QAAA,EAAA,MAAA,GAAA,IAAA,GAAA,SAAA,EAAA,KAAA,EAAV,UAAU,CAAC,MAAD,CAAA,GAAA,IAAA,GAAA,SAAA,EAAA,GAAA,MAAA"}
|
|
@@ -14,13 +14,15 @@ interface ThemeEntry<Themes extends ThemeMap = ThemeMap> {
|
|
|
14
14
|
/**
|
|
15
15
|
* Function type for parsing stored string into ThemeEntry.
|
|
16
16
|
* Used as options.parse in persisting theme stores.
|
|
17
|
+
* Value accepts null (e.g. from getItem, getAttribute, cookie parsing).
|
|
17
18
|
*/
|
|
18
|
-
type ParseStoredTheme<Themes extends ThemeMap> = (themes: Themes, value: string | undefined) => ThemeEntry<Themes> | undefined;
|
|
19
|
+
type ParseStoredTheme<Themes extends ThemeMap> = (themes: Themes, value: string | null | undefined) => ThemeEntry<Themes> | undefined;
|
|
19
20
|
/**
|
|
20
21
|
* Function type for stringify ThemeEntry to a stored string.
|
|
21
22
|
* Used as options.stringify in persisting theme stores.
|
|
23
|
+
* Existing accepts null (e.g. from getAttribute, getItem); entry accepts null for remove/clear.
|
|
22
24
|
*/
|
|
23
|
-
type StringifyStoredTheme<Themes extends ThemeMap> = (themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined) => string;
|
|
25
|
+
type StringifyStoredTheme<Themes extends ThemeMap> = (themes: Themes, existing: string | null | undefined, entry: ThemeEntry<Themes> | null | undefined) => string;
|
|
24
26
|
//#endregion
|
|
25
27
|
export { ParseStoredTheme, StringifyStoredTheme, ThemeEntry };
|
|
26
28
|
//# sourceMappingURL=theme-entry.types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-entry.types.d.mts","names":[],"sources":["../../src/theme/theme-entry.types.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;AACc,UADG,UACH,CAAA,eAD6B,QAC7B,GADwC,QACxC,CAAA,CAAA;EACN,KAAA,EAAA,MADM,MACN;EAAa,KAAA,EAAb,MAAa,CAAA,MAAA,MAAA,CAAA;;
|
|
1
|
+
{"version":3,"file":"theme-entry.types.d.mts","names":[],"sources":["../../src/theme/theme-entry.types.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;AACc,UADG,UACH,CAAA,eAD6B,QAC7B,GADwC,QACxC,CAAA,CAAA;EACN,KAAA,EAAA,MADM,MACN;EAAa,KAAA,EAAb,MAAa,CAAA,MAAA,MAAA,CAAA;;AAQrB;;;;;AAGe,KAHH,gBAGG,CAAA,eAH6B,QAG7B,CAAA,GAAA,CAAA,MAAA,EAFN,MAEM,EAAA,KAAA,EAAA,MAAA,GAAA,IAAA,GAAA,SAAA,EAAA,GAAV,UAAU,CAAC,MAAD,CAAA,GAAA,SAAA;AAOf;;;;;AAGkB,KAHN,oBAGM,CAAA,eAH8B,QAG9B,CAAA,GAAA,CAAA,MAAA,EAFT,MAES,EAAA,QAAA,EAAA,MAAA,GAAA,IAAA,GAAA,SAAA,EAAA,KAAA,EAAV,UAAU,CAAC,MAAD,CAAA,GAAA,IAAA,GAAA,SAAA,EAAA,GAAA,MAAA"}
|
|
@@ -18,7 +18,7 @@ import { ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
18
18
|
interface AsyncThemeStore<Themes extends ThemeMap = ThemeMap> {
|
|
19
19
|
read?: (() => ThemeEntry<Themes> | undefined | Promise<ThemeEntry<Themes> | undefined>) | undefined;
|
|
20
20
|
write?: ((entry: ThemeEntry<Themes> | undefined) => void | Promise<void>) | undefined;
|
|
21
|
-
subscribe?: ((handler: (entry: ThemeEntry<Themes> | undefined
|
|
21
|
+
subscribe?: ((handler: (entry: ThemeEntry<Themes> | undefined) => void) => () => void) | undefined;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
24
|
export { AsyncThemeStore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-theme-store.types.d.cts","names":[],"sources":["../../../src/theme/theme-store/async-theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;;;;AAI4D,UAJ3C,eAI2C,CAAA,eAJZ,QAIY,GAJD,QAIC,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"async-theme-store.types.d.cts","names":[],"sources":["../../../src/theme/theme-store/async-theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;;;;AAI4D,UAJ3C,eAI2C,CAAA,eAJZ,QAIY,GAJD,QAIC,CAAA,CAAA;EACjB,IAAA,CAAA,EAAA,CAAA,GAAA,GAHhC,UAGgC,CAHrB,MAGqB,CAAA,GAAA,SAAA,GAHC,OAGD,CAHS,UAGT,CAHoB,MAGpB,CAAA,GAAA,SAAA,CAAA,CAAA,GAAA,SAAA;EAAX,KAAA,CAAA,EAAA,CAAA,CAAA,KAAA,EADd,UACc,CADH,MACG,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,GAD4B,OAC5B,CAAA,IAAA,CAAA,CAAA,GAAA,SAAA;EAAU,SAAA,CAAA,EAAA,CAAA,CAAA,OAAA,EAAA,CAAA,KAAA,EAAV,UAAU,CAAC,MAAD,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,GAAA,GAAA,GAAA,IAAA,CAAA,GAAA,SAAA"}
|
|
@@ -18,7 +18,7 @@ import { ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
18
18
|
interface AsyncThemeStore<Themes extends ThemeMap = ThemeMap> {
|
|
19
19
|
read?: (() => ThemeEntry<Themes> | undefined | Promise<ThemeEntry<Themes> | undefined>) | undefined;
|
|
20
20
|
write?: ((entry: ThemeEntry<Themes> | undefined) => void | Promise<void>) | undefined;
|
|
21
|
-
subscribe?: ((handler: (entry: ThemeEntry<Themes> | undefined
|
|
21
|
+
subscribe?: ((handler: (entry: ThemeEntry<Themes> | undefined) => void) => () => void) | undefined;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
24
|
export { AsyncThemeStore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-theme-store.types.d.mts","names":[],"sources":["../../../src/theme/theme-store/async-theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;;;;AAI4D,UAJ3C,eAI2C,CAAA,eAJZ,QAIY,GAJD,QAIC,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"async-theme-store.types.d.mts","names":[],"sources":["../../../src/theme/theme-store/async-theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;;;;AAI4D,UAJ3C,eAI2C,CAAA,eAJZ,QAIY,GAJD,QAIC,CAAA,CAAA;EACjB,IAAA,CAAA,EAAA,CAAA,GAAA,GAHhC,UAGgC,CAHrB,MAGqB,CAAA,GAAA,SAAA,GAHC,OAGD,CAHS,UAGT,CAHoB,MAGpB,CAAA,GAAA,SAAA,CAAA,CAAA,GAAA,SAAA;EAAX,KAAA,CAAA,EAAA,CAAA,CAAA,KAAA,EADd,UACc,CADH,MACG,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,GAD4B,OAC5B,CAAA,IAAA,CAAA,CAAA,GAAA,SAAA;EAAU,SAAA,CAAA,EAAA,CAAA,CAAA,OAAA,EAAA,CAAA,KAAA,EAAV,UAAU,CAAC,MAAD,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,GAAA,GAAA,GAAA,IAAA,CAAA,GAAA,SAAA"}
|
|
@@ -10,7 +10,7 @@ const require_write_class_name = require('../../class-name/write-class-name.cjs'
|
|
|
10
10
|
* Creates a theme store that reads and writes via element class names.
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to class name(s)
|
|
13
|
-
* @param options.element - Element to operate on (
|
|
13
|
+
* @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
14
14
|
* @param options.parse - Custom parser (default: parseClassName)
|
|
15
15
|
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
16
16
|
* @returns ThemeStore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-name-theme-store.cjs","names":["dummyThemeStore","parseClassName","stringifyClassName","readClassName","subscribeClassName"],"sources":["../../../../src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts"],"sourcesContent":["import type { Required } from 'type-plus'\nimport { dummyThemeStore } from '../../../testing/theme/dummy-theme-store.ts'\nimport { parseClassName } from '../../class-name/parse-class-name.ts'\nimport { readClassName } from '../../class-name/read-class-name.ts'\nimport { stringifyClassName } from '../../class-name/stringify-class-name.ts'\nimport { subscribeClassName } from '../../class-name/subscribe-class-name.ts'\nimport { writeClassName } from '../../class-name/write-class-name.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store that reads and writes via element class names.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param options.element - Element to operate on (
|
|
1
|
+
{"version":3,"file":"class-name-theme-store.cjs","names":["dummyThemeStore","parseClassName","stringifyClassName","readClassName","subscribeClassName"],"sources":["../../../../src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts"],"sourcesContent":["import type { Required } from 'type-plus'\nimport { dummyThemeStore } from '../../../testing/theme/dummy-theme-store.ts'\nimport { parseClassName } from '../../class-name/parse-class-name.ts'\nimport { readClassName } from '../../class-name/read-class-name.ts'\nimport { stringifyClassName } from '../../class-name/stringify-class-name.ts'\nimport { subscribeClassName } from '../../class-name/subscribe-class-name.ts'\nimport { writeClassName } from '../../class-name/write-class-name.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store that reads and writes via element class names.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.parse - Custom parser (default: parseClassName)\n * @param options.stringify - Custom serializer (default: stringifyClassName)\n * @returns ThemeStore\n *\n * @example\n * ```ts\n * const themes = { current: 'theme-current', grayscale: 'theme-grayscale' }\n * const store = classNameThemeStore(themes)\n * store.read() // returns themeResult from element.className\n * store.write(themeEntry(themes, 'grayscale'))\n * store.subscribe((themeResult) => {})\n * ```\n */\nexport function classNameThemeStore<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions?: {\n\t\telement?: Element | null | undefined\n\t\tparse?: ParseStoredTheme<Themes> | undefined\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t}\n): Required<ThemeStore<Themes>> {\n\tconst element = options?.element ?? document?.documentElement\n\n\tif (!element) return dummyThemeStore\n\n\tconst parse = options?.parse ?? parseClassName\n\tconst stringify = options?.stringify ?? stringifyClassName\n\n\treturn {\n\t\tread() {\n\t\t\treturn readClassName(themes, { element, parse })\n\t\t},\n\t\twrite(entry) {\n\t\t\twriteClassName(themes, entry, { element, stringify })\n\t\t},\n\t\tsubscribe(handler) {\n\t\t\treturn subscribeClassName(themes, handler, { element, parse })\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,oBACf,QACA,SAK+B;CAC/B,MAAM,UAAU,SAAS,WAAW,UAAU;AAE9C,KAAI,CAAC,QAAS,QAAOA;CAErB,MAAM,QAAQ,SAAS,SAASC;CAChC,MAAM,YAAY,SAAS,aAAaC;AAExC,QAAO;EACN,OAAO;AACN,UAAOC,sCAAc,QAAQ;IAAE;IAAS;IAAO,CAAC;;EAEjD,MAAM,OAAO;AACZ,2CAAe,QAAQ,OAAO;IAAE;IAAS;IAAW,CAAC;;EAEtD,UAAU,SAAS;AAClB,UAAOC,gDAAmB,QAAQ,SAAS;IAAE;IAAS;IAAO,CAAC;;EAE/D"}
|
|
@@ -9,7 +9,7 @@ import { Required } from "type-plus";
|
|
|
9
9
|
* Creates a theme store that reads and writes via element class names.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to class name(s)
|
|
12
|
-
* @param options.element - Element to operate on (
|
|
12
|
+
* @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.parse - Custom parser (default: parseClassName)
|
|
14
14
|
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
15
15
|
* @returns ThemeStore
|
|
@@ -24,7 +24,7 @@ import { Required } from "type-plus";
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
declare function classNameThemeStore<Themes extends ThemeMap>(themes: Themes, options?: {
|
|
27
|
-
element?: Element | undefined;
|
|
27
|
+
element?: Element | null | undefined;
|
|
28
28
|
parse?: ParseStoredTheme<Themes> | undefined;
|
|
29
29
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
30
30
|
}): Required<ThemeStore<Themes>>;
|
|
@@ -9,7 +9,7 @@ import { Required } from "type-plus";
|
|
|
9
9
|
* Creates a theme store that reads and writes via element class names.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to class name(s)
|
|
12
|
-
* @param options.element - Element to operate on (
|
|
12
|
+
* @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
13
13
|
* @param options.parse - Custom parser (default: parseClassName)
|
|
14
14
|
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
15
15
|
* @returns ThemeStore
|
|
@@ -24,7 +24,7 @@ import { Required } from "type-plus";
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
declare function classNameThemeStore<Themes extends ThemeMap>(themes: Themes, options?: {
|
|
27
|
-
element?: Element | undefined;
|
|
27
|
+
element?: Element | null | undefined;
|
|
28
28
|
parse?: ParseStoredTheme<Themes> | undefined;
|
|
29
29
|
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
30
30
|
}): Required<ThemeStore<Themes>>;
|
|
@@ -10,7 +10,7 @@ import { writeClassName } from "../../class-name/write-class-name.mjs";
|
|
|
10
10
|
* Creates a theme store that reads and writes via element class names.
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to class name(s)
|
|
13
|
-
* @param options.element - Element to operate on (
|
|
13
|
+
* @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
14
14
|
* @param options.parse - Custom parser (default: parseClassName)
|
|
15
15
|
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
16
16
|
* @returns ThemeStore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-name-theme-store.mjs","names":[],"sources":["../../../../src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts"],"sourcesContent":["import type { Required } from 'type-plus'\nimport { dummyThemeStore } from '../../../testing/theme/dummy-theme-store.ts'\nimport { parseClassName } from '../../class-name/parse-class-name.ts'\nimport { readClassName } from '../../class-name/read-class-name.ts'\nimport { stringifyClassName } from '../../class-name/stringify-class-name.ts'\nimport { subscribeClassName } from '../../class-name/subscribe-class-name.ts'\nimport { writeClassName } from '../../class-name/write-class-name.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store that reads and writes via element class names.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param options.element - Element to operate on (
|
|
1
|
+
{"version":3,"file":"class-name-theme-store.mjs","names":[],"sources":["../../../../src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts"],"sourcesContent":["import type { Required } from 'type-plus'\nimport { dummyThemeStore } from '../../../testing/theme/dummy-theme-store.ts'\nimport { parseClassName } from '../../class-name/parse-class-name.ts'\nimport { readClassName } from '../../class-name/read-class-name.ts'\nimport { stringifyClassName } from '../../class-name/stringify-class-name.ts'\nimport { subscribeClassName } from '../../class-name/subscribe-class-name.ts'\nimport { writeClassName } from '../../class-name/write-class-name.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store that reads and writes via element class names.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.parse - Custom parser (default: parseClassName)\n * @param options.stringify - Custom serializer (default: stringifyClassName)\n * @returns ThemeStore\n *\n * @example\n * ```ts\n * const themes = { current: 'theme-current', grayscale: 'theme-grayscale' }\n * const store = classNameThemeStore(themes)\n * store.read() // returns themeResult from element.className\n * store.write(themeEntry(themes, 'grayscale'))\n * store.subscribe((themeResult) => {})\n * ```\n */\nexport function classNameThemeStore<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions?: {\n\t\telement?: Element | null | undefined\n\t\tparse?: ParseStoredTheme<Themes> | undefined\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t}\n): Required<ThemeStore<Themes>> {\n\tconst element = options?.element ?? document?.documentElement\n\n\tif (!element) return dummyThemeStore\n\n\tconst parse = options?.parse ?? parseClassName\n\tconst stringify = options?.stringify ?? stringifyClassName\n\n\treturn {\n\t\tread() {\n\t\t\treturn readClassName(themes, { element, parse })\n\t\t},\n\t\twrite(entry) {\n\t\t\twriteClassName(themes, entry, { element, stringify })\n\t\t},\n\t\tsubscribe(handler) {\n\t\t\treturn subscribeClassName(themes, handler, { element, parse })\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,oBACf,QACA,SAK+B;CAC/B,MAAM,UAAU,SAAS,WAAW,UAAU;AAE9C,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,YAAY,SAAS,aAAa;AAExC,QAAO;EACN,OAAO;AACN,UAAO,cAAc,QAAQ;IAAE;IAAS;IAAO,CAAC;;EAEjD,MAAM,OAAO;AACZ,kBAAe,QAAQ,OAAO;IAAE;IAAS;IAAW,CAAC;;EAEtD,UAAU,SAAS;AAClB,UAAO,mBAAmB,QAAQ,SAAS;IAAE;IAAS;IAAO,CAAC;;EAE/D"}
|
|
@@ -17,7 +17,7 @@ const require_write_data_attribute = require('../../data-attribute/write-data-at
|
|
|
17
17
|
*
|
|
18
18
|
* @param themes - Record mapping theme keys to attribute values
|
|
19
19
|
* @param options.attributeName - Data attribute name (e.g. `data-theme`)
|
|
20
|
-
* @param options.element - Element to operate on (
|
|
20
|
+
* @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
21
21
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
22
22
|
* @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
|
|
23
23
|
* @returns ThemeStore
|
package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-attribute-theme-store.cjs","names":["parseDataAttribute","SEPARATOR_SPACE","stringifyDataAttribute","readDataAttribute","subscribeDataAttribute"],"sources":["../../../../src/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts"],"sourcesContent":["import { SEPARATOR_SPACE } from '../../data-attribute/_constant.ts'\nimport { parseDataAttribute } from '../../data-attribute/parse-data-attribute.ts'\nimport { readDataAttribute } from '../../data-attribute/read-data-attribute.ts'\nimport { stringifyDataAttribute } from '../../data-attribute/stringify-data-attribute.ts'\nimport { subscribeDataAttribute } from '../../data-attribute/subscribe-data-attribute.ts'\nimport { writeDataAttribute } from '../../data-attribute/write-data-attribute.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store that reads and writes via a data attribute.\n *\n * read: parse(themes, getDataAttribute(element, attribute)) → ThemeEntry\n * write: setAttribute(attribute, stringify(themes, getDataAttribute(element, attribute), entry))\n *\n * Supports space-separated attribute values by default. Use `parse` and `stringify` to customize\n * (e.g. comma-separated via curried parseDataAttribute/stringifyDataAttribute).\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param options.attributeName - Data attribute name (e.g. `data-theme`)\n * @param options.element - Element to operate on (
|
|
1
|
+
{"version":3,"file":"data-attribute-theme-store.cjs","names":["parseDataAttribute","SEPARATOR_SPACE","stringifyDataAttribute","readDataAttribute","subscribeDataAttribute"],"sources":["../../../../src/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts"],"sourcesContent":["import { SEPARATOR_SPACE } from '../../data-attribute/_constant.ts'\nimport { parseDataAttribute } from '../../data-attribute/parse-data-attribute.ts'\nimport { readDataAttribute } from '../../data-attribute/read-data-attribute.ts'\nimport { stringifyDataAttribute } from '../../data-attribute/stringify-data-attribute.ts'\nimport { subscribeDataAttribute } from '../../data-attribute/subscribe-data-attribute.ts'\nimport { writeDataAttribute } from '../../data-attribute/write-data-attribute.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store that reads and writes via a data attribute.\n *\n * read: parse(themes, getDataAttribute(element, attribute)) → ThemeEntry\n * write: setAttribute(attribute, stringify(themes, getDataAttribute(element, attribute), entry))\n *\n * Supports space-separated attribute values by default. Use `parse` and `stringify` to customize\n * (e.g. comma-separated via curried parseDataAttribute/stringifyDataAttribute).\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param options.attributeName - Data attribute name (e.g. `data-theme`)\n * @param options.element - Element to operate on (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.parse - Custom parser (default: parseDataAttribute with space separator)\n * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)\n * @returns ThemeStore\n *\n * @example\n * ```ts\n * const themes = { current: 'current', grayscale: 'grayscale' }\n * const store = dataAttributeThemeStore(themes, { attributeName: 'data-theme' })\n * store.read() // returns ThemeEntry from data attribute\n * store.write(themeEntry(themes, 'grayscale'))\n * store.subscribe((entry) => {})\n * ```\n *\n * @example\n * ```ts\n * // Comma-separated\n * const store = dataAttributeThemeStore(themes, {\n * attributeName: 'data-theme',\n * parse: (t, v) => parseDataAttribute(t, v, { separator: ',' }),\n * stringify: (t, x, e) => stringifyDataAttribute(t, x, e, { separator: ',' })\n * })\n * ```\n */\nexport function dataAttributeThemeStore<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: {\n\t\tattributeName: `data-${string}`\n\t\telement?: Element | null | undefined\n\t\tparse?: ParseStoredTheme<Themes> | undefined\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t}\n) {\n\tconst element = options.element ?? document?.documentElement\n\tconst {\n\t\tattributeName,\n\t\tparse = (t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }),\n\t\tstringify = (t, x, e) => stringifyDataAttribute(t, x, e, { separator: SEPARATOR_SPACE })\n\t} = options\n\n\treturn {\n\t\tread() {\n\t\t\treturn readDataAttribute(themes, attributeName, { element, parse })\n\t\t},\n\t\twrite(entry) {\n\t\t\twriteDataAttribute(themes, attributeName, entry, { element, stringify })\n\t\t},\n\t\tsubscribe(handler) {\n\t\t\treturn subscribeDataAttribute(themes, attributeName, handler, { element, parse })\n\t\t}\n\t} satisfies ThemeStore<Themes>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,wBACf,QACA,SAMC;CACD,MAAM,UAAU,QAAQ,WAAW,UAAU;CAC7C,MAAM,EACL,eACA,SAAS,GAAG,MAAMA,gDAAmB,GAAG,GAAG,EAAE,WAAWC,mCAAiB,CAAC,EAC1E,aAAa,GAAG,GAAG,MAAMC,wDAAuB,GAAG,GAAG,GAAG,EAAE,WAAWD,mCAAiB,CAAC,KACrF;AAEJ,QAAO;EACN,OAAO;AACN,UAAOE,8CAAkB,QAAQ,eAAe;IAAE;IAAS;IAAO,CAAC;;EAEpE,MAAM,OAAO;AACZ,mDAAmB,QAAQ,eAAe,OAAO;IAAE;IAAS;IAAW,CAAC;;EAEzE,UAAU,SAAS;AAClB,UAAOC,wDAAuB,QAAQ,eAAe,SAAS;IAAE;IAAS;IAAO,CAAC;;EAElF"}
|