@krosoft/react 0.0.71 → 0.0.73

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.
Files changed (40) hide show
  1. package/dist/KpiCards-Bjsd4bSz.js +40 -0
  2. package/dist/{SearchInput-LIey3bo9.js → SearchInput-Bu4wb0gI.js} +10 -9
  3. package/dist/ThemeSelector-DMgBLEYm.js +49 -0
  4. package/dist/Topbar-CFALRIJn.js +168 -0
  5. package/dist/{badge-Cj2EQgcL.js → badge-C4pCH7IL.js} +1 -1
  6. package/dist/components/core/cards/KpiCards.d.ts.map +1 -1
  7. package/dist/components/core/cards/index.js +1 -1
  8. package/dist/components/core/index.d.ts +1 -0
  9. package/dist/components/core/index.d.ts.map +1 -1
  10. package/dist/components/core/index.js +10 -8
  11. package/dist/components/core/inputs/index.js +1 -1
  12. package/dist/components/core/navbar/index.js +1 -1
  13. package/dist/components/core/theme/ThemeSelector.d.ts +8 -0
  14. package/dist/components/core/theme/ThemeSelector.d.ts.map +1 -0
  15. package/dist/components/core/theme/index.d.ts +3 -0
  16. package/dist/components/core/theme/index.d.ts.map +1 -0
  17. package/dist/components/core/theme/index.js +4 -0
  18. package/dist/components/index.js +41 -30
  19. package/dist/components/ui/index.d.ts +1 -0
  20. package/dist/components/ui/index.d.ts.map +1 -1
  21. package/dist/components/ui/index.js +27 -18
  22. package/dist/components/ui/select.d.ts +14 -0
  23. package/dist/components/ui/select.d.ts.map +1 -0
  24. package/dist/hooks/index.d.ts +2 -0
  25. package/dist/hooks/index.d.ts.map +1 -1
  26. package/dist/hooks/index.js +16 -112
  27. package/dist/hooks/ui/useTheme.d.ts +20 -0
  28. package/dist/hooks/ui/useTheme.d.ts.map +1 -0
  29. package/dist/index-BQOmHRsD.js +1662 -0
  30. package/dist/select-CdiR6cO0.js +2020 -0
  31. package/dist/tailwind/index.d.ts +1 -1
  32. package/dist/tailwind/index.d.ts.map +1 -1
  33. package/dist/tailwind/index.js +3 -1
  34. package/dist/{toast-B6CC_ory.js → toast-BypnW71k.js} +1 -1
  35. package/dist/tooltip-Dep8OR3c.js +779 -0
  36. package/dist/useTheme-D__o7mLN.js +122 -0
  37. package/package.json +10 -2
  38. package/dist/KpiCards-D4Cy8CLT.js +0 -38
  39. package/dist/Topbar-CtXJ337W.js +0 -2314
  40. package/dist/index-BNCR478R.js +0 -272
@@ -0,0 +1,122 @@
1
+ import { useTheme as _ } from "next-themes";
2
+ import * as l from "react";
3
+ const I = 1, O = 1e6;
4
+ let i = 0;
5
+ function D() {
6
+ return i = (i + 1) % Number.MAX_SAFE_INTEGER, i.toString();
7
+ }
8
+ const S = /* @__PURE__ */ new Map(), h = (s) => {
9
+ if (S.has(s))
10
+ return;
11
+ const e = setTimeout(() => {
12
+ S.delete(s), c({
13
+ type: "REMOVE_TOAST",
14
+ toastId: s
15
+ });
16
+ }, O);
17
+ S.set(s, e);
18
+ }, v = (s, e) => {
19
+ switch (e.type) {
20
+ case "ADD_TOAST":
21
+ return {
22
+ ...s,
23
+ toasts: [e.toast, ...s.toasts].slice(0, I)
24
+ };
25
+ case "UPDATE_TOAST":
26
+ return {
27
+ ...s,
28
+ toasts: s.toasts.map((t) => t.id === e.toast.id ? { ...t, ...e.toast } : t)
29
+ };
30
+ case "DISMISS_TOAST": {
31
+ const { toastId: t } = e;
32
+ return t ? h(t) : s.toasts.forEach((o) => {
33
+ h(o.id);
34
+ }), {
35
+ ...s,
36
+ toasts: s.toasts.map(
37
+ (o) => o.id === t || t === void 0 ? {
38
+ ...o,
39
+ open: !1
40
+ } : o
41
+ )
42
+ };
43
+ }
44
+ case "REMOVE_TOAST":
45
+ return e.toastId === void 0 ? {
46
+ ...s,
47
+ toasts: []
48
+ } : {
49
+ ...s,
50
+ toasts: s.toasts.filter((t) => t.id !== e.toastId)
51
+ };
52
+ }
53
+ }, a = [];
54
+ let u = { toasts: [] };
55
+ function c(s) {
56
+ u = v(u, s), a.forEach((e) => {
57
+ e(u);
58
+ });
59
+ }
60
+ function d({ ...s }) {
61
+ const e = D(), t = (n) => c({
62
+ type: "UPDATE_TOAST",
63
+ toast: { ...n, id: e }
64
+ }), o = () => c({ type: "DISMISS_TOAST", toastId: e });
65
+ return c({
66
+ type: "ADD_TOAST",
67
+ toast: {
68
+ ...s,
69
+ id: e,
70
+ open: !0,
71
+ onOpenChange: (n) => {
72
+ n || o();
73
+ }
74
+ }
75
+ }), {
76
+ id: e,
77
+ dismiss: o,
78
+ update: t
79
+ };
80
+ }
81
+ function x() {
82
+ const [s, e] = l.useState(u);
83
+ return l.useEffect(() => (a.push(e), () => {
84
+ const t = a.indexOf(e);
85
+ t > -1 && a.splice(t, 1);
86
+ }), [s]), {
87
+ ...s,
88
+ toast: d,
89
+ dismiss: (t) => c({ type: "DISMISS_TOAST", toastId: t })
90
+ };
91
+ }
92
+ const y = () => ({
93
+ showSuccess: (t, o, n) => {
94
+ d({ title: t, description: o, action: n });
95
+ },
96
+ showError: (t, o, n) => {
97
+ console.error(o, n), d({ title: t, description: o, variant: "destructive" });
98
+ }
99
+ });
100
+ function R(s) {
101
+ const { showSuccess: e } = y(), { theme: t, setTheme: o } = _(), n = (r) => {
102
+ o(r);
103
+ const T = s.find((p) => p.value === r);
104
+ e("Thème mis à jour", `Le thème a été changé vers ${(T == null ? void 0 : T.label) ?? r}.`);
105
+ }, m = s.find((r) => r.value === t), A = s.findIndex((r) => r.value === t), f = s[(A + 1) % s.length], E = (t == null ? void 0 : t.startsWith("dark")) ?? !1;
106
+ return {
107
+ theme: t,
108
+ setTheme: o,
109
+ handleThemeChange: n,
110
+ themeOptions: s,
111
+ currentThemeOption: m,
112
+ nextThemeOption: f,
113
+ isDark: E,
114
+ cycleTheme: () => n(f.value)
115
+ };
116
+ }
117
+ export {
118
+ y as a,
119
+ x as b,
120
+ d as t,
121
+ R as u
122
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -31,13 +31,20 @@
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@krosoft/core": ">=0.0.1",
34
+ "next-themes": ">=0.4.0",
34
35
  "react": ">=18.3.1",
35
36
  "react-i18next": ">=17.0.8"
36
37
  },
