@knymbus/voxel-ui 1.0.8 → 1.0.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.
@@ -0,0 +1,65 @@
1
+ import { t as e } from "./jsx-runtime-Boo2vksn.js";
2
+ import { forwardRef as t } from "react";
3
+ //#region src/components/button/Button.tsx
4
+ var n = e(), r = {
5
+ xs: "w-3 h-3",
6
+ sm: "w-3.5 h-3.5",
7
+ md: "w-4 h-4",
8
+ lg: "w-5 h-5"
9
+ }, i = ({ icon: e, size: t = "sm", className: i = "", ...a }) => {
10
+ let o = r[t];
11
+ return /* @__PURE__ */ (0, n.jsx)(e, {
12
+ className: `${o} ${i}`.trim(),
13
+ ...a
14
+ });
15
+ }, a = t((e, t) => {
16
+ let { size: r = "sm", color: a = "vsc", iconOnly: o = !1, startIcon: s, endIcon: c, className: l = "", disabled: u, ...d } = e, f = {
17
+ primary: "bg-vsc-accent text-vsc-button-text hover:bg-vsc-accent-hover border border-transparent focus:border-vsc-accent/50",
18
+ secondary: "bg-vsc-bg border border-vsc-border text-vsc-text hover:bg-vsc-hover focus:border-vsc-accent",
19
+ ghost: "bg-transparent border border-transparent text-vsc-muted hover:bg-vsc-hover/40 hover:text-vsc-text focus:border-vsc-border",
20
+ danger: "bg-rose-500/10 border border-rose-500/20 text-rose-500 hover:bg-rose-500/20 focus:border-rose-500/50",
21
+ vsc: "bg-transparent text-vsc-text border border-transparent opacity-55 hover:opacity-100 hover:bg-vsc-hover focus:border-vsc-hover/50"
22
+ }, p = {
23
+ xs: o ? "p-1 rounded-sm h-5 w-5" : "px-2 py-0.5 text-[10px] rounded-sm gap-1 h-5.5",
24
+ sm: o ? "p-1.5 rounded-md h-7 w-7" : "px-3 py-1.5 text-xs rounded-md gap-1.5 h-7.5",
25
+ md: o ? "p-2 rounded-md h-9 w-9" : "px-4 py-2 text-sm rounded-md gap-2 h-9",
26
+ lg: o ? "p-3 rounded-lg h-11 w-11" : "px-5 py-2.5 text-base rounded-lg gap-2.5 h-11"
27
+ }, m = `inline-flex items-center justify-center font-sans font-medium select-none
28
+ outline-none focus:ring-0 cursor-pointer
29
+ disabled:opacity-40 disabled:cursor-not-allowed disabled:transform-none disabled:active:scale-100 disabled:pointer-events-none
30
+ transition-all duration-150 cubic-bezier(0.34, 1.56, 0.64, 1)
31
+ active:scale-95 active:duration-75 ${f[a]} ${p[r]} ${l}`;
32
+ if (o) {
33
+ let a = e.icon;
34
+ return /* @__PURE__ */ (0, n.jsx)("button", {
35
+ ref: t,
36
+ disabled: u,
37
+ className: m,
38
+ ...d,
39
+ children: /* @__PURE__ */ (0, n.jsx)(i, {
40
+ icon: a,
41
+ size: r
42
+ })
43
+ });
44
+ }
45
+ return /* @__PURE__ */ (0, n.jsxs)("button", {
46
+ ref: t,
47
+ disabled: u,
48
+ className: m,
49
+ ...d,
50
+ children: [
51
+ s && /* @__PURE__ */ (0, n.jsx)(i, {
52
+ icon: s,
53
+ size: r
54
+ }),
55
+ /* @__PURE__ */ (0, n.jsx)("span", { children: e.children }),
56
+ c && /* @__PURE__ */ (0, n.jsx)(i, {
57
+ icon: c,
58
+ size: r
59
+ })
60
+ ]
61
+ });
62
+ });
63
+ a.displayName = "Button";
64
+ //#endregion
65
+ export { i as n, a as t };
@@ -0,0 +1,97 @@
1
+ import { t as e } from "./jsx-runtime-Boo2vksn.js";
2
+ import { n as t, t as n } from "./Button-BgQwvn3C.js";
3
+ import r, { useEffect as i, useRef as a, useState as o } from "react";
4
+ //#region src/components/button/ButtonGroup.tsx
5
+ var s = e();
6
+ function c({ children: e, orientation: t = "horizontal", variant: n = "default", gap: i = 0, className: a = "" }) {
7
+ let o = t === "horizontal", c = i > 0, l = o ? "flex-row" : "flex-col", u = "";
8
+ !c && n === "default" ? u = o ? "[&>button:not(:first-child)]:-ml-[1px] [&>button:first-child]:rounded-l-sm [&>button:last-child]:rounded-r-sm [&>button:not(:first-child):not(:last-child)]:rounded-none" : "[&>button:not(:first-child)]:-mt-[1px] [&>button:first-child]:rounded-t-sm [&>button:last-child]:rounded-b-sm [&>button:not(:first-child):not(:last-child)]:rounded-none" : c && (u = "[&>button]:rounded-sm");
9
+ let d = r.Children.map(e, (e) => r.isValidElement(e) && n === "ghost" ? r.cloneElement(e, { color: "ghost" }) : e), f = c ? { gap: `${i}px` } : {};
10
+ return /* @__PURE__ */ (0, s.jsx)("div", {
11
+ className: `inline-flex bg-transparent rounded-sm select-none isolation-auto ${l} ${u} ${a}`.trim(),
12
+ style: f,
13
+ children: d
14
+ });
15
+ }
16
+ //#endregion
17
+ //#region src/components/button/SplitActionButton.tsx
18
+ var l = (e) => /* @__PURE__ */ (0, s.jsx)("svg", {
19
+ className: e.className,
20
+ fill: "none",
21
+ stroke: "currentColor",
22
+ strokeWidth: "2.5",
23
+ viewBox: "0 0 24 24",
24
+ children: /* @__PURE__ */ (0, s.jsx)("path", {
25
+ strokeLinecap: "round",
26
+ strokeLinejoin: "round",
27
+ d: "M19 9l-7 7-7-7"
28
+ })
29
+ });
30
+ function u({ children: e, color: r = "primary", size: c = "sm", startIcon: u, onMainActionClick: d, menuItems: f, className: p = "" }) {
31
+ let [m, h] = o(!1), g = a(null);
32
+ i(() => {
33
+ let e = (e) => {
34
+ g.current && !g.current.contains(e.target) && h(!1);
35
+ };
36
+ return m && window.addEventListener("mousedown", e), () => window.removeEventListener("mousedown", e);
37
+ }, [m]);
38
+ let _ = {
39
+ xs: {
40
+ height: "22px",
41
+ menuTop: "26px"
42
+ },
43
+ sm: {
44
+ height: "30px",
45
+ menuTop: "34px"
46
+ },
47
+ md: {
48
+ height: "36px",
49
+ menuTop: "40px"
50
+ },
51
+ lg: {
52
+ height: "44px",
53
+ menuTop: "48px"
54
+ }
55
+ }[c], v = r === "primary" ? "bg-vsc-accent-hover/60" : "bg-vsc-border";
56
+ return /* @__PURE__ */ (0, s.jsxs)("div", {
57
+ ref: g,
58
+ className: `relative inline-flex items-center rounded-sm select-none isolation-auto ${p}`.trim(),
59
+ style: { height: _.height },
60
+ children: [
61
+ /* @__PURE__ */ (0, s.jsx)(n, {
62
+ color: r,
63
+ size: c,
64
+ startIcon: u,
65
+ onClick: d,
66
+ className: "rounded-r-none! h-full border-r-0",
67
+ children: e
68
+ }),
69
+ /* @__PURE__ */ (0, s.jsx)("div", { className: `w-px h-3/5 pointer-events-none z-20 ${v}` }),
70
+ /* @__PURE__ */ (0, s.jsx)("button", {
71
+ onClick: () => h(!m),
72
+ className: `h-full flex items-center justify-center transition-all duration-150 focus:outline-none border-none outline-none rounded-l-none! cursor-pointer ${r === "primary" ? "bg-vsc-accent text-vsc-button-text hover:bg-vsc-accent-hover" : r === "secondary" ? "bg-vsc-bg border border-vsc-sidebar border-l-0 text-vsc-text hover:bg-vsc-hover" : "bg-transparent text-vsc-muted hover:bg-vsc-hover/40 hover:text-vsc-text"} ${c === "xs" ? "w-5 rounded-r-sm" : c === "sm" ? "w-7 rounded-r-md" : c === "md" ? "w-9 rounded-r-md" : "w-11 rounded-r-lg"}`,
73
+ children: /* @__PURE__ */ (0, s.jsx)(l, { className: `w-3.5 h-3.5 transition-transform duration-200 ${m ? "rotate-180" : ""}` })
74
+ }),
75
+ m && /* @__PURE__ */ (0, s.jsx)("div", {
76
+ className: "absolute left-0 w-48 bg-vsc-sidebar border border-vsc-border rounded shadow-xl z-50 p-1 flex flex-col font-sans text-xs text-vsc-text animate-in fade-in slide-in-from-top-2 duration-150",
77
+ style: { top: _.menuTop },
78
+ children: f.map((e) => /* @__PURE__ */ (0, s.jsxs)("button", {
79
+ onClick: () => {
80
+ e.onClick(), h(!1);
81
+ },
82
+ className: "w-full flex items-center gap-2 p-2 hover:bg-vsc-hover text-left rounded-sm border-none bg-transparent text-vsc-text hover:text-white cursor-pointer",
83
+ children: [e.startIcon && /* @__PURE__ */ (0, s.jsx)(t, {
84
+ icon: e.startIcon,
85
+ size: "xs",
86
+ className: "opacity-70"
87
+ }), /* @__PURE__ */ (0, s.jsx)("span", {
88
+ className: "truncate",
89
+ children: e.label
90
+ })]
91
+ }, e.id))
92
+ })
93
+ ]
94
+ });
95
+ }
96
+ //#endregion
97
+ export { c as n, u as t };