@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.
- package/README.md +136 -87
- package/build/components/Alert.js +18 -13
- package/build/components/Animation/FadeIn.js +36 -25
- package/build/components/Animation/SlideDown.js +14 -9
- package/build/components/Avatar.js +17 -10
- package/build/components/Badge.js +33 -24
- package/build/components/BottomSheet.js +114 -0
- package/build/components/Breadcrumb.js +27 -21
- package/build/components/Breakdown.js +66 -74
- package/build/components/Buttons/Button.js +53 -47
- package/build/components/Buttons/ButtonGroup.js +42 -39
- package/build/components/Buttons/SecondaryButton.js +31 -0
- package/build/components/Buttons/SubmitButton.js +72 -66
- package/build/components/Buttons/ToggleButton.js +15 -16
- package/build/components/Counter.js +10 -6
- package/build/components/DatePicker/DatePicker.helpers.js +24 -13
- package/build/components/DatePicker/DatePicker.js +196 -223
- package/build/components/DatePicker/DatePickerPopover.js +75 -66
- package/build/components/DatePicker/Day.js +35 -32
- package/build/components/DatePicker/LocalizedDayPicker.js +15 -18
- package/build/components/DatePicker/MonthGrid.js +35 -48
- package/build/components/DatePicker/MonthPicker.js +25 -20
- package/build/components/DatePicker/MonthSelector.js +39 -40
- package/build/components/DatePicker/MonthYearSelector.js +18 -39
- package/build/components/DatePicker/NavbarElement.js +26 -35
- package/build/components/DatePicker/RangeDatePicker.js +104 -123
- package/build/components/DatePicker/RelativeDateRange.js +153 -143
- package/build/components/DatePicker/UpcomingDatePicker.js +29 -25
- package/build/components/Dot/Dot.js +13 -8
- package/build/components/Dot/DotProgress.js +12 -7
- package/build/components/Drawer.js +109 -101
- package/build/components/Forms/BaseInput.js +50 -34
- package/build/components/Forms/Checkbox.js +33 -30
- package/build/components/Forms/ComboBox.js +35 -35
- package/build/components/Forms/FormGroup.js +7 -3
- package/build/components/Forms/InlineValuePopover.js +33 -39
- package/build/components/Forms/Input.js +15 -7
- package/build/components/Forms/Label.js +14 -8
- package/build/components/Forms/RangeSlider.js +41 -22
- package/build/components/Forms/Select.js +5 -6
- package/build/components/Forms/Switch.js +46 -38
- package/build/components/Forms/Textarea.js +37 -30
- package/build/components/Forms/ValuePopoverText.js +5 -8
- package/build/components/GooglePlacesAutocomplete.js +112 -0
- package/build/components/HeaderToolbar.js +30 -22
- package/build/components/ImageUpload.js +76 -79
- package/build/components/Key.js +21 -16
- package/build/components/Logo.js +12 -5
- package/build/components/Modal.js +87 -72
- package/build/components/Popover/Popover.js +40 -31
- package/build/components/Popover/PopoverList.js +43 -36
- package/build/components/Provider.js +7 -8
- package/build/components/Screens/Login.js +97 -126
- package/build/components/Search.js +114 -144
- package/build/components/Sidebar/Sidebar.Account.js +39 -46
- package/build/components/Sidebar/Sidebar.Button.js +45 -19
- package/build/components/Sidebar/Sidebar.Footer.js +8 -7
- package/build/components/Sidebar/Sidebar.Heading.js +11 -8
- package/build/components/Sidebar/Sidebar.Link.js +79 -44
- package/build/components/Sidebar/Sidebar.Menu.js +52 -28
- package/build/components/Sidebar/Sidebar.Notifications.js +107 -0
- package/build/components/Sidebar/Sidebar.js +207 -214
- package/build/components/Sidebar/SidebarContext.js +15 -0
- package/build/components/Sidebar/sidebarWidth.js +41 -0
- package/build/components/Sidebar/useSidebarWidthState.js +115 -0
- package/build/components/Skeleton.js +19 -20
- package/build/components/Spinner.js +18 -10
- package/build/components/Table.js +86 -50
- package/build/components/Tabs/Tabs.Panel.js +9 -5
- package/build/components/Tabs/Tabs.Tab.js +28 -23
- package/build/components/Tabs/Tabs.js +23 -23
- package/build/components/Tag.js +28 -23
- package/build/components/Tooltip.js +19 -5
- package/build/components/Utilities/Currency.js +49 -42
- package/build/components/Utilities/Number.js +14 -12
- package/build/components/Utilities/Phone.js +18 -12
- package/build/helpers/environment.js +10 -0
- package/build/helpers/flash.js +45 -46
- package/build/hooks/useIsMobile.js +8 -0
- package/build/hooks/useViewportHeight.js +6 -12
- package/build/icons/src/AnnounceIcon.js +3 -4
- package/build/icons/src/BellIcon.js +0 -1
- package/build/icons/src/CalendarIcon.js +0 -1
- package/build/icons/src/CheckIcon.js +0 -1
- package/build/icons/src/ChevronDownIcon.js +4 -5
- package/build/icons/src/ChevronLeftIcon.js +0 -1
- package/build/icons/src/ChevronRightIcon.js +0 -1
- package/build/icons/src/CircleNotch.js +0 -1
- package/build/icons/src/CloseIcon.js +11 -9
- package/build/icons/src/DownArrowIcon.js +0 -1
- package/build/icons/src/ImageIcon.js +0 -1
- package/build/icons/src/SearchIcon.js +4 -5
- package/build/icons/src/TrashIcon.js +0 -1
- package/build/icons/src/WarningDiamondIcon.js +0 -1
- package/build/icons/src/helpers/icon.js +5 -9
- package/build/icons/src/images/XolaLogoSimple.js +2 -3
- package/build/index.js +143 -130
- package/build/style.css +1 -0
- package/build/theme.css +76 -0
- package/build/theme.js +2 -0
- package/build/utils/currency.js +5 -5
- package/build/{helpers → utils}/date.js +17 -20
- package/build/utils/numbers.js +12 -12
- package/build/utils/phone.js +12 -14
- package/build/utils/userLocale.js +6 -0
- package/index.css +96 -4
- package/index.d.ts +204 -0
- package/package.json +87 -77
- package/skills/README.md +27 -0
- package/skills/migrate-2.6-to-3.7/SKILL.md +110 -0
- package/tailwind.config.js +5 -2
- package/build/base.css +0 -2
- package/build/components/Alert.d.ts +0 -18
- package/build/components/Animation/FadeIn.d.ts +0 -13
- package/build/components/Animation/SlideDown.d.ts +0 -6
- package/build/components/Avatar.d.ts +0 -16
- package/build/components/Badge.d.ts +0 -28
- package/build/components/Breadcrumb.d.ts +0 -21
- package/build/components/Breakdown.d.ts +0 -63
- package/build/components/Buttons/Button.d.ts +0 -53
- package/build/components/Buttons/ButtonGroup.d.ts +0 -35
- package/build/components/Buttons/SubmitButton.d.ts +0 -11
- package/build/components/Buttons/ToggleButton.d.ts +0 -21
- package/build/components/Charts/BaseChartOptions.d.ts +0 -136
- package/build/components/Charts/HistogramOptions.d.ts +0 -192
- package/build/components/Charts/PieOptions.d.ts +0 -177
- package/build/components/Counter.d.ts +0 -5
- package/build/components/DatePicker/DatePicker.d.ts +0 -41
- package/build/components/DatePicker/DatePicker.helpers.d.ts +0 -17
- package/build/components/DatePicker/DatePickerPopover.d.ts +0 -29
- package/build/components/DatePicker/Day.d.ts +0 -13
- package/build/components/DatePicker/LocalizedDayPicker.d.ts +0 -6
- package/build/components/DatePicker/MonthGrid.d.ts +0 -11
- package/build/components/DatePicker/MonthPicker.d.ts +0 -7
- package/build/components/DatePicker/MonthSelector.d.ts +0 -8
- package/build/components/DatePicker/MonthYearSelector.d.ts +0 -8
- package/build/components/DatePicker/NavbarElement.d.ts +0 -15
- package/build/components/DatePicker/RangeDatePicker.d.ts +0 -25
- package/build/components/DatePicker/RelativeDateRange.d.ts +0 -51
- package/build/components/DatePicker/UpcomingDatePicker.d.ts +0 -11
- package/build/components/Dot/Dot.d.ts +0 -24
- package/build/components/Dot/DotProgress.d.ts +0 -6
- package/build/components/Drawer.d.ts +0 -28
- package/build/components/Forms/BaseInput.d.ts +0 -20
- package/build/components/Forms/Checkbox.d.ts +0 -10
- package/build/components/Forms/ComboBox.d.ts +0 -8
- package/build/components/Forms/FormGroup.d.ts +0 -5
- package/build/components/Forms/InlineValuePopover.d.ts +0 -17
- package/build/components/Forms/Input.d.ts +0 -6
- package/build/components/Forms/Label.d.ts +0 -7
- package/build/components/Forms/RangeSlider.d.ts +0 -33
- package/build/components/Forms/Select.d.ts +0 -5
- package/build/components/Forms/Switch.d.ts +0 -46
- package/build/components/Forms/Textarea.d.ts +0 -6
- package/build/components/Forms/ValuePopoverText.d.ts +0 -6
- package/build/components/GooglePlacesAutocomplete.d.ts +0 -14
- package/build/components/HeaderToolbar.d.ts +0 -21
- package/build/components/ImageUpload.d.ts +0 -17
- package/build/components/Key.d.ts +0 -6
- package/build/components/Logo.d.ts +0 -19
- package/build/components/Modal.d.ts +0 -52
- package/build/components/Popover/Popover.d.ts +0 -20
- package/build/components/Popover/PopoverList.d.ts +0 -25
- package/build/components/Provider.d.ts +0 -18
- package/build/components/Screens/Login.d.ts +0 -25
- package/build/components/Search.d.ts +0 -16
- package/build/components/Sidebar/Sidebar.Account.d.ts +0 -13
- package/build/components/Sidebar/Sidebar.Button.d.ts +0 -10
- package/build/components/Sidebar/Sidebar.Footer.d.ts +0 -8
- package/build/components/Sidebar/Sidebar.Heading.d.ts +0 -10
- package/build/components/Sidebar/Sidebar.Link.d.ts +0 -24
- package/build/components/Sidebar/Sidebar.Menu.d.ts +0 -13
- package/build/components/Sidebar/Sidebar.d.ts +0 -58
- package/build/components/Sidebar/index.d.ts +0 -8
- package/build/components/Skeleton.d.ts +0 -13
- package/build/components/Spinner.d.ts +0 -26
- package/build/components/Table.d.ts +0 -59
- package/build/components/Tabs/Tabs.Panel.d.ts +0 -9
- package/build/components/Tabs/Tabs.Tab.d.ts +0 -19
- package/build/components/Tabs/Tabs.d.ts +0 -27
- package/build/components/Tabs/index.d.ts +0 -4
- package/build/components/Tag.d.ts +0 -25
- package/build/components/Tooltip.d.ts +0 -8
- package/build/components/Utilities/Currency.d.ts +0 -32
- package/build/components/Utilities/Number.d.ts +0 -8
- package/build/components/Utilities/Phone.d.ts +0 -8
- package/build/full.css +0 -2
- package/build/helpers/avatar.d.ts +0 -1
- package/build/helpers/avatar.js +0 -8
- package/build/helpers/browser.d.ts +0 -2
- package/build/helpers/children.d.ts +0 -3
- package/build/helpers/classnames.d.ts +0 -5
- package/build/helpers/currency.d.ts +0 -2
- package/build/helpers/currency.js +0 -11
- package/build/helpers/date.d.ts +0 -12
- package/build/helpers/flash.d.ts +0 -21
- package/build/helpers/numbers.d.ts +0 -4
- package/build/helpers/numbers.js +0 -23
- package/build/helpers/phone.d.ts +0 -11
- package/build/helpers/phone.js +0 -25
- package/build/hooks/useId.d.ts +0 -1
- package/build/hooks/useId.js +0 -9
- package/build/hooks/useIsClient.d.ts +0 -1
- package/build/hooks/useViewportHeight.d.ts +0 -1
- package/build/icons/src/helpers/classnames.js +0 -8
- package/build/index.d.ts +0 -66
- package/build/theme.d.ts +0 -413
- package/build/types/index.d.ts +0 -22
- package/build/types/migration.d.ts +0 -2
- package/build/ui-kit.css +0 -1
- package/build/utils/avatar.d.ts +0 -1
- package/build/utils/currency.d.ts +0 -2
- package/build/utils/index.d.ts +0 -4
- package/build/utils/numbers.d.ts +0 -4
- package/build/utils/phone.d.ts +0 -2
|
@@ -1,219 +1,212 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { SidebarAccount as
|
|
7
|
-
import { SidebarButton as
|
|
8
|
-
import { SidebarFooter as
|
|
9
|
-
import { SidebarHeading as
|
|
10
|
-
import { SidebarLink as
|
|
11
|
-
import { SidebarMenu as
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
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:
|
|
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
|
-
|
|
11
|
+
r.container
|
|
18
12
|
),
|
|
19
|
-
style: { height:
|
|
20
|
-
...s
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
};
|