@xola/ui-kit 3.4.1 → 3.4.2
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/build/components/DatePicker/DatePicker.js +4 -4
- package/build/helpers/date.js +29 -24
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/utils/index.d.ts +0 -1
- package/package.json +1 -1
- package/build/utils/date.d.ts +0 -12
- package/build/utils/date.js +0 -23
|
@@ -8,8 +8,8 @@ import { Tooltip as Vt } from "../Tooltip.js";
|
|
|
8
8
|
import { RelativeDateRange as Lt } from "./RelativeDateRange.js";
|
|
9
9
|
import { MonthSelector as Ot } from "./MonthSelector.js";
|
|
10
10
|
import { UpcomingDatePicker as St } from "./UpcomingDatePicker.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { now as f, isSame as L, isValidTimeZoneName as Et, toDate as l } from "../../helpers/date.js";
|
|
12
|
+
import { Context as Ft } from "../Provider.js";
|
|
13
13
|
import { Day as rt } from "./Day.js";
|
|
14
14
|
import { LocalizedDayPicker as _t } from "./LocalizedDayPicker.js";
|
|
15
15
|
import { MonthYearSelector as Tt } from "./MonthYearSelector.js";
|
|
@@ -44,9 +44,9 @@ const P = {
|
|
|
44
44
|
...H
|
|
45
45
|
}) => {
|
|
46
46
|
var K, Q;
|
|
47
|
-
const { locale: j } = yt(
|
|
47
|
+
const { locale: j } = yt(Ft), o = u ?? void 0, st = r ? U === P.single ? r : r.from : null, [d, _] = N(it ?? st ?? f(void 0, o).toDate()), [mt, Z] = N(() => !r || typeof r != "object" || !("from" in r) || !r.from ? /* @__PURE__ */ new Date() : r.from), [lt, $] = N(() => !r || typeof r != "object" || !("from" in r) || !("to" in r) || !r.to || !r.from ? f(void 0, o).add(1, "month").toDate() : L(f(r.to, o), f(r.from, o), "month") ? f(r.from, o).add(1, "month").toDate() : r.to), [ct, at] = N(""), p = U === P.range, R = r && typeof r == "object" && "from" in r && "to" in r && r.from && r.to, dt = c && typeof c == "object" && "from" in c && "to" in c && c.from && c.to;
|
|
48
48
|
jt(() => {
|
|
49
|
-
u && !
|
|
49
|
+
u && !Et(u) && (console.log(`${u} is not a valid timezone. Using default timezone now`), Y.tz.setDefault());
|
|
50
50
|
}, [u]);
|
|
51
51
|
const q = (t, e, m) => {
|
|
52
52
|
if (p)
|
package/build/helpers/date.js
CHANGED
|
@@ -1,44 +1,49 @@
|
|
|
1
1
|
import n, { isDayjs as s } from "dayjs";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import c from "dayjs/plugin/timezone";
|
|
6
|
-
import D from "dayjs/plugin/utc";
|
|
7
|
-
n.extend(f);
|
|
8
|
-
n.extend(m);
|
|
2
|
+
import a from "dayjs/plugin/customParseFormat.js";
|
|
3
|
+
import u from "dayjs/plugin/localizedFormat.js";
|
|
4
|
+
import f from "dayjs/plugin/quarterOfYear.js";
|
|
5
|
+
import c from "dayjs/plugin/timezone.js";
|
|
6
|
+
import D from "dayjs/plugin/utc.js";
|
|
9
7
|
n.extend(a);
|
|
8
|
+
n.extend(u);
|
|
9
|
+
n.extend(f);
|
|
10
10
|
n.extend(D);
|
|
11
11
|
n.extend(c);
|
|
12
|
-
const
|
|
12
|
+
const i = {
|
|
13
13
|
DATE_ISO: "YYYY-MM-DD"
|
|
14
|
-
},
|
|
14
|
+
}, O = (t) => {
|
|
15
15
|
try {
|
|
16
16
|
n.tz(/* @__PURE__ */ new Date(), t);
|
|
17
17
|
} catch {
|
|
18
18
|
return !1;
|
|
19
19
|
}
|
|
20
20
|
return !0;
|
|
21
|
-
}, g = (t, r =
|
|
21
|
+
}, g = (t, r = i.DATE_ISO) => n(t).format(r), Y = (t, r = "h:mm a") => {
|
|
22
|
+
const e = String(t).padStart(4, "0");
|
|
23
|
+
return n(e, "hhmm").format(r);
|
|
24
|
+
}, b = (t) => n(new Date(Number.parseInt(t.slice(0, 8), 16) * 1e3)), h = (t, r) => {
|
|
22
25
|
if (!t)
|
|
23
26
|
return r ? n().tz(r).startOf("day") : n();
|
|
24
27
|
if (typeof t == "number") {
|
|
25
|
-
const
|
|
26
|
-
return r ? n(
|
|
28
|
+
const e = t <= 2147483647 ? t * 1e3 : t;
|
|
29
|
+
return r ? n(e).tz(r) : n(e);
|
|
27
30
|
}
|
|
28
|
-
return typeof t == "string" ? r ? n(t).tz(r) : n() : s(t) ? t : t instanceof Date && !Number.isNaN(t.getTime()) ? r ? n.tz(
|
|
29
|
-
},
|
|
30
|
-
const r = `${t.getFullYear()}-${
|
|
31
|
-
return `${r} ${
|
|
31
|
+
return typeof t == "string" ? r ? n(t).tz(r) : n() : s(t) ? t : t instanceof Date && !Number.isNaN(t.getTime()) ? r ? n.tz(m(t), r) : n(m(t)) : r ? n().tz(r) : n();
|
|
32
|
+
}, o = (t) => t.toString().padStart(2, "0"), m = (t) => {
|
|
33
|
+
const r = `${t.getFullYear()}-${o(t.getMonth() + 1)}-${o(t.getDate())}`, e = `${o(t.getHours())}:${o(t.getMinutes())}:${o(t.getSeconds())}`;
|
|
34
|
+
return `${r} ${e}`;
|
|
32
35
|
}, p = "T00:00:00", S = "T23:59:59", w = (t, r = !0) => {
|
|
33
|
-
const
|
|
34
|
-
return s(t) ? new Date(t.format(
|
|
35
|
-
},
|
|
36
|
+
const e = r ? p : S;
|
|
37
|
+
return s(t) ? new Date(t.format(i.DATE_ISO) + e) : new Date(g(t) + e);
|
|
38
|
+
}, F = (t, r, e = "day") => s(t) && s(r) ? t.isSame(r, e) : !1;
|
|
36
39
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
i as DateFormat,
|
|
41
|
+
b as dateFromObjectId,
|
|
42
|
+
m as dateToString,
|
|
39
43
|
g as formatDate,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
O as
|
|
44
|
+
Y as formatTime,
|
|
45
|
+
F as isSame,
|
|
46
|
+
O as isValidTimeZoneName,
|
|
47
|
+
h as now,
|
|
43
48
|
w as toDate
|
|
44
49
|
};
|
package/build/index.d.ts
CHANGED
|
@@ -61,6 +61,6 @@ export { theme } from './theme';
|
|
|
61
61
|
export { Provider } from './components/Provider';
|
|
62
62
|
export { almostZero, compactNumber, numberFormat, roundNumber } from './utils/numbers';
|
|
63
63
|
export { getSymbol, isZeroDecimal } from './utils/currency';
|
|
64
|
-
export { formatDate, formatTime, dateFromObjectId } from './
|
|
64
|
+
export { formatDate, formatTime, dateFromObjectId } from './helpers/date';
|
|
65
65
|
export { isOSX, isIosBrowser } from './helpers/browser';
|
|
66
66
|
export { getChildByType, getChildrenByType } from './helpers/children';
|
package/build/index.js
CHANGED
|
@@ -50,7 +50,7 @@ import { Number as qo } from "./components/Utilities/Number.js";
|
|
|
50
50
|
import { getInitials as Eo } from "./utils/avatar.js";
|
|
51
51
|
import { almostZero as Qo, compactNumber as Wo, numberFormat as Yo, roundNumber as _o } from "./utils/numbers.js";
|
|
52
52
|
import { getSymbol as or, isZeroDecimal as rr } from "./utils/currency.js";
|
|
53
|
-
import { dateFromObjectId as tr, formatDate as mr, formatTime as pr } from "./
|
|
53
|
+
import { dateFromObjectId as tr, formatDate as mr, formatTime as pr } from "./helpers/date.js";
|
|
54
54
|
import { formatPhoneNumber as xr } from "./utils/phone.js";
|
|
55
55
|
import { isIosBrowser as ir, isOSX as nr } from "./helpers/browser.js";
|
|
56
56
|
import { flash as ur } from "./helpers/flash.js";
|
package/build/utils/index.d.ts
CHANGED
package/package.json
CHANGED
package/build/utils/date.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { default as dayjs } from 'dayjs';
|
|
2
|
-
export namespace DateFormat {
|
|
3
|
-
let DATE_ISO: string;
|
|
4
|
-
}
|
|
5
|
-
export function isValidTimeZoneName(timezoneName: any): boolean;
|
|
6
|
-
export function formatDate(date: any, format?: string): string;
|
|
7
|
-
export function formatTime(time: any, format?: string): string;
|
|
8
|
-
export function dateFromObjectId(id: any): dayjs.Dayjs;
|
|
9
|
-
export function now(date: any, timezone: any): dayjs.Dayjs;
|
|
10
|
-
export function dateToString(date: any): string;
|
|
11
|
-
export function toDate(date: any, isStartDate?: boolean): Date;
|
|
12
|
-
export function isSame(date1: any, date2: any, unit?: string): boolean;
|
package/build/utils/date.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import t from "dayjs";
|
|
2
|
-
import o from "dayjs/plugin/customParseFormat";
|
|
3
|
-
import a from "dayjs/plugin/localizedFormat";
|
|
4
|
-
import n from "dayjs/plugin/quarterOfYear";
|
|
5
|
-
import i from "dayjs/plugin/timezone";
|
|
6
|
-
import f from "dayjs/plugin/utc";
|
|
7
|
-
t.extend(o);
|
|
8
|
-
t.extend(a);
|
|
9
|
-
t.extend(n);
|
|
10
|
-
t.extend(f);
|
|
11
|
-
t.extend(i);
|
|
12
|
-
const s = {
|
|
13
|
-
DATE_ISO: "YYYY-MM-DD"
|
|
14
|
-
}, Y = (r, e = s.DATE_ISO) => t(r).format(e), F = (r, e = "h:mm a") => {
|
|
15
|
-
const m = String(r).padStart(4, 0);
|
|
16
|
-
return t(m, "hhmm").format(e);
|
|
17
|
-
}, I = (r) => t(new Date(Number.parseInt(r.slice(0, 8), 16) * 1e3));
|
|
18
|
-
export {
|
|
19
|
-
s as DateFormat,
|
|
20
|
-
I as dateFromObjectId,
|
|
21
|
-
Y as formatDate,
|
|
22
|
-
F as formatTime
|
|
23
|
-
};
|