@pibit.ai/cure-design-system 0.6.13 → 0.6.14
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +155 -153
- package/dist/patterns/expandable-drawer/expandable-drawer.d.ts +36 -0
- package/dist/patterns/expandable-drawer/expandable-drawer.d.ts.map +1 -0
- package/dist/patterns/expandable-drawer/expandable-drawer.js +120 -0
- package/dist/patterns/expandable-drawer/index.d.ts +2 -0
- package/dist/patterns/expandable-drawer/index.d.ts.map +1 -0
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type ExpandableRightDrawerState = "hidden" | "normal" | "expanded";
|
|
3
|
+
export interface ExpandableRightDrawerProps {
|
|
4
|
+
/** Current state: hidden (no space), normal (sidebar width), expanded (wide). */
|
|
5
|
+
state: ExpandableRightDrawerState;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
/** Optional custom header. When not provided, default header with title/subtitle and actions is used. */
|
|
8
|
+
header?: React.ReactNode;
|
|
9
|
+
/** Used by default header. */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Used by default header. */
|
|
12
|
+
subtitle?: string;
|
|
13
|
+
/** Content; only rendered when state is not "hidden" (lazy). */
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
/** Width in pixels for normal state. Default 512 (32rem). */
|
|
16
|
+
normalWidth?: number;
|
|
17
|
+
/** Width when expanded. Default `calc(100vw - 140px)`. */
|
|
18
|
+
maxWidth?: string;
|
|
19
|
+
/** Controlled drawer width. When provided, it is used for the normal state. */
|
|
20
|
+
width?: number | string;
|
|
21
|
+
/** Minimum drawer width while visible. */
|
|
22
|
+
minWidth?: number;
|
|
23
|
+
/** Maximum width allowed while dragging. */
|
|
24
|
+
maxResizableWidth?: number;
|
|
25
|
+
/** Called while the user drags the drawer resize handle. */
|
|
26
|
+
onWidthChange?: (width: number) => void;
|
|
27
|
+
/** Callback when expand/collapse is toggled. When provided, default header shows expand/minimize button. */
|
|
28
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
29
|
+
/** Extra actions rendered in the default header before expand/close controls. */
|
|
30
|
+
headerActions?: React.ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
headerClassName?: string;
|
|
33
|
+
bodyClassName?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const ExpandableRightDrawer: React.FC<ExpandableRightDrawerProps>;
|
|
36
|
+
//# sourceMappingURL=expandable-drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expandable-drawer.d.ts","sourceRoot":"","sources":["../../../src/patterns/expandable-drawer/expandable-drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAQlE,MAAM,MAAM,0BAA0B,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAM1E,MAAM,WAAW,0BAA0B;IACzC,iFAAiF;IACjF,KAAK,EAAE,0BAA0B,CAAC;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,yGAAyG;IACzG,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,4GAA4G;IAC5G,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,iFAAiF;IACjF,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAsKtE,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as t, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { Minimize01 as H, Expand01 as K, X as F } from "@untitledui/icons";
|
|
3
|
+
import { useState as U, useId as Y, useRef as G, useEffect as J } from "react";
|
|
4
|
+
import { motion as Q } from "../../node_modules/framer-motion/dist/es/render/components/motion/proxy.js";
|
|
5
|
+
const Z = 512, W = "calc(100vw - 140px)", C = { type: "tween", duration: 0.3, ease: "easeInOut" }, se = ({
|
|
6
|
+
state: o,
|
|
7
|
+
onClose: h,
|
|
8
|
+
header: n,
|
|
9
|
+
title: I = "",
|
|
10
|
+
subtitle: y,
|
|
11
|
+
children: z,
|
|
12
|
+
normalWidth: g = Z,
|
|
13
|
+
maxWidth: D = W,
|
|
14
|
+
width: k,
|
|
15
|
+
minWidth: a = 480,
|
|
16
|
+
maxResizableWidth: R,
|
|
17
|
+
onWidthChange: r,
|
|
18
|
+
onExpandedChange: c,
|
|
19
|
+
headerActions: M,
|
|
20
|
+
className: P = "",
|
|
21
|
+
headerClassName: S = "",
|
|
22
|
+
bodyClassName: E = ""
|
|
23
|
+
}) => {
|
|
24
|
+
const [v, V] = U(!1), u = o !== "hidden";
|
|
25
|
+
u && !v && V(!0);
|
|
26
|
+
const w = c !== void 0, m = o === "expanded", l = o === "hidden" ? 0 : o === "expanded" ? D : k ?? g, f = Math.max(R ?? Number.POSITIVE_INFINITY, a), b = o === "normal" && u && typeof l == "number" && r !== void 0, p = (e) => Math.min(Math.max(e, a), f), L = Y(), s = G(null);
|
|
27
|
+
J(() => () => {
|
|
28
|
+
var e;
|
|
29
|
+
return (e = s.current) == null ? void 0 : e.call(s);
|
|
30
|
+
}, []);
|
|
31
|
+
const T = (e) => {
|
|
32
|
+
if (!b || typeof l != "number") return;
|
|
33
|
+
e.preventDefault(), e.stopPropagation();
|
|
34
|
+
const d = e.clientX, $ = l, O = document.body.style.cursor, q = document.body.style.userSelect;
|
|
35
|
+
document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
36
|
+
const N = (B) => {
|
|
37
|
+
r == null || r(p($ + d - B.clientX));
|
|
38
|
+
}, x = () => {
|
|
39
|
+
document.body.style.cursor = O, document.body.style.userSelect = q, window.removeEventListener("pointermove", N), window.removeEventListener("pointerup", x), s.current = null;
|
|
40
|
+
};
|
|
41
|
+
s.current = x, window.addEventListener("pointermove", N), window.addEventListener("pointerup", x);
|
|
42
|
+
}, X = (e) => {
|
|
43
|
+
if (!b || typeof l != "number") return;
|
|
44
|
+
const d = e.shiftKey ? 50 : 16;
|
|
45
|
+
e.key === "ArrowLeft" && (e.preventDefault(), r == null || r(p(l + d))), e.key === "ArrowRight" && (e.preventDefault(), r == null || r(p(l - d)));
|
|
46
|
+
}, _ = {
|
|
47
|
+
backgroundImage: "linear-gradient(90deg, rgba(6, 132, 240, 0.1) 0%, rgba(6, 132, 240, 0.1) 100%), linear-gradient(0deg, rgba(255, 255, 255, 0) 60.66%, rgba(255, 255, 255, 0.5) 100%), linear-gradient(90deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.3) 100%)"
|
|
48
|
+
}, j = `flex items-center justify-between pl-6 pr-2 border-b border-secondary gap-2 py-4 ${S}`, A = `flex min-h-0 flex-1 flex-col overflow-y-auto pb-3 ${E} ${n ? "" : "px-5"}`;
|
|
49
|
+
return /* @__PURE__ */ t(
|
|
50
|
+
Q.div,
|
|
51
|
+
{
|
|
52
|
+
className: `relative flex flex-col flex-shrink-0 overflow-hidden min-w-0 h-[calc(98vh-85px)] z-1000 ${P}`,
|
|
53
|
+
initial: !1,
|
|
54
|
+
animate: {
|
|
55
|
+
width: l,
|
|
56
|
+
minWidth: o === "hidden" ? 0 : a || void 0
|
|
57
|
+
},
|
|
58
|
+
transition: C,
|
|
59
|
+
children: u && /* @__PURE__ */ i(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: "h-full w-full min-w-0 flex flex-col rounded-2xl border-l border-t border-b border-white backdrop-blur-[3px] p-2",
|
|
63
|
+
style: _,
|
|
64
|
+
children: [
|
|
65
|
+
b && /* @__PURE__ */ t(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
role: "separator",
|
|
69
|
+
"aria-label": "Resize drawer",
|
|
70
|
+
"aria-orientation": "vertical",
|
|
71
|
+
"aria-valuemin": a,
|
|
72
|
+
"aria-valuemax": Number.isFinite(f) ? f : void 0,
|
|
73
|
+
"aria-valuenow": typeof l == "number" ? Math.round(l) : void 0,
|
|
74
|
+
tabIndex: 0,
|
|
75
|
+
onPointerDown: T,
|
|
76
|
+
onKeyDown: X,
|
|
77
|
+
className: "absolute left-0 top-0 z-10 h-full w-2 -translate-x-1 cursor-col-resize touch-none focus-visible:outline-none"
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ i("div", { className: "h-full w-full bg-white rounded-lg overflow-hidden flex flex-col min-w-0", children: [
|
|
81
|
+
n ?? /* @__PURE__ */ i("header", { className: j, children: [
|
|
82
|
+
/* @__PURE__ */ i("div", { className: `flex-1 flex flex-col gap-0 min-w-0 ${w ? "pr-2" : "pr-16"}`, children: [
|
|
83
|
+
/* @__PURE__ */ t("h2", { id: L, className: "text-lg font-semibold leading-7 text-[#06060a] truncate", children: I }),
|
|
84
|
+
y && /* @__PURE__ */ t("p", { className: "text-sm text-secondary truncate", children: y })
|
|
85
|
+
] }),
|
|
86
|
+
/* @__PURE__ */ i("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
|
|
87
|
+
M,
|
|
88
|
+
w && /* @__PURE__ */ t(
|
|
89
|
+
"button",
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
onClick: () => c == null ? void 0 : c(!m),
|
|
93
|
+
className: "flex items-center justify-center p-2 rounded-lg hover:bg-primary_hover transition-colors cursor-pointer",
|
|
94
|
+
"aria-label": m ? "Collapse sidebar" : "Expand sidebar",
|
|
95
|
+
children: m ? /* @__PURE__ */ t(H, { size: 20, className: "text-fg-quaternary", strokeWidth: 1.67 }) : /* @__PURE__ */ t(K, { size: 20, className: "text-fg-quaternary", strokeWidth: 1.67 })
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ t(
|
|
99
|
+
"button",
|
|
100
|
+
{
|
|
101
|
+
type: "button",
|
|
102
|
+
onClick: h,
|
|
103
|
+
className: "flex items-center justify-center p-2 rounded-lg hover:bg-primary_hover transition-colors cursor-pointer",
|
|
104
|
+
"aria-label": "Close",
|
|
105
|
+
children: /* @__PURE__ */ t(F, { size: 20, className: "text-fg-quaternary", strokeWidth: 1.67 })
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] })
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ t("main", { className: A, children: v ? z : null })
|
|
111
|
+
] })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
se as ExpandableRightDrawer
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/expandable-drawer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,GAChC,MAAM,qBAAqB,CAAC"}
|