@just-web/toolkits 1.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/_internal/utils/try-parse-json.cjs +14 -0
- package/dist/_internal/utils/try-parse-json.cjs.map +1 -0
- package/dist/_internal/utils/try-parse-json.mjs +13 -0
- package/dist/_internal/utils/try-parse-json.mjs.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/attributes/data-attribute.d.cts +17 -0
- package/dist/attributes/data-attribute.d.cts.map +1 -0
- package/dist/attributes/data-attribute.d.mts +17 -0
- package/dist/attributes/data-attribute.d.mts.map +1 -0
- package/dist/attributes/get-attribute.cjs +26 -0
- package/dist/attributes/get-attribute.cjs.map +1 -0
- package/dist/attributes/get-attribute.d.cts +21 -0
- package/dist/attributes/get-attribute.d.cts.map +1 -0
- package/dist/attributes/get-attribute.d.mts +21 -0
- package/dist/attributes/get-attribute.d.mts.map +1 -0
- package/dist/attributes/get-attribute.mjs +25 -0
- package/dist/attributes/get-attribute.mjs.map +1 -0
- package/dist/attributes/get-data-attribute.cjs +19 -0
- package/dist/attributes/get-data-attribute.cjs.map +1 -0
- package/dist/attributes/get-data-attribute.d.cts +17 -0
- package/dist/attributes/get-data-attribute.d.cts.map +1 -0
- package/dist/attributes/get-data-attribute.d.mts +17 -0
- package/dist/attributes/get-data-attribute.d.mts.map +1 -0
- package/dist/attributes/get-data-attribute.mjs +19 -0
- package/dist/attributes/get-data-attribute.mjs.map +1 -0
- package/dist/attributes/observe-attribute.cjs +40 -0
- package/dist/attributes/observe-attribute.cjs.map +1 -0
- package/dist/attributes/observe-attribute.d.cts +23 -0
- package/dist/attributes/observe-attribute.d.cts.map +1 -0
- package/dist/attributes/observe-attribute.d.mts +23 -0
- package/dist/attributes/observe-attribute.d.mts.map +1 -0
- package/dist/attributes/observe-attribute.mjs +39 -0
- package/dist/attributes/observe-attribute.mjs.map +1 -0
- package/dist/attributes/observe-data-attribute.cjs +31 -0
- package/dist/attributes/observe-data-attribute.cjs.map +1 -0
- package/dist/attributes/observe-data-attribute.d.cts +26 -0
- package/dist/attributes/observe-data-attribute.d.cts.map +1 -0
- package/dist/attributes/observe-data-attribute.d.mts +26 -0
- package/dist/attributes/observe-data-attribute.d.mts.map +1 -0
- package/dist/attributes/observe-data-attribute.mjs +31 -0
- package/dist/attributes/observe-data-attribute.mjs.map +1 -0
- package/dist/children/just-children.d.cts +37 -0
- package/dist/children/just-children.d.cts.map +1 -0
- package/dist/children/just-children.d.mts +37 -0
- package/dist/children/just-children.d.mts.map +1 -0
- package/dist/children/resolve-children.cjs +11 -0
- package/dist/children/resolve-children.cjs.map +1 -0
- package/dist/children/resolve-children.d.cts +9 -0
- package/dist/children/resolve-children.d.cts.map +1 -0
- package/dist/children/resolve-children.d.mts +9 -0
- package/dist/children/resolve-children.d.mts.map +1 -0
- package/dist/children/resolve-children.mjs +10 -0
- package/dist/children/resolve-children.mjs.map +1 -0
- package/dist/class-name/class-name-props.d.cts +11 -0
- package/dist/class-name/class-name-props.d.cts.map +1 -0
- package/dist/class-name/class-name-props.d.mts +11 -0
- package/dist/class-name/class-name-props.d.mts.map +1 -0
- package/dist/class-name/clsx.cjs +3 -0
- package/dist/class-name/clsx.d.cts +2 -0
- package/dist/class-name/clsx.d.mts +2 -0
- package/dist/class-name/clsx.mjs +3 -0
- package/dist/class-name/just-class-name.d.cts +36 -0
- package/dist/class-name/just-class-name.d.cts.map +1 -0
- package/dist/class-name/just-class-name.d.mts +36 -0
- package/dist/class-name/just-class-name.d.mts.map +1 -0
- package/dist/class-name/resolve-class-name.cjs +12 -0
- package/dist/class-name/resolve-class-name.cjs.map +1 -0
- package/dist/class-name/resolve-class-name.d.cts +8 -0
- package/dist/class-name/resolve-class-name.d.cts.map +1 -0
- package/dist/class-name/resolve-class-name.d.mts +8 -0
- package/dist/class-name/resolve-class-name.d.mts.map +1 -0
- package/dist/class-name/resolve-class-name.mjs +10 -0
- package/dist/class-name/resolve-class-name.mjs.map +1 -0
- package/dist/color-scheme/get-prefers-color-scheme.cjs +21 -0
- package/dist/color-scheme/get-prefers-color-scheme.cjs.map +1 -0
- package/dist/color-scheme/get-prefers-color-scheme.d.cts +16 -0
- package/dist/color-scheme/get-prefers-color-scheme.d.cts.map +1 -0
- package/dist/color-scheme/get-prefers-color-scheme.d.mts +16 -0
- package/dist/color-scheme/get-prefers-color-scheme.d.mts.map +1 -0
- package/dist/color-scheme/get-prefers-color-scheme.mjs +20 -0
- package/dist/color-scheme/get-prefers-color-scheme.mjs.map +1 -0
- package/dist/color-scheme/observe-prefers-color-scheme.cjs +29 -0
- package/dist/color-scheme/observe-prefers-color-scheme.cjs.map +1 -0
- package/dist/color-scheme/observe-prefers-color-scheme.d.cts +20 -0
- package/dist/color-scheme/observe-prefers-color-scheme.d.cts.map +1 -0
- package/dist/color-scheme/observe-prefers-color-scheme.d.mts +20 -0
- package/dist/color-scheme/observe-prefers-color-scheme.d.mts.map +1 -0
- package/dist/color-scheme/observe-prefers-color-scheme.mjs +28 -0
- package/dist/color-scheme/observe-prefers-color-scheme.mjs.map +1 -0
- package/dist/index.cjs +39 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.mjs +20 -0
- package/dist/react/hooks/use-attribute.cjs +41 -0
- package/dist/react/hooks/use-attribute.cjs.map +1 -0
- package/dist/react/hooks/use-attribute.d.cts +21 -0
- package/dist/react/hooks/use-attribute.d.cts.map +1 -0
- package/dist/react/hooks/use-attribute.d.mts +21 -0
- package/dist/react/hooks/use-attribute.d.mts.map +1 -0
- package/dist/react/hooks/use-attribute.mjs +40 -0
- package/dist/react/hooks/use-attribute.mjs.map +1 -0
- package/dist/react/hooks/use-prefers-color-scheme.cjs +42 -0
- package/dist/react/hooks/use-prefers-color-scheme.cjs.map +1 -0
- package/dist/react/hooks/use-prefers-color-scheme.d.cts +29 -0
- package/dist/react/hooks/use-prefers-color-scheme.d.cts.map +1 -0
- package/dist/react/hooks/use-prefers-color-scheme.d.mts +29 -0
- package/dist/react/hooks/use-prefers-color-scheme.d.mts.map +1 -0
- package/dist/react/hooks/use-prefers-color-scheme.mjs +41 -0
- package/dist/react/hooks/use-prefers-color-scheme.mjs.map +1 -0
- package/dist/react/hooks/use-theme-by-class-name.cjs +60 -0
- package/dist/react/hooks/use-theme-by-class-name.cjs.map +1 -0
- package/dist/react/hooks/use-theme-by-class-name.d.cts +34 -0
- package/dist/react/hooks/use-theme-by-class-name.d.cts.map +1 -0
- package/dist/react/hooks/use-theme-by-class-name.d.mts +34 -0
- package/dist/react/hooks/use-theme-by-class-name.d.mts.map +1 -0
- package/dist/react/hooks/use-theme-by-class-name.mjs +59 -0
- package/dist/react/hooks/use-theme-by-class-name.mjs.map +1 -0
- package/dist/react/hooks/use-theme-by-data-attribute.cjs +73 -0
- package/dist/react/hooks/use-theme-by-data-attribute.cjs.map +1 -0
- package/dist/react/hooks/use-theme-by-data-attribute.d.cts +39 -0
- package/dist/react/hooks/use-theme-by-data-attribute.d.cts.map +1 -0
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts +39 -0
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts.map +1 -0
- package/dist/react/hooks/use-theme-by-data-attribute.mjs +72 -0
- package/dist/react/hooks/use-theme-by-data-attribute.mjs.map +1 -0
- package/dist/react/hooks/use-theme-by-local-storage.cjs +53 -0
- package/dist/react/hooks/use-theme-by-local-storage.cjs.map +1 -0
- package/dist/react/hooks/use-theme-by-local-storage.d.cts +37 -0
- package/dist/react/hooks/use-theme-by-local-storage.d.cts.map +1 -0
- package/dist/react/hooks/use-theme-by-local-storage.d.mts +37 -0
- package/dist/react/hooks/use-theme-by-local-storage.d.mts.map +1 -0
- package/dist/react/hooks/use-theme-by-local-storage.mjs +52 -0
- package/dist/react/hooks/use-theme-by-local-storage.mjs.map +1 -0
- package/dist/react/hooks/use-theme-stores.cjs +40 -0
- package/dist/react/hooks/use-theme-stores.cjs.map +1 -0
- package/dist/react/hooks/use-theme-stores.d.cts +38 -0
- package/dist/react/hooks/use-theme-stores.d.cts.map +1 -0
- package/dist/react/hooks/use-theme-stores.d.mts +38 -0
- package/dist/react/hooks/use-theme-stores.d.mts.map +1 -0
- package/dist/react/hooks/use-theme-stores.mjs +39 -0
- package/dist/react/hooks/use-theme-stores.mjs.map +1 -0
- package/dist/react/theme/create-theme-hook.cjs +105 -0
- package/dist/react/theme/create-theme-hook.cjs.map +1 -0
- package/dist/react/theme/create-theme-hook.d.cts +29 -0
- package/dist/react/theme/create-theme-hook.d.cts.map +1 -0
- package/dist/react/theme/create-theme-hook.d.mts +29 -0
- package/dist/react/theme/create-theme-hook.d.mts.map +1 -0
- package/dist/react/theme/create-theme-hook.mjs +104 -0
- package/dist/react/theme/create-theme-hook.mjs.map +1 -0
- package/dist/react.cjs +15 -0
- package/dist/react.d.cts +8 -0
- package/dist/react.d.mts +8 -0
- package/dist/react.mjs +9 -0
- package/dist/style/css-properties.d.cts +20 -0
- package/dist/style/css-properties.d.cts.map +1 -0
- package/dist/style/css-properties.d.mts +20 -0
- package/dist/style/css-properties.d.mts.map +1 -0
- package/dist/style/define-css-properties.cjs +25 -0
- package/dist/style/define-css-properties.cjs.map +1 -0
- package/dist/style/define-css-properties.d.cts +24 -0
- package/dist/style/define-css-properties.d.cts.map +1 -0
- package/dist/style/define-css-properties.d.mts +24 -0
- package/dist/style/define-css-properties.d.mts.map +1 -0
- package/dist/style/define-css-properties.mjs +24 -0
- package/dist/style/define-css-properties.mjs.map +1 -0
- package/dist/style/get-css-variable-value.cjs +11 -0
- package/dist/style/get-css-variable-value.cjs.map +1 -0
- package/dist/style/get-css-variable-value.d.cts +22 -0
- package/dist/style/get-css-variable-value.d.cts.map +1 -0
- package/dist/style/get-css-variable-value.d.mts +22 -0
- package/dist/style/get-css-variable-value.d.mts.map +1 -0
- package/dist/style/get-css-variable-value.mjs +10 -0
- package/dist/style/get-css-variable-value.mjs.map +1 -0
- package/dist/style/just-style.d.cts +44 -0
- package/dist/style/just-style.d.cts.map +1 -0
- package/dist/style/just-style.d.mts +44 -0
- package/dist/style/just-style.d.mts.map +1 -0
- package/dist/style/resolve-style.cjs +14 -0
- package/dist/style/resolve-style.cjs.map +1 -0
- package/dist/style/resolve-style.d.cts +11 -0
- package/dist/style/resolve-style.d.cts.map +1 -0
- package/dist/style/resolve-style.d.mts +11 -0
- package/dist/style/resolve-style.d.mts.map +1 -0
- package/dist/style/resolve-style.mjs +13 -0
- package/dist/style/resolve-style.mjs.map +1 -0
- package/dist/style/style-props.d.cts +13 -0
- package/dist/style/style-props.d.cts.map +1 -0
- package/dist/style/style-props.d.mts +13 -0
- package/dist/style/style-props.d.mts.map +1 -0
- package/dist/style/to-dom-style.cjs +33 -0
- package/dist/style/to-dom-style.cjs.map +1 -0
- package/dist/style/to-dom-style.d.cts +29 -0
- package/dist/style/to-dom-style.d.cts.map +1 -0
- package/dist/style/to-dom-style.d.mts +29 -0
- package/dist/style/to-dom-style.d.mts.map +1 -0
- package/dist/style/to-dom-style.mjs +32 -0
- package/dist/style/to-dom-style.mjs.map +1 -0
- package/dist/testing/theme/dummy-theme-store.cjs +11 -0
- package/dist/testing/theme/dummy-theme-store.cjs.map +1 -0
- package/dist/testing/theme/dummy-theme-store.mjs +10 -0
- package/dist/testing/theme/dummy-theme-store.mjs.map +1 -0
- package/dist/theme/_utils/get-theme-from-stores.cjs +24 -0
- package/dist/theme/_utils/get-theme-from-stores.cjs.map +1 -0
- package/dist/theme/_utils/get-theme-from-stores.mjs +23 -0
- package/dist/theme/_utils/get-theme-from-stores.mjs.map +1 -0
- package/dist/theme/_utils/observe-theme-from-stores.cjs +39 -0
- package/dist/theme/_utils/observe-theme-from-stores.cjs.map +1 -0
- package/dist/theme/_utils/observe-theme-from-stores.mjs +39 -0
- package/dist/theme/_utils/observe-theme-from-stores.mjs.map +1 -0
- package/dist/theme/_utils/parse-stored-theme.cjs +22 -0
- package/dist/theme/_utils/parse-stored-theme.cjs.map +1 -0
- package/dist/theme/_utils/parse-stored-theme.mjs +22 -0
- package/dist/theme/_utils/parse-stored-theme.mjs.map +1 -0
- package/dist/theme/_utils/set-theme-to-stores.cjs +16 -0
- package/dist/theme/_utils/set-theme-to-stores.cjs.map +1 -0
- package/dist/theme/_utils/set-theme-to-stores.mjs +15 -0
- package/dist/theme/_utils/set-theme-to-stores.mjs.map +1 -0
- package/dist/theme/class-name/apply-theme-to-class-name.cjs +23 -0
- package/dist/theme/class-name/apply-theme-to-class-name.cjs.map +1 -0
- package/dist/theme/class-name/apply-theme-to-class-name.mjs +22 -0
- package/dist/theme/class-name/apply-theme-to-class-name.mjs.map +1 -0
- package/dist/theme/class-name/resolve-theme-from-class-name.cjs +23 -0
- package/dist/theme/class-name/resolve-theme-from-class-name.cjs.map +1 -0
- package/dist/theme/class-name/resolve-theme-from-class-name.mjs +22 -0
- package/dist/theme/class-name/resolve-theme-from-class-name.mjs.map +1 -0
- package/dist/theme/compose-theme-stores.cjs +74 -0
- package/dist/theme/compose-theme-stores.cjs.map +1 -0
- package/dist/theme/compose-theme-stores.d.cts +33 -0
- package/dist/theme/compose-theme-stores.d.cts.map +1 -0
- package/dist/theme/compose-theme-stores.d.mts +33 -0
- package/dist/theme/compose-theme-stores.d.mts.map +1 -0
- package/dist/theme/compose-theme-stores.mjs +74 -0
- package/dist/theme/compose-theme-stores.mjs.map +1 -0
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs +23 -0
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs +22 -0
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs +23 -0
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs +22 -0
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs.map +1 -0
- package/dist/theme/theme-entry.cjs +13 -0
- package/dist/theme/theme-entry.cjs.map +1 -0
- package/dist/theme/theme-entry.d.cts +9 -0
- package/dist/theme/theme-entry.d.cts.map +1 -0
- package/dist/theme/theme-entry.d.mts +9 -0
- package/dist/theme/theme-entry.d.mts.map +1 -0
- package/dist/theme/theme-entry.mjs +12 -0
- package/dist/theme/theme-entry.mjs.map +1 -0
- package/dist/theme/theme-entry.types.d.cts +16 -0
- package/dist/theme/theme-entry.types.d.cts.map +1 -0
- package/dist/theme/theme-entry.types.d.mts +16 -0
- package/dist/theme/theme-entry.types.d.mts.map +1 -0
- package/dist/theme/theme-map.types.d.cts +10 -0
- package/dist/theme/theme-map.types.d.cts.map +1 -0
- package/dist/theme/theme-map.types.d.mts +10 -0
- package/dist/theme/theme-map.types.d.mts.map +1 -0
- package/dist/theme/theme-store/async-theme-store.types.d.cts +25 -0
- package/dist/theme/theme-store/async-theme-store.types.d.cts.map +1 -0
- package/dist/theme/theme-store/async-theme-store.types.d.mts +25 -0
- package/dist/theme/theme-store/async-theme-store.types.d.mts.map +1 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs +53 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs.map +1 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts +28 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts.map +1 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts +28 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts.map +1 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs +53 -0
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs.map +1 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs +121 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs.map +1 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts +65 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts.map +1 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts +65 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts.map +1 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs +120 -0
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs.map +1 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs +51 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs.map +1 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts +30 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts.map +1 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts +30 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts.map +1 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs +51 -0
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs.map +1 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.cjs +54 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.cjs.map +1 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.cts +31 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.cts.map +1 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.mts +31 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.mts.map +1 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.mjs +54 -0
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.mjs.map +1 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs +67 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs.map +1 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts +34 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts.map +1 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts +34 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts.map +1 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs +67 -0
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs.map +1 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs +39 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs.map +1 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.cts +32 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.cts.map +1 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.mts +32 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.mts.map +1 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs +39 -0
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs.map +1 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs +67 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs.map +1 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts +34 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts.map +1 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts +34 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts.map +1 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs +67 -0
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs.map +1 -0
- package/dist/theme/theme-store/theme-store-factory.types.d.cts +10 -0
- package/dist/theme/theme-store/theme-store-factory.types.d.cts.map +1 -0
- package/dist/theme/theme-store/theme-store-factory.types.d.mts +10 -0
- package/dist/theme/theme-store/theme-store-factory.types.d.mts.map +1 -0
- package/dist/theme/theme-store/theme-store.types.d.cts +33 -0
- package/dist/theme/theme-store/theme-store.types.d.cts.map +1 -0
- package/dist/theme/theme-store/theme-store.types.d.mts +33 -0
- package/dist/theme/theme-store/theme-store.types.d.mts.map +1 -0
- package/dist/theme.cjs +20 -0
- package/dist/theme.d.cts +15 -0
- package/dist/theme.d.mts +15 -0
- package/dist/theme.mjs +11 -0
- package/dist/units/get-rem-to-px-scale.cjs +30 -0
- package/dist/units/get-rem-to-px-scale.cjs.map +1 -0
- package/dist/units/get-rem-to-px-scale.d.cts +21 -0
- package/dist/units/get-rem-to-px-scale.d.cts.map +1 -0
- package/dist/units/get-rem-to-px-scale.d.mts +21 -0
- package/dist/units/get-rem-to-px-scale.d.mts.map +1 -0
- package/dist/units/get-rem-to-px-scale.mjs +29 -0
- package/dist/units/get-rem-to-px-scale.mjs.map +1 -0
- package/dist/units/px-2-num.cjs +23 -0
- package/dist/units/px-2-num.cjs.map +1 -0
- package/dist/units/px-2-num.d.cts +19 -0
- package/dist/units/px-2-num.d.cts.map +1 -0
- package/dist/units/px-2-num.d.mts +19 -0
- package/dist/units/px-2-num.d.mts.map +1 -0
- package/dist/units/px-2-num.mjs +22 -0
- package/dist/units/px-2-num.mjs.map +1 -0
- package/dist/units/px-2-rem.cjs +31 -0
- package/dist/units/px-2-rem.cjs.map +1 -0
- package/dist/units/px-2-rem.d.cts +25 -0
- package/dist/units/px-2-rem.d.cts.map +1 -0
- package/dist/units/px-2-rem.d.mts +25 -0
- package/dist/units/px-2-rem.d.mts.map +1 -0
- package/dist/units/px-2-rem.mjs +30 -0
- package/dist/units/px-2-rem.mjs.map +1 -0
- package/dist/units/rem-2-px.cjs +31 -0
- package/dist/units/rem-2-px.cjs.map +1 -0
- package/dist/units/rem-2-px.d.cts +25 -0
- package/dist/units/rem-2-px.d.cts.map +1 -0
- package/dist/units/rem-2-px.d.mts +25 -0
- package/dist/units/rem-2-px.d.mts.map +1 -0
- package/dist/units/rem-2-px.mjs +30 -0
- package/dist/units/rem-2-px.mjs.map +1 -0
- package/dist/utils/append-id.cjs +16 -0
- package/dist/utils/append-id.cjs.map +1 -0
- package/dist/utils/append-id.d.cts +12 -0
- package/dist/utils/append-id.d.cts.map +1 -0
- package/dist/utils/append-id.d.mts +12 -0
- package/dist/utils/append-id.d.mts.map +1 -0
- package/dist/utils/append-id.mjs +15 -0
- package/dist/utils/append-id.mjs.map +1 -0
- package/package.json +120 -0
- package/readme.md +15 -0
- package/src/_internal/utils/try-parse-json.ts +8 -0
- package/src/attributes/data-attribute.ts +49 -0
- package/src/attributes/get-attribute.ts +20 -0
- package/src/attributes/get-data-attribute.ts +15 -0
- package/src/attributes/observe-attribute.ts +37 -0
- package/src/attributes/observe-data-attribute.ts +29 -0
- package/src/children/just-children-fn-props.editor.default.tsx +29 -0
- package/src/children/just-children-props.editor.default.tsx +17 -0
- package/src/children/just-children.editor.default.tsx +11 -0
- package/src/children/just-children.ts +37 -0
- package/src/children/resolve-children.ts +16 -0
- package/src/class-name/class-name-props.editor.tsx +13 -0
- package/src/class-name/class-name-props.ts +7 -0
- package/src/class-name/clsx.ts +3 -0
- package/src/class-name/just-class-name-props.editor.default.tsx +23 -0
- package/src/class-name/just-class-name-resolver-state.editor.default.tsx +18 -0
- package/src/class-name/just-class-name.editor.default-class-name.tsx +28 -0
- package/src/class-name/just-class-name.editor.default.tsx +14 -0
- package/src/class-name/just-class-name.editor.type-param.tsx +25 -0
- package/src/class-name/just-class-name.ts +36 -0
- package/src/class-name/resolve-class-name.ts +12 -0
- package/src/color-scheme/get-prefers-color-scheme.ts +17 -0
- package/src/color-scheme/observe-prefers-color-scheme.ts +24 -0
- package/src/index.ts +25 -0
- package/src/react/hooks/use-attribute.ts +59 -0
- package/src/react/hooks/use-prefers-color-scheme.ts +42 -0
- package/src/react/hooks/use-theme-by-class-name.ts +69 -0
- package/src/react/hooks/use-theme-by-data-attribute.ts +84 -0
- package/src/react/hooks/use-theme-by-local-storage.ts +68 -0
- package/src/react/hooks/use-theme-stores.ts +83 -0
- package/src/react/theme/create-theme-hook.ts +197 -0
- package/src/react.ts +7 -0
- package/src/style/css-properties.ts +20 -0
- package/src/style/define-css-properties.ts +23 -0
- package/src/style/get-css-variable-value.ts +32 -0
- package/src/style/just-style-props.editor.default.tsx +17 -0
- package/src/style/just-style-resolver-state.editor.default.tsx +22 -0
- package/src/style/just-style.editor.default.tsx +17 -0
- package/src/style/just-style.editor.type-param.tsx +31 -0
- package/src/style/just-style.ts +60 -0
- package/src/style/resolve-style.ts +23 -0
- package/src/style/style-props.editor.tsx +13 -0
- package/src/style/style-props.ts +8 -0
- package/src/style/to-dom-style.ts +36 -0
- package/src/testing/button.theme.ts +21 -0
- package/src/testing/button.tsx +11 -0
- package/src/testing/log-panel.tsx +14 -0
- package/src/testing/theme/dummy-theme-store.ts +7 -0
- package/src/testing/theme/theme-result-card.tsx +43 -0
- package/src/testing/theme/theme-store-demo.tsx +87 -0
- package/src/theme/_utils/get-theme-from-stores.ts +34 -0
- package/src/theme/_utils/observe-theme-from-stores.ts +57 -0
- package/src/theme/_utils/parse-stored-theme.ts +21 -0
- package/src/theme/_utils/set-theme-to-stores.ts +23 -0
- package/src/theme/class-name/apply-theme-to-class-name.ts +26 -0
- package/src/theme/class-name/resolve-theme-from-class-name.ts +22 -0
- package/src/theme/compose-theme-stores.ts +139 -0
- package/src/theme/data-attribute/apply-theme-to-data-attribute.ts +27 -0
- package/src/theme/data-attribute/resolve-theme-from-data-attribute.ts +23 -0
- package/src/theme/theme-entry.ts +10 -0
- package/src/theme/theme-entry.types.ts +11 -0
- package/src/theme/theme-map.types.ts +6 -0
- package/src/theme/theme-store/async-theme-store.types.ts +24 -0
- package/src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts +62 -0
- package/src/theme/theme-store/cookie-theme-store/cookie-theme-store.ts +174 -0
- package/src/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts +60 -0
- package/src/theme/theme-store/in-memory-theme-store/in-memory-theme-store.ts +54 -0
- package/src/theme/theme-store/local-storage-theme-store/local-storage-theme-store.ts +83 -0
- package/src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts +43 -0
- package/src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts +83 -0
- package/src/theme/theme-store/theme-store-factory.types.ts +9 -0
- package/src/theme/theme-store/theme-store.types.ts +30 -0
- package/src/theme.ts +14 -0
- package/src/units/get-rem-to-px-scale.ts +27 -0
- package/src/units/px-2-num.ts +17 -0
- package/src/units/px-2-rem.ts +30 -0
- package/src/units/rem-2-px.ts +30 -0
- package/src/utils/append-id.ts +10 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_get_data_attribute = require('../../attributes/get-data-attribute.cjs');
|
|
3
|
+
const require_observe_theme_from_stores = require('../../theme/_utils/observe-theme-from-stores.cjs');
|
|
4
|
+
const require_set_theme_to_stores = require('../../theme/_utils/set-theme-to-stores.cjs');
|
|
5
|
+
const require_theme_entry = require('../../theme/theme-entry.cjs');
|
|
6
|
+
const require_resolve_theme_from_data_attribute = require('../../theme/data-attribute/resolve-theme-from-data-attribute.cjs');
|
|
7
|
+
const require_data_attribute_theme_store = require('../../theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs');
|
|
8
|
+
let react = require("react");
|
|
9
|
+
|
|
10
|
+
//#region src/react/hooks/use-theme-by-data-attribute.ts
|
|
11
|
+
/**
|
|
12
|
+
* React hook that returns the current theme (from element data attribute) and a setter.
|
|
13
|
+
* Subscribes to data attribute changes on the element so the returned theme stays in sync.
|
|
14
|
+
*
|
|
15
|
+
* @param themes - Record mapping theme keys to their data attribute values
|
|
16
|
+
* @param options.attributeName - Data attribute name (e.g. `data-theme`)
|
|
17
|
+
* @param options.defaultTheme - Fallback theme key when no matching attribute value is found
|
|
18
|
+
* @param options.element - Element to read/set theme on (defaults to document.documentElement)
|
|
19
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
24
|
+
* const [theme, setTheme] = useThemeByDataAttribute(themes, {
|
|
25
|
+
* attributeName: 'data-theme',
|
|
26
|
+
* defaultTheme: 'light'
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* return (
|
|
30
|
+
* <>
|
|
31
|
+
* <span>Current: {theme}</span>
|
|
32
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
33
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
34
|
+
* </>
|
|
35
|
+
* )
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function useThemeByDataAttribute(themes, options) {
|
|
39
|
+
const element = options.element ?? (typeof document !== "undefined" ? document.documentElement : void 0);
|
|
40
|
+
const defaultTheme = options.defaultTheme;
|
|
41
|
+
const attributeName = options.attributeName;
|
|
42
|
+
const store = (0, react.useMemo)(() => require_data_attribute_theme_store.dataAttributeThemeStore(themes, {
|
|
43
|
+
attributeName,
|
|
44
|
+
element
|
|
45
|
+
}), [
|
|
46
|
+
element,
|
|
47
|
+
themes,
|
|
48
|
+
attributeName
|
|
49
|
+
]);
|
|
50
|
+
const [theme, setThemeState] = (0, react.useState)(() => {
|
|
51
|
+
if (element) return require_resolve_theme_from_data_attribute.resolveThemeFromDataAttribute(themes, require_get_data_attribute.getDataAttribute(attributeName, element)) ?? defaultTheme;
|
|
52
|
+
return defaultTheme;
|
|
53
|
+
});
|
|
54
|
+
(0, react.useEffect)(() => {
|
|
55
|
+
if (!element) return;
|
|
56
|
+
return require_observe_theme_from_stores.observeThemeFromStores([store], defaultTheme, setThemeState);
|
|
57
|
+
}, [
|
|
58
|
+
element,
|
|
59
|
+
store,
|
|
60
|
+
defaultTheme
|
|
61
|
+
]);
|
|
62
|
+
return [theme, (0, react.useCallback)((themeKey) => {
|
|
63
|
+
if (element) require_set_theme_to_stores.setThemeToStores([store], require_theme_entry.themeEntry(themes, themeKey));
|
|
64
|
+
}, [
|
|
65
|
+
element,
|
|
66
|
+
store,
|
|
67
|
+
themes
|
|
68
|
+
])];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
exports.useThemeByDataAttribute = useThemeByDataAttribute;
|
|
73
|
+
//# sourceMappingURL=use-theme-by-data-attribute.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-data-attribute.cjs","names":["dataAttributeThemeStore","resolveThemeFromDataAttribute","getDataAttribute","observeThemeFromStores","themeEntry"],"sources":["../../../src/react/hooks/use-theme-by-data-attribute.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react'\nimport { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport { observeThemeFromStores } from '../../theme/_utils/observe-theme-from-stores.ts'\nimport { setThemeToStores } from '../../theme/_utils/set-theme-to-stores.ts'\nimport { resolveThemeFromDataAttribute } from '../../theme/data-attribute/resolve-theme-from-data-attribute.ts'\nimport { themeEntry } from '../../theme/theme-entry.ts'\nimport type { ThemeMap } from '../../theme/theme-map.types.ts'\nimport { dataAttributeThemeStore } from '../../theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts'\n\n/**\n * React hook that returns the current theme (from element data attribute) and a setter.\n * Subscribes to data attribute changes on the element so the returned theme stays in sync.\n *\n * @param themes - Record mapping theme keys to their data attribute values\n * @param options.attributeName - Data attribute name (e.g. `data-theme`)\n * @param options.defaultTheme - Fallback theme key when no matching attribute value is found\n * @param options.element - Element to read/set theme on (defaults to document.documentElement)\n * @returns Tuple of [currentTheme, setTheme]\n *\n * @example\n * ```tsx\n * const themes = { light: 'theme-light', dark: 'theme-dark' }\n * const [theme, setTheme] = useThemeByDataAttribute(themes, {\n * attributeName: 'data-theme',\n * defaultTheme: 'light'\n * })\n *\n * return (\n * <>\n * <span>Current: {theme}</span>\n * <button onClick={() => setTheme('dark')}>Dark</button>\n * <button onClick={() => setTheme('light')}>Light</button>\n * </>\n * )\n * ```\n */\nexport function useThemeByDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: {\n\t\tattributeName: `data-${string}`\n\t\tdefaultTheme?: keyof Themes | undefined\n\t\telement?: Element | undefined\n\t}\n): [keyof Themes | undefined, (theme: keyof Themes) => void] {\n\tconst element =\n\t\toptions.element ?? (typeof document !== 'undefined' ? document.documentElement : undefined)\n\tconst defaultTheme = options.defaultTheme\n\tconst attributeName = options.attributeName\n\n\tconst store = useMemo(\n\t\t() =>\n\t\t\tdataAttributeThemeStore(themes, {\n\t\t\t\tattributeName,\n\t\t\t\telement\n\t\t\t}),\n\t\t[element, themes, attributeName]\n\t)\n\n\tconst [theme, setThemeState] = useState<keyof Themes | undefined>(() => {\n\t\tif (element) {\n\t\t\tconst attrValue = getDataAttribute(attributeName, element)\n\t\t\tconst resolved = resolveThemeFromDataAttribute(themes, attrValue)\n\t\t\treturn resolved ?? defaultTheme\n\t\t}\n\t\treturn defaultTheme\n\t})\n\n\tuseEffect(() => {\n\t\tif (!element) return\n\t\tconst unobserve = observeThemeFromStores([store], defaultTheme, setThemeState)\n\t\treturn unobserve\n\t}, [element, store, defaultTheme])\n\n\tconst setTheme = useCallback(\n\t\t(themeKey: keyof Themes) => {\n\t\t\tif (element) {\n\t\t\t\tsetThemeToStores([store], themeEntry(themes, themeKey))\n\t\t\t}\n\t\t},\n\t\t[element, store, themes]\n\t)\n\n\treturn [theme, setTheme]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,wBACf,QACA,SAK4D;CAC5D,MAAM,UACL,QAAQ,YAAY,OAAO,aAAa,cAAc,SAAS,kBAAkB;CAClF,MAAM,eAAe,QAAQ;CAC7B,MAAM,gBAAgB,QAAQ;CAE9B,MAAM,iCAEJA,2DAAwB,QAAQ;EAC/B;EACA;EACA,CAAC,EACH;EAAC;EAAS;EAAQ;EAAc,CAChC;CAED,MAAM,CAAC,OAAO,2CAA0D;AACvE,MAAI,QAGH,QADiBC,wEAA8B,QAD7BC,4CAAiB,eAAe,QAAQ,CACO,IAC9C;AAEpB,SAAO;GACN;AAEF,4BAAgB;AACf,MAAI,CAAC,QAAS;AAEd,SADkBC,yDAAuB,CAAC,MAAM,EAAE,cAAc,cAAc;IAE5E;EAAC;EAAS;EAAO;EAAa,CAAC;AAWlC,QAAO,CAAC,+BARN,aAA2B;AAC3B,MAAI,QACH,8CAAiB,CAAC,MAAM,EAAEC,+BAAW,QAAQ,SAAS,CAAC;IAGzD;EAAC;EAAS;EAAO;EAAO,CACxB,CAEuB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ThemeMap } from "../../theme/theme-map.types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/react/hooks/use-theme-by-data-attribute.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* React hook that returns the current theme (from element data attribute) and a setter.
|
|
7
|
+
* Subscribes to data attribute changes on the element so the returned theme stays in sync.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to their data attribute values
|
|
10
|
+
* @param options.attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
+
* @param options.defaultTheme - Fallback theme key when no matching attribute value is found
|
|
12
|
+
* @param options.element - Element to read/set theme on (defaults to document.documentElement)
|
|
13
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
18
|
+
* const [theme, setTheme] = useThemeByDataAttribute(themes, {
|
|
19
|
+
* attributeName: 'data-theme',
|
|
20
|
+
* defaultTheme: 'light'
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <>
|
|
25
|
+
* <span>Current: {theme}</span>
|
|
26
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
27
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
28
|
+
* </>
|
|
29
|
+
* )
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function useThemeByDataAttribute<Themes extends ThemeMap>(themes: Themes, options: {
|
|
33
|
+
attributeName: `data-${string}`;
|
|
34
|
+
defaultTheme?: keyof Themes | undefined;
|
|
35
|
+
element?: Element | undefined;
|
|
36
|
+
}): [keyof Themes | undefined, (theme: keyof Themes) => void];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { useThemeByDataAttribute };
|
|
39
|
+
//# sourceMappingURL=use-theme-by-data-attribute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-data-attribute.d.cts","names":[],"sources":["../../../src/react/hooks/use-theme-by-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,uCAAuC,kBAC9C;;uBAGc;YACX;WAEF,kCAAkC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ThemeMap } from "../../theme/theme-map.types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/react/hooks/use-theme-by-data-attribute.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* React hook that returns the current theme (from element data attribute) and a setter.
|
|
7
|
+
* Subscribes to data attribute changes on the element so the returned theme stays in sync.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to their data attribute values
|
|
10
|
+
* @param options.attributeName - Data attribute name (e.g. `data-theme`)
|
|
11
|
+
* @param options.defaultTheme - Fallback theme key when no matching attribute value is found
|
|
12
|
+
* @param options.element - Element to read/set theme on (defaults to document.documentElement)
|
|
13
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
18
|
+
* const [theme, setTheme] = useThemeByDataAttribute(themes, {
|
|
19
|
+
* attributeName: 'data-theme',
|
|
20
|
+
* defaultTheme: 'light'
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <>
|
|
25
|
+
* <span>Current: {theme}</span>
|
|
26
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
27
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
28
|
+
* </>
|
|
29
|
+
* )
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function useThemeByDataAttribute<Themes extends ThemeMap>(themes: Themes, options: {
|
|
33
|
+
attributeName: `data-${string}`;
|
|
34
|
+
defaultTheme?: keyof Themes | undefined;
|
|
35
|
+
element?: Element | undefined;
|
|
36
|
+
}): [keyof Themes | undefined, (theme: keyof Themes) => void];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { useThemeByDataAttribute };
|
|
39
|
+
//# sourceMappingURL=use-theme-by-data-attribute.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-data-attribute.d.mts","names":[],"sources":["../../../src/react/hooks/use-theme-by-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,uCAAuC,kBAC9C;;uBAGc;YACX;WAEF,kCAAkC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getDataAttribute } from "../../attributes/get-data-attribute.mjs";
|
|
2
|
+
import { observeThemeFromStores } from "../../theme/_utils/observe-theme-from-stores.mjs";
|
|
3
|
+
import { setThemeToStores } from "../../theme/_utils/set-theme-to-stores.mjs";
|
|
4
|
+
import { themeEntry } from "../../theme/theme-entry.mjs";
|
|
5
|
+
import { resolveThemeFromDataAttribute } from "../../theme/data-attribute/resolve-theme-from-data-attribute.mjs";
|
|
6
|
+
import { dataAttributeThemeStore } from "../../theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
+
|
|
9
|
+
//#region src/react/hooks/use-theme-by-data-attribute.ts
|
|
10
|
+
/**
|
|
11
|
+
* React hook that returns the current theme (from element data attribute) and a setter.
|
|
12
|
+
* Subscribes to data attribute changes on the element so the returned theme stays in sync.
|
|
13
|
+
*
|
|
14
|
+
* @param themes - Record mapping theme keys to their data attribute values
|
|
15
|
+
* @param options.attributeName - Data attribute name (e.g. `data-theme`)
|
|
16
|
+
* @param options.defaultTheme - Fallback theme key when no matching attribute value is found
|
|
17
|
+
* @param options.element - Element to read/set theme on (defaults to document.documentElement)
|
|
18
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
23
|
+
* const [theme, setTheme] = useThemeByDataAttribute(themes, {
|
|
24
|
+
* attributeName: 'data-theme',
|
|
25
|
+
* defaultTheme: 'light'
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <>
|
|
30
|
+
* <span>Current: {theme}</span>
|
|
31
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
32
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
33
|
+
* </>
|
|
34
|
+
* )
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function useThemeByDataAttribute(themes, options) {
|
|
38
|
+
const element = options.element ?? (typeof document !== "undefined" ? document.documentElement : void 0);
|
|
39
|
+
const defaultTheme = options.defaultTheme;
|
|
40
|
+
const attributeName = options.attributeName;
|
|
41
|
+
const store = useMemo(() => dataAttributeThemeStore(themes, {
|
|
42
|
+
attributeName,
|
|
43
|
+
element
|
|
44
|
+
}), [
|
|
45
|
+
element,
|
|
46
|
+
themes,
|
|
47
|
+
attributeName
|
|
48
|
+
]);
|
|
49
|
+
const [theme, setThemeState] = useState(() => {
|
|
50
|
+
if (element) return resolveThemeFromDataAttribute(themes, getDataAttribute(attributeName, element)) ?? defaultTheme;
|
|
51
|
+
return defaultTheme;
|
|
52
|
+
});
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!element) return;
|
|
55
|
+
return observeThemeFromStores([store], defaultTheme, setThemeState);
|
|
56
|
+
}, [
|
|
57
|
+
element,
|
|
58
|
+
store,
|
|
59
|
+
defaultTheme
|
|
60
|
+
]);
|
|
61
|
+
return [theme, useCallback((themeKey) => {
|
|
62
|
+
if (element) setThemeToStores([store], themeEntry(themes, themeKey));
|
|
63
|
+
}, [
|
|
64
|
+
element,
|
|
65
|
+
store,
|
|
66
|
+
themes
|
|
67
|
+
])];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { useThemeByDataAttribute };
|
|
72
|
+
//# sourceMappingURL=use-theme-by-data-attribute.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-data-attribute.mjs","names":[],"sources":["../../../src/react/hooks/use-theme-by-data-attribute.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react'\nimport { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport { observeThemeFromStores } from '../../theme/_utils/observe-theme-from-stores.ts'\nimport { setThemeToStores } from '../../theme/_utils/set-theme-to-stores.ts'\nimport { resolveThemeFromDataAttribute } from '../../theme/data-attribute/resolve-theme-from-data-attribute.ts'\nimport { themeEntry } from '../../theme/theme-entry.ts'\nimport type { ThemeMap } from '../../theme/theme-map.types.ts'\nimport { dataAttributeThemeStore } from '../../theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts'\n\n/**\n * React hook that returns the current theme (from element data attribute) and a setter.\n * Subscribes to data attribute changes on the element so the returned theme stays in sync.\n *\n * @param themes - Record mapping theme keys to their data attribute values\n * @param options.attributeName - Data attribute name (e.g. `data-theme`)\n * @param options.defaultTheme - Fallback theme key when no matching attribute value is found\n * @param options.element - Element to read/set theme on (defaults to document.documentElement)\n * @returns Tuple of [currentTheme, setTheme]\n *\n * @example\n * ```tsx\n * const themes = { light: 'theme-light', dark: 'theme-dark' }\n * const [theme, setTheme] = useThemeByDataAttribute(themes, {\n * attributeName: 'data-theme',\n * defaultTheme: 'light'\n * })\n *\n * return (\n * <>\n * <span>Current: {theme}</span>\n * <button onClick={() => setTheme('dark')}>Dark</button>\n * <button onClick={() => setTheme('light')}>Light</button>\n * </>\n * )\n * ```\n */\nexport function useThemeByDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: {\n\t\tattributeName: `data-${string}`\n\t\tdefaultTheme?: keyof Themes | undefined\n\t\telement?: Element | undefined\n\t}\n): [keyof Themes | undefined, (theme: keyof Themes) => void] {\n\tconst element =\n\t\toptions.element ?? (typeof document !== 'undefined' ? document.documentElement : undefined)\n\tconst defaultTheme = options.defaultTheme\n\tconst attributeName = options.attributeName\n\n\tconst store = useMemo(\n\t\t() =>\n\t\t\tdataAttributeThemeStore(themes, {\n\t\t\t\tattributeName,\n\t\t\t\telement\n\t\t\t}),\n\t\t[element, themes, attributeName]\n\t)\n\n\tconst [theme, setThemeState] = useState<keyof Themes | undefined>(() => {\n\t\tif (element) {\n\t\t\tconst attrValue = getDataAttribute(attributeName, element)\n\t\t\tconst resolved = resolveThemeFromDataAttribute(themes, attrValue)\n\t\t\treturn resolved ?? defaultTheme\n\t\t}\n\t\treturn defaultTheme\n\t})\n\n\tuseEffect(() => {\n\t\tif (!element) return\n\t\tconst unobserve = observeThemeFromStores([store], defaultTheme, setThemeState)\n\t\treturn unobserve\n\t}, [element, store, defaultTheme])\n\n\tconst setTheme = useCallback(\n\t\t(themeKey: keyof Themes) => {\n\t\t\tif (element) {\n\t\t\t\tsetThemeToStores([store], themeEntry(themes, themeKey))\n\t\t\t}\n\t\t},\n\t\t[element, store, themes]\n\t)\n\n\treturn [theme, setTheme]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,wBACf,QACA,SAK4D;CAC5D,MAAM,UACL,QAAQ,YAAY,OAAO,aAAa,cAAc,SAAS,kBAAkB;CAClF,MAAM,eAAe,QAAQ;CAC7B,MAAM,gBAAgB,QAAQ;CAE9B,MAAM,QAAQ,cAEZ,wBAAwB,QAAQ;EAC/B;EACA;EACA,CAAC,EACH;EAAC;EAAS;EAAQ;EAAc,CAChC;CAED,MAAM,CAAC,OAAO,iBAAiB,eAAyC;AACvE,MAAI,QAGH,QADiB,8BAA8B,QAD7B,iBAAiB,eAAe,QAAQ,CACO,IAC9C;AAEpB,SAAO;GACN;AAEF,iBAAgB;AACf,MAAI,CAAC,QAAS;AAEd,SADkB,uBAAuB,CAAC,MAAM,EAAE,cAAc,cAAc;IAE5E;EAAC;EAAS;EAAO;EAAa,CAAC;AAWlC,QAAO,CAAC,OATS,aACf,aAA2B;AAC3B,MAAI,QACH,kBAAiB,CAAC,MAAM,EAAE,WAAW,QAAQ,SAAS,CAAC;IAGzD;EAAC;EAAS;EAAO;EAAO,CACxB,CAEuB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_observe_theme_from_stores = require('../../theme/_utils/observe-theme-from-stores.cjs');
|
|
3
|
+
const require_set_theme_to_stores = require('../../theme/_utils/set-theme-to-stores.cjs');
|
|
4
|
+
const require_theme_entry = require('../../theme/theme-entry.cjs');
|
|
5
|
+
const require_parse_stored_theme = require('../../theme/_utils/parse-stored-theme.cjs');
|
|
6
|
+
const require_local_storage_theme_store = require('../../theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs');
|
|
7
|
+
let react = require("react");
|
|
8
|
+
|
|
9
|
+
//#region src/react/hooks/use-theme-by-local-storage.ts
|
|
10
|
+
/**
|
|
11
|
+
* React hook that returns the current theme (from localStorage) and a setter.
|
|
12
|
+
* Subscribes to storage changes so the returned theme stays in sync across tabs.
|
|
13
|
+
*
|
|
14
|
+
* @param themes - Record mapping theme keys to their values
|
|
15
|
+
* @param options.storageKey - localStorage key to persist the theme
|
|
16
|
+
* @param options.defaultTheme - Fallback theme key when no stored value is found
|
|
17
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
22
|
+
* const [theme, setTheme] = useThemeByLocalStorage(themes, {
|
|
23
|
+
* storageKey: 'app-theme',
|
|
24
|
+
* defaultTheme: 'light'
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* return (
|
|
28
|
+
* <>
|
|
29
|
+
* <span>Current: {theme}</span>
|
|
30
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
31
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
32
|
+
* </>
|
|
33
|
+
* )
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function useThemeByLocalStorage(themes, options) {
|
|
37
|
+
const { storageKey, defaultTheme } = options;
|
|
38
|
+
const store = (0, react.useMemo)(() => require_local_storage_theme_store.localStorageThemeStore(themes, { storageKey }), [themes, storageKey]);
|
|
39
|
+
const [theme, setThemeState] = (0, react.useState)(() => {
|
|
40
|
+
if (typeof window !== "undefined" && window.localStorage) return require_parse_stored_theme.parseStoredTheme(themes, window.localStorage.getItem(storageKey)) ?? defaultTheme;
|
|
41
|
+
return defaultTheme;
|
|
42
|
+
});
|
|
43
|
+
(0, react.useEffect)(() => {
|
|
44
|
+
return require_observe_theme_from_stores.observeThemeFromStores([store], defaultTheme, setThemeState);
|
|
45
|
+
}, [store, defaultTheme]);
|
|
46
|
+
return [theme, (0, react.useCallback)((themeKey) => {
|
|
47
|
+
require_set_theme_to_stores.setThemeToStores([store], require_theme_entry.themeEntry(themes, themeKey));
|
|
48
|
+
}, [store, themes])];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.useThemeByLocalStorage = useThemeByLocalStorage;
|
|
53
|
+
//# sourceMappingURL=use-theme-by-local-storage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-local-storage.cjs","names":["localStorageThemeStore","parseStoredTheme","observeThemeFromStores","themeEntry"],"sources":["../../../src/react/hooks/use-theme-by-local-storage.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react'\nimport { observeThemeFromStores } from '../../theme/_utils/observe-theme-from-stores.ts'\nimport { parseStoredTheme } from '../../theme/_utils/parse-stored-theme.ts'\nimport { setThemeToStores } from '../../theme/_utils/set-theme-to-stores.ts'\nimport { themeEntry } from '../../theme/theme-entry.ts'\nimport type { ThemeMap } from '../../theme/theme-map.types.ts'\nimport { localStorageThemeStore } from '../../theme/theme-store/local-storage-theme-store/local-storage-theme-store.ts'\n\n/**\n * React hook that returns the current theme (from localStorage) and a setter.\n * Subscribes to storage changes so the returned theme stays in sync across tabs.\n *\n * @param themes - Record mapping theme keys to their values\n * @param options.storageKey - localStorage key to persist the theme\n * @param options.defaultTheme - Fallback theme key when no stored value is found\n * @returns Tuple of [currentTheme, setTheme]\n *\n * @example\n * ```tsx\n * const themes = { light: 'theme-light', dark: 'theme-dark' }\n * const [theme, setTheme] = useThemeByLocalStorage(themes, {\n * storageKey: 'app-theme',\n * defaultTheme: 'light'\n * })\n *\n * return (\n * <>\n * <span>Current: {theme}</span>\n * <button onClick={() => setTheme('dark')}>Dark</button>\n * <button onClick={() => setTheme('light')}>Light</button>\n * </>\n * )\n * ```\n */\nexport function useThemeByLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: {\n\t\tstorageKey: string\n\t\tdefaultTheme?: keyof Themes | undefined\n\t}\n): [keyof Themes | undefined, (theme: keyof Themes) => void] {\n\tconst { storageKey, defaultTheme } = options\n\n\tconst store = useMemo(() => localStorageThemeStore(themes, { storageKey }), [themes, storageKey])\n\n\tconst [theme, setThemeState] = useState<keyof Themes | undefined>(() => {\n\t\tif (typeof window !== 'undefined' && window.localStorage) {\n\t\t\tconst stored = window.localStorage.getItem(storageKey)\n\t\t\tconst resolved = parseStoredTheme(themes, stored)\n\t\t\treturn resolved ?? defaultTheme\n\t\t}\n\t\treturn defaultTheme\n\t})\n\n\tuseEffect(() => {\n\t\tconst unobserve = observeThemeFromStores([store], defaultTheme, setThemeState)\n\t\treturn unobserve\n\t}, [store, defaultTheme])\n\n\tconst setTheme = useCallback(\n\t\t(themeKey: keyof Themes) => {\n\t\t\tsetThemeToStores([store], themeEntry(themes, themeKey))\n\t\t},\n\t\t[store, themes]\n\t)\n\n\treturn [theme, setTheme]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,uBACf,QACA,SAI4D;CAC5D,MAAM,EAAE,YAAY,iBAAiB;CAErC,MAAM,iCAAsBA,yDAAuB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,QAAQ,WAAW,CAAC;CAEjG,MAAM,CAAC,OAAO,2CAA0D;AACvE,MAAI,OAAO,WAAW,eAAe,OAAO,aAG3C,QADiBC,4CAAiB,QADnB,OAAO,aAAa,QAAQ,WAAW,CACL,IAC9B;AAEpB,SAAO;GACN;AAEF,4BAAgB;AAEf,SADkBC,yDAAuB,CAAC,MAAM,EAAE,cAAc,cAAc;IAE5E,CAAC,OAAO,aAAa,CAAC;AASzB,QAAO,CAAC,+BANN,aAA2B;AAC3B,+CAAiB,CAAC,MAAM,EAAEC,+BAAW,QAAQ,SAAS,CAAC;IAExD,CAAC,OAAO,OAAO,CACf,CAEuB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ThemeMap } from "../../theme/theme-map.types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/react/hooks/use-theme-by-local-storage.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* React hook that returns the current theme (from localStorage) and a setter.
|
|
7
|
+
* Subscribes to storage changes so the returned theme stays in sync across tabs.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to their values
|
|
10
|
+
* @param options.storageKey - localStorage key to persist the theme
|
|
11
|
+
* @param options.defaultTheme - Fallback theme key when no stored value is found
|
|
12
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
17
|
+
* const [theme, setTheme] = useThemeByLocalStorage(themes, {
|
|
18
|
+
* storageKey: 'app-theme',
|
|
19
|
+
* defaultTheme: 'light'
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <>
|
|
24
|
+
* <span>Current: {theme}</span>
|
|
25
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
26
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
27
|
+
* </>
|
|
28
|
+
* )
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function useThemeByLocalStorage<Themes extends ThemeMap>(themes: Themes, options: {
|
|
32
|
+
storageKey: string;
|
|
33
|
+
defaultTheme?: keyof Themes | undefined;
|
|
34
|
+
}): [keyof Themes | undefined, (theme: keyof Themes) => void];
|
|
35
|
+
//#endregion
|
|
36
|
+
export { useThemeByLocalStorage };
|
|
37
|
+
//# sourceMappingURL=use-theme-by-local-storage.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-local-storage.d.cts","names":[],"sources":["../../../src/react/hooks/use-theme-by-local-storage.ts"],"sourcesContent":[],"mappings":";;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C;;uBAGc;WAEb,kCAAkC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ThemeMap } from "../../theme/theme-map.types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/react/hooks/use-theme-by-local-storage.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* React hook that returns the current theme (from localStorage) and a setter.
|
|
7
|
+
* Subscribes to storage changes so the returned theme stays in sync across tabs.
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to their values
|
|
10
|
+
* @param options.storageKey - localStorage key to persist the theme
|
|
11
|
+
* @param options.defaultTheme - Fallback theme key when no stored value is found
|
|
12
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
17
|
+
* const [theme, setTheme] = useThemeByLocalStorage(themes, {
|
|
18
|
+
* storageKey: 'app-theme',
|
|
19
|
+
* defaultTheme: 'light'
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <>
|
|
24
|
+
* <span>Current: {theme}</span>
|
|
25
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
26
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
27
|
+
* </>
|
|
28
|
+
* )
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function useThemeByLocalStorage<Themes extends ThemeMap>(themes: Themes, options: {
|
|
32
|
+
storageKey: string;
|
|
33
|
+
defaultTheme?: keyof Themes | undefined;
|
|
34
|
+
}): [keyof Themes | undefined, (theme: keyof Themes) => void];
|
|
35
|
+
//#endregion
|
|
36
|
+
export { useThemeByLocalStorage };
|
|
37
|
+
//# sourceMappingURL=use-theme-by-local-storage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-local-storage.d.mts","names":[],"sources":["../../../src/react/hooks/use-theme-by-local-storage.ts"],"sourcesContent":[],"mappings":";;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C;;uBAGc;WAEb,kCAAkC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { observeThemeFromStores } from "../../theme/_utils/observe-theme-from-stores.mjs";
|
|
2
|
+
import { setThemeToStores } from "../../theme/_utils/set-theme-to-stores.mjs";
|
|
3
|
+
import { themeEntry } from "../../theme/theme-entry.mjs";
|
|
4
|
+
import { parseStoredTheme } from "../../theme/_utils/parse-stored-theme.mjs";
|
|
5
|
+
import { localStorageThemeStore } from "../../theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs";
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
+
|
|
8
|
+
//#region src/react/hooks/use-theme-by-local-storage.ts
|
|
9
|
+
/**
|
|
10
|
+
* React hook that returns the current theme (from localStorage) and a setter.
|
|
11
|
+
* Subscribes to storage changes so the returned theme stays in sync across tabs.
|
|
12
|
+
*
|
|
13
|
+
* @param themes - Record mapping theme keys to their values
|
|
14
|
+
* @param options.storageKey - localStorage key to persist the theme
|
|
15
|
+
* @param options.defaultTheme - Fallback theme key when no stored value is found
|
|
16
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const themes = { light: 'theme-light', dark: 'theme-dark' }
|
|
21
|
+
* const [theme, setTheme] = useThemeByLocalStorage(themes, {
|
|
22
|
+
* storageKey: 'app-theme',
|
|
23
|
+
* defaultTheme: 'light'
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* return (
|
|
27
|
+
* <>
|
|
28
|
+
* <span>Current: {theme}</span>
|
|
29
|
+
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
30
|
+
* <button onClick={() => setTheme('light')}>Light</button>
|
|
31
|
+
* </>
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function useThemeByLocalStorage(themes, options) {
|
|
36
|
+
const { storageKey, defaultTheme } = options;
|
|
37
|
+
const store = useMemo(() => localStorageThemeStore(themes, { storageKey }), [themes, storageKey]);
|
|
38
|
+
const [theme, setThemeState] = useState(() => {
|
|
39
|
+
if (typeof window !== "undefined" && window.localStorage) return parseStoredTheme(themes, window.localStorage.getItem(storageKey)) ?? defaultTheme;
|
|
40
|
+
return defaultTheme;
|
|
41
|
+
});
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
return observeThemeFromStores([store], defaultTheme, setThemeState);
|
|
44
|
+
}, [store, defaultTheme]);
|
|
45
|
+
return [theme, useCallback((themeKey) => {
|
|
46
|
+
setThemeToStores([store], themeEntry(themes, themeKey));
|
|
47
|
+
}, [store, themes])];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { useThemeByLocalStorage };
|
|
52
|
+
//# sourceMappingURL=use-theme-by-local-storage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-by-local-storage.mjs","names":[],"sources":["../../../src/react/hooks/use-theme-by-local-storage.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react'\nimport { observeThemeFromStores } from '../../theme/_utils/observe-theme-from-stores.ts'\nimport { parseStoredTheme } from '../../theme/_utils/parse-stored-theme.ts'\nimport { setThemeToStores } from '../../theme/_utils/set-theme-to-stores.ts'\nimport { themeEntry } from '../../theme/theme-entry.ts'\nimport type { ThemeMap } from '../../theme/theme-map.types.ts'\nimport { localStorageThemeStore } from '../../theme/theme-store/local-storage-theme-store/local-storage-theme-store.ts'\n\n/**\n * React hook that returns the current theme (from localStorage) and a setter.\n * Subscribes to storage changes so the returned theme stays in sync across tabs.\n *\n * @param themes - Record mapping theme keys to their values\n * @param options.storageKey - localStorage key to persist the theme\n * @param options.defaultTheme - Fallback theme key when no stored value is found\n * @returns Tuple of [currentTheme, setTheme]\n *\n * @example\n * ```tsx\n * const themes = { light: 'theme-light', dark: 'theme-dark' }\n * const [theme, setTheme] = useThemeByLocalStorage(themes, {\n * storageKey: 'app-theme',\n * defaultTheme: 'light'\n * })\n *\n * return (\n * <>\n * <span>Current: {theme}</span>\n * <button onClick={() => setTheme('dark')}>Dark</button>\n * <button onClick={() => setTheme('light')}>Light</button>\n * </>\n * )\n * ```\n */\nexport function useThemeByLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: {\n\t\tstorageKey: string\n\t\tdefaultTheme?: keyof Themes | undefined\n\t}\n): [keyof Themes | undefined, (theme: keyof Themes) => void] {\n\tconst { storageKey, defaultTheme } = options\n\n\tconst store = useMemo(() => localStorageThemeStore(themes, { storageKey }), [themes, storageKey])\n\n\tconst [theme, setThemeState] = useState<keyof Themes | undefined>(() => {\n\t\tif (typeof window !== 'undefined' && window.localStorage) {\n\t\t\tconst stored = window.localStorage.getItem(storageKey)\n\t\t\tconst resolved = parseStoredTheme(themes, stored)\n\t\t\treturn resolved ?? defaultTheme\n\t\t}\n\t\treturn defaultTheme\n\t})\n\n\tuseEffect(() => {\n\t\tconst unobserve = observeThemeFromStores([store], defaultTheme, setThemeState)\n\t\treturn unobserve\n\t}, [store, defaultTheme])\n\n\tconst setTheme = useCallback(\n\t\t(themeKey: keyof Themes) => {\n\t\t\tsetThemeToStores([store], themeEntry(themes, themeKey))\n\t\t},\n\t\t[store, themes]\n\t)\n\n\treturn [theme, setTheme]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,uBACf,QACA,SAI4D;CAC5D,MAAM,EAAE,YAAY,iBAAiB;CAErC,MAAM,QAAQ,cAAc,uBAAuB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,QAAQ,WAAW,CAAC;CAEjG,MAAM,CAAC,OAAO,iBAAiB,eAAyC;AACvE,MAAI,OAAO,WAAW,eAAe,OAAO,aAG3C,QADiB,iBAAiB,QADnB,OAAO,aAAa,QAAQ,WAAW,CACL,IAC9B;AAEpB,SAAO;GACN;AAEF,iBAAgB;AAEf,SADkB,uBAAuB,CAAC,MAAM,EAAE,cAAc,cAAc;IAE5E,CAAC,OAAO,aAAa,CAAC;AASzB,QAAO,CAAC,OAPS,aACf,aAA2B;AAC3B,mBAAiB,CAAC,MAAM,EAAE,WAAW,QAAQ,SAAS,CAAC;IAExD,CAAC,OAAO,OAAO,CACf,CAEuB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_create_theme_hook = require('../theme/create-theme-hook.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
|
|
5
|
+
//#region src/react/hooks/use-theme-stores.ts
|
|
6
|
+
/**
|
|
7
|
+
* React hook that returns the current theme and a setter for composed theme stores.
|
|
8
|
+
* Delegates to createThemeHook internally.
|
|
9
|
+
*
|
|
10
|
+
* Accepts `stores` in two forms:
|
|
11
|
+
* - **Factory (recommended):** `() => [store1, store2, ...]` — run once on mount; no memoization needed.
|
|
12
|
+
* - **Array:** `[store1, store2, ...]` — must be memoized or ref-stable; recreating the array each render breaks subscriptions.
|
|
13
|
+
*
|
|
14
|
+
* @param themes - ThemeMap mapping theme keys to their values (e.g. CSS class names)
|
|
15
|
+
* @param stores - Array or factory returning 1–8 theme stores (see ComposeThemeStoreEntry)
|
|
16
|
+
* @param options.defaultTheme - Fallback theme key when stores return empty; also used for SSR
|
|
17
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // Factory form — no memoization needed
|
|
22
|
+
* const [theme, setTheme] = useThemeStores(
|
|
23
|
+
* themes,
|
|
24
|
+
* () => [inMemoryThemeStore(themes)],
|
|
25
|
+
* { defaultTheme: 'light' }
|
|
26
|
+
* )
|
|
27
|
+
*
|
|
28
|
+
* // Array form — must be memoized
|
|
29
|
+
* const stores = useMemo(() => [localStorageStore], [])
|
|
30
|
+
* const [theme, setTheme] = useThemeStores(themes, stores, { defaultTheme: 'light' })
|
|
31
|
+
* setTheme('dark')
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function useThemeStores(themes, stores, options) {
|
|
35
|
+
return require_create_theme_hook.createThemeHook(themes, (0, react.useMemo)(() => typeof stores === "function" ? stores() : stores, []), options)(options?.defaultTheme);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.useThemeStores = useThemeStores;
|
|
40
|
+
//# sourceMappingURL=use-theme-stores.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-stores.cjs","names":["createThemeHook"],"sources":["../../../src/react/hooks/use-theme-stores.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport type {\n\tComposeThemeStoreEntry,\n\tComposeThemeStoresOptions\n} from '../../theme/compose-theme-stores.ts'\nimport type { ThemeMap } from '../../theme/theme-map.types.ts'\nimport type { ThemeStoreFactory } from '../../theme/theme-store/theme-store-factory.types.ts'\nimport { createThemeHook } from '../theme/create-theme-hook.ts'\n\ntype ThemeStoresTuple<\n\tThemes extends ThemeMap,\n\tA extends ThemeStoreFactory<Themes> = never,\n\tB extends ThemeStoreFactory<Themes> = never,\n\tC extends ThemeStoreFactory<Themes> = never,\n\tD extends ThemeStoreFactory<Themes> = never,\n\tE extends ThemeStoreFactory<Themes> = never,\n\tF extends ThemeStoreFactory<Themes> = never,\n\tG extends ThemeStoreFactory<Themes> = never,\n\tH extends ThemeStoreFactory<Themes> = never\n> = readonly [\n\tstore1: ComposeThemeStoreEntry<Themes, A>,\n\tstore2?: ComposeThemeStoreEntry<Themes, B>,\n\tstore3?: ComposeThemeStoreEntry<Themes, C>,\n\tstore4?: ComposeThemeStoreEntry<Themes, D>,\n\tstore5?: ComposeThemeStoreEntry<Themes, E>,\n\tstore6?: ComposeThemeStoreEntry<Themes, F>,\n\tstore7?: ComposeThemeStoreEntry<Themes, G>,\n\tstore8?: ComposeThemeStoreEntry<Themes, H>\n]\n\n/**\n * React hook that returns the current theme and a setter for composed theme stores.\n * Delegates to createThemeHook internally.\n *\n * Accepts `stores` in two forms:\n * - **Factory (recommended):** `() => [store1, store2, ...]` — run once on mount; no memoization needed.\n * - **Array:** `[store1, store2, ...]` — must be memoized or ref-stable; recreating the array each render breaks subscriptions.\n *\n * @param themes - ThemeMap mapping theme keys to their values (e.g. CSS class names)\n * @param stores - Array or factory returning 1–8 theme stores (see ComposeThemeStoreEntry)\n * @param options.defaultTheme - Fallback theme key when stores return empty; also used for SSR\n * @returns Tuple of [currentTheme, setTheme]\n *\n * @example\n * ```tsx\n * // Factory form — no memoization needed\n * const [theme, setTheme] = useThemeStores(\n * themes,\n * () => [inMemoryThemeStore(themes)],\n * { defaultTheme: 'light' }\n * )\n *\n * // Array form — must be memoized\n * const stores = useMemo(() => [localStorageStore], [])\n * const [theme, setTheme] = useThemeStores(themes, stores, { defaultTheme: 'light' })\n * setTheme('dark')\n * ```\n */\nexport function useThemeStores<\n\tThemes extends ThemeMap,\n\tA extends ThemeStoreFactory<Themes> = never,\n\tB extends ThemeStoreFactory<Themes> = never,\n\tC extends ThemeStoreFactory<Themes> = never,\n\tD extends ThemeStoreFactory<Themes> = never,\n\tE extends ThemeStoreFactory<Themes> = never,\n\tF extends ThemeStoreFactory<Themes> = never,\n\tG extends ThemeStoreFactory<Themes> = never,\n\tH extends ThemeStoreFactory<Themes> = never\n>(\n\tthemes: Themes,\n\tstores:\n\t\t| ThemeStoresTuple<Themes, A, B, C, D, E, F, G, H>\n\t\t| (() => ThemeStoresTuple<Themes, A, B, C, D, E, F, G, H>),\n\toptions?: ComposeThemeStoresOptions<Themes>\n): [keyof Themes | undefined, (theme: keyof Themes) => void] {\n\tconst resolvedStores = useMemo(\n\t\t() => (typeof stores === 'function' ? stores() : stores),\n\t\t// Empty deps: factory runs once on mount; array form must be ref-stable (user memoizes)\n\t\t[]\n\t)\n\tconst useTheme = createThemeHook<Themes, A, B, C, D, E, F, G, H>(themes, resolvedStores, options)\n\treturn useTheme(options?.defaultTheme)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,eAWf,QACA,QAGA,SAC4D;AAO5D,QADiBA,0CAAgD,iCAJzD,OAAO,WAAW,aAAa,QAAQ,GAAG,QAEjD,EAAE,CACF,EACwF,QAAQ,CACjF,SAAS,aAAa"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ThemeMap } from "../../theme/theme-map.types.cjs";
|
|
2
|
+
import { ThemeStoreFactory } from "../../theme/theme-store/theme-store-factory.types.cjs";
|
|
3
|
+
import { ComposeThemeStoreEntry, ComposeThemeStoresOptions } from "../../theme/compose-theme-stores.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/react/hooks/use-theme-stores.d.ts
|
|
6
|
+
type ThemeStoresTuple<Themes extends ThemeMap, A extends ThemeStoreFactory<Themes> = never, B extends ThemeStoreFactory<Themes> = never, C extends ThemeStoreFactory<Themes> = never, D extends ThemeStoreFactory<Themes> = never, E extends ThemeStoreFactory<Themes> = never, F extends ThemeStoreFactory<Themes> = never, G extends ThemeStoreFactory<Themes> = never, H extends ThemeStoreFactory<Themes> = never> = readonly [store1: ComposeThemeStoreEntry<Themes, A>, store2?: ComposeThemeStoreEntry<Themes, B>, store3?: ComposeThemeStoreEntry<Themes, C>, store4?: ComposeThemeStoreEntry<Themes, D>, store5?: ComposeThemeStoreEntry<Themes, E>, store6?: ComposeThemeStoreEntry<Themes, F>, store7?: ComposeThemeStoreEntry<Themes, G>, store8?: ComposeThemeStoreEntry<Themes, H>];
|
|
7
|
+
/**
|
|
8
|
+
* React hook that returns the current theme and a setter for composed theme stores.
|
|
9
|
+
* Delegates to createThemeHook internally.
|
|
10
|
+
*
|
|
11
|
+
* Accepts `stores` in two forms:
|
|
12
|
+
* - **Factory (recommended):** `() => [store1, store2, ...]` — run once on mount; no memoization needed.
|
|
13
|
+
* - **Array:** `[store1, store2, ...]` — must be memoized or ref-stable; recreating the array each render breaks subscriptions.
|
|
14
|
+
*
|
|
15
|
+
* @param themes - ThemeMap mapping theme keys to their values (e.g. CSS class names)
|
|
16
|
+
* @param stores - Array or factory returning 1–8 theme stores (see ComposeThemeStoreEntry)
|
|
17
|
+
* @param options.defaultTheme - Fallback theme key when stores return empty; also used for SSR
|
|
18
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* // Factory form — no memoization needed
|
|
23
|
+
* const [theme, setTheme] = useThemeStores(
|
|
24
|
+
* themes,
|
|
25
|
+
* () => [inMemoryThemeStore(themes)],
|
|
26
|
+
* { defaultTheme: 'light' }
|
|
27
|
+
* )
|
|
28
|
+
*
|
|
29
|
+
* // Array form — must be memoized
|
|
30
|
+
* const stores = useMemo(() => [localStorageStore], [])
|
|
31
|
+
* const [theme, setTheme] = useThemeStores(themes, stores, { defaultTheme: 'light' })
|
|
32
|
+
* setTheme('dark')
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function useThemeStores<Themes extends ThemeMap, A extends ThemeStoreFactory<Themes> = never, B extends ThemeStoreFactory<Themes> = never, C extends ThemeStoreFactory<Themes> = never, D extends ThemeStoreFactory<Themes> = never, E extends ThemeStoreFactory<Themes> = never, F extends ThemeStoreFactory<Themes> = never, G extends ThemeStoreFactory<Themes> = never, H extends ThemeStoreFactory<Themes> = never>(themes: Themes, stores: ThemeStoresTuple<Themes, A, B, C, D, E, F, G, H> | (() => ThemeStoresTuple<Themes, A, B, C, D, E, F, G, H>), options?: ComposeThemeStoresOptions<Themes>): [keyof Themes | undefined, (theme: keyof Themes) => void];
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useThemeStores };
|
|
38
|
+
//# sourceMappingURL=use-theme-stores.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-stores.d.cts","names":[],"sources":["../../../src/react/hooks/use-theme-stores.ts"],"sourcesContent":[],"mappings":";;;;;KASK,gCACW,oBACL,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,qCAEpB,uBAAuB,QAAQ,IAXnC,MAAA,GAYK,sBAZW,CAYY,MAZZ,EAYoB,CAZpB,CAAA,EACL,MAAA,GAYN,sBAZM,CAYiB,MAZjB,EAYyB,CAZzB,CAAA,EACa,MAAA,GAYnB,sBAZmB,CAYI,MAZJ,EAYY,CAZZ,CAAA,EAAlB,MAAA,GAaD,sBAbC,CAasB,MAbtB,EAa8B,CAb9B,CAAA,EACkB,MAAA,GAanB,sBAbmB,CAaI,MAbJ,EAaY,CAbZ,CAAA,EAAlB,MAAA,GAcD,sBAdC,CAcsB,MAdtB,EAc8B,CAd9B,CAAA,EACkB,MAAA,GAcnB,sBAdmB,CAcI,MAdJ,EAcY,CAdZ,CAAA,CAAlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAasB,iBAgCjB,cAhCiB,CAAA,eAiCjB,QAjCiB,EAAA,UAkCtB,iBAlCsB,CAkCJ,MAlCI,CAAA,GAAA,KAAA,EAAA,UAmCtB,iBAnCsB,CAmCJ,MAnCI,CAAA,GAAA,KAAA,EAAA,UAoCtB,iBApCsB,CAoCJ,MApCI,CAAA,GAAA,KAAA,EAAA,UAqCtB,iBArCsB,CAqCJ,MArCI,CAAA,GAAA,KAAA,EAAA,UAsCtB,iBAtCsB,CAsCJ,MAtCI,CAAA,GAAA,KAAA,EAAA,UAuCtB,iBAvCsB,CAuCJ,MAvCI,CAAA,GAAA,KAAA,EAAA,UAwCtB,iBAxCsB,CAwCJ,MAxCI,CAAA,GAAA,KAAA,EAAA,UAyCtB,iBAzCsB,CAyCJ,MAzCI,CAAA,GAAA,KAAA,CAAA,CAAA,MAAA,EA2CxB,MA3CwB,EAAA,MAAA,EA6C7B,gBA7C6B,CA6CZ,MA7CY,EA6CJ,CA7CI,EA6CD,CA7CC,EA6CE,CA7CF,EA6CK,CA7CL,EA6CQ,CA7CR,EA6CW,CA7CX,EA6Cc,CA7Cd,EA6CiB,CA7CjB,CAAA,GAAA,CAAA,GAAA,GA8CtB,gBA9CsB,CA8CL,MA9CK,EA8CG,CA9CH,EA8CM,CA9CN,EA8CS,CA9CT,EA8CY,CA9CZ,EA8Ce,CA9Cf,EA8CkB,CA9ClB,EA8CqB,CA9CrB,EA8CwB,CA9CxB,CAAA,CAAA,EAAA,OAAA,CAAA,EA+CtB,yBA/CsB,CA+CI,MA/CJ,CAAA,CAAA,EAAA,CAAA,MAgDvB,MAhDuB,GAAA,SAAA,EAAA,CAAA,KAAA,EAAA,MAgDW,MAhDX,EAAA,GAAA,IAAA,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ThemeMap } from "../../theme/theme-map.types.mjs";
|
|
2
|
+
import { ThemeStoreFactory } from "../../theme/theme-store/theme-store-factory.types.mjs";
|
|
3
|
+
import { ComposeThemeStoreEntry, ComposeThemeStoresOptions } from "../../theme/compose-theme-stores.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/react/hooks/use-theme-stores.d.ts
|
|
6
|
+
type ThemeStoresTuple<Themes extends ThemeMap, A extends ThemeStoreFactory<Themes> = never, B extends ThemeStoreFactory<Themes> = never, C extends ThemeStoreFactory<Themes> = never, D extends ThemeStoreFactory<Themes> = never, E extends ThemeStoreFactory<Themes> = never, F extends ThemeStoreFactory<Themes> = never, G extends ThemeStoreFactory<Themes> = never, H extends ThemeStoreFactory<Themes> = never> = readonly [store1: ComposeThemeStoreEntry<Themes, A>, store2?: ComposeThemeStoreEntry<Themes, B>, store3?: ComposeThemeStoreEntry<Themes, C>, store4?: ComposeThemeStoreEntry<Themes, D>, store5?: ComposeThemeStoreEntry<Themes, E>, store6?: ComposeThemeStoreEntry<Themes, F>, store7?: ComposeThemeStoreEntry<Themes, G>, store8?: ComposeThemeStoreEntry<Themes, H>];
|
|
7
|
+
/**
|
|
8
|
+
* React hook that returns the current theme and a setter for composed theme stores.
|
|
9
|
+
* Delegates to createThemeHook internally.
|
|
10
|
+
*
|
|
11
|
+
* Accepts `stores` in two forms:
|
|
12
|
+
* - **Factory (recommended):** `() => [store1, store2, ...]` — run once on mount; no memoization needed.
|
|
13
|
+
* - **Array:** `[store1, store2, ...]` — must be memoized or ref-stable; recreating the array each render breaks subscriptions.
|
|
14
|
+
*
|
|
15
|
+
* @param themes - ThemeMap mapping theme keys to their values (e.g. CSS class names)
|
|
16
|
+
* @param stores - Array or factory returning 1–8 theme stores (see ComposeThemeStoreEntry)
|
|
17
|
+
* @param options.defaultTheme - Fallback theme key when stores return empty; also used for SSR
|
|
18
|
+
* @returns Tuple of [currentTheme, setTheme]
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* // Factory form — no memoization needed
|
|
23
|
+
* const [theme, setTheme] = useThemeStores(
|
|
24
|
+
* themes,
|
|
25
|
+
* () => [inMemoryThemeStore(themes)],
|
|
26
|
+
* { defaultTheme: 'light' }
|
|
27
|
+
* )
|
|
28
|
+
*
|
|
29
|
+
* // Array form — must be memoized
|
|
30
|
+
* const stores = useMemo(() => [localStorageStore], [])
|
|
31
|
+
* const [theme, setTheme] = useThemeStores(themes, stores, { defaultTheme: 'light' })
|
|
32
|
+
* setTheme('dark')
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function useThemeStores<Themes extends ThemeMap, A extends ThemeStoreFactory<Themes> = never, B extends ThemeStoreFactory<Themes> = never, C extends ThemeStoreFactory<Themes> = never, D extends ThemeStoreFactory<Themes> = never, E extends ThemeStoreFactory<Themes> = never, F extends ThemeStoreFactory<Themes> = never, G extends ThemeStoreFactory<Themes> = never, H extends ThemeStoreFactory<Themes> = never>(themes: Themes, stores: ThemeStoresTuple<Themes, A, B, C, D, E, F, G, H> | (() => ThemeStoresTuple<Themes, A, B, C, D, E, F, G, H>), options?: ComposeThemeStoresOptions<Themes>): [keyof Themes | undefined, (theme: keyof Themes) => void];
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useThemeStores };
|
|
38
|
+
//# sourceMappingURL=use-theme-stores.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme-stores.d.mts","names":[],"sources":["../../../src/react/hooks/use-theme-stores.ts"],"sourcesContent":[],"mappings":";;;;;KASK,gCACW,oBACL,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,2BAClB,kBAAkB,qCAEpB,uBAAuB,QAAQ,IAXnC,MAAA,GAYK,sBAZW,CAYY,MAZZ,EAYoB,CAZpB,CAAA,EACL,MAAA,GAYN,sBAZM,CAYiB,MAZjB,EAYyB,CAZzB,CAAA,EACa,MAAA,GAYnB,sBAZmB,CAYI,MAZJ,EAYY,CAZZ,CAAA,EAAlB,MAAA,GAaD,sBAbC,CAasB,MAbtB,EAa8B,CAb9B,CAAA,EACkB,MAAA,GAanB,sBAbmB,CAaI,MAbJ,EAaY,CAbZ,CAAA,EAAlB,MAAA,GAcD,sBAdC,CAcsB,MAdtB,EAc8B,CAd9B,CAAA,EACkB,MAAA,GAcnB,sBAdmB,CAcI,MAdJ,EAcY,CAdZ,CAAA,CAAlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAasB,iBAgCjB,cAhCiB,CAAA,eAiCjB,QAjCiB,EAAA,UAkCtB,iBAlCsB,CAkCJ,MAlCI,CAAA,GAAA,KAAA,EAAA,UAmCtB,iBAnCsB,CAmCJ,MAnCI,CAAA,GAAA,KAAA,EAAA,UAoCtB,iBApCsB,CAoCJ,MApCI,CAAA,GAAA,KAAA,EAAA,UAqCtB,iBArCsB,CAqCJ,MArCI,CAAA,GAAA,KAAA,EAAA,UAsCtB,iBAtCsB,CAsCJ,MAtCI,CAAA,GAAA,KAAA,EAAA,UAuCtB,iBAvCsB,CAuCJ,MAvCI,CAAA,GAAA,KAAA,EAAA,UAwCtB,iBAxCsB,CAwCJ,MAxCI,CAAA,GAAA,KAAA,EAAA,UAyCtB,iBAzCsB,CAyCJ,MAzCI,CAAA,GAAA,KAAA,CAAA,CAAA,MAAA,EA2CxB,MA3CwB,EAAA,MAAA,EA6C7B,gBA7C6B,CA6CZ,MA7CY,EA6CJ,CA7CI,EA6CD,CA7CC,EA6CE,CA7CF,EA6CK,CA7CL,EA6CQ,CA7CR,EA6CW,CA7CX,EA6Cc,CA7Cd,EA6CiB,CA7CjB,CAAA,GAAA,CAAA,GAAA,GA8CtB,gBA9CsB,CA8CL,MA9CK,EA8CG,CA9CH,EA8CM,CA9CN,EA8CS,CA9CT,EA8CY,CA9CZ,EA8Ce,CA9Cf,EA8CkB,CA9ClB,EA8CqB,CA9CrB,EA8CwB,CA9CxB,CAAA,CAAA,EAAA,OAAA,CAAA,EA+CtB,yBA/CsB,CA+CI,MA/CJ,CAAA,CAAA,EAAA,CAAA,MAgDvB,MAhDuB,GAAA,SAAA,EAAA,CAAA,KAAA,EAAA,MAgDW,MAhDX,EAAA,GAAA,IAAA,CAAA"}
|