mimir-ui-kit 1.36.1 → 1.36.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ export type TProps = {
12
12
  /**
13
13
  * Функция обратного вызова при потере фокуса компонентом
14
14
  */
15
- onBlur?: (e: Date) => void;
15
+ onBlur?: (e: string) => void;
16
16
  /**
17
17
  * Функция ограничения выбора даты (до какой даты выбор не доступен)
18
18
  */
@@ -43,7 +43,7 @@ export type TProps = {
43
43
  editable?: boolean;
44
44
  } & TInputProps;
45
45
  export type TDatePickerValue = {
46
- value?: Date;
46
+ value?: string;
47
47
  name?: string;
48
48
  };
49
49
  export type TDatePickerOnError = {
@@ -62,7 +62,7 @@ export declare const DatePicker: import('react').MemoExoticComponent<import('rea
62
62
  /**
63
63
  * Функция обратного вызова при потере фокуса компонентом
64
64
  */
65
- onBlur?: (e: Date) => void;
65
+ onBlur?: (e: string) => void;
66
66
  /**
67
67
  * Функция ограничения выбора даты (до какой даты выбор не доступен)
68
68
  */
@@ -1,123 +1,123 @@
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";
1
+ import { jsxs as Q, jsx as g } from "react/jsx-runtime";
2
+ import { c as v } from "../../index-DIxK0V-G.js";
3
+ import { memo as W, forwardRef as Z, useState as y, useEffect as w } from "react";
4
+ import { MAX_DAY as E, MAX_MONTH as B, DATE_LENGTH as V } from "./constants.js";
5
+ import { DatePickerModal as tt } from "./DatePickerModal.js";
6
+ import { MonthPickerModal as st } from "./MonthPickerModal.js";
7
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";
8
+ import { formatDatePart as Y } from "./utils.js";
9
+ import { YearPickerModal as et } from "./YearPickerModal.js";
10
+ import { useClickOutside as it } from "../../hooks/useClickOutside/useClickOutside.js";
11
+ import { formating as d } from "../../utils/index.js";
12
12
  import { I as at } from "../../Input-DlGNMuUD.js";
13
13
  import { EInputStatus as rt } from "../Input/constants.js";
14
- const ot = {
15
- days: V,
16
- months: tt,
17
- years: st
18
- }, ct = Q(
19
- W(
14
+ const mt = {
15
+ days: tt,
16
+ months: st,
17
+ years: et
18
+ }, ot = W(
19
+ Z(
20
20
  ({
21
- size: Y,
21
+ size: $,
22
22
  value: s,
23
23
  onChangeValue: e,
24
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,
33
- editable: S = !1,
34
- ...H
35
- }, L) => {
36
- const [n, f] = d(!1), [T, p] = d(o), [i, l] = d(
25
+ before: N,
26
+ type: m = "days",
27
+ error: T,
28
+ onError: o,
29
+ onBlur: c,
30
+ validateImmediately: x,
31
+ variant: H,
32
+ disabled: S = !1,
33
+ editable: _ = !1,
34
+ ...L
35
+ }, R) => {
36
+ const [n, f] = y(!1), [A, p] = y(m), [i, D] = y(
37
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(() => {
42
- l(
38
+ ), [k, M] = y(T), [X, P] = y("");
39
+ w(() => {
40
+ M(T);
41
+ }, [T]), w(() => {
42
+ D(
43
43
  s && !isNaN(new Date(s).getTime()) ? new Date(s) : void 0
44
44
  );
45
- }, [s]), N(() => {
46
- i && typeof i != "string" && !isNaN(i == null ? void 0 : i.getTime()) ? M(it.Date(i, "dd/mm/yyyy")) : M("");
45
+ }, [s]), w(() => {
46
+ i && typeof i != "string" && !isNaN(i == null ? void 0 : i.getTime()) ? P(d.Date(i, "dd/mm/yyyy")) : P("");
47
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({
48
+ const b = s && new Date(s).getTime;
49
+ w(() => {
50
+ x && (b ? (M(!1), o == null || o({ name: r, active: !1 })) : (M(!0), o == null || o({ name: r, active: !0 })));
51
+ }, [x, r, b]), it({
52
52
  isActive: n,
53
53
  setActive: (t) => {
54
- f(t), p(o);
54
+ f(t), p(m);
55
55
  },
56
56
  className: a["calendar-block"]
57
57
  });
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);
58
+ const G = () => {
59
+ S || f(!0);
62
60
  }, K = (t) => {
63
- if (S) {
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")}`
61
+ isNaN(t.getTime()) || (D(t), e == null || e({ value: d.Date(t, "yyyy-mm-dd"), name: r })), A === "years" && (m === "years" ? (f(!1), p(m)) : p("months")), A === "months" && (m === "months" ? (f(!1), p(m)) : p("days")), D(t), e == null || e({ value: d.Date(t, "yyyy-mm-dd"), name: r }), c == null || c(d.Date(t, "yyyy-mm-dd"));
62
+ }, U = (t) => {
63
+ if (_) {
64
+ const I = t.target.value.replace(/[^\d]/g, ""), [h, u, O] = [
65
+ Y(I.substring(0, 2), E),
66
+ Y(I.substring(2, 4), B),
67
+ I.substring(4, 8)
68
+ ], j = [h, u, O].filter(Boolean).join("/");
69
+ if (P(j), j.length === V) {
70
+ const J = parseInt(O), l = /* @__PURE__ */ new Date(
71
+ `${J}-${u.padStart(2, "0")}-${h.padStart(2, "0")}`
72
72
  );
73
- isNaN(w.getTime()) || (l(w), e == null || e({ value: w, name: r }), m == null || m(w));
73
+ isNaN(l.getTime()) || (D(l), e == null || e({ value: d.Date(l, "yyyy-mm-dd"), name: r }), c == null || c(d.Date(l, "yyyy-mm-dd")));
74
74
  }
75
75
  }
76
- }, U = g(a.wrapper, n && a.active), q = g(a.input, a.inputBorderControl), z = {
77
- onChangeValue: G,
76
+ }, q = v(a.wrapper, n && a.active), z = v(a.input, a.inputBorderControl), C = {
77
+ onChangeValue: K,
78
78
  date: i || /* @__PURE__ */ new Date(),
79
- before: typeof D == "string" ? new Date(D) : D,
79
+ before: typeof N == "string" ? new Date(N) : N,
80
80
  onChangeType: p,
81
81
  setIsActive: f
82
- }, C = ot[T];
83
- return /* @__PURE__ */ J("div", { className: U, "data-disabled": x, children: [
84
- /* @__PURE__ */ I(
82
+ }, F = mt[A];
83
+ return /* @__PURE__ */ Q("div", { className: q, "data-disabled": S, children: [
84
+ /* @__PURE__ */ g(
85
85
  "div",
86
86
  {
87
87
  role: "button",
88
- "data-error": A,
89
- className: g(a["date-wrapper"], {
90
- [a.editable]: S
88
+ "data-error": k,
89
+ className: v(a["date-wrapper"], {
90
+ [a.editable]: _
91
91
  }),
92
- onClick: X,
93
- children: /* @__PURE__ */ I(
92
+ onClick: G,
93
+ children: /* @__PURE__ */ g(
94
94
  at,
95
95
  {
96
- ref: L,
97
- className: q,
96
+ ref: R,
97
+ className: z,
98
98
  wrapperClassName: a["input-wrapper"],
99
- size: Y,
99
+ size: $,
100
100
  type: "text",
101
- variant: $,
102
- status: A ? rt.Error : void 0,
103
- value: R,
104
- onChange: K,
101
+ variant: H,
102
+ status: k ? rt.Error : void 0,
103
+ value: X,
104
+ onChange: U,
105
105
  rightAddon: {
106
106
  addonType: "icon",
107
107
  addonContent: n ? "DropdownArrowUp24px" : "DropdownArrowDown24px"
108
108
  },
109
- "data-error": A,
110
- ...H
109
+ "data-error": k,
110
+ ...L
111
111
  }
112
112
  )
113
113
  }
114
114
  ),
115
- n && /* @__PURE__ */ I(C, { ...z })
115
+ n && /* @__PURE__ */ g(F, { ...C })
116
116
  ] });
117
117
  }
118
118
  )
119
119
  );
120
- ct.displayName = "DatePicker";
120
+ ot.displayName = "DatePicker";
121
121
  export {
122
- ct as DatePicker
122
+ ot as DatePicker
123
123
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.36.1",
4
+ "version": "1.36.2",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {