@just-web/toolkits 2.0.0 → 2.1.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 +1 -1
- package/dist/attributes/observe-attribute.cjs.map +1 -1
- package/dist/attributes/observe-attribute.d.cts +2 -2
- package/dist/attributes/observe-attribute.d.cts.map +1 -1
- package/dist/attributes/observe-attribute.d.mts +2 -2
- package/dist/attributes/observe-attribute.d.mts.map +1 -1
- package/dist/attributes/observe-attribute.mjs +1 -1
- package/dist/attributes/observe-attribute.mjs.map +1 -1
- package/dist/attributes/observe-data-attribute.cjs +1 -1
- package/dist/attributes/observe-data-attribute.cjs.map +1 -1
- package/dist/attributes/observe-data-attribute.d.cts +2 -2
- package/dist/attributes/observe-data-attribute.d.cts.map +1 -1
- package/dist/attributes/observe-data-attribute.d.mts +2 -2
- package/dist/attributes/observe-data-attribute.d.mts.map +1 -1
- package/dist/attributes/observe-data-attribute.mjs +1 -1
- 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 +7 -7
- 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 +7 -7
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +2 -2
- package/src/attributes/observe-data-attribute.ts +2 -2
- 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 +11 -11
- 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 +2 -2
- 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 +2 -2
- 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":"write-cookie-theme.d.cts","names":[],"sources":["../../../src/theme/cookie/write-cookie-theme.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wCAAwC,WAAW;;EAAnD,IAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAiBD,MAAA,CAAA,EAAA,MAAA,GAAA,SAAgB;EAAgB,QAAA,CAAA,EAAA,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,SAAA;EACtC,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;;;;;;;;;;;iBADM,gCAAgC,mBACtC,eACF,WAAW,
|
|
1
|
+
{"version":3,"file":"write-cookie-theme.d.cts","names":[],"sources":["../../../src/theme/cookie/write-cookie-theme.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wCAAwC,WAAW;;EAAnD,IAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAiBD,MAAA,CAAA,EAAA,MAAA,GAAA,SAAgB;EAAgB,QAAA,CAAA,EAAA,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,SAAA;EACtC,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;;;;;;;;;;;iBADM,gCAAgC,mBACtC,eACF,WAAW,qCACT,wBAAwB"}
|
|
@@ -15,10 +15,10 @@ interface WriteCookieThemeOptions<_Themes extends ThemeMap = ThemeMap> {
|
|
|
15
15
|
* Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.
|
|
16
16
|
*
|
|
17
17
|
* @param themes - Record mapping theme keys to values (used for type validation)
|
|
18
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
18
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
19
19
|
* @param options - Cookie options
|
|
20
20
|
*/
|
|
21
|
-
declare function writeCookieTheme<Themes extends ThemeMap>(_themes: Themes, entry: ThemeEntry<Themes> | undefined, options: WriteCookieThemeOptions<Themes>): void;
|
|
21
|
+
declare function writeCookieTheme<Themes extends ThemeMap>(_themes: Themes, entry: ThemeEntry<Themes> | null | undefined, options: WriteCookieThemeOptions<Themes>): void;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { WriteCookieThemeOptions, writeCookieTheme };
|
|
24
24
|
//# sourceMappingURL=write-cookie-theme.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-cookie-theme.d.mts","names":[],"sources":["../../../src/theme/cookie/write-cookie-theme.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wCAAwC,WAAW;;EAAnD,IAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAiBD,MAAA,CAAA,EAAA,MAAA,GAAA,SAAgB;EAAgB,QAAA,CAAA,EAAA,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,SAAA;EACtC,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;;;;;;;;;;;iBADM,gCAAgC,mBACtC,eACF,WAAW,
|
|
1
|
+
{"version":3,"file":"write-cookie-theme.d.mts","names":[],"sources":["../../../src/theme/cookie/write-cookie-theme.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wCAAwC,WAAW;;EAAnD,IAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAiBD,MAAA,CAAA,EAAA,MAAA,GAAA,SAAgB;EAAgB,QAAA,CAAA,EAAA,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,SAAA;EACtC,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;;;;;;;;;;;iBADM,gCAAgC,mBACtC,eACF,WAAW,qCACT,wBAAwB"}
|
|
@@ -7,13 +7,13 @@ import { deleteCookie, setCookie } from "./_cookie-utils.mjs";
|
|
|
7
7
|
* Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.
|
|
8
8
|
*
|
|
9
9
|
* @param themes - Record mapping theme keys to values (used for type validation)
|
|
10
|
-
* @param entry - Theme entry to write, or undefined to remove
|
|
10
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
11
11
|
* @param options - Cookie options
|
|
12
12
|
*/
|
|
13
13
|
function writeCookieTheme(_themes, entry, options) {
|
|
14
14
|
const { cookieName, path = "/", maxAge, sameSite, secure } = options;
|
|
15
15
|
if (typeof document === "undefined" || document.cookie === void 0) return;
|
|
16
|
-
if (entry
|
|
16
|
+
if (entry == null) {
|
|
17
17
|
deleteCookie(cookieName, path);
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-cookie-theme.mjs","names":["opts: {\n\t\tpath: string\n\t\tmaxAge?: number\n\t\tsameSite?: 'lax' | 'strict' | 'none'\n\t\tsecure?: boolean\n\t}"],"sources":["../../../src/theme/cookie/write-cookie-theme.ts"],"sourcesContent":["import type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { deleteCookie, setCookie } from './_cookie-utils.ts'\n\nexport interface WriteCookieThemeOptions<_Themes extends ThemeMap = ThemeMap> {\n\tcookieName: string\n\tpath?: string | undefined\n\tmaxAge?: number | undefined\n\tsameSite?: 'lax' | 'strict' | 'none' | undefined\n\tsecure?: boolean | undefined\n}\n\n/**\n * Writes a theme entry to a cookie.\n *\n * Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used for type validation)\n * @param entry - Theme entry to write, or undefined to remove\n * @param options - Cookie options\n */\nexport function writeCookieTheme<Themes extends ThemeMap>(\n\t_themes: Themes,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions: WriteCookieThemeOptions<Themes>\n): void {\n\tconst { cookieName, path = '/', maxAge, sameSite, secure } = options\n\n\tif (typeof document === 'undefined' || document.cookie === undefined) {\n\t\treturn\n\t}\n\n\tif (entry
|
|
1
|
+
{"version":3,"file":"write-cookie-theme.mjs","names":["opts: {\n\t\tpath: string\n\t\tmaxAge?: number\n\t\tsameSite?: 'lax' | 'strict' | 'none'\n\t\tsecure?: boolean\n\t}"],"sources":["../../../src/theme/cookie/write-cookie-theme.ts"],"sourcesContent":["import type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { deleteCookie, setCookie } from './_cookie-utils.ts'\n\nexport interface WriteCookieThemeOptions<_Themes extends ThemeMap = ThemeMap> {\n\tcookieName: string\n\tpath?: string | undefined\n\tmaxAge?: number | undefined\n\tsameSite?: 'lax' | 'strict' | 'none' | undefined\n\tsecure?: boolean | undefined\n}\n\n/**\n * Writes a theme entry to a cookie.\n *\n * Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used for type validation)\n * @param entry - Theme entry to write, or null/undefined to remove\n * @param options - Cookie options\n */\nexport function writeCookieTheme<Themes extends ThemeMap>(\n\t_themes: Themes,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions: WriteCookieThemeOptions<Themes>\n): void {\n\tconst { cookieName, path = '/', maxAge, sameSite, secure } = options\n\n\tif (typeof document === 'undefined' || document.cookie === undefined) {\n\t\treturn\n\t}\n\n\tif (entry == null) {\n\t\tdeleteCookie(cookieName, path)\n\t\treturn\n\t}\n\n\tconst opts: {\n\t\tpath: string\n\t\tmaxAge?: number\n\t\tsameSite?: 'lax' | 'strict' | 'none'\n\t\tsecure?: boolean\n\t} = { path }\n\tif (maxAge !== undefined) opts.maxAge = maxAge\n\tif (sameSite !== undefined) opts.sameSite = sameSite\n\tif (secure) opts.secure = true\n\tsetCookie(cookieName, JSON.stringify(entry), opts)\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAgB,iBACf,SACA,OACA,SACO;CACP,MAAM,EAAE,YAAY,OAAO,KAAK,QAAQ,UAAU,WAAW;AAE7D,KAAI,OAAO,aAAa,eAAe,SAAS,WAAW,OAC1D;AAGD,KAAI,SAAS,MAAM;AAClB,eAAa,YAAY,KAAK;AAC9B;;CAGD,MAAMA,OAKF,EAAE,MAAM;AACZ,KAAI,WAAW,OAAW,MAAK,SAAS;AACxC,KAAI,aAAa,OAAW,MAAK,WAAW;AAC5C,KAAI,OAAQ,MAAK,SAAS;AAC1B,WAAU,YAAY,KAAK,UAAU,MAAM,EAAE,KAAK"}
|
|
@@ -9,7 +9,7 @@ const require_match_attribute_value_to_theme = require('../_utils/match-attribut
|
|
|
9
9
|
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
-
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute; accepts null)
|
|
13
13
|
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
14
|
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-data-attribute.cjs","names":["SEPARATOR_SPACE","matchAttributeValueToTheme","themeEntry"],"sources":["../../../src/theme/data-attribute/parse-data-attribute.ts"],"sourcesContent":["import { matchAttributeValueToTheme } from '../_utils/match-attribute-value-to-theme.ts'\nimport { themeEntry } from '../theme-entry.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Parses a data attribute value string into a ThemeEntry.\n *\n * Pure function: no DOM access. Uses first token when separator is defined.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param value - Raw attribute value string (e.g. from getAttribute)\n * @param options.separator - When defined, split by separator and use first token (default: space)\n * @returns ThemeEntry if a match is found, otherwise undefined\n */\nexport function parseDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tvalue: string | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): ThemeEntry<Themes> | undefined {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst theme = matchAttributeValueToTheme(themes, value ?? null, { separator })\n\treturn theme !== undefined ? themeEntry(themes, theme) : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,mBACf,QACA,OACA,SACiC;CACjC,MAAM,YAAY,SAAS,aAAaA;CACxC,MAAM,QAAQC,kEAA2B,QAAQ,SAAS,MAAM,EAAE,WAAW,CAAC;AAC9E,QAAO,UAAU,SAAYC,+BAAW,QAAQ,MAAM,GAAG"}
|
|
1
|
+
{"version":3,"file":"parse-data-attribute.cjs","names":["SEPARATOR_SPACE","matchAttributeValueToTheme","themeEntry"],"sources":["../../../src/theme/data-attribute/parse-data-attribute.ts"],"sourcesContent":["import { matchAttributeValueToTheme } from '../_utils/match-attribute-value-to-theme.ts'\nimport { themeEntry } from '../theme-entry.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Parses a data attribute value string into a ThemeEntry.\n *\n * Pure function: no DOM access. Uses first token when separator is defined.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param value - Raw attribute value string (e.g. from getAttribute; accepts null)\n * @param options.separator - When defined, split by separator and use first token (default: space)\n * @returns ThemeEntry if a match is found, otherwise undefined\n */\nexport function parseDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tvalue: string | null | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): ThemeEntry<Themes> | undefined {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst theme = matchAttributeValueToTheme(themes, value ?? null, { separator })\n\treturn theme !== undefined ? themeEntry(themes, theme) : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,mBACf,QACA,OACA,SACiC;CACjC,MAAM,YAAY,SAAS,aAAaA;CACxC,MAAM,QAAQC,kEAA2B,QAAQ,SAAS,MAAM,EAAE,WAAW,CAAC;AAC9E,QAAO,UAAU,SAAYC,+BAAW,QAAQ,MAAM,GAAG"}
|
|
@@ -9,11 +9,11 @@ import { ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
9
9
|
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
-
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute; accepts null)
|
|
13
13
|
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
14
|
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
15
|
*/
|
|
16
|
-
declare function parseDataAttribute<Themes extends ThemeMap>(themes: Themes, value: string | undefined, options?: {
|
|
16
|
+
declare function parseDataAttribute<Themes extends ThemeMap>(themes: Themes, value: string | null | undefined, options?: {
|
|
17
17
|
separator?: string | undefined;
|
|
18
18
|
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
19
|
//#endregion
|
|
@@ -9,11 +9,11 @@ import { ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
9
9
|
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
-
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute; accepts null)
|
|
13
13
|
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
14
|
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
15
|
*/
|
|
16
|
-
declare function parseDataAttribute<Themes extends ThemeMap>(themes: Themes, value: string | undefined, options?: {
|
|
16
|
+
declare function parseDataAttribute<Themes extends ThemeMap>(themes: Themes, value: string | null | undefined, options?: {
|
|
17
17
|
separator?: string | undefined;
|
|
18
18
|
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
19
|
//#endregion
|
|
@@ -9,7 +9,7 @@ import { matchAttributeValueToTheme } from "../_utils/match-attribute-value-to-t
|
|
|
9
9
|
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
-
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute; accepts null)
|
|
13
13
|
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
14
|
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/parse-data-attribute.ts"],"sourcesContent":["import { matchAttributeValueToTheme } from '../_utils/match-attribute-value-to-theme.ts'\nimport { themeEntry } from '../theme-entry.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Parses a data attribute value string into a ThemeEntry.\n *\n * Pure function: no DOM access. Uses first token when separator is defined.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param value - Raw attribute value string (e.g. from getAttribute)\n * @param options.separator - When defined, split by separator and use first token (default: space)\n * @returns ThemeEntry if a match is found, otherwise undefined\n */\nexport function parseDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tvalue: string | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): ThemeEntry<Themes> | undefined {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst theme = matchAttributeValueToTheme(themes, value ?? null, { separator })\n\treturn theme !== undefined ? themeEntry(themes, theme) : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,mBACf,QACA,OACA,SACiC;CACjC,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,QAAQ,2BAA2B,QAAQ,SAAS,MAAM,EAAE,WAAW,CAAC;AAC9E,QAAO,UAAU,SAAY,WAAW,QAAQ,MAAM,GAAG"}
|
|
1
|
+
{"version":3,"file":"parse-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/parse-data-attribute.ts"],"sourcesContent":["import { matchAttributeValueToTheme } from '../_utils/match-attribute-value-to-theme.ts'\nimport { themeEntry } from '../theme-entry.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Parses a data attribute value string into a ThemeEntry.\n *\n * Pure function: no DOM access. Uses first token when separator is defined.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param value - Raw attribute value string (e.g. from getAttribute; accepts null)\n * @param options.separator - When defined, split by separator and use first token (default: space)\n * @returns ThemeEntry if a match is found, otherwise undefined\n */\nexport function parseDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tvalue: string | null | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): ThemeEntry<Themes> | undefined {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst theme = matchAttributeValueToTheme(themes, value ?? null, { separator })\n\treturn theme !== undefined ? themeEntry(themes, theme) : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,mBACf,QACA,OACA,SACiC;CACjC,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,QAAQ,2BAA2B,QAAQ,SAAS,MAAM,EAAE,WAAW,CAAC;AAC9E,QAAO,UAAU,SAAY,WAAW,QAAQ,MAAM,GAAG"}
|
|
@@ -8,7 +8,7 @@ const require_parse_data_attribute = require('./parse-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 options.element - Element to read from (
|
|
11
|
+
* @param options.element - Element to read from (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
12
12
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
13
|
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-data-attribute.cjs","names":["parseDataAttribute","SEPARATOR_SPACE","getDataAttribute"],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-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 * Reads a theme entry from 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 options.element - Element to read from (
|
|
1
|
+
{"version":3,"file":"read-data-attribute.cjs","names":["parseDataAttribute","SEPARATOR_SPACE","getDataAttribute"],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-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 * Reads a theme entry from 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 options.element - Element to read from (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.parse - Custom parser (default: parseDataAttribute with space separator)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).\n */\nexport function readDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\toptions?:\n\t\t| { element?: Element | null | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): ThemeEntry<Themes> | undefined {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return undefined\n\tconst parse =\n\t\toptions?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }))\n\tconst raw = getDataAttribute(attributeName, element) ?? undefined\n\treturn parse(themes, raw)\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,kBACf,QACA,eACA,SAGiC;CACjC,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,QAAO;AAIrB,SAFC,SAAS,WAAW,GAAG,MAAMA,gDAAmB,GAAG,GAAG,EAAE,WAAWC,mCAAiB,CAAC,GAEzE,QADDC,4CAAiB,eAAe,QAAQ,IAAI,OAC/B"}
|
|
@@ -8,12 +8,12 @@ import { ParseStoredTheme, 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 options.element - Element to read from (
|
|
11
|
+
* @param options.element - Element to read from (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
12
12
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
13
|
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
14
|
*/
|
|
15
15
|
declare function readDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, options?: {
|
|
16
|
-
element?: Element | undefined;
|
|
16
|
+
element?: Element | null | undefined;
|
|
17
17
|
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
18
|
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAMG,iBANa,iBAMb,CAAA,eAN8C,QAM9C,CAAA,CAAA,MAAA,EALM,MAKN,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,QAAA,EAAA;EAAU,OAAA,CAAA,EAFG,OAEH,GAAA,SAAA;
|
|
1
|
+
{"version":3,"file":"read-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAMG,iBANa,iBAMb,CAAA,eAN8C,QAM9C,CAAA,CAAA,MAAA,EALM,MAKN,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,QAAA,EAAA;EAAU,OAAA,CAAA,EAFG,OAEH,GAAA,IAAA,GAAA,SAAA;UAFuC,iBAAiB;gBAElE,WAAW"}
|
|
@@ -8,12 +8,12 @@ import { ParseStoredTheme, 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 options.element - Element to read from (
|
|
11
|
+
* @param options.element - Element to read from (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
12
12
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
13
|
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
14
|
*/
|
|
15
15
|
declare function readDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, options?: {
|
|
16
|
-
element?: Element | undefined;
|
|
16
|
+
element?: Element | null | undefined;
|
|
17
17
|
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
18
|
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAMG,iBANa,iBAMb,CAAA,eAN8C,QAM9C,CAAA,CAAA,MAAA,EALM,MAKN,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,QAAA,EAAA;EAAU,OAAA,CAAA,EAFG,OAEH,GAAA,SAAA;
|
|
1
|
+
{"version":3,"file":"read-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAMG,iBANa,iBAMb,CAAA,eAN8C,QAM9C,CAAA,CAAA,MAAA,EALM,MAKN,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,QAAA,EAAA;EAAU,OAAA,CAAA,EAFG,OAEH,GAAA,IAAA,GAAA,SAAA;UAFuC,iBAAiB;gBAElE,WAAW"}
|
|
@@ -8,7 +8,7 @@ import { parseDataAttribute } from "./parse-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 options.element - Element to read from (
|
|
11
|
+
* @param options.element - Element to read from (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
12
12
|
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
13
|
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-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 * Reads a theme entry from 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 options.element - Element to read from (
|
|
1
|
+
{"version":3,"file":"read-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/read-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-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 * Reads a theme entry from 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 options.element - Element to read from (accepts null e.g. from refs). Defaults to document.documentElement.\n * @param options.parse - Custom parser (default: parseDataAttribute with space separator)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).\n */\nexport function readDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\toptions?:\n\t\t| { element?: Element | null | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): ThemeEntry<Themes> | undefined {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return undefined\n\tconst parse =\n\t\toptions?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }))\n\tconst raw = getDataAttribute(attributeName, element) ?? undefined\n\treturn parse(themes, raw)\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,kBACf,QACA,eACA,SAGiC;CACjC,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,QAAO;AAIrB,SAFC,SAAS,WAAW,GAAG,MAAM,mBAAmB,GAAG,GAAG,EAAE,WAAW,iBAAiB,CAAC,GAEzE,QADD,iBAAiB,eAAe,QAAQ,IAAI,OAC/B"}
|
|
@@ -9,8 +9,8 @@ const require__constant = require('./_constant.cjs');
|
|
|
9
9
|
* Aligns with stringifyClassName logic.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
|
|
12
|
-
* @param existing - Current attribute value string
|
|
13
|
-
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
|
|
12
|
+
* @param existing - Current attribute value string (accepts null e.g. from getAttribute)
|
|
13
|
+
* @param entry - Theme entry to stringify, or null/undefined to clear theme (keeps non-theme tokens)
|
|
14
14
|
* @param options.separator - Token separator (default: space)
|
|
15
15
|
* @returns Attribute value string
|
|
16
16
|
*/
|
|
@@ -20,8 +20,8 @@ function stringifyDataAttribute(themes, existing, entry, options) {
|
|
|
20
20
|
const resolved = require_resolve_theme_map_value.resolveThemeMapValue(v);
|
|
21
21
|
return Array.isArray(resolved) ? [...resolved] : [resolved];
|
|
22
22
|
});
|
|
23
|
-
const withoutThemeValues = (existing?.trim() ? existing.trim().split(separator) : []).filter((t) => !allThemeValues.includes(t.trim()));
|
|
24
|
-
const newTokens = entry
|
|
23
|
+
const withoutThemeValues = ((existing ?? "")?.trim() ? (existing ?? "").trim().split(separator) : []).filter((t) => !allThemeValues.includes(t.trim()));
|
|
24
|
+
const newTokens = entry != null ? (() => {
|
|
25
25
|
const resolved = require_resolve_theme_map_value.resolveThemeMapValue(entry.value);
|
|
26
26
|
return Array.isArray(resolved) ? [resolved[0]] : [resolved];
|
|
27
27
|
})() : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-data-attribute.cjs","names":["SEPARATOR_SPACE","resolveThemeMapValue"],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Stringifies a ThemeEntry for a data attribute value.\n *\n * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).\n * Aligns with stringifyClassName logic.\n *\n * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)\n * @param existing - Current attribute value string\n * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)\n * @param options.separator - Token separator (default: space)\n * @returns Attribute value string\n */\nexport function stringifyDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | undefined,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): string {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst allThemeValues = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingTokens = existing?.trim() ? existing.trim().split(separator) : []\n\tconst withoutThemeValues = existingTokens.filter((t) => !allThemeValues.includes(t.trim()))\n\tconst newTokens =\n\t\tentry
|
|
1
|
+
{"version":3,"file":"stringify-data-attribute.cjs","names":["SEPARATOR_SPACE","resolveThemeMapValue"],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Stringifies a ThemeEntry for a data attribute value.\n *\n * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).\n * Aligns with stringifyClassName logic.\n *\n * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)\n * @param existing - Current attribute value string (accepts null e.g. from getAttribute)\n * @param entry - Theme entry to stringify, or null/undefined to clear theme (keeps non-theme tokens)\n * @param options.separator - Token separator (default: space)\n * @returns Attribute value string\n */\nexport function stringifyDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | null | undefined,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): string {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst allThemeValues = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingTokens = (existing ?? '')?.trim() ? (existing ?? '').trim().split(separator) : []\n\tconst withoutThemeValues = existingTokens.filter((t) => !allThemeValues.includes(t.trim()))\n\tconst newTokens =\n\t\tentry != null\n\t\t\t? (() => {\n\t\t\t\t\tconst resolved = resolveThemeMapValue(entry.value)\n\t\t\t\t\treturn Array.isArray(resolved) ? [resolved[0]] : [resolved]\n\t\t\t\t})()\n\t\t\t: []\n\treturn [...withoutThemeValues, ...newTokens].filter(Boolean).join(separator)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,uBACf,QACA,UACA,OACA,SACS;CACT,MAAM,YAAY,SAAS,aAAaA;CACxC,MAAM,iBAAiB,OAAO,OAAO,OAAO,CAAC,SAAS,MAAM;EAC3D,MAAM,WAAWC,qDAAqB,EAAE;AACxC,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;GAC1D;CAEF,MAAM,uBADkB,YAAY,KAAK,MAAM,IAAI,YAAY,IAAI,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,EACrD,QAAQ,MAAM,CAAC,eAAe,SAAS,EAAE,MAAM,CAAC,CAAC;CAC3F,MAAM,YACL,SAAS,cACC;EACP,MAAM,WAAWA,qDAAqB,MAAM,MAAM;AAClD,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS;KACxD,GACH,EAAE;AACN,QAAO,CAAC,GAAG,oBAAoB,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,UAAU"}
|
|
@@ -10,12 +10,12 @@ import { ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
10
10
|
* Aligns with stringifyClassName logic.
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
|
|
13
|
-
* @param existing - Current attribute value string
|
|
14
|
-
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
|
|
13
|
+
* @param existing - Current attribute value string (accepts null e.g. from getAttribute)
|
|
14
|
+
* @param entry - Theme entry to stringify, or null/undefined to clear theme (keeps non-theme tokens)
|
|
15
15
|
* @param options.separator - Token separator (default: space)
|
|
16
16
|
* @returns Attribute value string
|
|
17
17
|
*/
|
|
18
|
-
declare function stringifyDataAttribute<Themes extends ThemeMap>(themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
18
|
+
declare function stringifyDataAttribute<Themes extends ThemeMap>(themes: Themes, existing: string | null | undefined, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
19
19
|
separator?: string | undefined;
|
|
20
20
|
} | undefined): string;
|
|
21
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C,
|
|
1
|
+
{"version":3,"file":"stringify-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C,oDAED,WAAW"}
|
|
@@ -10,12 +10,12 @@ import { ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
10
10
|
* Aligns with stringifyClassName logic.
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
|
|
13
|
-
* @param existing - Current attribute value string
|
|
14
|
-
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
|
|
13
|
+
* @param existing - Current attribute value string (accepts null e.g. from getAttribute)
|
|
14
|
+
* @param entry - Theme entry to stringify, or null/undefined to clear theme (keeps non-theme tokens)
|
|
15
15
|
* @param options.separator - Token separator (default: space)
|
|
16
16
|
* @returns Attribute value string
|
|
17
17
|
*/
|
|
18
|
-
declare function stringifyDataAttribute<Themes extends ThemeMap>(themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
18
|
+
declare function stringifyDataAttribute<Themes extends ThemeMap>(themes: Themes, existing: string | null | undefined, entry: ThemeEntry<Themes> | null | undefined, options?: {
|
|
19
19
|
separator?: string | undefined;
|
|
20
20
|
} | undefined): string;
|
|
21
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C,
|
|
1
|
+
{"version":3,"file":"stringify-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C,oDAED,WAAW"}
|
|
@@ -9,8 +9,8 @@ import { SEPARATOR_SPACE } from "./_constant.mjs";
|
|
|
9
9
|
* Aligns with stringifyClassName logic.
|
|
10
10
|
*
|
|
11
11
|
* @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
|
|
12
|
-
* @param existing - Current attribute value string
|
|
13
|
-
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
|
|
12
|
+
* @param existing - Current attribute value string (accepts null e.g. from getAttribute)
|
|
13
|
+
* @param entry - Theme entry to stringify, or null/undefined to clear theme (keeps non-theme tokens)
|
|
14
14
|
* @param options.separator - Token separator (default: space)
|
|
15
15
|
* @returns Attribute value string
|
|
16
16
|
*/
|
|
@@ -20,8 +20,8 @@ function stringifyDataAttribute(themes, existing, entry, options) {
|
|
|
20
20
|
const resolved = resolveThemeMapValue(v);
|
|
21
21
|
return Array.isArray(resolved) ? [...resolved] : [resolved];
|
|
22
22
|
});
|
|
23
|
-
const withoutThemeValues = (existing?.trim() ? existing.trim().split(separator) : []).filter((t) => !allThemeValues.includes(t.trim()));
|
|
24
|
-
const newTokens = entry
|
|
23
|
+
const withoutThemeValues = ((existing ?? "")?.trim() ? (existing ?? "").trim().split(separator) : []).filter((t) => !allThemeValues.includes(t.trim()));
|
|
24
|
+
const newTokens = entry != null ? (() => {
|
|
25
25
|
const resolved = resolveThemeMapValue(entry.value);
|
|
26
26
|
return Array.isArray(resolved) ? [resolved[0]] : [resolved];
|
|
27
27
|
})() : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Stringifies a ThemeEntry for a data attribute value.\n *\n * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).\n * Aligns with stringifyClassName logic.\n *\n * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)\n * @param existing - Current attribute value string\n * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)\n * @param options.separator - Token separator (default: space)\n * @returns Attribute value string\n */\nexport function stringifyDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | undefined,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): string {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst allThemeValues = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingTokens = existing?.trim() ? existing.trim().split(separator) : []\n\tconst withoutThemeValues = existingTokens.filter((t) => !allThemeValues.includes(t.trim()))\n\tconst newTokens =\n\t\tentry
|
|
1
|
+
{"version":3,"file":"stringify-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Stringifies a ThemeEntry for a data attribute value.\n *\n * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).\n * Aligns with stringifyClassName logic.\n *\n * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)\n * @param existing - Current attribute value string (accepts null e.g. from getAttribute)\n * @param entry - Theme entry to stringify, or null/undefined to clear theme (keeps non-theme tokens)\n * @param options.separator - Token separator (default: space)\n * @returns Attribute value string\n */\nexport function stringifyDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | null | undefined,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): string {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst allThemeValues = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingTokens = (existing ?? '')?.trim() ? (existing ?? '').trim().split(separator) : []\n\tconst withoutThemeValues = existingTokens.filter((t) => !allThemeValues.includes(t.trim()))\n\tconst newTokens =\n\t\tentry != null\n\t\t\t? (() => {\n\t\t\t\t\tconst resolved = resolveThemeMapValue(entry.value)\n\t\t\t\t\treturn Array.isArray(resolved) ? [resolved[0]] : [resolved]\n\t\t\t\t})()\n\t\t\t: []\n\treturn [...withoutThemeValues, ...newTokens].filter(Boolean).join(separator)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,uBACf,QACA,UACA,OACA,SACS;CACT,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,iBAAiB,OAAO,OAAO,OAAO,CAAC,SAAS,MAAM;EAC3D,MAAM,WAAW,qBAAqB,EAAE;AACxC,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;GAC1D;CAEF,MAAM,uBADkB,YAAY,KAAK,MAAM,IAAI,YAAY,IAAI,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,EACrD,QAAQ,MAAM,CAAC,eAAe,SAAS,EAAE,MAAM,CAAC,CAAC;CAC3F,MAAM,YACL,SAAS,cACC;EACP,MAAM,WAAW,qBAAqB,MAAM,MAAM;AAClD,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS;KACxD,GACH,EAAE;AACN,QAAO,CAAC,GAAG,oBAAoB,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,UAAU"}
|
|
@@ -9,7 +9,7 @@ const require_parse_data_attribute = require('./parse-data-attribute.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
|
*/
|
|
@@ -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\tconst observer = 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\treturn () => observer.disconnect()\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;CACtF,MAAM,WAAWC,qDAChB,GACE,iBAAiB,UAAU;AAE3B,UADc,MAAM,QAAQ,SAAS,OAAU,CACjC;IAEf,EACD,QACA;AACD,cAAa,SAAS,YAAY"}
|
|
@@ -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
|
*/
|
|
@@ -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\tconst observer = 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\treturn () => observer.disconnect()\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;CACtF,MAAM,WAAW,sBAChB,GACE,iBAAiB,UAAU;AAE3B,UADc,MAAM,QAAQ,SAAS,OAAU,CACjC;IAEf,EACD,QACA;AACD,cAAa,SAAS,YAAY"}
|
|
@@ -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
|
*/
|