@just-web/toolkits 1.0.0 → 2.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/react/hooks/use-theme-by-class-name.cjs +1 -5
- package/dist/react/hooks/use-theme-by-class-name.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.d.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.mjs +1 -5
- package/dist/react/hooks/use-theme-by-class-name.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.cjs +1 -6
- package/dist/react/hooks/use-theme-by-data-attribute.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.d.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.mjs +1 -6
- package/dist/react/hooks/use-theme-by-data-attribute.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.cjs +1 -5
- package/dist/react/hooks/use-theme-by-local-storage.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.d.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.mjs +1 -5
- package/dist/react/hooks/use-theme-by-local-storage.mjs.map +1 -1
- package/dist/theme/_utils/match-attribute-value-to-theme.cjs +29 -0
- package/dist/theme/_utils/match-attribute-value-to-theme.cjs.map +1 -0
- package/dist/theme/_utils/match-attribute-value-to-theme.mjs +28 -0
- package/dist/theme/_utils/match-attribute-value-to-theme.mjs.map +1 -0
- package/dist/theme/_utils/parse-stored-theme.cjs +61 -7
- package/dist/theme/_utils/parse-stored-theme.cjs.map +1 -1
- package/dist/theme/_utils/parse-stored-theme.mjs +61 -7
- package/dist/theme/_utils/parse-stored-theme.mjs.map +1 -1
- package/dist/theme/_utils/resolve-theme-map-value.cjs +19 -0
- package/dist/theme/_utils/resolve-theme-map-value.cjs.map +1 -0
- package/dist/theme/_utils/resolve-theme-map-value.mjs +17 -0
- package/dist/theme/_utils/resolve-theme-map-value.mjs.map +1 -0
- package/dist/theme/class-name/parse-class-name.cjs +32 -0
- package/dist/theme/class-name/parse-class-name.cjs.map +1 -0
- package/dist/theme/class-name/parse-class-name.d.cts +20 -0
- package/dist/theme/class-name/parse-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/parse-class-name.d.mts +20 -0
- package/dist/theme/class-name/parse-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/parse-class-name.mjs +31 -0
- package/dist/theme/class-name/parse-class-name.mjs.map +1 -0
- package/dist/theme/class-name/read-class-name.cjs +20 -0
- package/dist/theme/class-name/read-class-name.cjs.map +1 -0
- package/dist/theme/class-name/read-class-name.d.cts +20 -0
- package/dist/theme/class-name/read-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/read-class-name.d.mts +20 -0
- package/dist/theme/class-name/read-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/read-class-name.mjs +20 -0
- package/dist/theme/class-name/read-class-name.mjs.map +1 -0
- package/dist/theme/class-name/stringify-class-name.cjs +31 -0
- package/dist/theme/class-name/stringify-class-name.cjs.map +1 -0
- package/dist/theme/class-name/stringify-class-name.d.cts +21 -0
- package/dist/theme/class-name/stringify-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/stringify-class-name.d.mts +21 -0
- package/dist/theme/class-name/stringify-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/stringify-class-name.mjs +31 -0
- package/dist/theme/class-name/stringify-class-name.mjs.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.cjs +31 -0
- package/dist/theme/class-name/subscribe-class-name.cjs.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.d.cts +21 -0
- package/dist/theme/class-name/subscribe-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.d.mts +21 -0
- package/dist/theme/class-name/subscribe-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.mjs +31 -0
- package/dist/theme/class-name/subscribe-class-name.mjs.map +1 -0
- package/dist/theme/class-name/write-class-name.cjs +20 -0
- package/dist/theme/class-name/write-class-name.cjs.map +1 -0
- package/dist/theme/class-name/write-class-name.d.cts +20 -0
- package/dist/theme/class-name/write-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/write-class-name.d.mts +20 -0
- package/dist/theme/class-name/write-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/write-class-name.mjs +20 -0
- package/dist/theme/class-name/write-class-name.mjs.map +1 -0
- package/dist/theme/cookie/_cookie-utils.cjs +37 -0
- package/dist/theme/cookie/_cookie-utils.cjs.map +1 -0
- package/dist/theme/cookie/_cookie-utils.mjs +33 -0
- package/dist/theme/cookie/_cookie-utils.mjs.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.cjs +22 -0
- package/dist/theme/cookie/read-cookie-theme.cjs.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.d.cts +22 -0
- package/dist/theme/cookie/read-cookie-theme.d.cts.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.d.mts +22 -0
- package/dist/theme/cookie/read-cookie-theme.d.mts.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.mjs +22 -0
- package/dist/theme/cookie/read-cookie-theme.mjs.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.cjs +29 -0
- package/dist/theme/cookie/write-cookie-theme.cjs.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.d.cts +24 -0
- package/dist/theme/cookie/write-cookie-theme.d.cts.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.d.mts +24 -0
- package/dist/theme/cookie/write-cookie-theme.d.mts.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.mjs +29 -0
- package/dist/theme/cookie/write-cookie-theme.mjs.map +1 -0
- package/dist/theme/data-attribute/_constant.cjs +7 -0
- package/dist/theme/data-attribute/_constant.cjs.map +1 -0
- package/dist/theme/data-attribute/_constant.mjs +6 -0
- package/dist/theme/data-attribute/_constant.mjs.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.cjs +24 -0
- package/dist/theme/data-attribute/parse-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.cts +21 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.mts +21 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.mjs +24 -0
- package/dist/theme/data-attribute/parse-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.cjs +23 -0
- package/dist/theme/data-attribute/read-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.d.cts +21 -0
- package/dist/theme/data-attribute/read-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.d.mts +21 -0
- package/dist/theme/data-attribute/read-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.mjs +23 -0
- package/dist/theme/data-attribute/read-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.cjs +33 -0
- package/dist/theme/data-attribute/stringify-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.cts +23 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.mts +23 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.mjs +33 -0
- package/dist/theme/data-attribute/stringify-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.cjs +28 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.cts +22 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.mts +22 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.mjs +28 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.cjs +30 -0
- package/dist/theme/data-attribute/write-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.d.cts +21 -0
- package/dist/theme/data-attribute/write-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.d.mts +21 -0
- package/dist/theme/data-attribute/write-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.mjs +30 -0
- package/dist/theme/data-attribute/write-data-attribute.mjs.map +1 -0
- package/dist/theme/local-storage/read-local-storage.cjs +22 -0
- package/dist/theme/local-storage/read-local-storage.cjs.map +1 -0
- package/dist/theme/local-storage/read-local-storage.d.cts +19 -0
- package/dist/theme/local-storage/read-local-storage.d.cts.map +1 -0
- package/dist/theme/local-storage/read-local-storage.d.mts +19 -0
- package/dist/theme/local-storage/read-local-storage.d.mts.map +1 -0
- package/dist/theme/local-storage/read-local-storage.mjs +22 -0
- package/dist/theme/local-storage/read-local-storage.mjs.map +1 -0
- package/dist/theme/local-storage/write-local-storage.cjs +26 -0
- package/dist/theme/local-storage/write-local-storage.cjs.map +1 -0
- package/dist/theme/local-storage/write-local-storage.d.cts +23 -0
- package/dist/theme/local-storage/write-local-storage.d.cts.map +1 -0
- package/dist/theme/local-storage/write-local-storage.d.mts +23 -0
- package/dist/theme/local-storage/write-local-storage.d.mts.map +1 -0
- package/dist/theme/local-storage/write-local-storage.mjs +26 -0
- package/dist/theme/local-storage/write-local-storage.mjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.cts +23 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.cts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.mts +23 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.mts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.cts +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.cts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.mts +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.mts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs.map +1 -0
- package/dist/theme/session-storage/read-session-storage.cjs +22 -0
- package/dist/theme/session-storage/read-session-storage.cjs.map +1 -0
- package/dist/theme/session-storage/read-session-storage.d.cts +19 -0
- package/dist/theme/session-storage/read-session-storage.d.cts.map +1 -0
- package/dist/theme/session-storage/read-session-storage.d.mts +19 -0
- package/dist/theme/session-storage/read-session-storage.d.mts.map +1 -0
- package/dist/theme/session-storage/read-session-storage.mjs +22 -0
- package/dist/theme/session-storage/read-session-storage.mjs.map +1 -0
- package/dist/theme/session-storage/write-session-storage.cjs +26 -0
- package/dist/theme/session-storage/write-session-storage.cjs.map +1 -0
- package/dist/theme/session-storage/write-session-storage.d.cts +23 -0
- package/dist/theme/session-storage/write-session-storage.d.cts.map +1 -0
- package/dist/theme/session-storage/write-session-storage.d.mts +23 -0
- package/dist/theme/session-storage/write-session-storage.d.mts.map +1 -0
- package/dist/theme/session-storage/write-session-storage.mjs +26 -0
- package/dist/theme/session-storage/write-session-storage.mjs.map +1 -0
- package/dist/theme/theme-entry.types.d.cts +11 -1
- package/dist/theme/theme-entry.types.d.cts.map +1 -1
- package/dist/theme/theme-entry.types.d.mts +11 -1
- package/dist/theme/theme-entry.types.d.mts.map +1 -1
- package/dist/theme/theme-map.types.d.cts +11 -3
- package/dist/theme/theme-map.types.d.cts.map +1 -1
- package/dist/theme/theme-map.types.d.mts +11 -3
- package/dist/theme/theme-map.types.d.mts.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs +21 -18
- 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 +5 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts +5 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs +21 -18
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs +18 -36
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts +5 -3
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts +5 -3
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs +18 -36
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs +39 -19
- 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 +28 -5
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts +28 -5
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs +39 -19
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs +13 -12
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts +7 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts +7 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs +13 -12
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs +4 -5
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs +4 -5
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs +13 -12
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts +7 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts +7 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs +13 -12
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs.map +1 -1
- package/dist/theme/web-storage/read-web-storage.cjs +20 -0
- package/dist/theme/web-storage/read-web-storage.cjs.map +1 -0
- package/dist/theme/web-storage/read-web-storage.d.cts +21 -0
- package/dist/theme/web-storage/read-web-storage.d.cts.map +1 -0
- package/dist/theme/web-storage/read-web-storage.d.mts +21 -0
- package/dist/theme/web-storage/read-web-storage.d.mts.map +1 -0
- package/dist/theme/web-storage/read-web-storage.mjs +20 -0
- package/dist/theme/web-storage/read-web-storage.mjs.map +1 -0
- package/dist/theme/web-storage/write-web-storage.cjs +33 -0
- package/dist/theme/web-storage/write-web-storage.cjs.map +1 -0
- package/dist/theme/web-storage/write-web-storage.d.cts +25 -0
- package/dist/theme/web-storage/write-web-storage.d.cts.map +1 -0
- package/dist/theme/web-storage/write-web-storage.d.mts +25 -0
- package/dist/theme/web-storage/write-web-storage.d.mts.map +1 -0
- package/dist/theme/web-storage/write-web-storage.mjs +32 -0
- package/dist/theme/web-storage/write-web-storage.mjs.map +1 -0
- package/dist/theme.cjs +41 -1
- package/dist/theme.d.cts +23 -3
- package/dist/theme.d.mts +23 -3
- package/dist/theme.mjs +21 -1
- package/package.json +1 -1
- package/src/react/hooks/use-theme-by-class-name.ts +3 -8
- package/src/react/hooks/use-theme-by-data-attribute.ts +3 -10
- package/src/react/hooks/use-theme-by-local-storage.ts +3 -9
- package/src/testing/theme/theme-result-card.tsx +1 -0
- package/src/theme/_utils/match-attribute-value-to-theme.ts +36 -0
- package/src/theme/_utils/parse-stored-theme.ts +52 -12
- package/src/theme/_utils/resolve-theme-map-value.ts +15 -0
- package/src/theme/class-name/parse-class-name.ts +31 -0
- package/src/theme/class-name/read-class-name.ts +24 -0
- package/src/theme/class-name/stringify-class-name.ts +36 -0
- package/src/theme/class-name/subscribe-class-name.ts +39 -0
- package/src/theme/class-name/write-class-name.ts +24 -0
- package/src/theme/cookie/_cookie-utils.ts +45 -0
- package/src/theme/cookie/read-cookie-theme.ts +33 -0
- package/src/theme/cookie/write-cookie-theme.ts +48 -0
- package/src/theme/data-attribute/_constant.ts +1 -0
- package/src/theme/data-attribute/parse-data-attribute.ts +25 -0
- package/src/theme/data-attribute/read-data-attribute.ts +29 -0
- package/src/theme/data-attribute/stringify-data-attribute.ts +39 -0
- package/src/theme/data-attribute/subscribe-data-attribute.ts +39 -0
- package/src/theme/data-attribute/write-data-attribute.ts +40 -0
- package/src/theme/local-storage/read-local-storage.ts +23 -0
- package/src/theme/local-storage/write-local-storage.ts +31 -0
- package/src/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.ts +30 -0
- package/src/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.ts +24 -0
- package/src/theme/session-storage/read-session-storage.ts +23 -0
- package/src/theme/session-storage/write-session-storage.ts +31 -0
- package/src/theme/theme-entry.types.ts +19 -0
- package/src/theme/theme-map.types.ts +9 -2
- package/src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts +19 -25
- package/src/theme/theme-store/cookie-theme-store/cookie-theme-store.ts +18 -63
- package/src/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts +41 -28
- package/src/theme/theme-store/local-storage-theme-store/local-storage-theme-store.ts +17 -20
- package/src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts +4 -5
- package/src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts +17 -20
- package/src/theme/web-storage/read-web-storage.ts +22 -0
- package/src/theme/web-storage/write-web-storage.ts +46 -0
- package/src/theme.ts +20 -0
- package/dist/theme/class-name/apply-theme-to-class-name.cjs +0 -23
- package/dist/theme/class-name/apply-theme-to-class-name.cjs.map +0 -1
- package/dist/theme/class-name/apply-theme-to-class-name.mjs +0 -22
- package/dist/theme/class-name/apply-theme-to-class-name.mjs.map +0 -1
- package/dist/theme/class-name/resolve-theme-from-class-name.cjs +0 -23
- package/dist/theme/class-name/resolve-theme-from-class-name.cjs.map +0 -1
- package/dist/theme/class-name/resolve-theme-from-class-name.mjs +0 -22
- package/dist/theme/class-name/resolve-theme-from-class-name.mjs.map +0 -1
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs +0 -23
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs.map +0 -1
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs +0 -22
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs.map +0 -1
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs +0 -23
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs.map +0 -1
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs +0 -22
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs.map +0 -1
- package/src/theme/class-name/apply-theme-to-class-name.ts +0 -26
- package/src/theme/class-name/resolve-theme-from-class-name.ts +0 -22
- package/src/theme/data-attribute/apply-theme-to-data-attribute.ts +0 -27
- package/src/theme/data-attribute/resolve-theme-from-data-attribute.ts +0 -23
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/theme/cookie/_cookie-utils.ts
|
|
3
|
+
/**
|
|
4
|
+
* Internal cookie utilities for theme cookie storage.
|
|
5
|
+
* Cookie Store API has limited support; document.cookie is standard for theme persistence.
|
|
6
|
+
*/
|
|
7
|
+
function getCookieValue(name) {
|
|
8
|
+
if (typeof document === "undefined" || !document.cookie) return null;
|
|
9
|
+
const value = document.cookie.match(/* @__PURE__ */ new RegExp(`(?:^|;\\s*)${name}=([^;]*)`))?.[1];
|
|
10
|
+
return value !== void 0 ? decodeURIComponent(value) : null;
|
|
11
|
+
}
|
|
12
|
+
function setCookie(name, value, options) {
|
|
13
|
+
const parts = [`${name}=${encodeURIComponent(value)}`];
|
|
14
|
+
parts.push(`path=${options.path ?? "/"}`);
|
|
15
|
+
if (options.maxAge !== void 0) parts.push(`max-age=${options.maxAge}`);
|
|
16
|
+
if (options.sameSite !== void 0) parts.push(`samesite=${options.sameSite}`);
|
|
17
|
+
if (options.secure) parts.push("secure");
|
|
18
|
+
document.cookie = parts.join("; ");
|
|
19
|
+
}
|
|
20
|
+
function deleteCookie(name, path = "/") {
|
|
21
|
+
document.cookie = `${name}=; path=${path}; max-age=0`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parses a cookie value from a raw Cookie header string.
|
|
25
|
+
* Used for SSR when reading from request headers or framework cookie APIs.
|
|
26
|
+
*/
|
|
27
|
+
function getCookieFromHeader(cookieHeader, name) {
|
|
28
|
+
const value = cookieHeader.match(/* @__PURE__ */ new RegExp(`(?:^|;\\s*)${name}=([^;]*)`))?.[1];
|
|
29
|
+
return value !== void 0 ? decodeURIComponent(value.trim()) : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.deleteCookie = deleteCookie;
|
|
34
|
+
exports.getCookieFromHeader = getCookieFromHeader;
|
|
35
|
+
exports.getCookieValue = getCookieValue;
|
|
36
|
+
exports.setCookie = setCookie;
|
|
37
|
+
//# sourceMappingURL=_cookie-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_cookie-utils.cjs","names":[],"sources":["../../../src/theme/cookie/_cookie-utils.ts"],"sourcesContent":["/**\n * Internal cookie utilities for theme cookie storage.\n * Cookie Store API has limited support; document.cookie is standard for theme persistence.\n */\n\nexport function getCookieValue(name: string): string | null {\n\tif (typeof document === 'undefined' || !document.cookie) return null\n\tconst match = document.cookie.match(new RegExp(`(?:^|;\\\\s*)${name}=([^;]*)`))\n\tconst value = match?.[1]\n\treturn value !== undefined ? decodeURIComponent(value) : null\n}\n\nexport function setCookie(\n\tname: string,\n\tvalue: string,\n\toptions: {\n\t\tpath?: string | undefined\n\t\tmaxAge?: number | undefined\n\t\tsameSite?: 'lax' | 'strict' | 'none' | undefined\n\t\tsecure?: boolean | undefined\n\t}\n) {\n\tconst parts = [`${name}=${encodeURIComponent(value)}`]\n\tparts.push(`path=${options.path ?? '/'}`)\n\tif (options.maxAge !== undefined) parts.push(`max-age=${options.maxAge}`)\n\tif (options.sameSite !== undefined) parts.push(`samesite=${options.sameSite}`)\n\tif (options.secure) parts.push('secure')\n\t// biome-ignore lint/suspicious/noDocumentCookie: Cookie Store API has limited support; document.cookie is standard for theme persistence\n\tdocument.cookie = parts.join('; ')\n}\n\nexport function deleteCookie(name: string, path = '/') {\n\t// biome-ignore lint/suspicious/noDocumentCookie: Cookie Store API has limited support; document.cookie is standard for theme persistence\n\tdocument.cookie = `${name}=; path=${path}; max-age=0`\n}\n\n/**\n * Parses a cookie value from a raw Cookie header string.\n * Used for SSR when reading from request headers or framework cookie APIs.\n */\nexport function getCookieFromHeader(cookieHeader: string, name: string): string | null {\n\tconst match = cookieHeader.match(new RegExp(`(?:^|;\\\\s*)${name}=([^;]*)`))\n\tconst value = match?.[1]\n\treturn value !== undefined ? decodeURIComponent(value.trim()) : null\n}\n"],"mappings":";;;;;;AAKA,SAAgB,eAAe,MAA6B;AAC3D,KAAI,OAAO,aAAa,eAAe,CAAC,SAAS,OAAQ,QAAO;CAEhE,MAAM,QADQ,SAAS,OAAO,sBAAM,IAAI,OAAO,cAAc,KAAK,UAAU,CAAC,GACvD;AACtB,QAAO,UAAU,SAAY,mBAAmB,MAAM,GAAG;;AAG1D,SAAgB,UACf,MACA,OACA,SAMC;CACD,MAAM,QAAQ,CAAC,GAAG,KAAK,GAAG,mBAAmB,MAAM,GAAG;AACtD,OAAM,KAAK,QAAQ,QAAQ,QAAQ,MAAM;AACzC,KAAI,QAAQ,WAAW,OAAW,OAAM,KAAK,WAAW,QAAQ,SAAS;AACzE,KAAI,QAAQ,aAAa,OAAW,OAAM,KAAK,YAAY,QAAQ,WAAW;AAC9E,KAAI,QAAQ,OAAQ,OAAM,KAAK,SAAS;AAExC,UAAS,SAAS,MAAM,KAAK,KAAK;;AAGnC,SAAgB,aAAa,MAAc,OAAO,KAAK;AAEtD,UAAS,SAAS,GAAG,KAAK,UAAU,KAAK;;;;;;AAO1C,SAAgB,oBAAoB,cAAsB,MAA6B;CAEtF,MAAM,QADQ,aAAa,sBAAM,IAAI,OAAO,cAAc,KAAK,UAAU,CAAC,GACpD;AACtB,QAAO,UAAU,SAAY,mBAAmB,MAAM,MAAM,CAAC,GAAG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/theme/cookie/_cookie-utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Internal cookie utilities for theme cookie storage.
|
|
4
|
+
* Cookie Store API has limited support; document.cookie is standard for theme persistence.
|
|
5
|
+
*/
|
|
6
|
+
function getCookieValue(name) {
|
|
7
|
+
if (typeof document === "undefined" || !document.cookie) return null;
|
|
8
|
+
const value = document.cookie.match(/* @__PURE__ */ new RegExp(`(?:^|;\\s*)${name}=([^;]*)`))?.[1];
|
|
9
|
+
return value !== void 0 ? decodeURIComponent(value) : null;
|
|
10
|
+
}
|
|
11
|
+
function setCookie(name, value, options) {
|
|
12
|
+
const parts = [`${name}=${encodeURIComponent(value)}`];
|
|
13
|
+
parts.push(`path=${options.path ?? "/"}`);
|
|
14
|
+
if (options.maxAge !== void 0) parts.push(`max-age=${options.maxAge}`);
|
|
15
|
+
if (options.sameSite !== void 0) parts.push(`samesite=${options.sameSite}`);
|
|
16
|
+
if (options.secure) parts.push("secure");
|
|
17
|
+
document.cookie = parts.join("; ");
|
|
18
|
+
}
|
|
19
|
+
function deleteCookie(name, path = "/") {
|
|
20
|
+
document.cookie = `${name}=; path=${path}; max-age=0`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parses a cookie value from a raw Cookie header string.
|
|
24
|
+
* Used for SSR when reading from request headers or framework cookie APIs.
|
|
25
|
+
*/
|
|
26
|
+
function getCookieFromHeader(cookieHeader, name) {
|
|
27
|
+
const value = cookieHeader.match(/* @__PURE__ */ new RegExp(`(?:^|;\\s*)${name}=([^;]*)`))?.[1];
|
|
28
|
+
return value !== void 0 ? decodeURIComponent(value.trim()) : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { deleteCookie, getCookieFromHeader, getCookieValue, setCookie };
|
|
33
|
+
//# sourceMappingURL=_cookie-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_cookie-utils.mjs","names":[],"sources":["../../../src/theme/cookie/_cookie-utils.ts"],"sourcesContent":["/**\n * Internal cookie utilities for theme cookie storage.\n * Cookie Store API has limited support; document.cookie is standard for theme persistence.\n */\n\nexport function getCookieValue(name: string): string | null {\n\tif (typeof document === 'undefined' || !document.cookie) return null\n\tconst match = document.cookie.match(new RegExp(`(?:^|;\\\\s*)${name}=([^;]*)`))\n\tconst value = match?.[1]\n\treturn value !== undefined ? decodeURIComponent(value) : null\n}\n\nexport function setCookie(\n\tname: string,\n\tvalue: string,\n\toptions: {\n\t\tpath?: string | undefined\n\t\tmaxAge?: number | undefined\n\t\tsameSite?: 'lax' | 'strict' | 'none' | undefined\n\t\tsecure?: boolean | undefined\n\t}\n) {\n\tconst parts = [`${name}=${encodeURIComponent(value)}`]\n\tparts.push(`path=${options.path ?? '/'}`)\n\tif (options.maxAge !== undefined) parts.push(`max-age=${options.maxAge}`)\n\tif (options.sameSite !== undefined) parts.push(`samesite=${options.sameSite}`)\n\tif (options.secure) parts.push('secure')\n\t// biome-ignore lint/suspicious/noDocumentCookie: Cookie Store API has limited support; document.cookie is standard for theme persistence\n\tdocument.cookie = parts.join('; ')\n}\n\nexport function deleteCookie(name: string, path = '/') {\n\t// biome-ignore lint/suspicious/noDocumentCookie: Cookie Store API has limited support; document.cookie is standard for theme persistence\n\tdocument.cookie = `${name}=; path=${path}; max-age=0`\n}\n\n/**\n * Parses a cookie value from a raw Cookie header string.\n * Used for SSR when reading from request headers or framework cookie APIs.\n */\nexport function getCookieFromHeader(cookieHeader: string, name: string): string | null {\n\tconst match = cookieHeader.match(new RegExp(`(?:^|;\\\\s*)${name}=([^;]*)`))\n\tconst value = match?.[1]\n\treturn value !== undefined ? decodeURIComponent(value.trim()) : null\n}\n"],"mappings":";;;;;AAKA,SAAgB,eAAe,MAA6B;AAC3D,KAAI,OAAO,aAAa,eAAe,CAAC,SAAS,OAAQ,QAAO;CAEhE,MAAM,QADQ,SAAS,OAAO,sBAAM,IAAI,OAAO,cAAc,KAAK,UAAU,CAAC,GACvD;AACtB,QAAO,UAAU,SAAY,mBAAmB,MAAM,GAAG;;AAG1D,SAAgB,UACf,MACA,OACA,SAMC;CACD,MAAM,QAAQ,CAAC,GAAG,KAAK,GAAG,mBAAmB,MAAM,GAAG;AACtD,OAAM,KAAK,QAAQ,QAAQ,QAAQ,MAAM;AACzC,KAAI,QAAQ,WAAW,OAAW,OAAM,KAAK,WAAW,QAAQ,SAAS;AACzE,KAAI,QAAQ,aAAa,OAAW,OAAM,KAAK,YAAY,QAAQ,WAAW;AAC9E,KAAI,QAAQ,OAAQ,OAAM,KAAK,SAAS;AAExC,UAAS,SAAS,MAAM,KAAK,KAAK;;AAGnC,SAAgB,aAAa,MAAc,OAAO,KAAK;AAEtD,UAAS,SAAS,GAAG,KAAK,UAAU,KAAK;;;;;;AAO1C,SAAgB,oBAAoB,cAAsB,MAA6B;CAEtF,MAAM,QADQ,aAAa,sBAAM,IAAI,OAAO,cAAc,KAAK,UAAU,CAAC,GACpD;AACtB,QAAO,UAAU,SAAY,mBAAmB,MAAM,MAAM,CAAC,GAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_parse_stored_theme = require('../_utils/parse-stored-theme.cjs');
|
|
2
|
+
const require__cookie_utils = require('./_cookie-utils.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/theme/cookie/read-cookie-theme.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads a theme entry from a cookie.
|
|
7
|
+
*
|
|
8
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
9
|
+
* @param options.cookieName - Cookie name to read from
|
|
10
|
+
* @param options.path - Cookie path (default: '/')
|
|
11
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
12
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when document.cookie is unavailable (e.g. SSR).
|
|
13
|
+
*/
|
|
14
|
+
function readCookieTheme(themes, options) {
|
|
15
|
+
const { cookieName, parse = require_parse_stored_theme.parseStoredTheme } = options;
|
|
16
|
+
if (typeof document === "undefined" || document.cookie === void 0) return;
|
|
17
|
+
return parse(themes, require__cookie_utils.getCookieValue(cookieName) ?? void 0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.readCookieTheme = readCookieTheme;
|
|
22
|
+
//# sourceMappingURL=read-cookie-theme.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-cookie-theme.cjs","names":["parseStoredTheme","getCookieValue"],"sources":["../../../src/theme/cookie/read-cookie-theme.ts"],"sourcesContent":["import { parseStoredTheme } from '../_utils/parse-stored-theme.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { getCookieValue } from './_cookie-utils.ts'\n\nexport interface ReadCookieThemeOptions<Themes extends ThemeMap = ThemeMap> {\n\tcookieName: string\n\tpath?: string | undefined\n\tparse?: ParseStoredTheme<Themes> | undefined\n}\n\n/**\n * Reads a theme entry from a cookie.\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param options.cookieName - Cookie name to read from\n * @param options.path - Cookie path (default: '/')\n * @param options.parse - Custom parser (default: parseStoredTheme)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when document.cookie is unavailable (e.g. SSR).\n */\nexport function readCookieTheme<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: ReadCookieThemeOptions<Themes>\n): ThemeEntry<Themes> | undefined {\n\tconst { cookieName, parse = parseStoredTheme } = options\n\n\tif (typeof document === 'undefined' || document.cookie === undefined) {\n\t\treturn undefined\n\t}\n\n\tconst stored = getCookieValue(cookieName)\n\treturn parse(themes, stored ?? undefined)\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,SAAgB,gBACf,QACA,SACiC;CACjC,MAAM,EAAE,YAAY,QAAQA,gDAAqB;AAEjD,KAAI,OAAO,aAAa,eAAe,SAAS,WAAW,OAC1D;AAID,QAAO,MAAM,QADEC,qCAAe,WAAW,IACV,OAAU"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/cookie/read-cookie-theme.d.ts
|
|
5
|
+
interface ReadCookieThemeOptions<Themes extends ThemeMap = ThemeMap> {
|
|
6
|
+
cookieName: string;
|
|
7
|
+
path?: string | undefined;
|
|
8
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Reads a theme entry from a cookie.
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
14
|
+
* @param options.cookieName - Cookie name to read from
|
|
15
|
+
* @param options.path - Cookie path (default: '/')
|
|
16
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
17
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when document.cookie is unavailable (e.g. SSR).
|
|
18
|
+
*/
|
|
19
|
+
declare function readCookieTheme<Themes extends ThemeMap>(themes: Themes, options: ReadCookieThemeOptions<Themes>): ThemeEntry<Themes> | undefined;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ReadCookieThemeOptions, readCookieTheme };
|
|
22
|
+
//# sourceMappingURL=read-cookie-theme.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-cookie-theme.d.cts","names":[],"sources":["../../../src/theme/cookie/read-cookie-theme.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,sCAAsC,WAAW;;EAAjD,IAAA,CAAA,EAAA,MAAA,GAAA,SAAsB;EAAgB,KAAA,CAAA,EAG9C,gBAH8C,CAG7B,MAH6B,CAAA,GAAA,SAAA;;;;;AAevD;;;;;;AAGG,iBAHa,eAGb,CAAA,eAH4C,QAG5C,CAAA,CAAA,MAAA,EAFM,MAEN,EAAA,OAAA,EADO,sBACP,CAD8B,MAC9B,CAAA,CAAA,EAAA,UAAA,CAAW,MAAX,CAAA,GAAA,SAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/cookie/read-cookie-theme.d.ts
|
|
5
|
+
interface ReadCookieThemeOptions<Themes extends ThemeMap = ThemeMap> {
|
|
6
|
+
cookieName: string;
|
|
7
|
+
path?: string | undefined;
|
|
8
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Reads a theme entry from a cookie.
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
14
|
+
* @param options.cookieName - Cookie name to read from
|
|
15
|
+
* @param options.path - Cookie path (default: '/')
|
|
16
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
17
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when document.cookie is unavailable (e.g. SSR).
|
|
18
|
+
*/
|
|
19
|
+
declare function readCookieTheme<Themes extends ThemeMap>(themes: Themes, options: ReadCookieThemeOptions<Themes>): ThemeEntry<Themes> | undefined;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ReadCookieThemeOptions, readCookieTheme };
|
|
22
|
+
//# sourceMappingURL=read-cookie-theme.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-cookie-theme.d.mts","names":[],"sources":["../../../src/theme/cookie/read-cookie-theme.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,sCAAsC,WAAW;;EAAjD,IAAA,CAAA,EAAA,MAAA,GAAA,SAAsB;EAAgB,KAAA,CAAA,EAG9C,gBAH8C,CAG7B,MAH6B,CAAA,GAAA,SAAA;;;;;AAevD;;;;;;AAGG,iBAHa,eAGb,CAAA,eAH4C,QAG5C,CAAA,CAAA,MAAA,EAFM,MAEN,EAAA,OAAA,EADO,sBACP,CAD8B,MAC9B,CAAA,CAAA,EAAA,UAAA,CAAW,MAAX,CAAA,GAAA,SAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parseStoredTheme } from "../_utils/parse-stored-theme.mjs";
|
|
2
|
+
import { getCookieValue } from "./_cookie-utils.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/cookie/read-cookie-theme.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads a theme entry from a cookie.
|
|
7
|
+
*
|
|
8
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
9
|
+
* @param options.cookieName - Cookie name to read from
|
|
10
|
+
* @param options.path - Cookie path (default: '/')
|
|
11
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
12
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when document.cookie is unavailable (e.g. SSR).
|
|
13
|
+
*/
|
|
14
|
+
function readCookieTheme(themes, options) {
|
|
15
|
+
const { cookieName, parse = parseStoredTheme } = options;
|
|
16
|
+
if (typeof document === "undefined" || document.cookie === void 0) return;
|
|
17
|
+
return parse(themes, getCookieValue(cookieName) ?? void 0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { readCookieTheme };
|
|
22
|
+
//# sourceMappingURL=read-cookie-theme.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-cookie-theme.mjs","names":[],"sources":["../../../src/theme/cookie/read-cookie-theme.ts"],"sourcesContent":["import { parseStoredTheme } from '../_utils/parse-stored-theme.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { getCookieValue } from './_cookie-utils.ts'\n\nexport interface ReadCookieThemeOptions<Themes extends ThemeMap = ThemeMap> {\n\tcookieName: string\n\tpath?: string | undefined\n\tparse?: ParseStoredTheme<Themes> | undefined\n}\n\n/**\n * Reads a theme entry from a cookie.\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param options.cookieName - Cookie name to read from\n * @param options.path - Cookie path (default: '/')\n * @param options.parse - Custom parser (default: parseStoredTheme)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when document.cookie is unavailable (e.g. SSR).\n */\nexport function readCookieTheme<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: ReadCookieThemeOptions<Themes>\n): ThemeEntry<Themes> | undefined {\n\tconst { cookieName, parse = parseStoredTheme } = options\n\n\tif (typeof document === 'undefined' || document.cookie === undefined) {\n\t\treturn undefined\n\t}\n\n\tconst stored = getCookieValue(cookieName)\n\treturn parse(themes, stored ?? undefined)\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,SAAgB,gBACf,QACA,SACiC;CACjC,MAAM,EAAE,YAAY,QAAQ,qBAAqB;AAEjD,KAAI,OAAO,aAAa,eAAe,SAAS,WAAW,OAC1D;AAID,QAAO,MAAM,QADE,eAAe,WAAW,IACV,OAAU"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const require__cookie_utils = require('./_cookie-utils.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/theme/cookie/write-cookie-theme.ts
|
|
4
|
+
/**
|
|
5
|
+
* Writes a theme entry to a cookie.
|
|
6
|
+
*
|
|
7
|
+
* Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to values (used for type validation)
|
|
10
|
+
* @param entry - Theme entry to write, or undefined to remove
|
|
11
|
+
* @param options - Cookie options
|
|
12
|
+
*/
|
|
13
|
+
function writeCookieTheme(_themes, entry, options) {
|
|
14
|
+
const { cookieName, path = "/", maxAge, sameSite, secure } = options;
|
|
15
|
+
if (typeof document === "undefined" || document.cookie === void 0) return;
|
|
16
|
+
if (entry === void 0) {
|
|
17
|
+
require__cookie_utils.deleteCookie(cookieName, path);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const opts = { path };
|
|
21
|
+
if (maxAge !== void 0) opts.maxAge = maxAge;
|
|
22
|
+
if (sameSite !== void 0) opts.sameSite = sameSite;
|
|
23
|
+
if (secure) opts.secure = true;
|
|
24
|
+
require__cookie_utils.setCookie(cookieName, JSON.stringify(entry), opts);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.writeCookieTheme = writeCookieTheme;
|
|
29
|
+
//# sourceMappingURL=write-cookie-theme.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-cookie-theme.cjs","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 === undefined) {\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,UAAU,QAAW;AACxB,qCAAa,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,iCAAU,YAAY,KAAK,UAAU,MAAM,EAAE,KAAK"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/cookie/write-cookie-theme.d.ts
|
|
5
|
+
interface WriteCookieThemeOptions<_Themes extends ThemeMap = ThemeMap> {
|
|
6
|
+
cookieName: string;
|
|
7
|
+
path?: string | undefined;
|
|
8
|
+
maxAge?: number | undefined;
|
|
9
|
+
sameSite?: 'lax' | 'strict' | 'none' | undefined;
|
|
10
|
+
secure?: boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Writes a theme entry to a cookie.
|
|
14
|
+
*
|
|
15
|
+
* Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.
|
|
16
|
+
*
|
|
17
|
+
* @param themes - Record mapping theme keys to values (used for type validation)
|
|
18
|
+
* @param entry - Theme entry to write, or undefined to remove
|
|
19
|
+
* @param options - Cookie options
|
|
20
|
+
*/
|
|
21
|
+
declare function writeCookieTheme<Themes extends ThemeMap>(_themes: Themes, entry: ThemeEntry<Themes> | undefined, options: WriteCookieThemeOptions<Themes>): void;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { WriteCookieThemeOptions, writeCookieTheme };
|
|
24
|
+
//# sourceMappingURL=write-cookie-theme.d.cts.map
|
|
@@ -0,0 +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,8BACT,wBAAwB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/cookie/write-cookie-theme.d.ts
|
|
5
|
+
interface WriteCookieThemeOptions<_Themes extends ThemeMap = ThemeMap> {
|
|
6
|
+
cookieName: string;
|
|
7
|
+
path?: string | undefined;
|
|
8
|
+
maxAge?: number | undefined;
|
|
9
|
+
sameSite?: 'lax' | 'strict' | 'none' | undefined;
|
|
10
|
+
secure?: boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Writes a theme entry to a cookie.
|
|
14
|
+
*
|
|
15
|
+
* Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.
|
|
16
|
+
*
|
|
17
|
+
* @param themes - Record mapping theme keys to values (used for type validation)
|
|
18
|
+
* @param entry - Theme entry to write, or undefined to remove
|
|
19
|
+
* @param options - Cookie options
|
|
20
|
+
*/
|
|
21
|
+
declare function writeCookieTheme<Themes extends ThemeMap>(_themes: Themes, entry: ThemeEntry<Themes> | undefined, options: WriteCookieThemeOptions<Themes>): void;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { WriteCookieThemeOptions, writeCookieTheme };
|
|
24
|
+
//# sourceMappingURL=write-cookie-theme.d.mts.map
|
|
@@ -0,0 +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,8BACT,wBAAwB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { deleteCookie, setCookie } from "./_cookie-utils.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/theme/cookie/write-cookie-theme.ts
|
|
4
|
+
/**
|
|
5
|
+
* Writes a theme entry to a cookie.
|
|
6
|
+
*
|
|
7
|
+
* Performs cookie set/delete only. Does not notify subscribers; the store must call notify() after this.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to values (used for type validation)
|
|
10
|
+
* @param entry - Theme entry to write, or undefined to remove
|
|
11
|
+
* @param options - Cookie options
|
|
12
|
+
*/
|
|
13
|
+
function writeCookieTheme(_themes, entry, options) {
|
|
14
|
+
const { cookieName, path = "/", maxAge, sameSite, secure } = options;
|
|
15
|
+
if (typeof document === "undefined" || document.cookie === void 0) return;
|
|
16
|
+
if (entry === void 0) {
|
|
17
|
+
deleteCookie(cookieName, path);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const opts = { path };
|
|
21
|
+
if (maxAge !== void 0) opts.maxAge = maxAge;
|
|
22
|
+
if (sameSite !== void 0) opts.sameSite = sameSite;
|
|
23
|
+
if (secure) opts.secure = true;
|
|
24
|
+
setCookie(cookieName, JSON.stringify(entry), opts);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { writeCookieTheme };
|
|
29
|
+
//# sourceMappingURL=write-cookie-theme.mjs.map
|
|
@@ -0,0 +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 === undefined) {\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,UAAU,QAAW;AACxB,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_constant.cjs","names":[],"sources":["../../../src/theme/data-attribute/_constant.ts"],"sourcesContent":["export const SEPARATOR_SPACE = ' '\n"],"mappings":";;AAAA,MAAa,kBAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_constant.mjs","names":[],"sources":["../../../src/theme/data-attribute/_constant.ts"],"sourcesContent":["export const SEPARATOR_SPACE = ' '\n"],"mappings":";AAAA,MAAa,kBAAkB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_theme_entry = require('../theme-entry.cjs');
|
|
2
|
+
const require__constant = require('./_constant.cjs');
|
|
3
|
+
const require_match_attribute_value_to_theme = require('../_utils/match-attribute-value-to-theme.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/theme/data-attribute/parse-data-attribute.ts
|
|
6
|
+
/**
|
|
7
|
+
* Parses a data attribute value string into a ThemeEntry.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
|
+
*
|
|
11
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
13
|
+
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
|
+
*/
|
|
16
|
+
function parseDataAttribute(themes, value, options) {
|
|
17
|
+
const separator = options?.separator ?? require__constant.SEPARATOR_SPACE;
|
|
18
|
+
const theme = require_match_attribute_value_to_theme.matchAttributeValueToTheme(themes, value ?? null, { separator });
|
|
19
|
+
return theme !== void 0 ? require_theme_entry.themeEntry(themes, theme) : void 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.parseDataAttribute = parseDataAttribute;
|
|
24
|
+
//# sourceMappingURL=parse-data-attribute.cjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/data-attribute/parse-data-attribute.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parses a data attribute value string into a ThemeEntry.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
|
+
*
|
|
11
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
13
|
+
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
|
+
*/
|
|
16
|
+
declare function parseDataAttribute<Themes extends ThemeMap>(themes: Themes, value: string | undefined, options?: {
|
|
17
|
+
separator?: string | undefined;
|
|
18
|
+
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { parseDataAttribute };
|
|
21
|
+
//# sourceMappingURL=parse-data-attribute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/parse-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;iBAAgB,kCAAkC,kBACzC;;gBAGN,WAAW"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/data-attribute/parse-data-attribute.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parses a data attribute value string into a ThemeEntry.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
|
+
*
|
|
11
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
13
|
+
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
|
+
*/
|
|
16
|
+
declare function parseDataAttribute<Themes extends ThemeMap>(themes: Themes, value: string | undefined, options?: {
|
|
17
|
+
separator?: string | undefined;
|
|
18
|
+
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { parseDataAttribute };
|
|
21
|
+
//# sourceMappingURL=parse-data-attribute.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/parse-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;iBAAgB,kCAAkC,kBACzC;;gBAGN,WAAW"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { themeEntry } from "../theme-entry.mjs";
|
|
2
|
+
import { SEPARATOR_SPACE } from "./_constant.mjs";
|
|
3
|
+
import { matchAttributeValueToTheme } from "../_utils/match-attribute-value-to-theme.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/theme/data-attribute/parse-data-attribute.ts
|
|
6
|
+
/**
|
|
7
|
+
* Parses a data attribute value string into a ThemeEntry.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Uses first token when separator is defined.
|
|
10
|
+
*
|
|
11
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
12
|
+
* @param value - Raw attribute value string (e.g. from getAttribute)
|
|
13
|
+
* @param options.separator - When defined, split by separator and use first token (default: space)
|
|
14
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
15
|
+
*/
|
|
16
|
+
function parseDataAttribute(themes, value, options) {
|
|
17
|
+
const separator = options?.separator ?? SEPARATOR_SPACE;
|
|
18
|
+
const theme = matchAttributeValueToTheme(themes, value ?? null, { separator });
|
|
19
|
+
return theme !== void 0 ? themeEntry(themes, theme) : void 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { parseDataAttribute };
|
|
24
|
+
//# sourceMappingURL=parse-data-attribute.mjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_get_data_attribute = require('../../attributes/get-data-attribute.cjs');
|
|
2
|
+
const require__constant = require('./_constant.cjs');
|
|
3
|
+
const require_parse_data_attribute = require('./parse-data-attribute.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/theme/data-attribute/read-data-attribute.ts
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from a data attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
10
|
+
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
function readDataAttribute(themes, attributeName, options) {
|
|
16
|
+
const element = options?.element ?? document?.documentElement;
|
|
17
|
+
if (!element) return void 0;
|
|
18
|
+
return (options?.parse ?? ((t, v) => require_parse_data_attribute.parseDataAttribute(t, v, { separator: require__constant.SEPARATOR_SPACE })))(themes, require_get_data_attribute.getDataAttribute(attributeName, element) ?? void 0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.readDataAttribute = readDataAttribute;
|
|
23
|
+
//# sourceMappingURL=read-data-attribute.cjs.map
|
|
@@ -0,0 +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 (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 | 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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/data-attribute/read-data-attribute.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from a data attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
10
|
+
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
declare function readDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, options?: {
|
|
16
|
+
element?: Element | undefined;
|
|
17
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
|
+
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { readDataAttribute };
|
|
21
|
+
//# sourceMappingURL=read-data-attribute.d.cts.map
|
|
@@ -0,0 +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;UAFgC,iBAAiB;gBAE3D,WAAW"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/data-attribute/read-data-attribute.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from a data attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
10
|
+
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
declare function readDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, options?: {
|
|
16
|
+
element?: Element | undefined;
|
|
17
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
|
+
} | undefined): ThemeEntry<Themes> | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { readDataAttribute };
|
|
21
|
+
//# sourceMappingURL=read-data-attribute.d.mts.map
|
|
@@ -0,0 +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;UAFgC,iBAAiB;gBAE3D,WAAW"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getDataAttribute } from "../../attributes/get-data-attribute.mjs";
|
|
2
|
+
import { SEPARATOR_SPACE } from "./_constant.mjs";
|
|
3
|
+
import { parseDataAttribute } from "./parse-data-attribute.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/theme/data-attribute/read-data-attribute.ts
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from a data attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to attribute values
|
|
10
|
+
* @param attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseDataAttribute with space separator)
|
|
13
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
function readDataAttribute(themes, attributeName, options) {
|
|
16
|
+
const element = options?.element ?? document?.documentElement;
|
|
17
|
+
if (!element) return void 0;
|
|
18
|
+
return (options?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE })))(themes, getDataAttribute(attributeName, element) ?? void 0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { readDataAttribute };
|
|
23
|
+
//# sourceMappingURL=read-data-attribute.mjs.map
|
|
@@ -0,0 +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 (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 | 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"}
|