mimir-ui-kit 1.38.15 → 1.38.16

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