@alphakits/ui 2.4.2 → 2.4.4

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.
@@ -7,7 +7,7 @@ import { ModalContext as x } from "../modal/context.js";
7
7
  import { showError as T, showSuccess as F } from "../utils/show-toast/index.js";
8
8
  import { RestForm as w } from "./templates/rest-form/index.js";
9
9
  const E = { baz: "", bar: "" }, M = { buz: "", bur: "" }, V = (l) => {
10
- const [i, c] = a.useState(!0), [f, u] = a.useState(!1), [p, m] = a.useState(!1);
10
+ const [i, c] = a.useState(!0), [f, m] = a.useState(!1), [p, u] = a.useState(!1);
11
11
  return a.useEffect(() => {
12
12
  setTimeout(() => c(!1), 500);
13
13
  }, []), /* @__PURE__ */ e(
@@ -17,30 +17,30 @@ const E = { baz: "", bar: "" }, M = { buz: "", bur: "" }, V = (l) => {
17
17
  initialValues: M,
18
18
  customValidationFields: ["bur"],
19
19
  save: () => new Promise((b) => {
20
- u(!0), setTimeout(() => {
21
- b(), u(!1), F("", "Saved");
20
+ m(!0), setTimeout(() => {
21
+ b(), m(!1), F("", "Saved");
22
22
  }, 3e3);
23
23
  }),
24
24
  remove: () => new Promise((b) => {
25
- m(!0), setTimeout(() => {
26
- b(), m(!1), T("Some error from server", "Error");
25
+ u(!0), setTimeout(() => {
26
+ b(), u(!1), T("Some error from server", "Error");
27
27
  }, 3e3);
28
28
  }),
29
29
  title: "custom title other",
30
30
  loading: i,
31
- submitButtonText: "submit",
31
+ submitButtonText: "common:submit",
32
32
  updating: f,
33
33
  removing: p,
34
34
  close: l?.close,
35
35
  t: (b) => b,
36
- children: ({ values: b, touched: d, errors: r, handleChange: o }) => /* @__PURE__ */ C(S, { columns: 1, gr: 16, gc: 0, children: [
36
+ children: ({ values: b, touched: g, errors: r, handleChange: o }) => /* @__PURE__ */ C(S, { columns: 1, gr: 16, gc: 0, children: [
37
37
  /* @__PURE__ */ e(
38
38
  t,
39
39
  {
40
40
  label: "buz",
41
41
  value: b.buz,
42
42
  onChange: o("buz"),
43
- error: d.buz && r.buz
43
+ error: g.buz && r.buz
44
44
  }
45
45
  ),
46
46
  /* @__PURE__ */ e(
@@ -49,14 +49,14 @@ const E = { baz: "", bar: "" }, M = { buz: "", bur: "" }, V = (l) => {
49
49
  label: "bur",
50
50
  value: b.bur,
51
51
  onChange: o("bur"),
52
- error: d.bur && r.bur
52
+ error: g.bur && r.bur
53
53
  }
54
54
  )
55
55
  ] })
56
56
  }
57
57
  );
58
58
  }, O = (l) => {
59
- const [i, c] = a.useState(!0), [f, u] = a.useState(!1), [p, m] = a.useState(!1), { openModal: g } = a.useContext(x), v = g(V);
59
+ const [i, c] = a.useState(!0), [f, m] = a.useState(!1), [p, u] = a.useState(!1), { openModal: v } = a.useContext(x), d = v(V);
60
60
  return a.useEffect(() => {
61
61
  setTimeout(() => c(!1), 500);
62
62
  }, []), /* @__PURE__ */ e(
@@ -66,13 +66,13 @@ const E = { baz: "", bar: "" }, M = { buz: "", bur: "" }, V = (l) => {
66
66
  initialValues: E,
67
67
  customValidationFields: ["bar"],
68
68
  save: () => new Promise((r) => {
69
- u(!0), setTimeout(() => {
70
- r(), u(!1), F("", "Saved");
69
+ m(!0), setTimeout(() => {
70
+ r(), m(!1), F("", "Saved");
71
71
  }, 3e3);
72
72
  }),
73
73
  remove: () => new Promise((r) => {
74
- m(!0), setTimeout(() => {
75
- r(), m(!1), T("Some error from server", "Error");
74
+ u(!0), setTimeout(() => {
75
+ r(), u(!1), T("Some error from server", "Error");
76
76
  }, 3e3);
77
77
  }),
78
78
  title: "Настройки",
@@ -81,7 +81,7 @@ const E = { baz: "", bar: "" }, M = { buz: "", bur: "" }, V = (l) => {
81
81
  },
82
82
  softError: "Some error",
83
83
  loading: i,
84
- submitButtonText: "csdcds",
84
+ submitButtonText: "common:save",
85
85
  updating: f,
86
86
  removing: p,
87
87
  close: l?.close,
@@ -168,7 +168,7 @@ const E = { baz: "", bar: "" }, M = { buz: "", bur: "" }, V = (l) => {
168
168
  error: o.bar && n.bar
169
169
  }
170
170
  ),
171
- /* @__PURE__ */ e(z, { onClick: v, children: "openCrudModalOther" })
171
+ /* @__PURE__ */ e(z, { onClick: d, children: "openCrudModalOther" })
172
172
  ] })
173
173
  }
174
174
  );
@@ -1,4 +1,4 @@
1
- import { jsx as e, jsxs as c } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
2
  import { Formik as d } from "formik";
3
3
  import u from "react";
4
4
  import { Button as i } from "../../../button/component.js";
@@ -8,42 +8,42 @@ const C = ({
8
8
  initialValues: n,
9
9
  defaultValues: m,
10
10
  children: s,
11
- submitCallback: l,
12
- close: o,
13
- t: r
11
+ submitCallback: c,
12
+ close: r,
13
+ t: e
14
14
  }) => {
15
- const a = p(n, m);
16
- return /* @__PURE__ */ e(d, { initialValues: a, onSubmit: (t) => {
17
- l(t), o();
18
- }, children: (t) => (process.env.REACT_APP_STAGE, /* @__PURE__ */ e(
15
+ const l = p(n, m);
16
+ return /* @__PURE__ */ t(d, { initialValues: l, onSubmit: (o) => {
17
+ c(o), r();
18
+ }, children: (o) => (process.env.REACT_APP_STAGE, /* @__PURE__ */ t(
19
19
  f,
20
20
  {
21
- title: r("filters"),
22
- bottomAddons: /* @__PURE__ */ c(u.Fragment, { children: [
23
- /* @__PURE__ */ e(
21
+ title: e("common:filters"),
22
+ bottomAddons: /* @__PURE__ */ a(u.Fragment, { children: [
23
+ /* @__PURE__ */ t(
24
24
  i,
25
25
  {
26
26
  view: "primary",
27
27
  size: "s",
28
28
  block: !0,
29
29
  dataTestId: "buttonSave",
30
- onClick: () => t.submitForm(),
31
- children: r("save")
30
+ onClick: () => o.submitForm(),
31
+ children: e("common:save")
32
32
  }
33
33
  ),
34
- /* @__PURE__ */ e(
34
+ /* @__PURE__ */ t(
35
35
  i,
36
36
  {
37
37
  block: !0,
38
38
  view: "secondary",
39
39
  size: "s",
40
40
  dataTestId: "buttonCancel",
41
- onClick: o,
42
- children: r("cancel")
41
+ onClick: r,
42
+ children: e("common:cancel")
43
43
  }
44
44
  )
45
45
  ] }),
46
- children: s(t)
46
+ children: s(o)
47
47
  }
48
48
  )) });
49
49
  };
@@ -1,115 +1,121 @@
1
- import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
- import V from "@alphakits/icons/dist/TrashM";
1
+ import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
+ import A from "@alphakits/icons/dist/TrashM";
3
3
  import D, { useContext as H, useRef as q, useCallback as x, useEffect as G } from "react";
4
- import { Button as F } from "../../../button/component.js";
5
- import { Flex as J } from "../../../flex/component.js";
6
- import { FlexColumns as K } from "../../../flex-columns/component.js";
7
- import { IconButton as L } from "../../../icon-button/component.js";
8
- import { ModalContext as N } from "../../../modal/context.js";
9
- import { Sidepanel as O } from "../../../sidepanel/component.js";
10
- import { ToastPlate as I } from "../../../toast-plate/component.js";
11
- function ie({
12
- recordId: R,
13
- title: M,
14
- subtitle: T,
15
- headerBottomAddons: b,
16
- initialValues: w,
17
- submitButtonText: y,
4
+ import { Button as w } from "../../../button/component.js";
5
+ import { showConfirm as J } from "../../../confirm-popup/component.js";
6
+ import { Flex as K } from "../../../flex/component.js";
7
+ import { FlexColumns as L } from "../../../flex-columns/component.js";
8
+ import { IconButton as N } from "../../../icon-button/component.js";
9
+ import { ModalContext as O } from "../../../modal/context.js";
10
+ import { Sidepanel as Q } from "../../../sidepanel/component.js";
11
+ import { ToastPlate as T } from "../../../toast-plate/component.js";
12
+ function se({
13
+ recordId: F,
14
+ title: I,
15
+ subtitle: R,
16
+ headerBottomAddons: h,
17
+ initialValues: y,
18
+ submitButtonText: M,
18
19
  customFooter: B,
19
20
  loading: n,
20
21
  updating: i,
21
- removing: s,
22
- customValidationFields: Q,
23
- validate: U,
24
- save: W,
25
- remove: a,
22
+ removing: m,
23
+ customValidationFields: U,
24
+ validate: W,
25
+ save: X,
26
+ remove: c,
26
27
  close: S,
27
- back: z,
28
- t: r,
29
- children: P,
30
- headerAddon: h,
31
- error: X,
32
- softError: d,
33
- ...g
28
+ back: g,
29
+ t: e,
30
+ children: z,
31
+ headerAddon: b,
32
+ error: Y,
33
+ softError: s,
34
+ ...P
34
35
  }) {
35
- const { setModalDirty: e, currentModalId: l } = H(N), c = q("");
36
- !c.current && l && (c.current = l);
37
- const t = c.current || l, { submitCount: m, handleSubmit: C, isValid: f, ...u } = g, v = !!R && !!a, k = x(
36
+ const { setModalDirty: o, currentModalId: a } = H(O), l = q("");
37
+ !l.current && a && (l.current = a);
38
+ const t = l.current || a, { submitCount: d, handleSubmit: v, isValid: f, ...u } = P, C = !!F && !!c, k = x(
38
39
  () => {
39
- e(t, !1), C();
40
+ o(t, !1), v();
40
41
  },
41
42
  // eslint-disable-next-line react-hooks/exhaustive-deps
42
- [t, e, C]
43
- ), j = x(() => {
44
- e(t, !1), confirm(r("common:deleteConfirm")) && a?.();
45
- }, [t, r, e, a]);
43
+ [t, o, v]
44
+ ), V = x(async () => {
45
+ o(t, !1), await J({
46
+ title: e("common:deleteConfirm"),
47
+ confirmText: e("common:remove"),
48
+ cancelText: e("common:cancel"),
49
+ confirmView: "negative"
50
+ }) && c?.();
51
+ }, [t, e, o, c]);
46
52
  G(() => {
47
- n || e(t, u.dirty);
48
- }, [u.dirty, n, t, e]);
49
- const A = v || h ? /* @__PURE__ */ p(D.Fragment, { children: [
50
- h,
51
- v && /* @__PURE__ */ o(
52
- L,
53
+ n || o(t, u.dirty);
54
+ }, [u.dirty, n, t, o]);
55
+ const j = C || b ? /* @__PURE__ */ p(D.Fragment, { children: [
56
+ b,
57
+ C && /* @__PURE__ */ r(
58
+ N,
53
59
  {
54
60
  dataTestId: "removeTariffBtn",
55
61
  size: "m",
56
62
  disabled: i,
57
- loading: s,
58
- onClick: j,
59
- icon: V
63
+ loading: m,
64
+ onClick: V,
65
+ icon: A
60
66
  }
61
67
  )
62
68
  ] }) : null;
63
- return /* @__PURE__ */ o(
64
- O,
69
+ return /* @__PURE__ */ r(
70
+ Q,
65
71
  {
66
- headerRightAddons: A,
67
- title: M,
68
- subtitle: T,
69
- loading: i || s || n,
70
- headerBottomAddons: (b || !!d || !f && !!m) && /* @__PURE__ */ p(K, { columns: 1, gr: 8, children: [
71
- b,
72
- !!d && /* @__PURE__ */ o(I, { view: "negative", children: d }),
73
- !f && !!m && /* @__PURE__ */ o(I, { view: "negative", children: "Please correct errors before submitting form." })
72
+ headerRightAddons: j,
73
+ title: I,
74
+ subtitle: R,
75
+ loading: i || m || n,
76
+ headerBottomAddons: (h || !!s || !f && !!d) && /* @__PURE__ */ p(L, { columns: 1, gr: 8, children: [
77
+ h,
78
+ !!s && /* @__PURE__ */ r(T, { view: "negative", children: s }),
79
+ !f && !!d && /* @__PURE__ */ r(T, { view: "negative", children: "Please correct errors before submitting form." })
74
80
  ] }),
75
- back: z,
76
- t: r,
77
- bottomAddons: B || /* @__PURE__ */ p(J, { gap: "md", children: [
78
- /* @__PURE__ */ o(
79
- F,
81
+ back: g,
82
+ t: e,
83
+ bottomAddons: B || /* @__PURE__ */ p(K, { gap: "md", children: [
84
+ /* @__PURE__ */ r(
85
+ w,
80
86
  {
81
87
  view: "primary",
82
88
  size: "s",
83
89
  block: !0,
84
90
  loading: n,
85
- disabled: i || s,
91
+ disabled: i || m,
86
92
  dataTestId: "buttonSave",
87
93
  onClick: () => k(),
88
- children: r(y || "save")
94
+ children: e(M || "common:save")
89
95
  }
90
96
  ),
91
- /* @__PURE__ */ o(
92
- F,
97
+ /* @__PURE__ */ r(
98
+ w,
93
99
  {
94
100
  block: !0,
95
101
  view: "secondary",
96
102
  size: "s",
97
103
  dataTestId: "buttonCancel",
98
104
  onClick: S,
99
- children: r("cancel")
105
+ children: e("common:cancel")
100
106
  }
101
107
  )
102
108
  ] }),
103
- children: P({
104
- submitCount: m,
109
+ children: z({
110
+ submitCount: d,
105
111
  isValid: f,
106
112
  handleSubmit: k,
107
- initialValues: w,
113
+ initialValues: y,
108
114
  ...u
109
115
  })
110
116
  }
111
117
  );
112
118
  }
113
119
  export {
114
- ie as Form
120
+ se as Form
115
121
  };
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './checkbox-group';
17
17
  export * from './checkbox-lists';
18
18
  export * from './collapsable-row';
19
19
  export * from './collapse';
20
+ export * from './confirm-popup';
20
21
  export * from './copy-button';
21
22
  export * from './date';
22
23
  export * from './date-switcher';