38
+ "peerDependenciesMeta": {
39
+ "next-themes": {
40
+ "optional": true
41
+ }
42
+ },
37
43
  "dependencies": {
38
44
  "@radix-ui/react-dialog": "^1.1.15",
39
- "@radix-ui/react-separator": "^1.1.8",
40
45
  "@radix-ui/react-popover": "^1.1.15",
46
+ "@radix-ui/react-select": "^2.2.6",
47
+ "@radix-ui/react-separator": "^1.1.8",
41
48
  "@radix-ui/react-toast": "^1.2.15",
42
49
  "@radix-ui/react-tooltip": "^1.2.8",
43
50
  "class-variance-authority": "^0.7.1",
@@ -57,6 +64,7 @@
57
64
  "@types/react": "^18.3.29",
58
65
  "autoprefixer": "^10.5.0",
59
66
  "jsdom": "^26.1.0",
67
+ "next-themes": "^0.4.6",
60
68
  "prettier": "^3.8.3",
61
69
  "react": "^18.3.1",
62
70
  "react-dom": "^18.3.1",
@@ -1,38 +0,0 @@
1
- import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
- import { C as p, f, g as u, c as N } from "./toast-B6CC_ory.js";
3
- import "./index-BNCR478R.js";
4
- import { c as a } from "./index-gWiv5-6R.js";
5
- import C from "react";
6
- import { formatNumber as x } from "@krosoft/core/helpers";
7
- import { useTranslation as g } from "react-i18next";
8
- const h = ({ titleKey: s, value: e, valueClassName: m, icon: l, iconClassName: t, description: c, descriptionClassName: d, onClick: o }) => {
9
- const { t: n } = g();
10
- return /* @__PURE__ */ i(p, { className: a(o ? "hover:border-primary cursor-pointer" : ""), onClick: o, children: [
11
- /* @__PURE__ */ i(f, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
12
- /* @__PURE__ */ r(u, { className: "text-sm font-medium", children: n(s) }),
13
- C.createElement(l, {
14
- className: a("size-6 text-muted-foreground", t)
15
- })
16
- ] }),
17
- /* @__PURE__ */ i(N, { children: [
18
- /* @__PURE__ */ r("div", { className: a("text-2xl font-bold", m), children: x(e) }),
19
- /* @__PURE__ */ r("p", { className: a("text-xs text-muted-foreground", d), children: c })
20
- ] })
21
- ] });
22
- }, _ = ({ stats: s }) => /* @__PURE__ */ r("div", { className: "grid gap-6 md:grid-cols-2 lg:grid-cols-4", children: s.map((e) => /* @__PURE__ */ r(
23
- h,
24
- {
25
- titleKey: e.titleKey,
26
- value: e.value,
27
- valueClassName: e.valueClassName,
28
- icon: e.icon,
29
- iconClassName: e.iconClassName,
30
- description: e.description,
31
- descriptionClassName: e.descriptionClassName
32
- },
33
- e.titleKey
34
- )) });
35
- export {
36
- h as K,
37
- _ as a
38
- };