@just-web/toolkits 1.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 +2 -6
- 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.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.d.mts +2 -2
- package/dist/react/hooks/use-theme-by-class-name.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.mjs +2 -6
- package/dist/react/hooks/use-theme-by-class-name.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.cjs +2 -7
- 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.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts +2 -2
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.mjs +2 -7
- 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/react/theme/create-theme-hook.cjs.map +1 -1
- package/dist/react/theme/create-theme-hook.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/_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 +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/compose-theme-stores.cjs.map +1 -1
- package/dist/theme/compose-theme-stores.mjs.map +1 -1
- 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 +13 -1
- package/dist/theme/theme-entry.types.d.cts.map +1 -1
- package/dist/theme/theme-entry.types.d.mts +13 -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/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 +22 -19
- 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 +7 -2
- 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 +7 -2
- 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 +22 -19
- 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 +40 -20
- 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 +30 -7
- 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 +30 -7
- 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 +40 -20
- 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.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 +8 -2
- 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 +8 -2
- 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 +8 -2
- 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 +8 -2
- 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/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/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/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 +5 -10
- package/src/react/hooks/use-theme-by-data-attribute.ts +5 -12
- package/src/react/hooks/use-theme-by-local-storage.ts +3 -9
- package/src/react/theme/create-theme-hook.ts +4 -6
- 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 +51 -11
- package/src/theme/_utils/resolve-theme-map-value.ts +15 -0
- package/src/theme/_utils/set-theme-to-stores.ts +3 -3
- 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/compose-theme-stores.ts +1 -1
- 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 +21 -0
- package/src/theme/theme-map.types.ts +9 -2
- 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 +20 -26
- 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 +42 -29
- package/src/theme/theme-store/in-memory-theme-store/in-memory-theme-store.ts +1 -1
- 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/theme-store/theme-store.types.ts +1 -3
- 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/src/utils/append-id.ts +3 -3
- 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
package/dist/theme.cjs
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
const require_theme_entry = require('./theme/theme-entry.cjs');
|
|
2
|
+
const require_parse_class_name = require('./theme/class-name/parse-class-name.cjs');
|
|
3
|
+
const require_read_class_name = require('./theme/class-name/read-class-name.cjs');
|
|
4
|
+
const require_stringify_class_name = require('./theme/class-name/stringify-class-name.cjs');
|
|
5
|
+
const require_subscribe_class_name = require('./theme/class-name/subscribe-class-name.cjs');
|
|
6
|
+
const require_write_class_name = require('./theme/class-name/write-class-name.cjs');
|
|
2
7
|
const require_class_name_theme_store = require('./theme/theme-store/class-name-theme-store/class-name-theme-store.cjs');
|
|
8
|
+
const require_parse_data_attribute = require('./theme/data-attribute/parse-data-attribute.cjs');
|
|
9
|
+
const require_read_data_attribute = require('./theme/data-attribute/read-data-attribute.cjs');
|
|
10
|
+
const require_stringify_data_attribute = require('./theme/data-attribute/stringify-data-attribute.cjs');
|
|
11
|
+
const require_subscribe_data_attribute = require('./theme/data-attribute/subscribe-data-attribute.cjs');
|
|
12
|
+
const require_write_data_attribute = require('./theme/data-attribute/write-data-attribute.cjs');
|
|
3
13
|
const require_data_attribute_theme_store = require('./theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs');
|
|
14
|
+
const require_read_web_storage = require('./theme/web-storage/read-web-storage.cjs');
|
|
15
|
+
const require_read_local_storage = require('./theme/local-storage/read-local-storage.cjs');
|
|
16
|
+
const require_write_web_storage = require('./theme/web-storage/write-web-storage.cjs');
|
|
17
|
+
const require_write_local_storage = require('./theme/local-storage/write-local-storage.cjs');
|
|
4
18
|
const require_local_storage_theme_store = require('./theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs');
|
|
5
19
|
const require_compose_theme_stores = require('./theme/compose-theme-stores.cjs');
|
|
20
|
+
const require_read_cookie_theme = require('./theme/cookie/read-cookie-theme.cjs');
|
|
21
|
+
const require_write_cookie_theme = require('./theme/cookie/write-cookie-theme.cjs');
|
|
22
|
+
const require_read_prefers_color_scheme_theme = require('./theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs');
|
|
23
|
+
const require_subscribe_prefers_color_scheme_theme = require('./theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs');
|
|
24
|
+
const require_read_session_storage = require('./theme/session-storage/read-session-storage.cjs');
|
|
25
|
+
const require_write_session_storage = require('./theme/session-storage/write-session-storage.cjs');
|
|
6
26
|
const require_cookie_theme_store = require('./theme/theme-store/cookie-theme-store/cookie-theme-store.cjs');
|
|
7
27
|
const require_in_memory_theme_store = require('./theme/theme-store/in-memory-theme-store/in-memory-theme-store.cjs');
|
|
8
28
|
const require_prefers_color_scheme_theme_store = require('./theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs');
|
|
@@ -15,6 +35,26 @@ exports.dataAttributeThemeStore = require_data_attribute_theme_store.dataAttribu
|
|
|
15
35
|
exports.getThemeFromCookie = require_cookie_theme_store.getThemeFromCookie;
|
|
16
36
|
exports.inMemoryThemeStore = require_in_memory_theme_store.inMemoryThemeStore;
|
|
17
37
|
exports.localStorageThemeStore = require_local_storage_theme_store.localStorageThemeStore;
|
|
38
|
+
exports.parseClassName = require_parse_class_name.parseClassName;
|
|
39
|
+
exports.parseDataAttribute = require_parse_data_attribute.parseDataAttribute;
|
|
18
40
|
exports.prefersColorSchemeThemeStore = require_prefers_color_scheme_theme_store.prefersColorSchemeThemeStore;
|
|
41
|
+
exports.readClassName = require_read_class_name.readClassName;
|
|
42
|
+
exports.readCookieTheme = require_read_cookie_theme.readCookieTheme;
|
|
43
|
+
exports.readDataAttribute = require_read_data_attribute.readDataAttribute;
|
|
44
|
+
exports.readLocalStorage = require_read_local_storage.readLocalStorage;
|
|
45
|
+
exports.readPrefersColorSchemeTheme = require_read_prefers_color_scheme_theme.readPrefersColorSchemeTheme;
|
|
46
|
+
exports.readSessionStorage = require_read_session_storage.readSessionStorage;
|
|
47
|
+
exports.readWebStorage = require_read_web_storage.readWebStorage;
|
|
19
48
|
exports.sessionStorageThemeStore = require_session_storage_theme_store.sessionStorageThemeStore;
|
|
20
|
-
exports.
|
|
49
|
+
exports.stringifyClassName = require_stringify_class_name.stringifyClassName;
|
|
50
|
+
exports.stringifyDataAttribute = require_stringify_data_attribute.stringifyDataAttribute;
|
|
51
|
+
exports.subscribeClassName = require_subscribe_class_name.subscribeClassName;
|
|
52
|
+
exports.subscribeDataAttribute = require_subscribe_data_attribute.subscribeDataAttribute;
|
|
53
|
+
exports.subscribePrefersColorSchemeTheme = require_subscribe_prefers_color_scheme_theme.subscribePrefersColorSchemeTheme;
|
|
54
|
+
exports.themeEntry = require_theme_entry.themeEntry;
|
|
55
|
+
exports.writeClassName = require_write_class_name.writeClassName;
|
|
56
|
+
exports.writeCookieTheme = require_write_cookie_theme.writeCookieTheme;
|
|
57
|
+
exports.writeDataAttribute = require_write_data_attribute.writeDataAttribute;
|
|
58
|
+
exports.writeLocalStorage = require_write_local_storage.writeLocalStorage;
|
|
59
|
+
exports.writeSessionStorage = require_write_session_storage.writeSessionStorage;
|
|
60
|
+
exports.writeWebStorage = require_write_web_storage.writeWebStorage;
|
package/dist/theme.d.cts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { ThemeMap } from "./theme/theme-map.types.cjs";
|
|
2
|
-
import { ThemeEntry } from "./theme/theme-entry.types.cjs";
|
|
1
|
+
import { ThemeMap, ThemeMapValue } from "./theme/theme-map.types.cjs";
|
|
2
|
+
import { ParseStoredTheme, StringifyStoredTheme, ThemeEntry } from "./theme/theme-entry.types.cjs";
|
|
3
3
|
import { AsyncThemeStore } from "./theme/theme-store/async-theme-store.types.cjs";
|
|
4
4
|
import { ThemeStore } from "./theme/theme-store/theme-store.types.cjs";
|
|
5
5
|
import { ThemeStoreFactory } from "./theme/theme-store/theme-store-factory.types.cjs";
|
|
6
6
|
import { ComposeThemeStoreEntry, ComposeThemeStoresOptions, composeThemeStores } from "./theme/compose-theme-stores.cjs";
|
|
7
|
+
import { parseClassName } from "./theme/class-name/parse-class-name.cjs";
|
|
8
|
+
import { readClassName } from "./theme/class-name/read-class-name.cjs";
|
|
9
|
+
import { stringifyClassName } from "./theme/class-name/stringify-class-name.cjs";
|
|
10
|
+
import { subscribeClassName } from "./theme/class-name/subscribe-class-name.cjs";
|
|
11
|
+
import { writeClassName } from "./theme/class-name/write-class-name.cjs";
|
|
12
|
+
import { ReadCookieThemeOptions, readCookieTheme } from "./theme/cookie/read-cookie-theme.cjs";
|
|
13
|
+
import { WriteCookieThemeOptions, writeCookieTheme } from "./theme/cookie/write-cookie-theme.cjs";
|
|
14
|
+
import { parseDataAttribute } from "./theme/data-attribute/parse-data-attribute.cjs";
|
|
15
|
+
import { readDataAttribute } from "./theme/data-attribute/read-data-attribute.cjs";
|
|
16
|
+
import { stringifyDataAttribute } from "./theme/data-attribute/stringify-data-attribute.cjs";
|
|
17
|
+
import { subscribeDataAttribute } from "./theme/data-attribute/subscribe-data-attribute.cjs";
|
|
18
|
+
import { writeDataAttribute } from "./theme/data-attribute/write-data-attribute.cjs";
|
|
19
|
+
import { readLocalStorage } from "./theme/local-storage/read-local-storage.cjs";
|
|
20
|
+
import { writeLocalStorage } from "./theme/local-storage/write-local-storage.cjs";
|
|
21
|
+
import { ReadPrefersColorSchemeThemeOptions, readPrefersColorSchemeTheme } from "./theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs";
|
|
22
|
+
import { subscribePrefersColorSchemeTheme } from "./theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs";
|
|
23
|
+
import { readSessionStorage } from "./theme/session-storage/read-session-storage.cjs";
|
|
24
|
+
import { writeSessionStorage } from "./theme/session-storage/write-session-storage.cjs";
|
|
7
25
|
import { themeEntry } from "./theme/theme-entry.cjs";
|
|
8
26
|
import { classNameThemeStore } from "./theme/theme-store/class-name-theme-store/class-name-theme-store.cjs";
|
|
9
27
|
import { CookieThemeStoreOptions, cookieThemeStore, getThemeFromCookie } from "./theme/theme-store/cookie-theme-store/cookie-theme-store.cjs";
|
|
@@ -12,4 +30,6 @@ import { inMemoryThemeStore } from "./theme/theme-store/in-memory-theme-store/in
|
|
|
12
30
|
import { localStorageThemeStore } from "./theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs";
|
|
13
31
|
import { prefersColorSchemeThemeStore } from "./theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs";
|
|
14
32
|
import { sessionStorageThemeStore } from "./theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs";
|
|
15
|
-
|
|
33
|
+
import { readWebStorage } from "./theme/web-storage/read-web-storage.cjs";
|
|
34
|
+
import { writeWebStorage } from "./theme/web-storage/write-web-storage.cjs";
|
|
35
|
+
export { AsyncThemeStore, ComposeThemeStoreEntry, ComposeThemeStoresOptions, CookieThemeStoreOptions, ParseStoredTheme, ReadCookieThemeOptions, ReadPrefersColorSchemeThemeOptions, StringifyStoredTheme, ThemeEntry, ThemeMap, ThemeMapValue, ThemeStore, ThemeStoreFactory, WriteCookieThemeOptions, classNameThemeStore, composeThemeStores, cookieThemeStore, dataAttributeThemeStore, getThemeFromCookie, inMemoryThemeStore, localStorageThemeStore, parseClassName, parseDataAttribute, prefersColorSchemeThemeStore, readClassName, readCookieTheme, readDataAttribute, readLocalStorage, readPrefersColorSchemeTheme, readSessionStorage, readWebStorage, sessionStorageThemeStore, stringifyClassName, stringifyDataAttribute, subscribeClassName, subscribeDataAttribute, subscribePrefersColorSchemeTheme, themeEntry, writeClassName, writeCookieTheme, writeDataAttribute, writeLocalStorage, writeSessionStorage, writeWebStorage };
|
package/dist/theme.d.mts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { ThemeMap } from "./theme/theme-map.types.mjs";
|
|
2
|
-
import { ThemeEntry } from "./theme/theme-entry.types.mjs";
|
|
1
|
+
import { ThemeMap, ThemeMapValue } from "./theme/theme-map.types.mjs";
|
|
2
|
+
import { ParseStoredTheme, StringifyStoredTheme, ThemeEntry } from "./theme/theme-entry.types.mjs";
|
|
3
3
|
import { AsyncThemeStore } from "./theme/theme-store/async-theme-store.types.mjs";
|
|
4
4
|
import { ThemeStore } from "./theme/theme-store/theme-store.types.mjs";
|
|
5
5
|
import { ThemeStoreFactory } from "./theme/theme-store/theme-store-factory.types.mjs";
|
|
6
6
|
import { ComposeThemeStoreEntry, ComposeThemeStoresOptions, composeThemeStores } from "./theme/compose-theme-stores.mjs";
|
|
7
|
+
import { parseClassName } from "./theme/class-name/parse-class-name.mjs";
|
|
8
|
+
import { readClassName } from "./theme/class-name/read-class-name.mjs";
|
|
9
|
+
import { stringifyClassName } from "./theme/class-name/stringify-class-name.mjs";
|
|
10
|
+
import { subscribeClassName } from "./theme/class-name/subscribe-class-name.mjs";
|
|
11
|
+
import { writeClassName } from "./theme/class-name/write-class-name.mjs";
|
|
12
|
+
import { ReadCookieThemeOptions, readCookieTheme } from "./theme/cookie/read-cookie-theme.mjs";
|
|
13
|
+
import { WriteCookieThemeOptions, writeCookieTheme } from "./theme/cookie/write-cookie-theme.mjs";
|
|
14
|
+
import { parseDataAttribute } from "./theme/data-attribute/parse-data-attribute.mjs";
|
|
15
|
+
import { readDataAttribute } from "./theme/data-attribute/read-data-attribute.mjs";
|
|
16
|
+
import { stringifyDataAttribute } from "./theme/data-attribute/stringify-data-attribute.mjs";
|
|
17
|
+
import { subscribeDataAttribute } from "./theme/data-attribute/subscribe-data-attribute.mjs";
|
|
18
|
+
import { writeDataAttribute } from "./theme/data-attribute/write-data-attribute.mjs";
|
|
19
|
+
import { readLocalStorage } from "./theme/local-storage/read-local-storage.mjs";
|
|
20
|
+
import { writeLocalStorage } from "./theme/local-storage/write-local-storage.mjs";
|
|
21
|
+
import { ReadPrefersColorSchemeThemeOptions, readPrefersColorSchemeTheme } from "./theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs";
|
|
22
|
+
import { subscribePrefersColorSchemeTheme } from "./theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs";
|
|
23
|
+
import { readSessionStorage } from "./theme/session-storage/read-session-storage.mjs";
|
|
24
|
+
import { writeSessionStorage } from "./theme/session-storage/write-session-storage.mjs";
|
|
7
25
|
import { themeEntry } from "./theme/theme-entry.mjs";
|
|
8
26
|
import { classNameThemeStore } from "./theme/theme-store/class-name-theme-store/class-name-theme-store.mjs";
|
|
9
27
|
import { CookieThemeStoreOptions, cookieThemeStore, getThemeFromCookie } from "./theme/theme-store/cookie-theme-store/cookie-theme-store.mjs";
|
|
@@ -12,4 +30,6 @@ import { inMemoryThemeStore } from "./theme/theme-store/in-memory-theme-store/in
|
|
|
12
30
|
import { localStorageThemeStore } from "./theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs";
|
|
13
31
|
import { prefersColorSchemeThemeStore } from "./theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs";
|
|
14
32
|
import { sessionStorageThemeStore } from "./theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs";
|
|
15
|
-
|
|
33
|
+
import { readWebStorage } from "./theme/web-storage/read-web-storage.mjs";
|
|
34
|
+
import { writeWebStorage } from "./theme/web-storage/write-web-storage.mjs";
|
|
35
|
+
export { AsyncThemeStore, ComposeThemeStoreEntry, ComposeThemeStoresOptions, CookieThemeStoreOptions, ParseStoredTheme, ReadCookieThemeOptions, ReadPrefersColorSchemeThemeOptions, StringifyStoredTheme, ThemeEntry, ThemeMap, ThemeMapValue, ThemeStore, ThemeStoreFactory, WriteCookieThemeOptions, classNameThemeStore, composeThemeStores, cookieThemeStore, dataAttributeThemeStore, getThemeFromCookie, inMemoryThemeStore, localStorageThemeStore, parseClassName, parseDataAttribute, prefersColorSchemeThemeStore, readClassName, readCookieTheme, readDataAttribute, readLocalStorage, readPrefersColorSchemeTheme, readSessionStorage, readWebStorage, sessionStorageThemeStore, stringifyClassName, stringifyDataAttribute, subscribeClassName, subscribeDataAttribute, subscribePrefersColorSchemeTheme, themeEntry, writeClassName, writeCookieTheme, writeDataAttribute, writeLocalStorage, writeSessionStorage, writeWebStorage };
|
package/dist/theme.mjs
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { themeEntry } from "./theme/theme-entry.mjs";
|
|
2
|
+
import { parseClassName } from "./theme/class-name/parse-class-name.mjs";
|
|
3
|
+
import { readClassName } from "./theme/class-name/read-class-name.mjs";
|
|
4
|
+
import { stringifyClassName } from "./theme/class-name/stringify-class-name.mjs";
|
|
5
|
+
import { subscribeClassName } from "./theme/class-name/subscribe-class-name.mjs";
|
|
6
|
+
import { writeClassName } from "./theme/class-name/write-class-name.mjs";
|
|
2
7
|
import { classNameThemeStore } from "./theme/theme-store/class-name-theme-store/class-name-theme-store.mjs";
|
|
8
|
+
import { parseDataAttribute } from "./theme/data-attribute/parse-data-attribute.mjs";
|
|
9
|
+
import { readDataAttribute } from "./theme/data-attribute/read-data-attribute.mjs";
|
|
10
|
+
import { stringifyDataAttribute } from "./theme/data-attribute/stringify-data-attribute.mjs";
|
|
11
|
+
import { subscribeDataAttribute } from "./theme/data-attribute/subscribe-data-attribute.mjs";
|
|
12
|
+
import { writeDataAttribute } from "./theme/data-attribute/write-data-attribute.mjs";
|
|
3
13
|
import { dataAttributeThemeStore } from "./theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs";
|
|
14
|
+
import { readWebStorage } from "./theme/web-storage/read-web-storage.mjs";
|
|
15
|
+
import { readLocalStorage } from "./theme/local-storage/read-local-storage.mjs";
|
|
16
|
+
import { writeWebStorage } from "./theme/web-storage/write-web-storage.mjs";
|
|
17
|
+
import { writeLocalStorage } from "./theme/local-storage/write-local-storage.mjs";
|
|
4
18
|
import { localStorageThemeStore } from "./theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs";
|
|
5
19
|
import { composeThemeStores } from "./theme/compose-theme-stores.mjs";
|
|
20
|
+
import { readCookieTheme } from "./theme/cookie/read-cookie-theme.mjs";
|
|
21
|
+
import { writeCookieTheme } from "./theme/cookie/write-cookie-theme.mjs";
|
|
22
|
+
import { readPrefersColorSchemeTheme } from "./theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs";
|
|
23
|
+
import { subscribePrefersColorSchemeTheme } from "./theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs";
|
|
24
|
+
import { readSessionStorage } from "./theme/session-storage/read-session-storage.mjs";
|
|
25
|
+
import { writeSessionStorage } from "./theme/session-storage/write-session-storage.mjs";
|
|
6
26
|
import { cookieThemeStore, getThemeFromCookie } from "./theme/theme-store/cookie-theme-store/cookie-theme-store.mjs";
|
|
7
27
|
import { inMemoryThemeStore } from "./theme/theme-store/in-memory-theme-store/in-memory-theme-store.mjs";
|
|
8
28
|
import { prefersColorSchemeThemeStore } from "./theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs";
|
|
9
29
|
import { sessionStorageThemeStore } from "./theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs";
|
|
10
30
|
|
|
11
|
-
export { classNameThemeStore, composeThemeStores, cookieThemeStore, dataAttributeThemeStore, getThemeFromCookie, inMemoryThemeStore, localStorageThemeStore, prefersColorSchemeThemeStore, sessionStorageThemeStore, themeEntry };
|
|
31
|
+
export { classNameThemeStore, composeThemeStores, cookieThemeStore, dataAttributeThemeStore, getThemeFromCookie, inMemoryThemeStore, localStorageThemeStore, parseClassName, parseDataAttribute, prefersColorSchemeThemeStore, readClassName, readCookieTheme, readDataAttribute, readLocalStorage, readPrefersColorSchemeTheme, readSessionStorage, readWebStorage, sessionStorageThemeStore, stringifyClassName, stringifyDataAttribute, subscribeClassName, subscribeDataAttribute, subscribePrefersColorSchemeTheme, themeEntry, writeClassName, writeCookieTheme, writeDataAttribute, writeLocalStorage, writeSessionStorage, writeWebStorage };
|
package/dist/utils/append-id.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Appends a suffix to an ID if the ID is defined.
|
|
5
5
|
*
|
|
6
|
-
* @param id - The ID to append the suffix to.
|
|
6
|
+
* @param id - The ID to append the suffix to (accepts null e.g. from getAttribute).
|
|
7
7
|
* @param suffix - The suffix to append to the ID.
|
|
8
|
-
* @returns The ID with the suffix appended, or undefined if the ID is undefined.
|
|
8
|
+
* @returns The ID with the suffix appended, or undefined if the ID is null/undefined.
|
|
9
9
|
*/
|
|
10
10
|
function appendId(id, suffix) {
|
|
11
11
|
return id ? `${id}-${suffix}` : void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append-id.cjs","names":[],"sources":["../../src/utils/append-id.ts"],"sourcesContent":["/**\n * Appends a suffix to an ID if the ID is defined.\n *\n * @param id - The ID to append the suffix to.\n * @param suffix - The suffix to append to the ID.\n * @returns The ID with the suffix appended, or undefined if the ID is undefined.\n */\nexport function appendId(id: string | undefined, suffix: string): string | undefined {\n\treturn id ? `${id}-${suffix}` : undefined\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,SAAS,
|
|
1
|
+
{"version":3,"file":"append-id.cjs","names":[],"sources":["../../src/utils/append-id.ts"],"sourcesContent":["/**\n * Appends a suffix to an ID if the ID is defined.\n *\n * @param id - The ID to append the suffix to (accepts null e.g. from getAttribute).\n * @param suffix - The suffix to append to the ID.\n * @returns The ID with the suffix appended, or undefined if the ID is null/undefined.\n */\nexport function appendId(id: string | null | undefined, suffix: string): string | undefined {\n\treturn id ? `${id}-${suffix}` : undefined\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,SAAS,IAA+B,QAAoC;AAC3F,QAAO,KAAK,GAAG,GAAG,GAAG,WAAW"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Appends a suffix to an ID if the ID is defined.
|
|
4
4
|
*
|
|
5
|
-
* @param id - The ID to append the suffix to.
|
|
5
|
+
* @param id - The ID to append the suffix to (accepts null e.g. from getAttribute).
|
|
6
6
|
* @param suffix - The suffix to append to the ID.
|
|
7
|
-
* @returns The ID with the suffix appended, or undefined if the ID is undefined.
|
|
7
|
+
* @returns The ID with the suffix appended, or undefined if the ID is null/undefined.
|
|
8
8
|
*/
|
|
9
|
-
declare function appendId(id: string | undefined, suffix: string): string | undefined;
|
|
9
|
+
declare function appendId(id: string | null | undefined, suffix: string): string | undefined;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { appendId };
|
|
12
12
|
//# sourceMappingURL=append-id.d.cts.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Appends a suffix to an ID if the ID is defined.
|
|
4
4
|
*
|
|
5
|
-
* @param id - The ID to append the suffix to.
|
|
5
|
+
* @param id - The ID to append the suffix to (accepts null e.g. from getAttribute).
|
|
6
6
|
* @param suffix - The suffix to append to the ID.
|
|
7
|
-
* @returns The ID with the suffix appended, or undefined if the ID is undefined.
|
|
7
|
+
* @returns The ID with the suffix appended, or undefined if the ID is null/undefined.
|
|
8
8
|
*/
|
|
9
|
-
declare function appendId(id: string | undefined, suffix: string): string | undefined;
|
|
9
|
+
declare function appendId(id: string | null | undefined, suffix: string): string | undefined;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { appendId };
|
|
12
12
|
//# sourceMappingURL=append-id.d.mts.map
|
package/dist/utils/append-id.mjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Appends a suffix to an ID if the ID is defined.
|
|
4
4
|
*
|
|
5
|
-
* @param id - The ID to append the suffix to.
|
|
5
|
+
* @param id - The ID to append the suffix to (accepts null e.g. from getAttribute).
|
|
6
6
|
* @param suffix - The suffix to append to the ID.
|
|
7
|
-
* @returns The ID with the suffix appended, or undefined if the ID is undefined.
|
|
7
|
+
* @returns The ID with the suffix appended, or undefined if the ID is null/undefined.
|
|
8
8
|
*/
|
|
9
9
|
function appendId(id, suffix) {
|
|
10
10
|
return id ? `${id}-${suffix}` : void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append-id.mjs","names":[],"sources":["../../src/utils/append-id.ts"],"sourcesContent":["/**\n * Appends a suffix to an ID if the ID is defined.\n *\n * @param id - The ID to append the suffix to.\n * @param suffix - The suffix to append to the ID.\n * @returns The ID with the suffix appended, or undefined if the ID is undefined.\n */\nexport function appendId(id: string | undefined, suffix: string): string | undefined {\n\treturn id ? `${id}-${suffix}` : undefined\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,SAAS,
|
|
1
|
+
{"version":3,"file":"append-id.mjs","names":[],"sources":["../../src/utils/append-id.ts"],"sourcesContent":["/**\n * Appends a suffix to an ID if the ID is defined.\n *\n * @param id - The ID to append the suffix to (accepts null e.g. from getAttribute).\n * @param suffix - The suffix to append to the ID.\n * @returns The ID with the suffix appended, or undefined if the ID is null/undefined.\n */\nexport function appendId(id: string | null | undefined, suffix: string): string | undefined {\n\treturn id ? `${id}-${suffix}` : undefined\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,SAAS,IAA+B,QAAoC;AAC3F,QAAO,KAAK,GAAG,GAAG,GAAG,WAAW"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Gets the value of an attribute from an element.
|
|
3
3
|
*
|
|
4
4
|
* @param qualifiedName - The name of the attribute to get
|
|
5
|
-
* @param element - The element to get the attribute from. Defaults to `document.documentElement`
|
|
5
|
+
* @param element - The element to get the attribute from (accepts null e.g. from refs). Defaults to `document.documentElement`
|
|
6
6
|
* @returns The attribute value cast to type T, or null if the attribute doesn't exist
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* const testId = getAttribute('data-testid', element)
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export function getAttribute<T extends string>(
|
|
17
|
+
export function getAttribute<T extends string>(
|
|
18
|
+
qualifiedName: T,
|
|
19
|
+
element?: Element | null | undefined
|
|
20
|
+
) {
|
|
18
21
|
element = element ?? globalThis.document.documentElement
|
|
19
22
|
return element.getAttribute(qualifiedName)
|
|
20
23
|
}
|
|
@@ -5,11 +5,14 @@ import { getAttribute } from './get-attribute.ts'
|
|
|
5
5
|
* Gets the value of a data attribute from an element.
|
|
6
6
|
*
|
|
7
7
|
* @param qualifiedName - The name of the data attribute to get
|
|
8
|
-
* @param element - The element to get the data attribute from. Defaults to `document.documentElement`
|
|
8
|
+
* @param element - The element to get the data attribute from (accepts null e.g. from refs). Defaults to `document.documentElement`
|
|
9
9
|
* @returns The data attribute value, or null if the attribute doesn't exist
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
*/
|
|
13
|
-
export function getDataAttribute(
|
|
13
|
+
export function getDataAttribute(
|
|
14
|
+
qualifiedName: DataAttribute,
|
|
15
|
+
element?: Element | null | undefined
|
|
16
|
+
) {
|
|
14
17
|
return getAttribute(qualifiedName, element)
|
|
15
18
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Observes attributes changes on an element and calls corresponding handlers.
|
|
3
3
|
*
|
|
4
4
|
* @param handlers - An object mapping attribute names to handler functions.
|
|
5
|
-
* @param element - The element to observe. Defaults to `document.documentElement`.
|
|
5
|
+
* @param element - The element to observe (accepts null e.g. from refs). Defaults to `document.documentElement`.
|
|
6
6
|
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export function observeAttributes<T extends string>(
|
|
20
20
|
handlers: Record<string, (value: T | null) => void>,
|
|
21
|
-
element?: Element | undefined
|
|
21
|
+
element?: Element | null | undefined
|
|
22
22
|
) {
|
|
23
23
|
element = element ?? globalThis.document.documentElement
|
|
24
24
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -5,7 +5,7 @@ import { observeAttributes } from './observe-attribute.ts'
|
|
|
5
5
|
*
|
|
6
6
|
* @param options - Configuration options
|
|
7
7
|
* @param options.handlers - An object mapping `data-*` attribute names to handler functions.
|
|
8
|
-
* @param options.element - The element to observe. Defaults to `document.documentElement`
|
|
8
|
+
* @param options.element - The element to observe (accepts null e.g. from refs). Defaults to `document.documentElement`
|
|
9
9
|
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
@@ -23,7 +23,7 @@ import { observeAttributes } from './observe-attribute.ts'
|
|
|
23
23
|
*/
|
|
24
24
|
export function observeDataAttributes<T extends string, K extends `data-${string}`>(
|
|
25
25
|
handlers: Record<K, (value: T | null) => void>,
|
|
26
|
-
element?: Element | undefined
|
|
26
|
+
element?: Element | null | undefined
|
|
27
27
|
) {
|
|
28
28
|
return observeAttributes(handlers, element)
|
|
29
29
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The color scheme of the system.
|
|
3
|
+
*
|
|
4
|
+
* Per {@link https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme Media Queries Level 5 § prefers-color-scheme},
|
|
5
|
+
* these are the only valid values exposed by the `prefers-color-scheme` media feature.
|
|
6
|
+
*/
|
|
7
|
+
export type ColorScheme = 'light' | 'dark'
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import type { ColorScheme } from './color-scheme.types.ts'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Gets the current preferred color scheme.
|
|
3
5
|
* It can only be 'light' or 'dark'.
|
|
4
6
|
*
|
|
5
|
-
*
|
|
7
|
+
* Per {@link https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme Media Queries Level 5},
|
|
8
|
+
* the `prefers-color-scheme` media feature has only two valid values. Even if the browser
|
|
9
|
+
* preference is 'auto'/'device', it will return 'light' or 'dark'.
|
|
6
10
|
*
|
|
7
11
|
* When `matchMedia` is unavailable (e.g. SSR), returns `defaultColorScheme`.
|
|
8
12
|
*
|
|
9
13
|
* @param defaultColorScheme - Fallback when `matchMedia` is unavailable (default: `'light'`)
|
|
10
14
|
* @returns 'light' or 'dark'
|
|
11
15
|
*/
|
|
12
|
-
export function getPrefersColorScheme(
|
|
13
|
-
defaultColorScheme: 'light' | 'dark' = 'light'
|
|
14
|
-
): 'light' | 'dark' {
|
|
16
|
+
export function getPrefersColorScheme(defaultColorScheme: ColorScheme = 'light'): ColorScheme {
|
|
15
17
|
if (typeof matchMedia === 'undefined') return defaultColorScheme
|
|
16
18
|
return matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'
|
|
17
19
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ColorScheme } from './color-scheme.types.ts'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Observes system color scheme preference changes and calls handlers when they occur.
|
|
3
5
|
*
|
|
@@ -13,7 +15,7 @@
|
|
|
13
15
|
* cleanup()
|
|
14
16
|
* ```
|
|
15
17
|
*/
|
|
16
|
-
export function observePrefersColorScheme(handler: (value:
|
|
18
|
+
export function observePrefersColorScheme(handler: (value: ColorScheme) => void) {
|
|
17
19
|
const m = globalThis.matchMedia('(prefers-color-scheme: light)')
|
|
18
20
|
const listener = (event: MediaQueryListEvent) => {
|
|
19
21
|
handler(event.matches ? 'light' : 'dark')
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './class-name/class-name-props.ts'
|
|
|
9
9
|
export * from './class-name/clsx.ts'
|
|
10
10
|
export * from './class-name/just-class-name.ts'
|
|
11
11
|
export * from './class-name/resolve-class-name.ts'
|
|
12
|
+
export * from './color-scheme/color-scheme.types.ts'
|
|
12
13
|
export * from './color-scheme/get-prefers-color-scheme.ts'
|
|
13
14
|
export * from './color-scheme/observe-prefers-color-scheme.ts'
|
|
14
15
|
export * from './style/css-properties.ts'
|
|
@@ -6,36 +6,36 @@ import { observeAttributes } from '../../attributes/observe-attribute.ts'
|
|
|
6
6
|
* and a setter to update it. Stays in sync when the attribute changes (e.g. from elsewhere).
|
|
7
7
|
*
|
|
8
8
|
* @param attributeName - The attribute to observe (e.g. `'class'`, `'data-theme'`).
|
|
9
|
-
* @param element - The element to observe. Defaults to `document.documentElement` when omitted.
|
|
10
|
-
* @returns Tuple of [value, setValue]. Pass null to setValue to remove the attribute.
|
|
9
|
+
* @param element - The element to observe (accepts null e.g. from refs). Defaults to `document.documentElement` when omitted.
|
|
10
|
+
* @returns Tuple of [value, setValue]. Pass null or undefined to setValue to remove the attribute.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
14
|
* const [className, setClassName] = useAttribute('class')
|
|
15
15
|
* const [theme, setTheme] = useAttribute('data-theme', myElement)
|
|
16
16
|
* setTheme('dark')
|
|
17
|
-
* setClassName(
|
|
17
|
+
* setClassName(undefined) // removes class attribute
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export function useAttribute(
|
|
21
21
|
attributeName: string,
|
|
22
|
-
element: Element | undefined = typeof document !== 'undefined'
|
|
22
|
+
element: Element | null | undefined = typeof document !== 'undefined'
|
|
23
23
|
? document.documentElement
|
|
24
24
|
: undefined
|
|
25
|
-
): [string |
|
|
26
|
-
const [value, setValueState] = useState<string |
|
|
27
|
-
() => element?.getAttribute(attributeName) ??
|
|
25
|
+
): [string | undefined, (value: string | null | undefined) => void] {
|
|
26
|
+
const [value, setValueState] = useState<string | undefined>(
|
|
27
|
+
() => element?.getAttribute(attributeName) ?? undefined
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
useEffect(() => {
|
|
31
31
|
if (!element) return
|
|
32
32
|
|
|
33
|
-
setValueState(element.getAttribute(attributeName))
|
|
33
|
+
setValueState(element.getAttribute(attributeName) ?? undefined)
|
|
34
34
|
|
|
35
35
|
const observer = observeAttributes(
|
|
36
36
|
{
|
|
37
37
|
[attributeName]: (next) => {
|
|
38
|
-
setValueState(next)
|
|
38
|
+
setValueState(next ?? undefined)
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
element
|
|
@@ -44,9 +44,9 @@ export function useAttribute(
|
|
|
44
44
|
}, [element, attributeName])
|
|
45
45
|
|
|
46
46
|
const setValue = useCallback(
|
|
47
|
-
(next: string | null) => {
|
|
47
|
+
(next: string | null | undefined) => {
|
|
48
48
|
if (!element) return
|
|
49
|
-
if (next
|
|
49
|
+
if (next == null) {
|
|
50
50
|
element.removeAttribute(attributeName)
|
|
51
51
|
} else {
|
|
52
52
|
element.setAttribute(attributeName, next)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
2
|
import { observeThemeFromStores } from '../../theme/_utils/observe-theme-from-stores.ts'
|
|
3
3
|
import { setThemeToStores } from '../../theme/_utils/set-theme-to-stores.ts'
|
|
4
|
-
import { resolveThemeFromClassName } from '../../theme/class-name/resolve-theme-from-class-name.ts'
|
|
5
4
|
import { themeEntry } from '../../theme/theme-entry.ts'
|
|
6
5
|
import type { ThemeMap } from '../../theme/theme-map.types.ts'
|
|
7
6
|
import { classNameThemeStore } from '../../theme/theme-store/class-name-theme-store/class-name-theme-store.ts'
|
|
@@ -12,7 +11,7 @@ import { classNameThemeStore } from '../../theme/theme-store/class-name-theme-st
|
|
|
12
11
|
*
|
|
13
12
|
* @param themes - Record mapping theme keys to their class name values
|
|
14
13
|
* @param options.theme - Fallback theme key when no matching class is found
|
|
15
|
-
* @param options.element - Element to read/set theme on (
|
|
14
|
+
* @param options.element - Element to read/set theme on (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
16
15
|
* @returns Tuple of [currentTheme, setTheme]
|
|
17
16
|
*
|
|
18
17
|
* @example
|
|
@@ -33,7 +32,7 @@ export function useThemeByClassName<Themes extends ThemeMap>(
|
|
|
33
32
|
themes: Themes,
|
|
34
33
|
options?: {
|
|
35
34
|
defaultTheme?: keyof Themes | undefined
|
|
36
|
-
element?: Element | undefined
|
|
35
|
+
element?: Element | null | undefined
|
|
37
36
|
}
|
|
38
37
|
): [keyof Themes | undefined, (theme: keyof Themes) => void] {
|
|
39
38
|
const element =
|
|
@@ -42,13 +41,9 @@ export function useThemeByClassName<Themes extends ThemeMap>(
|
|
|
42
41
|
|
|
43
42
|
const store = useMemo(() => classNameThemeStore(themes, { element }), [element, themes])
|
|
44
43
|
|
|
45
|
-
const [theme, setThemeState] = useState<keyof Themes | undefined>(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return resolved ?? defaultTheme
|
|
49
|
-
}
|
|
50
|
-
return defaultTheme
|
|
51
|
-
})
|
|
44
|
+
const [theme, setThemeState] = useState<keyof Themes | undefined>(
|
|
45
|
+
() => store.read()?.theme ?? defaultTheme
|
|
46
|
+
)
|
|
52
47
|
|
|
53
48
|
useEffect(() => {
|
|
54
49
|
if (!element) return
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
|
-
import { getDataAttribute } from '../../attributes/get-data-attribute.ts'
|
|
3
2
|
import { observeThemeFromStores } from '../../theme/_utils/observe-theme-from-stores.ts'
|
|
4
3
|
import { setThemeToStores } from '../../theme/_utils/set-theme-to-stores.ts'
|
|
5
|
-
import { resolveThemeFromDataAttribute } from '../../theme/data-attribute/resolve-theme-from-data-attribute.ts'
|
|
6
4
|
import { themeEntry } from '../../theme/theme-entry.ts'
|
|
7
5
|
import type { ThemeMap } from '../../theme/theme-map.types.ts'
|
|
8
6
|
import { dataAttributeThemeStore } from '../../theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts'
|
|
@@ -14,7 +12,7 @@ import { dataAttributeThemeStore } from '../../theme/theme-store/data-attribute-
|
|
|
14
12
|
* @param themes - Record mapping theme keys to their data attribute values
|
|
15
13
|
* @param options.attributeName - Data attribute name (e.g. `data-theme`)
|
|
16
14
|
* @param options.defaultTheme - Fallback theme key when no matching attribute value is found
|
|
17
|
-
* @param options.element - Element to read/set theme on (
|
|
15
|
+
* @param options.element - Element to read/set theme on (accepts null e.g. from refs). Defaults to document.documentElement.
|
|
18
16
|
* @returns Tuple of [currentTheme, setTheme]
|
|
19
17
|
*
|
|
20
18
|
* @example
|
|
@@ -39,7 +37,7 @@ export function useThemeByDataAttribute<Themes extends ThemeMap>(
|
|
|
39
37
|
options: {
|
|
40
38
|
attributeName: `data-${string}`
|
|
41
39
|
defaultTheme?: keyof Themes | undefined
|
|
42
|
-
element?: Element | undefined
|
|
40
|
+
element?: Element | null | undefined
|
|
43
41
|
}
|
|
44
42
|
): [keyof Themes | undefined, (theme: keyof Themes) => void] {
|
|
45
43
|
const element =
|
|
@@ -56,14 +54,9 @@ export function useThemeByDataAttribute<Themes extends ThemeMap>(
|
|
|
56
54
|
[element, themes, attributeName]
|
|
57
55
|
)
|
|
58
56
|
|
|
59
|
-
const [theme, setThemeState] = useState<keyof Themes | undefined>(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const resolved = resolveThemeFromDataAttribute(themes, attrValue)
|
|
63
|
-
return resolved ?? defaultTheme
|
|
64
|
-
}
|
|
65
|
-
return defaultTheme
|
|
66
|
-
})
|
|
57
|
+
const [theme, setThemeState] = useState<keyof Themes | undefined>(
|
|
58
|
+
() => store.read()?.theme ?? defaultTheme
|
|
59
|
+
)
|
|
67
60
|
|
|
68
61
|
useEffect(() => {
|
|
69
62
|
if (!element) return
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
2
|
import { observeThemeFromStores } from '../../theme/_utils/observe-theme-from-stores.ts'
|
|
3
|
-
import { parseStoredTheme } from '../../theme/_utils/parse-stored-theme.ts'
|
|
4
3
|
import { setThemeToStores } from '../../theme/_utils/set-theme-to-stores.ts'
|
|
5
4
|
import { themeEntry } from '../../theme/theme-entry.ts'
|
|
6
5
|
import type { ThemeMap } from '../../theme/theme-map.types.ts'
|
|
@@ -43,14 +42,9 @@ export function useThemeByLocalStorage<Themes extends ThemeMap>(
|
|
|
43
42
|
|
|
44
43
|
const store = useMemo(() => localStorageThemeStore(themes, { storageKey }), [themes, storageKey])
|
|
45
44
|
|
|
46
|
-
const [theme, setThemeState] = useState<keyof Themes | undefined>(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const resolved = parseStoredTheme(themes, stored)
|
|
50
|
-
return resolved ?? defaultTheme
|
|
51
|
-
}
|
|
52
|
-
return defaultTheme
|
|
53
|
-
})
|
|
45
|
+
const [theme, setThemeState] = useState<keyof Themes | undefined>(
|
|
46
|
+
() => store.read()?.theme ?? defaultTheme
|
|
47
|
+
)
|
|
54
48
|
|
|
55
49
|
useEffect(() => {
|
|
56
50
|
const unobserve = observeThemeFromStores([store], defaultTheme, setThemeState)
|
|
@@ -101,16 +101,14 @@ function createSharedChannel<Themes extends ThemeMap>(
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
const handleStoreUpdate = (entry: ThemeEntry<Themes> | undefined
|
|
104
|
+
const handleStoreUpdate = (entry: ThemeEntry<Themes> | undefined) => {
|
|
105
105
|
notify(entry?.theme ?? defaultTheme)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// Initial read to populate lastTheme (compose store subscribe has no initial notify)
|
|
109
|
-
void Promise.resolve(composedStore.read()).then(
|
|
110
|
-
(entry
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
)
|
|
109
|
+
void Promise.resolve(composedStore.read()).then((entry: ThemeEntry<Themes> | undefined) => {
|
|
110
|
+
notify(entry?.theme ?? defaultTheme)
|
|
111
|
+
})
|
|
114
112
|
|
|
115
113
|
let unobserve: () => void = composedStore.subscribe(handleStoreUpdate)
|
|
116
114
|
let isSubscribedToStore = true
|
|
@@ -16,6 +16,7 @@ function formatValue(value: unknown): string {
|
|
|
16
16
|
if (value === null) return '(missing)'
|
|
17
17
|
if (value === '') return '(empty)'
|
|
18
18
|
if (Array.isArray(value)) return `[${value.join(', ')}]`
|
|
19
|
+
if (typeof value === 'object' && value !== null) return JSON.stringify(value)
|
|
19
20
|
return String(value)
|
|
20
21
|
}
|
|
21
22
|
|