@maz-ui/themes 4.7.2 → 4.7.4

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/plugin.d.ts CHANGED
@@ -37,11 +37,11 @@ declare module 'vue' {
37
37
  * @description You should install the plugin to use this property
38
38
  * @example
39
39
  * ```ts
40
- * import { MazUi } from 'maz-ui/plugins/maz-ui'
40
+ * import { MazUiTheme } from '@maz-ui/themes'
41
41
  * import { createApp } from 'vue'
42
42
  *
43
43
  * const app = createApp(App)
44
- * app.use(MazUi)
44
+ * app.use(MazUiTheme, { preset: mazUi })
45
45
  *
46
46
  * const { setColorMode, toggleDarkMode } = useTheme()
47
47
  * setColorMode('dark')
@@ -1,43 +1,11 @@
1
1
  import { isServer } from "@maz-ui/utils";
2
- import { ref, onMounted, computed, toValue, watch } from "vue";
3
- import { isClient } from "@maz-ui/utils/helpers/isClient";
4
- import { truthyFilter } from "@maz-ui/utils/helpers/truthyFilter";
2
+ import { ref, watch } from "vue";
5
3
  import { getSavedColorMode, getSystemColorMode, getColorMode } from "./get-color-mode.js";
6
4
  import { getPreset } from "./get-preset.js";
7
5
  import { injectThemeCSS } from "./inject-theme-css.js";
8
6
  import { mergePresets } from "./preset-merger.js";
9
7
  import { updateDocumentClass } from "./update-document-class.js";
10
- function useMutationObserver(target, callback, options = {}) {
11
- const {
12
- internalWindow = isClient() ? globalThis : void 0,
13
- ...mutationOptions
14
- } = options;
15
- let observer;
16
- const isSupported = ref((internalWindow && "MutationObserver" in internalWindow) ?? !1);
17
- isSupported.value || onMounted(() => {
18
- isSupported.value = (internalWindow && "MutationObserver" in internalWindow) ?? !1;
19
- });
20
- const cleanup = () => {
21
- observer && (observer.disconnect(), observer = void 0);
22
- }, targets = computed(() => {
23
- const value = toValue(target);
24
- let element;
25
- return value && "$el" in value ? element = value.$el : value && (element = value), new Set([element].filter(truthyFilter));
26
- }), stopWatch = watch(
27
- [targets, isSupported],
28
- ([newTargets, isSupported2]) => {
29
- cleanup(), isSupported2 && newTargets.size && (observer = new MutationObserver(callback), newTargets.forEach((el) => observer?.observe(el, mutationOptions)));
30
- },
31
- { immediate: !0, flush: "post" }
32
- );
33
- return {
34
- isSupported,
35
- stop: () => {
36
- stopWatch(), cleanup();
37
- },
38
- takeRecords: () => observer?.takeRecords()
39
- };
40
- }
8
+ import { useMutationObserver } from "./use-mutation-observer.js";
41
9
  function watchColorSchemeFromMedia(themeState) {
42
10
  if (isServer())
43
11
  return () => {
@@ -0,0 +1,4 @@
1
+ export declare function useMutationObserver(target: HTMLElement, callback: MutationCallback, options?: MutationObserverInit): {
2
+ stop: () => void;
3
+ };
4
+ //# sourceMappingURL=use-mutation-observer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mutation-observer.d.ts","sourceRoot":"","sources":["../../src/utils/use-mutation-observer.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE,oBAAyB;;EAcnC"}
@@ -0,0 +1,13 @@
1
+ import { isServer } from "@maz-ui/utils";
2
+ function useMutationObserver(target, callback, options = {}) {
3
+ if (isServer() || !("MutationObserver" in globalThis))
4
+ return { stop: () => {
5
+ } };
6
+ const observer = new MutationObserver(callback);
7
+ return observer.observe(target, options), { stop: () => {
8
+ observer.disconnect();
9
+ } };
10
+ }
11
+ export {
12
+ useMutationObserver
13
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/themes",
3
3
  "type": "module",
4
- "version": "4.7.2",
4
+ "version": "4.7.4",
5
5
  "description": "Theme system for Maz-UI with TypeScript support and CSS variables",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -78,7 +78,7 @@
78
78
  "vue": ">=3.5.0 <4.0.0"
79
79
  },
80
80
  "dependencies": {
81
- "@maz-ui/utils": "4.7.2"
81
+ "@maz-ui/utils": "4.7.4"
82
82
  },
83
83
  "lint-staged": {
84
84
  "*.{js,ts,vue,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"