@konstructio/ui 0.1.2-alpha.85 → 0.1.2-alpha.86
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/Sidebar/components/Logo/Logo.js +12 -7
- package/dist/components/Sidebar/components/NavigationOption/NavigationOption.js +19 -14
- package/dist/components/Sidebar/components/Wrapper/Wrapper.js +62 -58
- package/dist/components/Sidebar/contexts/SidebarContext.js +7 -5
- package/dist/lib/components/Sidebar/components/NavigationOption/NavigationOption.types.d.ts +6 -0
- package/dist/lib/components/Sidebar/contexts/SidebarContext.d.ts +6 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { t as a } from "../../../../utils-COaoD3PI.js";
|
|
2
|
+
import { useSidebarContext as e } from "../../contexts/SidebarContext.js";
|
|
2
3
|
import { logoVariants as m } from "./Logo.variants.js";
|
|
3
|
-
import { jsx as
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})
|
|
8
|
-
|
|
4
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
5
|
+
var i = ({ children: o, className: r }) => {
|
|
6
|
+
const { closeDrawer: t } = e();
|
|
7
|
+
return /* @__PURE__ */ s("header", {
|
|
8
|
+
className: a(m({ className: r })),
|
|
9
|
+
onClick: () => t(),
|
|
10
|
+
children: o
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
i.displayName = "KonstructSidebarLogo";
|
|
9
14
|
export {
|
|
10
|
-
|
|
15
|
+
i as Logo
|
|
11
16
|
};
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { useSidebarContext as
|
|
1
|
+
import { t as u } from "../../../../utils-COaoD3PI.js";
|
|
2
|
+
import { useSidebarContext as v } from "../../contexts/SidebarContext.js";
|
|
3
3
|
import { navigationOptionVariants as m } from "./NavigationOption.variants.js";
|
|
4
|
-
import { jsx as
|
|
5
|
-
var
|
|
6
|
-
const { isCollapsed: e, expandOnHover:
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
5
|
+
var k = ({ children: i, className: r, closeDrawerOnClick: n = !0, isVisible: t = !0, isActive: a, ...o }) => {
|
|
6
|
+
const { isCollapsed: e, expandOnHover: s, closeDrawer: l } = v(), p = e && s;
|
|
7
|
+
if (!t) return null;
|
|
8
|
+
const c = "onClick" in o ? o.onClick : void 0;
|
|
9
|
+
return /* @__PURE__ */ d("li", {
|
|
10
|
+
...o,
|
|
9
11
|
role: "option",
|
|
10
|
-
|
|
12
|
+
onClick: () => {
|
|
13
|
+
n && l(), c?.();
|
|
14
|
+
},
|
|
15
|
+
className: u(m({
|
|
11
16
|
className: r,
|
|
12
|
-
isActive:
|
|
13
|
-
}),
|
|
17
|
+
isActive: a
|
|
18
|
+
}), p && [
|
|
14
19
|
"group/sidebar-option",
|
|
15
20
|
"relative",
|
|
16
21
|
"hover:z-50",
|
|
17
22
|
"hover:shadow-lg",
|
|
18
23
|
"hover:bg-kubefirst-dark-blue-900"
|
|
19
24
|
]),
|
|
20
|
-
children:
|
|
21
|
-
})
|
|
25
|
+
children: i
|
|
26
|
+
});
|
|
22
27
|
};
|
|
23
|
-
|
|
28
|
+
k.displayName = "KonstructSidebarNavigationOption";
|
|
24
29
|
export {
|
|
25
|
-
|
|
30
|
+
k as NavigationOption
|
|
26
31
|
};
|
|
@@ -1,101 +1,105 @@
|
|
|
1
1
|
import { t as X } from "../../../../HamburgerTrigger-BzCfBWzH.js";
|
|
2
|
-
import { t as
|
|
2
|
+
import { t as h } from "../../../../utils-COaoD3PI.js";
|
|
3
3
|
import { Drawer as W } from "../../../Drawer/Drawer.js";
|
|
4
|
-
import { SidebarContext as
|
|
4
|
+
import { SidebarContext as O } from "../../contexts/SidebarContext.js";
|
|
5
5
|
import { useSidebarMode as q } from "../../hooks/useSidebarMode.js";
|
|
6
|
-
import { dragVariants as B, wrapperSiderbarVariants as
|
|
7
|
-
import { useCallback as c, useEffect as
|
|
8
|
-
import { Fragment as G, jsx as s, jsxs as
|
|
9
|
-
var J = 280, K = ({ animateOnHover:
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
|
|
6
|
+
import { dragVariants as B, wrapperSiderbarVariants as S } from "../../Sidebar.variants.js";
|
|
7
|
+
import { useCallback as c, useEffect as u, useRef as p, useState as N } from "react";
|
|
8
|
+
import { Fragment as G, jsx as s, jsxs as z } from "react/jsx-runtime";
|
|
9
|
+
var J = 280, K = ({ animateOnHover: C = !0, canResize: H = !0, children: y, dividerClassName: V, drawerBreakpoint: A, drawerMaxWidth: x = J, expandedBreakpoint: F, expandOnHover: I = !0, initialWidth: D = 256, maxWith: o = 300, minWith: a = 240, mode: P = "auto", separatorClassName: b, theme: g, triggerClassName: T, wrapperClassName: L }) => {
|
|
10
|
+
const r = q(P, F, A), [M, m] = N(!1), [E, _] = N(null), n = p(null), e = p(null), f = p(!1), R = p(!1);
|
|
11
|
+
u(() => {
|
|
12
|
+
if (r !== "drawer") return;
|
|
13
|
+
const t = () => {
|
|
14
|
+
_(window.innerWidth);
|
|
15
15
|
};
|
|
16
|
-
return
|
|
17
|
-
window.removeEventListener("resize",
|
|
16
|
+
return t(), window.addEventListener("resize", t), () => {
|
|
17
|
+
window.removeEventListener("resize", t);
|
|
18
18
|
};
|
|
19
|
-
}, [
|
|
20
|
-
const l = c((
|
|
21
|
-
if (!
|
|
19
|
+
}, [r]);
|
|
20
|
+
const l = c((t) => {
|
|
21
|
+
if (!f.current) {
|
|
22
22
|
n.current && (n.current.style.opacity = "0");
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
let i =
|
|
25
|
+
let i = t.clientX;
|
|
26
26
|
i < a && (i = a), i > o && (i = o), e.current && n.current && (e.current.style.width = `${i}px`, n.current.classList.add("opacity-100"));
|
|
27
|
-
}, [o, a]),
|
|
28
|
-
|
|
29
|
-
}, [l]),
|
|
30
|
-
|
|
31
|
-
}, [l,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
}, [o, a]), v = c(() => {
|
|
28
|
+
f.current = !1, n.current && n.current.classList.remove("opacity-100"), e.current && e.current.classList.remove("transition-none"), document.body.style.userSelect = "", document.body.style.cursor = "", document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", v);
|
|
29
|
+
}, [l]), $ = c((t) => {
|
|
30
|
+
t.preventDefault(), t.stopPropagation(), f.current = !0, e.current && e.current.classList.add("transition-none"), document.body.style.userSelect = "none", document.body.style.cursor = "col-resize", document.addEventListener("mousemove", l), document.addEventListener("mouseup", v);
|
|
31
|
+
}, [l, v]);
|
|
32
|
+
u(() => {
|
|
33
|
+
r !== "expanded" && e.current && (e.current.style.width = "");
|
|
34
|
+
}, [r]), u(() => {
|
|
35
|
+
r !== "drawer" && m(!1);
|
|
36
|
+
}, [r]), u(() => {
|
|
37
|
+
if (R.current || r !== "expanded" || !e.current) return;
|
|
38
|
+
const t = Math.min(Math.max(D, a), o);
|
|
39
|
+
e.current.style.width = `${t}px`, R.current = !0;
|
|
38
40
|
}, [
|
|
39
|
-
|
|
41
|
+
D,
|
|
40
42
|
o,
|
|
41
43
|
a,
|
|
42
|
-
|
|
44
|
+
r
|
|
43
45
|
]);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}, []),
|
|
47
|
-
|
|
46
|
+
const j = c(() => {
|
|
47
|
+
m(!0);
|
|
48
|
+
}, []), w = c(() => {
|
|
49
|
+
m(!1);
|
|
48
50
|
}, []);
|
|
49
|
-
if (
|
|
50
|
-
isOpen:
|
|
51
|
-
onClick:
|
|
52
|
-
className:
|
|
51
|
+
if (r === "drawer") return /* @__PURE__ */ z(G, { children: [/* @__PURE__ */ s(X, {
|
|
52
|
+
isOpen: M,
|
|
53
|
+
onClick: j,
|
|
54
|
+
className: T
|
|
53
55
|
}), /* @__PURE__ */ s(W, {
|
|
54
|
-
isOpen:
|
|
55
|
-
onClose:
|
|
56
|
+
isOpen: M,
|
|
57
|
+
onClose: w,
|
|
56
58
|
position: "left",
|
|
57
|
-
defaultWidth:
|
|
58
|
-
theme:
|
|
59
|
+
defaultWidth: E !== null ? Math.min(E, x) : x,
|
|
60
|
+
theme: g,
|
|
59
61
|
classNames: {
|
|
60
|
-
panel:
|
|
62
|
+
panel: h(S({ mode: "expanded" }), "h-full border-r-0", L),
|
|
61
63
|
content: "gap-0"
|
|
62
64
|
},
|
|
63
|
-
children: /* @__PURE__ */ s(
|
|
65
|
+
children: /* @__PURE__ */ s(O.Provider, {
|
|
64
66
|
value: {
|
|
65
67
|
mode: "expanded",
|
|
66
68
|
isCollapsed: !1,
|
|
67
69
|
expandOnHover: !1,
|
|
68
70
|
animateOnHover: !1,
|
|
69
|
-
separatorClassName:
|
|
71
|
+
separatorClassName: b,
|
|
72
|
+
closeDrawer: w
|
|
70
73
|
},
|
|
71
74
|
children: /* @__PURE__ */ s("div", {
|
|
72
75
|
className: "group/sidebar flex flex-col flex-1 min-h-0",
|
|
73
76
|
"data-mode": "expanded",
|
|
74
|
-
children:
|
|
77
|
+
children: y
|
|
75
78
|
})
|
|
76
79
|
})
|
|
77
80
|
})] });
|
|
78
|
-
const d =
|
|
81
|
+
const d = r, k = H && d === "expanded", U = {
|
|
79
82
|
mode: d,
|
|
80
83
|
isCollapsed: d === "collapsed",
|
|
81
|
-
expandOnHover:
|
|
82
|
-
animateOnHover:
|
|
83
|
-
separatorClassName:
|
|
84
|
+
expandOnHover: I,
|
|
85
|
+
animateOnHover: C,
|
|
86
|
+
separatorClassName: b,
|
|
87
|
+
closeDrawer: w
|
|
84
88
|
};
|
|
85
|
-
return /* @__PURE__ */ s(
|
|
89
|
+
return /* @__PURE__ */ s(O.Provider, {
|
|
86
90
|
value: U,
|
|
87
|
-
children: /* @__PURE__ */
|
|
91
|
+
children: /* @__PURE__ */ z("aside", {
|
|
88
92
|
ref: e,
|
|
89
|
-
className:
|
|
93
|
+
className: h(S({
|
|
90
94
|
mode: d,
|
|
91
|
-
className:
|
|
95
|
+
className: L
|
|
92
96
|
})),
|
|
93
|
-
"data-theme":
|
|
97
|
+
"data-theme": g,
|
|
94
98
|
"data-mode": d,
|
|
95
|
-
children: [
|
|
99
|
+
children: [y, k && /* @__PURE__ */ s("div", {
|
|
96
100
|
ref: n,
|
|
97
|
-
className:
|
|
98
|
-
onMouseDown:
|
|
101
|
+
className: h(B({ className: V })),
|
|
102
|
+
onMouseDown: $
|
|
99
103
|
})]
|
|
100
104
|
})
|
|
101
105
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { createContext as e, useContext as
|
|
2
|
-
var
|
|
1
|
+
import { createContext as e, useContext as r } from "react";
|
|
2
|
+
var t = e({
|
|
3
3
|
mode: "expanded",
|
|
4
4
|
isCollapsed: !1,
|
|
5
5
|
expandOnHover: !1,
|
|
6
|
-
animateOnHover: !0
|
|
7
|
-
|
|
6
|
+
animateOnHover: !0,
|
|
7
|
+
closeDrawer: () => {
|
|
8
|
+
}
|
|
9
|
+
}), o = () => r(t);
|
|
8
10
|
export {
|
|
9
|
-
|
|
11
|
+
t as SidebarContext,
|
|
10
12
|
o as useSidebarContext
|
|
11
13
|
};
|
|
@@ -5,6 +5,12 @@ type NavigationOption = VariantProps<typeof navigationOptionVariants> & {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
isVisible?: boolean;
|
|
7
7
|
isActive?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether clicking this option should close the drawer when the Sidebar
|
|
10
|
+
* is in `drawer` mode. Defaults to `true`. Has no effect in `expanded` or
|
|
11
|
+
* `collapsed` modes.
|
|
12
|
+
*/
|
|
13
|
+
closeDrawerOnClick?: boolean;
|
|
8
14
|
};
|
|
9
15
|
export type Props = NavigationOption & ({
|
|
10
16
|
role: 'button';
|
|
@@ -5,6 +5,12 @@ export interface SidebarContextValue {
|
|
|
5
5
|
expandOnHover: boolean;
|
|
6
6
|
animateOnHover: boolean;
|
|
7
7
|
separatorClassName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Closes the drawer when the Sidebar is in `drawer` mode. No-op in
|
|
10
|
+
* `expanded` or `collapsed` modes. Useful for closing the drawer on
|
|
11
|
+
* navigation events (e.g. when the user clicks a link).
|
|
12
|
+
*/
|
|
13
|
+
closeDrawer: () => void;
|
|
8
14
|
}
|
|
9
15
|
export declare const SidebarContext: import('react').Context<SidebarContextValue>;
|
|
10
16
|
export declare const useSidebarContext: () => SidebarContextValue;
|
package/dist/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.85",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.86",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|