triafly-ui-kit 1.0.51 → 1.0.53

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,26 +1,31 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { jsx as c } from "react/jsx-runtime";
2
2
  import '../../../../assets/src/components/Ui/Form/FormRoot/Form.css';/* empty css */
3
- import { useMemo as l } from "react";
4
- import { FormContext as f } from "../FormContext/FormContext.js";
5
- import { FormItem as i } from "../FormItem/FormItem.js";
6
- import { useForm as p } from "../useForm/useForm.js";
7
- const v = ({ form: m, children: c, onFinish: o, disabled: t = !1 }) => {
8
- const n = p()[0], s = l(() => {
9
- const r = m || n;
10
- return r.disabled = t, r;
11
- }, [m, n, t]), u = async (r) => {
12
- r.preventDefault();
3
+ import { useMemo as u } from "react";
4
+ import { FormContext as p } from "../FormContext/FormContext.js";
5
+ import { FormItem as d } from "../FormItem/FormItem.js";
6
+ import { useForm as v, FormValidationError as F } from "../useForm/useForm.js";
7
+ const w = ({ form: a, children: s, onFinish: o, disabled: e = !1 }) => {
8
+ const n = v()[0], m = u(() => {
9
+ const t = a || n;
10
+ return t.disabled = e, t;
11
+ }, [a, n, e]), f = async (t) => {
12
+ t.preventDefault();
13
13
  try {
14
- if (t) return;
15
- const e = await s.validateFields();
16
- o == null || o(e);
17
- } catch (e) {
18
- console.error("Form submission error:", e);
14
+ if (e) return;
15
+ const r = await m.validateFields();
16
+ await (o == null ? void 0 : o(r));
17
+ } catch (r) {
18
+ if (r instanceof F)
19
+ r.errors.forEach(({ name: l, errors: i }) => {
20
+ m.setFieldError(l, i);
21
+ });
22
+ else
23
+ throw r;
19
24
  }
20
25
  };
21
- return /* @__PURE__ */ a(f.Provider, { value: s || null, children: /* @__PURE__ */ a("form", { onSubmit: u, children: c }) });
26
+ return /* @__PURE__ */ c(p.Provider, { value: m || null, children: /* @__PURE__ */ c("form", { onSubmit: f, children: s }) });
22
27
  };
23
- v.Item = i;
28
+ w.Item = d;
24
29
  export {
25
- v as Form
30
+ w as Form
26
31
  };
@@ -1,6 +1,7 @@
1
1
  import { Form as m } from "./FormRoot/FormRoot.js";
2
- import { useForm as f } from "./useForm/useForm.js";
2
+ import { FormValidationError as t, useForm as F } from "./useForm/useForm.js";
3
3
  export {
4
4
  m as Form,
5
- f as useForm
5
+ t as FormValidationError,
6
+ F as useForm
6
7
  };
@@ -1,4 +1,5 @@
1
- import { useForm as e } from "./useForm.js";
1
+ import { FormValidationError as m, useForm as a } from "./useForm.js";
2
2
  export {
3
- e as useForm
3
+ m as FormValidationError,
4
+ a as useForm
4
5
  };
@@ -1,33 +1,37 @@
1
- import { useRef as y, useCallback as g } from "react";
2
- import { normalizePath as i, validateRule as b, getFieldKey as f, getByPath as k, getNestedValue as V, setByPath as v } from "../utils/fn.js";
1
+ import { useRef as y, useCallback as F } from "react";
2
+ import { normalizePath as u, validateRule as b, getFieldKey as f, getByPath as k, getNestedValue as V, setByPath as v } from "../utils/fn.js";
3
3
  class O extends Error {
4
- constructor(l) {
5
- super("Form validation failed"), this.errorFields = l, this.name = "FormValidationError";
4
+ constructor(i) {
5
+ super("Form validation failed"), this.errors = i, this.name = "FormValidationError";
6
+ }
7
+ toString() {
8
+ return this.errors.map((i) => `${i.name}: ${i.errors.join(", ")}`).join(`
9
+ `);
6
10
  }
7
11
  }
8
- function N() {
9
- const a = y({}), l = y({}), p = y({}), o = y({}), d = g((t) => {
10
- const r = i(t), e = /* @__PURE__ */ new Set();
11
- e.add(r.join("."));
12
- for (let n = 1; n < r.length; n++)
13
- e.add(r.slice(0, n).join("."));
12
+ function S() {
13
+ const a = y({}), i = y({}), p = y({}), o = y({}), d = F((r) => {
14
+ const t = u(r), e = /* @__PURE__ */ new Set();
15
+ e.add(t.join("."));
16
+ for (let n = 1; n < t.length; n++)
17
+ e.add(t.slice(0, n).join("."));
14
18
  e.forEach((n) => {
15
19
  var s;
16
20
  (s = o.current[n]) == null || s.forEach((c) => c());
17
21
  });
18
- }, []), m = g(
19
- async (t, r, e) => {
22
+ }, []), m = F(
23
+ async (r, t, e) => {
20
24
  if (!e) return [];
21
- const n = (await Promise.all(e.map((c) => b(c, r)))).filter(Boolean), s = f(t);
22
- return l.current[s] = n, d(s), n;
25
+ const n = (await Promise.all(e.map((c) => b(c, t)))).filter(Boolean), s = f(r);
26
+ return i.current[s] = n, d(s), n;
23
27
  },
24
28
  [d]
25
- ), w = g(
26
- async (t) => {
27
- const r = t || Object.keys(p.current).map((n) => n.includes(".") ? n.split(".") : n), e = {};
29
+ ), w = F(
30
+ async (r) => {
31
+ const t = r || Object.keys(p.current).map((n) => n.includes(".") ? n.split(".") : n), e = {};
28
32
  if (await Promise.all(
29
- r.map(async (n) => {
30
- const s = i(n), c = f(s), u = p.current[c] || [], F = k(a.current, s), h = await m(s, F, u);
33
+ t.map(async (n) => {
34
+ const s = u(n), c = f(s), l = p.current[c] || [], g = k(a.current, s), h = await m(s, g, l);
31
35
  h.length && (e[c] = h);
32
36
  })
33
37
  ), Object.keys(e).length)
@@ -40,72 +44,73 @@ function N() {
40
44
  return { ...a.current };
41
45
  },
42
46
  [m]
43
- ), E = (t) => Array.isArray(t) ? t : typeof t == "string" && t.includes(".") ? t.split(".") : [t], j = y({
47
+ ), E = (r) => Array.isArray(r) ? r : typeof r == "string" && r.includes(".") ? r.split(".") : [r], j = y({
44
48
  resetFields: () => {
45
- a.current = {}, l.current = {}, Object.keys(o.current).forEach(d);
49
+ a.current = {}, i.current = {}, Object.keys(o.current).forEach(d);
46
50
  },
47
- setFieldsValue: (t) => {
48
- const r = { ...a.current };
49
- Object.entries(t).forEach(([e, n]) => {
51
+ setFieldsValue: (r) => {
52
+ const t = { ...a.current };
53
+ Object.entries(r).forEach(([e, n]) => {
50
54
  const s = E(e);
51
- v(r, s, n);
52
- }), a.current = r, Object.keys(t).forEach((e) => {
55
+ v(t, s, n);
56
+ }), a.current = t, Object.keys(r).forEach((e) => {
53
57
  d(Array.isArray(e) ? e.join(".") : e);
54
58
  });
55
59
  },
56
- setFieldValue: (t, r) => {
57
- const e = i(t), n = JSON.parse(JSON.stringify(a.current));
60
+ setFieldValue: (r, t) => {
61
+ const e = u(r), n = JSON.parse(JSON.stringify(a.current));
58
62
  let s = n;
59
63
  for (let c = 0; c < e.length - 1; c++) {
60
- const u = e[c];
61
- s[u] || (s[u] = {}), s = s[u];
64
+ const l = e[c];
65
+ s[l] || (s[l] = {}), s = s[l];
62
66
  }
63
- s[e[e.length - 1]] = r, a.current = n, d(e);
67
+ s[e[e.length - 1]] = t, a.current = n, d(e);
64
68
  },
65
- getFieldValue: (t) => {
66
- const r = i(t);
67
- return V(a.current, r);
69
+ getFieldValue: (r) => {
70
+ const t = u(r);
71
+ return V(a.current, t);
68
72
  },
69
73
  getFieldsValue: () => ({ ...a.current }),
70
74
  submit: async () => {
71
75
  await j.validateFields();
72
76
  },
73
77
  validateFields: w,
74
- getFieldError: (t) => {
75
- const r = f(i(t));
76
- return l.current[r] || [];
78
+ getFieldError: (r) => {
79
+ const t = f(u(r));
80
+ return i.current[t] || [];
77
81
  },
78
- setFieldError: (t, r) => {
79
- const e = f(i(t));
80
- l.current[e] = r, d(e);
82
+ setFieldError: (r, t) => {
83
+ const e = f(u(r));
84
+ i.current[e] = t, d(e);
81
85
  },
82
- getFieldRules: (t) => {
83
- const r = f(i(t));
84
- return p.current[r] || [];
86
+ getFieldRules: (r) => {
87
+ const t = f(u(r));
88
+ return p.current[t] || [];
85
89
  },
86
- setFieldRules: (t, r) => {
87
- const e = f(i(t));
88
- p.current[e] = r;
90
+ setFieldRules: (r, t) => {
91
+ const e = f(u(r));
92
+ p.current[e] = t;
89
93
  },
90
- subscribe: (t, r) => {
91
- const e = i(t), n = e.join(".");
92
- if (o.current[n] || (o.current[n] = /* @__PURE__ */ new Set()), o.current[n].add(r), e.length > 1) {
94
+ subscribe: (r, t) => {
95
+ const e = u(r), n = e.join(".");
96
+ if (o.current[n] || (o.current[n] = /* @__PURE__ */ new Set()), o.current[n].add(t), e.length > 1) {
93
97
  const c = e.slice(0, -1).join(".");
94
98
  o.current[c] || (o.current[c] = /* @__PURE__ */ new Set());
95
- const u = () => r();
96
- return o.current[c].add(u), () => {
97
- var F, h;
98
- (F = o.current[n]) == null || F.delete(r), (h = o.current[c]) == null || h.delete(u);
99
+ const l = () => t();
100
+ return o.current[c].add(l), () => {
101
+ var g, h;
102
+ (g = o.current[n]) == null || g.delete(t), (h = o.current[c]) == null || h.delete(l);
99
103
  };
100
104
  }
101
105
  return () => {
102
106
  var s;
103
- return (s = o.current[n]) == null ? void 0 : s.delete(r);
107
+ return (s = o.current[n]) == null ? void 0 : s.delete(t);
104
108
  };
105
109
  }
106
110
  }).current;
107
111
  return [j];
108
112
  }
109
113
  export {
110
- N as useForm
114
+ O as FormValidationError,
115
+ S as useForm
111
116
  };
package/dist/main.d.ts CHANGED
@@ -1081,7 +1081,7 @@ declare type RadioProps = {
1081
1081
 
1082
1082
  declare type RositionModal = "center" | "right" | "left" | "top" | "bottom";
1083
1083
 
1084
- declare type Rule = {
1084
+ export declare type Rule = {
1085
1085
  required?: boolean;
1086
1086
  message?: string;
1087
1087
  pattern?: RegExp;
@@ -1233,6 +1233,10 @@ declare type TextInputProps = {
1233
1233
 
1234
1234
  declare type Theme = "light" | "dark";
1235
1235
 
1236
+ declare interface ToastContextType {
1237
+ addToast: (message: string) => void;
1238
+ }
1239
+
1236
1240
  export declare const ToastProvider: ({ children }: {
1237
1241
  children: ReactNode;
1238
1242
  }) => JSX.Element;
@@ -1280,6 +1284,8 @@ export declare const useThemeLogic: () => {
1280
1284
  toggleTheme: () => void;
1281
1285
  };
1282
1286
 
1287
+ export declare const useToast: () => ToastContextType;
1288
+
1283
1289
  export declare const useTriafly: () => TriaflyContextType;
1284
1290
 
1285
1291
  export { }
package/dist/main.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { Accordeon as e } from "./components/Ui/Accordeon/Accordeon.js";
2
2
  import { Alert as t } from "./components/Ui/Alert/Alert.js";
3
- import { Avatar as i } from "./components/Ui/Avatar/Avatar.js";
3
+ import { Avatar as a } from "./components/Ui/Avatar/Avatar.js";
4
4
  import { ModalWindow as p } from "./components/Ui/ModalWindow/ModalWindow.js";
5
5
  import { Badge as f } from "./components/Ui/Badge/Badge.js";
6
6
  import { DatePicker as x } from "./components/Ui/DatePicker/DatePicker.js";
7
7
  import { DateRangePicker as u } from "./components/Ui/DateRangePicker/DateRangePicker.js";
8
8
  import { Button as d } from "./components/Ui/Button/Button.js";
9
9
  import { ButtonsArray as w } from "./components/Ui/ButtonsArray/ButtonsArray.js";
10
- import { Checkbox as k } from "./components/Ui/Checkbox/Checkbox.js";
11
- import { CliTextareaInput as T } from "./components/Ui/CliTextareaInput/CliTextareaInput.js";
10
+ import { Checkbox as g } from "./components/Ui/Checkbox/Checkbox.js";
11
+ import { CliTextareaInput as S } from "./components/Ui/CliTextareaInput/CliTextareaInput.js";
12
12
  import "react";
13
13
  import { CustomLink as D } from "./components/Ui/CustomLink/CustomLink.js";
14
14
  import { DropdownInput as P } from "./components/Ui/DropdownInput/DropdownInput.js";
@@ -27,21 +27,21 @@ import { TextInput as Z } from "./components/Ui/TextInput/TextInput.js";
27
27
  import { TextareaInput as $ } from "./components/Ui/TextareaInput/TextareaInput.js";
28
28
  import { Tooltip as no } from "./components/Ui/Tooltip/Tooltip.js";
29
29
  import { Tabs as eo } from "./components/Ui/Tabs/Tabs.js";
30
- import { IconArrowBendUpRight as to, IconArrowClockwise as Io, IconArrowDown as io, IconArrowLeft as ao, IconArrowLineDown as po, IconArrowLineLeft as lo, IconArrowLineRight as fo, IconArrowLineUp as mo, IconArrowRight as xo, IconArrowUp as so, IconArrowsOut as uo, IconArticle as Co, IconAt as ho, IconBellSimple as wo, IconBookOpenText as go, IconCalendarBlank as ko, IconCaretDown as So, IconCaretLeft as To, IconCaretRight as Ao, IconCaretUp as Do, IconCaretUpDown as Lo, IconChartPieSlice as Po, IconChatText as yo, IconCheck as Bo, IconCheckCircle as Uo, IconChecks as Fo, IconCircleNotch as Mo, IconClickHouse as Ro, IconCopy as vo, IconCornersOut as Xo, IconCsv as bo, IconCube as Ho, IconDatabase as Go, IconDotsNine as No, IconDotsThreeVertical as Oo, IconExport as Qo, IconEye as Eo, IconEyeSlash as Wo, IconFile as Vo, IconFiles as zo, IconFloppyDisk as Jo, IconFolderSimple as Yo, IconFolderSimpleX as jo, IconFunnel as qo, IconGauge as Ko, IconGear as Zo, IconGitBranchX as _o, IconGoogleDrive as $o, IconHand as on, IconHeadCircuit as nn, IconHouse as rn, IconIcon as en, IconInfo as cn, IconJoin as tn, IconLanguage as In, IconLink as an, IconList as pn, IconLock as ln, IconLockOpen as fn, IconMariaDB as mn, IconMinus as xn, IconMongoDB as sn, IconMoon as un, IconMySQL as Cn, IconNavigationArrow as dn, IconNotePencil as hn, IconPassword as wn, IconPen as gn, IconPlay as kn, IconPlugsX as Sn, IconPlus as Tn, IconPorsgteSQL as An, IconPresentationChart as Dn, IconQuestion as Ln, IconQuestionFullfilled as Pn, IconRedo as yn, IconRoleX as Bn, IconSearch as Un, IconSearchX as Fn, IconSelection as Mn, IconServer as Rn, IconSlidersHorizontal as vn, IconSticker as Xn, IconSun as bn, IconThreeDot as Hn, IconTrash as Gn, IconTriangleDown as Nn, IconTriangleUp as On, IconUndo as Qn, IconUploadSimple as En, IconUser as Wn, IconUserX as Vn, IconWarningCircle as zn, IconWrench as Jn, IconX as Yn, IconYandexDisk as jn } from "./components/Ui/Icons/Icons.js";
31
- import { ToastProvider as Kn } from "./context/ToastContext/ToastContext.js";
32
- import { TriaflyContext as _n, TriaflyProvider as $n, useTriafly as or } from "./context/TriaflyContext/TriaflyProvider.js";
33
- import { useBreakpointValueTriafly as rr } from "./context/TriaflyContext/hooks/useBreakpointValue/useBreakpointValue.js";
34
- import { useThemeLogic as cr } from "./context/TriaflyContext/hooks/useTheme/useTheme.js";
35
- import { useModalState as Ir } from "./context/TriaflyContext/hooks/useModal/useModal.js";
30
+ import { IconArrowBendUpRight as to, IconArrowClockwise as Io, IconArrowDown as ao, IconArrowLeft as io, IconArrowLineDown as po, IconArrowLineLeft as lo, IconArrowLineRight as fo, IconArrowLineUp as mo, IconArrowRight as xo, IconArrowUp as so, IconArrowsOut as uo, IconArticle as Co, IconAt as ho, IconBellSimple as wo, IconBookOpenText as To, IconCalendarBlank as go, IconCaretDown as ko, IconCaretLeft as So, IconCaretRight as Ao, IconCaretUp as Do, IconCaretUpDown as Lo, IconChartPieSlice as Po, IconChatText as yo, IconCheck as Bo, IconCheckCircle as Uo, IconChecks as Fo, IconCircleNotch as Mo, IconClickHouse as Ro, IconCopy as vo, IconCornersOut as Xo, IconCsv as bo, IconCube as Ho, IconDatabase as Go, IconDotsNine as No, IconDotsThreeVertical as Oo, IconExport as Qo, IconEye as Eo, IconEyeSlash as Wo, IconFile as Vo, IconFiles as zo, IconFloppyDisk as Jo, IconFolderSimple as Yo, IconFolderSimpleX as jo, IconFunnel as qo, IconGauge as Ko, IconGear as Zo, IconGitBranchX as _o, IconGoogleDrive as $o, IconHand as on, IconHeadCircuit as nn, IconHouse as rn, IconIcon as en, IconInfo as cn, IconJoin as tn, IconLanguage as In, IconLink as an, IconList as pn, IconLock as ln, IconLockOpen as fn, IconMariaDB as mn, IconMinus as xn, IconMongoDB as sn, IconMoon as un, IconMySQL as Cn, IconNavigationArrow as dn, IconNotePencil as hn, IconPassword as wn, IconPen as Tn, IconPlay as gn, IconPlugsX as kn, IconPlus as Sn, IconPorsgteSQL as An, IconPresentationChart as Dn, IconQuestion as Ln, IconQuestionFullfilled as Pn, IconRedo as yn, IconRoleX as Bn, IconSearch as Un, IconSearchX as Fn, IconSelection as Mn, IconServer as Rn, IconSlidersHorizontal as vn, IconSticker as Xn, IconSun as bn, IconThreeDot as Hn, IconTrash as Gn, IconTriangleDown as Nn, IconTriangleUp as On, IconUndo as Qn, IconUploadSimple as En, IconUser as Wn, IconUserX as Vn, IconWarningCircle as zn, IconWrench as Jn, IconX as Yn, IconYandexDisk as jn } from "./components/Ui/Icons/Icons.js";
31
+ import { ToastProvider as Kn, useToast as Zn } from "./context/ToastContext/ToastContext.js";
32
+ import { TriaflyContext as $n, TriaflyProvider as or, useTriafly as nr } from "./context/TriaflyContext/TriaflyProvider.js";
33
+ import { useBreakpointValueTriafly as er } from "./context/TriaflyContext/hooks/useBreakpointValue/useBreakpointValue.js";
34
+ import { useThemeLogic as tr } from "./context/TriaflyContext/hooks/useTheme/useTheme.js";
35
+ import { useModalState as ar } from "./context/TriaflyContext/hooks/useModal/useModal.js";
36
36
  export {
37
37
  e as Accordeon,
38
38
  t as Alert,
39
- i as Avatar,
39
+ a as Avatar,
40
40
  f as Badge,
41
41
  d as Button,
42
42
  w as ButtonsArray,
43
- k as Checkbox,
44
- T as CliTextareaInput,
43
+ g as Checkbox,
44
+ S as CliTextareaInput,
45
45
  D as CustomLink,
46
46
  x as DatePicker,
47
47
  u as DateRangePicker,
@@ -51,8 +51,8 @@ export {
51
51
  R as Form,
52
52
  to as IconArrowBendUpRight,
53
53
  Io as IconArrowClockwise,
54
- io as IconArrowDown,
55
- ao as IconArrowLeft,
54
+ ao as IconArrowDown,
55
+ io as IconArrowLeft,
56
56
  po as IconArrowLineDown,
57
57
  lo as IconArrowLineLeft,
58
58
  fo as IconArrowLineRight,
@@ -63,10 +63,10 @@ export {
63
63
  Co as IconArticle,
64
64
  ho as IconAt,
65
65
  wo as IconBellSimple,
66
- go as IconBookOpenText,
67
- ko as IconCalendarBlank,
68
- So as IconCaretDown,
69
- To as IconCaretLeft,
66
+ To as IconBookOpenText,
67
+ go as IconCalendarBlank,
68
+ ko as IconCaretDown,
69
+ So as IconCaretLeft,
70
70
  Ao as IconCaretRight,
71
71
  Do as IconCaretUp,
72
72
  Lo as IconCaretUpDown,
@@ -116,10 +116,10 @@ export {
116
116
  dn as IconNavigationArrow,
117
117
  hn as IconNotePencil,
118
118
  wn as IconPassword,
119
- gn as IconPen,
120
- kn as IconPlay,
121
- Sn as IconPlugsX,
122
- Tn as IconPlus,
119
+ Tn as IconPen,
120
+ gn as IconPlay,
121
+ kn as IconPlugsX,
122
+ Sn as IconPlus,
123
123
  An as IconPorsgteSQL,
124
124
  Dn as IconPresentationChart,
125
125
  Ln as IconQuestion,
@@ -158,11 +158,12 @@ export {
158
158
  $ as TextareaInput,
159
159
  Kn as ToastProvider,
160
160
  no as Tooltip,
161
- _n as TriaflyContext,
162
- $n as TriaflyProvider,
163
- rr as useBreakpointValueTriafly,
161
+ $n as TriaflyContext,
162
+ or as TriaflyProvider,
163
+ er as useBreakpointValueTriafly,
164
164
  X as useForm,
165
- Ir as useModalState,
166
- cr as useThemeLogic,
167
- or as useTriafly
165
+ ar as useModalState,
166
+ tr as useThemeLogic,
167
+ Zn as useToast,
168
+ nr as useTriafly
168
169
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triafly-ui-kit",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "UI Kit from Triafly",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",