@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,14 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/_internal/utils/try-parse-json.ts
|
|
3
|
+
function tryParseJSON(json) {
|
|
4
|
+
if (!json) return void 0;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(json);
|
|
7
|
+
} catch {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.tryParseJSON = tryParseJSON;
|
|
14
|
+
//# sourceMappingURL=try-parse-json.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"try-parse-json.cjs","names":[],"sources":["../../../src/_internal/utils/try-parse-json.ts"],"sourcesContent":["export function tryParseJSON<T>(json: string | null | undefined): T | undefined {\n\tif (!json) return undefined\n\ttry {\n\t\treturn JSON.parse(json)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n"],"mappings":";;AAAA,SAAgB,aAAgB,MAAgD;AAC/E,KAAI,CAAC,KAAM,QAAO;AAClB,KAAI;AACH,SAAO,KAAK,MAAM,KAAK;SAChB;AACP"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/_internal/utils/try-parse-json.ts
|
|
2
|
+
function tryParseJSON(json) {
|
|
3
|
+
if (!json) return void 0;
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(json);
|
|
6
|
+
} catch {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { tryParseJSON };
|
|
13
|
+
//# sourceMappingURL=try-parse-json.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"try-parse-json.mjs","names":[],"sources":["../../../src/_internal/utils/try-parse-json.ts"],"sourcesContent":["export function tryParseJSON<T>(json: string | null | undefined): T | undefined {\n\tif (!json) return undefined\n\ttry {\n\t\treturn JSON.parse(json)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n"],"mappings":";AAAA,SAAgB,aAAgB,MAAgD;AAC/E,KAAI,CAAC,KAAM,QAAO;AAClB,KAAI;AACH,SAAO,KAAK,MAAM,KAAK;SAChB;AACP"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/attributes/data-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Well-known data attribute names used in web development.
|
|
4
|
+
* Includes testing, analytics, Radix/shadcn-style component state,
|
|
5
|
+
* positioning, and common UI/design-system attributes.
|
|
6
|
+
* The `data-${string}` tail allows any custom data attribute.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/data-* MDN: data-* (HTML)}
|
|
9
|
+
* @see {@link https://testing-library.com/docs/queries/bytestid/ Testing Library: ByTestId}
|
|
10
|
+
* @see {@link https://css-tricks.com/a-complete-guide-to-data-attributes/ CSS-Tricks: A Complete Guide to Data Attributes}
|
|
11
|
+
* @see {@link https://www.components.build/data-attributes Components.build: Data Attributes}
|
|
12
|
+
* @see {@link https://www.radix-ui.com/primitives/docs/guides/styling Radix UI: Styling (data attributes)}
|
|
13
|
+
*/
|
|
14
|
+
type DataAttribute = 'data-testid' | 'data-metrics' | 'data-state' | 'data-orientation' | 'data-side' | 'data-align' | 'data-placement' | 'data-loading' | 'data-disabled' | 'data-selected' | 'data-checked' | 'data-expanded' | 'data-highlighted' | 'data-active' | 'data-open' | 'data-pressed' | 'data-value' | 'data-id' | 'data-name' | 'data-type' | 'data-label' | 'data-key' | 'data-index' | 'data-position' | 'data-variant' | 'data-size' | 'data-theme' | 'data-color' | 'data-intent' | (`data-${string}` & {});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DataAttribute };
|
|
17
|
+
//# sourceMappingURL=data-attribute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-attribute.d.cts","names":[],"sources":["../../src/attributes/data-attribute.ts"],"sourcesContent":[],"mappings":";;AAYA;;;;;;;;;;;KAAY,aAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/attributes/data-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Well-known data attribute names used in web development.
|
|
4
|
+
* Includes testing, analytics, Radix/shadcn-style component state,
|
|
5
|
+
* positioning, and common UI/design-system attributes.
|
|
6
|
+
* The `data-${string}` tail allows any custom data attribute.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/data-* MDN: data-* (HTML)}
|
|
9
|
+
* @see {@link https://testing-library.com/docs/queries/bytestid/ Testing Library: ByTestId}
|
|
10
|
+
* @see {@link https://css-tricks.com/a-complete-guide-to-data-attributes/ CSS-Tricks: A Complete Guide to Data Attributes}
|
|
11
|
+
* @see {@link https://www.components.build/data-attributes Components.build: Data Attributes}
|
|
12
|
+
* @see {@link https://www.radix-ui.com/primitives/docs/guides/styling Radix UI: Styling (data attributes)}
|
|
13
|
+
*/
|
|
14
|
+
type DataAttribute = 'data-testid' | 'data-metrics' | 'data-state' | 'data-orientation' | 'data-side' | 'data-align' | 'data-placement' | 'data-loading' | 'data-disabled' | 'data-selected' | 'data-checked' | 'data-expanded' | 'data-highlighted' | 'data-active' | 'data-open' | 'data-pressed' | 'data-value' | 'data-id' | 'data-name' | 'data-type' | 'data-label' | 'data-key' | 'data-index' | 'data-position' | 'data-variant' | 'data-size' | 'data-theme' | 'data-color' | 'data-intent' | (`data-${string}` & {});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DataAttribute };
|
|
17
|
+
//# sourceMappingURL=data-attribute.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-attribute.d.mts","names":[],"sources":["../../src/attributes/data-attribute.ts"],"sourcesContent":[],"mappings":";;AAYA;;;;;;;;;;;KAAY,aAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/attributes/get-attribute.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gets the value of an attribute from an element.
|
|
5
|
+
*
|
|
6
|
+
* @param qualifiedName - The name of the attribute to get
|
|
7
|
+
* @param element - The element to get the attribute from. Defaults to `document.documentElement`
|
|
8
|
+
* @returns The attribute value cast to type T, or null if the attribute doesn't exist
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Get theme from document root
|
|
13
|
+
* const theme = getAttribute('data-theme')
|
|
14
|
+
*
|
|
15
|
+
* // Get data-testid from a specific element
|
|
16
|
+
* const testId = getAttribute('data-testid', element)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function getAttribute(qualifiedName, element) {
|
|
20
|
+
element = element ?? globalThis.document.documentElement;
|
|
21
|
+
return element.getAttribute(qualifiedName);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.getAttribute = getAttribute;
|
|
26
|
+
//# sourceMappingURL=get-attribute.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-attribute.cjs","names":[],"sources":["../../src/attributes/get-attribute.ts"],"sourcesContent":["/**\n * Gets the value of an attribute from an element.\n *\n * @param qualifiedName - The name of the attribute to get\n * @param element - The element to get the attribute from. Defaults to `document.documentElement`\n * @returns The attribute value cast to type T, or null if the attribute doesn't exist\n *\n * @example\n * ```ts\n * // Get theme from document root\n * const theme = getAttribute('data-theme')\n *\n * // Get data-testid from a specific element\n * const testId = getAttribute('data-testid', element)\n * ```\n */\nexport function getAttribute<T extends string>(qualifiedName: T, element?: Element | undefined) {\n\telement = element ?? globalThis.document.documentElement\n\treturn element.getAttribute(qualifiedName)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,SAAgB,aAA+B,eAAkB,SAA+B;AAC/F,WAAU,WAAW,WAAW,SAAS;AACzC,QAAO,QAAQ,aAAa,cAAc"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/attributes/get-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gets the value of an attribute from an element.
|
|
4
|
+
*
|
|
5
|
+
* @param qualifiedName - The name of the attribute to get
|
|
6
|
+
* @param element - The element to get the attribute from. Defaults to `document.documentElement`
|
|
7
|
+
* @returns The attribute value cast to type T, or null if the attribute doesn't exist
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Get theme from document root
|
|
12
|
+
* const theme = getAttribute('data-theme')
|
|
13
|
+
*
|
|
14
|
+
* // Get data-testid from a specific element
|
|
15
|
+
* const testId = getAttribute('data-testid', element)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function getAttribute<T extends string>(qualifiedName: T, element?: Element | undefined): string | null;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getAttribute };
|
|
21
|
+
//# sourceMappingURL=get-attribute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-attribute.d.cts","names":[],"sources":["../../src/attributes/get-attribute.ts"],"sourcesContent":[],"mappings":";;AAgBA;;;;;;;;;;;;;;;iBAAgB,8CAA8C,aAAa"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/attributes/get-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gets the value of an attribute from an element.
|
|
4
|
+
*
|
|
5
|
+
* @param qualifiedName - The name of the attribute to get
|
|
6
|
+
* @param element - The element to get the attribute from. Defaults to `document.documentElement`
|
|
7
|
+
* @returns The attribute value cast to type T, or null if the attribute doesn't exist
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Get theme from document root
|
|
12
|
+
* const theme = getAttribute('data-theme')
|
|
13
|
+
*
|
|
14
|
+
* // Get data-testid from a specific element
|
|
15
|
+
* const testId = getAttribute('data-testid', element)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function getAttribute<T extends string>(qualifiedName: T, element?: Element | undefined): string | null;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getAttribute };
|
|
21
|
+
//# sourceMappingURL=get-attribute.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-attribute.d.mts","names":[],"sources":["../../src/attributes/get-attribute.ts"],"sourcesContent":[],"mappings":";;AAgBA;;;;;;;;;;;;;;;iBAAgB,8CAA8C,aAAa"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/attributes/get-attribute.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gets the value of an attribute from an element.
|
|
4
|
+
*
|
|
5
|
+
* @param qualifiedName - The name of the attribute to get
|
|
6
|
+
* @param element - The element to get the attribute from. Defaults to `document.documentElement`
|
|
7
|
+
* @returns The attribute value cast to type T, or null if the attribute doesn't exist
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Get theme from document root
|
|
12
|
+
* const theme = getAttribute('data-theme')
|
|
13
|
+
*
|
|
14
|
+
* // Get data-testid from a specific element
|
|
15
|
+
* const testId = getAttribute('data-testid', element)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function getAttribute(qualifiedName, element) {
|
|
19
|
+
element = element ?? globalThis.document.documentElement;
|
|
20
|
+
return element.getAttribute(qualifiedName);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getAttribute };
|
|
25
|
+
//# sourceMappingURL=get-attribute.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-attribute.mjs","names":[],"sources":["../../src/attributes/get-attribute.ts"],"sourcesContent":["/**\n * Gets the value of an attribute from an element.\n *\n * @param qualifiedName - The name of the attribute to get\n * @param element - The element to get the attribute from. Defaults to `document.documentElement`\n * @returns The attribute value cast to type T, or null if the attribute doesn't exist\n *\n * @example\n * ```ts\n * // Get theme from document root\n * const theme = getAttribute('data-theme')\n *\n * // Get data-testid from a specific element\n * const testId = getAttribute('data-testid', element)\n * ```\n */\nexport function getAttribute<T extends string>(qualifiedName: T, element?: Element | undefined) {\n\telement = element ?? globalThis.document.documentElement\n\treturn element.getAttribute(qualifiedName)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAgB,aAA+B,eAAkB,SAA+B;AAC/F,WAAU,WAAW,WAAW,SAAS;AACzC,QAAO,QAAQ,aAAa,cAAc"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_get_attribute = require('./get-attribute.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/attributes/get-data-attribute.ts
|
|
4
|
+
/**
|
|
5
|
+
* Gets the value of a data attribute from an element.
|
|
6
|
+
*
|
|
7
|
+
* @param qualifiedName - The name of the data attribute to get
|
|
8
|
+
* @param element - The element to get the data attribute from. Defaults to `document.documentElement`
|
|
9
|
+
* @returns The data attribute value, or null if the attribute doesn't exist
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*/
|
|
13
|
+
function getDataAttribute(qualifiedName, element) {
|
|
14
|
+
return require_get_attribute.getAttribute(qualifiedName, element);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.getDataAttribute = getDataAttribute;
|
|
19
|
+
//# sourceMappingURL=get-data-attribute.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-data-attribute.cjs","names":["getAttribute"],"sources":["../../src/attributes/get-data-attribute.ts"],"sourcesContent":["import type { DataAttribute } from './data-attribute.ts'\nimport { getAttribute } from './get-attribute.ts'\n\n/**\n * Gets the value of a data attribute from an element.\n *\n * @param qualifiedName - The name of the data attribute to get\n * @param element - The element to get the data attribute from. Defaults to `document.documentElement`\n * @returns The data attribute value, or null if the attribute doesn't exist\n *\n * @example\n */\nexport function getDataAttribute(qualifiedName: DataAttribute, element?: Element | undefined) {\n\treturn getAttribute(qualifiedName, element)\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,iBAAiB,eAA8B,SAA+B;AAC7F,QAAOA,mCAAa,eAAe,QAAQ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DataAttribute } from "./data-attribute.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/attributes/get-data-attribute.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gets the value of a data attribute from an element.
|
|
7
|
+
*
|
|
8
|
+
* @param qualifiedName - The name of the data attribute to get
|
|
9
|
+
* @param element - The element to get the data attribute from. Defaults to `document.documentElement`
|
|
10
|
+
* @returns The data attribute value, or null if the attribute doesn't exist
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*/
|
|
14
|
+
declare function getDataAttribute(qualifiedName: DataAttribute, element?: Element | undefined): string | null;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { getDataAttribute };
|
|
17
|
+
//# sourceMappingURL=get-data-attribute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-data-attribute.d.cts","names":[],"sources":["../../src/attributes/get-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;;;;;;;iBAAgB,gBAAA,gBAAgC,yBAAyB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DataAttribute } from "./data-attribute.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/attributes/get-data-attribute.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gets the value of a data attribute from an element.
|
|
7
|
+
*
|
|
8
|
+
* @param qualifiedName - The name of the data attribute to get
|
|
9
|
+
* @param element - The element to get the data attribute from. Defaults to `document.documentElement`
|
|
10
|
+
* @returns The data attribute value, or null if the attribute doesn't exist
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*/
|
|
14
|
+
declare function getDataAttribute(qualifiedName: DataAttribute, element?: Element | undefined): string | null;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { getDataAttribute };
|
|
17
|
+
//# sourceMappingURL=get-data-attribute.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-data-attribute.d.mts","names":[],"sources":["../../src/attributes/get-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;;;;;;;iBAAgB,gBAAA,gBAAgC,yBAAyB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getAttribute } from "./get-attribute.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/attributes/get-data-attribute.ts
|
|
4
|
+
/**
|
|
5
|
+
* Gets the value of a data attribute from an element.
|
|
6
|
+
*
|
|
7
|
+
* @param qualifiedName - The name of the data attribute to get
|
|
8
|
+
* @param element - The element to get the data attribute from. Defaults to `document.documentElement`
|
|
9
|
+
* @returns The data attribute value, or null if the attribute doesn't exist
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*/
|
|
13
|
+
function getDataAttribute(qualifiedName, element) {
|
|
14
|
+
return getAttribute(qualifiedName, element);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getDataAttribute };
|
|
19
|
+
//# sourceMappingURL=get-data-attribute.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-data-attribute.mjs","names":[],"sources":["../../src/attributes/get-data-attribute.ts"],"sourcesContent":["import type { DataAttribute } from './data-attribute.ts'\nimport { getAttribute } from './get-attribute.ts'\n\n/**\n * Gets the value of a data attribute from an element.\n *\n * @param qualifiedName - The name of the data attribute to get\n * @param element - The element to get the data attribute from. Defaults to `document.documentElement`\n * @returns The data attribute value, or null if the attribute doesn't exist\n *\n * @example\n */\nexport function getDataAttribute(qualifiedName: DataAttribute, element?: Element | undefined) {\n\treturn getAttribute(qualifiedName, element)\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,iBAAiB,eAA8B,SAA+B;AAC7F,QAAO,aAAa,eAAe,QAAQ"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/attributes/observe-attribute.ts
|
|
3
|
+
/**
|
|
4
|
+
* Observes attributes changes on an element and calls corresponding handlers.
|
|
5
|
+
*
|
|
6
|
+
* @param handlers - An object mapping attribute names to handler functions.
|
|
7
|
+
* @param element - The element to observe. Defaults to `document.documentElement`.
|
|
8
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const observer = observeAttributes({
|
|
13
|
+
* 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),
|
|
14
|
+
* 'class': (attr, value) => console.log(`class changed to: ${value}`)
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Later, to stop observing:
|
|
18
|
+
* observer.disconnect();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function observeAttributes(handlers, element) {
|
|
22
|
+
element = element ?? globalThis.document.documentElement;
|
|
23
|
+
const observer = new MutationObserver((mutations) => {
|
|
24
|
+
for (const mutation of mutations) {
|
|
25
|
+
const attribute = mutation.attributeName;
|
|
26
|
+
if (!attribute) continue;
|
|
27
|
+
const value = element.getAttribute(attribute);
|
|
28
|
+
handlers[attribute]?.(value);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
observer.observe(element, {
|
|
32
|
+
attributes: true,
|
|
33
|
+
attributeFilter: Object.keys(handlers)
|
|
34
|
+
});
|
|
35
|
+
return observer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.observeAttributes = observeAttributes;
|
|
40
|
+
//# sourceMappingURL=observe-attribute.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-attribute.cjs","names":[],"sources":["../../src/attributes/observe-attribute.ts"],"sourcesContent":["/**\n * Observes attributes changes on an element and calls corresponding handlers.\n *\n * @param handlers - An object mapping attribute names to handler functions.\n * @param element - The element to observe. Defaults to `document.documentElement`.\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.\n *\n * @example\n * ```ts\n * const observer = observeAttributes({\n * 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),\n * 'class': (attr, value) => console.log(`class changed to: ${value}`)\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeAttributes<T extends string>(\n\thandlers: Record<string, (value: T | null) => void>,\n\telement?: Element | undefined\n) {\n\telement = element ?? globalThis.document.documentElement\n\tconst observer = new MutationObserver((mutations) => {\n\t\tfor (const mutation of mutations) {\n\t\t\tconst attribute = mutation.attributeName\n\t\t\tif (!attribute) continue\n\t\t\tconst value = element.getAttribute(attribute) as T | null\n\t\t\thandlers[attribute]?.(value)\n\t\t}\n\t})\n\tobserver.observe(element, {\n\t\tattributes: true,\n\t\tattributeFilter: Object.keys(handlers)\n\t})\n\treturn observer\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,SAAgB,kBACf,UACA,SACC;AACD,WAAU,WAAW,WAAW,SAAS;CACzC,MAAM,WAAW,IAAI,kBAAkB,cAAc;AACpD,OAAK,MAAM,YAAY,WAAW;GACjC,MAAM,YAAY,SAAS;AAC3B,OAAI,CAAC,UAAW;GAChB,MAAM,QAAQ,QAAQ,aAAa,UAAU;AAC7C,YAAS,aAAa,MAAM;;GAE5B;AACF,UAAS,QAAQ,SAAS;EACzB,YAAY;EACZ,iBAAiB,OAAO,KAAK,SAAS;EACtC,CAAC;AACF,QAAO"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/attributes/observe-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Observes attributes changes on an element and calls corresponding handlers.
|
|
4
|
+
*
|
|
5
|
+
* @param handlers - An object mapping attribute names to handler functions.
|
|
6
|
+
* @param element - The element to observe. Defaults to `document.documentElement`.
|
|
7
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const observer = observeAttributes({
|
|
12
|
+
* 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),
|
|
13
|
+
* 'class': (attr, value) => console.log(`class changed to: ${value}`)
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Later, to stop observing:
|
|
17
|
+
* observer.disconnect();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function observeAttributes<T extends string>(handlers: Record<string, (value: T | null) => void>, element?: Element | undefined): MutationObserver;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { observeAttributes };
|
|
23
|
+
//# sourceMappingURL=observe-attribute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-attribute.d.cts","names":[],"sources":["../../src/attributes/observe-attribute.ts"],"sourcesContent":[],"mappings":";;AAkBA;;;;;;;;;;;;;;;;;iBAAgB,8CACL,uBAAuB,8BACvB,sBAAmB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/attributes/observe-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Observes attributes changes on an element and calls corresponding handlers.
|
|
4
|
+
*
|
|
5
|
+
* @param handlers - An object mapping attribute names to handler functions.
|
|
6
|
+
* @param element - The element to observe. Defaults to `document.documentElement`.
|
|
7
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const observer = observeAttributes({
|
|
12
|
+
* 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),
|
|
13
|
+
* 'class': (attr, value) => console.log(`class changed to: ${value}`)
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Later, to stop observing:
|
|
17
|
+
* observer.disconnect();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function observeAttributes<T extends string>(handlers: Record<string, (value: T | null) => void>, element?: Element | undefined): MutationObserver;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { observeAttributes };
|
|
23
|
+
//# sourceMappingURL=observe-attribute.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-attribute.d.mts","names":[],"sources":["../../src/attributes/observe-attribute.ts"],"sourcesContent":[],"mappings":";;AAkBA;;;;;;;;;;;;;;;;;iBAAgB,8CACL,uBAAuB,8BACvB,sBAAmB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/attributes/observe-attribute.ts
|
|
2
|
+
/**
|
|
3
|
+
* Observes attributes changes on an element and calls corresponding handlers.
|
|
4
|
+
*
|
|
5
|
+
* @param handlers - An object mapping attribute names to handler functions.
|
|
6
|
+
* @param element - The element to observe. Defaults to `document.documentElement`.
|
|
7
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const observer = observeAttributes({
|
|
12
|
+
* 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),
|
|
13
|
+
* 'class': (attr, value) => console.log(`class changed to: ${value}`)
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Later, to stop observing:
|
|
17
|
+
* observer.disconnect();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function observeAttributes(handlers, element) {
|
|
21
|
+
element = element ?? globalThis.document.documentElement;
|
|
22
|
+
const observer = new MutationObserver((mutations) => {
|
|
23
|
+
for (const mutation of mutations) {
|
|
24
|
+
const attribute = mutation.attributeName;
|
|
25
|
+
if (!attribute) continue;
|
|
26
|
+
const value = element.getAttribute(attribute);
|
|
27
|
+
handlers[attribute]?.(value);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
observer.observe(element, {
|
|
31
|
+
attributes: true,
|
|
32
|
+
attributeFilter: Object.keys(handlers)
|
|
33
|
+
});
|
|
34
|
+
return observer;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { observeAttributes };
|
|
39
|
+
//# sourceMappingURL=observe-attribute.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-attribute.mjs","names":[],"sources":["../../src/attributes/observe-attribute.ts"],"sourcesContent":["/**\n * Observes attributes changes on an element and calls corresponding handlers.\n *\n * @param handlers - An object mapping attribute names to handler functions.\n * @param element - The element to observe. Defaults to `document.documentElement`.\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.\n *\n * @example\n * ```ts\n * const observer = observeAttributes({\n * 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),\n * 'class': (attr, value) => console.log(`class changed to: ${value}`)\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeAttributes<T extends string>(\n\thandlers: Record<string, (value: T | null) => void>,\n\telement?: Element | undefined\n) {\n\telement = element ?? globalThis.document.documentElement\n\tconst observer = new MutationObserver((mutations) => {\n\t\tfor (const mutation of mutations) {\n\t\t\tconst attribute = mutation.attributeName\n\t\t\tif (!attribute) continue\n\t\t\tconst value = element.getAttribute(attribute) as T | null\n\t\t\thandlers[attribute]?.(value)\n\t\t}\n\t})\n\tobserver.observe(element, {\n\t\tattributes: true,\n\t\tattributeFilter: Object.keys(handlers)\n\t})\n\treturn observer\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,SAAgB,kBACf,UACA,SACC;AACD,WAAU,WAAW,WAAW,SAAS;CACzC,MAAM,WAAW,IAAI,kBAAkB,cAAc;AACpD,OAAK,MAAM,YAAY,WAAW;GACjC,MAAM,YAAY,SAAS;AAC3B,OAAI,CAAC,UAAW;GAChB,MAAM,QAAQ,QAAQ,aAAa,UAAU;AAC7C,YAAS,aAAa,MAAM;;GAE5B;AACF,UAAS,QAAQ,SAAS;EACzB,YAAY;EACZ,iBAAiB,OAAO,KAAK,SAAS;EACtC,CAAC;AACF,QAAO"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_observe_attribute = require('./observe-attribute.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/attributes/observe-data-attribute.ts
|
|
4
|
+
/**
|
|
5
|
+
* Observes changes to `data-*` attributes on an element and calls corresponding handlers.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Configuration options
|
|
8
|
+
* @param options.handlers - An object mapping `data-*` attribute names to handler functions.
|
|
9
|
+
* @param options.element - The element to observe. Defaults to `document.documentElement`
|
|
10
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const observer = observeDataAttributes({
|
|
15
|
+
* handlers: {
|
|
16
|
+
* 'data-theme': (value) => console.log(`Theme changed to: ${value}`),
|
|
17
|
+
* 'data-mode': (value) => console.log(`Mode changed to: ${value}`)
|
|
18
|
+
* }
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Later, to stop observing:
|
|
22
|
+
* observer.disconnect();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function observeDataAttributes(handlers, element) {
|
|
26
|
+
return require_observe_attribute.observeAttributes(handlers, element);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.observeDataAttributes = observeDataAttributes;
|
|
31
|
+
//# sourceMappingURL=observe-data-attribute.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-data-attribute.cjs","names":["observeAttributes"],"sources":["../../src/attributes/observe-data-attribute.ts"],"sourcesContent":["import { observeAttributes } from './observe-attribute.ts'\n\n/**\n * Observes changes to `data-*` attributes on an element and calls corresponding handlers.\n *\n * @param options - Configuration options\n * @param options.handlers - An object mapping `data-*` attribute names to handler functions.\n * @param options.element - The element to observe. Defaults to `document.documentElement`\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer\n *\n * @example\n * ```ts\n * const observer = observeDataAttributes({\n * handlers: {\n * 'data-theme': (value) => console.log(`Theme changed to: ${value}`),\n * 'data-mode': (value) => console.log(`Mode changed to: ${value}`)\n * }\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeDataAttributes<T extends string, K extends `data-${string}`>(\n\thandlers: Record<K, (value: T | null) => void>,\n\telement?: Element | undefined\n) {\n\treturn observeAttributes(handlers, element)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,sBACf,UACA,SACC;AACD,QAAOA,4CAAkB,UAAU,QAAQ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/attributes/observe-data-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Observes changes to `data-*` attributes on an element and calls corresponding handlers.
|
|
4
|
+
*
|
|
5
|
+
* @param options - Configuration options
|
|
6
|
+
* @param options.handlers - An object mapping `data-*` attribute names to handler functions.
|
|
7
|
+
* @param options.element - The element to observe. Defaults to `document.documentElement`
|
|
8
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const observer = observeDataAttributes({
|
|
13
|
+
* handlers: {
|
|
14
|
+
* 'data-theme': (value) => console.log(`Theme changed to: ${value}`),
|
|
15
|
+
* 'data-mode': (value) => console.log(`Mode changed to: ${value}`)
|
|
16
|
+
* }
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Later, to stop observing:
|
|
20
|
+
* observer.disconnect();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function observeDataAttributes<T extends string, K extends `data-${string}`>(handlers: Record<K, (value: T | null) => void>, element?: Element | undefined): MutationObserver;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { observeDataAttributes };
|
|
26
|
+
//# sourceMappingURL=observe-data-attribute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-data-attribute.d.cts","names":[],"sources":["../../src/attributes/observe-data-attribute.ts"],"sourcesContent":[],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;;iBAAgB,8EACL,OAAO,WAAW,8BAClB,sBAAmB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/attributes/observe-data-attribute.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Observes changes to `data-*` attributes on an element and calls corresponding handlers.
|
|
4
|
+
*
|
|
5
|
+
* @param options - Configuration options
|
|
6
|
+
* @param options.handlers - An object mapping `data-*` attribute names to handler functions.
|
|
7
|
+
* @param options.element - The element to observe. Defaults to `document.documentElement`
|
|
8
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const observer = observeDataAttributes({
|
|
13
|
+
* handlers: {
|
|
14
|
+
* 'data-theme': (value) => console.log(`Theme changed to: ${value}`),
|
|
15
|
+
* 'data-mode': (value) => console.log(`Mode changed to: ${value}`)
|
|
16
|
+
* }
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Later, to stop observing:
|
|
20
|
+
* observer.disconnect();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function observeDataAttributes<T extends string, K extends `data-${string}`>(handlers: Record<K, (value: T | null) => void>, element?: Element | undefined): MutationObserver;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { observeDataAttributes };
|
|
26
|
+
//# sourceMappingURL=observe-data-attribute.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-data-attribute.d.mts","names":[],"sources":["../../src/attributes/observe-data-attribute.ts"],"sourcesContent":[],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;;iBAAgB,8EACL,OAAO,WAAW,8BAClB,sBAAmB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { observeAttributes } from "./observe-attribute.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/attributes/observe-data-attribute.ts
|
|
4
|
+
/**
|
|
5
|
+
* Observes changes to `data-*` attributes on an element and calls corresponding handlers.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Configuration options
|
|
8
|
+
* @param options.handlers - An object mapping `data-*` attribute names to handler functions.
|
|
9
|
+
* @param options.element - The element to observe. Defaults to `document.documentElement`
|
|
10
|
+
* @returns {MutationObserver} The observer instance, which can be used to disconnect the observer
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const observer = observeDataAttributes({
|
|
15
|
+
* handlers: {
|
|
16
|
+
* 'data-theme': (value) => console.log(`Theme changed to: ${value}`),
|
|
17
|
+
* 'data-mode': (value) => console.log(`Mode changed to: ${value}`)
|
|
18
|
+
* }
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Later, to stop observing:
|
|
22
|
+
* observer.disconnect();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function observeDataAttributes(handlers, element) {
|
|
26
|
+
return observeAttributes(handlers, element);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { observeDataAttributes };
|
|
31
|
+
//# sourceMappingURL=observe-data-attribute.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-data-attribute.mjs","names":[],"sources":["../../src/attributes/observe-data-attribute.ts"],"sourcesContent":["import { observeAttributes } from './observe-attribute.ts'\n\n/**\n * Observes changes to `data-*` attributes on an element and calls corresponding handlers.\n *\n * @param options - Configuration options\n * @param options.handlers - An object mapping `data-*` attribute names to handler functions.\n * @param options.element - The element to observe. Defaults to `document.documentElement`\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer\n *\n * @example\n * ```ts\n * const observer = observeDataAttributes({\n * handlers: {\n * 'data-theme': (value) => console.log(`Theme changed to: ${value}`),\n * 'data-mode': (value) => console.log(`Mode changed to: ${value}`)\n * }\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeDataAttributes<T extends string, K extends `data-${string}`>(\n\thandlers: Record<K, (value: T | null) => void>,\n\telement?: Element | undefined\n) {\n\treturn observeAttributes(handlers, element)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,sBACf,UACA,SACC;AACD,QAAO,kBAAkB,UAAU,QAAQ"}
|