@xola/ui-kit 3.6.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 +98 -19
- package/build/components/Alert.js +29 -0
- package/build/components/Animation/FadeIn.js +40 -0
- package/build/components/Animation/SlideDown.js +25 -0
- package/build/components/Avatar.js +28 -0
- package/build/components/Badge.js +51 -0
- package/build/components/BottomSheet.js +114 -0
- package/build/components/Breadcrumb.js +33 -0
- package/build/components/Breakdown.js +81 -0
- package/build/components/Buttons/Button.js +89 -0
- package/build/components/Buttons/ButtonGroup.js +58 -0
- package/build/components/Buttons/SecondaryButton.js +31 -0
- package/build/components/Buttons/SubmitButton.js +89 -0
- package/build/components/Buttons/ToggleButton.js +33 -0
- package/build/components/Charts/BaseChartOptions.js +95 -0
- package/build/components/Charts/HistogramOptions.js +69 -0
- package/build/components/Charts/PieOptions.js +55 -0
- package/build/components/Counter.js +20 -0
- package/build/components/DatePicker/DatePicker.helpers.js +33 -0
- package/build/components/DatePicker/DatePicker.js +214 -0
- package/build/components/DatePicker/DatePickerPopover.js +90 -0
- package/build/components/DatePicker/Day.js +43 -0
- package/build/components/DatePicker/LocalizedDayPicker.js +17 -0
- package/build/components/DatePicker/MonthGrid.js +39 -0
- package/build/components/DatePicker/MonthPicker.js +33 -0
- package/build/components/DatePicker/MonthSelector.js +46 -0
- package/build/components/DatePicker/MonthYearSelector.js +23 -0
- package/build/components/DatePicker/NavbarElement.js +34 -0
- package/build/components/DatePicker/RangeDatePicker.js +111 -0
- package/build/components/DatePicker/RelativeDateRange.js +290 -0
- package/build/components/DatePicker/UpcomingDatePicker.js +31 -0
- package/build/components/Dot/Dot.js +29 -0
- package/build/components/Dot/DotProgress.js +15 -0
- package/build/components/Drawer.js +134 -0
- package/build/components/Forms/BaseInput.js +57 -0
- package/build/components/Forms/Checkbox.js +37 -0
- package/build/components/Forms/Checkbox.module.css.js +7 -0
- package/build/components/Forms/ComboBox.js +41 -0
- package/build/components/Forms/FormGroup.js +10 -0
- package/build/components/Forms/InlineValuePopover.js +41 -0
- package/build/components/Forms/Input.js +17 -0
- package/build/components/Forms/Label.js +23 -0
- package/build/components/Forms/RangeSlider.js +58 -0
- package/build/components/Forms/Select.js +7 -0
- package/build/components/Forms/Switch.js +70 -0
- package/build/components/Forms/Textarea.js +42 -0
- package/build/components/Forms/ValuePopoverText.js +7 -0
- package/build/components/GooglePlacesAutocomplete.js +112 -0
- package/build/components/HeaderToolbar.js +41 -0
- package/build/components/ImageUpload.js +83 -0
- package/build/components/Key.js +33 -0
- package/build/components/Logo.js +17 -0
- package/build/components/Modal.js +141 -0
- package/build/components/Popover/Popover.js +53 -0
- package/build/components/Popover/Popover.module.css.js +7 -0
- package/build/components/Popover/PopoverList.js +57 -0
- package/build/components/Popover/PopoverScroll.module.css.js +4 -0
- package/build/components/Provider.js +16 -0
- package/build/components/Screens/Login.js +115 -0
- package/build/components/Search.js +144 -0
- package/build/components/Sidebar/Sidebar.Account.js +49 -0
- package/build/components/Sidebar/Sidebar.Button.js +47 -0
- package/build/components/Sidebar/Sidebar.Footer.js +10 -0
- package/build/components/Sidebar/Sidebar.Heading.js +13 -0
- package/build/components/Sidebar/Sidebar.Link.js +92 -0
- package/build/components/Sidebar/Sidebar.Menu.js +54 -0
- package/build/components/Sidebar/Sidebar.Menu.module.css.js +7 -0
- package/build/components/Sidebar/Sidebar.Notifications.js +107 -0
- package/build/components/Sidebar/Sidebar.js +212 -0
- package/build/components/Sidebar/SidebarContext.js +15 -0
- package/build/components/Sidebar/SidebarScroll.module.css.js +4 -0
- package/build/components/Sidebar/sidebarWidth.js +41 -0
- package/build/components/Sidebar/useSidebarWidthState.js +115 -0
- package/build/components/Skeleton.js +28 -0
- package/build/components/Skeleton.module.css.js +7 -0
- package/build/components/Spinner.js +35 -0
- package/build/components/Table.js +107 -0
- package/build/components/Tabs/Tabs.Panel.js +11 -0
- package/build/components/Tabs/Tabs.Tab.js +42 -0
- package/build/components/Tabs/Tabs.js +28 -0
- package/build/components/Tag.js +41 -0
- package/build/components/Tooltip.js +22 -0
- package/build/components/Utilities/Currency.js +56 -0
- package/build/components/Utilities/Number.js +17 -0
- package/build/components/Utilities/Phone.js +25 -0
- package/build/helpers/browser.js +9 -0
- package/build/helpers/children.js +6 -0
- package/build/helpers/classnames.js +8 -0
- package/build/helpers/environment.js +10 -0
- package/build/helpers/flash.js +86 -0
- package/build/hooks/useIsClient.js +10 -0
- package/build/hooks/useIsMobile.js +8 -0
- package/build/hooks/useViewportHeight.js +9 -0
- package/build/icons/src/AnnounceIcon.js +12 -0
- package/build/icons/src/BellIcon.js +26 -0
- package/build/icons/src/CalendarIcon.js +15 -0
- package/build/icons/src/CheckIcon.js +7 -0
- package/build/icons/src/ChevronDownIcon.js +7 -0
- package/build/icons/src/ChevronLeftIcon.js +7 -0
- package/build/icons/src/ChevronRightIcon.js +7 -0
- package/build/icons/src/CircleNotch.js +5 -0
- package/build/icons/src/CloseIcon.js +13 -0
- package/build/icons/src/DownArrowIcon.js +15 -0
- package/build/icons/src/ImageIcon.js +26 -0
- package/build/icons/src/SearchIcon.js +15 -0
- package/build/icons/src/TrashIcon.js +19 -0
- package/build/icons/src/WarningDiamondIcon.js +26 -0
- package/build/icons/src/helpers/icon.js +7 -0
- package/build/icons/src/helpers/iconSizes.js +13 -0
- package/build/icons/src/images/XolaLogoSimple.js +13 -0
- package/build/index.js +155 -0
- package/build/style.css +1 -1
- package/build/theme.js +374 -0
- package/build/utils/avatar.js +8 -0
- package/build/utils/currency.js +11 -0
- package/build/utils/date.js +46 -0
- package/build/utils/numbers.js +19 -0
- package/build/utils/phone.js +15 -0
- package/build/utils/userLocale.js +6 -0
- package/index.d.ts +132 -79
- package/package.json +76 -45
- package/postcss.config.js +1 -1
- package/skills/README.md +27 -0
- package/skills/migrate-2.6-to-3.7/SKILL.md +110 -0
- package/tailwind.config.js +9 -5
- package/build/ui-kit.es.js +0 -16771
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import t from "prop-types";
|
|
2
|
+
import r from "react";
|
|
3
|
+
import n from "../../helpers/classnames.js";
|
|
4
|
+
import { Dot as x } from "../Dot/Dot.js";
|
|
5
|
+
import { useSidebar as c } from "./SidebarContext.js";
|
|
6
|
+
import { ChevronRightIcon as k } from "../../icons/src/ChevronRightIcon.js";
|
|
7
|
+
const l = ({
|
|
8
|
+
isActive: i = !1,
|
|
9
|
+
hasSubmenu: h = !1,
|
|
10
|
+
icon: p,
|
|
11
|
+
info: g,
|
|
12
|
+
children: d,
|
|
13
|
+
isSubMenuItem: f,
|
|
14
|
+
align: y,
|
|
15
|
+
classNames: e,
|
|
16
|
+
className: m,
|
|
17
|
+
...b
|
|
18
|
+
}) => {
|
|
19
|
+
const { showIcons: a, showText: o } = c();
|
|
20
|
+
return f ? /* @__PURE__ */ r.createElement(
|
|
21
|
+
"button",
|
|
22
|
+
{
|
|
23
|
+
type: "button",
|
|
24
|
+
className: n(
|
|
25
|
+
"ui-sidebar-link",
|
|
26
|
+
"flex w-full items-center justify-start rounded px-6 py-2 leading-none transition-colors",
|
|
27
|
+
i ? "bg-primary text-white hover:bg-primary-dark" : "text-gray hover:bg-gray-darker",
|
|
28
|
+
e == null ? void 0 : e.button,
|
|
29
|
+
m
|
|
30
|
+
),
|
|
31
|
+
...b
|
|
32
|
+
},
|
|
33
|
+
/* @__PURE__ */ r.createElement(x, { className: n("mr-3 shrink-0", i ? "bg-white" : "bg-gray") }),
|
|
34
|
+
/* @__PURE__ */ r.createElement("span", { className: n("px-1 text-left", e == null ? void 0 : e.text) }, d)
|
|
35
|
+
) : /* @__PURE__ */ r.createElement(
|
|
36
|
+
"button",
|
|
37
|
+
{
|
|
38
|
+
type: "button",
|
|
39
|
+
className: n(
|
|
40
|
+
"ui-sidebar-link",
|
|
41
|
+
"flex h-10 w-full items-center rounded leading-none transition-colors",
|
|
42
|
+
"py-3",
|
|
43
|
+
o ? "justify-start" : "justify-center px-2",
|
|
44
|
+
// No icon: the label sits nearer the edge instead of holding open the icon's gutter.
|
|
45
|
+
o && (a ? "px-6" : "px-3"),
|
|
46
|
+
i ? "bg-primary text-white hover:bg-primary-dark" : "text-gray hover:bg-gray-darker",
|
|
47
|
+
e == null ? void 0 : e.button,
|
|
48
|
+
m
|
|
49
|
+
),
|
|
50
|
+
...b
|
|
51
|
+
},
|
|
52
|
+
/* @__PURE__ */ r.createElement("div", { className: n("shrink-0", !a && "hidden") }, p && /* @__PURE__ */ r.createElement(p, { className: n("h-5 w-5 shrink-0", a && o && "mr-3") })),
|
|
53
|
+
/* @__PURE__ */ r.createElement(
|
|
54
|
+
"span",
|
|
55
|
+
{
|
|
56
|
+
className: n(
|
|
57
|
+
// leading-5 overrides the button's leading-none: `truncate` hides overflow, so a
|
|
58
|
+
// line box only as tall as the cap height clips the descenders off g, y, p.
|
|
59
|
+
"min-w-0 truncate px-1 leading-5",
|
|
60
|
+
!o && "hidden",
|
|
61
|
+
y === "left" && "text-left",
|
|
62
|
+
e == null ? void 0 : e.text
|
|
63
|
+
)
|
|
64
|
+
},
|
|
65
|
+
d
|
|
66
|
+
),
|
|
67
|
+
g ?? (h && /* @__PURE__ */ r.createElement(k, { className: n("ml-auto h-3 w-3 shrink-0", !o && "hidden") }))
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
l.displayName = "Sidebar.Link";
|
|
71
|
+
l.propTypes = {
|
|
72
|
+
align: t.oneOf(["center", "left", "right"]),
|
|
73
|
+
isActive: t.bool,
|
|
74
|
+
hasSubmenu: t.bool,
|
|
75
|
+
icon: t.func,
|
|
76
|
+
// A consumer-supplied trailing node. Rendered in every variant, unlike the default chevron:
|
|
77
|
+
// it carries opt-in content such as a badge or a portal target that must survive the rail.
|
|
78
|
+
info: t.node,
|
|
79
|
+
children: t.node.isRequired,
|
|
80
|
+
isSubMenuItem: t.bool,
|
|
81
|
+
className: t.string,
|
|
82
|
+
classNames: t.shape({ button: t.string, text: t.string })
|
|
83
|
+
};
|
|
84
|
+
const u = ({ className: i }) => /* @__PURE__ */ r.createElement("hr", { className: n("mx-3 my-4 border-gray-lighter/20", i) });
|
|
85
|
+
u.displayName = "Sidebar.Separator";
|
|
86
|
+
u.propTypes = {
|
|
87
|
+
className: t.string
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
l as SidebarLink,
|
|
91
|
+
u as SidebarSeparator
|
|
92
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import b from "@tippyjs/react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import s from "react";
|
|
4
|
+
import E from "../../helpers/classnames.js";
|
|
5
|
+
import T from "./Sidebar.Menu.module.css.js";
|
|
6
|
+
const h = typeof window > "u" ? void 0 : window.document.body, y = 24, R = 75, g = [150, 100], I = [200, 0], r = /* @__PURE__ */ new Set(), a = (o) => {
|
|
7
|
+
for (const n of r)
|
|
8
|
+
n !== o && n.hide();
|
|
9
|
+
}, C = () => a(null), l = ({ children: o, content: n, onShow: i, onHidden: c, onDestroy: d, ...p }) => {
|
|
10
|
+
const m = (e) => (a(e), r.add(e), i == null ? void 0 : i(e)), u = (e) => {
|
|
11
|
+
r.delete(e), c == null || c(e);
|
|
12
|
+
}, f = (e) => {
|
|
13
|
+
r.delete(e), d == null || d(e);
|
|
14
|
+
};
|
|
15
|
+
return /* @__PURE__ */ s.createElement(
|
|
16
|
+
b,
|
|
17
|
+
{
|
|
18
|
+
interactive: !0,
|
|
19
|
+
arrow: !1,
|
|
20
|
+
trigger: "mouseenter",
|
|
21
|
+
hideOnClick: "toggle",
|
|
22
|
+
appendTo: h,
|
|
23
|
+
placement: "right",
|
|
24
|
+
offset: [0, 4],
|
|
25
|
+
interactiveBorder: y,
|
|
26
|
+
interactiveDebounce: R,
|
|
27
|
+
delay: g,
|
|
28
|
+
duration: I,
|
|
29
|
+
content: n,
|
|
30
|
+
className: E(
|
|
31
|
+
"ui-sidebar-menu",
|
|
32
|
+
T.main,
|
|
33
|
+
"!rounded-none bg-black bg-opacity-90 p-2 backdrop-blur-sm backdrop-filter"
|
|
34
|
+
),
|
|
35
|
+
onShow: m,
|
|
36
|
+
onHidden: u,
|
|
37
|
+
onDestroy: f,
|
|
38
|
+
...p
|
|
39
|
+
},
|
|
40
|
+
/* @__PURE__ */ s.createElement("span", { className: "block" }, o)
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
l.displayName = "Sidebar.Menu";
|
|
44
|
+
l.propTypes = {
|
|
45
|
+
children: t.node.isRequired,
|
|
46
|
+
content: t.node.isRequired,
|
|
47
|
+
onShow: t.func,
|
|
48
|
+
onHidden: t.func,
|
|
49
|
+
onDestroy: t.func
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
l as SidebarMenu,
|
|
53
|
+
C as hideAllSidebarMenus
|
|
54
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import e from "prop-types";
|
|
2
|
+
import i from "react";
|
|
3
|
+
import s from "../../helpers/classnames.js";
|
|
4
|
+
import { Counter as r } from "../Counter.js";
|
|
5
|
+
import { Drawer as u } from "../Drawer.js";
|
|
6
|
+
import { AnnounceIcon as k } from "../../icons/src/AnnounceIcon.js";
|
|
7
|
+
import { BellIcon as F } from "../../icons/src/BellIcon.js";
|
|
8
|
+
const z = {
|
|
9
|
+
// From Figma
|
|
10
|
+
background: "linear-gradient(138.65deg, #583DFF 19.59%, #F849C7 62.96%, #FFC03D 97.07%)"
|
|
11
|
+
}, f = (l) => {
|
|
12
|
+
const c = l ? "30px" : "48px";
|
|
13
|
+
return {
|
|
14
|
+
minWidth: c,
|
|
15
|
+
width: c,
|
|
16
|
+
minHeight: "20px",
|
|
17
|
+
height: "20px",
|
|
18
|
+
display: "inline-flex",
|
|
19
|
+
justifyContent: "center",
|
|
20
|
+
alignItems: "center"
|
|
21
|
+
};
|
|
22
|
+
}, d = ({
|
|
23
|
+
notifications: l,
|
|
24
|
+
isCollapsed: c,
|
|
25
|
+
isSticky: x = !0,
|
|
26
|
+
width: p,
|
|
27
|
+
isLeftDrawerOpen: y,
|
|
28
|
+
isRightDrawerOpen: E,
|
|
29
|
+
onDrawerStateChange: t
|
|
30
|
+
}) => {
|
|
31
|
+
const { announcements: o, notices: n } = l ?? {};
|
|
32
|
+
if (!o && !n)
|
|
33
|
+
return null;
|
|
34
|
+
const N = (n == null ? void 0 : n.count) > 0;
|
|
35
|
+
return /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
className: s(
|
|
39
|
+
"flex w-full gap-2 bg-black p-2",
|
|
40
|
+
x && "sticky top-0 z-50",
|
|
41
|
+
c ? "flex-col justify-center" : "justify-between"
|
|
42
|
+
)
|
|
43
|
+
},
|
|
44
|
+
o && /* @__PURE__ */ i.createElement("div", { className: s("cursor-pointer text-center", o.hide && "hidden") }, /* @__PURE__ */ i.createElement(
|
|
45
|
+
r,
|
|
46
|
+
{
|
|
47
|
+
style: { ...z, ...f(c) },
|
|
48
|
+
onClick: () => t == null ? void 0 : t("left")
|
|
49
|
+
},
|
|
50
|
+
/* @__PURE__ */ i.createElement(k, { className: s(c && "hidden") }),
|
|
51
|
+
o.count
|
|
52
|
+
)),
|
|
53
|
+
n && /* @__PURE__ */ i.createElement("div", { className: s("cursor-pointer text-center", !N && "hidden") }, /* @__PURE__ */ i.createElement(
|
|
54
|
+
r,
|
|
55
|
+
{
|
|
56
|
+
className: "text-sm",
|
|
57
|
+
style: f(c),
|
|
58
|
+
onClick: () => t == null ? void 0 : t("right")
|
|
59
|
+
},
|
|
60
|
+
/* @__PURE__ */ i.createElement(F, { className: s(c && "hidden") }),
|
|
61
|
+
n.count
|
|
62
|
+
))
|
|
63
|
+
), o && /* @__PURE__ */ i.createElement(
|
|
64
|
+
u,
|
|
65
|
+
{
|
|
66
|
+
isOpen: y,
|
|
67
|
+
sideIndent: p,
|
|
68
|
+
position: "left",
|
|
69
|
+
size: "xl",
|
|
70
|
+
title: o.title,
|
|
71
|
+
content: o.content,
|
|
72
|
+
onClose: (m) => !!m && (t == null ? void 0 : t("left"))
|
|
73
|
+
}
|
|
74
|
+
), n && /* @__PURE__ */ i.createElement(
|
|
75
|
+
u,
|
|
76
|
+
{
|
|
77
|
+
isOpen: E,
|
|
78
|
+
sideIndent: p,
|
|
79
|
+
position: "left",
|
|
80
|
+
size: "xl",
|
|
81
|
+
title: n.title,
|
|
82
|
+
content: n.content,
|
|
83
|
+
onClose: (m) => !!m && (t == null ? void 0 : t("right"))
|
|
84
|
+
}
|
|
85
|
+
));
|
|
86
|
+
};
|
|
87
|
+
d.displayName = "Sidebar.Notifications";
|
|
88
|
+
const b = {
|
|
89
|
+
count: e.number,
|
|
90
|
+
content: e.node,
|
|
91
|
+
title: e.string,
|
|
92
|
+
onClose: e.func
|
|
93
|
+
}, I = e.shape(b), O = e.shape({ ...b, hide: e.bool });
|
|
94
|
+
d.propTypes = {
|
|
95
|
+
notifications: e.shape({ announcements: O, notices: I }),
|
|
96
|
+
isCollapsed: e.bool,
|
|
97
|
+
isSticky: e.bool,
|
|
98
|
+
width: e.number.isRequired,
|
|
99
|
+
isLeftDrawerOpen: e.bool,
|
|
100
|
+
isRightDrawerOpen: e.bool,
|
|
101
|
+
// Optional: Sidebar forwards its own optional `handleDrawerStateChange` prop here, so a
|
|
102
|
+
// consumer can render notification badges without wiring up drawer toggling.
|
|
103
|
+
onDrawerStateChange: e.func
|
|
104
|
+
};
|
|
105
|
+
export {
|
|
106
|
+
d as SidebarNotifications
|
|
107
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
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"
|
|
104
|
+
),
|
|
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
|
|
122
|
+
),
|
|
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
|
+
})
|
|
202
|
+
};
|
|
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;
|
|
210
|
+
export {
|
|
211
|
+
o as Sidebar
|
|
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
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
className: o(
|
|
9
|
+
"ui-skeleton",
|
|
10
|
+
"relative flex items-center justify-center overflow-hidden rounded border border-gray-lighter bg-gray-lighter",
|
|
11
|
+
r.container
|
|
12
|
+
),
|
|
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)
|
|
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
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
c as Skeleton
|
|
28
|
+
};
|