@definable/ui 0.1.26 → 0.1.27

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.
@@ -8,6 +8,7 @@ interface SheetProps {
8
8
  enableFullscreen?: boolean;
9
9
  position?: 'left' | 'right' | 'bottom';
10
10
  headerClassName?: string;
11
+ disableOutsideClose?: boolean;
11
12
  }
12
- export declare function Sheet({ isOpen, onClose, children, header, footer, className, enableFullscreen, position, headerClassName }: SheetProps): import('react').ReactPortal | null;
13
+ export declare function Sheet({ isOpen, onClose, children, header, footer, className, enableFullscreen, position, headerClassName, disableOutsideClose }: SheetProps): import('react').ReactPortal | null;
13
14
  export {};
@@ -1,79 +1,81 @@
1
- import { jsxs as l, jsx as t, Fragment as F } from "react/jsx-runtime";
2
- import { Minimize2 as R, Maximize2 as B, X as I } from "lucide-react";
3
- import { Button as x } from "./button.js";
4
- import { useState as M, useRef as X, useEffect as m } from "react";
1
+ import { jsxs as l, jsx as t, Fragment as R } from "react/jsx-runtime";
2
+ import { Minimize2 as B, Maximize2 as I, X as M } from "lucide-react";
3
+ import { Button as b } from "./button.js";
4
+ import { useState as X, useRef as q, useEffect as m } from "react";
5
5
  import { cn as u } from "../lib/utils.js";
6
- import { AnimatePresence as q, motion as b } from "framer-motion";
7
- import { createPortal as D } from "react-dom";
6
+ import { AnimatePresence as D, motion as y } from "framer-motion";
7
+ import { createPortal as G } from "react-dom";
8
8
  let a = [];
