@xola/ui-kit 3.4.0 → 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.
@@ -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 { Context as Et } from "../Provider.js";
12
- import { now as f, isSame as L, isValidTimeZoneName as Ft, toDate as l } from "../../helpers/date.js";
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(Et), 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;
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 && !Ft(u) && (console.log(`${u} is not a valid timezone. Using default timezone now`), Y.tz.setDefault());
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)
@@ -1,7 +1,7 @@
1
1
  import { jsxs as l, jsx as t, Fragment as re } from "react/jsx-runtime";
2
2
  import I from "clsx";
3
3
  import { useCombobox as w } from "downshift";
4
- import le from "lodash-es/debounce";
4
+ import { debounce as le } from "lodash-es";
5
5
  import { useState as u, useRef as E, useEffect as K } from "react";
6
6
  import { useHotkeys as O } from "react-hotkeys-hook";
7
7
  import { isOSX as ae } from "../helpers/browser.js";
@@ -1,44 +1,49 @@
1
1
  import n, { isDayjs as s } from "dayjs";
2
- import f from "dayjs/plugin/customParseFormat";
3
- import m from "dayjs/plugin/localizedFormat";
4
- import a from "dayjs/plugin/quarterOfYear";
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 u = {
12
+ const i = {
13
13
  DATE_ISO: "YYYY-MM-DD"
14
- }, N = (t) => {
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 = u.DATE_ISO) => n(t).format(r), O = (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 o = t <= 2147483647 ? t * 1e3 : t;
26
- return r ? n(o).tz(r) : n(o);
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(i(t), r) : n(i(t)) : r ? n().tz(r) : n();
29
- }, e = (t) => t.toString().padStart(2, "0"), i = (t) => {
30
- const r = `${t.getFullYear()}-${e(t.getMonth() + 1)}-${e(t.getDate())}`, o = `${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}`;
31
- return `${r} ${o}`;
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 o = r ? p : S;
34
- return s(t) ? new Date(t.format(u.DATE_ISO) + o) : new Date(g(t) + o);
35
- }, E = (t, r, o = "day") => s(t) && s(r) ? t.isSame(r, o) : !1;
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
- u as DateFormat,
38
- i as dateToString,
40
+ i as DateFormat,
41
+ b as dateFromObjectId,
42
+ m as dateToString,
39
43
  g as formatDate,
40
- E as isSame,
41
- N as isValidTimeZoneName,
42
- O as now,
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 './utils/date';
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 "./utils/date.js";
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";
@@ -1,5 +1,4 @@
1
1
  export * from './avatar.js';
2
2
  export * from './currency.js';
3
- export * from './date.js';
4
3
  export * from './numbers.js';
5
4
  export * from './phone.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xola/ui-kit",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "Xola UI Kit",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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;
@@ -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
- };