mimir-ui-kit 1.35.2 → 1.35.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.
@@ -1,140 +1,123 @@
1
- import { jsxs as K, jsx as N } from "react/jsx-runtime";
2
- import { c as I } from "../../index-DIxK0V-G.js";
3
- import { memo as Q, forwardRef as W, useState as D, useEffect as T } from "react";
4
- import { DatePickerModal as Z } from "./DatePickerModal.js";
5
- import { MonthPickerModal as b } from "./MonthPickerModal.js";
6
- import { c as r } from "../../styles.module-BQZZ6FB1.js";
7
- import { formatDatePart as h } from "./utils.js";
8
- import { YearPickerModal as C } from "./YearPickerModal.js";
9
- import { useClickOutside as E } from "../../hooks/useClickOutside/useClickOutside.js";
10
- import { formating as B } from "../../utils/index.js";
11
- import { I as V } from "../../Input-B-gKQ9FT.js";
12
- import { EInputStatus as tt } from "../Input/constants.js";
13
- const st = 31, et = 12, it = 10, at = Q(
1
+ import { jsxs as J, jsx as I } from "react/jsx-runtime";
2
+ import { c as g } from "../../index-DIxK0V-G.js";
3
+ import { memo as Q, forwardRef as W, useState as d, useEffect as N } from "react";
4
+ import { MAX_DAY as Z, MAX_MONTH as E, DATE_LENGTH as B } from "./constants.js";
5
+ import { DatePickerModal as V } from "./DatePickerModal.js";
6
+ import { MonthPickerModal as tt } from "./MonthPickerModal.js";
7
+ import { c as a } from "../../styles.module-Chnn6DA-.js";
8
+ import { formatDatePart as j } from "./utils.js";
9
+ import { YearPickerModal as st } from "./YearPickerModal.js";
10
+ import { useClickOutside as et } from "../../hooks/useClickOutside/useClickOutside.js";
11
+ import { formating as it } from "../../utils/index.js";
12
+ import { I as at } from "../../Input-B-gKQ9FT.js";
13
+ import { EInputStatus as rt } from "../Input/constants.js";
14
+ const ot = {
15
+ days: V,
16
+ months: tt,
17
+ years: st
18
+ }, ct = Q(
14
19
  W(
15
20
  ({
16
- size: H,
17
- value: e,
18
- onChangeValue: i,
19
- name: p,
20
- before: a,
21
- type: m = "days",
22
- error: A,
23
- onError: f,
24
- onBlur: n,
25
- validateImmediately: P,
26
- variant: X,
27
- disabled: u = !1,
21
+ size: Y,
22
+ value: s,
23
+ onChangeValue: e,
24
+ name: r,
25
+ before: D,
26
+ type: o = "days",
27
+ error: y,
28
+ onError: c,
29
+ onBlur: m,
30
+ validateImmediately: v,
31
+ variant: $,
32
+ disabled: x = !1,
28
33
  editable: S = !1,
29
- ...G
34
+ ...H
30
35
  }, L) => {
31
- const [d, c] = D(!1), [w, o] = D(m), [t, l] = D(
32
- e && !isNaN(new Date(e).getTime()) ? new Date(e) : void 0
33
- ), [g, k] = D(A), [R, v] = D("");
34
- T(() => {
35
- k(A);
36
- }, [A]), T(() => {
36
+ const [n, f] = d(!1), [T, p] = d(o), [i, l] = d(
37
+ () => s && !isNaN(new Date(s).getTime()) ? new Date(s) : void 0
38
+ ), [A, k] = d(y), [R, M] = d("");
39
+ N(() => {
40
+ k(y);
41
+ }, [y]), N(() => {
37
42
  l(
38
- e && !isNaN(new Date(e).getTime()) ? new Date(e) : void 0
43
+ s && !isNaN(new Date(s).getTime()) ? new Date(s) : void 0
39
44
  );
40
- }, [e]), T(() => {
41
- t && typeof t != "string" && !isNaN(t == null ? void 0 : t.getTime()) ? v(B.Date(t, "dd/mm/yyyy")) : v("");
42
- }, [t]);
43
- const j = e && new Date(e).getTime;
44
- T(() => {
45
- P && (j ? (k(!1), f == null || f({ name: p, active: !1 })) : (k(!0), f == null || f({ name: p, active: !0 })));
46
- }, [P, p, j]), E({
47
- isActive: d,
48
- setActive: (s) => {
49
- c(s), o(m);
45
+ }, [s]), N(() => {
46
+ i && typeof i != "string" && !isNaN(i == null ? void 0 : i.getTime()) ? M(it.Date(i, "dd/mm/yyyy")) : M("");
47
+ }, [i]);
48
+ const _ = s && new Date(s).getTime;
49
+ N(() => {
50
+ v && (_ ? (k(!1), c == null || c({ name: r, active: !1 })) : (k(!0), c == null || c({ name: r, active: !0 })));
51
+ }, [v, r, _]), et({
52
+ isActive: n,
53
+ setActive: (t) => {
54
+ f(t), p(o);
50
55
  },
51
- className: r["calendar-block"]
56
+ className: a["calendar-block"]
52
57
  });
53
- const U = () => {
54
- u || c(!0);
55
- }, M = (s) => {
56
- isNaN(s.getTime()) || (l(s), i == null || i({ value: s, name: p })), w === "years" && (m === "years" ? (c(!1), o(m)) : o("months")), w === "months" && (m === "months" ? (c(!1), o(m)) : o("days")), l(s), i == null || i({ value: s, name: p }), n == null || n(s);
57
- }, q = (s) => {
58
+ const X = () => {
59
+ x || f(!0);
60
+ }, G = (t) => {
61
+ isNaN(t.getTime()) || (l(t), e == null || e({ value: t, name: r })), T === "years" && (o === "years" ? (f(!1), p(o)) : p("months")), T === "months" && (o === "months" ? (f(!1), p(o)) : p("days")), l(t), e == null || e({ value: t, name: r }), m == null || m(t);
62
+ }, K = (t) => {
58
63
  if (S) {
59
- const x = s.target.value.replace(/[^\d]/g, ""), [O, Y, _] = [
60
- h(x.substring(0, 2), st),
61
- h(x.substring(2, 4), et),
62
- x.substring(4, 8)
63
- ], $ = [O, Y, _].filter(Boolean).join("/");
64
- if (v($), $.length === it) {
65
- const J = parseInt(_), y = /* @__PURE__ */ new Date(
66
- `${J}-${Y.padStart(2, "0")}-${O.padStart(2, "0")}`
64
+ const P = t.target.value.replace(/[^\d]/g, ""), [b, h, u] = [
65
+ j(P.substring(0, 2), Z),
66
+ j(P.substring(2, 4), E),
67
+ P.substring(4, 8)
68
+ ], O = [b, h, u].filter(Boolean).join("/");
69
+ if (M(O), O.length === B) {
70
+ const F = parseInt(u), w = /* @__PURE__ */ new Date(
71
+ `${F}-${h.padStart(2, "0")}-${b.padStart(2, "0")}`
67
72
  );
68
- isNaN(y.getTime()) || (l(y), i == null || i({ value: y, name: p }), n == null || n(y));
73
+ isNaN(w.getTime()) || (l(w), e == null || e({ value: w, name: r }), m == null || m(w));
69
74
  }
70
75
  }
71
- }, z = I(r.wrapper, d && r.active), F = I(r.input, r.inputBorderControl);
72
- return /* @__PURE__ */ K("div", { className: z, "data-disabled": u, children: [
73
- /* @__PURE__ */ N(
76
+ }, U = g(a.wrapper, n && a.active), q = g(a.input, a.inputBorderControl), z = {
77
+ onChangeValue: G,
78
+ date: i || /* @__PURE__ */ new Date(),
79
+ before: typeof D == "string" ? new Date(D) : D,
80
+ onChangeType: p,
81
+ setIsActive: f
82
+ }, C = ot[T];
83
+ return /* @__PURE__ */ J("div", { className: U, "data-disabled": x, children: [
84
+ /* @__PURE__ */ I(
74
85
  "div",
75
86
  {
76
- "data-error": g,
77
- className: I(r["date-wrapper"], {
78
- [r.editable]: S
87
+ role: "button",
88
+ "data-error": A,
89
+ className: g(a["date-wrapper"], {
90
+ [a.editable]: S
79
91
  }),
80
- onClick: U,
81
- children: /* @__PURE__ */ N(
82
- V,
92
+ onClick: X,
93
+ children: /* @__PURE__ */ I(
94
+ at,
83
95
  {
84
96
  ref: L,
85
- className: F,
86
- wrapperClassName: r["input-wrapper"],
87
- size: H,
97
+ className: q,
98
+ wrapperClassName: a["input-wrapper"],
99
+ size: Y,
88
100
  type: "text",
89
- variant: X,
90
- status: g ? tt.Error : void 0,
101
+ variant: $,
102
+ status: A ? rt.Error : void 0,
91
103
  value: R,
92
- onChange: q,
104
+ onChange: K,
93
105
  rightAddon: {
94
106
  addonType: "icon",
95
- addonContent: d ? "DropdownArrowUp24px" : "DropdownArrowDown24px"
107
+ addonContent: n ? "DropdownArrowUp24px" : "DropdownArrowDown24px"
96
108
  },
97
- "data-error": g,
98
- ...G
109
+ "data-error": A,
110
+ ...H
99
111
  }
100
112
  )
101
113
  }
102
114
  ),
103
- w === "days" && d && /* @__PURE__ */ N(
104
- Z,
105
- {
106
- onChangeValue: M,
107
- date: t || /* @__PURE__ */ new Date(),
108
- setActive: c,
109
- before: typeof a == "string" ? new Date(a) : a,
110
- onType: o
111
- }
112
- ),
113
- w === "months" && d && /* @__PURE__ */ N(
114
- b,
115
- {
116
- onChangeValue: M,
117
- date: t || /* @__PURE__ */ new Date(),
118
- setActive: c,
119
- before: typeof a == "string" ? new Date(a) : a,
120
- onType: o
121
- }
122
- ),
123
- w === "years" && d && /* @__PURE__ */ N(
124
- C,
125
- {
126
- onChangeValue: M,
127
- date: t || /* @__PURE__ */ new Date(),
128
- setActive: c,
129
- before: typeof a == "string" ? new Date(a) : a,
130
- onType: o
131
- }
132
- )
115
+ n && /* @__PURE__ */ I(C, { ...z })
133
116
  ] });
134
117
  }
135
118
  )
136
119
  );
137
- at.displayName = "DatePicker";
120
+ ct.displayName = "DatePicker";
138
121
  export {
139
- at as DatePicker
122
+ ct as DatePicker
140
123
  };
@@ -1,9 +1,9 @@
1
- type DatePickerModal = {
1
+ type TProps = {
2
2
  date: Date;
3
- onChangeValue: (d: Date) => void;
4
- setActive: (s: boolean) => void;
5
3
  before?: Date;
6
- onType?: (s: 'days' | 'months' | 'years') => void;
4
+ onChangeValue: (date: Date) => void;
5
+ setIsActive: (isActive: boolean) => void;
6
+ onChangeType?: (s: 'days' | 'months' | 'years') => void;
7
7
  };
8
- export declare function DatePickerModal({ date, onChangeValue, setActive, before, onType }: DatePickerModal): import("react/jsx-runtime").JSX.Element;
8
+ export declare const DatePickerModal: ({ date, onChangeValue, setIsActive, before, onChangeType }: TProps) => import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -1,151 +1,147 @@
1
- import { jsx as a, Fragment as q, jsxs as u } from "react/jsx-runtime";
2
- import { useRef as G, useState as J, useEffect as K } from "react";
3
- import { week as Q } from "./constants.js";
4
- import { c as o } from "../../styles.module-BQZZ6FB1.js";
5
- import { Icon as T } from "../../icons/Icon.js";
6
- import { formating as i } from "../../utils/index.js";
7
- import { Button as j } from "../Button/Button.js";
8
- import { parseDate as F } from "../../utils/formating/Date.js";
9
- function ct({
10
- date: l,
11
- onChangeValue: I,
12
- setActive: P,
13
- before: g,
14
- onType: d
15
- }) {
16
- var k;
17
- const r = G(null);
18
- l = isNaN(new Date(l).getTime()) ? /* @__PURE__ */ new Date() : l;
19
- const h = F(l), p = F(l), y = {
20
- y: h.getFullYear(),
21
- d: h.getDate(),
22
- m: h.getMonth() + 1
1
+ import { jsxs as l, jsx as a } from "react/jsx-runtime";
2
+ import { c as x } from "../../index-DIxK0V-G.js";
3
+ import { useState as O } from "react";
4
+ import { week as Y, COUNT_WORK_DAYS as j } from "./constants.js";
5
+ import { useDatePickerPosition as z } from "./hooks.js";
6
+ import { c as o } from "../../styles.module-Chnn6DA-.js";
7
+ import { getUpdateDate as M } from "./utils.js";
8
+ import { Icon as G } from "../../icons/Icon.js";
9
+ import { formating as s } from "../../utils/index.js";
10
+ import { Button as $ } from "../Button/Button.js";
11
+ import { parseDate as k } from "../../utils/formating/Date.js";
12
+ const tt = ({
13
+ date: i,
14
+ onChangeValue: P,
15
+ setIsActive: A,
16
+ before: h,
17
+ onChangeType: u
18
+ }) => {
19
+ var b;
20
+ i = isNaN(new Date(i).getTime()) ? /* @__PURE__ */ new Date() : i;
21
+ const d = k(i), D = k(i), y = {
22
+ y: d.getFullYear(),
23
+ d: d.getDate(),
24
+ m: d.getMonth() + 1
23
25
  }, f = {
24
- y: p.getFullYear(),
25
- d: p.getDate(),
26
- m: p.getMonth() + 1
27
- }, z = 4, [n, w] = J({ y: f.y, m: f.m }), v = 368;
28
- K(() => {
29
- var c, s, M, W, B, C;
30
- const t = window.innerHeight, e = window.innerWidth;
31
- if (r.current !== null) {
32
- const O = ((s = (c = r == null ? void 0 : r.current) == null ? void 0 : c.parentElement) == null ? void 0 : s.offsetWidth) || 0, A = ((W = (M = r == null ? void 0 : r.current) == null ? void 0 : M.parentElement) == null ? void 0 : W.offsetHeight) || 0, E = (C = (B = r == null ? void 0 : r.current) == null ? void 0 : B.parentElement) == null ? void 0 : C.getBoundingClientRect(), H = r.current.offsetHeight;
33
- t < E.y + H + A ? r.current.style.top = -H + "px" : r.current.style.top = A + "px", e < E.x + v && (r.current.style.left = O - v + "px"), r.current.style.opacity = "1";
34
- }
35
- }, [n]);
36
- const L = (t) => {
37
- let e = t.getDay();
38
- return e === 0 && (e = 7), e - 1;
39
- }, N = n.m - 1, m = new Date(n.y, N), D = [], x = (() => {
26
+ y: D.getFullYear(),
27
+ d: D.getDate(),
28
+ m: D.getMonth() + 1
29
+ }, [e, g] = O({ y: f.y, m: f.m }), B = z([e]), I = (t) => {
30
+ let r = t.getDay();
31
+ return r === 0 && (r = 7), r - 1;
32
+ }, N = e.m - 1, m = new Date(e.y, N), p = [], v = (() => {
40
33
  const t = new Date(m);
41
34
  t.setDate(t.getDate() - 1);
42
- const e = t.getDate(), c = [];
43
- for (let s = 0; s < L(m); s++)
44
- c.push(e - s);
35
+ const r = t.getDate(), c = [];
36
+ for (let n = 0; n < I(m); n++)
37
+ c.push(r - n);
45
38
  return c.reverse(), c;
46
39
  })();
47
40
  for (; m.getMonth() === N; )
48
- D.push(m.getDate()), m.setDate(m.getDate() + 1);
49
- const R = (() => {
50
- const e = 42 - (x.length + D.length), c = [];
51
- for (let s = 1; s <= e; s++)
52
- c.push(s);
41
+ p.push(m.getDate()), m.setDate(m.getDate() + 1);
42
+ const S = (() => {
43
+ const r = 42 - (v.length + p.length), c = [];
44
+ for (let n = 1; n <= r; n++)
45
+ c.push(n);
53
46
  return c;
54
- })(), b = (t, e) => (e = t > 12 ? e + 1 : t < 1 ? e - 1 : e, t = t > 12 ? 1 : t < 1 ? 12 : t, { y: e, m: t }), S = () => {
55
- P(!1);
56
- }, V = () => {
57
- w(b(n.m + 1, n.y));
58
- }, Y = () => {
59
- w(b(n.m - 1, n.y));
60
- }, $ = (t) => !!(g && g.getTime() > t), _ = (t) => {
61
- $(
47
+ })(), _ = () => {
48
+ A(!1);
49
+ }, C = () => {
50
+ g(M(e.m + 1, e.y));
51
+ }, F = () => {
52
+ g(M(e.m - 1, e.y));
53
+ }, w = (t) => !!(h && h.getTime() > t), L = (t) => {
54
+ w(
62
55
  (/* @__PURE__ */ new Date(
63
- `${n.y}-${i.Number(2, n.m)}-${i.Number(2, t)}`
56
+ `${e.y}-${s.Number(2, e.m)}-${s.Number(2, t)}`
64
57
  )).getTime()
65
- ) || (I(
58
+ ) || (P(
66
59
  /* @__PURE__ */ new Date(
67
- `${n.y}-${i.Number(2, n.m)}-${i.Number(2, t)}`
60
+ `${e.y}-${s.Number(2, e.m)}-${s.Number(2, t)}`
68
61
  )
69
- ), S());
62
+ ), _());
70
63
  };
71
- return /* @__PURE__ */ a(q, { children: /* @__PURE__ */ u(
64
+ return /* @__PURE__ */ l(
72
65
  "div",
73
66
  {
74
- className: [o["calendar-block"]].join(" "),
75
- ref: r,
67
+ className: o["calendar-block"],
68
+ ref: B,
76
69
  "data-testid": "calendar-modal",
77
70
  children: [
78
- /* @__PURE__ */ u("div", { className: o.h, children: [
71
+ /* @__PURE__ */ l("div", { className: o.h, children: [
79
72
  /* @__PURE__ */ a(
80
- j,
73
+ $,
81
74
  {
82
75
  isIconButton: !0,
83
76
  iconName: "DropdownArrowLeft16px",
84
- onClick: Y,
77
+ onClick: F,
85
78
  variant: "secondary-gray",
86
79
  size: "l"
87
80
  }
88
81
  ),
89
- /* @__PURE__ */ u(
90
- "div",
82
+ /* @__PURE__ */ l(
83
+ "button",
91
84
  {
85
+ type: "button",
92
86
  className: o.d,
93
- onClick: () => d == null ? void 0 : d("months"),
87
+ onClick: () => u == null ? void 0 : u("months"),
94
88
  "data-testid": "month-year-button",
95
89
  children: [
96
- (k = i.Month(n.m)) == null ? void 0 : k.name,
90
+ (b = s.Month(e.m)) == null ? void 0 : b.name,
97
91
  "’",
98
- n.y.toString().slice(-2),
99
- /* @__PURE__ */ a(T, { iconName: "DropdownArrowBottom16px" })
92
+ e.y.toString().slice(-2),
93
+ /* @__PURE__ */ a(G, { iconName: "DropdownArrowBottom16px" })
100
94
  ]
101
95
  }
102
96
  ),
103
97
  /* @__PURE__ */ a(
104
- j,
98
+ $,
105
99
  {
106
100
  isIconButton: !0,
107
101
  iconName: "DropdownArrowRight16px",
108
- onClick: V,
102
+ onClick: C,
109
103
  variant: "secondary-gray",
110
104
  size: "l"
111
105
  }
112
106
  )
113
107
  ] }),
114
- /* @__PURE__ */ u("div", { className: o.b, children: [
115
- Q.map((t, e) => /* @__PURE__ */ a(
108
+ /* @__PURE__ */ l("div", { className: o.b, children: [
109
+ Y.map((t, r) => /* @__PURE__ */ a(
116
110
  "div",
117
111
  {
118
- className: `${e > z ? [o.m, o.orange].join(" ") : o.m}`,
112
+ className: x(o.m, {
113
+ [o.orange]: r > j
114
+ }),
119
115
  children: t
120
116
  },
121
- `v${e}`
117
+ `v${r}`
122
118
  )),
123
- x.map((t, e) => /* @__PURE__ */ a("div", { className: o.m, children: t }, e)),
124
- D.map((t, e) => /* @__PURE__ */ a(
125
- "div",
119
+ v.map((t, r) => /* @__PURE__ */ a("div", { className: o.m, children: t }, r)),
120
+ p.map((t, r) => /* @__PURE__ */ a(
121
+ "button",
126
122
  {
127
- className: $(
128
- (/* @__PURE__ */ new Date(
129
- `${n.y}-${i.Number(2, n.m)}-${i.Number(2, t)}`
130
- )).getTime()
131
- ) ? o.m : o.a,
132
- children: t !== 0 ? /* @__PURE__ */ a(
133
- "b",
123
+ type: "button",
124
+ onClick: () => L(t),
125
+ className: x(
126
+ w(
127
+ (/* @__PURE__ */ new Date(
128
+ `${e.y}-${s.Number(2, e.m)}-${s.Number(2, t)}`
129
+ )).getTime()
130
+ ) ? o.m : o.a,
134
131
  {
135
- className: y.y === n.y && y.m === n.m && y.d === t ? o.current : "",
136
- onClick: () => _(t),
137
- children: t
132
+ [o.current]: y.y === e.y && y.m === e.m && y.d === t
138
133
  }
139
- ) : /* @__PURE__ */ a("p", {})
134
+ ),
135
+ children: t !== 0 && t
140
136
  },
141
- e
137
+ r
142
138
  )),
143
- R.map((t, e) => /* @__PURE__ */ a("div", { className: o.m, children: t }, e))
139
+ S.map((t, r) => /* @__PURE__ */ a("div", { className: o.m, children: t }, r))
144
140
  ] })
145
141
  ]
146
142
  }
147
- ) });
148
- }
143
+ );
144
+ };
149
145
  export {
150
- ct as DatePickerModal
146
+ tt as DatePickerModal
151
147
  };
@@ -1,9 +1,8 @@
1
- type MonthPickerModal = {
1
+ type TProps = {
2
2
  date: Date;
3
- onChangeValue: (d: Date) => void;
4
- setActive: (s: boolean) => void;
5
3
  before?: Date;
6
- onType?: (s: 'years') => void;
4
+ onChangeValue: (date: Date) => void;
5
+ onChangeType?: (type: 'years') => void;
7
6
  };
8
- export declare function MonthPickerModal({ date, onChangeValue, before, onType }: MonthPickerModal): import("react/jsx-runtime").JSX.Element;
7
+ export declare const MonthPickerModal: ({ date, onChangeValue, before, onChangeType }: TProps) => import("react/jsx-runtime").JSX.Element;
9
8
  export {};