9
- function V({
9
+ function W({
10
10
  isOpen: i,
11
- onClose: n,
12
- children: y,
13
- header: g,
11
+ onClose: s,
12
+ children: g,
13
+ header: v,
14
14
  footer: f,
15
- className: v,
16
- enableFullscreen: N = !0,
15
+ className: N,
16
+ enableFullscreen: k = !0,
17
17
  position: c = "right",
18
- headerClassName: k = ""
18
+ headerClassName: w = "",
19
+ disableOutsideClose: h = !1
19
20
  }) {
20
- const [o, w] = M(!1), r = X(null);
21
+ const [n, P] = X(!1), r = q(null);
21
22
  if (m(() => (i ? a.push(r) : a = a.filter((e) => e !== r), () => {
22
23
  a = a.filter((e) => e !== r);
23
24
  }), [i]), m(() => {
24
- const e = (s) => {
25
- var h;
26
- const j = a.some(
27
- (p) => p.current && p.current.contains(s.target)
28
- ), A = (h = s.target) == null ? void 0 : h.closest("[data-sheet-close]");
29
- !j && !A && r.current && !r.current.contains(s.target) && n();
25
+ const e = (o) => {
26
+ var p;
27
+ if (h) return;
28
+ const A = a.some(
29
+ (x) => x.current && x.current.contains(o.target)
30
+ ), F = (p = o.target) == null ? void 0 : p.closest("[data-sheet-close]");
31
+ !A && !F && r.current && !r.current.contains(o.target) && s();
30
32
  };
31
- return i && !o && document.addEventListener("mousedown", e), () => {
33
+ return i && !n && document.addEventListener("mousedown", e), () => {
32
34
  document.removeEventListener("mousedown", e);
33
35
  };
34
- }, [i, o, n]), m(() => {
35
- const e = (s) => {
36
- s.key === "Escape" && i && a[a.length - 1] === r && n();
36
+ }, [i, n, h]), m(() => {
37
+ const e = (o) => {
38
+ o.key === "Escape" && i && a[a.length - 1] === r && s();
37
39
  };
38
40
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
39
- }, [i, n]), !i) return null;
40
- const P = (e) => {
41
- e.stopPropagation(), n();
42
- }, E = /* @__PURE__ */ l("div", { className: "flex flex-col h-full", children: [
41
+ }, [i]), !i) return null;
42
+ const E = (e) => {
43
+ e.stopPropagation(), s();
44
+ }, z = /* @__PURE__ */ l("div", { className: "flex flex-col h-full", children: [
43
45
  /* @__PURE__ */ l("div", { className: u(
44
46
  "flex items-center bg-card justify-between py-4 px-4 h-header border-b border-border/50",
45
- k
47
+ w
46
48
  ), children: [
47
- /* @__PURE__ */ t("div", { className: "text-sm font-medium", children: g }),
49
+ /* @__PURE__ */ t("div", { className: "text-sm font-medium", children: v }),
48
50
  /* @__PURE__ */ l("div", { className: "flex items-center gap-1 ml-auto", children: [
49
- N && /* @__PURE__ */ t(
50
- x,
51
+ k && /* @__PURE__ */ t(
52
+ b,
51
53
  {
52
54
  variant: "ghost",
53
55
  size: "icon",
54
56
  className: "h-7 w-7",
55
57
  onClick: (e) => {
56
- e.stopPropagation(), w(!o);
58
+ e.stopPropagation(), P(!n);
57
59
  },
58
- children: o ? /* @__PURE__ */ t(R, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(B, { className: "h-3.5 w-3.5" })
60
+ children: n ? /* @__PURE__ */ t(B, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5" })
59
61
  }
60
62
  ),
61
63
  /* @__PURE__ */ t(
62
- x,
64
+ b,
63
65
  {
64
66
  variant: "ghost",
65
67
  size: "icon",
66
68
  className: "h-7 w-7",
67
- onClick: P,
69
+ onClick: E,
68
70
  "data-sheet-close": "true",
69
- children: /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5" })
71
+ children: /* @__PURE__ */ t(M, { className: "h-3.5 w-3.5" })
70
72
  }
71
73
  )
72
74
  ] })
73
75
  ] }),
74
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-auto", children: y }),
76
+ /* @__PURE__ */ t("div", { className: "flex-1 overflow-auto", children: g }),
75
77
  f && /* @__PURE__ */ t("div", { className: "border-t border-border/50 bg-card py-2 px-3", children: /* @__PURE__ */ t("div", { className: "text-sm", children: f }) })
76
- ] }), z = () => c === "left" ? {
78
+ ] }), C = () => c === "left" ? {
77
79
  initial: { x: -100, opacity: 0 },
78
80
  animate: { x: 0, opacity: 1 },
79
81
  exit: { x: -100, opacity: 0 }
@@ -85,24 +87,24 @@ function V({
85
87
  initial: { x: 100, opacity: 0 },
86
88
  animate: { x: 0, opacity: 1 },
87
89
  exit: { x: 100, opacity: 0 }
88
- }, C = () => o ? "inset-4 rounded-lg" : c === "left" ? "inset-y-0 left-0 border-r" : c === "bottom" ? "inset-x-0 bottom-0 border-t" : "inset-y-0 right-0 border-l", d = z(), L = C(), S = /* @__PURE__ */ t(q, { children: i && /* @__PURE__ */ l(F, { children: [
90
+ }, L = () => n ? "inset-4 rounded-lg" : c === "left" ? "inset-y-0 left-0 border-r" : c === "bottom" ? "inset-x-0 bottom-0 border-t" : "inset-y-0 right-0 border-l", d = C(), S = L(), j = /* @__PURE__ */ t(D, { children: i && /* @__PURE__ */ l(R, { children: [
89
91
  /* @__PURE__ */ t(
90
- b.div,
92
+ y.div,
91
93
  {
92
94
  initial: { opacity: 0 },
93
95
  animate: { opacity: 1 },
94
96
  exit: { opacity: 0 },
95
97
  onClick: (e) => {
96
- e.stopPropagation(), n();
98
+ e.stopPropagation(), s();
97
99
  },
98
100
  className: u(
99
101
  "fixed inset-0 z-[100] bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
100
- o ? "block" : "hidden"
102
+ n ? "block" : "hidden"
101
103
  )
102
104
  }
103
105
  ),
104
106
  /* @__PURE__ */ t(
105
- b.div,
107
+ y.div,
106
108
  {
107
109
  ref: r,
108
110
  initial: d.initial,
@@ -114,15 +116,15 @@ function V({
114
116
  },
115
117
  className: u(
116
118
  "fixed z-[100] bg-background shadow-lg flex flex-col border-border/50",
117
- L,
118
- v
119
+ S,
120
+ N
119
121
  ),
120
- children: E
122
+ children: z
121
123
  }
122
124
  )
123
125
  ] }) });
124
- return D(S, document.body);
126
+ return G(j, document.body);
125
127
  }
126
128
  export {
127
- V as Sheet
129
+ W as Sheet
128
130
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@definable/ui",
3
3
  "type": "module",
4
- "version": "0.1.26",
4
+ "version": "0.1.27",
5
5
  "private": false,
6
6
  "description": "Definable UI Component Library",
7
7
  "main": "dist/index.js",