@loczer/storefront-sdk 0.214.0 → 0.215.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/ui/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,KAAK,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAoB1D,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;IACjD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED,iBAAS,MAAM,CAAC,EACd,IAAI,EAAE,QAAQ,EACd,WAAmB,EACnB,YAAY,EACZ,SAAoB,EACpB,QAAQ,EACR,KAAY,EACZ,WAAkB,EAClB,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,iBAAiB,EACnC,UAAU,EAAE,WAAW,EACvB,eAAe,EAAE,gBAAgB,EACjC,kBAAkB,EAAE,mBAAmB,EACvC,UAAiB,GAClB,EAAE,WAAW,2CA4Bb;AAMD,QAAA,MAAM,aAAa;cAHP,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M,aAAa;2BAHM,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE;YAAE,aAAa,EAAE,YAAY,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI;wCAiCpF,CAAA;AAUD,QAAA,MAAM,aAAa;wBANG,MAAM;iBACb,MAAM;2BACI,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE;YAAE,aAAa,EAAE,YAAY,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI;sBACjE,OAAO;wCAsE1B,CAAA;AAGD,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,2CAWzE;AAED,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,2CAQzE;AAED,QAAA,MAAM,WAAW,qHAUf,CAAA;AAGF,QAAA,MAAM,iBAAiB,yHAUrB,CAAA;AAGF,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,iBAAiB,GAClB,CAAA"}
package/dist/ui/drawer.js CHANGED
@@ -6,34 +6,45 @@ import { cn as a } from "@rpcbase/ui";
6
6
  import { X as o } from "lucide-react";
7
7
  import { createPortal as s } from "react-dom";
8
8
  //#region src/ui/drawer.tsx
