@alphakits/ui 2.0.0 → 2.0.1
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.
- package/dist/calendar/component.js +1 -1
- package/dist/calendar/component.js.map +1 -1
- package/dist/calendar/components/days-table/component.d.ts +1 -1
- package/dist/calendar/components/days-table/component.js +40 -44
- package/dist/calendar/components/days-table/component.js.map +1 -1
- package/dist/calendar/components/months-table//321/201omponent.d.ts +1 -1
- package/dist/calendar/components/months-table//321/201omponent.js +1 -1
- package/dist/calendar/components/months-table//321/201omponent.js.map +1 -1
- package/dist/calendar/components/years-table//321/201omponent.js +1 -1
- package/dist/calendar/components/years-table//321/201omponent.js.map +1 -1
- package/dist/calendar/use-calendar.js +1 -1
- package/dist/calendar/use-calendar.js.map +1 -1
- package/dist/calendar/utils.d.ts +2 -2
- package/dist/calendar/utils.js +54 -54
- package/dist/calendar/utils.js.map +1 -1
- package/dist/calendar-input/component.js +2 -3
- package/dist/calendar-input/component.js.map +1 -1
- package/dist/calendar-input/utils.js +5 -5
- package/dist/calendar-input/utils.js.map +1 -1
- package/dist/date-switcher/component.js +1 -1
- package/dist/date-switcher/component.js.map +1 -1
- package/dist/form/component.js +79 -92
- package/dist/form/component.js.map +1 -1
- package/dist/formik/index.d.ts +5 -0
- package/dist/formik/index.js +15 -0
- package/dist/formik/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +321 -270
- package/dist/index.js.map +1 -1
- package/dist/utils/date/index.d.ts +73 -0
- package/dist/utils/date/index.js +224 -0
- package/dist/utils/date/index.js.map +1 -0
- package/dist/utils/format-date/index.d.ts +16 -16
- package/dist/utils/format-date/index.js +36 -42
- package/dist/utils/format-date/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +51 -12
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** Small date helpers (local timezone), replacing date-fns for bundle size. */
|
|
2
|
+
export declare function startOfMonth(d: Date): Date;
|
|
3
|
+
export declare function startOfYear(d: Date): Date;
|
|
4
|
+
export declare function endOfYear(d: Date): Date;
|
|
5
|
+
export declare function lastDayOfMonth(d: Date): Date;
|
|
6
|
+
export declare function startOfDay(d: Date | number): Date;
|
|
7
|
+
export declare function endOfDay(d: Date | number): Date;
|
|
8
|
+
/** Monday 00:00 of the ISO week containing `d`. */
|
|
9
|
+
export declare function startOfISOWeek(d: Date): Date;
|
|
10
|
+
export declare function endOfISOWeek(d: Date): Date;
|
|
11
|
+
export declare function startOfWeek(d: Date, options?: {
|
|
12
|
+
weekStartsOn?: number;
|
|
13
|
+
}): Date;
|
|
14
|
+
export declare function endOfWeek(d: Date, options?: {
|
|
15
|
+
weekStartsOn?: number;
|
|
16
|
+
}): Date;
|
|
17
|
+
export declare function addDays(d: Date, amount: number): Date;
|
|
18
|
+
export declare function subDays(d: Date, amount: number): Date;
|
|
19
|
+
export declare function addMonths(d: Date, amount: number): Date;
|
|
20
|
+
export declare function subMonths(d: Date, amount: number): Date;
|
|
21
|
+
export declare function addYears(d: Date, amount: number): Date;
|
|
22
|
+
export declare function subYears(d: Date, amount: number): Date;
|
|
23
|
+
export declare function add(d: Date, duration: {
|
|
24
|
+
years?: number;
|
|
25
|
+
months?: number;
|
|
26
|
+
weeks?: number;
|
|
27
|
+
days?: number;
|
|
28
|
+
}): Date;
|
|
29
|
+
export declare function subWeeks(d: Date, amount: number): Date;
|
|
30
|
+
export declare function eachDayOfInterval(interval: {
|
|
31
|
+
start: Date;
|
|
32
|
+
end: Date;
|
|
33
|
+
}): Date[];
|
|
34
|
+
export declare function eachMonthOfInterval(interval: {
|
|
35
|
+
start: Date;
|
|
36
|
+
end: Date;
|
|
37
|
+
}): Date[];
|
|
38
|
+
export declare function eachYearOfInterval(interval: {
|
|
39
|
+
start: Date;
|
|
40
|
+
end: Date;
|
|
41
|
+
}): Date[];
|
|
42
|
+
export declare function isSameDay(a: Date, b: Date): boolean;
|
|
43
|
+
export declare function isSameMonth(a: Date, b: Date): boolean;
|
|
44
|
+
export declare function isSameYear(a: Date, b: Date): boolean;
|
|
45
|
+
export declare function isBefore(a: Date, b: Date): boolean;
|
|
46
|
+
export declare function isAfter(a: Date, b: Date): boolean;
|
|
47
|
+
export declare function max(dates: Array<Date | number>): Date;
|
|
48
|
+
export declare function min(dates: Array<Date | number>): Date;
|
|
49
|
+
export declare function isEqual(a: Date | number, b: Date | number): boolean;
|
|
50
|
+
export declare function isLastDayOfMonth(d: Date): boolean;
|
|
51
|
+
export declare function isWithinInterval(date: Date, interval: {
|
|
52
|
+
start: Date;
|
|
53
|
+
end: Date;
|
|
54
|
+
}): boolean;
|
|
55
|
+
export declare function isToday(d: Date): boolean;
|
|
56
|
+
export declare function isThisMonth(d: Date): boolean;
|
|
57
|
+
export declare function isThisYear(d: Date): boolean;
|
|
58
|
+
export declare function parseISO(s: string): Date;
|
|
59
|
+
/** Monday-first short weekday labels (aligned with previous date-fns `localize.day` order). */
|
|
60
|
+
export declare function weekDaysShort(localeTag: string): string[];
|
|
61
|
+
declare type FormatOptions = {
|
|
62
|
+
locale?: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Subset of date-fns `format` tokens: yyyy, yy, MM, dd, HH, mm, MMM, MMMM.
|
|
66
|
+
* Longer tokens first so `MMMM` is not broken by `MM`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function format(d: Date, pattern: string, options?: FormatOptions): string;
|
|
69
|
+
/**
|
|
70
|
+
* Parse fixed-width patterns used in the UI (local date).
|
|
71
|
+
*/
|
|
72
|
+
export declare function parse(value: string, pattern: string, _referenceDate?: Date): Date;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
const i = (t) => String(t).padStart(2, "0");
|
|
2
|
+
function l(t) {
|
|
3
|
+
return new Date(t.getFullYear(), t.getMonth(), 1, 0, 0, 0, 0);
|
|
4
|
+
}
|
|
5
|
+
function D(t) {
|
|
6
|
+
return new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0);
|
|
7
|
+
}
|
|
8
|
+
function W(t) {
|
|
9
|
+
return new Date(t.getFullYear(), 11, 31, 23, 59, 59, 999);
|
|
10
|
+
}
|
|
11
|
+
function O(t) {
|
|
12
|
+
return new Date(t.getFullYear(), t.getMonth() + 1, 0, 0, 0, 0, 0);
|
|
13
|
+
}
|
|
14
|
+
function y(t) {
|
|
15
|
+
const e = new Date(t);
|
|
16
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 0, 0, 0, 0);
|
|
17
|
+
}
|
|
18
|
+
function h(t) {
|
|
19
|
+
const e = new Date(t);
|
|
20
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 23, 59, 59, 999);
|
|
21
|
+
}
|
|
22
|
+
function N(t) {
|
|
23
|
+
const e = new Date(t.getFullYear(), t.getMonth(), t.getDate()), n = e.getDay(), r = n === 0 ? -6 : 1 - n;
|
|
24
|
+
return e.setDate(e.getDate() + r), new Date(e.getFullYear(), e.getMonth(), e.getDate(), 0, 0, 0, 0);
|
|
25
|
+
}
|
|
26
|
+
function A(t) {
|
|
27
|
+
return h(c(N(t), 6));
|
|
28
|
+
}
|
|
29
|
+
function b(t, e) {
|
|
30
|
+
var u;
|
|
31
|
+
const n = (u = e == null ? void 0 : e.weekStartsOn) != null ? u : 0, r = new Date(t.getFullYear(), t.getMonth(), t.getDate()), o = (r.getDay() - n + 7) % 7;
|
|
32
|
+
return r.setDate(r.getDate() - o), new Date(r.getFullYear(), r.getMonth(), r.getDate(), 0, 0, 0, 0);
|
|
33
|
+
}
|
|
34
|
+
function B(t, e) {
|
|
35
|
+
return h(c(b(t, e), 6));
|
|
36
|
+
}
|
|
37
|
+
function c(t, e) {
|
|
38
|
+
const n = new Date(t);
|
|
39
|
+
return n.setDate(n.getDate() + e), n;
|
|
40
|
+
}
|
|
41
|
+
function E(t, e) {
|
|
42
|
+
return c(t, -e);
|
|
43
|
+
}
|
|
44
|
+
function k(t, e) {
|
|
45
|
+
return new Date(t, e + 1, 0).getDate();
|
|
46
|
+
}
|
|
47
|
+
function f(t, e) {
|
|
48
|
+
const n = t.getDate(), r = t.getFullYear(), a = t.getMonth() + e, o = Math.min(n, k(r, a));
|
|
49
|
+
return new Date(r, a, o, t.getHours(), t.getMinutes(), t.getSeconds(), t.getMilliseconds());
|
|
50
|
+
}
|
|
51
|
+
function P(t, e) {
|
|
52
|
+
return f(t, -e);
|
|
53
|
+
}
|
|
54
|
+
function w(t, e) {
|
|
55
|
+
return f(t, e * 12);
|
|
56
|
+
}
|
|
57
|
+
function _(t, e) {
|
|
58
|
+
return w(t, -e);
|
|
59
|
+
}
|
|
60
|
+
function q(t, e) {
|
|
61
|
+
let n = t;
|
|
62
|
+
return e.years && (n = w(n, e.years)), e.months && (n = f(n, e.months)), e.weeks && (n = c(n, 7 * e.weeks)), e.days && (n = c(n, e.days)), n;
|
|
63
|
+
}
|
|
64
|
+
function G(t, e) {
|
|
65
|
+
return c(t, -7 * e);
|
|
66
|
+
}
|
|
67
|
+
function L(t) {
|
|
68
|
+
const e = y(t.start).getTime(), n = y(t.end).getTime(), [r, a] = e <= n ? [e, n] : [n, e], o = [];
|
|
69
|
+
for (let u = r; u <= a; u += 864e5)
|
|
70
|
+
o.push(new Date(u));
|
|
71
|
+
return o;
|
|
72
|
+
}
|
|
73
|
+
function R(t) {
|
|
74
|
+
let e = l(t.start);
|
|
75
|
+
const n = l(t.end);
|
|
76
|
+
if (e > n) return [];
|
|
77
|
+
const r = [];
|
|
78
|
+
for (; e <= n; )
|
|
79
|
+
r.push(new Date(e)), e = f(e, 1);
|
|
80
|
+
return r;
|
|
81
|
+
}
|
|
82
|
+
function $(t) {
|
|
83
|
+
const e = D(t.start).getFullYear(), n = D(t.end).getFullYear(), r = Math.min(e, n), a = Math.max(e, n), o = [];
|
|
84
|
+
for (let u = r; u <= a; u += 1)
|
|
85
|
+
o.push(new Date(u, 0, 1));
|
|
86
|
+
return o;
|
|
87
|
+
}
|
|
88
|
+
function S(t, e) {
|
|
89
|
+
return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate();
|
|
90
|
+
}
|
|
91
|
+
function H(t, e) {
|
|
92
|
+
return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth();
|
|
93
|
+
}
|
|
94
|
+
function x(t, e) {
|
|
95
|
+
return t.getFullYear() === e.getFullYear();
|
|
96
|
+
}
|
|
97
|
+
function j(t, e) {
|
|
98
|
+
return t.getTime() < e.getTime();
|
|
99
|
+
}
|
|
100
|
+
function z(t, e) {
|
|
101
|
+
return t.getTime() > e.getTime();
|
|
102
|
+
}
|
|
103
|
+
function C(t) {
|
|
104
|
+
return new Date(Math.max(...t.map((e) => new Date(e).getTime())));
|
|
105
|
+
}
|
|
106
|
+
function J(t) {
|
|
107
|
+
return new Date(Math.min(...t.map((e) => new Date(e).getTime())));
|
|
108
|
+
}
|
|
109
|
+
function K(t, e) {
|
|
110
|
+
return new Date(t).getTime() === new Date(e).getTime();
|
|
111
|
+
}
|
|
112
|
+
function Q(t) {
|
|
113
|
+
return t.getDate() === O(t).getDate();
|
|
114
|
+
}
|
|
115
|
+
function U(t, e) {
|
|
116
|
+
const n = t.getTime();
|
|
117
|
+
return n >= e.start.getTime() && n <= e.end.getTime();
|
|
118
|
+
}
|
|
119
|
+
function V(t) {
|
|
120
|
+
return S(t, /* @__PURE__ */ new Date());
|
|
121
|
+
}
|
|
122
|
+
function X(t) {
|
|
123
|
+
return H(t, /* @__PURE__ */ new Date());
|
|
124
|
+
}
|
|
125
|
+
function Z(t) {
|
|
126
|
+
return x(t, /* @__PURE__ */ new Date());
|
|
127
|
+
}
|
|
128
|
+
function v(t) {
|
|
129
|
+
return new Date(t);
|
|
130
|
+
}
|
|
131
|
+
function tt(t) {
|
|
132
|
+
const e = new Date(2021, 5, 7, 12, 0, 0, 0);
|
|
133
|
+
return Array.from(
|
|
134
|
+
{ length: 7 },
|
|
135
|
+
(n, r) => new Intl.DateTimeFormat(t, { weekday: "short" }).format(c(e, r))
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function M(t, e, n) {
|
|
139
|
+
return new Intl.DateTimeFormat(e, { month: n }).format(t);
|
|
140
|
+
}
|
|
141
|
+
function et(t, e, n) {
|
|
142
|
+
var m;
|
|
143
|
+
const r = (m = n == null ? void 0 : n.locale) != null ? m : "en-GB", a = t.getFullYear(), o = t.getMonth(), u = t.getDate(), s = t.getHours(), Y = t.getMinutes(), d = [
|
|
144
|
+
[/yyyy/g, () => String(a)],
|
|
145
|
+
[/MMMM/g, () => M(t, r, "long")],
|
|
146
|
+
[/MMM/g, () => M(t, r, "short")],
|
|
147
|
+
[/MM/g, () => i(o + 1)],
|
|
148
|
+
[/dd/g, () => i(u)],
|
|
149
|
+
[/HH/g, () => i(s)],
|
|
150
|
+
[/mm/g, () => i(Y)],
|
|
151
|
+
[/yy/g, () => i(a % 100)]
|
|
152
|
+
];
|
|
153
|
+
let g = e;
|
|
154
|
+
return d.forEach(([F, T]) => {
|
|
155
|
+
g = g.replace(F, T);
|
|
156
|
+
}), g;
|
|
157
|
+
}
|
|
158
|
+
function I(t, e) {
|
|
159
|
+
if (!e) return;
|
|
160
|
+
const [n, r] = e.split(":").map((a) => Number(a));
|
|
161
|
+
t.setHours(Number.isFinite(n) ? n : 0, Number.isFinite(r) ? r : 0, 0, 0);
|
|
162
|
+
}
|
|
163
|
+
function p(t, e, n) {
|
|
164
|
+
if (e === "yyyy-MM-dd HH:mm" || e === "dd.MM.yyyy HH:mm") {
|
|
165
|
+
const [a, o] = t.trim().split(/\s+/), u = e.replace(/\s+HH:mm$/, ""), s = p(a, u);
|
|
166
|
+
return I(s, o), s;
|
|
167
|
+
}
|
|
168
|
+
if (e === "yyyy-MM-dd") {
|
|
169
|
+
const [a, o, u] = t.split("-");
|
|
170
|
+
return new Date(Number(a), Number(o) - 1, Number(u), 0, 0, 0, 0);
|
|
171
|
+
}
|
|
172
|
+
if (e === "dd.MM.yyyy") {
|
|
173
|
+
const [a, o, u] = t.split(".");
|
|
174
|
+
return new Date(Number(u), Number(o) - 1, Number(a), 0, 0, 0, 0);
|
|
175
|
+
}
|
|
176
|
+
if (e === "dd.MM.yy") {
|
|
177
|
+
const [a, o, u] = t.split(".");
|
|
178
|
+
let s = Number(u);
|
|
179
|
+
return s < 100 && (s += s >= 70 ? 1900 : 2e3), new Date(s, Number(o) - 1, Number(a), 0, 0, 0, 0);
|
|
180
|
+
}
|
|
181
|
+
const r = new Date(t);
|
|
182
|
+
return Number.isNaN(r.getTime()) ? /* @__PURE__ */ new Date(NaN) : r;
|
|
183
|
+
}
|
|
184
|
+
export {
|
|
185
|
+
q as add,
|
|
186
|
+
c as addDays,
|
|
187
|
+
f as addMonths,
|
|
188
|
+
w as addYears,
|
|
189
|
+
L as eachDayOfInterval,
|
|
190
|
+
R as eachMonthOfInterval,
|
|
191
|
+
$ as eachYearOfInterval,
|
|
192
|
+
h as endOfDay,
|
|
193
|
+
A as endOfISOWeek,
|
|
194
|
+
B as endOfWeek,
|
|
195
|
+
W as endOfYear,
|
|
196
|
+
et as format,
|
|
197
|
+
z as isAfter,
|
|
198
|
+
j as isBefore,
|
|
199
|
+
K as isEqual,
|
|
200
|
+
Q as isLastDayOfMonth,
|
|
201
|
+
S as isSameDay,
|
|
202
|
+
H as isSameMonth,
|
|
203
|
+
x as isSameYear,
|
|
204
|
+
X as isThisMonth,
|
|
205
|
+
Z as isThisYear,
|
|
206
|
+
V as isToday,
|
|
207
|
+
U as isWithinInterval,
|
|
208
|
+
O as lastDayOfMonth,
|
|
209
|
+
C as max,
|
|
210
|
+
J as min,
|
|
211
|
+
p as parse,
|
|
212
|
+
v as parseISO,
|
|
213
|
+
y as startOfDay,
|
|
214
|
+
N as startOfISOWeek,
|
|
215
|
+
l as startOfMonth,
|
|
216
|
+
b as startOfWeek,
|
|
217
|
+
D as startOfYear,
|
|
218
|
+
E as subDays,
|
|
219
|
+
P as subMonths,
|
|
220
|
+
G as subWeeks,
|
|
221
|
+
_ as subYears,
|
|
222
|
+
tt as weekDaysShort
|
|
223
|
+
};
|
|
224
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/date/index.ts"],"sourcesContent":["/** Small date helpers (local timezone), replacing date-fns for bundle size. */\n\nconst pad2 = (n: number) => String(n).padStart(2, '0');\n\nexport function startOfMonth(d: Date): Date {\n return new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0);\n}\n\nexport function startOfYear(d: Date): Date {\n return new Date(d.getFullYear(), 0, 1, 0, 0, 0, 0);\n}\n\nexport function endOfYear(d: Date): Date {\n return new Date(d.getFullYear(), 11, 31, 23, 59, 59, 999);\n}\n\nexport function lastDayOfMonth(d: Date): Date {\n return new Date(d.getFullYear(), d.getMonth() + 1, 0, 0, 0, 0, 0);\n}\n\nexport function startOfDay(d: Date | number): Date {\n const x = new Date(d);\n\n return new Date(x.getFullYear(), x.getMonth(), x.getDate(), 0, 0, 0, 0);\n}\n\nexport function endOfDay(d: Date | number): Date {\n const x = new Date(d);\n\n return new Date(x.getFullYear(), x.getMonth(), x.getDate(), 23, 59, 59, 999);\n}\n\n/** Monday 00:00 of the ISO week containing `d`. */\nexport function startOfISOWeek(d: Date): Date {\n const x = new Date(d.getFullYear(), d.getMonth(), d.getDate());\n const day = x.getDay();\n const diffToMonday = day === 0 ? -6 : 1 - day;\n\n x.setDate(x.getDate() + diffToMonday);\n\n return new Date(x.getFullYear(), x.getMonth(), x.getDate(), 0, 0, 0, 0);\n}\n\nexport function endOfISOWeek(d: Date): Date {\n return endOfDay(addDays(startOfISOWeek(d), 6));\n}\n\nexport function startOfWeek(d: Date, options?: { weekStartsOn?: number }): Date {\n const weekStartsOn = options?.weekStartsOn ?? 0;\n const x = new Date(d.getFullYear(), d.getMonth(), d.getDate());\n const day = x.getDay();\n const diff = (day - weekStartsOn + 7) % 7;\n\n x.setDate(x.getDate() - diff);\n\n return new Date(x.getFullYear(), x.getMonth(), x.getDate(), 0, 0, 0, 0);\n}\n\nexport function endOfWeek(d: Date, options?: { weekStartsOn?: number }): Date {\n return endOfDay(addDays(startOfWeek(d, options), 6));\n}\n\nexport function addDays(d: Date, amount: number): Date {\n const x = new Date(d);\n\n x.setDate(x.getDate() + amount);\n\n return x;\n}\n\nexport function subDays(d: Date, amount: number): Date {\n return addDays(d, -amount);\n}\n\nfunction daysInMonth(year: number, month0: number): number {\n return new Date(year, month0 + 1, 0).getDate();\n}\n\nexport function addMonths(d: Date, amount: number): Date {\n const day = d.getDate();\n const y = d.getFullYear();\n const m = d.getMonth() + amount;\n const safeDay = Math.min(day, daysInMonth(y, m));\n\n return new Date(y, m, safeDay, d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());\n}\n\nexport function subMonths(d: Date, amount: number): Date {\n return addMonths(d, -amount);\n}\n\nexport function addYears(d: Date, amount: number): Date {\n return addMonths(d, amount * 12);\n}\n\nexport function subYears(d: Date, amount: number): Date {\n return addYears(d, -amount);\n}\n\nexport function add(\n d: Date,\n duration: { years?: number; months?: number; weeks?: number; days?: number },\n): Date {\n let x = d;\n\n if (duration.years) x = addYears(x, duration.years);\n if (duration.months) x = addMonths(x, duration.months);\n if (duration.weeks) x = addDays(x, 7 * duration.weeks);\n if (duration.days) x = addDays(x, duration.days);\n\n return x;\n}\n\nexport function subWeeks(d: Date, amount: number): Date {\n return addDays(d, -7 * amount);\n}\n\nexport function eachDayOfInterval(interval: { start: Date; end: Date }): Date[] {\n const a = startOfDay(interval.start).getTime();\n const b = startOfDay(interval.end).getTime();\n const [from, to] = a <= b ? [a, b] : [b, a];\n const out: Date[] = [];\n\n for (let t = from; t <= to; t += 86400000) {\n out.push(new Date(t));\n }\n\n return out;\n}\n\nexport function eachMonthOfInterval(interval: { start: Date; end: Date }): Date[] {\n let cur = startOfMonth(interval.start);\n const last = startOfMonth(interval.end);\n\n if (cur > last) return [];\n\n const out: Date[] = [];\n\n while (cur <= last) {\n out.push(new Date(cur));\n cur = addMonths(cur, 1);\n }\n\n return out;\n}\n\nexport function eachYearOfInterval(interval: { start: Date; end: Date }): Date[] {\n const y1 = startOfYear(interval.start).getFullYear();\n const y2 = startOfYear(interval.end).getFullYear();\n const fromY = Math.min(y1, y2);\n const toY = Math.max(y1, y2);\n const out: Date[] = [];\n\n for (let yy = fromY; yy <= toY; yy += 1) {\n out.push(new Date(yy, 0, 1));\n }\n\n return out;\n}\n\nexport function isSameDay(a: Date, b: Date): boolean {\n return (\n a.getFullYear() === b.getFullYear()\n && a.getMonth() === b.getMonth()\n && a.getDate() === b.getDate()\n );\n}\n\nexport function isSameMonth(a: Date, b: Date): boolean {\n return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();\n}\n\nexport function isSameYear(a: Date, b: Date): boolean {\n return a.getFullYear() === b.getFullYear();\n}\n\nexport function isBefore(a: Date, b: Date): boolean {\n return a.getTime() < b.getTime();\n}\n\nexport function isAfter(a: Date, b: Date): boolean {\n return a.getTime() > b.getTime();\n}\n\nexport function max(dates: Array<Date | number>): Date {\n return new Date(Math.max(...dates.map((d) => new Date(d).getTime())));\n}\n\nexport function min(dates: Array<Date | number>): Date {\n return new Date(Math.min(...dates.map((d) => new Date(d).getTime())));\n}\n\nexport function isEqual(a: Date | number, b: Date | number): boolean {\n return new Date(a).getTime() === new Date(b).getTime();\n}\n\nexport function isLastDayOfMonth(d: Date): boolean {\n return d.getDate() === lastDayOfMonth(d).getDate();\n}\n\nexport function isWithinInterval(date: Date, interval: { start: Date; end: Date }): boolean {\n const t = date.getTime();\n\n return t >= interval.start.getTime() && t <= interval.end.getTime();\n}\n\nexport function isToday(d: Date): boolean {\n return isSameDay(d, new Date());\n}\n\nexport function isThisMonth(d: Date): boolean {\n return isSameMonth(d, new Date());\n}\n\nexport function isThisYear(d: Date): boolean {\n return isSameYear(d, new Date());\n}\n\nexport function parseISO(s: string): Date {\n return new Date(s);\n}\n\n/** Monday-first short weekday labels (aligned with previous date-fns `localize.day` order). */\nexport function weekDaysShort(localeTag: string): string[] {\n const refMonday = new Date(2021, 5, 7, 12, 0, 0, 0);\n\n return Array.from({ length: 7 }, (_, i) =>\n new Intl.DateTimeFormat(localeTag, { weekday: 'short' }).format(addDays(refMonday, i)),\n );\n}\n\ntype FormatOptions = { locale?: string };\n\nfunction intlMonth(d: Date, locale: string, style: 'long' | 'short'): string {\n return new Intl.DateTimeFormat(locale, { month: style }).format(d);\n}\n\n/**\n * Subset of date-fns `format` tokens: yyyy, yy, MM, dd, HH, mm, MMM, MMMM.\n * Longer tokens first so `MMMM` is not broken by `MM`.\n */\nexport function format(d: Date, pattern: string, options?: FormatOptions): string {\n const locale = options?.locale ?? 'en-GB';\n const y = d.getFullYear();\n const m = d.getMonth();\n const day = d.getDate();\n const h = d.getHours();\n const minu = d.getMinutes();\n\n const tokenReplacements: Array<[RegExp, () => string]> = [\n [/yyyy/g, () => String(y)],\n [/MMMM/g, () => intlMonth(d, locale, 'long')],\n [/MMM/g, () => intlMonth(d, locale, 'short')],\n [/MM/g, () => pad2(m + 1)],\n [/dd/g, () => pad2(day)],\n [/HH/g, () => pad2(h)],\n [/mm/g, () => pad2(minu)],\n [/yy/g, () => pad2(y % 100)],\n ];\n\n let out = pattern;\n\n tokenReplacements.forEach(([re, fn]) => {\n out = out.replace(re, fn);\n });\n\n return out;\n}\n\nfunction applyTime(d: Date, timePart: string | undefined): void {\n if (!timePart) return;\n const [hh, mm] = timePart.split(':').map((x) => Number(x));\n\n d.setHours(Number.isFinite(hh) ? hh : 0, Number.isFinite(mm) ? mm : 0, 0, 0);\n}\n\n/**\n * Parse fixed-width patterns used in the UI (local date).\n */\nexport function parse(value: string, pattern: string, _referenceDate?: Date): Date {\n if (pattern === 'yyyy-MM-dd HH:mm' || pattern === 'dd.MM.yyyy HH:mm') {\n const [datePart, timePart] = value.trim().split(/\\s+/);\n const dateOnlyPattern = pattern.replace(/\\s+HH:mm$/, '') as 'yyyy-MM-dd' | 'dd.MM.yyyy';\n const d = parse(datePart, dateOnlyPattern, _referenceDate);\n\n applyTime(d, timePart);\n\n return d;\n }\n\n if (pattern === 'yyyy-MM-dd') {\n const [ys, ms, ds] = value.split('-');\n\n return new Date(Number(ys), Number(ms) - 1, Number(ds), 0, 0, 0, 0);\n }\n\n if (pattern === 'dd.MM.yyyy') {\n const [ds, ms, ys] = value.split('.');\n\n return new Date(Number(ys), Number(ms) - 1, Number(ds), 0, 0, 0, 0);\n }\n\n if (pattern === 'dd.MM.yy') {\n const [ds, ms, ys] = value.split('.');\n let year = Number(ys);\n\n if (year < 100) {\n year += year >= 70 ? 1900 : 2000;\n }\n\n return new Date(year, Number(ms) - 1, Number(ds), 0, 0, 0, 0);\n }\n\n const fallback = new Date(value);\n\n if (!Number.isNaN(fallback.getTime())) return fallback;\n\n return new Date(NaN);\n}\n"],"names":["pad2","n","startOfMonth","d","startOfYear","endOfYear","lastDayOfMonth","startOfDay","x","endOfDay","startOfISOWeek","day","diffToMonday","endOfISOWeek","addDays","startOfWeek","options","_a","weekStartsOn","diff","endOfWeek","amount","subDays","daysInMonth","year","month0","addMonths","y","m","safeDay","subMonths","addYears","subYears","add","duration","subWeeks","eachDayOfInterval","interval","a","b","from","to","out","t","eachMonthOfInterval","cur","last","eachYearOfInterval","y1","y2","fromY","toY","yy","isSameDay","isSameMonth","isSameYear","isBefore","isAfter","max","dates","min","isEqual","isLastDayOfMonth","isWithinInterval","date","isToday","isThisMonth","isThisYear","parseISO","s","weekDaysShort","localeTag","refMonday","_","i","intlMonth","locale","style","format","pattern","h","minu","tokenReplacements","re","fn","applyTime","timePart","hh","mm","parse","value","_referenceDate","datePart","dateOnlyPattern","ys","ms","ds","fallback"],"mappings":"AAEA,MAAMA,IAAO,CAACC,MAAc,OAAOA,CAAC,EAAE,SAAS,GAAG,GAAG;AAE9C,SAASC,EAAaC,GAAe;AACxC,SAAO,IAAI,KAAKA,EAAE,YAAA,GAAeA,EAAE,SA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lF,GAAGmF,CAAQ,GAEdnF;AAAA,EACX;AAEA,MAAI4E,MAAY,cAAc;AAC1B,UAAM,CAACe,GAAIC,GAAIC,CAAE,IAAIN,EAAM,MAAM,GAAG;AAEpC,WAAO,IAAI,KAAK,OAAOI,CAAE,GAAG,OAAOC,CAAE,IAAI,GAAG,OAAOC,CAAE,GAAG,GAAG,GAAG,GAAG,CAAC;AAAA,EACtE;AAEA,MAAIjB,MAAY,cAAc;AAC1B,UAAM,CAACiB,GAAID,GAAID,CAAE,IAAIJ,EAAM,MAAM,GAAG;AAEpC,WAAO,IAAI,KAAK,OAAOI,CAAE,GAAG,OAAOC,CAAE,IAAI,GAAG,OAAOC,CAAE,GAAG,GAAG,GAAG,GAAG,CAAC;AAAA,EACtE;AAEA,MAAIjB,MAAY,YAAY;AACxB,UAAM,CAACiB,GAAID,GAAID,CAAE,IAAIJ,EAAM,MAAM,GAAG;AACpC,QAAIlE,IAAO,OAAOsE,CAAE;AAEpB,WAAItE,IAAO,QACPA,KAAQA,KAAQ,KAAK,OAAO,MAGzB,IAAI,KAAKA,GAAM,OAAOuE,CAAE,IAAI,GAAG,OAAOC,CAAE,GAAG,GAAG,GAAG,GAAG,CAAC;AAAA,EAChE;AAEA,QAAMC,IAAW,IAAI,KAAKP,CAAK;AAE/B,SAAK,OAAO,MAAMO,EAAS,QAAA,CAAS,IAE7B,oBAAI,KAAK,GAAG,IAF2BA;AAGlD;"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
+
export declare const locales: {
|
|
2
|
+
readonly ru: "ru-RU";
|
|
3
|
+
readonly de: "de-DE";
|
|
4
|
+
readonly en: "en-GB";
|
|
5
|
+
readonly pl: "pl-PL";
|
|
6
|
+
readonly et: "et-EE";
|
|
7
|
+
readonly fr: "fr-FR";
|
|
8
|
+
readonly it: "it-IT";
|
|
9
|
+
readonly pt: "pt-PT";
|
|
10
|
+
readonly es: "es-ES";
|
|
11
|
+
readonly el: "el-GR";
|
|
12
|
+
readonly nl: "nl-NL";
|
|
13
|
+
readonly cs: "cs-CZ";
|
|
14
|
+
};
|
|
1
15
|
declare type FormatDateOptions = {
|
|
2
16
|
time?: string;
|
|
3
17
|
format?: string;
|
|
4
|
-
lang?:
|
|
5
|
-
};
|
|
6
|
-
export declare const locales: {
|
|
7
|
-
readonly ru: Locale;
|
|
8
|
-
readonly de: Locale;
|
|
9
|
-
readonly en: Locale;
|
|
10
|
-
readonly pl: Locale;
|
|
11
|
-
readonly et: Locale;
|
|
12
|
-
readonly fr: Locale;
|
|
13
|
-
readonly it: Locale;
|
|
14
|
-
readonly pt: Locale;
|
|
15
|
-
readonly es: Locale;
|
|
16
|
-
readonly el: Locale;
|
|
17
|
-
readonly nl: Locale;
|
|
18
|
-
readonly cs: Locale;
|
|
18
|
+
lang?: string;
|
|
19
19
|
};
|
|
20
|
-
export declare const formatDate: (date: Date | number | string, { time, format, lang }: FormatDateOptions) => string;
|
|
20
|
+
export declare const formatDate: (date: Date | number | string, { time, format: fmt, lang }: FormatDateOptions) => string;
|
|
21
21
|
export {};
|
|
@@ -1,50 +1,44 @@
|
|
|
1
|
-
import { parse as
|
|
2
|
-
import n from "date-fns/esm/locale/cs";
|
|
3
|
-
import c from "date-fns/esm/locale/de";
|
|
4
|
-
import M from "date-fns/esm/locale/en-GB";
|
|
5
|
-
import d from "date-fns/esm/locale/pl";
|
|
6
|
-
import u from "date-fns/esm/locale/ru";
|
|
7
|
-
import a from "date-fns/locale/el";
|
|
8
|
-
import H from "date-fns/locale/es";
|
|
9
|
-
import D from "date-fns/locale/et";
|
|
10
|
-
import $ from "date-fns/locale/fr";
|
|
11
|
-
import b from "date-fns/locale/it";
|
|
12
|
-
import h from "date-fns/locale/nl";
|
|
13
|
-
import w from "date-fns/locale/pt";
|
|
1
|
+
import { parse as y, format as p } from "../date/index.js";
|
|
14
2
|
const i = {
|
|
15
|
-
ru:
|
|
16
|
-
de:
|
|
17
|
-
en:
|
|
18
|
-
pl:
|
|
19
|
-
et:
|
|
20
|
-
fr:
|
|
21
|
-
it:
|
|
22
|
-
pt:
|
|
23
|
-
es:
|
|
24
|
-
el:
|
|
25
|
-
nl:
|
|
26
|
-
cs:
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
3
|
+
ru: "ru-RU",
|
|
4
|
+
de: "de-DE",
|
|
5
|
+
en: "en-GB",
|
|
6
|
+
pl: "pl-PL",
|
|
7
|
+
et: "et-EE",
|
|
8
|
+
fr: "fr-FR",
|
|
9
|
+
it: "it-IT",
|
|
10
|
+
pt: "pt-PT",
|
|
11
|
+
es: "es-ES",
|
|
12
|
+
el: "el-GR",
|
|
13
|
+
nl: "nl-NL",
|
|
14
|
+
cs: "cs-CZ"
|
|
15
|
+
};
|
|
16
|
+
function c(e) {
|
|
17
|
+
var n, s;
|
|
18
|
+
const r = ((n = e == null ? void 0 : e.split("-")) == null ? void 0 : n[0]) || "en";
|
|
19
|
+
return (s = i[r]) != null ? s : i.en;
|
|
20
|
+
}
|
|
21
|
+
const u = (e, { time: r, format: n = "dd MMMM yyyy, HH:mm", lang: s }) => {
|
|
22
|
+
if (e == null || e === "") return "-";
|
|
23
|
+
let t;
|
|
31
24
|
try {
|
|
32
|
-
if (typeof
|
|
33
|
-
|
|
34
|
-
else {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
if (typeof e == "number" || typeof e == "object")
|
|
26
|
+
t = new Date(e);
|
|
27
|
+
else if (typeof e == "string" && (e.includes("Z") || /^\d{4}-\d{2}-\d{2}T/.test(e)))
|
|
28
|
+
t = new Date(e);
|
|
29
|
+
else if (typeof e == "string") {
|
|
30
|
+
let l = e.split("-").length === 3 ? "yyyy-MM-dd" : "dd.MM.yyyy";
|
|
31
|
+
const o = r ? ` ${r.split(":")[0]}:${r.split(":")[1]}` : "";
|
|
32
|
+
o && (l += " HH:mm"), t = y(`${e}${o}`, l, /* @__PURE__ */ new Date());
|
|
33
|
+
} else
|
|
34
|
+
t = /* @__PURE__ */ new Date(NaN);
|
|
35
|
+
return Number.isNaN(t.getTime()) ? `Invalid date ${e}` : p(t, n, { locale: c(s) });
|
|
36
|
+
} catch (f) {
|
|
37
|
+
return `Invalid date ${e}`;
|
|
44
38
|
}
|
|
45
39
|
};
|
|
46
40
|
export {
|
|
47
|
-
|
|
41
|
+
u as formatDate,
|
|
48
42
|
i as locales
|
|
49
43
|
};
|
|
50
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/format-date/index.ts"],"sourcesContent":["import { format as
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/format-date/index.ts"],"sourcesContent":["import { format as formatPattern, parse } from '../date';\n\nexport const locales = {\n ru: 'ru-RU',\n de: 'de-DE',\n en: 'en-GB',\n pl: 'pl-PL',\n et: 'et-EE',\n fr: 'fr-FR',\n it: 'it-IT',\n pt: 'pt-PT',\n es: 'es-ES',\n el: 'el-GR',\n nl: 'nl-NL',\n cs: 'cs-CZ',\n} as const;\n\ntype FormatDateOptions = {\n time?: string;\n\n format?: string;\n\n lang?: string;\n};\n\nfunction resolveLocaleTag(lang?: string): string {\n const key = (lang?.split('-')?.[0] || 'en') as keyof typeof locales;\n\n return locales[key] ?? locales.en;\n}\n\nexport const formatDate = (\n date: Date | number | string,\n { time, format: fmt = 'dd MMMM yyyy, HH:mm', lang }: FormatDateOptions,\n) => {\n if (date == null || date === '') return '-';\n\n let d: Date;\n\n try {\n if (typeof date === 'number' || typeof date === 'object') {\n d = new Date(date as number | Date);\n } else if (typeof date === 'string' && (date.includes('Z') || /^\\d{4}-\\d{2}-\\d{2}T/.test(date))) {\n d = new Date(date);\n } else if (typeof date === 'string') {\n const split = date.split('-');\n let dateFormat = split.length === 3 ? 'yyyy-MM-dd' : 'dd.MM.yyyy';\n const formattedTime = time ? ` ${time.split(':')[0]}:${time.split(':')[1]}` : '';\n\n if (formattedTime) dateFormat += ' HH:mm';\n\n d = parse(`${date}${formattedTime}`, dateFormat, new Date());\n } else {\n d = new Date(NaN);\n }\n\n if (Number.isNaN(d.getTime())) return `Invalid date ${date}`;\n\n return formatPattern(d, fmt, { locale: resolveLocaleTag(lang) });\n } catch {\n return `Invalid date ${date}`;\n }\n};\n"],"names":["locales","resolveLocaleTag","lang","key","_a","_b","formatDate","date","time","fmt","d","dateFormat","formattedTime","parse","formatPattern","e"],"mappings":";AAEO,MAAMA,IAAU;AAAA,EACnB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACR;AAUA,SAASC,EAAiBC,GAAuB;;AAC7C,QAAMC,MAAOC,IAAAF,KAAA,gBAAAA,EAAM,MAAM,SAAZ,gBAAAE,EAAmB,OAAM;AAEtC,UAAOC,IAAAL,EAAQG,CAAG,MAAX,OAAAE,IAAgBL,EAAQ;AACnC;AAEO,MAAMM,IAAa,CACtBC,GACA,EAAE,MAAAC,GAAM,QAAQC,IAAM,uBAAuB,MAAAP,QAC5C;AACD,MAAIK,KAAQ,QAAQA,MAAS,GAAI,QAAO;AAExC,MAAIG;AAEJ,MAAI;AACA,QAAI,OAAOH,KAAS,YAAY,OAAOA,KAAS;AAC5C,MAAAG,IAAI,IAAI,KAAKH,CAAqB;AAAA,aAC3B,OAAOA,KAAS,aAAaA,EAAK,SAAS,GAAG,KAAK,sBAAsB,KAAKA,CAAI;AACzF,MAAAG,IAAI,IAAI,KAAKH,CAAI;AAAA,aACV,OAAOA,KAAS,UAAU;AAEjC,UAAII,IADUJ,EAAK,MAAM,GAAG,EACL,WAAW,IAAI,eAAe;AACrD,YAAMK,IAAgBJ,IAAO,IAAIA,EAAK,MAAM,GAAG,EAAE,CAAC,CAAC,IAAIA,EAAK,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;AAE9E,MAAII,MAAeD,KAAc,WAEjCD,IAAIG,EAAM,GAAGN,CAAI,GAAGK,CAAa,IAAID,GAAY,oBAAI,MAAM;AAAA,IAC/D;AACI,MAAAD,IAAI,oBAAI,KAAK,GAAG;AAGpB,WAAI,OAAO,MAAMA,EAAE,QAAA,CAAS,IAAU,gBAAgBH,CAAI,KAEnDO,EAAcJ,GAAGD,GAAK,EAAE,QAAQR,EAAiBC,CAAI,GAAG;AAAA,EACnE,SAAQa,GAAA;AACJ,WAAO,gBAAgBR,CAAI;AAAA,EAC/B;AACJ;"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,15 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { add as s, addDays as t, addMonths as r, addYears as o, eachDayOfInterval as f, eachMonthOfInterval as O, eachYearOfInterval as n, endOfDay as h, endOfISOWeek as i, endOfWeek as m, endOfYear as d, format as M, isAfter as S, isBefore as y, isEqual as D, isLastDayOfMonth as l, isSameDay as I, isSameMonth as p, isSameYear as u, isThisMonth as A, isThisYear as T, isToday as Y, isWithinInterval as c, lastDayOfMonth as k, max as x, min as W, parse as R, parseISO as b, startOfDay as v, startOfISOWeek as _, startOfMonth as w, startOfWeek as E, startOfYear as N, subDays as P, subMonths as q, subWeeks as B, subYears as H, weekDaysShort as J } from "./date/index.js";
|
|
2
|
+
import { AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR as U, THINSP as g, formatAmount as j } from "./format-amount/util.js";
|
|
3
|
+
import { showError as C, showSuccess as F } from "./show-toast/index.js";
|
|
4
|
+
import { splitAmount as K } from "./split-amount/util.js";
|
|
5
|
+
import { formatDate as V, locales as X } from "./format-date/index.js";
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
U as AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR,
|
|
8
|
+
g as THINSP,
|
|
9
|
+
s as add,
|
|
10
|
+
t as addDays,
|
|
11
|
+
r as addMonths,
|
|
12
|
+
o as addYears,
|
|
13
|
+
f as eachDayOfInterval,
|
|
14
|
+
O as eachMonthOfInterval,
|
|
15
|
+
n as eachYearOfInterval,
|
|
16
|
+
h as endOfDay,
|
|
17
|
+
i as endOfISOWeek,
|
|
18
|
+
m as endOfWeek,
|
|
19
|
+
d as endOfYear,
|
|
20
|
+
M as format,
|
|
21
|
+
j as formatAmount,
|
|
22
|
+
V as formatDate,
|
|
23
|
+
S as isAfter,
|
|
24
|
+
y as isBefore,
|
|
25
|
+
D as isEqual,
|
|
26
|
+
l as isLastDayOfMonth,
|
|
27
|
+
I as isSameDay,
|
|
28
|
+
p as isSameMonth,
|
|
29
|
+
u as isSameYear,
|
|
30
|
+
A as isThisMonth,
|
|
31
|
+
T as isThisYear,
|
|
32
|
+
Y as isToday,
|
|
33
|
+
c as isWithinInterval,
|
|
34
|
+
k as lastDayOfMonth,
|
|
35
|
+
X as locales,
|
|
36
|
+
x as max,
|
|
37
|
+
W as min,
|
|
38
|
+
R as parse,
|
|
39
|
+
b as parseISO,
|
|
40
|
+
C as showError,
|
|
41
|
+
F as showSuccess,
|
|
42
|
+
K as splitAmount,
|
|
43
|
+
v as startOfDay,
|
|
44
|
+
_ as startOfISOWeek,
|
|
45
|
+
w as startOfMonth,
|
|
46
|
+
E as startOfWeek,
|
|
47
|
+
N as startOfYear,
|
|
48
|
+
P as subDays,
|
|
49
|
+
q as subMonths,
|
|
50
|
+
B as subWeeks,
|
|
51
|
+
H as subYears,
|
|
52
|
+
J as weekDaysShort
|
|
14
53
|
};
|
|
15
54
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphakits/ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -105,7 +105,6 @@
|
|
|
105
105
|
"alphakit-presets-lint": "1.0.0",
|
|
106
106
|
"conventional-changelog-cli": "2.0.31",
|
|
107
107
|
"cz-conventional-changelog": "3.1.0",
|
|
108
|
-
"date-fns": "2.19.0",
|
|
109
108
|
"eslint": "^7.7.0",
|
|
110
109
|
"eslint-config-airbnb": "^18.2.0",
|
|
111
110
|
"eslint-config-airbnb-typescript": "^9.0.0",
|
|
@@ -151,7 +150,6 @@
|
|
|
151
150
|
},
|
|
152
151
|
"peerDependencies": {
|
|
153
152
|
"@alphakits/icons": "1.25.0",
|
|
154
|
-
"date-fns": "2.19.0",
|
|
155
153
|
"formik": "2.2.9",
|
|
156
154
|
"react": "17.0.2",
|
|
157
155
|
"react-dom": "17.0.2"
|