@alphakits/ui 2.5.16 → 2.5.17

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,17 +1,19 @@
1
- import { useRef as g, useEffect as y } from "react";
2
- import { startOfDay as k, startOfMonth as m, startOfISOWeek as v, endOfISOWeek as p, lastDayOfMonth as T, eachDayOfInterval as I, isSameDay as h, eachMonthOfInterval as S, endOfYear as E, startOfYear as u, eachYearOfInterval as x, max as d, min as D, addDays as l, isBefore as M, isAfter as b, isSameMonth as A, endOfWeek as N, startOfWeek as Y, addMonths as _, subMonths as R, subDays as O } from "../utils/date/index.js";
3
- const w = 7, X = 12, K = 6;
1
+ import { useRef as W, useEffect as g } from "react";
2
+ import { startOfDay as O, startOfMonth as D, startOfISOWeek as p, endOfISOWeek as v, lastDayOfMonth as T, eachDayOfInterval as I, isSameDay as h, eachMonthOfInterval as S, endOfYear as E, startOfYear as u, eachYearOfInterval as x, max as d, min as m, addDays as l, isBefore as w, isAfter as y, isSameMonth as A, endOfWeek as N, startOfWeek as Y, addMonths as _, subMonths as R, subDays as k } from "../utils/date/index.js";
3
+ const M = 7, X = 12, K = 6;
4
4
  function B(e) {
5
5
  const n = e.getDay();
6
- return n === 0 ? w - 1 : n - 1;
6
+ return n === 0 ? M - 1 : n - 1;
7
7
  }
8
8
  function j(e, t) {
9
- const n = () => Array(w).fill(null), r = m(e), i = v(m(e)), a = p(T(e));
9
+ const n = () => Array(M).fill(null), r = D(e), i = p(D(e)), f = v(T(e));
10
10
  let s = n();
11
- return I({ start: i, end: a }).reduce((o, f) => {
12
- const c = B(f);
13
- return s[c] = H(f, r, t), (c === K || h(f, a)) && (o.push(s), s = n()), o;
14
- }, []);
11
+ const o = [];
12
+ for (const a of I({ start: i, end: f })) {
13
+ const c = B(a);
14
+ s[c] = H(a, r, t), (c === K || h(a, f)) && (o.push(s), s = n());
15
+ }
16
+ return s.some((a) => a !== null) && o.push(s), o;
15
17
  }