9
- var c = n.createContext(null), l = () => {
10
- let e = n.useContext(c);
9
+ var c = 250, l = n.createContext(null), u = () => {
10
+ let e = n.useContext(l);
11
11
  if (!e) throw Error("Drawer components must be used within <Drawer>");
12
12
  return e;
13
13
  };
14
- function u({ open: e, defaultOpen: t = !1, onOpenChange: i, direction: a = "bottom", children: o, modal: s = !0, dismissible: l = !0, fixed: u, repositionInputs: d, snapPoints: f, activeSnapPoint: p, setActiveSnapPoint: m, lockScroll: h = !0 }) {
15
- let [g, _] = n.useState(t), v = e !== void 0, y = v ? e : g;
14
+ function d({ open: e, defaultOpen: t = !1, onOpenChange: i, direction: a = "bottom", children: o, modal: s = !0, dismissible: u = !0, fixed: d, repositionInputs: f, snapPoints: p, activeSnapPoint: m, setActiveSnapPoint: h, lockScroll: g = !0 }) {
15
+ let [_, v] = n.useState(t), y = e !== void 0, b = y ? e : _, [x, S] = n.useState(b);
16
16
  return n.useEffect(() => {
17
- if (!y || !h || typeof document > "u") return;
17
+ if (!b || !g || typeof document > "u") return;
18
18
  let e = document.body.style.overflow;
19
19
  return document.body.style.overflow = "hidden", () => {
20
20
  document.body.style.overflow = e;
21
21
  };
22
- }, [h, y]), /* @__PURE__ */ r(c.Provider, {
22
+ }, [g, b]), n.useEffect(() => {
23
+ if (b) {
24
+ S(!0);
25
+ return;
26
+ }
27
+ if (!x) return;
28
+ let e = window.setTimeout(() => {
29
+ S(!1);
30
+ }, c);
31
+ return () => window.clearTimeout(e);
32
+ }, [b, x]), /* @__PURE__ */ r(l.Provider, {
23
33
  value: {
24
- open: y,
34
+ open: b,
35
+ present: x,
25
36
  setOpen: (e) => {
26
- v || _(e), i?.(e);
37
+ y || v(e), i?.(e);
27
38
  },
28
39
  direction: a,
29
40
  modal: s,
30
- dismissible: l
41
+ dismissible: u
31
42
  },
32
43
  children: o
33
44
  });
34
45
  }
35
- var d = n.forwardRef(({ asChild: t, onClick: n, ...i }, a) => {
36
- let { setOpen: o } = l();
46
+ var f = n.forwardRef(({ asChild: t, onClick: n, ...i }, a) => {
47
+ let { setOpen: o } = u();
37
48
  return /* @__PURE__ */ r(t ? e : "button", {
38
49
  ref: a,
39
50
  "data-slot": "drawer-trigger",
@@ -43,19 +54,19 @@ var d = n.forwardRef(({ asChild: t, onClick: n, ...i }, a) => {
43
54
  ...i
44
55
  });
45
56
  });
46
- d.displayName = "DrawerTrigger";
47
- function f({ children: e, container: i }) {
48
- let { open: a, modal: o } = l(), [c, u] = n.useState(!1), d = n.useRef(null);
57
+ f.displayName = "DrawerTrigger";
58
+ function p({ children: e, container: i }) {
59
+ let { open: a, present: o, modal: c } = u(), [l, d] = n.useState(!1), f = n.useRef(null);
49
60
  return n.useEffect(() => {
50
- u(!0);
51
- }, []), t(a && c && o, d), !a || !c || typeof document > "u" ? null : s(/* @__PURE__ */ r("div", {
52
- ref: d,
61
+ d(!0);
62
+ }, []), t(a && l && c, f), !o || !l || typeof document > "u" ? null : s(/* @__PURE__ */ r("div", {
63
+ ref: f,
53
64
  "data-slot": "drawer-portal",
54
65
  children: e
55
66
  }), i ?? document.body);
56
67
  }
57
- var p = n.forwardRef(({ asChild: t, onClick: n, ...i }, a) => {
58
- let { setOpen: o } = l();
68
+ var m = n.forwardRef(({ asChild: t, onClick: n, ...i }, a) => {
69
+ let { setOpen: o } = u();
59
70
  return /* @__PURE__ */ r(t ? e : "button", {
60
71
  ref: a,
61
72
  "data-slot": "drawer-close",
@@ -65,44 +76,44 @@ var p = n.forwardRef(({ asChild: t, onClick: n, ...i }, a) => {
65
76
  ...i
66
77
  });
67
78
  });
68
- p.displayName = "DrawerClose";
69
- var m = n.forwardRef(({ className: e, onClick: t, onPointerDownOutside: n, ...i }, o) => {
70
- let { setOpen: s, dismissible: c } = l();
79
+ m.displayName = "DrawerClose";
80
+ var h = n.forwardRef(({ className: e, onClick: t, onPointerDownOutside: n, ...i }, o) => {
81
+ let { open: s, setOpen: c, dismissible: l } = u();
71
82
  return /* @__PURE__ */ r("div", {
72
83
  ref: o,
73
84
  "data-slot": "drawer-overlay",
74
- "data-state": "open",
75
- className: a("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50", e),
85
+ "data-state": s ? "open" : "closed",
86
+ className: a("fixed inset-0 z-50 bg-black/50 duration-200 data-[state=open]:animate-in data-[state=closed]:pointer-events-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", e),
76
87
  onPointerDown: (e) => {
77
88
  n?.({ detail: { originalEvent: e.nativeEvent } });
78
89
  },
79
90
  onClick: (e) => {
80
- t?.(e), !(e.defaultPrevented || !c) && (e.stopPropagation(), s(!1));
91
+ t?.(e), !(e.defaultPrevented || !l) && (e.stopPropagation(), c(!1));
81
92
  },
82
93
  ...i
83
94
  });
84
95
  });
85
- m.displayName = "DrawerOverlay";
86
- var h = n.forwardRef(({ className: e, children: t, closeButtonTestId: s = "drawer-close", closeLabel: c = "Close", onPointerDownOutside: u, showCloseButton: d = !1, ...h }, g) => {
87
- let { direction: _, setOpen: v, dismissible: y } = l();
96
+ h.displayName = "DrawerOverlay";
97
+ var g = n.forwardRef(({ className: e, children: t, closeButtonTestId: s = "drawer-close", closeLabel: c = "Close", onPointerDownOutside: l, showCloseButton: d = !1, ...f }, g) => {
98
+ let { direction: _, open: v, setOpen: y, dismissible: b } = u();
88
99
  return n.useEffect(() => {
89
100
  if (typeof document > "u") return;
90
101
  let e = (e) => {
91
- y && e.key === "Escape" && v(!1);
102
+ b && e.key === "Escape" && y(!1);
92
103
  };
93
104
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
94
- }, [y, v]), /* @__PURE__ */ i(f, { children: [/* @__PURE__ */ r(m, { onPointerDownOutside: u }), /* @__PURE__ */ i("div", {
105
+ }, [b, y]), /* @__PURE__ */ i(p, { children: [/* @__PURE__ */ r(h, { onPointerDownOutside: l }), /* @__PURE__ */ i("div", {
95
106
  ref: g,
96
107
  "data-slot": "drawer-content",
97
108
  "data-drawer-direction": _,
98
- "data-state": "open",
109
+ "data-state": v ? "open" : "closed",
99
110
  role: "dialog",
100
111
  "aria-modal": "true",
101
- className: a("group/drawer-content bg-background fixed z-50 flex h-auto flex-col", _ === "top" && "inset-x-0 top-0 mb-24 max-h-[80vh] rounded-b-lg border-b", _ === "bottom" && "inset-x-0 bottom-0 max-h-[95dvh] rounded-t-lg border-t", _ === "right" && "inset-y-0 right-0 w-3/4 border-l sm:max-w-sm", _ === "left" && "inset-y-0 left-0 w-3/4 border-r sm:max-w-sm", e),
102
- ...h,
112
+ className: a("group/drawer-content bg-background fixed z-50 flex h-auto flex-col duration-200 data-[state=open]:animate-in data-[state=closed]:pointer-events-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", _ === "top" && "inset-x-0 top-0 mb-24 max-h-[80vh] rounded-b-lg border-b data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top", _ === "bottom" && "inset-x-0 bottom-0 max-h-[95dvh] rounded-t-lg border-t data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom", _ === "right" && "inset-y-0 right-0 w-3/4 border-l data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right sm:max-w-sm", _ === "left" && "inset-y-0 left-0 w-3/4 border-r data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left sm:max-w-sm", e),
113
+ ...f,
103
114
  children: [
104
115
  /* @__PURE__ */ r("div", { className: "bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[drawer-direction=bottom]/drawer-content:block" }),
105
- d ? /* @__PURE__ */ r(p, {
116
+ d ? /* @__PURE__ */ r(m, {
106
117
  asChild: !0,
107
118
  children: /* @__PURE__ */ r("button", {
108
119
  type: "button",
@@ -121,34 +132,34 @@ var h = n.forwardRef(({ className: e, children: t, closeButtonTestId: s = "drawe
121
132
  ]
122
133
  })] });
123
134
  });
124
- h.displayName = "DrawerContent";
125
- function g({ className: e, ...t }) {
135
+ g.displayName = "DrawerContent";
136
+ function _({ className: e, ...t }) {
126
137
  return /* @__PURE__ */ r("div", {
127
138
  "data-slot": "drawer-header",
128
139
  className: a("flex flex-col gap-0.5 p-4 group-data-[drawer-direction=bottom]/drawer-content:text-center group-data-[drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left", e),
129
140
  ...t
130
141
  });
131
142
  }
132
- function _({ className: e, ...t }) {
143
+ function v({ className: e, ...t }) {
133
144
  return /* @__PURE__ */ r("div", {
134
145
  "data-slot": "drawer-footer",
135
146
  className: a("mt-auto flex flex-col gap-2 p-4", e),
136
147
  ...t
137
148
  });
138
149
  }
139
- var v = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ r("h2", {
150
+ var y = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ r("h2", {
140
151
  ref: n,
141
152
  "data-slot": "drawer-title",
142
153
  className: a("text-foreground font-semibold", e),
143
154
  ...t
144
155
  }));
145
- v.displayName = "DrawerTitle";
146
- var y = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ r("p", {
156
+ y.displayName = "DrawerTitle";
157
+ var b = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ r("p", {
147
158
  ref: n,
148
159
  "data-slot": "drawer-description",
149
160
  className: a("text-muted-foreground text-sm", e),
150
161
  ...t
151
162
  }));
152
- y.displayName = "DrawerDescription";
163
+ b.displayName = "DrawerDescription";
153
164
  //#endregion
154
- export { u as Drawer, p as DrawerClose, h as DrawerContent, y as DrawerDescription, _ as DrawerFooter, g as DrawerHeader, m as DrawerOverlay, f as DrawerPortal, v as DrawerTitle, d as DrawerTrigger };
165
+ export { d as Drawer, m as DrawerClose, g as DrawerContent, b as DrawerDescription, v as DrawerFooter, _ as DrawerHeader, h as DrawerOverlay, p as DrawerPortal, y as DrawerTitle, f as DrawerTrigger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loczer/storefront-sdk",
3
- "version": "0.214.0",
3
+ "version": "0.215.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"