triafly-ui-kit 1.0.70 → 1.0.72

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,35 +1,33 @@
1
- import { jsxs as p, jsx as l } from "react/jsx-runtime";
1
+ import { jsxs as p, jsx as d } from "react/jsx-runtime";
2
2
  import { createContext as x, useState as f, useCallback as u, useMemo as h, useContext as w } from "react";
3
- import g from "react-dom";
3
+ import C from "react-dom";
4
4
  import '../../assets/src/context/ToastContext/ToastContext.css';/* empty css */
5
5
  const m = x(void 0), j = () => {
6
- const o = w(m);
7
- if (!o)
6
+ const e = w(m);
7
+ if (!e)
8
8
  throw new Error("useToast must be used within a ToastProvider");
9
- return o;
10
- }, M = ({ children: o }) => {
11
- const [r, n] = f([]), T = 3, c = 4e3, i = u((t) => {
12
- n((e) => e.filter((s) => s.id !== t));
13
- }, []), d = u(
9
+ return e;
10
+ }, M = ({ children: e }) => {
11
+ const [l, a] = f([]), T = 3, n = 4e3, i = u((t) => {
12
+ a((o) => o.filter((s) => s.id !== t));
13
+ }, []), c = u(
14
14
  (t) => {
15
- const e = {
15
+ const o = {
16
16
  id: Date.now(),
17
17
  message: t,
18
- duration: c
18
+ duration: n
19
19
  };
20
- n((s) => {
21
- const a = [...s, e];
22
- return a.length > T ? a.slice(1) : a;
23
- }), setTimeout(() => i(e.id), c);
20
+ a((s) => {
21
+ const r = [...s, o];
22
+ return r.length > T ? r.slice(1) : r;
23
+ }), setTimeout(() => i(o.id), n);
24
24
  },
25
25
  [i]
26
- );
27
- console.log("тест addToast"), console.log("toasts", r);
28
- const v = h(() => ({ addToast: d }), [d]);
26
+ ), v = h(() => ({ addToast: c }), [c]);
29
27
  return /* @__PURE__ */ p(m.Provider, { value: v, children: [
30
- o,
31
- g.createPortal(
32
- /* @__PURE__ */ l("div", { className: "toast-provider", children: r.map((t) => /* @__PURE__ */ l("div", { className: "toast-provider__element", children: t.message }, t.id)) }),
28
+ e,
29
+ C.createPortal(
30
+ /* @__PURE__ */ d("div", { className: "toast-provider", children: l.map((t) => /* @__PURE__ */ d("div", { className: "toast-provider__element", children: t.message }, t.id)) }),
33
31
  document.body
34
32
  )
35
33
  ] });
@@ -1,27 +1,28 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { createContext as s, useMemo as m, useContext as a } from "react";
3
- import { useBreakpointValueTriafly as u } from "./hooks/useBreakpointValue/useBreakpointValue.js";
4
- import { useThemeLogic as f } from "./hooks/useTheme/useTheme.js";
5
- import { useModalState as l } from "./hooks/useModal/useModal.js";
6
- const t = s(void 0), y = () => {
7
- const e = a(t);
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { createContext as n, useMemo as a, useContext as u } from "react";
3
+ import { useBreakpointValueTriafly as f } from "./hooks/useBreakpointValue/useBreakpointValue.js";
4
+ import { useThemeLogic as l } from "./hooks/useTheme/useTheme.js";
5
+ import { useModalState as c } from "./hooks/useModal/useModal.js";
6
+ const i = n(void 0), y = () => {
7
+ const e = u(i);
8
8
  if (!e)
9
9
  throw new Error("useTriafly must be used within a TriaflyProvider");
10
10
  return e;
11
- }, h = ({ children: e }) => {
12
- const { theme: o, toggleTheme: r } = f(), i = m(
11
+ }, v = ({ children: e }) => {
12
+ const { theme: t, toggleTheme: o, setTheme: r } = l(), s = a(
13
13
  () => ({
14
- theme: o,
15
- toggleTheme: r,
16
- useBreakpointValueTriafly: u,
17
- useModalState: l
14
+ theme: t,
15
+ toggleTheme: o,
16
+ useBreakpointValueTriafly: f,
17
+ useModalState: c,
18
+ setTheme: r
18
19
  }),
19
- [o, r]
20
+ [t, o, r]
20
21
  );
21
- return /* @__PURE__ */ n(t.Provider, { value: i, children: e });
22
+ return /* @__PURE__ */ m(i.Provider, { value: s, children: e });
22
23
  };
23
24
  export {
24
- t as TriaflyContext,
25
- h as TriaflyProvider,
25
+ i as TriaflyContext,
26
+ v as TriaflyProvider,
26
27
  y as useTriafly
27
28
  };
@@ -1,16 +1,16 @@
1
1
  import { useSyncExternalStore as n } from "react";
2
- const o = () => {
2
+ const r = () => {
3
3
  const t = window.matchMedia("(prefers-color-scheme: dark)").matches;
4
4
  return localStorage.getItem("theme") || (t ? "dark" : "light");
5
- }, m = o();
5
+ }, m = r();
6
6
  document.documentElement.setAttribute("data-theme", m);
7
7
  const c = () => {
8
- const t = n((e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e)), o), r = (e) => {
8
+ const t = n((e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e)), r), o = (e) => {
9
9
  localStorage.setItem("theme", e), localStorage.setItem("chakra-ui-color-mode", e), document.documentElement.setAttribute("data-theme", e), window.dispatchEvent(new Event("storage"));
10
10
  };
11
11
  return { theme: t, toggleTheme: () => {
12
- r(t === "light" ? "dark" : "light");
13
- } };
12
+ o(t === "light" ? "dark" : "light");
13
+ }, setTheme: o };
14
14
  };
15
15
  export {
16
16
  c as useThemeLogic
package/dist/main.d.ts CHANGED
@@ -1277,6 +1277,7 @@ export declare const TriaflyContext: Context<TriaflyContextType | undefined>;
1277
1277
  declare interface TriaflyContextType {
1278
1278
  theme: Theme;
1279
1279
  toggleTheme: () => void;
1280
+ setTheme: (newTheme: Theme) => void;
1280
1281
  useBreakpointValueTriafly: <T>(values: BreakpointValuesTriafly<T>) => T;
1281
1282
  useModalState: typeof useModalState;
1282
1283
  }
@@ -1300,6 +1301,7 @@ export declare const useModalState: () => UseModalReturn;
1300
1301
  export declare const useThemeLogic: () => {
1301
1302
  theme: Theme;
1302
1303
  toggleTheme: () => void;
1304
+ setTheme: (newTheme: Theme) => void;
1303
1305
  };
1304
1306
 
1305
1307
  export declare const useToast: () => ToastContextType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triafly-ui-kit",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "description": "UI Kit from Triafly",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",
@@ -42,9 +42,9 @@
42
42
  ],
43
43
  "peerDependencies": {
44
44
  "classnames": "^2.5.1",
45
- "react": "^18.0.0",
46
- "react-dom": "^18.0.0",
47
- "react-router-dom": "6.26.1"
45
+ "react": "^17.0.2",
46
+ "react-dom": "^17.0.2",
47
+ "react-router-dom": "5.3.4"
48
48
  },
49
49
  "dependencies": {
50
50
  "dayjs": "^1.11.13",