@xola/ui-kit 3.5.0 → 3.7.0

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.
Files changed (215) hide show
  1. package/README.md +136 -87
  2. package/build/components/Alert.js +18 -13
  3. package/build/components/Animation/FadeIn.js +36 -25
  4. package/build/components/Animation/SlideDown.js +14 -9
  5. package/build/components/Avatar.js +17 -10
  6. package/build/components/Badge.js +33 -24
  7. package/build/components/BottomSheet.js +114 -0
  8. package/build/components/Breadcrumb.js +27 -21
  9. package/build/components/Breakdown.js +66 -74
  10. package/build/components/Buttons/Button.js +53 -47
  11. package/build/components/Buttons/ButtonGroup.js +42 -39
  12. package/build/components/Buttons/SecondaryButton.js +31 -0
  13. package/build/components/Buttons/SubmitButton.js +72 -66
  14. package/build/components/Buttons/ToggleButton.js +15 -16
  15. package/build/components/Counter.js +10 -6
  16. package/build/components/DatePicker/DatePicker.helpers.js +24 -13
  17. package/build/components/DatePicker/DatePicker.js +196 -223
  18. package/build/components/DatePicker/DatePickerPopover.js +75 -66
  19. package/build/components/DatePicker/Day.js +35 -32
  20. package/build/components/DatePicker/LocalizedDayPicker.js +15 -18
  21. package/build/components/DatePicker/MonthGrid.js +35 -48
  22. package/build/components/DatePicker/MonthPicker.js +25 -20
  23. package/build/components/DatePicker/MonthSelector.js +39 -40
  24. package/build/components/DatePicker/MonthYearSelector.js +18 -39
  25. package/build/components/DatePicker/NavbarElement.js +26 -35
  26. package/build/components/DatePicker/RangeDatePicker.js +104 -123
  27. package/build/components/DatePicker/RelativeDateRange.js +153 -143
  28. package/build/components/DatePicker/UpcomingDatePicker.js +29 -25
  29. package/build/components/Dot/Dot.js +13 -8
  30. package/build/components/Dot/DotProgress.js +12 -7
  31. package/build/components/Drawer.js +109 -101
  32. package/build/components/Forms/BaseInput.js +50 -34
  33. package/build/components/Forms/Checkbox.js +33 -30
  34. package/build/components/Forms/ComboBox.js +35 -35
  35. package/build/components/Forms/FormGroup.js +7 -3
  36. package/build/components/Forms/InlineValuePopover.js +33 -39
  37. package/build/components/Forms/Input.js +15 -7
  38. package/build/components/Forms/Label.js +14 -8
  39. package/build/components/Forms/RangeSlider.js +41 -22
  40. package/build/components/Forms/Select.js +5 -6
  41. package/build/components/Forms/Switch.js +46 -38
  42. package/build/components/Forms/Textarea.js +37 -30
  43. package/build/components/Forms/ValuePopoverText.js +5 -8
  44. package/build/components/GooglePlacesAutocomplete.js +112 -0
  45. package/build/components/HeaderToolbar.js +30 -22
  46. package/build/components/ImageUpload.js +76 -79
  47. package/build/components/Key.js +21 -16
  48. package/build/components/Logo.js +12 -5
  49. package/build/components/Modal.js +87 -72
  50. package/build/components/Popover/Popover.js +40 -31
  51. package/build/components/Popover/PopoverList.js +43 -36
  52. package/build/components/Provider.js +7 -8
  53. package/build/components/Screens/Login.js +97 -126
  54. package/build/components/Search.js +114 -144
  55. package/build/components/Sidebar/Sidebar.Account.js +39 -46
  56. package/build/components/Sidebar/Sidebar.Button.js +45 -19
  57. package/build/components/Sidebar/Sidebar.Footer.js +8 -7
  58. package/build/components/Sidebar/Sidebar.Heading.js +11 -8
  59. package/build/components/Sidebar/Sidebar.Link.js +79 -44
  60. package/build/components/Sidebar/Sidebar.Menu.js +52 -28
  61. package/build/components/Sidebar/Sidebar.Notifications.js +107 -0
  62. package/build/components/Sidebar/Sidebar.js +207 -214
  63. package/build/components/Sidebar/SidebarContext.js +15 -0
  64. package/build/components/Sidebar/sidebarWidth.js +41 -0
  65. package/build/components/Sidebar/useSidebarWidthState.js +115 -0
  66. package/build/components/Skeleton.js +19 -20
  67. package/build/components/Spinner.js +18 -10
  68. package/build/components/Table.js +86 -50
  69. package/build/components/Tabs/Tabs.Panel.js +9 -5
  70. package/build/components/Tabs/Tabs.Tab.js +28 -23
  71. package/build/components/Tabs/Tabs.js +23 -23
  72. package/build/components/Tag.js +28 -23
  73. package/build/components/Tooltip.js +19 -5
  74. package/build/components/Utilities/Currency.js +49 -42
  75. package/build/components/Utilities/Number.js +14 -12
  76. package/build/components/Utilities/Phone.js +18 -12
  77. package/build/helpers/environment.js +10 -0
  78. package/build/helpers/flash.js +45 -46
  79. package/build/hooks/useIsMobile.js +8 -0
  80. package/build/hooks/useViewportHeight.js +6 -12
  81. package/build/icons/src/AnnounceIcon.js +3 -4
  82. package/build/icons/src/BellIcon.js +0 -1
  83. package/build/icons/src/CalendarIcon.js +0 -1
  84. package/build/icons/src/CheckIcon.js +0 -1
  85. package/build/icons/src/ChevronDownIcon.js +4 -5
  86. package/build/icons/src/ChevronLeftIcon.js +0 -1
  87. package/build/icons/src/ChevronRightIcon.js +0 -1
  88. package/build/icons/src/CircleNotch.js +0 -1
  89. package/build/icons/src/CloseIcon.js +11 -9
  90. package/build/icons/src/DownArrowIcon.js +0 -1
  91. package/build/icons/src/ImageIcon.js +0 -1
  92. package/build/icons/src/SearchIcon.js +4 -5
  93. package/build/icons/src/TrashIcon.js +0 -1
  94. package/build/icons/src/WarningDiamondIcon.js +0 -1
  95. package/build/icons/src/helpers/icon.js +5 -9
  96. package/build/icons/src/images/XolaLogoSimple.js +2 -3
  97. package/build/index.js +143 -130
  98. package/build/style.css +1 -0
  99. package/build/theme.css +76 -0
  100. package/build/theme.js +2 -0
  101. package/build/utils/currency.js +5 -5
  102. package/build/{helpers → utils}/date.js +17 -20
  103. package/build/utils/numbers.js +12 -12
  104. package/build/utils/phone.js +12 -14
  105. package/build/utils/userLocale.js +6 -0
  106. package/index.css +96 -4
  107. package/index.d.ts +204 -0
  108. package/package.json +87 -77
  109. package/skills/README.md +27 -0
  110. package/skills/migrate-2.6-to-3.7/SKILL.md +110 -0
  111. package/tailwind.config.js +5 -2
  112. package/build/base.css +0 -2
  113. package/build/components/Alert.d.ts +0 -18
  114. package/build/components/Animation/FadeIn.d.ts +0 -13
  115. package/build/components/Animation/SlideDown.d.ts +0 -6
  116. package/build/components/Avatar.d.ts +0 -16
  117. package/build/components/Badge.d.ts +0 -28
  118. package/build/components/Breadcrumb.d.ts +0 -21
  119. package/build/components/Breakdown.d.ts +0 -63
  120. package/build/components/Buttons/Button.d.ts +0 -53
  121. package/build/components/Buttons/ButtonGroup.d.ts +0 -35
  122. package/build/components/Buttons/SubmitButton.d.ts +0 -11
  123. package/build/components/Buttons/ToggleButton.d.ts +0 -21
  124. package/build/components/Charts/BaseChartOptions.d.ts +0 -136
  125. package/build/components/Charts/HistogramOptions.d.ts +0 -192
  126. package/build/components/Charts/PieOptions.d.ts +0 -177
  127. package/build/components/Counter.d.ts +0 -5
  128. package/build/components/DatePicker/DatePicker.d.ts +0 -41
  129. package/build/components/DatePicker/DatePicker.helpers.d.ts +0 -17
  130. package/build/components/DatePicker/DatePickerPopover.d.ts +0 -29
  131. package/build/components/DatePicker/Day.d.ts +0 -13
  132. package/build/components/DatePicker/LocalizedDayPicker.d.ts +0 -6
  133. package/build/components/DatePicker/MonthGrid.d.ts +0 -11
  134. package/build/components/DatePicker/MonthPicker.d.ts +0 -7
  135. package/build/components/DatePicker/MonthSelector.d.ts +0 -8
  136. package/build/components/DatePicker/MonthYearSelector.d.ts +0 -8
  137. package/build/components/DatePicker/NavbarElement.d.ts +0 -15
  138. package/build/components/DatePicker/RangeDatePicker.d.ts +0 -25
  139. package/build/components/DatePicker/RelativeDateRange.d.ts +0 -51
  140. package/build/components/DatePicker/UpcomingDatePicker.d.ts +0 -11
  141. package/build/components/Dot/Dot.d.ts +0 -24
  142. package/build/components/Dot/DotProgress.d.ts +0 -6
  143. package/build/components/Drawer.d.ts +0 -28
  144. package/build/components/Forms/BaseInput.d.ts +0 -20
  145. package/build/components/Forms/Checkbox.d.ts +0 -10
  146. package/build/components/Forms/ComboBox.d.ts +0 -8
  147. package/build/components/Forms/FormGroup.d.ts +0 -5
  148. package/build/components/Forms/InlineValuePopover.d.ts +0 -17
  149. package/build/components/Forms/Input.d.ts +0 -6
  150. package/build/components/Forms/Label.d.ts +0 -7
  151. package/build/components/Forms/RangeSlider.d.ts +0 -33
  152. package/build/components/Forms/Select.d.ts +0 -5
  153. package/build/components/Forms/Switch.d.ts +0 -46
  154. package/build/components/Forms/Textarea.d.ts +0 -6
  155. package/build/components/Forms/ValuePopoverText.d.ts +0 -6
  156. package/build/components/GooglePlacesAutocomplete.d.ts +0 -14
  157. package/build/components/HeaderToolbar.d.ts +0 -21
  158. package/build/components/ImageUpload.d.ts +0 -17
  159. package/build/components/Key.d.ts +0 -6
  160. package/build/components/Logo.d.ts +0 -19
  161. package/build/components/Modal.d.ts +0 -52
  162. package/build/components/Popover/Popover.d.ts +0 -20
  163. package/build/components/Popover/PopoverList.d.ts +0 -25
  164. package/build/components/Provider.d.ts +0 -18
  165. package/build/components/Screens/Login.d.ts +0 -25
  166. package/build/components/Search.d.ts +0 -16
  167. package/build/components/Sidebar/Sidebar.Account.d.ts +0 -13
  168. package/build/components/Sidebar/Sidebar.Button.d.ts +0 -10
  169. package/build/components/Sidebar/Sidebar.Footer.d.ts +0 -8
  170. package/build/components/Sidebar/Sidebar.Heading.d.ts +0 -10
  171. package/build/components/Sidebar/Sidebar.Link.d.ts +0 -24
  172. package/build/components/Sidebar/Sidebar.Menu.d.ts +0 -13
  173. package/build/components/Sidebar/Sidebar.d.ts +0 -58
  174. package/build/components/Sidebar/index.d.ts +0 -8
  175. package/build/components/Skeleton.d.ts +0 -13
  176. package/build/components/Spinner.d.ts +0 -26
  177. package/build/components/Table.d.ts +0 -59
  178. package/build/components/Tabs/Tabs.Panel.d.ts +0 -9
  179. package/build/components/Tabs/Tabs.Tab.d.ts +0 -19
  180. package/build/components/Tabs/Tabs.d.ts +0 -27
  181. package/build/components/Tabs/index.d.ts +0 -4
  182. package/build/components/Tag.d.ts +0 -25
  183. package/build/components/Tooltip.d.ts +0 -8
  184. package/build/components/Utilities/Currency.d.ts +0 -32
  185. package/build/components/Utilities/Number.d.ts +0 -8
  186. package/build/components/Utilities/Phone.d.ts +0 -8
  187. package/build/full.css +0 -2
  188. package/build/helpers/avatar.d.ts +0 -1
  189. package/build/helpers/avatar.js +0 -8
  190. package/build/helpers/browser.d.ts +0 -2
  191. package/build/helpers/children.d.ts +0 -3
  192. package/build/helpers/classnames.d.ts +0 -5
  193. package/build/helpers/currency.d.ts +0 -2
  194. package/build/helpers/currency.js +0 -11
  195. package/build/helpers/date.d.ts +0 -12
  196. package/build/helpers/flash.d.ts +0 -21
  197. package/build/helpers/numbers.d.ts +0 -4
  198. package/build/helpers/numbers.js +0 -23
  199. package/build/helpers/phone.d.ts +0 -11
  200. package/build/helpers/phone.js +0 -25
  201. package/build/hooks/useId.d.ts +0 -1
  202. package/build/hooks/useId.js +0 -9
  203. package/build/hooks/useIsClient.d.ts +0 -1
  204. package/build/hooks/useViewportHeight.d.ts +0 -1
  205. package/build/icons/src/helpers/classnames.js +0 -8
  206. package/build/index.d.ts +0 -66
  207. package/build/theme.d.ts +0 -413
  208. package/build/types/index.d.ts +0 -22
  209. package/build/types/migration.d.ts +0 -2
  210. package/build/ui-kit.css +0 -1
  211. package/build/utils/avatar.d.ts +0 -1
  212. package/build/utils/currency.d.ts +0 -2
  213. package/build/utils/index.d.ts +0 -4
  214. package/build/utils/numbers.d.ts +0 -4
  215. package/build/utils/phone.d.ts +0 -2
@@ -1,241 +1,214 @@
1
- import { jsx as s, jsxs as X, Fragment as kt } from "react/jsx-runtime";
2
- import Y from "dayjs";
3
- import { isArray as h, isFunction as M } from "lodash-es";
4
- import { useContext as Dt, useState as N, useEffect as yt, useCallback as V, useMemo as jt } from "react";
5
- import { isBefore as C, startOfDay as b, endOfDay as v, isAfter as tt, isSameDay as Rt } from "date-fns";
6
- import { Tooltip as Nt } from "../Tooltip.js";
7
- import { RelativeDateRange as Vt } from "./RelativeDateRange.js";
8
- import { MonthSelector as Lt } from "./MonthSelector.js";
9
- import { UpcomingDatePicker as Ot } from "./UpcomingDatePicker.js";
10
- import { now as f, isSame as L, isValidTimeZoneName as St, toDate as l } from "../../helpers/date.js";
11
- import { Context as Et } from "../Provider.js";
12
- import Ft from "../../helpers/classnames.js";
13
- import { Day as rt } from "./Day.js";
14
- import { LocalizedDayPicker as _t } from "./LocalizedDayPicker.js";
15
- import { MonthYearSelector as Tt } from "./MonthYearSelector.js";
16
- import { NavbarElement as At } from "./NavbarElement.js";
17
- import Bt from "./RangeDatePicker.js";
18
- const P = {
1
+ import C from "dayjs";
2
+ import { isArray as h, isFunction as N } from "lodash-es";
3
+ import e from "prop-types";
4
+ import s, { useContext as Et, useState as b, useEffect as gt, useMemo as Rt } from "react";
5
+ import ut from "react-day-picker";
6
+ /* empty css */
7
+ import { Tooltip as kt } from "../Tooltip.js";
8
+ import { RelativeDateRange as yt } from "./RelativeDateRange.js";
9
+ import { now as c, isSame as O, isValidTimeZoneName as Tt, toDate as i } from "../../utils/date.js";
10
+ import { Context as bt } from "../Provider.js";
11
+ import Ot from "../../helpers/classnames.js";
12
+ /* empty css */
13
+ import { Day as z } from "./Day.js";
14
+ import { LocalizedDayPicker as St } from "./LocalizedDayPicker.js";
15
+ import { MonthYearSelector as wt } from "./MonthYearSelector.js";
16
+ import { MonthSelector as xt } from "./MonthSelector.js";
17
+ import { NavbarElement as Vt } from "./NavbarElement.js";
18
+ import jt from "./RangeDatePicker.js";
19
+ import { UpcomingDatePicker as Ft } from "./UpcomingDatePicker.js";
20
+ const { DateUtils: R } = ut, S = {
19
21
  single: "single",
20
22
  range: "range"
21
- }, Ct = ({
22
- variant: U = P.single,
23
- value: r,
24
- selectedDays: c,
25
- upcomingDates: W,
26
- disabledDays: x = [],
27
- loadingDays: k = [],
28
- shouldShowYearPicker: O = !1,
29
- shouldShowMonthSelector: S = !1,
30
- shouldShowRelativeRanges: et = !1,
23
+ }, Lt = ({
24
+ variant: B = S.single,
25
+ value: t,
26
+ getDayContent: u,
27
+ disabledDays: p = [],
28
+ selectedDays: a,
29
+ loadingDays: g = [],
30
+ shouldShowYearPicker: w = !1,
31
+ shouldShowMonthSelector: x = !1,
32
+ onChange: d,
33
+ onMonthChange: f,
34
+ onSubmitDateRange: v,
35
+ modifiers: k = {},
36
+ ranges: tt,
37
+ shouldShowRelativeRanges: rt = !1,
31
38
  isFutureDatesAllowed: ot = !1,
32
- modifiers: E = {},
33
- ranges: nt,
34
- components: z = {},
35
- locale: D,
36
- timezoneName: u,
37
- getDayContent: F,
39
+ components: U = {},
38
40
  getTooltip: y,
39
- onChange: a,
40
- onMonthChange: i,
41
- onSubmitDateRange: ft,
42
- month: it,
43
- // Deprecated v7 props are spread into rest and ignored
44
- ...H
41
+ upcomingDates: q,
42
+ locale: V,
43
+ timezoneName: o = null,
44
+ // seller timezone (e.g. "America/Los_Angeles") to return correct today date
45
+ ...A
45
46
  }) => {
46
- var K, Q;
47
- const { locale: j } = Dt(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;
48
- yt(() => {
49
- u && !St(u) && (console.log(`${u} is not a valid timezone. Using default timezone now`), Y.tz.setDefault());
50
- }, [u]);
51
- const q = (t, e, m) => {
52
- if (p)
47
+ var X, Y, _, M;
48
+ const { locale: j } = Et(bt), et = t ? B === S.single ? t : t.from : null, [D, F] = b(et ?? c(null, o).toDate()), [nt, H] = b(() => !t || !t.from ? /* @__PURE__ */ new Date() : t.from), [ct, Z] = b(() => !t || !t.to || !t.from ? c(null, o).add(1, "month").toDate() : O(c(t.to, o), c(t.from, o), "month") ? c(t.from, o).add(1, "month").toDate() : t.to), [st, ft] = b(""), E = B === S.range, L = t && t.from && t.to, $ = a && a.from && a.to;
49
+ gt(() => {
50
+ o && !Tt(o) && (console.log(`${o} is not a valid timezone. Using default timezone now`), C.tz.setDefault());
51
+ }, [o]);
52
+ const G = (r, n, l) => {
53
+ if (E)
53
54
  return;
54
- const n = u ? l(f(t, u)) : /* @__PURE__ */ new Date();
55
- e.disabled || T(n) ? (_(n), i == null || i(n)) : a(n, e, m);
56
- }, T = (t) => h(x) ? x.some((e) => {
57
- if (e.daysOfWeek)
58
- return e.daysOfWeek.includes(t.getDay());
59
- if (e.after || e.before) {
60
- const m = e.after ? tt(b(t), b(e.after)) : !0, n = e.before ? C(b(t), b(e.before)) : !0;
61
- return m && n;
62
- }
63
- return e instanceof Date ? L(f(e, o), t, "day") : !1;
64
- }) : M(x) ? x(t) : !1, bt = (t) => h(k) ? k.some((e) => L(f(e, o), t, "day")) : M(k) ? k(t) : !1, ut = (t, e) => {
65
- _(e.from), Z(e.from), $(e.to), a({ ...e, rangeName: t }, E, null);
66
- }, g = V(
67
- (t) => {
68
- _(t), i == null || i(t);
69
- },
70
- [i]
71
- ), G = V(
72
- (t) => {
73
- Z(t), i == null || i(t);
74
- },
75
- [i]
76
- ), pt = V(
77
- (t) => {
78
- $(t), i == null || i(t);
79
- },
80
- [i]
81
- ), A = V(
82
- (t, e, m) => {
83
- if (!(!t || e.disabled))
84
- if (r && typeof r == "object" && "from" in r && r.from && L(f(r.from, o), f(t, o), "month") && G(t), at(""), p) {
85
- const n = r;
86
- if (R)
87
- a({ from: l(f(t, o)), to: null }, e, m);
88
- else if (n && (n.from || n.to) && (n.from || n.to).getTime() === t.getTime()) {
89
- const w = l(f(t, o)), B = l(f(t, o).endOf("day"), !1);
90
- a({ from: w, to: B }, e, m);
91
- } else if (n.from && C(b(n.from), b(l(f(t, o))))) {
92
- const w = n.from, B = v(l(f(t, o), !1));
93
- a({ from: w, to: B }, e, m);
94
- } else if (n.from && (tt(b(n.from), b(l(f(t, o)))) || Rt(n.from, l(f(t, o)))))
95
- a(
96
- {
97
- from: l(f(t, o)),
98
- to: l(f(n.from).endOf("day"), !1)
99
- },
100
- e,
101
- m
102
- );
103
- else {
104
- const w = v(l(f(t, o), !1));
105
- a({ from: n.from, to: w }, e, m);
106
- }
107
- } else
108
- a(l(f(t, o)), e, m);
109
- },
110
- // eslint-disable-next-line react-hooks/exhaustive-deps
111
- [p, R, a, o, r]
112
- ), I = jt(() => (O || S) && d ? (t) => S ? /* @__PURE__ */ s(
113
- Lt,
55
+ const m = o ? i(c(r, o)) : /* @__PURE__ */ new Date();
56
+ n.disabled || I(m) ? (F(m), f == null || f(m)) : d(m, n, l);
57
+ }, I = (r) => h(p) ? p.some((n) => O(c(n, o), r, "day")) : (N(p), p(r)), it = (r) => h(g) ? g.some((n) => O(c(n, o), r, "day")) : (N(g), g(r)), lt = (r, n) => {
58
+ F(n.from), H(n.from), Z(n.to), d({ ...n, rangeName: r }, k, null);
59
+ }, T = (r) => {
60
+ F(r), f == null || f(r);
61
+ }, J = (r) => {
62
+ H(r), f == null || f(r);
63
+ }, mt = (r) => {
64
+ Z(r), f == null || f(r);
65
+ }, P = (r, n, l) => {
66
+ if (!n.disabled)
67
+ if (O(c(t == null ? void 0 : t.from, o), c(r, o), "month") && J(r), ft(""), E)
68
+ if (L)
69
+ d({ from: i(c(r, o)), to: null }, n, l);
70
+ else if (t && (t.from || t.to) && (t.from || t.to).getTime() === r.getTime()) {
71
+ const m = i(c(r, o)), Dt = i(c(r, o).endOf("day"), !1);
72
+ d({ from: m, to: Dt }, n, l);
73
+ } else t.from && R.isDayBefore(t.from, i(c(r, o))) ? d(R.addDayToRange(i(c(r, o), !1), t), n, l) : t.from && (R.isDayAfter(t.from, i(c(r, o))) || R.isSameDay(t.from, i(c(r, o)))) ? d(
74
+ {
75
+ from: i(c(r, o)),
76
+ to: i(c(t.from).endOf("day"), !1)
77
+ },
78
+ n,
79
+ l
80
+ ) : d(
81
+ R.addDayToRange(i(c(r, o).endOf("day"), !1), t),
82
+ n,
83
+ l
84
+ );
85
+ else
86
+ d(i(c(r, o)), n, l);
87
+ }, at = Rt(() => (w || x) && D ? ({ date: r }) => x ? /* @__PURE__ */ s.createElement(
88
+ xt,
114
89
  {
115
- date: t.date || d,
116
- currentMonth: d,
117
- locale: D ?? j,
118
- onChange: g
90
+ date: r,
91
+ currentMonth: D,
92
+ locale: V ?? j,
93
+ onChange: T
119
94
  }
120
- ) : /* @__PURE__ */ s(
121
- Tt,
95
+ ) : /* @__PURE__ */ s.createElement(
96
+ wt,
122
97
  {
123
- date: t.date || d,
124
- currentMonth: d,
125
- locale: D ?? j,
126
- onChange: g
98
+ date: r,
99
+ currentMonth: D,
100
+ locale: V ?? j,
101
+ onChange: T
127
102
  }
128
- ) : void 0, [O, S, d, g, D, j]), xt = (t) => {
129
- const e = y == null ? void 0 : y(t), m = T(t), n = bt(t);
130
- return e ? /* @__PURE__ */ s(Nt, { placement: "top", content: e, children: /* @__PURE__ */ s(
131
- rt,
103
+ ) : void 0, [w, x, D]), dt = (r) => {
104
+ const n = y == null ? void 0 : y(r), l = I(r), m = it(r);
105
+ return n ? /* @__PURE__ */ s.createElement(kt, { placement: "top", content: n }, /* @__PURE__ */ s.createElement(
106
+ z,
132
107
  {
133
- disabled: m,
134
- isLoading: n,
135
- selectedDate: r,
136
- date: t,
137
- getContent: F,
138
- currentMonth: d
108
+ disabled: l,
109
+ isLoading: m,
110
+ selectedDate: t,
111
+ date: r,
112
+ getContent: u,
113
+ currentMonth: D
139
114
  }
140
- ) }) : /* @__PURE__ */ s(
141
- rt,
115
+ )) : /* @__PURE__ */ s.createElement(
116
+ z,
142
117
  {
143
- disabled: m,
144
- isLoading: n,
145
- selectedDate: r,
146
- date: t,
147
- getContent: F,
148
- currentMonth: d
118
+ disabled: l,
119
+ isLoading: m,
120
+ selectedDate: t,
121
+ date: r,
122
+ getContent: u,
123
+ currentMonth: D
149
124
  }
150
125
  );
151
- }, J = p && R ? { start: r.from, end: r.to } : dt ? { start: c.from, end: c.to } : null, gt = p && R && ((K = r.from) == null ? void 0 : K.getTime()) !== ((Q = r.to) == null ? void 0 : Q.getTime()), wt = c ?? (r && (Y.isDayjs(r) || p ? r : f(r, o).toDate()));
152
- return /* @__PURE__ */ X(kt, { children: [
153
- /* @__PURE__ */ X("div", { className: "flex", children: [
154
- W ? /* @__PURE__ */ s(
155
- Ot,
156
- {
157
- upcomingDates: W,
158
- value: r,
159
- onChange: A,
160
- onMonthChange: g
161
- }
162
- ) : null,
163
- p ? /* @__PURE__ */ s(
164
- Bt,
165
- {
166
- isDateRangeStyle: gt,
167
- shouldShowYearPicker: O,
168
- startMonth: mt,
169
- endMonth: lt,
170
- modifiers: { ...E, ...J },
171
- getTooltip: y,
172
- disabledDays: x,
173
- getDayContent: F,
174
- value: r,
175
- handleDayClick: A,
176
- handleStartMonthChange: G,
177
- handleEndMonthChange: pt,
178
- handleTodayClick: q,
179
- selectedDays: wt,
180
- locale: D ?? j,
181
- timezoneName: o,
182
- ...H
183
- }
184
- ) : /* @__PURE__ */ s(
185
- _t,
186
- {
187
- className: Ft("pt-6 tracking-tightest rounded-lg ring-0 focus:outline-none focus:ring-0"),
188
- mode: "single",
189
- selected: r,
190
- month: d,
191
- modifiers: { ...E, ...J },
192
- disabled: T,
193
- onSelect: A,
194
- onMonthChange: g,
195
- classNames: {
196
- months: "flex flex-col relative",
197
- month_caption: "relative flex h-8 mb-4 pl-4",
198
- caption_label: "text-lg font-semibold",
199
- nav: "h-8 right-4 absolute items-center",
200
- weekdays: "flex flex-row",
201
- weekday: "w-full m-0 p-0 text-base font-semibold text-black",
202
- month: "w-full min-w-[400px]",
203
- month_grid: "w-full mt-4",
204
- week: "mt-0.5 flex w-full justify-between",
205
- day: "w-[calc(100%/7)] mr-0.5 rounded",
206
- day_button: "h-12 w-full cursor-pointer rounded bg-transparent hover:border hover:border-blue hover:bg-blue-lighter hover:text-black disabled:cursor-not-allowed disabled:text-gray-light disabled:hover:border-none disabled:hover:bg-transparent",
207
- selected: "[&>button]:border [&>button]:border-blue [&>button]:bg-blue [&>button]:text-white [&>button:hover]:border-blue-darker [&>button:hover]:bg-blue-darker",
208
- today: "[&>button]:border [&>button]:border-gray-light",
209
- outside: "opacity-0",
210
- disabled: "text-gray-light cursor-not-allowed [&>button]:cursor-not-allowed",
211
- hidden: "invisible"
212
- },
213
- modifiersClassNames: {
214
- waitlist: "[&>button]:relative [&>button]:after:content-[''] [&>button]:after:absolute [&>button]:after:bottom-1 [&>button]:after:left-1/2 [&>button]:after:-translate-x-1/2 [&>button]:after:h-2 [&>button]:after:w-2 [&>button]:after:rounded-full [&>button]:after:bg-yellow"
215
- },
216
- components: {
217
- ...I ? { CaptionLabel: I } : {},
218
- DayButton: ({ day: t, ...e }) => /* @__PURE__ */ s("button", { ...e, children: xt(t.date) }),
219
- Nav: (t) => /* @__PURE__ */ s(At, { ...t, onTodayClick: (e) => q(/* @__PURE__ */ new Date(), {}, e) })
220
- },
221
- ...H
222
- }
223
- )
224
- ] }),
225
- z.Footer ? /* @__PURE__ */ s(z.Footer, {}) : null,
226
- et && /* @__PURE__ */ s("div", { className: "max-w-200 ", children: /* @__PURE__ */ s("div", { className: "ml-auto w-5/12", children: /* @__PURE__ */ s(
227
- Vt,
228
- {
229
- value: ct,
230
- ranges: nt,
231
- timezoneName: o,
232
- isFutureDatesAllowed: ot,
233
- onChange: ut,
234
- onSubmit: ft
235
- }
236
- ) }) })
237
- ] });
126
+ }, K = E && L ? { start: t.from, end: t.to } : $ ? { start: a.from, end: a.to } : null, Q = E && L && ((X = t.from) == null ? void 0 : X.getTime()) !== ((Y = t.to) == null ? void 0 : Y.getTime()), pt = $ && ((_ = a.from) == null ? void 0 : _.getTime()) !== ((M = a.to) == null ? void 0 : M.getTime()), W = a ?? (t && (C.isDayjs(t) || E ? t : c(t, o).toDate()));
127
+ return /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("div", { className: "flex" }, q ? /* @__PURE__ */ s.createElement(
128
+ Ft,
129
+ {
130
+ upcomingDates: q,
131
+ value: t,
132
+ onChange: P,
133
+ onMonthChange: T
134
+ }
135
+ ) : null, E ? /* @__PURE__ */ s.createElement(
136
+ jt,
137
+ {
138
+ isDateRangeStyle: Q,
139
+ shouldShowYearPicker: w,
140
+ startMonth: nt,
141
+ endMonth: ct,
142
+ modifiers: { ...k, ...K },
143
+ getTooltip: y,
144
+ disabledDays: p,
145
+ getDayContent: u,
146
+ value: t,
147
+ handleDayClick: P,
148
+ handleStartMonthChange: J,
149
+ handleEndMonthChange: mt,
150
+ handleTodayClick: G,
151
+ selectedDays: W,
152
+ locale: V ?? j,
153
+ timezoneName: o,
154
+ ...A
155
+ }
156
+ ) : /* @__PURE__ */ s.createElement(
157
+ St,
158
+ {
159
+ className: Ot(
160
+ "ui-date-picker rounded-lg pt-3",
161
+ Q ? "date-range-picker" : null,
162
+ pt ? "date-range-picker max-w-[400px]" : null,
163
+ u ? "has-custom-content" : null,
164
+ k.waitlist ? "has-custom-content" : null
165
+ ),
166
+ todayButton: "Today",
167
+ selectedDays: W,
168
+ month: D,
169
+ modifiers: { ...k, ...K },
170
+ disabledDays: p,
171
+ captionElement: at,
172
+ renderDay: dt,
173
+ navbarElement: Vt,
174
+ onDayClick: P,
175
+ onMonthChange: T,
176
+ onTodayButtonClick: G,
177
+ ...A
178
+ }
179
+ )), U.Footer ? /* @__PURE__ */ s.createElement(U.Footer, null) : null, rt && /* @__PURE__ */ s.createElement("div", { className: "max-w-200 " }, /* @__PURE__ */ s.createElement("div", { className: "ml-auto w-5/12" }, /* @__PURE__ */ s.createElement(
180
+ yt,
181
+ {
182
+ value: st,
183
+ ranges: tt,
184
+ timezoneName: o,
185
+ isFutureDatesAllowed: ot,
186
+ onChange: lt,
187
+ onSubmit: v
188
+ }
189
+ ))));
190
+ };
191
+ Lt.propTypes = {
192
+ variant: e.oneOf(Object.keys(S)),
193
+ value: e.objectOf(Date),
194
+ selectedDays: e.objectOf(Date),
195
+ upcomingDates: e.arrayOf(Date),
196
+ onChange: e.func.isRequired,
197
+ onMonthChange: e.func,
198
+ disabledDays: e.oneOfType([e.object, e.array, e.func]),
199
+ shouldShowYearPicker: e.bool,
200
+ shouldShowMonthSelector: e.bool,
201
+ isDateRangeStyle: e.bool,
202
+ isRangeVariant: e.bool,
203
+ getDayContent: e.func,
204
+ modifiers: e.object,
205
+ ranges: e.arrayOf(e.oneOf(["day", "week", "month", "quarter", "year"])),
206
+ shouldShowRelativeRanges: e.bool,
207
+ components: e.shape({ Footer: e.oneOfType([e.node, e.func]) }),
208
+ getTooltip: e.func,
209
+ locale: e.string,
210
+ timezoneName: e.string
238
211
  };
239
212
  export {
240
- Ct as DatePicker
213
+ Lt as DatePicker
241
214
  };
@@ -1,81 +1,90 @@
1
- import { jsxs as x, jsx as e } from "react/jsx-runtime";
2
- import { useState as m, useEffect as E, cloneElement as L, forwardRef as A } from "react";
3
- import { formatDate as M } from "../../helpers/date.js";
4
- import y from "../../helpers/classnames.js";
1
+ import o from "prop-types";
2
+ import t, { useState as n, useEffect as j, cloneElement as z, forwardRef as L } from "react";
3
+ import I from "../../helpers/classnames.js";
4
+ import { formatDate as A } from "../../utils/date.js";
5
+ import { useIsMobile as F } from "../../hooks/useIsMobile.js";
5
6
  import { Input as W } from "../Forms/Input.js";
6
7
  import { Popover as D } from "../Popover/Popover.js";
7
- import { DatePicker as q } from "./DatePicker.js";
8
- import { MonthPicker as B } from "./MonthPicker.js";
9
- import { CalendarIcon as F } from "../../icons/src/CalendarIcon.js";
8
+ import { DatePicker as N } from "./DatePicker.js";
9
+ import { MonthPicker as q } from "./MonthPicker.js";
10
+ import { CalendarIcon as B } from "../../icons/src/CalendarIcon.js";
10
11
  import { DownArrowIcon as G } from "../../icons/src/DownArrowIcon.js";
11
- const $ = ({
12
- value: t,
13
- variant: r = "single",
14
- dateFormat: l = "ddd, LL",
15
- placeholder: V = "Select Date",
16
- pickerType: N = "day",
17
- classNames: o = {},
18
- components: P = {},
12
+ const H = ({
13
+ value: e,
14
+ variant: i = "single",
15
+ dateFormat: c = "ddd, LL",
16
+ placeholder: P = "Select Date",
17
+ pickerType: x = "day",
18
+ onChange: r,
19
+ children: a,
20
+ classNames: s = {},
21
+ components: V = {},
19
22
  popoverProps: O,
20
- children: n,
21
- getDayContent: S,
22
- onChange: i,
23
- ...p
23
+ getDayContent: R,
24
+ ...f
24
25
  }) => {
25
- const [j] = m(t), [w, f] = m(t), [c, d] = m(!1), s = () => {
26
- d(!c);
27
- }, a = (b, u, k) => {
28
- r === "single" ? (i == null || i(b, u, k), s()) : i == null || i(b, w, u, k);
29
- }, R = () => {
30
- f(t), i == null || i(t), d(!1);
31
- }, z = () => {
32
- r === "range" && t && typeof t == "object" && "to" in t && !t.to && (i == null || i(j)), s();
26
+ const [S] = n(e), [T, d] = n(e), [l, b] = n(!1), m = () => {
27
+ b(!l);
28
+ }, E = (u, k, y) => {
29
+ i === "single" ? (r == null || r(u, k, y), m()) : r == null || r(u, T, k, y);
30
+ }, g = () => {
31
+ d(e), r == null || r(e), b(!1);
32
+ }, w = () => {
33
+ !(e != null && e.to) && i === "range" && r(S), m();
33
34
  };
34
- return E(() => {
35
- f(t);
36
- }, [t]), /* @__PURE__ */ x(
35
+ j(() => {
36
+ d(e);
37
+ }, [e]);
38
+ const M = F();
39
+ return /* @__PURE__ */ t.createElement(
37
40
  D,
38
41
  {
39
- visible: c,
42
+ visible: l,
40
43
  maxWidth: 900,
41
44
  distance: 18,
42
45
  placement: "bottom",
43
- className: y("ui-date-picker-input", o.popover),
44
- onClickOutside: z,
46
+ className: I("ui-date-picker-input", s.popover),
47
+ onClickOutside: w,
45
48
  ...O,
46
- children: [
47
- n ? L(n, { onClick: s }) : /* @__PURE__ */ e(
48
- I,
49
- {
50
- readOnly: !0,
51
- size: "medium",
52
- value: t ? M(t, l) : "",
53
- placeholder: V,
54
- className: o == null ? void 0 : o.input,
55
- onClick: s
56
- }
57
- ),
58
- /* @__PURE__ */ e(D.Content, { className: "pr-1", children: c && (N === "month" ? /* @__PURE__ */ e(B, { value: t, onChange: a, ...p }) : /* @__PURE__ */ e(
59
- q,
60
- {
61
- variant: r,
62
- getDayContent: S,
63
- value: t,
64
- components: P,
65
- onChange: a,
66
- onSubmitDateRange: R,
67
- ...p
68
- }
69
- )) })
70
- ]
71
- }
49
+ ...M ? { placement: "top", distance: 4 } : {}
50
+ },
51
+ a ? z(a, { onClick: m }) : /* @__PURE__ */ t.createElement(
52
+ p,
53
+ {
54
+ readOnly: !0,
55
+ size: "medium",
56
+ value: e ? A(e, c) : "",
57
+ placeholder: P,
58
+ className: s == null ? void 0 : s.input,
59
+ onClick: m
60
+ }
61
+ ),
62
+ /* @__PURE__ */ t.createElement(D.Content, { className: "pr-1" }, l && (x === "month" ? /* @__PURE__ */ t.createElement(q, { value: e, onChange: E, ...f }) : /* @__PURE__ */ t.createElement(
63
+ N,
64
+ {
65
+ variant: i,
66
+ getDayContent: R,
67
+ value: e,
68
+ components: V,
69
+ onChange: E,
70
+ onSubmitDateRange: g,
71
+ ...f
72
+ }
73
+ )))
72
74
  );
73
- }, I = A(({ className: t, ...r }, l) => /* @__PURE__ */ x("div", { ref: l, className: "relative flex bg-gray-lighter", children: [
74
- /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-0 flex items-center pl-3", children: /* @__PURE__ */ e(F, { className: "z-10 inline-block" }) }),
75
- /* @__PURE__ */ e(W, { className: y("no-translate cursor-pointer px-8", t), ...r }),
76
- /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3", children: /* @__PURE__ */ e(G, { className: "inline-block" }) })
77
- ] }));
78
- I.displayName = "DefaultInput";
75
+ };
76
+ H.propTypes = {
77
+ ...N.propTypes,
78
+ dateFormat: o.string,
79
+ classNames: o.object,
80
+ popoverProps: o.object,
81
+ children: o.node
82
+ };
83
+ const p = L(({ className: e, ...i }, c) => /* @__PURE__ */ t.createElement("div", { ref: c, className: "relative flex bg-gray-lighter" }, /* @__PURE__ */ t.createElement("div", { className: "pointer-events-none absolute inset-0 flex items-center pl-3" }, /* @__PURE__ */ t.createElement(B, { className: "z-10 inline-block" })), /* @__PURE__ */ t.createElement(W, { className: I("no-translate cursor-pointer px-8", e), ...i }), /* @__PURE__ */ t.createElement("div", { className: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3" }, /* @__PURE__ */ t.createElement(G, { className: "inline-block" }))));
84
+ p.displayName = "DefaultInput";
85
+ p.propTypes = {
86
+ className: o.string
87
+ };
79
88
  export {
80
- $ as DatePickerPopover
89
+ H as DatePickerPopover
81
90
  };