@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,219 +1,212 @@
1
- import { jsxs as d, jsx as i } from "react/jsx-runtime";
2
- import $, { useState as x, useRef as K, useEffect as b } from "react";
3
- import s from "../../helpers/classnames.js";
4
- import { Counter as I } from "../Counter.js";
5
- import { Drawer as k } from "../Drawer.js";
6
- import { SidebarAccount as P } from "./Sidebar.Account.js";
7
- import { SidebarButton as U } from "./Sidebar.Button.js";
8
- import { SidebarFooter as _ } from "./Sidebar.Footer.js";
9
- import { SidebarHeading as q } from "./Sidebar.Heading.js";
10
- import { SidebarLink as J, SidebarSeparator as Q } from "./Sidebar.Link.js";
11
- import { SidebarMenu as S } from "./Sidebar.Menu.js";
12
- import V from "./SidebarScroll.module.css.js";
13
- import { AnnounceIcon as Y } from "../../icons/src/AnnounceIcon.js";
14
- import { BellIcon as Z } from "../../icons/src/BellIcon.js";
15
- import { XolaLogoSimple as D } from "../../icons/src/images/XolaLogoSimple.js";
16
- const C = {
17
- // From Figma
18
- background: "linear-gradient(138.65deg, #583DFF 19.59%, #F849C7 62.96%, #FFC03D 97.07%)"
19
- }, p = {
20
- SM: 64,
21
- // Small (mobile)
22
- MD: 134,
23
- // Medium (tablet)
24
- LG: 174,
25
- // Large (small desktop)
26
- XL: 200
27
- // Extra large (desktop)
28
- }, v = {
29
- MD: 768,
30
- LG: 1024,
31
- XL: 1280
32
- }, E = (r = typeof window > "u" ? 1280 : window.innerWidth) => r >= v.XL ? p.XL : r >= v.LG ? p.LG : r >= v.MD ? p.MD : p.SM, l = ({
33
- logo: r,
34
- footer: W,
35
- notifications: z,
36
- isFixed: g = !0,
37
- isStickyHeader: a = !0,
38
- isStickyFooter: y = !0,
39
- isLeftDrawerOpen: F,
40
- isRightDrawerOpen: H,
41
- children: j,
42
- className: X,
43
- onLogoClick: w,
44
- handleDrawerStateChange: o,
45
- onSidebarResize: m
46
- }) => {
47
- const [e, L] = x(() => {
48
- if (typeof window < "u") {
49
- const t = localStorage.getItem("sidebarWidth");
50
- return t ? Number.parseInt(t, 10) : E(window.innerWidth);
51
- }
52
- return 200;
53
- }), [A, N] = x(!1), [u, M] = x(!1), h = K(null), { announcements: c, notices: n } = z ?? {}, B = ((n == null ? void 0 : n.count) ?? 0) <= 0 || !n, R = a && y;
54
- b(() => {
55
- const t = () => {
56
- const f = E(window.innerWidth);
57
- L(f);
58
- };
59
- return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
60
- }, [e]), b(() => {
61
- const t = (T) => {
62
- if (!u || !h.current) return;
63
- const O = Math.min(Math.max(T.clientX, 64), 200);
64
- L(O);
65
- }, f = () => {
66
- M(!1), document.body.style.cursor = "", document.body.style.userSelect = "";
67
- };
68
- return u && (document.addEventListener("mousemove", t), document.addEventListener("mouseup", f), document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none"), () => {
69
- document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", f);
70
- };
71
- }, [u]), b(() => {
72
- if (typeof window < "u" && e) {
73
- const t = setTimeout(() => {
74
- localStorage.setItem("sidebarWidth", e.toString()), m == null || m(e);
75
- }, 500);
76
- return () => clearTimeout(t);
77
- }
78
- }, [e, m]);
79
- const G = (t) => {
80
- t.preventDefault(), M(!0);
81
- };
82
- return /* @__PURE__ */ d(
83
- "div",
84
- {
85
- ref: h,
86
- className: s(
87
- V,
88
- "ui-sidebar",
89
- g ? "fixed" : "relative",
90
- "z-20 flex h-full flex-col overflow-x-hidden border-r-4 border-black bg-black px-1 py-2 text-white transition-all duration-300",
91
- (A || u) && "box-border !border-r-4 !border-yellow",
92
- X
93
- ),
94
- style: { width: `${e}px` },
95
- children: [
96
- /* @__PURE__ */ i(
97
- "div",
98
- {
99
- className: "absolute -right-3 bottom-0 top-0 z-10 w-4 cursor-ew-resize",
100
- onMouseDown: G,
101
- onMouseEnter: () => N(!0),
102
- onMouseLeave: () => N(!1)
103
- }
104
- ),
105
- c ?? n ? /* @__PURE__ */ d(
106
- "div",
107
- {
108
- className: s(
109
- "flex w-full gap-2 p-2",
110
- e <= 78 && "flex-col",
111
- e < 134 ? "justify-center" : "justify-between",
112
- a && "sticky top-0 z-50 bg-black"
113
- ),
114
- children: [
115
- c && /* @__PURE__ */ i("div", { className: s("cursor-pointer text-center", c.hide && "hidden"), children: /* @__PURE__ */ d(
116
- I,
117
- {
118
- style: {
119
- ...C,
120
- minWidth: e > 168 ? "48px" : "30px",
121
- width: e > 168 ? "48px" : "30px",
122
- minHeight: "20px",
123
- height: "20px",
124
- display: "inline-flex",
125
- justifyContent: "center",
126
- alignItems: "center"
127
- },
128
- onClick: () => o == null ? void 0 : o("left"),
129
- children: [
130
- /* @__PURE__ */ i(Y, { className: s(e <= 168 && "hidden") }),
131
- c.count
132
- ]
133
- }
134
- ) }),
135
- n && /* @__PURE__ */ i("div", { className: s("cursor-pointer text-center", B && "hidden"), children: /* @__PURE__ */ d(
136
- I,
137
- {
138
- className: "text-sm",
139
- style: {
140
- minWidth: e > 168 ? "48px" : "30px",
141
- width: e > 168 ? "48px" : "30px",
142
- minHeight: "20px",
143
- height: "20px",
144
- display: "inline-flex",
145
- justifyContent: "center",
146
- alignItems: "center"
147
- },
148
- onClick: () => o == null ? void 0 : o("right"),
149
- children: [
150
- /* @__PURE__ */ i(Z, { className: s(e <= 168 && "hidden") }),
151
- n.count
152
- ]
153
- }
154
- ) })
155
- ]
156
- }
157
- ) : null,
158
- c && /* @__PURE__ */ i(
159
- k,
160
- {
161
- classNames: { dialogContent: `left-[${e}px]` },
162
- sideIndent: e,
163
- position: "left",
164
- size: "xl",
165
- title: c.title,
166
- content: c.content,
167
- isOpen: F ?? !1,
168
- onClose: (t) => !!t && (o == null ? void 0 : o("left"))
169
- }
1
+ import { useMount as ae, useUnmount as ie, useMemoizedFn as m } from "ahooks";
2
+ import e from "prop-types";
3
+ import t, { forwardRef as se, useRef as v, useState as N } from "react";
4
+ import g from "../../helpers/classnames.js";
5
+ import { isDevelopment as le } from "../../helpers/environment.js";
6
+ import { SidebarAccount as ce } from "./Sidebar.Account.js";
7
+ import { SidebarButton as de } from "./Sidebar.Button.js";
8
+ import { SidebarFooter as ue } from "./Sidebar.Footer.js";
9
+ import { SidebarHeading as me } from "./Sidebar.Heading.js";
10
+ import { SidebarLink as fe, SidebarSeparator as pe } from "./Sidebar.Link.js";
11
+ import { hideAllSidebarMenus as y, SidebarMenu as be } from "./Sidebar.Menu.js";
12
+ import { SidebarNotifications as he } from "./Sidebar.Notifications.js";
13
+ import { SidebarVariantContext as Se, SidebarWidthContext as ge } from "./SidebarContext.js";
14
+ import we from "./SidebarScroll.module.css.js";
15
+ import { clampWidth as V, snapWidth as Ce, SIDEBAR_WIDTH as c, SIDEBAR_AUTO_COLLAPSE_VIEWPORT as Ee, SIDEBAR_VARIANT as ve } from "./sidebarWidth.js";
16
+ import { useSidebarWidthState as ye } from "./useSidebarWidthState.js";
17
+ import { XolaLogoSimple as Re } from "../../icons/src/images/XolaLogoSimple.js";
18
+ const xe = 8, Ie = 32, R = /* @__PURE__ */ new Set(), z = (d, f, w) => {
19
+ const a = d[f];
20
+ return a === void 0 ? null : typeof a != "number" || a < c.MIN || a > c.MAX ? new Error(
21
+ `UI Kit: ${w} \`${f}\` must be a number between ${c.MIN} and ${c.MAX}.`
22
+ ) : null;
23
+ }, o = se(
24
+ ({
25
+ logo: d,
26
+ children: f,
27
+ className: w,
28
+ footer: a,
29
+ notifications: L,
30
+ isFixed: W = !0,
31
+ onLogoClick: x,
32
+ isStickyHeader: O = !0,
33
+ isStickyFooter: _ = !0,
34
+ isLeftDrawerOpen: B,
35
+ isRightDrawerOpen: H,
36
+ handleDrawerStateChange: K,
37
+ onSidebarResize: U,
38
+ variant: I,
39
+ isCollapsed: k,
40
+ minWidth: i = c.MIN,
41
+ maxWidth: F = c.MAX,
42
+ autoCollapseBelow: X = Ee,
43
+ storageKey: $ = "sidebarWidth",
44
+ cssVariableTarget: j,
45
+ onCollapsedChange: Z,
46
+ onVariantChange: q
47
+ }, G) => {
48
+ const P = v(!1);
49
+ le && (I !== void 0 && k !== void 0) && !P.current && (P.current = !0, console.warn("UI Kit: Sidebar received both `variant` and `isCollapsed`; `variant` wins."));
50
+ const J = k ?? !1, { width: s, setWidth: Q, commitWidth: C, variantValue: p, effectiveMaxWidth: l, resolvedCssVariableTarget: b } = ye({
51
+ storageKey: $,
52
+ minWidth: i,
53
+ maxWidth: F,
54
+ variant: I,
55
+ isCollapsedProperty: J,
56
+ autoCollapseBelow: X,
57
+ cssVariableTarget: j,
58
+ onSidebarResize: U,
59
+ onVariantChange: q,
60
+ onCollapsedChange: Z
61
+ }), h = v(null);
62
+ ae(() => {
63
+ b && (R.has(b) && console.warn(
64
+ "UI Kit: Multiple Sidebars share the same `cssVariableTarget`; each write overwrites the others."
65
+ ), R.add(b), h.current = b);
66
+ }), ie(() => {
67
+ h.current && (R.delete(h.current), h.current = null);
68
+ });
69
+ const [Y, T] = N(!1), [E, D] = N(!1), M = v(0), ee = m((r) => {
70
+ var n;
71
+ r.preventDefault(), y(), M.current = ((n = r.currentTarget.parentElement) == null ? void 0 : n.getBoundingClientRect().left) ?? 0, D(!0);
72
+ try {
73
+ r.currentTarget.setPointerCapture(r.pointerId);
74
+ } catch {
75
+ }
76
+ }), re = m((r) => {
77
+ E && Q(V(r.clientX - M.current, i, l));
78
+ }), A = m((r) => {
79
+ var n, u;
80
+ (u = (n = r.currentTarget).hasPointerCapture) != null && u.call(n, r.pointerId) && r.currentTarget.releasePointerCapture(r.pointerId), D(!1), C(Ce(s, i, l));
81
+ }), te = m((r) => {
82
+ const n = r.shiftKey ? Ie : xe, u = { ArrowLeft: -n, ArrowRight: n };
83
+ let S;
84
+ if (r.key === "Home")
85
+ S = i;
86
+ else if (r.key === "End")
87
+ S = l;
88
+ else if (u[r.key] !== void 0)
89
+ S = V(s + u[r.key], i, l);
90
+ else
91
+ return;
92
+ r.preventDefault(), y(), C(S);
93
+ }), oe = m(() => {
94
+ y(), C(l);
95
+ }), ne = d ? t.cloneElement(d, {
96
+ className: g("inline-block h-12 w-12", p.showText && "h-30 w-30", d.props.className)
97
+ }) : /* @__PURE__ */ t.createElement(
98
+ Re,
99
+ {
100
+ className: g(
101
+ "inline-block h-12 w-12",
102
+ p.showText && "h-30 w-30",
103
+ x && "cursor-pointer transition-opacity hover:opacity-80"
170
104
  ),
171
- n && /* @__PURE__ */ i(
172
- k,
173
- {
174
- classNames: { dialogContent: `left-[${e}px]` },
175
- position: "left",
176
- sideIndent: e,
177
- size: "xl",
178
- title: n.title,
179
- content: n.content,
180
- isOpen: H ?? !1,
181
- onClose: (t) => !!t && (o == null ? void 0 : o("right"))
182
- }
105
+ onClick: x
106
+ }
107
+ );
108
+ return /* @__PURE__ */ t.createElement(Se.Provider, { value: p }, /* @__PURE__ */ t.createElement(ge.Provider, { value: s }, /* @__PURE__ */ t.createElement(
109
+ "div",
110
+ {
111
+ ref: G,
112
+ className: g(
113
+ we,
114
+ "ui-sidebar",
115
+ W ? "fixed" : "relative",
116
+ "z-20 flex h-full flex-col border-r-4 border-black bg-black px-1 py-2 text-white transition-all duration-300",
117
+ (Y || E) && "box-border !border-r-4 !border-yellow",
118
+ // Per-pointermove width writes would each restart the 300ms interpolation,
119
+ // so the rail trails the cursor. Snap on release still animates.
120
+ E && "!transition-none",
121
+ w
183
122
  ),
184
- /* @__PURE__ */ d("div", { className: s("flex-grow space-y-2", R && "overflow-y-auto overflow-x-hidden"), children: [
185
- e > 60 && /* @__PURE__ */ i("div", { className: "text-center", children: r ? $.cloneElement(r, {
186
- className: s(
187
- "inline-block",
188
- "h-12 w-12",
189
- e > 160 && "h-30 w-30",
190
- r.props.className
191
- )
192
- }) : e > 90 && /* @__PURE__ */ i(
193
- D,
194
- {
195
- className: s(
196
- "inline-block h-12 w-12 ",
197
- e > 160 && "h-30 w-30",
198
- w !== void 0 && "cursor-pointer transition-opacity hover:opacity-80"
199
- ),
200
- onClick: w
201
- }
202
- ) }),
203
- /* @__PURE__ */ i("div", { children: j })
204
- ] }),
205
- /* @__PURE__ */ i("div", { className: s(y && "sticky bottom-0 bg-black"), children: W })
206
- ]
207
- }
208
- );
123
+ style: { width: `${s}px` }
124
+ },
125
+ /* @__PURE__ */ t.createElement(
126
+ "div",
127
+ {
128
+ role: "separator",
129
+ "aria-orientation": "vertical",
130
+ "aria-label": "Resize sidebar",
131
+ "aria-valuenow": s,
132
+ "aria-valuemin": i,
133
+ "aria-valuemax": l,
134
+ tabIndex: 0,
135
+ className: "absolute -right-3 bottom-0 top-0 z-10 w-6 cursor-ew-resize touch-none",
136
+ onPointerDown: ee,
137
+ onPointerMove: re,
138
+ onPointerUp: A,
139
+ onPointerCancel: A,
140
+ onKeyDown: te,
141
+ onDoubleClick: oe,
142
+ onMouseEnter: () => T(!0),
143
+ onMouseLeave: () => T(!1)
144
+ }
145
+ ),
146
+ /* @__PURE__ */ t.createElement(
147
+ he,
148
+ {
149
+ notifications: L,
150
+ isCollapsed: p.isCollapsed,
151
+ isSticky: O,
152
+ width: s,
153
+ isLeftDrawerOpen: B,
154
+ isRightDrawerOpen: H,
155
+ onDrawerStateChange: K
156
+ }
157
+ ),
158
+ /* @__PURE__ */ t.createElement("div", { className: "shrink-0 pb-2 text-center" }, ne),
159
+ /* @__PURE__ */ t.createElement("div", { className: "min-h-0 flex-grow space-y-2 overflow-y-auto" }, f),
160
+ /* @__PURE__ */ t.createElement("div", { className: g(_ && "sticky bottom-0 bg-black") }, a)
161
+ )));
162
+ }
163
+ );
164
+ o.displayName = "Sidebar";
165
+ o.propTypes = {
166
+ logo: e.element,
167
+ children: e.node.isRequired,
168
+ className: e.string,
169
+ footer: e.element,
170
+ isFixed: e.bool,
171
+ isStickyHeader: e.bool,
172
+ isStickyFooter: e.bool,
173
+ onLogoClick: e.func,
174
+ isLeftDrawerOpen: e.bool,
175
+ isRightDrawerOpen: e.bool,
176
+ handleDrawerStateChange: e.func,
177
+ onSidebarResize: e.func,
178
+ variant: e.oneOf(Object.values(ve)),
179
+ minWidth: z,
180
+ maxWidth: z,
181
+ isCollapsed: e.bool,
182
+ onCollapsedChange: e.func,
183
+ onVariantChange: e.func,
184
+ autoCollapseBelow: e.number,
185
+ storageKey: e.string,
186
+ cssVariableTarget: e.object,
187
+ notifications: e.shape({
188
+ announcements: e.shape({
189
+ count: e.number,
190
+ content: e.node,
191
+ title: e.string,
192
+ hide: e.bool,
193
+ onClose: e.func
194
+ }),
195
+ notices: e.shape({
196
+ count: e.number,
197
+ content: e.node,
198
+ title: e.string,
199
+ onClose: e.func
200
+ })
201
+ })
209
202
  };
210
- l.Account = P;
211
- l.Button = U;
212
- l.Footer = _;
213
- l.Link = J;
214
- l.Separator = Q;
215
- l.Menu = S;
216
- l.Heading = q;
203
+ o.Account = ce;
204
+ o.Button = de;
205
+ o.Footer = ue;
206
+ o.Link = fe;
207
+ o.Separator = pe;
208
+ o.Menu = be;
209
+ o.Heading = me;
217
210
  export {
218
- l as Sidebar
211
+ o as Sidebar
219
212
  };
@@ -0,0 +1,15 @@
1
+ import { useContext as o, createContext as s } from "react";
2
+ import { SIDEBAR_VARIANT as e, SIDEBAR_WIDTH as n } from "./sidebarWidth.js";
3
+ const r = (t) => ({
4
+ variant: t,
5
+ showIcons: t !== e.TEXT,
6
+ showText: t !== e.ICONS,
7
+ isCollapsed: t === e.ICONS
8
+ }), C = s(r(e.ICONS_AND_TEXT)), S = s(n.MAX), c = () => o(C), d = () => o(S);
9
+ export {
10
+ C as SidebarVariantContext,
11
+ S as SidebarWidthContext,
12
+ c as useSidebar,
13
+ d as useSidebarWidth,
14
+ r as variantContextValue
15
+ };
@@ -0,0 +1,41 @@
1
+ const I = { MIN: 64, MAX: 200 }, u = { ICONS: "icons", TEXT: "text", ICONS_AND_TEXT: "iconsAndText" }, c = { TEXT: 140, ICONS_AND_TEXT: 174 }, S = 1024, E = 24, X = (r) => r >= c.ICONS_AND_TEXT ? u.ICONS_AND_TEXT : r >= c.TEXT ? u.TEXT : u.ICONS, f = (r) => r === u.ICONS ? I.MIN : r === u.TEXT ? c.ICONS_AND_TEXT - 1 : I.MAX, A = (r, n, t) => {
2
+ if (r == null || typeof r == "string" && r.trim() === "")
3
+ return t;
4
+ const e = Number(r);
5
+ return Number.isFinite(e) ? Math.min(Math.max(e, n), t) : t;
6
+ }, C = (r, n, t) => {
7
+ const T = [n, c.TEXT, c.ICONS_AND_TEXT, t].filter(
8
+ (s) => s >= n && s <= t
9
+ ).filter((s) => Math.abs(s - r) <= E), o = T.length > 0 ? T.sort((s, N) => Math.abs(s - r) - Math.abs(N - r))[0] : r;
10
+ return A(o, n, t);
11
+ }, O = ({ storedWidth: r, hasIntent: n, viewportWidth: t, minWidth: e, maxWidth: T, autoCollapseBelow: o }) => {
12
+ const s = A(r, e, T);
13
+ return o != null && t < o && !n ? e : s;
14
+ }, _ = (r, n, t) => A(r ?? t, n, t), l = ({
15
+ width: r,
16
+ lastExpandedWidth: n,
17
+ wasBelow: t,
18
+ isBelow: e,
19
+ hasIntentBelow: T,
20
+ minWidth: o,
21
+ maxWidth: s
22
+ }) => e && !t && !T ? { width: o, lastExpandedWidth: r > o ? r : n } : !e && t ? {
23
+ width: _(n, o, s),
24
+ lastExpandedWidth: n
25
+ } : { width: r, lastExpandedWidth: n }, D = ({ width: r, lastExpandedWidth: n, minWidth: t, maxWidth: e }) => r > t ? { width: t, lastExpandedWidth: r } : {
26
+ width: _(n, t, e),
27
+ lastExpandedWidth: n
28
+ };
29
+ export {
30
+ S as SIDEBAR_AUTO_COLLAPSE_VIEWPORT,
31
+ u as SIDEBAR_VARIANT,
32
+ c as SIDEBAR_VARIANT_WIDTH,
33
+ I as SIDEBAR_WIDTH,
34
+ f as ceilingForVariant,
35
+ A as clampWidth,
36
+ l as resolveCrossingWidth,
37
+ O as resolveMountWidth,
38
+ D as resolveToggleWidth,
39
+ C as snapWidth,
40
+ X as variantForWidth
41
+ };
@@ -0,0 +1,115 @@
1
+ import { useMemoizedFn as d, useEventListener as Q, useIsomorphicLayoutEffect as Y, useThrottleFn as y, useUpdateEffect as P, useLatest as g } from "ahooks";
2
+ import { useState as V, useRef as x, useEffect as k, useMemo as C } from "react";
3
+ import { variantContextValue as K } from "./SidebarContext.js";
4
+ import { ceilingForVariant as H, SIDEBAR_VARIANT as T, resolveMountWidth as tt, clampWidth as nt, variantForWidth as et, resolveCrossingWidth as rt, resolveToggleWidth as it } from "./sidebarWidth.js";
5
+ const dt = 1280, st = 100, o = typeof window > "u", c = (n) => n ? { width: n, preferred: `${n}:preferred`, intent: `${n}:intent` } : null, _ = (n) => {
6
+ if (o)
7
+ return null;
8
+ try {
9
+ return window.localStorage.getItem(n);
10
+ } catch {
11
+ return null;
12
+ }
13
+ }, w = (n, e) => {
14
+ if (!o)
15
+ try {
16
+ window.localStorage.setItem(n, e);
17
+ } catch {
18
+ }
19
+ }, $ = (n) => {
20
+ const e = c(n);
21
+ return !!e && _(e.intent) === "1";
22
+ }, ft = ({
23
+ storageKey: n,
24
+ minWidth: e,
25
+ maxWidth: M,
26
+ variant: v,
27
+ isCollapsedProperty: W,
28
+ autoCollapseBelow: s,
29
+ cssVariableTarget: R,
30
+ onSidebarResize: a,
31
+ onVariantChange: m,
32
+ onCollapsedChange: p
33
+ }) => {
34
+ const u = R === void 0 ? o ? void 0 : document.documentElement : R, h = Math.min(
35
+ M,
36
+ H(v ?? (W ? T.ICONS : T.ICONS_AND_TEXT))
37
+ ), U = Math.min(M, H(v ?? T.ICONS_AND_TEXT)), L = () => {
38
+ if (!n)
39
+ return null;
40
+ const t = c(n);
41
+ return _(t.preferred) ?? _(t.width);
42
+ }, [r, f] = V(() => {
43
+ const t = tt({
44
+ storedWidth: L(),
45
+ hasIntent: $(n),
46
+ viewportWidth: o ? dt : window.innerWidth,
47
+ minWidth: e,
48
+ maxWidth: h,
49
+ autoCollapseBelow: s
50
+ });
51
+ return n && w(c(n).width, String(t)), t;
52
+ }), [S, N] = V(() => {
53
+ const t = nt(L(), e, h);
54
+ return t > e ? t : null;
55
+ }), A = x(!o && window.innerWidth < (s ?? 0)), F = x($(n)), l = et(r), E = r <= e, X = d(() => {
56
+ const t = window.innerWidth < s, i = rt({
57
+ width: r,
58
+ lastExpandedWidth: S,
59
+ wasBelow: A.current,
60
+ isBelow: t,
61
+ hasIntentBelow: F.current,
62
+ minWidth: e,
63
+ maxWidth: h
64
+ });
65
+ A.current = t, !(i.width === r && i.lastExpandedWidth === S) && (f(i.width), N(i.lastExpandedWidth));
66
+ });
67
+ Q("resize", X, { enable: s != null });
68
+ const Z = d((t) => a == null ? void 0 : a(t)), O = d((t) => m == null ? void 0 : m(t)), b = d((t) => p == null ? void 0 : p(t));
69
+ Y(() => {
70
+ u && u.style.setProperty("--ui-sidebar-width", `${r}px`);
71
+ }, [r, u]);
72
+ const B = x(null), j = d((t) => {
73
+ B.current !== t && (B.current = t, n && w(c(n).width, String(t)), Z(t));
74
+ }), { run: I, flush: q } = y(j, {
75
+ wait: st
76
+ });
77
+ k(() => {
78
+ I(r);
79
+ }, [r, I]), k(() => {
80
+ O(l);
81
+ }, [l, O]), P(() => {
82
+ b(E);
83
+ }, [E, b]);
84
+ const D = g({
85
+ width: r,
86
+ lastExpandedWidth: S,
87
+ isWidthCollapsed: E,
88
+ minWidth: e,
89
+ uncollapsedMaxWidth: U
90
+ });
91
+ P(() => {
92
+ const t = D.current;
93
+ if (W === t.isWidthCollapsed)
94
+ return;
95
+ const i = it({
96
+ width: t.width,
97
+ lastExpandedWidth: t.lastExpandedWidth,
98
+ minWidth: t.minWidth,
99
+ maxWidth: t.uncollapsedMaxWidth
100
+ });
101
+ f(i.width), N(i.lastExpandedWidth);
102
+ }, [W, D]);
103
+ const z = C(() => K(l), [l]), G = d((t) => {
104
+ if (window.innerWidth < (s ?? 0) && (F.current = !0), !n)
105
+ return;
106
+ const i = c(n);
107
+ w(i.intent, "1"), w(i.preferred, String(t));
108
+ }), J = d((t) => {
109
+ G(t), t !== r && (f(t), I(t), q());
110
+ });
111
+ return { width: r, setWidth: f, commitWidth: J, variantValue: z, effectiveMaxWidth: h, resolvedCssVariableTarget: u };
112
+ };
113
+ export {
114
+ ft as useSidebarWidthState
115
+ };
@@ -1,29 +1,28 @@
1
- import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
- import r from "../helpers/classnames.js";
3
- import d from "./Skeleton.module.css.js";
4
- const c = ({
5
- style: l,
6
- height: i = 300,
7
- shouldAnimate: o = !0,
8
- children: n,
9
- classNames: e = {},
10
- ...s
11
- }) => /* @__PURE__ */ m(
1
+ import e from "prop-types";
2
+ import t from "react";
3
+ import o from "../helpers/classnames.js";
4
+ import a from "./Skeleton.module.css.js";
5
+ const c = ({ style: l, height: n = 300, shouldAnimate: i = !0, children: m, classNames: r = {}, ...s }) => /* @__PURE__ */ t.createElement(
12
6
  "div",
13
7
  {
14
- className: r(
8
+ className: o(
15
9
  "ui-skeleton",
16
10
  "relative flex items-center justify-center overflow-hidden rounded border border-gray-lighter bg-gray-lighter",
17
- e.container
11
+ r.container
18
12
  ),
19
- style: { height: i, ...l },
20
- ...s,
21
- children: [
22
- o ? /* @__PURE__ */ t("div", { className: r(d.shimmer, "absolute h-full w-full", e.shimmer) }) : null,
23
- /* @__PURE__ */ t("div", { className: r("text-gray", e.text), children: n })
24
- ]
25
- }
13
+ style: { height: n, ...l },
14
+ ...s
15
+ },
16
+ i ? /* @__PURE__ */ t.createElement("div", { className: o(a.shimmer, "absolute h-full w-full", r.shimmer) }) : null,
17
+ /* @__PURE__ */ t.createElement("div", { className: o("text-gray", r.text) }, m)
26
18
  );
19
+ c.propTypes = {
20
+ style: e.object,
21
+ height: e.oneOfType([e.number, e.string]),
22
+ shouldAnimate: e.bool,
23
+ classNames: e.object,
24
+ children: e.oneOfType([e.arrayOf(e.node), e.node])
25
+ };
27
26
  export {
28
27
  c as Skeleton
29
28
  };