@devup-ui/react 1.0.16 → 1.0.17

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.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),o=require("./use-safe-effect.cjs");let t=null;const u={};let a=null;function f(){const n=l.useId(),[r,s]=l.useState(a);return o.useSafeEffect(()=>{if(a!==null)return;const e=document.documentElement.getAttribute("data-theme");e!==null&&e!==r&&s(e)},[r]),o.useSafeEffect(()=>{const e=document.documentElement;return u[n]=s,t||(t=new MutationObserver(()=>{const c=document.documentElement.getAttribute("data-theme");a=c;for(const i in u)u[i](c)}),t.observe(e,{attributes:!0,attributeFilter:["data-theme"],childList:!1,subtree:!1,characterData:!1,attributeOldValue:!1,characterDataOldValue:!1})),()=>{delete u[n],t&&Object.keys(u).length===0&&t.disconnect()}},[n]),r}exports.useTheme=f;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),r=require("../stores/theme-store.cjs"),e=r.createThemeStore();function o(){return t.useSyncExternalStore(e.subscribe,e.get,e.get)}exports.useTheme=o;
@@ -1,3 +1,2 @@
1
- import { DevupTheme } from '../types/theme';
2
- export declare function useTheme(): keyof DevupTheme | null;
1
+ export declare function useTheme(): null;
3
2
  //# sourceMappingURL=use-theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-theme.d.ts","sourceRoot":"","sources":["../../src/hooks/use-theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAOhD,wBAAgB,QAAQ,IAAI,MAAM,UAAU,GAAG,IAAI,CAqClD"}
1
+ {"version":3,"file":"use-theme.d.ts","sourceRoot":"","sources":["../../src/hooks/use-theme.ts"],"names":[],"mappings":"AAQA,wBAAgB,QAAQ,SAOvB"}
@@ -1,35 +1,14 @@
1
1
  "use client";
2
- import { useId as m, useState as i } from "react";
3
- import { useSafeEffect as s } from "./use-safe-effect.js";
4
- let t = null;
5
- const n = {};
6
- let u = null;
7
- function h() {
8
- const r = m(), [a, l] = i(u);
9
- return s(() => {
10
- if (u !== null) return;
11
- const e = document.documentElement.getAttribute("data-theme");
12
- e !== null && e !== a && l(e);
13
- }, [a]), s(() => {
14
- const e = document.documentElement;
15
- return n[r] = l, t || (t = new MutationObserver(() => {
16
- const o = document.documentElement.getAttribute("data-theme");
17
- u = o;
18
- for (const c in n)
19
- n[c](o);
20
- }), t.observe(e, {
21
- attributes: !0,
22
- attributeFilter: ["data-theme"],
23
- childList: !1,
24
- subtree: !1,
25
- characterData: !1,
26
- attributeOldValue: !1,
27
- characterDataOldValue: !1
28
- })), () => {
29
- delete n[r], t && Object.keys(n).length === 0 && t.disconnect();
30
- };
31
- }, [r]), a;
2
+ import { useSyncExternalStore as t } from "react";
3
+ import { createThemeStore as r } from "../stores/theme-store.js";
4
+ const e = r();
5
+ function c() {
6
+ return t(
7
+ e.subscribe,
8
+ e.get,
9
+ e.get
10
+ );
32
11
  }
33
12
  export {
34
- h as useTheme
13
+ c as useTheme
35
14
  };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=null;function a(){if(typeof window>"u")return{get:()=>u,set:()=>{},subscribe:()=>()=>{}};const o=document.documentElement,r=new Set;let n=u;const i=()=>n,s=e=>{n=e,r.forEach(t=>t(n))},c=e=>(r.add(e),s(o.getAttribute("data-theme")),()=>r.delete(e));return new MutationObserver(e=>{for(const t of e)t.type==="attributes"&&t.target instanceof HTMLElement&&s(t.target.getAttribute("data-theme"))}).observe(o,{attributes:!0,attributeFilter:["data-theme"],subtree:!1}),{get:i,set:s,subscribe:c}}exports.createThemeStore=a;
@@ -0,0 +1,14 @@
1
+ import { DevupTheme } from '../types/theme';
2
+ type Theme = keyof DevupTheme | null;
3
+ type StoreChangeEvent = (newTheme: Theme) => void;
4
+ export declare function createThemeStore(): {
5
+ get: () => null;
6
+ set: () => void;
7
+ subscribe: () => () => void;
8
+ } | {
9
+ get: () => null;
10
+ set: (newTheme: Theme) => void;
11
+ subscribe: (onStoreChange: StoreChangeEvent) => () => boolean;
12
+ };
13
+ export {};
14
+ //# sourceMappingURL=theme-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-store.d.ts","sourceRoot":"","sources":["../../src/stores/theme-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,KAAK,KAAK,GAAG,MAAM,UAAU,GAAG,IAAI,CAAA;AACpC,KAAK,gBAAgB,GAAG,CAAC,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAA;AAIjD,wBAAgB,gBAAgB;;;;;;oBAYP,KAAK;+BAKM,gBAAgB;EAqBnD"}
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ function a() {
3
+ if (typeof window > "u")
4
+ return {
5
+ get: () => null,
6
+ set: () => {
7
+ },
8
+ subscribe: () => () => {
9
+ }
10
+ };
11
+ const i = document.documentElement, n = /* @__PURE__ */ new Set();
12
+ let r = null;
13
+ const o = () => r, s = (e) => {
14
+ r = e, n.forEach((t) => t(r));
15
+ }, u = (e) => (n.add(e), s(i.getAttribute("data-theme")), () => n.delete(e));
16
+ return new MutationObserver((e) => {
17
+ for (const t of e)
18
+ t.type === "attributes" && t.target instanceof HTMLElement && s(t.target.getAttribute("data-theme"));
19
+ }).observe(i, {
20
+ attributes: !0,
21
+ attributeFilter: ["data-theme"],
22
+ subtree: !1
23
+ }), {
24
+ get: o,
25
+ set: s,
26
+ subscribe: u
27
+ };
28
+ }
29
+ export {
30
+ a as createThemeStore
31
+ };
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "css-in-js-framework",
17
17
  "react"
18
18
  ],
19
- "version": "1.0.16",
19
+ "version": "1.0.17",
20
20
  "type": "module",
21
21
  "publishConfig": {
22
22
  "access": "public"
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=typeof window>"u"?e.useEffect:e.useLayoutEffect;exports.useSafeEffect=t;
@@ -1,6 +0,0 @@
1
- "use client";
2
- import { useEffect as e, useLayoutEffect as f } from "react";
3
- const o = typeof window > "u" ? e : f;
4
- export {
5
- o as useSafeEffect
6
- };