mimir-ui-kit 1.38.0 → 1.38.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  import { jsxs as H, jsx as a } from "react/jsx-runtime";
2
2
  import { c as _ } from "../../index-DIxK0V-G.js";
3
- import { memo as V, forwardRef as tt, useState as w, useEffect as T } from "react";
3
+ import { memo as V, forwardRef as tt, useState as N, useEffect as T } from "react";
4
4
  import { MAX_DAY as st, MAX_MONTH as et, DATE_LENGTH as it } from "./constants.js";
5
5
  import { DatePickerModal as rt } from "./DatePickerModal.js";
6
6
  import { MonthPickerModal as ot } from "./MonthPickerModal.js";
@@ -31,13 +31,13 @@ const dt = {
31
31
  validateImmediately: b,
32
32
  variant: X,
33
33
  disabled: S = !1,
34
- editable: D = !1,
34
+ editable: w = !1,
35
35
  openOnInput: j = !0,
36
36
  ...E
37
37
  }, F) => {
38
- const [l, m] = w(!1), [g, f] = w(p), [o, k] = w(
38
+ const [D, m] = N(!1), [g, f] = N(p), [o, k] = N(
39
39
  () => i && !isNaN(new Date(i).getTime()) ? new Date(i) : void 0
40
- ), [n, h] = w(x), [G, A] = w("");
40
+ ), [n, h] = N(x), [G, A] = N("");
41
41
  T(() => {
42
42
  h(x);
43
43
  }, [x]), T(() => {
@@ -51,14 +51,14 @@ const dt = {
51
51
  T(() => {
52
52
  b && (u ? (h(!1), d == null || d({ name: c, active: !1 })) : (h(!0), d == null || d({ name: c, active: !0 })));
53
53
  }, [b, c, u]), ct({
54
- isActive: l,
54
+ isActive: D,
55
55
  setActive: (t) => {
56
56
  m(t), f(p);
57
57
  },
58
58
  className: e["calendar-block"]
59
59
  });
60
60
  const K = () => {
61
- !S && (j || !D) && m(!0);
61
+ !S && (j || !w) && m(!0);
62
62
  }, W = (t) => {
63
63
  isNaN(t.getTime()) || (k(t), s == null || s({
64
64
  value: y.Date(t, "yyyy-mm-dd"),
@@ -68,15 +68,15 @@ const dt = {
68
68
  name: c
69
69
  }), r == null || r(y.Date(t, "yyyy-mm-dd"));
70
70
  }, q = (t) => {
71
- if (D) {
72
- const N = t.target.value.replace(/[^\d]/g, "");
73
- if (N.length === 0)
71
+ if (w) {
72
+ const l = t.target.value.replace(/[^\d]/g, "");
73
+ if (l.length === 0)
74
74
  A(""), s == null || s({ value: "", name: c }), r == null || r("");
75
75
  else {
76
76
  const [I, O, Y] = [
77
- L(N.substring(0, 2), st),
78
- L(N.substring(2, 4), et),
79
- N.substring(4, 8)
77
+ L(l.substring(0, 2), st),
78
+ L(l.substring(2, 4), et),
79
+ l.substring(4, 8)
80
80
  ], $ = [I, O, Y].filter(Boolean).join("/");
81
81
  if (A($), $.length === it) {
82
82
  const B = parseInt(Y), P = /* @__PURE__ */ new Date(
@@ -89,7 +89,7 @@ const dt = {
89
89
  }
90
90
  }
91
91
  }
92
- }, J = _(e.wrapper, l && e.active), Q = _(e.input, e.inputBorderControl), Z = {
92
+ }, J = _(e.wrapper, D && e.active), Q = _(e.input, e.inputBorderControl), Z = {
93
93
  onChangeValue: W,
94
94
  date: o || /* @__PURE__ */ new Date(),
95
95
  before: typeof v == "string" ? new Date(v) : v,
@@ -114,9 +114,9 @@ const dt = {
114
114
  "div",
115
115
  {
116
116
  role: "button",
117
- "data-error": n,
117
+ "data-error": !!n,
118
118
  className: _(e["date-wrapper"], {
119
- [e.editable]: D
119
+ [e.editable]: w
120
120
  }),
121
121
  onClick: K,
122
122
  children: /* @__PURE__ */ a(
@@ -133,18 +133,18 @@ const dt = {
133
133
  onChange: q,
134
134
  rightAddon: {
135
135
  addonType: "react-node",
136
- addonContent: /* @__PURE__ */ a(C, { isActive: l })
136
+ addonContent: /* @__PURE__ */ a(C, { isActive: D })
137
137
  },
138
138
  onFocus: () => {
139
- j && !D && m(!0);
139
+ j && !w && m(!0);
140
140
  },
141
- "data-error": n,
141
+ "data-error": !!n,
142
142
  ...E
143
143
  }
144
144
  )
145
145
  }
146
146
  ),
147
- l && /* @__PURE__ */ a(z, { ...Z })
147
+ D && /* @__PURE__ */ a(z, { ...Z })
148
148
  ] }),
149
149
  n && typeof n == "string" && /* @__PURE__ */ a("div", { className: e.textError, children: n })
150
150
  ] });
@@ -1,20 +1,20 @@
1
- import { useRef as g, useEffect as m } from "react";
1
+ import { useRef as x, useEffect as a } from "react";
2
2
  import { BLOCK_WIDTH as f } from "./constants.js";
3
- const x = (d) => {
4
- const t = g(null);
5
- return m(() => {
6
- var n, i, o, r, c, s;
7
- const h = window.innerHeight, w = window.innerWidth;
3
+ const H = (d) => {
4
+ const t = x(null);
5
+ return a(() => {
6
+ var o, r, s, c, l, u;
7
+ const h = window.innerHeight, y = window.innerWidth;
8
8
  if (t.current !== null) {
9
- const a = ((i = (n = t == null ? void 0 : t.current) == null ? void 0 : n.parentElement) == null ? void 0 : i.offsetWidth) ?? 0, u = ((r = (o = t == null ? void 0 : t.current) == null ? void 0 : o.parentElement) == null ? void 0 : r.offsetHeight) ?? 0, l = (s = (c = t == null ? void 0 : t.current) == null ? void 0 : c.parentElement) == null ? void 0 : s.getBoundingClientRect(), p = t.current.offsetHeight;
10
- if (h < l.y + p + u ? t.current.style.top = -p + "px" : t.current.style.top = u + "px", w < l.x + f) {
11
- const e = a - f;
12
- t.current.style.left = (e < 0 ? e / 2 : e) + "px";
9
+ const w = ((r = (o = t == null ? void 0 : t.current) == null ? void 0 : o.parentElement) == null ? void 0 : r.offsetWidth) ?? 0, p = ((c = (s = t == null ? void 0 : t.current) == null ? void 0 : s.parentElement) == null ? void 0 : c.offsetHeight) ?? 0, n = (u = (l = t == null ? void 0 : t.current) == null ? void 0 : l.parentElement) == null ? void 0 : u.getBoundingClientRect(), i = t.current.offsetHeight;
10
+ if (h < n.y + i + p ? n.y - i > 0 ? t.current.style.top = -i + "px" : t.current.style.position = "fixed" : t.current.style.top = p + "px", y < n.x + f) {
11
+ const e = w - f;
12
+ n.x - e < 0 ? t.current.style.left = (e < 0 ? e / 2 : e) + "px" : t.current.style.left = -e + "px";
13
13
  }
14
14
  t.current.style.opacity = "1";
15
15
  }
16
16
  }, [d]), t;
17
17
  };
18
18
  export {
19
- x as useDatePickerPosition
19
+ H as useDatePickerPosition
20
20
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.38.0",
4
+ "version": "1.38.1",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {