mimir-ui-kit 1.43.17 → 1.43.18

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.
@@ -25,6 +25,10 @@ export type TProps = {
25
25
  * Значение типа модального окна календаря
26
26
  */
27
27
  type?: 'days' | 'months' | 'years';
28
+ /**
29
+ * Формат отображения даты в инпуте
30
+ */
31
+ dateFormat?: 'full' | 'month' | 'year';
28
32
  /**
29
33
  * Флаг отключения компонента
30
34
  */
@@ -99,6 +103,10 @@ export declare const DatePicker: import('react').MemoExoticComponent<import('rea
99
103
  * Значение типа модального окна календаря
100
104
  */
101
105
  type?: "days" | "months" | "years";
106
+ /**
107
+ * Формат отображения даты в инпуте
108
+ */
109
+ dateFormat?: "full" | "month" | "year";
102
110
  /**
103
111
  * Флаг отключения компонента
104
112
  */
@@ -1,242 +1,353 @@
1
- import { jsxs as Q, jsx as d } from "react/jsx-runtime";
2
- import { c as X } from "../../index-DIxK0V-G.js";
3
- import { memo as pt, forwardRef as dt, useState as I, useEffect as $ } from "react";
4
- import { MAX_DAY as yt, MAX_MONTH as wt, DATE_LENGTH as lt } from "./constants.js";
5
- import { DatePickerModal as Nt } from "./DatePickerModal.js";
6
- import { MonthPickerModal as Tt } from "./MonthPickerModal.js";
7
- import { c as n } from "../../styles.module-Cuqm31CO.js";
8
- import { formatDatePart as Z } from "./utils.js";
1
+ import { jsxs as Z, jsx as D } from "react/jsx-runtime";
2
+ import { c as G } from "../../index-DIxK0V-G.js";
3
+ import { memo as dt, forwardRef as Dt, useState as b, useEffect as H } from "react";
4
+ import { months as $, MAX_DAY as wt, MAX_MONTH as kt, DATE_LENGTH as Nt } from "./constants.js";
5
+ import { DatePickerModal as ut } from "./DatePickerModal.js";
6
+ import { MonthPickerModal as ht } from "./MonthPickerModal.js";
7
+ import { c as y } from "../../styles.module-Cuqm31CO.js";
8
+ import { formatDatePart as z } from "./utils.js";
9
9
  import { YearPickerModal as Mt } from "./YearPickerModal.js";
10
- import { useClickOutside as kt } from "../../hooks/useClickOutside/useClickOutside.js";
11
- import { Icon as z } from "../../icons/Icon.js";
12
- import { formating as w } from "../../utils/index.js";
13
- import { I as At } from "../../Input-BU_6U1CW.js";
14
- import { EInputStatus as It, EInputSize as b } from "../Input/constants.js";
15
- const Pt = pt(
16
- dt(
10
+ import { useClickOutside as gt } from "../../hooks/useClickOutside/useClickOutside.js";
11
+ import { Icon as C } from "../../icons/Icon.js";
12
+ import { formating as p } from "../../utils/index.js";
13
+ import { I as Tt } from "../../Input-BU_6U1CW.js";
14
+ import { EInputStatus as bt, EInputSize as R } from "../Input/constants.js";
15
+ const $t = dt(
16
+ Dt(
17
17
  ({
18
- size: g,
19
- value: l,
20
- onChangeValue: s,
21
- name: y,
22
- before: N,
23
- type: a = "days",
24
- error: j,
25
- onError: T,
26
- onBlur: o,
27
- validateImmediately: G,
28
- variant: C,
29
- disabled: v = !1,
30
- editable: x = !1,
31
- openOnInput: L = !0,
32
- sendIntermediateValues: R = !1,
33
- disableFuture: W = !1,
34
- disablePast: q = !1,
35
- disabledDate: _,
36
- validRange: c,
37
- ...u
38
- }, B) => {
39
- const [h, D] = I(!1), [F, m] = I(a), [p, M] = I(
40
- () => l && !isNaN(new Date(l).getTime()) ? new Date(l) : void 0
41
- ), [S, O] = I(j), [V, H] = I(""), [tt, k] = I();
42
- u.status = !!S && It.Error || u.status, $(() => {
43
- O(j);
44
- }, [j]), $(() => {
45
- M(
46
- l && !isNaN(new Date(l).getTime()) ? new Date(l) : void 0
18
+ size: j,
19
+ value: k,
20
+ onChangeValue: a,
21
+ name: w,
22
+ before: h,
23
+ type: n = "days",
24
+ dateFormat: N = "full",
25
+ error: v,
26
+ onError: M,
27
+ onBlur: m,
28
+ validateImmediately: L,
29
+ variant: B,
30
+ disabled: _ = !1,
31
+ editable: A = !1,
32
+ openOnInput: W = !0,
33
+ sendIntermediateValues: V = !1,
34
+ disableFuture: q = !1,
35
+ disablePast: E = !1,
36
+ disabledDate: O,
37
+ validRange: o,
38
+ ...S
39
+ }, tt) => {
40
+ const [Y, d] = b(!1), [U, l] = b(n), [f, g] = b(
41
+ () => k && !isNaN(new Date(k).getTime()) ? new Date(k) : void 0
42
+ ), [I, X] = b(v), [et, P] = b(""), [st, T] = b();
43
+ S.status = !!I && bt.Error || S.status, H(() => {
44
+ X(v);
45
+ }, [v]), H(() => {
46
+ g(
47
+ k && !isNaN(new Date(k).getTime()) ? new Date(k) : void 0
47
48
  );
48
- }, [l]), $(() => {
49
- p && typeof p != "string" && !isNaN(p == null ? void 0 : p.getTime()) ? H(w.Date(p, "dd/mm/yyyy")) : H("");
50
- }, [p]);
51
- const E = l && new Date(l).getTime;
52
- $(() => {
53
- G && (E ? (O(!1), T == null || T({ name: y, active: !1 })) : (O(!0), T == null || T({ name: y, active: !0 })));
54
- }, [G, y, E]), kt({
55
- isActive: h,
49
+ }, [k]), H(() => {
50
+ if (f && typeof f != "string" && !isNaN(f == null ? void 0 : f.getTime())) {
51
+ let t = "";
52
+ switch (N) {
53
+ case "year": {
54
+ t = f.getFullYear().toString();
55
+ break;
56
+ }
57
+ case "month": {
58
+ const s = $[f.getMonth()], e = f.getFullYear();
59
+ t = `${s} ${e}`;
60
+ break;
61
+ }
62
+ case "full": {
63
+ t = p.Date(f, "dd/mm/yyyy");
64
+ break;
65
+ }
66
+ default: {
67
+ t = p.Date(f, "dd/mm/yyyy");
68
+ break;
69
+ }
70
+ }
71
+ P(t);
72
+ } else
73
+ P("");
74
+ }, [f, N]);
75
+ const J = k && new Date(k).getTime;
76
+ H(() => {
77
+ L && (J ? (X(!1), M == null || M({ name: w, active: !1 })) : (X(!0), M == null || M({ name: w, active: !0 })));
78
+ }, [L, w, J]), gt({
79
+ isActive: Y,
56
80
  setActive: (t) => {
57
- D(t), m(a), t || k(void 0);
81
+ d(t), l(n), t || T(void 0);
58
82
  },
59
- className: n["calendar-block"]
83
+ className: y["calendar-block"]
60
84
  });
61
- const et = () => {
62
- !v && (L || !x) && D(!0);
63
- }, J = (t) => {
64
- const r = t.getTime();
65
- if (t.setHours(0, 0, 0, 0), N && (typeof N == "string" ? new Date(N) : N).getTime() > r)
85
+ const rt = () => {
86
+ !_ && (W || !A) && d(!0);
87
+ }, K = (t) => {
88
+ const s = t.getTime();
89
+ if (t.setHours(0, 0, 0, 0), h && (typeof h == "string" ? new Date(h) : h).getTime() > s)
66
90
  return !1;
67
- if (W) {
68
- const i = /* @__PURE__ */ new Date();
69
- if (i.setHours(0, 0, 0, 0), t.getTime() > i.getTime()) return !1;
70
- }
71
91
  if (q) {
72
- const i = /* @__PURE__ */ new Date();
73
- if (i.setHours(0, 0, 0, 0), r < i.getTime()) return !1;
92
+ const e = /* @__PURE__ */ new Date();
93
+ if (e.setHours(0, 0, 0, 0), t.getTime() > e.getTime()) return !1;
94
+ }
95
+ if (E) {
96
+ const e = /* @__PURE__ */ new Date();
97
+ if (e.setHours(0, 0, 0, 0), s < e.getTime()) return !1;
74
98
  }
75
- if (_ && _(t)) return !1;
76
- if (c) {
77
- let i;
78
- typeof c[0] == "string" ? i = [
79
- new Date(c[0]),
80
- typeof c[1] == "string" ? new Date(c[1]) : c[1]
81
- ] : i = [
82
- c[0],
83
- typeof c[1] == "string" ? new Date(c[1]) : c[1]
99
+ if (O && O(t)) return !1;
100
+ if (o) {
101
+ let e;
102
+ typeof o[0] == "string" ? e = [
103
+ new Date(o[0]),
104
+ typeof o[1] == "string" ? new Date(o[1]) : o[1]
105
+ ] : e = [
106
+ o[0],
107
+ typeof o[1] == "string" ? new Date(o[1]) : o[1]
84
108
  ];
85
- const [f, e] = i, P = new Date(f), A = new Date(e);
86
- if (P.setHours(0, 0, 0, 0), A.setHours(23, 59, 59, 999), t < P || t > A) return !1;
109
+ const [i, r] = e, c = new Date(i), u = new Date(r);
110
+ if (c.setHours(0, 0, 0, 0), u.setHours(23, 59, 59, 999), t < c || t > u) return !1;
87
111
  }
88
112
  return !0;
89
- }, st = (t) => {
90
- isNaN(t.getTime()) || (M(t), k(void 0), s == null || s({
91
- value: w.Date(t, "yyyy-mm-dd"),
92
- name: y
93
- })), F === "years" && (a === "years" ? (D(!1), m(a)) : m("months")), F === "months" && (a === "months" ? (D(!1), m(a)) : m("days")), M(t), s == null || s({
94
- value: w.Date(t, "yyyy-mm-dd"),
95
- name: y
96
- }), o == null || o(w.Date(t, "yyyy-mm-dd"));
97
- }, it = (t) => {
98
- const r = p || /* @__PURE__ */ new Date(), i = r.getDate(), f = r.getMonth() + 1, e = new Date(t, f - 1, i);
99
- if (e.getFullYear() === t && e.getMonth() === f - 1 && e.getDate() === i && J(e)) {
100
- if (M(e), k(void 0), s == null || s({
101
- value: w.Date(e, "yyyy-mm-dd"),
102
- name: y
103
- }), o == null || o(w.Date(e, "yyyy-mm-dd")), a === "years") {
104
- D(!1), m(a);
113
+ }, at = (t) => {
114
+ if (!isNaN(t.getTime())) {
115
+ g(t), T(void 0);
116
+ let e = "";
117
+ switch (N) {
118
+ case "year": {
119
+ e = t.getFullYear().toString();
120
+ break;
121
+ }
122
+ case "month": {
123
+ const i = $[t.getMonth()], r = t.getFullYear();
124
+ e = `${i} ${r}`;
125
+ break;
126
+ }
127
+ case "full": {
128
+ e = p.Date(t, "yyyy-mm-dd");
129
+ break;
130
+ }
131
+ default: {
132
+ e = p.Date(t, "yyyy-mm-dd");
133
+ break;
134
+ }
135
+ }
136
+ a == null || a({
137
+ value: e,
138
+ name: w
139
+ });
140
+ }
141
+ U === "years" && (n === "years" ? (d(!1), l(n)) : l("months")), U === "months" && (n === "months" ? (d(!1), l(n)) : l("days")), g(t);
142
+ let s = "";
143
+ switch (N) {
144
+ case "year": {
145
+ s = t.getFullYear().toString();
146
+ break;
147
+ }
148
+ case "month": {
149
+ const e = $[t.getMonth()], i = t.getFullYear();
150
+ s = `${e} ${i}`;
151
+ break;
152
+ }
153
+ case "full": {
154
+ s = p.Date(t, "yyyy-mm-dd");
155
+ break;
156
+ }
157
+ default: {
158
+ s = p.Date(t, "yyyy-mm-dd");
159
+ break;
160
+ }
161
+ }
162
+ a == null || a({
163
+ value: s,
164
+ name: w
165
+ }), m == null || m(s);
166
+ }, ct = (t) => {
167
+ const s = f || /* @__PURE__ */ new Date(), e = s.getDate(), i = s.getMonth() + 1, r = new Date(t, i - 1, e);
168
+ if (r.getFullYear() === t && r.getMonth() === i - 1 && r.getDate() === e && K(r)) {
169
+ g(r), T(void 0);
170
+ let c = "";
171
+ switch (N) {
172
+ case "year": {
173
+ c = t.toString();
174
+ break;
175
+ }
176
+ case "month": {
177
+ c = `${$[i - 1]} ${t}`;
178
+ break;
179
+ }
180
+ case "full": {
181
+ c = p.Date(r, "yyyy-mm-dd");
182
+ break;
183
+ }
184
+ default: {
185
+ c = p.Date(r, "yyyy-mm-dd");
186
+ break;
187
+ }
188
+ }
189
+ if (a == null || a({
190
+ value: c,
191
+ name: w
192
+ }), m == null || m(c), n === "years") {
193
+ d(!1), l(n);
105
194
  return;
106
195
  }
107
196
  } else
108
- k(new Date(t, f - 1, 1));
109
- a === "years" ? (D(!1), m(a)) : m("months");
110
- }, rt = (t, r) => {
111
- const f = (p || /* @__PURE__ */ new Date()).getDate(), e = new Date(t, r - 1, f);
112
- if (e.getFullYear() === t && e.getMonth() === r - 1 && e.getDate() === f && J(e)) {
113
- if (M(e), k(void 0), s == null || s({
114
- value: w.Date(e, "yyyy-mm-dd"),
115
- name: y
116
- }), o == null || o(w.Date(e, "yyyy-mm-dd")), a === "months") {
117
- D(!1), m(a);
197
+ T(new Date(t, i - 1, 1));
198
+ n === "years" ? (d(!1), l(n)) : l("months");
199
+ }, it = (t, s) => {
200
+ const i = (f || /* @__PURE__ */ new Date()).getDate(), r = new Date(t, s - 1, i);
201
+ if (r.getFullYear() === t && r.getMonth() === s - 1 && r.getDate() === i && K(r)) {
202
+ g(r), T(void 0);
203
+ let c = "";
204
+ switch (N) {
205
+ case "year": {
206
+ c = t.toString();
207
+ break;
208
+ }
209
+ case "month": {
210
+ c = `${$[s - 1]} ${t}`;
211
+ break;
212
+ }
213
+ case "full": {
214
+ c = p.Date(r, "yyyy-mm-dd");
215
+ break;
216
+ }
217
+ default: {
218
+ c = p.Date(r, "yyyy-mm-dd");
219
+ break;
220
+ }
221
+ }
222
+ if (a == null || a({
223
+ value: c,
224
+ name: w
225
+ }), m == null || m(c), n === "months") {
226
+ d(!1), l(n);
118
227
  return;
119
228
  }
120
229
  } else
121
- k(new Date(t, r - 1, 1));
122
- a === "months" ? (D(!1), m(a)) : m("days");
123
- }, ct = (t) => {
124
- if (x) {
125
- const r = t.target.value.replace(/[^\d]/g, "");
126
- if (r.length === 0)
127
- H(""), s == null || s({ value: "", name: y }), o == null || o("");
230
+ T(new Date(t, s - 1, 1));
231
+ n === "months" ? (d(!1), l(n)) : l("days");
232
+ }, ot = (t) => {
233
+ if (A) {
234
+ const s = t.target.value.replace(/[^\d]/g, "");
235
+ if (s.length === 0)
236
+ P(""), a == null || a({ value: "", name: w }), m == null || m("");
128
237
  else {
129
- const [i, f, e] = [
130
- Z(r.substring(0, 2), yt),
131
- Z(r.substring(2, 4), wt),
132
- r.substring(4, 8)
133
- ], P = [i, f, e].filter(Boolean).join("/");
134
- if (H(P), R) {
135
- const A = e ? `${e}-${f || "00"}-${i || "00"}` : [i, f, e].filter(Boolean).join("-");
136
- s == null || s({
137
- value: A,
138
- name: y
238
+ const [e, i, r] = [
239
+ z(s.substring(0, 2), wt),
240
+ z(s.substring(2, 4), kt),
241
+ s.substring(4, 8)
242
+ ], c = [e, i, r].filter(Boolean).join("/");
243
+ if (P(c), V) {
244
+ const u = r ? `${r}-${i || "00"}-${e || "00"}` : [e, i, r].filter(Boolean).join("-");
245
+ a == null || a({
246
+ value: u,
247
+ name: w
139
248
  });
140
249
  }
141
- if (P.length === lt) {
142
- const A = parseInt(e), Y = /* @__PURE__ */ new Date(
143
- `${A}-${f.padStart(2, "0")}-${i.padStart(2, "0")}`
250
+ if (c.length === Nt) {
251
+ const u = parseInt(r), x = /* @__PURE__ */ new Date(
252
+ `${u}-${i.padStart(2, "0")}-${e.padStart(2, "0")}`
144
253
  );
145
- isNaN(Y.getTime()) || (M(Y), s == null || s({
146
- value: w.Date(Y, "yyyy-mm-dd"),
147
- name: y
148
- }), o == null || o(w.Date(Y, "yyyy-mm-dd")));
254
+ isNaN(x.getTime()) || (g(x), a == null || a({
255
+ value: p.Date(x, "yyyy-mm-dd"),
256
+ name: w
257
+ }), m == null || m(p.Date(x, "yyyy-mm-dd")));
149
258
  }
150
259
  }
151
260
  }
152
- }, ot = X(n.wrapper, h && n.active), at = X(n.input, n.inputBorderControl);
153
- let K;
154
- if (c) {
155
- let t, r;
156
- typeof c[0] == "string" ? t = new Date(c[0]) : t = c[0], typeof c[1] == "string" ? r = new Date(c[1]) : r = c[1], K = [t, r];
261
+ }, mt = G(y.wrapper, Y && y.active), ft = G(y.input, y.inputBorderControl);
262
+ let Q;
263
+ if (o) {
264
+ let t, s;
265
+ typeof o[0] == "string" ? t = new Date(o[0]) : t = o[0], typeof o[1] == "string" ? s = new Date(o[1]) : s = o[1], Q = [t, s];
157
266
  }
158
- const U = {
159
- onChangeValue: st,
160
- date: tt || p || /* @__PURE__ */ new Date(),
161
- selectedDate: p,
162
- before: typeof N == "string" ? new Date(N) : N,
163
- onChangeType: m,
164
- setIsActive: D,
165
- disableFuture: W,
166
- disablePast: q,
167
- disabledDate: _,
168
- validRange: K
169
- }, ft = {
170
- ...U,
171
- onChangeMonth: rt
172
- }, mt = {
173
- ...U,
174
- onChangeYear: it
175
- }, nt = (() => {
176
- switch (F) {
267
+ const F = {
268
+ onChangeValue: at,
269
+ date: st || f || /* @__PURE__ */ new Date(),
270
+ selectedDate: f,
271
+ before: typeof h == "string" ? new Date(h) : h,
272
+ onChangeType: l,
273
+ setIsActive: d,
274
+ disableFuture: q,
275
+ disablePast: E,
276
+ disabledDate: O,
277
+ validRange: Q,
278
+ dateFormat: N
279
+ }, nt = {
280
+ ...F,
281
+ onChangeMonth: it,
282
+ dateFormat: N
283
+ }, lt = {
284
+ ...F,
285
+ onChangeYear: ct
286
+ }, yt = (() => {
287
+ switch (U) {
177
288
  case "months":
178
- return () => /* @__PURE__ */ d(Tt, { ...ft });
289
+ return () => /* @__PURE__ */ D(ht, { ...nt });
179
290
  case "years":
180
- return () => /* @__PURE__ */ d(Mt, { ...mt });
291
+ return () => /* @__PURE__ */ D(Mt, { ...lt });
181
292
  default:
182
- return () => /* @__PURE__ */ d(Nt, { ...U });
293
+ return () => /* @__PURE__ */ D(ut, { ...F });
183
294
  }
184
- })(), Dt = ({ isActive: t }) => /* @__PURE__ */ d("button", { onClick: (i) => {
185
- i.stopPropagation(), v || D(!t);
186
- }, className: n["icon-button"], children: t ? /* @__PURE__ */ d(
187
- z,
295
+ })(), pt = ({ isActive: t }) => /* @__PURE__ */ D("button", { onClick: (e) => {
296
+ e.stopPropagation(), _ || d(!t);
297
+ }, className: y["icon-button"], children: t ? /* @__PURE__ */ D(
298
+ C,
188
299
  {
189
- iconName: g === b.S ? "DropdownArrowUp16px" : "DropdownArrowUp24px"
300
+ iconName: j === R.S ? "DropdownArrowUp16px" : "DropdownArrowUp24px"
190
301
  }
191
- ) : /* @__PURE__ */ d(
192
- z,
302
+ ) : /* @__PURE__ */ D(
303
+ C,
193
304
  {
194
- iconName: g === b.S ? "DropdownArrowBottom16px" : "DropdownArrowDown24px"
305
+ iconName: j === R.S ? "DropdownArrowBottom16px" : "DropdownArrowDown24px"
195
306
  }
196
307
  ) });
197
- return /* @__PURE__ */ Q("div", { className: n["input-field-group-datePicker"], children: [
198
- /* @__PURE__ */ Q("div", { className: ot, "data-disabled": v, children: [
199
- /* @__PURE__ */ d(
308
+ return /* @__PURE__ */ Z("div", { className: y["input-field-group-datePicker"], children: [
309
+ /* @__PURE__ */ Z("div", { className: mt, "data-disabled": _, children: [
310
+ /* @__PURE__ */ D(
200
311
  "div",
201
312
  {
202
313
  role: "button",
203
- "data-status": u.status,
204
- className: X(n["date-wrapper"], {
205
- [n.editable]: x
314
+ "data-status": S.status,
315
+ className: G(y["date-wrapper"], {
316
+ [y.editable]: A
206
317
  }),
207
- onClick: et,
208
- children: /* @__PURE__ */ d(
209
- At,
318
+ onClick: rt,
319
+ children: /* @__PURE__ */ D(
320
+ Tt,
210
321
  {
211
- ref: B,
212
- className: at,
213
- wrapperClassName: n["input-wrapper"],
214
- size: g,
322
+ ref: tt,
323
+ className: ft,
324
+ wrapperClassName: y["input-wrapper"],
325
+ size: j,
215
326
  type: "text",
216
- variant: C,
217
- value: V,
218
- onChange: ct,
327
+ variant: B,
328
+ value: et,
329
+ onChange: ot,
219
330
  rightAddon: {
220
331
  addonType: "react-node",
221
- addonContent: /* @__PURE__ */ d(Dt, { isActive: h })
332
+ addonContent: /* @__PURE__ */ D(pt, { isActive: Y })
222
333
  },
223
- rightSlotClassName: n["right-slot"],
334
+ rightSlotClassName: y["right-slot"],
224
335
  onFocus: () => {
225
- L && !x && D(!0);
336
+ W && !A && d(!0);
226
337
  },
227
- ...u
338
+ ...S
228
339
  }
229
340
  )
230
341
  }
231
342
  ),
232
- h && /* @__PURE__ */ d(nt, {})
343
+ Y && /* @__PURE__ */ D(yt, {})
233
344
  ] }),
234
- S && typeof S == "string" && /* @__PURE__ */ d("div", { className: n.textError, children: S })
345
+ I && typeof I == "string" && /* @__PURE__ */ D("div", { className: y.textError, children: I })
235
346
  ] });
236
347
  }
237
348
  )
238
349
  );
239
- Pt.displayName = "DatePicker";
350
+ $t.displayName = "DatePicker";
240
351
  export {
241
- Pt as DatePicker
352
+ $t as DatePicker
242
353
  };
@@ -9,6 +9,7 @@ type TProps = {
9
9
  disablePast?: boolean;
10
10
  disabledDate?: (date: Date) => boolean;
11
11
  validRange?: [Date, Date];
12
+ dateFormat?: 'full' | 'month' | 'year';
12
13
  };
13
- export declare const DatePickerModal: ({ date, selectedDate, onChangeValue, setIsActive, before, onChangeType, disableFuture, disablePast, disabledDate, validRange }: TProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const DatePickerModal: ({ date, selectedDate, onChangeValue, setIsActive, before, onChangeType, disableFuture, disablePast, disabledDate, validRange, dateFormat }: TProps) => import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -1,103 +1,104 @@
1
1
  import { jsxs as u, jsx as a } from "react/jsx-runtime";
2
- import { c as P } from "../../index-DIxK0V-G.js";
3
- import { useState as G } from "react";
4
- import { week as U, COUNT_WORK_DAYS as V } from "./constants.js";
5
- import { useDatePickerPosition as W } from "./hooks.js";
2
+ import { c as A } from "../../index-DIxK0V-G.js";
3
+ import { useState as U } from "react";
4
+ import { week as V, COUNT_WORK_DAYS as W } from "./constants.js";
5
+ import { useDatePickerPosition as E } from "./hooks.js";
6
6
  import { c as n } from "../../styles.module-Cuqm31CO.js";
7
- import { getUpdateDate as A } from "./utils.js";
8
- import { Icon as E } from "../../icons/Icon.js";
7
+ import { getUpdateDate as B } from "./utils.js";
8
+ import { Icon as K } from "../../icons/Icon.js";
9
9
  import { formating as m } from "../../utils/index.js";
10
- import { Button as B } from "../Button/Button.js";
11
- import { parseDate as H } from "../../utils/formating/Date.js";
12
- const at = ({
10
+ import { Button as H } from "../Button/Button.js";
11
+ import { parseDate as I } from "../../utils/formating/Date.js";
12
+ const mt = ({
13
13
  date: i,
14
14
  selectedDate: d,
15
- onChangeValue: I,
16
- setIsActive: O,
17
- before: p,
15
+ onChangeValue: O,
16
+ setIsActive: S,
17
+ before: g,
18
18
  onChangeType: D,
19
- disableFuture: S = !1,
20
- disablePast: T = !1,
21
- disabledDate: h,
22
- validRange: N
19
+ disableFuture: T = !1,
20
+ disablePast: _ = !1,
21
+ disabledDate: p,
22
+ validRange: N,
23
+ dateFormat: w
23
24
  }) => {
24
- var $;
25
+ var k;
25
26
  i = isNaN(new Date(i).getTime()) ? /* @__PURE__ */ new Date() : i;
26
- const l = H(i), f = d ? H(d) : l, y = {
27
+ const l = I(i), f = d ? I(d) : l, y = {
27
28
  y: f.getFullYear(),
28
29
  d: f.getDate(),
29
30
  m: f.getMonth() + 1
30
- }, w = {
31
+ }, v = {
31
32
  y: l.getFullYear(),
32
33
  d: l.getDate(),
33
34
  m: l.getMonth() + 1
34
- }, [r, b] = G({ y: w.y, m: w.m }), _ = W([r]), j = (t) => {
35
+ }, [r, b] = U({ y: v.y, m: v.m }), j = E([r]), C = (t) => {
35
36
  let e = t.getDay();
36
37
  return e === 0 && (e = 7), e - 1;
37
- }, v = r.m - 1, c = new Date(r.y, v), g = [], x = (() => {
38
+ }, x = r.m - 1, c = new Date(r.y, x), h = [], M = (() => {
38
39
  const t = new Date(c);
39
40
  t.setDate(t.getDate() - 1);
40
41
  const e = t.getDate(), o = [];
41
- for (let s = 0; s < j(c); s++)
42
+ for (let s = 0; s < C(c); s++)
42
43
  o.push(e - s);
43
44
  return o.reverse(), o;
44
45
  })();
45
- for (; c.getMonth() === v; )
46
- g.push(c.getDate()), c.setDate(c.getDate() + 1);
47
- const C = (() => {
48
- const e = 42 - (x.length + g.length), o = [];
46
+ for (; c.getMonth() === x; )
47
+ h.push(c.getDate()), c.setDate(c.getDate() + 1);
48
+ const L = (() => {
49
+ const e = 42 - (M.length + h.length), o = [];
49
50
  for (let s = 1; s <= e; s++)
50
51
  o.push(s);
51
52
  return o;
52
- })(), F = () => {
53
- O(!1);
54
- }, L = () => {
55
- b(A(r.m + 1, r.y));
56
- }, Y = () => {
57
- b(A(r.m - 1, r.y));
58
- }, M = (t) => {
53
+ })(), Y = () => {
54
+ S(!1);
55
+ }, z = () => {
56
+ b(B(r.m + 1, r.y));
57
+ }, F = () => {
58
+ b(B(r.m - 1, r.y));
59
+ }, $ = (t) => {
59
60
  const e = new Date(t);
60
- if (e.setHours(0, 0, 0, 0), p && p.getTime() > t)
61
+ if (e.setHours(0, 0, 0, 0), g && g.getTime() > t)
61
62
  return !0;
62
- if (S) {
63
+ if (T) {
63
64
  const o = /* @__PURE__ */ new Date();
64
65
  if (o.setHours(0, 0, 0, 0), e.getTime() > o.getTime()) return !0;
65
66
  }
66
- if (T) {
67
+ if (_) {
67
68
  const o = /* @__PURE__ */ new Date();
68
69
  if (o.setHours(0, 0, 0, 0), t < o.getTime()) return !0;
69
70
  }
70
- if (h && h(e)) return !0;
71
+ if (p && p(e)) return !0;
71
72
  if (N) {
72
- const [o, s] = N, k = new Date(t);
73
- if (o.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0), k < o || k > s) return !0;
73
+ const [o, s] = N, P = new Date(t);
74
+ if (o.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0), P < o || P > s) return !0;
74
75
  }
75
76
  return !1;
76
- }, z = (t) => {
77
- M(
77
+ }, G = (t) => {
78
+ $(
78
79
  (/* @__PURE__ */ new Date(
79
80
  `${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
80
81
  )).getTime()
81
- ) || (I(
82
+ ) || (O(
82
83
  /* @__PURE__ */ new Date(
83
84
  `${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
84
85
  )
85
- ), F());
86
+ ), Y());
86
87
  };
87
88
  return /* @__PURE__ */ u(
88
89
  "div",
89
90
  {
90
91
  className: n["calendar-block"],
91
- ref: _,
92
+ ref: j,
92
93
  "data-testid": "calendar-modal",
93
94
  children: [
94
95
  /* @__PURE__ */ u("div", { className: n.h, children: [
95
96
  /* @__PURE__ */ a(
96
- B,
97
+ H,
97
98
  {
98
99
  isIconButton: !0,
99
100
  iconName: "DropdownArrowLeft16px",
100
- onClick: Y,
101
+ onClick: F,
101
102
  variant: "secondary-gray",
102
103
  size: "l"
103
104
  }
@@ -107,46 +108,46 @@ const at = ({
107
108
  {
108
109
  type: "button",
109
110
  className: n.d,
110
- onClick: () => D == null ? void 0 : D("months"),
111
111
  "data-testid": "month-year-button",
112
+ onClick: w === "month" ? void 0 : () => D == null ? void 0 : D("months"),
112
113
  children: [
113
- ($ = m.Month(r.m)) == null ? void 0 : $.name,
114
+ (k = m.Month(r.m)) == null ? void 0 : k.name,
114
115
  "’",
115
116
  r.y.toString().slice(-2),
116
- /* @__PURE__ */ a(E, { iconName: "DropdownArrowBottom16px" })
117
+ w !== "month" && /* @__PURE__ */ a(K, { iconName: "DropdownArrowBottom16px" })
117
118
  ]
118
119
  }
119
120
  ),
120
121
  /* @__PURE__ */ a(
121
- B,
122
+ H,
122
123
  {
123
124
  isIconButton: !0,
124
125
  iconName: "DropdownArrowRight16px",
125
- onClick: L,
126
+ onClick: z,
126
127
  variant: "secondary-gray",
127
128
  size: "l"
128
129
  }
129
130
  )
130
131
  ] }),
131
132
  /* @__PURE__ */ u("div", { className: n.b, children: [
132
- U.map((t, e) => /* @__PURE__ */ a(
133
+ V.map((t, e) => /* @__PURE__ */ a(
133
134
  "div",
134
135
  {
135
- className: P(n.m, {
136
- [n.orange]: e > V
136
+ className: A(n.m, {
137
+ [n.orange]: e > W
137
138
  }),
138
139
  children: t
139
140
  },
140
141
  `v${e}`
141
142
  )),
142
- x.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e)),
143
- g.map((t, e) => /* @__PURE__ */ a(
143
+ M.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e)),
144
+ h.map((t, e) => /* @__PURE__ */ a(
144
145
  "button",
145
146
  {
146
147
  type: "button",
147
- onClick: () => z(t),
148
- className: P(
149
- M(
148
+ onClick: () => G(t),
149
+ className: A(
150
+ $(
150
151
  (/* @__PURE__ */ new Date(
151
152
  `${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
152
153
  )).getTime()
@@ -159,12 +160,12 @@ const at = ({
159
160
  },
160
161
  e
161
162
  )),
162
- C.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e))
163
+ L.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e))
163
164
  ] })
164
165
  ]
165
166
  }
166
167
  );
167
168
  };
168
169
  export {
169
- at as DatePickerModal
170
+ mt as DatePickerModal
170
171
  };
@@ -9,6 +9,7 @@ type TProps = {
9
9
  disablePast?: boolean;
10
10
  disabledDate?: (date: Date) => boolean;
11
11
  validRange?: [Date, Date];
12
+ dateFormat?: 'full' | 'month' | 'year';
12
13
  };
13
- export declare const MonthPickerModal: ({ date, selectedDate, onChangeValue, before, onChangeType, onChangeMonth, disableFuture, disablePast, disabledDate, validRange }: TProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const MonthPickerModal: ({ date, selectedDate, onChangeValue, before, onChangeType, onChangeMonth, disableFuture, disablePast, disabledDate, validRange, dateFormat }: TProps) => import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -1,66 +1,67 @@
1
1
  import { jsxs as w, jsx as f } from "react/jsx-runtime";
2
- import { c as R } from "../../index-DIxK0V-G.js";
3
- import { useState as _ } from "react";
4
- import { months as C } from "./constants.js";
5
- import { useDatePickerPosition as L } from "./hooks.js";
2
+ import { c as _ } from "../../index-DIxK0V-G.js";
3
+ import { useState as C } from "react";
4
+ import { months as L } from "./constants.js";
5
+ import { useDatePickerPosition as b } from "./hooks.js";
6
6
  import { c } from "../../styles.module-Cuqm31CO.js";
7
- import { Icon as b } from "../../icons/Icon.js";
8
- import { formating as F } from "../../utils/index.js";
9
- import { Button as H } from "../Button/Button.js";
10
- const Z = ({
11
- date: P,
7
+ import { Icon as q } from "../../icons/Icon.js";
8
+ import { formating as P } from "../../utils/index.js";
9
+ import { Button as A } from "../Button/Button.js";
10
+ const T = ({
11
+ date: F,
12
12
  selectedDate: D,
13
- onChangeValue: A,
13
+ onChangeValue: G,
14
14
  before: m,
15
15
  onChangeType: y,
16
16
  onChangeMonth: g,
17
- disableFuture: G = !1,
18
- disablePast: I = !1,
17
+ disableFuture: I = !1,
18
+ disablePast: N = !1,
19
19
  disabledDate: u,
20
- validRange: M
20
+ validRange: h,
21
+ dateFormat: M
21
22
  }) => {
22
- const N = L(), d = new Date(P), p = D ? new Date(D) : d, h = {
23
+ const O = b(), d = new Date(F), p = D ? new Date(D) : d, k = {
23
24
  y: p.getFullYear(),
24
25
  d: p.getDate(),
25
26
  m: p.getMonth() + 1
26
- }, k = {
27
+ }, x = {
27
28
  y: d.getFullYear(),
28
29
  d: d.getDate(),
29
30
  m: d.getMonth() + 1
30
- }, [t, x] = _(k.y), O = () => {
31
- x(t + 1);
32
- }, S = () => {
33
- x(t - 1);
34
- }, Y = (e) => {
35
- const i = /* @__PURE__ */ new Date(), n = i.getFullYear(), l = i.getMonth() + 1;
36
- if (M) {
37
- const [r, a] = M, o = new Date(t, e - 1, 1), s = new Date(t, e, 0);
31
+ }, [t, Y] = C(x.y), S = () => {
32
+ Y(t + 1);
33
+ }, $ = () => {
34
+ Y(t - 1);
35
+ }, v = (e) => {
36
+ const i = /* @__PURE__ */ new Date(), r = i.getFullYear(), l = i.getMonth() + 1;
37
+ if (h) {
38
+ const [n, a] = h, o = new Date(t, e - 1, 1), s = new Date(t, e, 0);
38
39
  o.setHours(0, 0, 0, 0), s.setHours(23, 59, 59, 999);
39
- const v = new Date(r), B = new Date(a);
40
- v.setHours(0, 0, 0, 0), B.setHours(23, 59, 59, 999);
41
- const j = s < v, z = o > B;
42
- if (j || z)
40
+ const B = new Date(n), H = new Date(a);
41
+ B.setHours(0, 0, 0, 0), H.setHours(23, 59, 59, 999);
42
+ const z = s < B, R = o > H;
43
+ if (z || R)
43
44
  return !0;
44
45
  }
45
46
  if (m) {
46
- const r = m.getFullYear(), a = m.getMonth() + 1;
47
- if (r > t || r === t && a > e)
47
+ const n = m.getFullYear(), a = m.getMonth() + 1;
48
+ if (n > t || n === t && a > e)
48
49
  return !0;
49
50
  }
50
- if (G && (t > n || t === n && e > l) || I && (t < n || t === n && e < l))
51
+ if (I && (t > r || t === r && e > l) || N && (t < r || t === r && e < l))
51
52
  return !0;
52
53
  if (u) {
53
- const r = new Date(t, e, 0).getDate(), a = [1, Math.ceil(r / 2), r];
54
+ const n = new Date(t, e, 0).getDate(), a = [1, Math.ceil(n / 2), n];
54
55
  for (const o of a) {
55
56
  const s = new Date(t, e - 1, o);
56
57
  if (!u(s)) return !1;
57
58
  }
58
- for (let o = 2; o < r; o += 3) {
59
+ for (let o = 2; o < n; o += 3) {
59
60
  if (a.includes(o)) continue;
60
61
  const s = new Date(t, e - 1, o);
61
62
  if (!u(s)) return !1;
62
63
  }
63
- for (let o = 1; o <= r; o++) {
64
+ for (let o = 1; o <= n; o++) {
64
65
  if (a.includes(o) || (o - 2) % 3 === 0) continue;
65
66
  const s = new Date(t, e - 1, o);
66
67
  if (!u(s)) return !1;
@@ -68,21 +69,21 @@ const Z = ({
68
69
  return !0;
69
70
  }
70
71
  return !1;
71
- }, $ = (e) => {
72
- Y(e) || (g ? g(t, e) : A(
72
+ }, j = (e) => {
73
+ v(e) || (g ? g(t, e) : G(
73
74
  /* @__PURE__ */ new Date(
74
- `${t}-${F.Number(2, e)}-${F.Number(2, k.d)}`
75
+ `${t}-${P.Number(2, e)}-${P.Number(2, x.d)}`
75
76
  )
76
77
  ));
77
78
  };
78
- return /* @__PURE__ */ w("div", { className: c["calendar-block"], ref: N, children: [
79
+ return /* @__PURE__ */ w("div", { className: c["calendar-block"], ref: O, children: [
79
80
  /* @__PURE__ */ w("div", { className: c.h, children: [
80
81
  /* @__PURE__ */ f(
81
- H,
82
+ A,
82
83
  {
83
84
  isIconButton: !0,
84
85
  iconName: "DropdownArrowLeft16px",
85
- onClick: S,
86
+ onClick: $,
86
87
  variant: "secondary-gray",
87
88
  size: "l"
88
89
  }
@@ -91,36 +92,36 @@ const Z = ({
91
92
  "button",
92
93
  {
93
94
  type: "button",
94
- onClick: () => y == null ? void 0 : y("years"),
95
95
  className: c.d,
96
96
  "data-testid": "year-button",
97
+ onClick: M === "month" ? void 0 : () => y == null ? void 0 : y("years"),
97
98
  children: [
98
99
  t.toString(),
99
- /* @__PURE__ */ f(b, { iconName: "DropdownArrowBottom16px" })
100
+ M !== "month" && /* @__PURE__ */ f(q, { iconName: "DropdownArrowBottom16px" })
100
101
  ]
101
102
  }
102
103
  ),
103
104
  /* @__PURE__ */ f(
104
- H,
105
+ A,
105
106
  {
106
107
  isIconButton: !0,
107
108
  iconName: "DropdownArrowRight16px",
108
- onClick: O,
109
+ onClick: S,
109
110
  variant: "secondary-gray",
110
111
  size: "l"
111
112
  }
112
113
  )
113
114
  ] }),
114
- /* @__PURE__ */ f("div", { className: c.monthGrid, "data-testid": "month-picker", children: C.map((e, i) => {
115
- const n = i + 1, l = Y(n);
115
+ /* @__PURE__ */ f("div", { className: c.monthGrid, "data-testid": "month-picker", children: L.map((e, i) => {
116
+ const r = i + 1, l = v(r);
116
117
  return /* @__PURE__ */ f(
117
118
  "button",
118
119
  {
119
120
  type: "button",
120
- onClick: () => $(n),
121
+ onClick: () => j(r),
121
122
  disabled: l,
122
- className: R(l ? c.m : c.a, {
123
- [c.current]: D && h.y === t && h.m === n
123
+ className: _(l ? c.m : c.a, {
124
+ [c.current]: D && k.y === t && k.m === r
124
125
  }),
125
126
  children: e
126
127
  },
@@ -130,5 +131,5 @@ const Z = ({
130
131
  ] });
131
132
  };
132
133
  export {
133
- Z as MonthPickerModal
134
+ T as MonthPickerModal
134
135
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.43.17",
4
+ "version": "1.43.18",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {