xtreme-ui 0.0.84 → 0.0.86

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 +1 @@
1
- {"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../../../src/components/context/Theme/ThemeContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAe,iBAAiB,EAAE,mBAAmB,EAA6C,MAAM,QAAQ,CAAC;AASxH,QAAA,MAAM,YAAY,4CAA8B,CAAC;AACjD,QAAA,MAAM,aAAa,GAAI,cAAc,mBAAmB,4CAmBvD,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../../../src/components/context/Theme/ThemeContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAe,iBAAiB,EAAE,mBAAmB,EAAgB,MAAM,QAAQ,CAAC;AAS3F,QAAA,MAAM,YAAY,4CAA8B,CAAC;AACjD,QAAA,MAAM,aAAa,GAAI,cAAc,mBAAmB,4CAyBvD,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC"}
@@ -1,28 +1,22 @@
1
1
  "use client";
2
- import { jsx as i } from "react/jsx-runtime";
3
- import { createContext as u, useState as h, useEffect as a } from "react";
4
- import "../../../utils/constants/commons.js";
5
- import { win as o } from "../../../utils/helper/domHelper.js";
6
- import { defaultColor as d, defaultScheme as p } from "./type.js";
7
- var c, l;
8
- const r = {
9
- themeScheme: ((c = o) == null ? void 0 : c.__themeScheme) ?? p,
2
+ import { jsx as u } from "react/jsx-runtime";
3
+ import { createContext as i, useState as s, useEffect as n } from "react";
4
+ import { STORAGE as e } from "../../../utils/constants/commons.js";
5
+ const m = {
6
+ themeScheme: void 0,
10
7
  setThemeScheme: () => null,
11
- themeColor: ((l = o) == null ? void 0 : l.__themeColor) ?? d,
8
+ themeColor: void 0,
12
9
  setThemeColor: () => null
13
- }, x = u(r), D = ({ children: s }) => {
14
- const [n, C] = h(r.themeScheme), [f, _] = h(r.themeColor), S = (m) => {
15
- var e, t;
16
- return (t = (e = o) == null ? void 0 : e.__setPreferredThemeScheme) == null ? void 0 : t.call(e, m);
17
- }, T = (m) => {
18
- var e, t;
19
- return (t = (e = o) == null ? void 0 : e.__setPreferredThemeColor) == null ? void 0 : t.call(e, m);
20
- };
21
- return a(() => {
22
- o && (o.__onThemeSchemeChange = C, o.__onThemeColorChange = _);
23
- }, []), /* @__PURE__ */ i(x.Provider, { value: { themeScheme: n, setThemeScheme: S, themeColor: f, setThemeColor: T }, children: s });
10
+ }, a = i(m), T = ({ children: S }) => {
11
+ const [t, r] = s(m.themeScheme), [o, h] = s(m.themeColor);
12
+ return n(() => {
13
+ const c = localStorage.getItem(e.themeScheme), l = localStorage.getItem(e.themeColor);
14
+ c && r(c), l && h(l);
15
+ }, []), n(() => {
16
+ !t || !o || (document.documentElement.setAttribute(e.themeSchemeAttr, t), document.documentElement.setAttribute(e.themeColorAttr, o), localStorage.setItem(e.themeScheme, t), localStorage.setItem(e.themeColor, o));
17
+ }, [t, o]), /* @__PURE__ */ u(a.Provider, { value: { themeScheme: t, setThemeScheme: r, themeColor: o, setThemeColor: h }, children: S });
24
18
  };
25
19
  export {
26
- x as ThemeContext,
27
- D as ThemeProvider
20
+ a as ThemeContext,
21
+ T as ThemeProvider
28
22
  };
@@ -13,7 +13,7 @@ export declare enum EThemeScheme {
13
13
  dark = "dark",
14
14
  system = "system"
15
15
  }
16
- export type TThemeScheme = keyof typeof EThemeScheme;
16
+ export type TThemeScheme = keyof typeof EThemeScheme | undefined;
17
17
  export declare const defaultScheme = EThemeScheme.system;
18
18
  export declare enum EThemeColor {
19
19
  red = "red",
@@ -24,6 +24,6 @@ export declare enum EThemeColor {
24
24
  violet = "violet",
25
25
  black = "black"
26
26
  }
27
- export type TThemeColor = keyof typeof EThemeColor;
27
+ export type TThemeColor = keyof typeof EThemeColor | undefined;
28
28
  export declare const defaultColor = EThemeColor.violet;
29
29
  //# sourceMappingURL=type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/components/context/Theme/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,YAAY,CAAC;IAC1B,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,WAAW,CAAC;IACxB,aAAa,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CAC5C,CAAA;AACD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAA;CACvB,CAAA;AAED,oBAAY,YAAY;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;CACjB;AACD,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,YAAY,CAAC;AACrD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,oBAAY,WAAW;IACtB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;CACf;AACD,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,WAAW,CAAC;AACnD,eAAO,MAAM,YAAY,qBAAqB,CAAC"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/components/context/Theme/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,YAAY,CAAC;IAC1B,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,WAAW,CAAC;IACxB,aAAa,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CAC5C,CAAA;AACD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAA;CACvB,CAAA;AAED,oBAAY,YAAY;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;CACjB;AACD,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,YAAY,GAAG,SAAS,CAAC;AACjE,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,oBAAY,WAAW;IACtB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;CACf;AACD,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,WAAW,GAAG,SAAS,CAAC;AAC/D,eAAO,MAAM,YAAY,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemeSwitch.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/SchemeSwitch/SchemeSwitch.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,YAAY,kHAyBvB,CAAC"}
1
+ {"version":3,"file":"SchemeSwitch.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/SchemeSwitch/SchemeSwitch.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,YAAY,kHAyBvB,CAAC"}
@@ -1,25 +1,25 @@
1
1
  "use client";
2
2
  import { jsx as p } from "react/jsx-runtime";
3
- import { forwardRef as S, useMemo as m } from "react";
3
+ import { forwardRef as S, useMemo as n } from "react";
4
4
  import { Button as y } from "../../base/Button/Button.js";
5
5
  import { useXTheme as T } from "../../context/useContext.js";
6
6
  import { THEME_SCHEME as o } from "../../../utils/constants/commons.js";
7
- const w = S((n, r) => {
8
- const { className: c, withLabel: i = !1, type: s = "secondary", size: a = "default", iconType: h = "solid" } = n, { themeScheme: e, setThemeScheme: f } = T(), l = m(() => o[(o.findIndex((t) => t.name === e) + 1) % o.length], [e]), u = m(() => {
7
+ const w = S((r, c) => {
8
+ const { className: i, withLabel: s = !1, type: a = "secondary", size: h = "default", iconType: f = "solid" } = r, { themeScheme: e, setThemeScheme: l } = T(), m = n(() => o[(o.findIndex((t) => t.name === e) + 1) % o.length], [e]), u = n(() => {
9
9
  var t;
10
10
  return ((t = o.find((d) => d.name === e)) == null ? void 0 : t.icon) ?? "";
11
11
  }, [e]);
12
12
  return /* @__PURE__ */ p(
13
13
  y,
14
14
  {
15
- ref: r,
16
- className: c,
17
- type: s,
18
- size: a,
15
+ ref: c,
16
+ className: i,
17
+ type: a,
18
+ size: h,
19
19
  icon: u,
20
- iconType: h,
21
- label: i ? `${e === "system" ? "auto" : e}` : void 0,
22
- onClick: () => f(l.name)
20
+ iconType: f,
21
+ label: s ? e === "system" ? "auto" : e : void 0,
22
+ onClick: () => m.name && l(m.name)
23
23
  }
24
24
  );
25
25
  });
@@ -1,5 +1,7 @@
1
1
  import { EThemeScheme } from '../../components/context/Theme/type';
2
2
  export declare const STORAGE: {
3
+ themeSchemeAttr: string;
4
+ themeColorAttr: string;
3
5
  themeScheme: string;
4
6
  themeColor: string;
5
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"commons.d.ts","sourceRoot":"","sources":["../../../src/utils/constants/commons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,eAAO,MAAM,OAAO;;;CAGnB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;EAIf,CAAC"}
1
+ {"version":3,"file":"commons.d.ts","sourceRoot":"","sources":["../../../src/utils/constants/commons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;EAIf,CAAC"}
@@ -1,13 +1,15 @@
1
1
  import { EThemeScheme as e } from "../../components/context/Theme/type.js";
2
- const o = {
2
+ const t = {
3
+ themeSchemeAttr: "data-theme-scheme",
4
+ themeColorAttr: "data-theme-color",
3
5
  themeScheme: "xThemeScheme",
4
6
  themeColor: "xThemeColor"
5
- }, c = [
7
+ }, o = [
6
8
  { name: e.system, icon: "f390" },
7
9
  { name: e.light, icon: "f185" },
8
10
  { name: e.dark, icon: "f6c3" }
9
11
  ];
10
12
  export {
11
- o as STORAGE,
12
- c as THEME_SCHEME
13
+ t as STORAGE,
14
+ o as THEME_SCHEME
13
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"themeController.d.ts","sourceRoot":"","sources":["../../../src/utils/helper/themeController.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,SAAQ,MAAsB,EAAE,QAAM,MAAqB,WA+C1F,CAAC"}
1
+ {"version":3,"file":"themeController.d.ts","sourceRoot":"","sources":["../../../src/utils/helper/themeController.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,SAAQ,MAAsB,EAAE,QAAO,MAAqB,WAW3F,CAAC"}
@@ -1,52 +1,16 @@
1
- import { defaultScheme as m, defaultColor as h } from "../../components/context/Theme/type.js";
1
+ import { defaultScheme as m, defaultColor as r } from "../../components/context/Theme/type.js";
2
2
  import { STORAGE as e } from "../constants/commons.js";
3
- const c = (o = m, t = h) => `
4
- (function () {
5
- function setThemeScheme(newThemeScheme) {
6
- document.documentElement.setAttribute("data-theme-scheme", newThemeScheme);
7
- window.__themeScheme = newThemeScheme;
8
- window.__onThemeSchemeChange(newThemeScheme);
9
- }
10
- function setThemeColor(newThemeColor) {
11
- document.documentElement.setAttribute("data-theme-color", newThemeColor);
12
- window.__themeColor = newThemeColor;
13
- window.__onThemeColorChange(newThemeColor);
14
- }
15
- function saveToStore() {
16
- try {
17
- localStorage.setItem("${e.themeScheme}", JSON.stringify(window.__themeScheme));
18
- } catch (err) {}
19
- try {
20
- localStorage.setItem("${e.themeColor}", JSON.stringify(window.__themeColor));
21
- } catch (err) {}
22
- }
23
-
24
- window.__onThemeSchemeChange = function () {};
25
- window.__onThemeColorChange = function () {};
26
-
27
- window.__setPreferredThemeScheme = function (newThemeScheme) {
28
- setThemeScheme(newThemeScheme);
29
- saveToStore();
30
- };
31
- window.__setPreferredThemeColor = function (newThemeColor) {
32
- setThemeColor(newThemeColor);
33
- saveToStore();
34
- };
35
-
36
- let themeScheme;
37
- let themeColor;
38
-
39
- try {
40
- themeScheme = JSON.parse(localStorage.getItem("${e.themeScheme}"));
41
- } catch (err) {}
42
- try {
43
- themeColor = JSON.parse(localStorage.getItem("${e.themeColor}"));
44
- } catch (err) {}
45
-
46
- setThemeScheme(themeScheme || "${o}");
47
- setThemeColor(themeColor || "${t}");
48
- })();
3
+ const l = (t = m, o = r) => `
4
+ (function() {
5
+ try {
6
+ const themeScheme = localStorage.getItem('${e.themeScheme}') || '${t}';
7
+ const themeColor = localStorage.getItem('${e.themeColor}') || '${o}';
8
+
9
+ document.documentElement.setAttribute('${e.themeSchemeAttr}', themeScheme);
10
+ document.documentElement.setAttribute('${e.themeColorAttr}', themeColor);
11
+ } catch (e) {}
12
+ })();
49
13
  `;
50
14
  export {
51
- c as themeController
15
+ l as themeController
52
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xtreme-ui",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
4
4
  "type": "module",
5
5
  "description": "Collection of reusable components that can be used in web projects",
6
6
  "main": "dist/index.js",