16
18
  function q(e, t) {
17
19
  return S({ start: u(e), end: E(e) }).map(
@@ -20,17 +22,17 @@ function q(e, t) {
20
22
  }
21
23
  function z(e, t) {
22
24
  return x({
23
- start: D([u(t), u(e)]),
25
+ start: m([u(t), u(e)]),
24
26
  end: d([u(t), u(e)])
25
27
  }).reverse();
26
28
  }
27
29
  function H(e, t, n) {
28
- const { minDate: r, maxDate: i, selected: a, eventsMap: s = {}, offDaysMap: o = {} } = n, f = o[e.getTime()], c = r && M(e, r) || i && b(e, i);
30
+ const { minDate: r, maxDate: i, selected: f, eventsMap: s = {}, offDaysMap: o = {} } = n, a = o[e.getTime()], c = r && w(e, r) || i && y(e, i);
29
31
  return {
30
32
  date: e,
31
- disabled: c || f,
33
+ disabled: c || a,
32
34
  event: s[e.getTime()],
33
- selected: a && h(e, a),
35
+ selected: f && h(e, f),
34
36
  muted: !A(e, t)
35
37
  };
36
38
  }
@@ -38,15 +40,15 @@ function U(e, t) {
38
40
  const { minMonth: n, maxMonth: r } = t;
39
41
  return {
40
42
  date: e,
41
- disabled: n && M(e, n) || r && b(e, r)
43
+ disabled: n && w(e, n) || r && y(e, r)
42
44
  };
43
45
  }
44
- function W(e, t, n) {
46
+ function b(e, t, n) {
45
47
  let r = e;
46
- return t && (r = d([t, r])), n && (r = D([n, r])), new Date(r);
48
+ return t && (r = d([t, r])), n && (r = m([n, r])), new Date(r);
47
49
  }
48
50
  function C(e, t, n) {
49
- return e && W(e, t, n).getTime() === new Date(e).getTime();
51
+ return e && b(e, t, n).getTime() === new Date(e).getTime();
50
52
  }
51
53
  function G(e, t, n) {
52
54
  return new Intl.DateTimeFormat(t, { month: n ? "short" : "long" }).format(
@@ -54,31 +56,31 @@ function G(e, t, n) {
54
56
  );
55
57
  }
56
58
  function J(e) {
57
- return e.reduce((t, n) => (t[k(n).getTime()] = !0, t), {});
59
+ return e.reduce((t, n) => (t[O(n).getTime()] = !0, t), {});
58
60
  }
59
61
  function P(e, t, n) {
60
62
  const r = t || n;
61
63
  return e && r && e !== r ? {
62
- start: D([e, r]),
64
+ start: m([e, r]),
63
65
  end: d([e, r])
64
66
  } : null;
65
67
  }
66
68
  function Q(e, t, n, r, i = {}) {
67
69
  let s = {
68
- prev: () => O(t, 1),
69
- prevWeek: () => O(t, 7),
70
+ prev: () => k(t, 1),
71
+ prevWeek: () => k(t, 7),
70
72
  prevMonth: () => R(t, 1),
71
73
  next: () => l(t, 1),
72
74
  nextWeek: () => l(t, 7),
73
75
  nextMonth: () => _(t, 1),
74
76
  startOfWeek: () => Y(t, { weekStartsOn: 1 }),
75
- endOfWeek: () => k(N(t, { weekStartsOn: 1 }))
77
+ endOfWeek: () => O(N(t, { weekStartsOn: 1 }))
76
78
  }[e]();
77
79
  for (; i[s.getTime()]; ) {
78
80
  let o = s < t ? -1 : 1;
79
81
  e === "endOfWeek" && (o = -1), e === "startOfWeek" && (o = 1), s = l(s, o);
80
82
  }
81
- return W(s, n, r);
83
+ return b(s, n, r);
82
84
  }
83
85
  function V(e) {
84
86
  if (window.KeyboardEvent) {
@@ -90,13 +92,13 @@ function V(e) {
90
92
  }
91
93
  }
92
94
  function Z(e, t) {
93
- const n = g(!1);
94
- y(() => {
95
+ const n = W(!1);
96
+ g(() => {
95
97
  n.current ? e() : n.current = !0;
96
98
  }, t);
97
99
  }
98
100
  export {
99
- w as DAYS_IN_WEEK,
101
+ M as DAYS_IN_WEEK,
100
102
  X as MONTHS_IN_YEAR,
101
103
  K as SUNDAY_INDEX,
102
104
  H as buildDay,
@@ -107,7 +109,7 @@ export {
107
109
  j as generateWeeks,
108
110
  z as generateYears,
109
111
  P as getSelectionRange,
110
- W as limitDate,
112
+ b as limitDate,
111
113
  Q as modifyDateByShift,
112
114
  G as monthName,
113
115
  B as russianWeekDay,
@@ -3,7 +3,7 @@ function m(t) {
3
3
  const e = new Date(t);
4
4
  return new Date(e.getFullYear(), e.getMonth(), 1, 0, 0, 0, 0);
5
5
  }
6
- function D(t) {
6
+ function l(t) {
7
7
  const e = new Date(t);
8
8
  return new Date(e.getFullYear(), 0, 1, 0, 0, 0, 0);
9
9
  }
@@ -15,7 +15,7 @@ function O(t) {
15
15
  const e = new Date(t);
16
16
  return new Date(e.getFullYear(), e.getMonth() + 1, 0, 0, 0, 0, 0);
17
17
  }
18
- function l(t) {
18
+ function D(t) {
19
19
  const e = new Date(t);
20
20
  return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 0, 0, 0, 0);
21
21
  }
@@ -76,10 +76,13 @@ function q(t, e) {
76
76
  return i(t, -7 * e);
77
77
  }
78
78
  function G(t) {
79
- const e = l(t.start).getTime(), n = l(t.end).getTime(), [r, a] = e <= n ? [e, n] : [n, e], o = [];
80
- for (let s = r; s <= a; s += 864e5)
81
- o.push(new Date(s));
82
- return o;
79
+ let e = D(t.start);
80
+ const n = D(t.end);
81
+ if (e > n) return [];
82
+ const r = [];
83
+ for (; e <= n; )
84
+ r.push(new Date(e)), e = i(e, 1);
85
+ return r;
83
86
  }
84
87
  function R(t) {
85
88
  let e = m(t.start);
@@ -91,7 +94,7 @@ function R(t) {
91
94
  return r;
92
95
  }
93
96
  function $(t) {
94
- const e = D(t.start).getFullYear(), n = D(t.end).getFullYear(), r = Math.min(e, n), a = Math.max(e, n), o = [];
97
+ const e = l(t.start).getFullYear(), n = l(t.end).getFullYear(), r = Math.min(e, n), a = Math.max(e, n), o = [];
95
98
  for (let s = r; s <= a; s += 1)
96
99
  o.push(new Date(s, 0, 1));
97
100
  return o;
@@ -227,11 +230,11 @@ export {
227
230
  J as min,
228
231
  H as parse,
229
232
  v as parseISO,
230
- l as startOfDay,
233
+ D as startOfDay,
231
234
  p as startOfISOWeek,
232
235
  m as startOfMonth,
233
236
  N as startOfWeek,
234
- D as startOfYear,
237
+ l as startOfYear,
235
238
  A as subDays,
236
239
  B as subMonths,
237
240
  q as subWeeks,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphakits/ui",
3
- "version": "2.5.16",
3
+ "version": "2.5.17",
4
4
  "files": [
5
5
  "dist"
6
6
  ],