@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,32 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_theme_entry = require('../theme-entry.cjs');
|
|
3
|
+
const require_resolve_theme_map_value = require('../_utils/resolve-theme-map-value.cjs');
|
|
4
|
+
let type_plus = require("type-plus");
|
|
5
|
+
|
|
6
|
+
//#region src/theme/class-name/parse-class-name.ts
|
|
7
|
+
/**
|
|
8
|
+
* Parses a class name string into a ThemeEntry.
|
|
9
|
+
*
|
|
10
|
+
* Pure function: no DOM access. Matches class strings by checking if any theme
|
|
11
|
+
* class is included in the className (e.g. `className.includes(themeClass)`).
|
|
12
|
+
* Arrays in theme map use first value for matching.
|
|
13
|
+
*
|
|
14
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
15
|
+
* @param className - Raw class attribute value (e.g. from element.className)
|
|
16
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
17
|
+
*/
|
|
18
|
+
function parseClassName(themes, className) {
|
|
19
|
+
const cls = className ?? "";
|
|
20
|
+
const theme = (0, type_plus.findKey)(themes, (key) => {
|
|
21
|
+
const value = themes[key];
|
|
22
|
+
if (value === void 0) return false;
|
|
23
|
+
const resolved = require_resolve_theme_map_value.resolveThemeMapValue(value);
|
|
24
|
+
const v = Array.isArray(resolved) ? resolved[0] : resolved;
|
|
25
|
+
return !!v && cls.includes(v);
|
|
26
|
+
});
|
|
27
|
+
return theme !== void 0 ? require_theme_entry.themeEntry(themes, theme) : void 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.parseClassName = parseClassName;
|
|
32
|
+
//# sourceMappingURL=parse-class-name.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-class-name.cjs","names":["resolveThemeMapValue","themeEntry"],"sources":["../../../src/theme/class-name/parse-class-name.ts"],"sourcesContent":["import { findKey } from 'type-plus'\nimport { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport { themeEntry } from '../theme-entry.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\n/**\n * Parses a class name string into a ThemeEntry.\n *\n * Pure function: no DOM access. Matches class strings by checking if any theme\n * class is included in the className (e.g. `className.includes(themeClass)`).\n * Arrays in theme map use first value for matching.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param className - Raw class attribute value (e.g. from element.className)\n * @returns ThemeEntry if a match is found, otherwise undefined\n */\nexport function parseClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tclassName: string | undefined\n): ThemeEntry<Themes> | undefined {\n\tconst cls = className ?? ''\n\tconst theme = findKey(themes, (key) => {\n\t\tconst value = themes[key]\n\t\tif (value === undefined) return false\n\t\tconst resolved = resolveThemeMapValue(value)\n\t\tconst v = Array.isArray(resolved) ? resolved[0] : resolved\n\t\treturn !!v && cls.includes(v)\n\t})\n\treturn theme !== undefined ? themeEntry(themes, theme) : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,eACf,QACA,WACiC;CACjC,MAAM,MAAM,aAAa;CACzB,MAAM,+BAAgB,SAAS,QAAQ;EACtC,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OAAW,QAAO;EAChC,MAAM,WAAWA,qDAAqB,MAAM;EAC5C,MAAM,IAAI,MAAM,QAAQ,SAAS,GAAG,SAAS,KAAK;AAClD,SAAO,CAAC,CAAC,KAAK,IAAI,SAAS,EAAE;GAC5B;AACF,QAAO,UAAU,SAAYC,+BAAW,QAAQ,MAAM,GAAG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/parse-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parses a class name string into a ThemeEntry.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Matches class strings by checking if any theme
|
|
10
|
+
* class is included in the className (e.g. `className.includes(themeClass)`).
|
|
11
|
+
* Arrays in theme map use first value for matching.
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
14
|
+
* @param className - Raw class attribute value (e.g. from element.className)
|
|
15
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
16
|
+
*/
|
|
17
|
+
declare function parseClassName<Themes extends ThemeMap>(themes: Themes, className: string | undefined): ThemeEntry<Themes> | undefined;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { parseClassName };
|
|
20
|
+
//# sourceMappingURL=parse-class-name.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-class-name.d.cts","names":[],"sources":["../../../src/theme/class-name/parse-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;iBAAgB,8BAA8B,kBACrC,wCAEN,WAAW"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/parse-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parses a class name string into a ThemeEntry.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Matches class strings by checking if any theme
|
|
10
|
+
* class is included in the className (e.g. `className.includes(themeClass)`).
|
|
11
|
+
* Arrays in theme map use first value for matching.
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
14
|
+
* @param className - Raw class attribute value (e.g. from element.className)
|
|
15
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
16
|
+
*/
|
|
17
|
+
declare function parseClassName<Themes extends ThemeMap>(themes: Themes, className: string | undefined): ThemeEntry<Themes> | undefined;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { parseClassName };
|
|
20
|
+
//# sourceMappingURL=parse-class-name.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-class-name.d.mts","names":[],"sources":["../../../src/theme/class-name/parse-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;iBAAgB,8BAA8B,kBACrC,wCAEN,WAAW"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { themeEntry } from "../theme-entry.mjs";
|
|
2
|
+
import { resolveThemeMapValue } from "../_utils/resolve-theme-map-value.mjs";
|
|
3
|
+
import { findKey } from "type-plus";
|
|
4
|
+
|
|
5
|
+
//#region src/theme/class-name/parse-class-name.ts
|
|
6
|
+
/**
|
|
7
|
+
* Parses a class name string into a ThemeEntry.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Matches class strings by checking if any theme
|
|
10
|
+
* class is included in the className (e.g. `className.includes(themeClass)`).
|
|
11
|
+
* Arrays in theme map use first value for matching.
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
14
|
+
* @param className - Raw class attribute value (e.g. from element.className)
|
|
15
|
+
* @returns ThemeEntry if a match is found, otherwise undefined
|
|
16
|
+
*/
|
|
17
|
+
function parseClassName(themes, className) {
|
|
18
|
+
const cls = className ?? "";
|
|
19
|
+
const theme = findKey(themes, (key) => {
|
|
20
|
+
const value = themes[key];
|
|
21
|
+
if (value === void 0) return false;
|
|
22
|
+
const resolved = resolveThemeMapValue(value);
|
|
23
|
+
const v = Array.isArray(resolved) ? resolved[0] : resolved;
|
|
24
|
+
return !!v && cls.includes(v);
|
|
25
|
+
});
|
|
26
|
+
return theme !== void 0 ? themeEntry(themes, theme) : void 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { parseClassName };
|
|
31
|
+
//# sourceMappingURL=parse-class-name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-class-name.mjs","names":[],"sources":["../../../src/theme/class-name/parse-class-name.ts"],"sourcesContent":["import { findKey } from 'type-plus'\nimport { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport { themeEntry } from '../theme-entry.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\n/**\n * Parses a class name string into a ThemeEntry.\n *\n * Pure function: no DOM access. Matches class strings by checking if any theme\n * class is included in the className (e.g. `className.includes(themeClass)`).\n * Arrays in theme map use first value for matching.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param className - Raw class attribute value (e.g. from element.className)\n * @returns ThemeEntry if a match is found, otherwise undefined\n */\nexport function parseClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tclassName: string | undefined\n): ThemeEntry<Themes> | undefined {\n\tconst cls = className ?? ''\n\tconst theme = findKey(themes, (key) => {\n\t\tconst value = themes[key]\n\t\tif (value === undefined) return false\n\t\tconst resolved = resolveThemeMapValue(value)\n\t\tconst v = Array.isArray(resolved) ? resolved[0] : resolved\n\t\treturn !!v && cls.includes(v)\n\t})\n\treturn theme !== undefined ? themeEntry(themes, theme) : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,eACf,QACA,WACiC;CACjC,MAAM,MAAM,aAAa;CACzB,MAAM,QAAQ,QAAQ,SAAS,QAAQ;EACtC,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OAAW,QAAO;EAChC,MAAM,WAAW,qBAAqB,MAAM;EAC5C,MAAM,IAAI,MAAM,QAAQ,SAAS,GAAG,SAAS,KAAK;AAClD,SAAO,CAAC,CAAC,KAAK,IAAI,SAAS,EAAE;GAC5B;AACF,QAAO,UAAU,SAAY,WAAW,QAAQ,MAAM,GAAG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_parse_class_name = require('./parse-class-name.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/theme/class-name/read-class-name.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reads a theme entry from the class attribute on an element.
|
|
6
|
+
*
|
|
7
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
8
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
9
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
10
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
11
|
+
*/
|
|
12
|
+
function readClassName(themes, options) {
|
|
13
|
+
const element = options?.element ?? document?.documentElement;
|
|
14
|
+
if (!element) return void 0;
|
|
15
|
+
return (options?.parse ?? require_parse_class_name.parseClassName)(themes, element.className ?? void 0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.readClassName = readClassName;
|
|
20
|
+
//# sourceMappingURL=read-class-name.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-class-name.cjs","names":["parseClassName"],"sources":["../../../src/theme/class-name/read-class-name.ts"],"sourcesContent":["import type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { parseClassName } from './parse-class-name.ts'\n\n/**\n * Reads a theme entry from the class attribute on an element.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param options.element - Element to read from (defaults to document.documentElement)\n * @param options.parse - Custom parser (default: parseClassName)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).\n */\nexport function readClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\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 = options?.parse ?? parseClassName\n\tconst raw = element.className ?? undefined\n\treturn parse(themes, raw)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,cACf,QACA,SAGiC;CACjC,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,QAAO;AAGrB,SAFc,SAAS,SAASA,yCAEnB,QADD,QAAQ,aAAa,OACR"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/read-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from the class attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
10
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
11
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
12
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
13
|
+
*/
|
|
14
|
+
declare function readClassName<Themes extends ThemeMap>(themes: Themes, options?: {
|
|
15
|
+
element?: Element | undefined;
|
|
16
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
17
|
+
} | undefined): ThemeEntry<Themes> | undefined;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { readClassName };
|
|
20
|
+
//# sourceMappingURL=read-class-name.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-class-name.d.cts","names":[],"sources":["../../../src/theme/class-name/read-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;;;;;;AAKc,iBALE,aAKF,CAAA,eAL+B,QAK/B,CAAA,CAAA,MAAA,EAJL,MAIK,EAAA,QAAA,EAAA;EAAX,OAAA,CAAA,EAFa,OAEb,GAAA,SAAA;EAAU,KAAA,CAAA,EAFgC,gBAEhC,CAFiD,MAEjD,CAAA,GAAA,SAAA;gBAAV,WAAW"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/read-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from the class attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
10
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
11
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
12
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
13
|
+
*/
|
|
14
|
+
declare function readClassName<Themes extends ThemeMap>(themes: Themes, options?: {
|
|
15
|
+
element?: Element | undefined;
|
|
16
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
17
|
+
} | undefined): ThemeEntry<Themes> | undefined;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { readClassName };
|
|
20
|
+
//# sourceMappingURL=read-class-name.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-class-name.d.mts","names":[],"sources":["../../../src/theme/class-name/read-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;;;;;;AAKc,iBALE,aAKF,CAAA,eAL+B,QAK/B,CAAA,CAAA,MAAA,EAJL,MAIK,EAAA,QAAA,EAAA;EAAX,OAAA,CAAA,EAFa,OAEb,GAAA,SAAA;EAAU,KAAA,CAAA,EAFgC,gBAEhC,CAFiD,MAEjD,CAAA,GAAA,SAAA;gBAAV,WAAW"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseClassName } from "./parse-class-name.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/theme/class-name/read-class-name.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reads a theme entry from the class attribute on an element.
|
|
6
|
+
*
|
|
7
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
8
|
+
* @param options.element - Element to read from (defaults to document.documentElement)
|
|
9
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
10
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).
|
|
11
|
+
*/
|
|
12
|
+
function readClassName(themes, options) {
|
|
13
|
+
const element = options?.element ?? document?.documentElement;
|
|
14
|
+
if (!element) return void 0;
|
|
15
|
+
return (options?.parse ?? parseClassName)(themes, element.className ?? void 0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { readClassName };
|
|
20
|
+
//# sourceMappingURL=read-class-name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-class-name.mjs","names":[],"sources":["../../../src/theme/class-name/read-class-name.ts"],"sourcesContent":["import type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { parseClassName } from './parse-class-name.ts'\n\n/**\n * Reads a theme entry from the class attribute on an element.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param options.element - Element to read from (defaults to document.documentElement)\n * @param options.parse - Custom parser (default: parseClassName)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when element is not available (e.g. SSR).\n */\nexport function readClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\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 = options?.parse ?? parseClassName\n\tconst raw = element.className ?? undefined\n\treturn parse(themes, raw)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,cACf,QACA,SAGiC;CACjC,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,QAAO;AAGrB,SAFc,SAAS,SAAS,gBAEnB,QADD,QAAQ,aAAa,OACR"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_resolve_theme_map_value = require('../_utils/resolve-theme-map-value.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/theme/class-name/stringify-class-name.ts
|
|
4
|
+
/**
|
|
5
|
+
* Stringifies a ThemeEntry for a class attribute value.
|
|
6
|
+
*
|
|
7
|
+
* Pure function: no DOM access. Removes all theme classes from existing, then
|
|
8
|
+
* adds entry's class(es). Applies all classes from entry when value is an array
|
|
9
|
+
* (unlike stringifyDataAttribute which uses first only).
|
|
10
|
+
*
|
|
11
|
+
* @param themes - Record mapping theme keys to class names (used to identify theme tokens)
|
|
12
|
+
* @param existing - Current class attribute value string
|
|
13
|
+
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme classes)
|
|
14
|
+
* @returns Class attribute value string
|
|
15
|
+
*/
|
|
16
|
+
function stringifyClassName(themes, existing, entry) {
|
|
17
|
+
const allThemeClasses = Object.values(themes).flatMap((v) => {
|
|
18
|
+
const resolved = require_resolve_theme_map_value.resolveThemeMapValue(v);
|
|
19
|
+
return Array.isArray(resolved) ? [...resolved] : [resolved];
|
|
20
|
+
});
|
|
21
|
+
const withoutThemes = (existing?.trim() ? existing.trim().split(/\s+/) : []).filter((c) => !allThemeClasses.includes(c));
|
|
22
|
+
const activeClasses = entry !== void 0 ? (() => {
|
|
23
|
+
const resolved = require_resolve_theme_map_value.resolveThemeMapValue(entry.value);
|
|
24
|
+
return Array.isArray(resolved) ? [...resolved] : [resolved];
|
|
25
|
+
})() : [];
|
|
26
|
+
return [...withoutThemes, ...activeClasses].filter(Boolean).join(" ");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.stringifyClassName = stringifyClassName;
|
|
31
|
+
//# sourceMappingURL=stringify-class-name.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify-class-name.cjs","names":["resolveThemeMapValue"],"sources":["../../../src/theme/class-name/stringify-class-name.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\n/**\n * Stringifies a ThemeEntry for a class attribute value.\n *\n * Pure function: no DOM access. Removes all theme classes from existing, then\n * adds entry's class(es). Applies all classes from entry when value is an array\n * (unlike stringifyDataAttribute which uses first only).\n *\n * @param themes - Record mapping theme keys to class names (used to identify theme tokens)\n * @param existing - Current class attribute value string\n * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme classes)\n * @returns Class attribute value string\n */\nexport function stringifyClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | undefined,\n\tentry: ThemeEntry<Themes> | undefined\n): string {\n\tconst allThemeClasses = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingClasses = existing?.trim() ? existing.trim().split(/\\s+/) : []\n\tconst withoutThemes = existingClasses.filter((c) => !allThemeClasses.includes(c))\n\tconst activeClasses =\n\t\tentry !== undefined\n\t\t\t? (() => {\n\t\t\t\t\tconst resolved = resolveThemeMapValue(entry.value)\n\t\t\t\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t\t\t\t})()\n\t\t\t: []\n\treturn [...withoutThemes, ...activeClasses].filter(Boolean).join(' ')\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,mBACf,QACA,UACA,OACS;CACT,MAAM,kBAAkB,OAAO,OAAO,OAAO,CAAC,SAAS,MAAM;EAC5D,MAAM,WAAWA,qDAAqB,EAAE;AACxC,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;GAC1D;CAEF,MAAM,iBADkB,UAAU,MAAM,GAAG,SAAS,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,EACtC,QAAQ,MAAM,CAAC,gBAAgB,SAAS,EAAE,CAAC;CACjF,MAAM,gBACL,UAAU,gBACA;EACP,MAAM,WAAWA,qDAAqB,MAAM,MAAM;AAClD,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;KACxD,GACH,EAAE;AACN,QAAO,CAAC,GAAG,eAAe,GAAG,cAAc,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI"}
|
|
@@ -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/class-name/stringify-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Stringifies a ThemeEntry for a class attribute value.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Removes all theme classes from existing, then
|
|
10
|
+
* adds entry's class(es). Applies all classes from entry when value is an array
|
|
11
|
+
* (unlike stringifyDataAttribute which uses first only).
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to class names (used to identify theme tokens)
|
|
14
|
+
* @param existing - Current class attribute value string
|
|
15
|
+
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme classes)
|
|
16
|
+
* @returns Class attribute value string
|
|
17
|
+
*/
|
|
18
|
+
declare function stringifyClassName<Themes extends ThemeMap>(themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { stringifyClassName };
|
|
21
|
+
//# sourceMappingURL=stringify-class-name.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify-class-name.d.cts","names":[],"sources":["../../../src/theme/class-name/stringify-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;;;iBAAgB,kCAAkC,kBACzC,6CAED,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/class-name/stringify-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Stringifies a ThemeEntry for a class attribute value.
|
|
8
|
+
*
|
|
9
|
+
* Pure function: no DOM access. Removes all theme classes from existing, then
|
|
10
|
+
* adds entry's class(es). Applies all classes from entry when value is an array
|
|
11
|
+
* (unlike stringifyDataAttribute which uses first only).
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to class names (used to identify theme tokens)
|
|
14
|
+
* @param existing - Current class attribute value string
|
|
15
|
+
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme classes)
|
|
16
|
+
* @returns Class attribute value string
|
|
17
|
+
*/
|
|
18
|
+
declare function stringifyClassName<Themes extends ThemeMap>(themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { stringifyClassName };
|
|
21
|
+
//# sourceMappingURL=stringify-class-name.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify-class-name.d.mts","names":[],"sources":["../../../src/theme/class-name/stringify-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;;;iBAAgB,kCAAkC,kBACzC,6CAED,WAAW"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { resolveThemeMapValue } from "../_utils/resolve-theme-map-value.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/theme/class-name/stringify-class-name.ts
|
|
4
|
+
/**
|
|
5
|
+
* Stringifies a ThemeEntry for a class attribute value.
|
|
6
|
+
*
|
|
7
|
+
* Pure function: no DOM access. Removes all theme classes from existing, then
|
|
8
|
+
* adds entry's class(es). Applies all classes from entry when value is an array
|
|
9
|
+
* (unlike stringifyDataAttribute which uses first only).
|
|
10
|
+
*
|
|
11
|
+
* @param themes - Record mapping theme keys to class names (used to identify theme tokens)
|
|
12
|
+
* @param existing - Current class attribute value string
|
|
13
|
+
* @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme classes)
|
|
14
|
+
* @returns Class attribute value string
|
|
15
|
+
*/
|
|
16
|
+
function stringifyClassName(themes, existing, entry) {
|
|
17
|
+
const allThemeClasses = Object.values(themes).flatMap((v) => {
|
|
18
|
+
const resolved = resolveThemeMapValue(v);
|
|
19
|
+
return Array.isArray(resolved) ? [...resolved] : [resolved];
|
|
20
|
+
});
|
|
21
|
+
const withoutThemes = (existing?.trim() ? existing.trim().split(/\s+/) : []).filter((c) => !allThemeClasses.includes(c));
|
|
22
|
+
const activeClasses = entry !== void 0 ? (() => {
|
|
23
|
+
const resolved = resolveThemeMapValue(entry.value);
|
|
24
|
+
return Array.isArray(resolved) ? [...resolved] : [resolved];
|
|
25
|
+
})() : [];
|
|
26
|
+
return [...withoutThemes, ...activeClasses].filter(Boolean).join(" ");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { stringifyClassName };
|
|
31
|
+
//# sourceMappingURL=stringify-class-name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify-class-name.mjs","names":[],"sources":["../../../src/theme/class-name/stringify-class-name.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\n/**\n * Stringifies a ThemeEntry for a class attribute value.\n *\n * Pure function: no DOM access. Removes all theme classes from existing, then\n * adds entry's class(es). Applies all classes from entry when value is an array\n * (unlike stringifyDataAttribute which uses first only).\n *\n * @param themes - Record mapping theme keys to class names (used to identify theme tokens)\n * @param existing - Current class attribute value string\n * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme classes)\n * @returns Class attribute value string\n */\nexport function stringifyClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | undefined,\n\tentry: ThemeEntry<Themes> | undefined\n): string {\n\tconst allThemeClasses = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingClasses = existing?.trim() ? existing.trim().split(/\\s+/) : []\n\tconst withoutThemes = existingClasses.filter((c) => !allThemeClasses.includes(c))\n\tconst activeClasses =\n\t\tentry !== undefined\n\t\t\t? (() => {\n\t\t\t\t\tconst resolved = resolveThemeMapValue(entry.value)\n\t\t\t\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t\t\t\t})()\n\t\t\t: []\n\treturn [...withoutThemes, ...activeClasses].filter(Boolean).join(' ')\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,mBACf,QACA,UACA,OACS;CACT,MAAM,kBAAkB,OAAO,OAAO,OAAO,CAAC,SAAS,MAAM;EAC5D,MAAM,WAAW,qBAAqB,EAAE;AACxC,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;GAC1D;CAEF,MAAM,iBADkB,UAAU,MAAM,GAAG,SAAS,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,EACtC,QAAQ,MAAM,CAAC,gBAAgB,SAAS,EAAE,CAAC;CACjF,MAAM,gBACL,UAAU,gBACA;EACP,MAAM,WAAW,qBAAqB,MAAM,MAAM;AAClD,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;KACxD,GACH,EAAE;AACN,QAAO,CAAC,GAAG,eAAe,GAAG,cAAc,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_observe_attribute = require('../../attributes/observe-attribute.cjs');
|
|
2
|
+
const require_parse_class_name = require('./parse-class-name.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/subscribe-class-name.ts
|
|
5
|
+
/**
|
|
6
|
+
* Subscribes to changes on the class attribute and invokes the handler with parsed theme entries.
|
|
7
|
+
*
|
|
8
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
9
|
+
* @param handler - Callback invoked when the class attribute changes
|
|
10
|
+
* @param options.element - Element to observe (defaults to document.documentElement)
|
|
11
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
12
|
+
* @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
|
|
13
|
+
*/
|
|
14
|
+
function subscribeClassName(themes, handler, options) {
|
|
15
|
+
const element = options?.element ?? document?.documentElement;
|
|
16
|
+
if (!element) return () => {};
|
|
17
|
+
const parse = options?.parse ?? require_parse_class_name.parseClassName;
|
|
18
|
+
let lastEmitted = null;
|
|
19
|
+
const observer = require_observe_attribute.observeAttributes({ class: (value) => {
|
|
20
|
+
const entry = parse(themes, value ?? void 0);
|
|
21
|
+
const key = entry?.theme ?? void 0;
|
|
22
|
+
if (lastEmitted === key) return;
|
|
23
|
+
lastEmitted = key;
|
|
24
|
+
handler(entry);
|
|
25
|
+
} }, element);
|
|
26
|
+
return () => observer.disconnect();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.subscribeClassName = subscribeClassName;
|
|
31
|
+
//# sourceMappingURL=subscribe-class-name.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe-class-name.cjs","names":["parseClassName","lastEmitted: keyof Themes | undefined | null","observeAttributes"],"sources":["../../../src/theme/class-name/subscribe-class-name.ts"],"sourcesContent":["import { observeAttributes } from '../../attributes/observe-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { parseClassName } from './parse-class-name.ts'\n\n/**\n * Subscribes to changes on the class attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param handler - Callback invoked when the class attribute changes\n * @param options.element - Element to observe (defaults to document.documentElement)\n * @param options.parse - Custom parser (default: parseClassName)\n * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).\n */\nexport function subscribeClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\thandler: (entry: ThemeEntry<Themes> | undefined) => void,\n\toptions?:\n\t\t| { element?: Element | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): () => void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return () => {}\n\tconst parse = options?.parse ?? parseClassName\n\tlet lastEmitted: keyof Themes | undefined | null = null\n\tconst observer = observeAttributes(\n\t\t{\n\t\t\tclass: (value) => {\n\t\t\t\tconst entry = parse(themes, value ?? undefined)\n\t\t\t\tconst key = entry?.theme ?? undefined\n\t\t\t\tif (lastEmitted === key) return\n\t\t\t\tlastEmitted = key\n\t\t\t\thandler(entry)\n\t\t\t}\n\t\t},\n\t\telement\n\t)\n\treturn () => observer.disconnect()\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,mBACf,QACA,SACA,SAGa;CACb,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,cAAa;CAC3B,MAAM,QAAQ,SAAS,SAASA;CAChC,IAAIC,cAA+C;CACnD,MAAM,WAAWC,4CAChB,EACC,QAAQ,UAAU;EACjB,MAAM,QAAQ,MAAM,QAAQ,SAAS,OAAU;EAC/C,MAAM,MAAM,OAAO,SAAS;AAC5B,MAAI,gBAAgB,IAAK;AACzB,gBAAc;AACd,UAAQ,MAAM;IAEf,EACD,QACA;AACD,cAAa,SAAS,YAAY"}
|
|
@@ -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/class-name/subscribe-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Subscribes to changes on the class attribute and invokes the handler with parsed theme entries.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
10
|
+
* @param handler - Callback invoked when the class attribute changes
|
|
11
|
+
* @param options.element - Element to observe (defaults to document.documentElement)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
13
|
+
* @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
declare function subscribeClassName<Themes extends ThemeMap>(themes: Themes, handler: (entry: ThemeEntry<Themes> | undefined) => void, options?: {
|
|
16
|
+
element?: Element | undefined;
|
|
17
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
|
+
} | undefined): () => void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { subscribeClassName };
|
|
21
|
+
//# sourceMappingURL=subscribe-class-name.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe-class-name.d.cts","names":[],"sources":["../../../src/theme/class-name/subscribe-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAcA;;;;;;;AAI6C,iBAJ7B,kBAI6B,CAAA,eAJK,QAIL,CAAA,CAAA,MAAA,EAHpC,MAGoC,EAAA,OAAA,EAAA,CAAA,KAAA,EAF3B,UAE2B,CAFhB,MAEgB,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,QAAA,EAAA;EAAgB,OAAA,CAAA,EAA7C,OAA6C,GAAA,SAAA;UAAhB,iBAAiB"}
|
|
@@ -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/class-name/subscribe-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Subscribes to changes on the class attribute and invokes the handler with parsed theme entries.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
10
|
+
* @param handler - Callback invoked when the class attribute changes
|
|
11
|
+
* @param options.element - Element to observe (defaults to document.documentElement)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
13
|
+
* @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
declare function subscribeClassName<Themes extends ThemeMap>(themes: Themes, handler: (entry: ThemeEntry<Themes> | undefined) => void, options?: {
|
|
16
|
+
element?: Element | undefined;
|
|
17
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
|
+
} | undefined): () => void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { subscribeClassName };
|
|
21
|
+
//# sourceMappingURL=subscribe-class-name.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe-class-name.d.mts","names":[],"sources":["../../../src/theme/class-name/subscribe-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAcA;;;;;;;AAI6C,iBAJ7B,kBAI6B,CAAA,eAJK,QAIL,CAAA,CAAA,MAAA,EAHpC,MAGoC,EAAA,OAAA,EAAA,CAAA,KAAA,EAF3B,UAE2B,CAFhB,MAEgB,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,QAAA,EAAA;EAAgB,OAAA,CAAA,EAA7C,OAA6C,GAAA,SAAA;UAAhB,iBAAiB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { observeAttributes } from "../../attributes/observe-attribute.mjs";
|
|
2
|
+
import { parseClassName } from "./parse-class-name.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/subscribe-class-name.ts
|
|
5
|
+
/**
|
|
6
|
+
* Subscribes to changes on the class attribute and invokes the handler with parsed theme entries.
|
|
7
|
+
*
|
|
8
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
9
|
+
* @param handler - Callback invoked when the class attribute changes
|
|
10
|
+
* @param options.element - Element to observe (defaults to document.documentElement)
|
|
11
|
+
* @param options.parse - Custom parser (default: parseClassName)
|
|
12
|
+
* @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
|
|
13
|
+
*/
|
|
14
|
+
function subscribeClassName(themes, handler, options) {
|
|
15
|
+
const element = options?.element ?? document?.documentElement;
|
|
16
|
+
if (!element) return () => {};
|
|
17
|
+
const parse = options?.parse ?? parseClassName;
|
|
18
|
+
let lastEmitted = null;
|
|
19
|
+
const observer = observeAttributes({ class: (value) => {
|
|
20
|
+
const entry = parse(themes, value ?? void 0);
|
|
21
|
+
const key = entry?.theme ?? void 0;
|
|
22
|
+
if (lastEmitted === key) return;
|
|
23
|
+
lastEmitted = key;
|
|
24
|
+
handler(entry);
|
|
25
|
+
} }, element);
|
|
26
|
+
return () => observer.disconnect();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { subscribeClassName };
|
|
31
|
+
//# sourceMappingURL=subscribe-class-name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe-class-name.mjs","names":["lastEmitted: keyof Themes | undefined | null"],"sources":["../../../src/theme/class-name/subscribe-class-name.ts"],"sourcesContent":["import { observeAttributes } from '../../attributes/observe-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { parseClassName } from './parse-class-name.ts'\n\n/**\n * Subscribes to changes on the class attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param handler - Callback invoked when the class attribute changes\n * @param options.element - Element to observe (defaults to document.documentElement)\n * @param options.parse - Custom parser (default: parseClassName)\n * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).\n */\nexport function subscribeClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\thandler: (entry: ThemeEntry<Themes> | undefined) => void,\n\toptions?:\n\t\t| { element?: Element | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): () => void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return () => {}\n\tconst parse = options?.parse ?? parseClassName\n\tlet lastEmitted: keyof Themes | undefined | null = null\n\tconst observer = observeAttributes(\n\t\t{\n\t\t\tclass: (value) => {\n\t\t\t\tconst entry = parse(themes, value ?? undefined)\n\t\t\t\tconst key = entry?.theme ?? undefined\n\t\t\t\tif (lastEmitted === key) return\n\t\t\t\tlastEmitted = key\n\t\t\t\thandler(entry)\n\t\t\t}\n\t\t},\n\t\telement\n\t)\n\treturn () => observer.disconnect()\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,mBACf,QACA,SACA,SAGa;CACb,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,cAAa;CAC3B,MAAM,QAAQ,SAAS,SAAS;CAChC,IAAIA,cAA+C;CACnD,MAAM,WAAW,kBAChB,EACC,QAAQ,UAAU;EACjB,MAAM,QAAQ,MAAM,QAAQ,SAAS,OAAU;EAC/C,MAAM,MAAM,OAAO,SAAS;AAC5B,MAAI,gBAAgB,IAAK;AACzB,gBAAc;AACd,UAAQ,MAAM;IAEf,EACD,QACA;AACD,cAAa,SAAS,YAAY"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_stringify_class_name = require('./stringify-class-name.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/theme/class-name/write-class-name.ts
|
|
4
|
+
/**
|
|
5
|
+
* Writes a theme entry to the class attribute on an element.
|
|
6
|
+
*
|
|
7
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
8
|
+
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
9
|
+
* @param options.element - Element to write to (defaults to document.documentElement)
|
|
10
|
+
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
11
|
+
*/
|
|
12
|
+
function writeClassName(themes, entry, options) {
|
|
13
|
+
const element = options?.element ?? document?.documentElement;
|
|
14
|
+
if (!element) return;
|
|
15
|
+
element.className = (options?.stringify ?? require_stringify_class_name.stringifyClassName)(themes, element.className ?? void 0, entry);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.writeClassName = writeClassName;
|
|
20
|
+
//# sourceMappingURL=write-class-name.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-class-name.cjs","names":["stringifyClassName"],"sources":["../../../src/theme/class-name/write-class-name.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { stringifyClassName } from './stringify-class-name.ts'\n\n/**\n * Writes a theme entry to the class attribute on an element.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param entry - Theme entry to write, or undefined to remove the theme\n * @param options.element - Element to write to (defaults to document.documentElement)\n * @param options.stringify - Custom serializer (default: stringifyClassName)\n */\nexport function writeClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?:\n\t\t| { element?: Element | undefined; stringify?: StringifyStoredTheme<Themes> | undefined }\n\t\t| undefined\n): void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return\n\tconst stringify = options?.stringify ?? stringifyClassName\n\telement.className = stringify(themes, element.className ?? undefined, entry)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,eACf,QACA,OACA,SAGO;CACP,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS;AAEd,SAAQ,aADU,SAAS,aAAaA,iDACV,QAAQ,QAAQ,aAAa,QAAW,MAAM"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/write-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Writes a theme entry to the class attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
10
|
+
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
11
|
+
* @param options.element - Element to write to (defaults to document.documentElement)
|
|
12
|
+
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
13
|
+
*/
|
|
14
|
+
declare function writeClassName<Themes extends ThemeMap>(themes: Themes, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
15
|
+
element?: Element | undefined;
|
|
16
|
+
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
17
|
+
} | undefined): void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { writeClassName };
|
|
20
|
+
//# sourceMappingURL=write-class-name.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-class-name.d.cts","names":[],"sources":["../../../src/theme/class-name/write-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;;;;;;AAIsE,iBAJtD,cAIsD,CAAA,eAJxB,QAIwB,CAAA,CAAA,MAAA,EAH7D,MAG6D,EAAA,KAAA,EAF9D,UAE8D,CAFnD,MAEmD,CAAA,GAAA,SAAA,EAAA,QAAA,EAAA;EAArB,OAAA,CAAA,EAAjC,OAAiC,GAAA,SAAA;EAAoB,SAAA,CAAA,EAApB,oBAAoB,CAAC,MAAD,CAAA,GAAA,SAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/class-name/write-class-name.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Writes a theme entry to the class attribute on an element.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
10
|
+
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
11
|
+
* @param options.element - Element to write to (defaults to document.documentElement)
|
|
12
|
+
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
13
|
+
*/
|
|
14
|
+
declare function writeClassName<Themes extends ThemeMap>(themes: Themes, entry: ThemeEntry<Themes> | undefined, options?: {
|
|
15
|
+
element?: Element | undefined;
|
|
16
|
+
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
17
|
+
} | undefined): void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { writeClassName };
|
|
20
|
+
//# sourceMappingURL=write-class-name.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-class-name.d.mts","names":[],"sources":["../../../src/theme/class-name/write-class-name.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;;;;;;AAIsE,iBAJtD,cAIsD,CAAA,eAJxB,QAIwB,CAAA,CAAA,MAAA,EAH7D,MAG6D,EAAA,KAAA,EAF9D,UAE8D,CAFnD,MAEmD,CAAA,GAAA,SAAA,EAAA,QAAA,EAAA;EAArB,OAAA,CAAA,EAAjC,OAAiC,GAAA,SAAA;EAAoB,SAAA,CAAA,EAApB,oBAAoB,CAAC,MAAD,CAAA,GAAA,SAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { stringifyClassName } from "./stringify-class-name.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/theme/class-name/write-class-name.ts
|
|
4
|
+
/**
|
|
5
|
+
* Writes a theme entry to the class attribute on an element.
|
|
6
|
+
*
|
|
7
|
+
* @param themes - Record mapping theme keys to class name(s)
|
|
8
|
+
* @param entry - Theme entry to write, or undefined to remove the theme
|
|
9
|
+
* @param options.element - Element to write to (defaults to document.documentElement)
|
|
10
|
+
* @param options.stringify - Custom serializer (default: stringifyClassName)
|
|
11
|
+
*/
|
|
12
|
+
function writeClassName(themes, entry, options) {
|
|
13
|
+
const element = options?.element ?? document?.documentElement;
|
|
14
|
+
if (!element) return;
|
|
15
|
+
element.className = (options?.stringify ?? stringifyClassName)(themes, element.className ?? void 0, entry);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { writeClassName };
|
|
20
|
+
//# sourceMappingURL=write-class-name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-class-name.mjs","names":[],"sources":["../../../src/theme/class-name/write-class-name.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { stringifyClassName } from './stringify-class-name.ts'\n\n/**\n * Writes a theme entry to the class attribute on an element.\n *\n * @param themes - Record mapping theme keys to class name(s)\n * @param entry - Theme entry to write, or undefined to remove the theme\n * @param options.element - Element to write to (defaults to document.documentElement)\n * @param options.stringify - Custom serializer (default: stringifyClassName)\n */\nexport function writeClassName<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?:\n\t\t| { element?: Element | undefined; stringify?: StringifyStoredTheme<Themes> | undefined }\n\t\t| undefined\n): void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return\n\tconst stringify = options?.stringify ?? stringifyClassName\n\telement.className = stringify(themes, element.className ?? undefined, entry)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,eACf,QACA,OACA,SAGO;CACP,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS;AAEd,SAAQ,aADU,SAAS,aAAa,oBACV,QAAQ,QAAQ,aAAa,QAAW,MAAM"}
|