@ztwoint/z-ui 0.1.8 → 0.1.10
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/dist/components/assets/icons/chevron-down.d.ts +7 -0
- package/dist/components/assets/icons/chevron-down.js +20 -0
- package/dist/components/assets/icons/chevron-up-icon.d.ts +7 -0
- package/dist/components/assets/icons/chevron-up-icon.js +22 -0
- package/dist/components/assets/icons/circles-icon.d.ts +8 -0
- package/dist/components/assets/icons/circles-icon.js +58 -0
- package/dist/components/assets/icons/database-copy.d.ts +7 -0
- package/dist/components/assets/icons/database-copy.js +49 -0
- package/dist/components/assets/icons/home.d.ts +6 -0
- package/dist/components/assets/icons/sidebar-left-show-copy.d.ts +7 -0
- package/dist/components/assets/icons/sidebar-left-show-copy.js +46 -0
- package/dist/components/assets/icons/sub-nav-indicator.d.ts +7 -0
- package/dist/components/assets/icons/sub-nav-indicator.js +48 -0
- package/dist/components/assets/icons/window-left-copy.d.ts +7 -0
- package/dist/components/assets/icons/window-left-copy.js +38 -0
- package/dist/components/assets/icons/z2-icon.d.ts +8 -0
- package/dist/components/assets/icons/z2-icon.js +17 -0
- package/dist/components/button/__tests__/Button.test.d.ts +1 -0
- package/dist/components/button/button.d.ts +16 -0
- package/dist/components/button/button.js +100 -0
- package/dist/components/button/button.stories.d.ts +26 -0
- package/dist/components/collapsible-side-nav-bar/constants.d.ts +2 -0
- package/dist/components/collapsible-side-nav-bar/constants.js +5 -0
- package/dist/components/collapsible-side-nav-bar/context.d.ts +4 -0
- package/dist/components/collapsible-side-nav-bar/context.js +11 -0
- package/dist/components/collapsible-side-nav-bar/index.d.ts +18 -0
- package/dist/components/collapsible-side-nav-bar/popover/index.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/popover/popover-content.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/popover/popover-content.js +97 -0
- package/dist/components/collapsible-side-nav-bar/popover/popover-trigger.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/popover/popover-trigger.js +13 -0
- package/dist/components/collapsible-side-nav-bar/popover/popover.d.ts +9 -0
- package/dist/components/collapsible-side-nav-bar/popover/popover.js +45 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-content.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-content.js +34 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-footer.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-footer.js +25 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-group.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-group.js +25 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-header.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-header.js +122 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-item.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-item.js +176 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-provider.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-provider.js +39 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-separator.d.ts +3 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-separator.js +10 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar.d.ts +7 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar.js +42 -0
- package/dist/components/collapsible-side-nav-bar/side-nav-bar.stories.d.ts +6 -0
- package/dist/components/collapsible-side-nav-bar/types.d.ts +84 -0
- package/dist/components/country-flags/__tests__/country-flags.test.d.ts +1 -0
- package/dist/components/country-flags/country-flags.d.ts +8 -0
- package/dist/components/country-flags/country-flags.js +34 -0
- package/dist/components/country-flags/country-flags.stories.d.ts +11 -0
- package/dist/components/input/__tests__/Input.test.d.ts +1 -0
- package/dist/components/input/input.d.ts +2 -0
- package/dist/components/input/input.js +11 -0
- package/dist/components/nav-header/index.d.ts +2 -0
- package/dist/components/nav-header/nav-header.d.ts +18 -0
- package/dist/components/nav-header/nav-header.js +40 -0
- package/dist/components/nav-header/nav-header.stories.d.ts +7 -0
- package/dist/components/nav-header/nav-item/nav-item.d.ts +6 -0
- package/dist/components/nav-header/nav-item/nav-item.js +31 -0
- package/dist/components/nav-header/nav-item/nav-item.stories.d.ts +12 -0
- package/dist/components/tab/__tests__/tab.test.d.ts +1 -0
- package/dist/components/tab/tab.d.ts +10 -0
- package/dist/components/tab/tab.js +80 -0
- package/dist/components/tab/tab.stories.d.ts +16 -0
- package/dist/components/tooltip/tooltip.d.ts +21 -0
- package/dist/components/tooltip/tooltip.js +32 -0
- package/dist/components/tooltip/tooltip.stories.d.ts +10 -0
- package/dist/css/config/colors/components/button.css +2 -2
- package/dist/css/styles/tailwind.css +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +61 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/main.d.ts +0 -0
- package/dist/test/setup.d.ts +0 -0
- package/dist/test/test-utils.d.ts +5 -0
- package/dist/tokens/typography/typography.stories.d.ts +12 -0
- package/dist/types/components/assets/icons/chevron-down.d.ts +7 -0
- package/dist/types/components/assets/icons/chevron-up-icon.d.ts +7 -0
- package/dist/types/components/assets/icons/circles-icon.d.ts +8 -0
- package/dist/types/components/assets/icons/database-copy.d.ts +7 -0
- package/dist/types/components/assets/icons/home.d.ts +6 -0
- package/dist/types/components/assets/icons/sidebar-left-show-copy.d.ts +7 -0
- package/dist/types/components/assets/icons/sub-nav-indicator.d.ts +7 -0
- package/dist/types/components/assets/icons/window-left-copy.d.ts +7 -0
- package/dist/types/components/assets/icons/z2-icon.d.ts +8 -0
- package/dist/types/components/button/__tests__/Button.test.d.ts +1 -0
- package/dist/types/components/button/button.d.ts +16 -0
- package/dist/types/components/button/button.stories.d.ts +26 -0
- package/dist/types/components/collapsible-side-nav-bar/constants.d.ts +2 -0
- package/dist/types/components/collapsible-side-nav-bar/context.d.ts +4 -0
- package/dist/types/components/collapsible-side-nav-bar/index.d.ts +18 -0
- package/dist/types/components/collapsible-side-nav-bar/popover/index.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/popover/popover-content.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/popover/popover-trigger.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/popover/popover.d.ts +9 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar-content.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar-footer.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar-group.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar-header.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar-item.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar-provider.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar-separator.d.ts +3 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar.d.ts +7 -0
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar.stories.d.ts +6 -0
- package/dist/types/components/collapsible-side-nav-bar/types.d.ts +84 -0
- package/dist/types/components/country-flags/__tests__/country-flags.test.d.ts +1 -0
- package/dist/types/components/country-flags/country-flags.d.ts +8 -0
- package/dist/types/components/country-flags/country-flags.stories.d.ts +11 -0
- package/dist/types/components/input/__tests__/Input.test.d.ts +1 -0
- package/dist/types/components/input/input.d.ts +2 -0
- package/dist/types/components/nav-header/index.d.ts +2 -0
- package/dist/types/components/nav-header/nav-header.d.ts +18 -0
- package/dist/types/components/nav-header/nav-header.stories.d.ts +7 -0
- package/dist/types/components/nav-header/nav-item/nav-item.d.ts +6 -0
- package/dist/types/components/nav-header/nav-item/nav-item.stories.d.ts +12 -0
- package/dist/types/components/tab/__tests__/tab.test.d.ts +1 -0
- package/dist/types/components/tab/tab.d.ts +10 -0
- package/dist/types/components/tab/tab.stories.d.ts +16 -0
- package/dist/types/components/tooltip/tooltip.d.ts +21 -0
- package/dist/types/components/tooltip/tooltip.stories.d.ts +10 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/test/setup.d.ts +1 -0
- package/dist/types/test/test-utils.d.ts +5 -0
- package/dist/types/tokens/typography/typography.stories.d.ts +12 -0
- package/package.json +2 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as a, Fragment as m, jsxs as b } from "react/jsx-runtime";
|
|
2
|
+
import * as o from "react";
|
|
3
|
+
import * as h from "react-dom";
|
|
4
|
+
import { cn as n } from "../../../lib/utils.js";
|
|
5
|
+
import { Z2PopoverContext as y } from "./popover.js";
|
|
6
|
+
const C = o.forwardRef(
|
|
7
|
+
({ children: i, side: l = "right", className: f }) => {
|
|
8
|
+
const t = o.useContext(y), [e, p] = o.useState(null), u = o.useRef(null);
|
|
9
|
+
o.useEffect(() => {
|
|
10
|
+
if (t != null && t.isOpen && (t != null && t.triggerId)) {
|
|
11
|
+
const r = document.querySelector(
|
|
12
|
+
`[data-popover-trigger="${t.triggerId}"]`
|
|
13
|
+
);
|
|
14
|
+
r && p(r.getBoundingClientRect());
|
|
15
|
+
}
|
|
16
|
+
}, [t == null ? void 0 : t.isOpen, t == null ? void 0 : t.triggerId]);
|
|
17
|
+
const d = o.useCallback(() => {
|
|
18
|
+
t != null && t.cancelClose && t.cancelClose();
|
|
19
|
+
}, [t]), g = o.useCallback(() => {
|
|
20
|
+
t != null && t.scheduleClose && t.scheduleClose();
|
|
21
|
+
}, [t]);
|
|
22
|
+
if (!(t != null && t.isOpen)) return null;
|
|
23
|
+
const s = (() => {
|
|
24
|
+
if (!e) return { top: 0, left: 0 };
|
|
25
|
+
const r = 8;
|
|
26
|
+
switch (l) {
|
|
27
|
+
case "right":
|
|
28
|
+
return {
|
|
29
|
+
top: e.top + e.height / 2,
|
|
30
|
+
left: e.right + r
|
|
31
|
+
};
|
|
32
|
+
case "left":
|
|
33
|
+
return {
|
|
34
|
+
top: e.top + e.height / 2,
|
|
35
|
+
left: e.left - r
|
|
36
|
+
};
|
|
37
|
+
case "top":
|
|
38
|
+
return {
|
|
39
|
+
top: e.top - r,
|
|
40
|
+
left: e.left + e.width / 2
|
|
41
|
+
};
|
|
42
|
+
case "bottom":
|
|
43
|
+
return {
|
|
44
|
+
top: e.bottom + r,
|
|
45
|
+
left: e.left + e.width / 2
|
|
46
|
+
};
|
|
47
|
+
default:
|
|
48
|
+
return { top: 0, left: 0 };
|
|
49
|
+
}
|
|
50
|
+
})(), c = {
|
|
51
|
+
top: "-translate-x-1/2 -translate-y-full",
|
|
52
|
+
bottom: "-translate-x-1/2",
|
|
53
|
+
left: "-translate-y-1/2 -translate-x-full",
|
|
54
|
+
right: "-translate-y-1/2"
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ a(m, { children: typeof document < "u" && h.createPortal(
|
|
57
|
+
/* @__PURE__ */ b(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
ref: u,
|
|
61
|
+
className: n(
|
|
62
|
+
"fixed z-[9999] px-3 py-2 text-sm bg-white text-gray-900 rounded-lg shadow-lg border border-gray-200 min-w-[200px]",
|
|
63
|
+
"pointer-events-auto select-none",
|
|
64
|
+
c[l],
|
|
65
|
+
f
|
|
66
|
+
),
|
|
67
|
+
style: {
|
|
68
|
+
top: s.top,
|
|
69
|
+
left: s.left
|
|
70
|
+
},
|
|
71
|
+
onMouseEnter: d,
|
|
72
|
+
onMouseLeave: g,
|
|
73
|
+
children: [
|
|
74
|
+
i,
|
|
75
|
+
/* @__PURE__ */ a(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: n(
|
|
79
|
+
"absolute w-2 h-2 bg-white border-gray-200 transform rotate-45",
|
|
80
|
+
l === "right" && "-left-1 top-1/2 -translate-y-1/2 border-l border-b",
|
|
81
|
+
l === "left" && "-right-1 top-1/2 -translate-y-1/2 border-r border-t",
|
|
82
|
+
l === "top" && "-bottom-1 left-1/2 -translate-x-1/2 border-r border-b",
|
|
83
|
+
l === "bottom" && "-top-1 left-1/2 -translate-x-1/2 border-l border-t"
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
document.body
|
|
91
|
+
) });
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
C.displayName = "Z2PopoverContent";
|
|
95
|
+
export {
|
|
96
|
+
C as Z2PopoverContent
|
|
97
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import * as o from "react";
|
|
3
|
+
import { Z2PopoverContext as a } from "./popover.js";
|
|
4
|
+
const p = o.forwardRef(
|
|
5
|
+
({ children: e }, t) => {
|
|
6
|
+
const r = o.useContext(a);
|
|
7
|
+
return /* @__PURE__ */ i("div", { ref: t, className: "relative inline-block", "data-popover-trigger": r == null ? void 0 : r.triggerId, children: e });
|
|
8
|
+
}
|
|
9
|
+
);
|
|
10
|
+
p.displayName = "Z2PopoverTrigger";
|
|
11
|
+
export {
|
|
12
|
+
p as Z2PopoverTrigger
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Z2PopoverProps, Z2PopoverContextType } from '../types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare const Z2PopoverContext: React.Context<Z2PopoverContextType | null>;
|
|
4
|
+
export declare const Z2Popover: {
|
|
5
|
+
({ children, delayDuration }: Z2PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
export { Z2PopoverTrigger } from './popover-trigger';
|
|
9
|
+
export { Z2PopoverContent } from './popover-content';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import * as r from "react";
|
|
3
|
+
import { Z2PopoverTrigger as g } from "./popover-trigger.js";
|
|
4
|
+
import { Z2PopoverContent as C } from "./popover-content.js";
|
|
5
|
+
const f = r.createContext(null), p = ({ children: i, delayDuration: n = 300 }) => {
|
|
6
|
+
const [u, o] = r.useState(!1), t = r.useRef(void 0), e = r.useRef(void 0), c = r.useMemo(
|
|
7
|
+
() => `popover-trigger-${Math.random().toString(36).substr(2, 9)}`,
|
|
8
|
+
[]
|
|
9
|
+
), a = r.useMemo(
|
|
10
|
+
() => ({
|
|
11
|
+
isOpen: u,
|
|
12
|
+
setIsOpen: o,
|
|
13
|
+
triggerId: c,
|
|
14
|
+
cancelClose: () => {
|
|
15
|
+
e.current && (clearTimeout(e.current), e.current = void 0);
|
|
16
|
+
},
|
|
17
|
+
scheduleClose: () => {
|
|
18
|
+
e.current && clearTimeout(e.current), e.current = window.setTimeout(() => o(!1), 150);
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
[u, c]
|
|
22
|
+
), l = r.useCallback(() => {
|
|
23
|
+
t.current && clearTimeout(t.current), e.current && (clearTimeout(e.current), e.current = void 0), t.current = window.setTimeout(() => o(!0), n);
|
|
24
|
+
}, [n]), m = r.useCallback(() => {
|
|
25
|
+
t.current && clearTimeout(t.current), e.current && clearTimeout(e.current), e.current = window.setTimeout(() => o(!1), 150);
|
|
26
|
+
}, []);
|
|
27
|
+
return r.useEffect(() => () => {
|
|
28
|
+
t.current && clearTimeout(t.current), e.current && clearTimeout(e.current);
|
|
29
|
+
}, []), /* @__PURE__ */ s(f.Provider, { value: a, children: /* @__PURE__ */ s(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
className: " inline-block",
|
|
33
|
+
onMouseEnter: l,
|
|
34
|
+
onMouseLeave: m,
|
|
35
|
+
children: i
|
|
36
|
+
}
|
|
37
|
+
) });
|
|
38
|
+
};
|
|
39
|
+
p.displayName = "Z2Popover";
|
|
40
|
+
export {
|
|
41
|
+
p as Z2Popover,
|
|
42
|
+
C as Z2PopoverContent,
|
|
43
|
+
f as Z2PopoverContext,
|
|
44
|
+
g as Z2PopoverTrigger
|
|
45
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
import { cn as f } from "../../lib/utils.js";
|
|
4
|
+
import { useZ2SideNavBar as m } from "./context.js";
|
|
5
|
+
const s = l.forwardRef(
|
|
6
|
+
({ className: e, children: r, ...o }, t) => {
|
|
7
|
+
const { isCollapsed: i } = m();
|
|
8
|
+
return i ? /* @__PURE__ */ a(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
ref: t,
|
|
12
|
+
className: f(
|
|
13
|
+
"flex-1 overflow-y-auto flex flex-col items-start gap-2 relative w-10.5 max-w-10.5",
|
|
14
|
+
"border-b border-gray-200",
|
|
15
|
+
e
|
|
16
|
+
),
|
|
17
|
+
...o,
|
|
18
|
+
children: r
|
|
19
|
+
}
|
|
20
|
+
) : /* @__PURE__ */ a(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
ref: t,
|
|
24
|
+
className: f("flex flex-col items-center flex-1 overflow-y-auto", e),
|
|
25
|
+
...o,
|
|
26
|
+
children: r
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
s.displayName = "Z2SideNavBarContent";
|
|
32
|
+
export {
|
|
33
|
+
s as Z2SideNavBarContent
|
|
34
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import * as m from "react";
|
|
3
|
+
import { cn as i } from "../../lib/utils.js";
|
|
4
|
+
import { useZ2SideNavBar as f } from "./context.js";
|
|
5
|
+
const d = m.forwardRef(
|
|
6
|
+
({ className: r, children: e, ...t }, o) => {
|
|
7
|
+
const { isCollapsed: s } = f();
|
|
8
|
+
return s ? /* @__PURE__ */ a(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
ref: o,
|
|
12
|
+
className: i(
|
|
13
|
+
"flex p-2 flex-col justify-center items-center gap-1.5 self-stretch relative",
|
|
14
|
+
r
|
|
15
|
+
),
|
|
16
|
+
...t,
|
|
17
|
+
children: e
|
|
18
|
+
}
|
|
19
|
+
) : /* @__PURE__ */ a("div", { ref: o, className: i("p-4 border-t border-gray-200", r), ...t, children: e });
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
d.displayName = "Z2SideNavBarFooter";
|
|
23
|
+
export {
|
|
24
|
+
d as Z2SideNavBarFooter
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as i, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import { cn as m } from "../../lib/utils.js";
|
|
4
|
+
import { useZ2SideNavBar as d } from "./context.js";
|
|
5
|
+
const f = c.forwardRef(
|
|
6
|
+
({ className: r, children: e, title: a, ...t }, o) => {
|
|
7
|
+
const { isCollapsed: s } = d(), l = a && !s;
|
|
8
|
+
return s ? /* @__PURE__ */ i(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
ref: o,
|
|
12
|
+
className: m("flex flex-col items-start gap-1.5 p-1.5 relative", r),
|
|
13
|
+
...t,
|
|
14
|
+
children: e
|
|
15
|
+
}
|
|
16
|
+
) : /* @__PURE__ */ p("div", { ref: o, className: m("w-56 max-w-56 pt-2", r), ...t, children: [
|
|
17
|
+
l && /* @__PURE__ */ i("h3", { className: "text-sm font-medium text-(--color-neutral-600) px-2 pb-2", children: a }),
|
|
18
|
+
e
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
f.displayName = "Z2SideNavBarGroup";
|
|
23
|
+
export {
|
|
24
|
+
f as Z2SideNavBarGroup
|
|
25
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { cn as x } from "../../lib/utils.js";
|
|
4
|
+
import { useZ2SideNavBar as N } from "./context.js";
|
|
5
|
+
import u from "../assets/icons/window-left-copy.js";
|
|
6
|
+
import w from "../assets/icons/sidebar-left-show-copy.js";
|
|
7
|
+
const C = n.forwardRef(
|
|
8
|
+
({
|
|
9
|
+
className: o,
|
|
10
|
+
children: l,
|
|
11
|
+
showCollapseButton: g = !0,
|
|
12
|
+
icon: s,
|
|
13
|
+
title: r,
|
|
14
|
+
forceMultiLine: c = !1,
|
|
15
|
+
...d
|
|
16
|
+
}, m) => {
|
|
17
|
+
const { toggleCollapsed: p, isCollapsed: i } = N(), [v, h] = n.useState(c), f = n.useRef(null), b = v || !!l;
|
|
18
|
+
return n.useEffect(() => {
|
|
19
|
+
if (c) {
|
|
20
|
+
h(!0);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (f.current && !i && r) {
|
|
24
|
+
const t = document.createElement("span");
|
|
25
|
+
t.style.visibility = "hidden", t.style.position = "absolute", t.style.whiteSpace = "nowrap", t.style.fontSize = "14px", t.style.fontWeight = "450", t.textContent = r, document.body.appendChild(t);
|
|
26
|
+
const y = t.offsetWidth;
|
|
27
|
+
document.body.removeChild(t), h(y > 168);
|
|
28
|
+
}
|
|
29
|
+
}, [r, i, c]), i ? /* @__PURE__ */ e(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
ref: m,
|
|
33
|
+
className: x(
|
|
34
|
+
"flex flex-col items-center gap-1.5 self-stretch border-b border-gray-200 p-2",
|
|
35
|
+
o
|
|
36
|
+
),
|
|
37
|
+
...d,
|
|
38
|
+
children: /* @__PURE__ */ e(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
onClick: p,
|
|
42
|
+
className: "flex items-center justify-center cursor-pointer p-1.5 gap-1 rounded-lg relative bg-transparent border-none",
|
|
43
|
+
title: "Expand sidebar",
|
|
44
|
+
children: /* @__PURE__ */ e(w, { className: "w-3.5 h-3.5 text-(--color-neutral-600)" })
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
) : b && !i ? /* @__PURE__ */ a(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
ref: m,
|
|
52
|
+
className: x(
|
|
53
|
+
"flex flex-col items-start gap-5 self-stretch border-b border-gray-100 w-60 px-2.5 py-4 pl-4 relative",
|
|
54
|
+
o
|
|
55
|
+
),
|
|
56
|
+
...d,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ a("div", { className: "header-icons-container flex justify-between items-center self-stretch relative", children: [
|
|
59
|
+
s && /* @__PURE__ */ e("div", { className: "database-icon-container flex p-1.5 justify-center items-center gap-1 rounded-lg bg-gray-50 relative", children: /* @__PURE__ */ e("div", { className: "w-3.5 h-3.5 aspect-square relative", children: s }) }),
|
|
60
|
+
g && /* @__PURE__ */ e(
|
|
61
|
+
"button",
|
|
62
|
+
{
|
|
63
|
+
onClick: p,
|
|
64
|
+
className: "sidebar-toggle-button flex p-1.5 justify-center items-center gap-1 rounded-lg relative bg-transparent border-none cursor-pointer",
|
|
65
|
+
title: "Collapse sidebar",
|
|
66
|
+
children: /* @__PURE__ */ e("div", { className: "w-3.5 h-3.5 aspect-square relative", children: /* @__PURE__ */ e(u, { className: "w-3.5 h-3.5 text-(--color-neutral-600)" }) })
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] }),
|
|
70
|
+
/* @__PURE__ */ a("div", { className: "text-preset-container flex flex-col items-start gap-2.5 self-stretch relative", children: [
|
|
71
|
+
/* @__PURE__ */ e("div", { className: "primary-text self-stretch text-gray-950 text-sm font-medium leading-none tracking-tight relative", children: r }),
|
|
72
|
+
/* @__PURE__ */ e(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
ref: f,
|
|
76
|
+
className: "secondary-text line-clamp-1 self-stretch overflow-hidden text-gray-600 text-ellipsis text-sm font-normal leading-none tracking-tight relative",
|
|
77
|
+
children: l
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] })
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
) : /* @__PURE__ */ a(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
ref: m,
|
|
87
|
+
className: x(
|
|
88
|
+
"flex items-center gap-2.5 border-b header-default-layout w-60 px-2.5 py-2.5 pl-3 border-gray-100 relative",
|
|
89
|
+
o
|
|
90
|
+
),
|
|
91
|
+
...d,
|
|
92
|
+
children: [
|
|
93
|
+
s && /* @__PURE__ */ e("div", { className: "icon-container flex p-1.5 justify-center items-center gap-1 rounded-lg bg-gray-50 relative", children: /* @__PURE__ */ e("div", { className: "w-3.5 h-3.5 aspect-square relative", children: s }) }),
|
|
94
|
+
/* @__PURE__ */ a(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
ref: f,
|
|
98
|
+
className: "text-content flex flex-col items-start gap-2.5 flex-1 relative",
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ e("div", { className: "primary-text line-clamp-1 self-stretch overflow-hidden text-gray-950 text-ellipsis text-sm font-medium leading-none tracking-tight relative", children: r }),
|
|
101
|
+
l && /* @__PURE__ */ e("div", { className: "secondary-text line-clamp-1 self-stretch overflow-hidden text-(--color-neutral-600) text-ellipsis text-xs font-normal leading-none tracking-tight relative", children: l })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
g && /* @__PURE__ */ e(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
onClick: p,
|
|
109
|
+
className: "collapse-button flex p-1.5 justify-center items-center gap-1 rounded-lg relative bg-transparent border-none cursor-pointer",
|
|
110
|
+
title: "Collapse sidebar",
|
|
111
|
+
children: /* @__PURE__ */ e("div", { className: "w-3.5 h-3.5 aspect-square relative", children: /* @__PURE__ */ e(u, { className: "text-(--color-neutral-600)" }) })
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
C.displayName = "Z2SideNavBarHeader";
|
|
120
|
+
export {
|
|
121
|
+
C as Z2SideNavBarHeader
|
|
122
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { jsxs as i, jsx as r, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import * as d from "react";
|
|
3
|
+
import { cn as f } from "../../lib/utils.js";
|
|
4
|
+
import { useZ2SideNavBar as A } from "./context.js";
|
|
5
|
+
import { ChevronUpIcon as B } from "../assets/icons/chevron-up-icon.js";
|
|
6
|
+
import M from "../assets/icons/sub-nav-indicator.js";
|
|
7
|
+
import Z from "../assets/icons/circles-icon.js";
|
|
8
|
+
import { Z2Popover as R } from "./popover/popover.js";
|
|
9
|
+
import q from "../assets/icons/chevron-down.js";
|
|
10
|
+
import { Z2PopoverTrigger as E } from "./popover/popover-trigger.js";
|
|
11
|
+
import { Z2PopoverContent as F } from "./popover/popover-content.js";
|
|
12
|
+
const K = d.forwardRef(
|
|
13
|
+
({
|
|
14
|
+
className: x,
|
|
15
|
+
children: u,
|
|
16
|
+
icon: m,
|
|
17
|
+
label: c,
|
|
18
|
+
href: y,
|
|
19
|
+
isActive: h = !1,
|
|
20
|
+
onClick: v,
|
|
21
|
+
tooltip: p,
|
|
22
|
+
subItems: s,
|
|
23
|
+
...N
|
|
24
|
+
}, D) => {
|
|
25
|
+
const { isCollapsed: l } = A(), [t, k] = d.useState(!1), o = c && !l, n = s && s.length > 0, C = d.useMemo(() => l ? n ? /* @__PURE__ */ i("div", { className: "text-left", children: [
|
|
26
|
+
/* @__PURE__ */ r("div", { className: "text-gray-500 mt-2 mb-1", children: p || c }),
|
|
27
|
+
/* @__PURE__ */ r("div", { className: "space-y-1", children: s.map((e) => {
|
|
28
|
+
const g = (a) => {
|
|
29
|
+
a.preventDefault(), a.stopPropagation(), e.onClick ? e.onClick() : e.href && (window.location.href = e.href);
|
|
30
|
+
}, S = /* @__PURE__ */ i(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
className: f(
|
|
34
|
+
"text-sm ml-2 px-2 py-2 rounded transition-colors cursor-pointer flex items-center gap-2",
|
|
35
|
+
{
|
|
36
|
+
"hover:!bg-gray-200 bg-gray-100": e.isActive,
|
|
37
|
+
"hover:!bg-gray-100": !e.isActive
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ r("div", { className: "w-3.5 h-3.5 flex-shrink-0 text-(--color-neutral-600)", children: e.icon || /* @__PURE__ */ r(Z, { className: "text-(--color-neutral-600)" }) }),
|
|
42
|
+
e.label
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
return e.href && !e.onClick ? /* @__PURE__ */ r(
|
|
47
|
+
"a",
|
|
48
|
+
{
|
|
49
|
+
href: e.href,
|
|
50
|
+
className: "block mt-2",
|
|
51
|
+
onClick: g,
|
|
52
|
+
children: S
|
|
53
|
+
},
|
|
54
|
+
e.id
|
|
55
|
+
) : /* @__PURE__ */ r(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
onClick: g,
|
|
59
|
+
role: "button",
|
|
60
|
+
tabIndex: 0,
|
|
61
|
+
className: "block",
|
|
62
|
+
onKeyDown: (a) => {
|
|
63
|
+
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), g(a));
|
|
64
|
+
},
|
|
65
|
+
children: S
|
|
66
|
+
},
|
|
67
|
+
e.id
|
|
68
|
+
);
|
|
69
|
+
}) })
|
|
70
|
+
] }) : p || c : null, [l, n, p, c, s]), w = d.useCallback(
|
|
71
|
+
(e) => {
|
|
72
|
+
e.stopPropagation(), k(!t);
|
|
73
|
+
},
|
|
74
|
+
[t]
|
|
75
|
+
), b = d.useCallback(() => {
|
|
76
|
+
n && !l ? k(!t) : v && v();
|
|
77
|
+
}, [n, l, t, v]);
|
|
78
|
+
if (l) {
|
|
79
|
+
const e = /* @__PURE__ */ i(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
className: f(
|
|
83
|
+
"flex items-center justify-center gap-1.5 rounded-lg cursor-pointer transition-all duration-200",
|
|
84
|
+
"p-2 justify-center gap-1.5 self-stretch relative",
|
|
85
|
+
"hover:bg-gray-50 text-gray-700 hover:text-gray-900",
|
|
86
|
+
h && "bg-(--color-neutral-100)",
|
|
87
|
+
x
|
|
88
|
+
),
|
|
89
|
+
onClick: b,
|
|
90
|
+
...N,
|
|
91
|
+
children: [
|
|
92
|
+
m && /* @__PURE__ */ r("span", { className: "nav-item-icon flex-shrink-0 flex items-center justify-center w-3.5 h-3.5", children: m }),
|
|
93
|
+
u
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
return C ? /* @__PURE__ */ i(R, { children: [
|
|
98
|
+
/* @__PURE__ */ r(E, { children: e }),
|
|
99
|
+
/* @__PURE__ */ r(F, { side: "right", children: C })
|
|
100
|
+
] }) : /* @__PURE__ */ r("div", { children: e });
|
|
101
|
+
}
|
|
102
|
+
const j = /* @__PURE__ */ i(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
className: f(
|
|
106
|
+
"nav-item-container flex flex-col justify-center items-center gap-1.5 rounded-lg relative overflow-hidden p-0",
|
|
107
|
+
o ? "w-56 max-w-56" : "w-auto max-w-none"
|
|
108
|
+
),
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ i(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
className: f(
|
|
114
|
+
"nav-item-main flex items-center justify-center gap-1.5 self-stretch rounded-lg cursor-pointer transition-all duration-200 my-1 p-2 relative",
|
|
115
|
+
{
|
|
116
|
+
// Background colors based on state
|
|
117
|
+
"hover:bg-gray-50 text-gray-700 hover:text-gray-900": !h && !(o && n && t),
|
|
118
|
+
// Focused state for expanded nav with sub items (matching component design)
|
|
119
|
+
"text-black bg-gray-100": h || o && n && t
|
|
120
|
+
},
|
|
121
|
+
x
|
|
122
|
+
),
|
|
123
|
+
onClick: b,
|
|
124
|
+
...N,
|
|
125
|
+
children: [
|
|
126
|
+
m && /* @__PURE__ */ r("span", { className: "nav-item-icon flex-shrink-0 flex items-center justify-center w-3.5 h-3.5", children: m }),
|
|
127
|
+
o && /* @__PURE__ */ r("div", { className: "nav-item-label-container flex items-center gap-2.5 flex-1 px-0.5 relative", children: /* @__PURE__ */ r("div", { className: "nav-item-label flex-1 truncate text-sm font-medium leading-none tracking-tight text-black relative line-clamp-1 py-1", children: c }) }),
|
|
128
|
+
o && n && /* @__PURE__ */ r(P, { children: t ? /* @__PURE__ */ r(
|
|
129
|
+
B,
|
|
130
|
+
{
|
|
131
|
+
className: "w-3.5 h-3.5 cursor-pointer text-(--color-neutral-600)",
|
|
132
|
+
onClick: w
|
|
133
|
+
}
|
|
134
|
+
) : /* @__PURE__ */ r(
|
|
135
|
+
q,
|
|
136
|
+
{
|
|
137
|
+
className: "w-3.5 h-3.5 text-(--color-neutral-600) cursor-pointer",
|
|
138
|
+
onClick: w
|
|
139
|
+
}
|
|
140
|
+
) }),
|
|
141
|
+
u
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
o && n && t && /* @__PURE__ */ i("div", { className: "sub-nav-container flex items-start gap-0 self-stretch relative p-0", children: [
|
|
146
|
+
/* @__PURE__ */ r("div", { className: "divider-group flex w-6 px-2 items-center gap-2.5 self-stretch relative" }),
|
|
147
|
+
/* @__PURE__ */ r("div", { className: "sub-nav-list flex flex-col items-start gap-1.5 flex-1 relative", children: s.map((e) => /* @__PURE__ */ i(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: f(
|
|
151
|
+
"sub-nav-item cursor-pointer transition-colors flex justify-center items-center gap-1.5 self-stretch rounded-lg p-2 relative",
|
|
152
|
+
{
|
|
153
|
+
"hover:!bg-gray-100 bg-gray-100": e.isActive,
|
|
154
|
+
"hover:!bg-gray-50": !e.isActive
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
onClick: e.onClick,
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ r(M, { className: "text-(--color-neutral-100)", secondaryfill: "white" }),
|
|
160
|
+
/* @__PURE__ */ r("div", { className: "sub-nav-icon w-3.5 h-3.5 aspect-square relative text-(--color-neutral-600)", children: e.icon || /* @__PURE__ */ r(Z, { className: "text-(--color-neutral-600)" }) }),
|
|
161
|
+
/* @__PURE__ */ r("div", { className: "sub-nav-label-container flex px-0.5 items-center gap-2.5 flex-1 relative", children: /* @__PURE__ */ r("div", { className: "sub-nav-label flex-1 overflow-hidden text-black text-ellipsis text-sm font-medium leading-none tracking-tight relative line-clamp-1", children: e.label }) })
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
e.id
|
|
165
|
+
)) })
|
|
166
|
+
] })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
return y ? /* @__PURE__ */ r("a", { href: y, children: j }) : /* @__PURE__ */ r("div", { ref: D, children: j });
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
K.displayName = "Z2SideNavBarItem";
|
|
174
|
+
export {
|
|
175
|
+
K as Z2SideNavBarItem
|
|
176
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import * as r from "react";
|
|
3
|
+
import { cn as f } from "../../lib/utils.js";
|
|
4
|
+
import { Z2SideNavBarContext as S } from "./context.js";
|
|
5
|
+
import { SIDEBAR_WIDTH_COLLAPSED as i, SIDEBAR_WIDTH as C } from "./constants.js";
|
|
6
|
+
const h = r.forwardRef(
|
|
7
|
+
({ children: d, defaultCollapsed: l = !1, style: o, className: m, ...c }, n) => {
|
|
8
|
+
const [e, p] = r.useState(l), t = r.useCallback(() => {
|
|
9
|
+
p(!e);
|
|
10
|
+
}, [e]), u = r.useMemo(
|
|
11
|
+
() => ({
|
|
12
|
+
isCollapsed: e,
|
|
13
|
+
toggleCollapsed: t
|
|
14
|
+
}),
|
|
15
|
+
[e, t]
|
|
16
|
+
), a = r.useMemo(() => e ? i : C, [e]), v = r.useMemo(
|
|
17
|
+
() => ({
|
|
18
|
+
"--sidebar-width": a,
|
|
19
|
+
"--sidebar-width-collapsed": i,
|
|
20
|
+
...o
|
|
21
|
+
}),
|
|
22
|
+
[a, o]
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ s(S.Provider, { value: u, children: /* @__PURE__ */ s(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
ref: n,
|
|
28
|
+
className: f("relative h-full", m),
|
|
29
|
+
style: v,
|
|
30
|
+
...c,
|
|
31
|
+
children: d
|
|
32
|
+
}
|
|
33
|
+
) });
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
h.displayName = "Z2SideNavBarProvider";
|
|
37
|
+
export {
|
|
38
|
+
h as Z2SideNavBarProvider
|
|
39
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { cn as m } from "../../lib/utils.js";
|
|
4
|
+
const i = t.forwardRef(
|
|
5
|
+
({ className: r, ...a }, o) => /* @__PURE__ */ e("div", { ref: o, className: m("", r), ...a })
|
|
6
|
+
);
|
|
7
|
+
i.displayName = "Z2SideNavBarSeparator";
|
|
8
|
+
export {
|
|
9
|
+
i as Z2SideNavBarSeparator
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Z2SideNavBarProps } from './types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare const Z2SidebarVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "inset" | "floating" | null | undefined;
|
|
5
|
+
side?: "left" | "right" | null | undefined;
|
|
6
|
+
} & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
|
|
7
|
+
export declare const Z2SideNavBar: React.ForwardRefExoticComponent<Z2SideNavBarProps & React.RefAttributes<HTMLDivElement>>;
|