@alphakits/ui 2.4.4 → 2.4.5

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,4 +1,4 @@
1
- import { jsxs as P, jsx as y } from "react/jsx-runtime";
1
+ import { jsxs as P, jsx as M } from "react/jsx-runtime";
2
2
  import se from "classnames";
3
3
  import { forwardRef as ae, useState as S, useMemo as o, useCallback as a } from "react";
4
4
  import { startOfMonth as D, isSameDay as le } from "../utils/date/index.js";
@@ -14,48 +14,48 @@ const me = ce, Pe = ae(
14
14
  className: b,
15
15
  defaultView: Y = "days",
16
16
  value: n,
17
- month: i,
17
+ month: d,
18
18
  defaultMonth: p = Date.now(),
19
- minDate: d,
20
- maxDate: h,
19
+ minDate: h,
20
+ maxDate: f,
21
21
  selectedFrom: l,
22
22
  selectedTo: V,
23
23
  offDays: j,
24
24
  events: R,
25
- onChange: f,
25
+ onChange: w,
26
26
  onMonthChange: B,
27
27
  onYearChange: E,
28
28
  locale: H = "en",
29
29
  shortNames: L = !0,
30
30
  dataTestId: O
31
31
  }, T) => {
32
- const [e, w] = S(Y), [U, W] = S(!1), m = me[H], r = o(() => n ? new Date(n) : void 0, [n]), q = o(
32
+ const [e, c] = S(Y), [U, W] = S(!1), m = me[H], r = o(() => n ? new Date(n) : void 0, [n]), q = o(
33
33
  () => D(
34
34
  r ?? (l != null ? new Date(l) : new Date(p))
35
35
  ),
36
36
  // eslint-disable-next-line react-hooks/exhaustive-deps
37
37
  [p, l, r]
38
38
  ), z = o(
39
- () => i ? new Date(i) : void 0,
40
- [i]
41
- ), G = o(
42
39
  () => d ? new Date(d) : void 0,
43
40
  [d]
44
- ), I = o(
41
+ ), G = o(
45
42
  () => h ? new Date(h) : void 0,
46
43
  [h]
44
+ ), I = o(
45
+ () => f ? new Date(f) : void 0,
46
+ [f]
47
47
  ), {
48
- activeMonth: c,
48
+ activeMonth: i,
49
49
  activeYear: J,
50
50
  weeks: k,
51
51
  months: K,
52
52
  canSetPrevMonth: Q,
53
53
  canSetNextMonth: X,
54
- setMonthByDate: M,
54
+ setMonthByDate: y,
55
55
  setPrevMonth: v,
56
56
  setNextMonth: x,
57
- setNextYear: C,
58
- setPrevYear: u,
57
+ setNextYear: u,
58
+ setPrevYear: C,
59
59
  highlighted: Z,
60
60
  getDayProps: _,
61
61
  getMonthProps: $,
@@ -69,13 +69,13 @@ const me = ce, Pe = ae(
69
69
  selected: r,
70
70
  offDays: j,
71
71
  events: R,
72
- onChange: f,
72
+ onChange: w,
73
73
  onMonthChange: B,
74
74
  onYearChange: E,
75
- setView: w
75
+ setView: c
76
76
  }), N = a(
77
77
  (t) => {
78
- w(e === t ? "days" : t);
78
+ c(e === t ? "days" : t);
79
79
  },
80
80
  [e]
81
81
  ), s = o(() => {
@@ -85,19 +85,20 @@ const me = ce, Pe = ae(
85
85
  () => !r || !le(r, s),
86
86
  [r, s]
87
87
  ), te = a(() => {
88
- w("days"), M(D(s)), f?.(s.getTime());
89
- }, [f, M, s]), oe = a(() => {
90
- e === "days" ? v() : u();
91
- }, [v, e, u]), ne = a(() => {
92
- e === "days" ? x() : C();
93
- }, [x, e, C]), re = a(() => {
88
+ c("days"), y(D(s)), w?.(s.getTime());
89
+ }, [w, y, s]), oe = a(() => {
90
+ e === "days" ? v() : C();
91
+ }, [v, e, C]), ne = a(() => {
92
+ e === "days" ? x() : u();
93
+ }, [x, e, u]), re = a(() => {
94
94
  N("months");
95
95
  }, [N]);
96
96
  return A(() => {
97
97
  W(!1);
98
98
  }, [e]), A(() => {
99
- const t = n != null && D(new Date(n));
100
- t && t.getTime() !== c.getTime() && M(t);
99
+ if (n == null) return;
100
+ const t = D(new Date(n));
101
+ t.getTime() !== i.getTime() && y(t), e !== "days" && c("days");
101
102
  }, [n]), /* @__PURE__ */ P(
102
103
  "div",
103
104
  {
@@ -107,10 +108,10 @@ const me = ce, Pe = ae(
107
108
  }),
108
109
  "data-test-id": O,
109
110
  children: [
110
- /* @__PURE__ */ y(
111
+ /* @__PURE__ */ M(
111
112
  de,
112
113
  {
113
- month: we(c, m, !1),
114
+ month: we(i, m, !1),
114
115
  onTodayClick: te,
115
116
  showToday: ee,
116
117
  year: J.getFullYear().toString(),
@@ -124,22 +125,22 @@ const me = ce, Pe = ae(
124
125
  }
125
126
  ),
126
127
  /* @__PURE__ */ P("div", { className: g.container, children: [
127
- e === "days" && /* @__PURE__ */ y(
128
+ e === "days" && /* @__PURE__ */ M(
128
129
  ie,
129
130
  {
130
131
  locale: m,
131
132
  weeks: k,
132
- activeMonth: c,
133
+ activeMonth: i,
133
134
  selectedFrom: l,
134
135
  selectedTo: V,
135
136
  getDayProps: _,
136
137
  highlighted: Z
137
138
  }
138
139
  ),
139
- e === "months" && /* @__PURE__ */ y(
140
+ e === "months" && /* @__PURE__ */ M(
140
141
  he,
141
142
  {
142
- selectedMonth: c,
143
+ selectedMonth: i,
143
144
  selectedLocale: m,
144
145
  shortNames: L,
145
146
  months: K,
@@ -1,54 +1,73 @@
1
- import { jsx as n, jsxs as w } from "react/jsx-runtime";
2
- import { useCallback as C, useEffect as b } from "react";
3
- import { createPortal as P } from "react-dom";
4
- import { createRoot as g } from "react-dom/client";
5
- import { Button as y } from "../button/component.js";
6
- import { Flex as E } from "../flex/component.js";
7
- import { Typography as v } from "../typography/component.js";
8
- import f from "./index.module.css.js";
9
- const T = ({
1
+ import { jsx as i, jsxs as p } from "react/jsx-runtime";
2
+ import { useCallback as b, useEffect as x } from "react";
3
+ import { createPortal as N } from "react-dom";
4
+ import { createRoot as P } from "react-dom/client";
5
+ import { Button as v } from "../button/component.js";
6
+ import { Typography as y } from "../typography/component.js";
7
+ import n from "./index.module.css.js";
8
+ const g = ({
10
9
  title: e,
11
10
  description: t,
12
11
  confirmText: r,
13
- cancelText: i,
14
- confirmView: m = "primary",
15
- mode: a = "confirm",
16
- onConfirm: l,
12
+ cancelText: l,
13
+ confirmView: d = "primary",
14
+ mode: m = "confirm",
15
+ onConfirm: c,
17
16
  onCancel: o
18
17
  }) => {
19
- const c = a === "alert", x = C(
20
- (s) => {
21
- s.target === s.currentTarget && o();
18
+ const s = m === "alert", C = b(
19
+ (a) => {
20
+ a.target === a.currentTarget && o();
22
21
  },
23
22
  [o]
24
23
  );
25
- return b(() => {
26
- const s = (p) => {
27
- p.key === "Escape" && o(), p.key === "Enter" && (c ? o : l)();
24
+ return x(() => {
25
+ const a = (w) => {
26
+ w.key === "Escape" && o(), w.key === "Enter" && (s ? o : c)();
28
27
  };
29
- return window.addEventListener("keydown", s), () => window.removeEventListener("keydown", s);
30
- }, [o, l, c]), P(
31
- /* @__PURE__ */ n(
28
+ return window.addEventListener("keydown", a), () => window.removeEventListener("keydown", a);
29
+ }, [o, c, s]), N(
30
+ /* @__PURE__ */ i(
32
31
  "div",
33
32
  {
34
- className: f.backdrop,
35
- onClick: x,
33
+ className: n.backdrop,
34
+ onClick: C,
36
35
  role: "dialog",
37
36
  "aria-modal": "true",
38
- children: /* @__PURE__ */ w("div", { className: f.card, children: [
39
- /* @__PURE__ */ n(v.Title, { tag: "h3", view: "xsmall", color: "primary", children: e }),
40
- t && /* @__PURE__ */ n(v.Text, { color: "secondary", view: "primary-medium", children: t }),
41
- /* @__PURE__ */ w(E, { gap: "xs", justify: "start", children: [
42
- !c && /* @__PURE__ */ n(y, { size: "xs", view: "outlined", block: !0, onClick: o, children: i }),
43
- /* @__PURE__ */ n(
44
- y,
37
+ children: /* @__PURE__ */ p("div", { className: n.card, children: [
38
+ /* @__PURE__ */ p("div", { className: n.content, children: [
39
+ /* @__PURE__ */ i(
40
+ y.Title,
45
41
  {
46
- size: "xs",
47
- className: f[m],
42
+ tag: "h3",
43
+ view: "xsmall",
44
+ color: "primary",
45
+ className: n.title,
46
+ children: e
47
+ }
48
+ ),
49
+ t && /* @__PURE__ */ i(
50
+ y.Text,
51
+ {
52
+ tag: "p",
53
+ color: "secondary",
54
+ view: "primary-medium",
55
+ className: n.description,
56
+ children: t
57
+ }
58
+ )
59
+ ] }),
60
+ /* @__PURE__ */ p("div", { className: n.actions, children: [
61
+ !s && /* @__PURE__ */ i(v, { size: "s", view: "outlined", block: !0, onClick: o, children: l }),
62
+ /* @__PURE__ */ i(
63
+ v,
64
+ {
65
+ size: "s",
66
+ className: n[d],
48
67
  view: "primary",
49
68
  block: !0,
50
- onClick: c ? o : l,
51
- children: c ? i : r
69
+ onClick: s ? o : c,
70
+ children: s ? l : r
52
71
  }
53
72
  )
54
73
  ] })
@@ -58,30 +77,30 @@ const T = ({
58
77
  document.body
59
78
  );
60
79
  };
61
- let d = null, u = null;
80
+ let u = null, f = null;
62
81
  const h = () => {
63
- d && (d.unmount(), d = null), u && (u.remove(), u = null);
82
+ u && (u.unmount(), u = null), f && (f.remove(), f = null);
64
83
  }, k = (e, t) => {
65
84
  h();
66
85
  const r = document.createElement("div");
67
86
  r.setAttribute("data-confirm-popup", ""), document.body.appendChild(r);
68
- const i = g(r);
69
- d = i, u = r;
70
- let m = !1;
71
- const a = (l) => () => {
72
- m || (m = !0, h(), l(), t());
87
+ const l = P(r);
88
+ u = l, f = r;
89
+ let d = !1;
90
+ const m = (c) => () => {
91
+ d || (d = !0, h(), c(), t());
73
92
  };
74
- i.render(
75
- /* @__PURE__ */ n(
76
- T,
93
+ l.render(
94
+ /* @__PURE__ */ i(
95
+ g,
77
96
  {
78
97
  ...e,
79
- onConfirm: a(e.onConfirm),
80
- onCancel: a(e.onCancel)
98
+ onConfirm: m(e.onConfirm),
99
+ onCancel: m(e.onCancel)
81
100
  }
82
101
  )
83
102
  );
84
- }, K = (e) => typeof window > "u" ? Promise.resolve(!1) : new Promise((t) => {
103
+ }, R = (e) => typeof window > "u" ? Promise.resolve(!1) : new Promise((t) => {
85
104
  let r = !1;
86
105
  k(
87
106
  {
@@ -96,7 +115,7 @@ const h = () => {
96
115
  },
97
116
  () => t(r)
98
117
  );
99
- }), q = (e) => typeof window > "u" ? Promise.resolve() : new Promise((t) => {
118
+ }), K = (e) => typeof window > "u" ? Promise.resolve() : new Promise((t) => {
100
119
  k(
101
120
  {
102
121
  title: e.title,
@@ -113,7 +132,7 @@ const h = () => {
113
132
  );
114
133
  });
115
134
  export {
116
- T as ConfirmPopup,
117
- q as showAlert,
118
- K as showConfirm
135
+ g as ConfirmPopup,
136
+ K as showAlert,
137
+ R as showConfirm
119
138
  };
@@ -1 +1 @@
1
- .backdrop_bTWm{position:fixed;inset:0;z-index:99999990;background:#00000073;display:flex;align-items:center;justify-content:center;padding:16px;animation:backdrop-in_2Gfp .15s ease-out}.card_QdKQ{background:var(--color-bg-primary);border-radius:12px;box-shadow:0 12px 40px #00000040;width:100%;max-width:360px;padding:20px;display:flex;flex-direction:column;gap:12px;animation:card-in_kaZX .18s ease-out}.actions_MbU4{display:flex;gap:8px;margin-top:4px}.negative_htRp{background:var(--color-bg-negative);border:1px solid var(--color-border-secondary)}.actions_MbU4>*{flex:1}@keyframes backdrop-in_2Gfp{0%{opacity:0}to{opacity:1}}@keyframes card-in_kaZX{0%{opacity:0;transform:translateY(-8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}
1
+ .backdrop_bTWm{position:fixed;inset:0;z-index:99999990;background:#00000073;display:flex;align-items:center;justify-content:center;padding:16px;animation:backdrop-in_2Gfp .15s ease-out}.card_QdKQ{background:var(--color-bg-primary);border-radius:16px;box-shadow:0 16px 48px #00000047;width:100%;max-width:380px;padding:24px;display:flex;flex-direction:column;gap:20px;animation:card-in_kaZX .18s ease-out}.content_qypP{display:flex;flex-direction:column;gap:6px}.title_Ax6t,.description_pjZB{margin:0}.actions_MbU4{display:flex;gap:8px}.actions_MbU4>*{flex:1 1 0;min-width:0}.negative_htRp{background:var(--color-bg-negative);border:1px solid var(--color-border-secondary)}@keyframes backdrop-in_2Gfp{0%{opacity:0}to{opacity:1}}@keyframes card-in_kaZX{0%{opacity:0;transform:translateY(-8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}
@@ -1,17 +1,23 @@
1
1
  import * as __css from './index.css';
2
2
  export const __cssModule = __css;
3
- const a = "backdrop_bTWm", c = "card_QdKQ", n = "actions_MbU4", t = "negative_htRp", o = {
4
- backdrop: a,
3
+ const t = "backdrop_bTWm", c = "card_QdKQ", n = "content_qypP", o = "title_Ax6t", a = "description_pjZB", i = "actions_MbU4", e = "negative_htRp", s = {
4
+ backdrop: t,
5
5
  "backdrop-in": "backdrop-in_2Gfp",
6
6
  card: c,
7
7
  "card-in": "card-in_kaZX",
8
- actions: n,
9
- negative: t
8
+ content: n,
9
+ title: o,
10
+ description: a,
11
+ actions: i,
12
+ negative: e
10
13
  };
11
14
  export {
12
- n as actions,
13
- a as backdrop,
15
+ i as actions,
16
+ t as backdrop,
14
17
  c as card,
15
- o as default,
16
- t as negative
18
+ n as content,
19
+ s as default,
20
+ a as description,
21
+ e as negative,
22
+ o as title
17
23
  };
@@ -1,5 +1,5 @@
1
1
  import { FormikProps, FormikValues } from 'formik';
2
2
  import { Props } from '.';
3
3
  type FormProps<T extends FormikValues> = Props<T> & FormikProps<T>;
4
- export declare function Form<T extends FormikValues>({ recordId, title, subtitle, headerBottomAddons, initialValues, submitButtonText, customFooter, loading, updating, removing, customValidationFields, validate, save, remove, close, back, t, children, headerAddon, error, softError, ...formProps }: FormProps<T>): import("react/jsx-runtime").JSX.Element;
4
+ export declare function Form<T extends FormikValues>({ recordId, title, subtitle, headerBottomAddons, initialValues, submitButtonText, customFooter, loading, updating, removing, customValidationFields, validate, save, remove, close, back, t, children, headerAddon, error, softError, modalId, ...formProps }: FormProps<T>): import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -1,61 +1,60 @@
1
- import { jsxs as p, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as n } from "react/jsx-runtime";
2
2
  import A from "@alphakits/icons/dist/TrashM";
3
- import D, { useContext as H, useRef as q, useCallback as x, useEffect as G } from "react";
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,
3
+ import D, { useContext as H, useCallback as C, useEffect as q } from "react";
4
+ import { Button as k } from "../../../button/component.js";
5
+ import { showConfirm as G } from "../../../confirm-popup/component.js";
6
+ import { Flex as J } from "../../../flex/component.js";
7
+ import { FlexColumns as K } from "../../../flex-columns/component.js";
8
+ import { IconButton as L } from "../../../icon-button/component.js";
9
+ import { ModalContext as N } from "../../../modal/context.js";
10
+ import { Sidepanel as O } from "../../../sidepanel/component.js";
11
+ import { ToastPlate as x } from "../../../toast-plate/component.js";
12
+ function ce({
13
+ recordId: w,
14
+ title: T,
15
+ subtitle: F,
16
+ headerBottomAddons: u,
17
17
  initialValues: y,
18
- submitButtonText: M,
19
- customFooter: B,
20
- loading: n,
18
+ submitButtonText: I,
19
+ customFooter: M,
20
+ loading: r,
21
21
  updating: i,
22
22
  removing: m,
23
- customValidationFields: U,
24
- validate: W,
25
- save: X,
23
+ customValidationFields: Q,
24
+ validate: U,
25
+ save: W,
26
26
  remove: c,
27
- close: S,
28
- back: g,
27
+ close: R,
28
+ back: B,
29
29
  t: e,
30
- children: z,
31
- headerAddon: b,
32
- error: Y,
30
+ children: S,
31
+ headerAddon: h,
32
+ error: X,
33
33
  softError: s,
34
- ...P
34
+ modalId: g,
35
+ ...z
35
36
  }) {
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(
37
+ const { setModalDirty: o, currentModalId: P } = H(N), t = g || P, { submitCount: a, handleSubmit: p, isValid: l, ...d } = z, b = !!w && !!c, v = C(
39
38
  () => {
40
- o(t, !1), v();
39
+ o(t, !1), p();
41
40
  },
42
41
  // eslint-disable-next-line react-hooks/exhaustive-deps
43
- [t, o, v]
44
- ), V = x(async () => {
45
- o(t, !1), await J({
42
+ [t, o, p]
43
+ ), V = C(async () => {
44
+ o(t, !1), await G({
46
45
  title: e("common:deleteConfirm"),
47
46
  confirmText: e("common:remove"),
48
47
  cancelText: e("common:cancel"),
49
48
  confirmView: "negative"
50
49
  }) && c?.();
51
50
  }, [t, e, o, c]);
52
- G(() => {
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,
51
+ q(() => {
52
+ r || o(t, d.dirty);
53
+ }, [d.dirty, r, t, o]);
54
+ const j = b || h ? /* @__PURE__ */ f(D.Fragment, { children: [
55
+ h,
56
+ b && /* @__PURE__ */ n(
57
+ L,
59
58
  {
60
59
  dataTestId: "removeTariffBtn",
61
60
  size: "m",
@@ -66,56 +65,56 @@ function se({
66
65
  }
67
66
  )
68
67
  ] }) : null;
69
- return /* @__PURE__ */ r(
70
- Q,
68
+ return /* @__PURE__ */ n(
69
+ O,
71
70
  {
72
71
  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." })
72
+ title: T,
73
+ subtitle: F,
74
+ loading: i || m || r,
75
+ headerBottomAddons: (u || !!s || !l && !!a) && /* @__PURE__ */ f(K, { columns: 1, gr: 8, children: [
76
+ u,
77
+ !!s && /* @__PURE__ */ n(x, { view: "negative", children: s }),
78
+ !l && !!a && /* @__PURE__ */ n(x, { view: "negative", children: "Please correct errors before submitting form." })
80
79
  ] }),
81
- back: g,
80
+ back: B,
82
81
  t: e,
83
- bottomAddons: B || /* @__PURE__ */ p(K, { gap: "md", children: [
84
- /* @__PURE__ */ r(
85
- w,
82
+ bottomAddons: M || /* @__PURE__ */ f(J, { gap: "md", children: [
83
+ /* @__PURE__ */ n(
84
+ k,
86
85
  {
87
86
  view: "primary",
88
87
  size: "s",
89
88
  block: !0,
90
- loading: n,
89
+ loading: r,
91
90
  disabled: i || m,
92
91
  dataTestId: "buttonSave",
93
- onClick: () => k(),
94
- children: e(M || "common:save")
92
+ onClick: () => v(),
93
+ children: e(I || "common:save")
95
94
  }
96
95
  ),
97
- /* @__PURE__ */ r(
98
- w,
96
+ /* @__PURE__ */ n(
97
+ k,
99
98
  {
100
99
  block: !0,
101
100
  view: "secondary",
102
101
  size: "s",
103
102
  dataTestId: "buttonCancel",
104
- onClick: S,
103
+ onClick: R,
105
104
  children: e("common:cancel")
106
105
  }
107
106
  )
108
107
  ] }),
109
- children: z({
110
- submitCount: d,
111
- isValid: f,
112
- handleSubmit: k,
108
+ children: S({
109
+ submitCount: a,
110
+ isValid: l,
111
+ handleSubmit: v,
113
112
  initialValues: y,
114
- ...u
113
+ ...d
115
114
  })
116
115
  }
117
116
  );
118
117
  }
119
118
  export {
120
- se as Form
119
+ ce as Form
121
120
  };
@@ -22,6 +22,7 @@ export type Props<T extends FormikValues> = {
22
22
  submitButtonText?: string;
23
23
  children: (props: FormikProps<FormikValues & T>) => React.ReactNode;
24
24
  close: () => void;
25
+ modalId?: string;
25
26
  t: TFunction;
26
27
  headerAddon?: React.ReactNode;
27
28
  };