@protobase/ui 0.14.3 → 0.14.4

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.
@@ -69,6 +69,15 @@ const AuthGate = ({ workspace, children }) => {
69
69
  useEffect(() => {
70
70
  if (state.kind === "signed-out" && page.kind === "sign-in" && page.providerError) forgetSignInLink();
71
71
  }, [state.kind, page]);
72
+ useEffect(() => {
73
+ if (state.kind !== "signed-out" || !browse) return;
74
+ const leave = () => {
75
+ setPage({ kind: "sign-in" });
76
+ browse();
77
+ };
78
+ window.addEventListener("popstate", leave);
79
+ return () => window.removeEventListener("popstate", leave);
80
+ }, [state.kind, browse]);
72
81
  const signInFailed = useCallback((error) => setPage({
73
82
  kind: "sign-in",
74
83
  error
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.14.3";
2
+ var version = "0.14.4";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };
@@ -11,7 +11,8 @@ export type ResponsiveDialogProps = {
11
11
  };
12
12
  /**
13
13
  * A modal centred on the screen from the `md` breakpoint up, and a sheet rising from the bottom on a phone, switching as
14
- * the viewport does. Both close on Escape and on a press outside, and keep focus inside while open.
14
+ * the viewport does. Both close on Escape and on a press outside, and keep focus inside while open; the sheet also
15
+ * closes when swiped down.
15
16
  */
16
17
  export declare const ResponsiveDialog: ({ title, description, open, onClose, actions, children }: ResponsiveDialogProps) => import("react").JSX.Element | null;
17
18
  //#endregion
@@ -5,21 +5,23 @@ import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/primitives/responsive-dialog.tsx
6
6
  /**
7
7
  * A modal centred on the screen from the `md` breakpoint up, and a sheet rising from the bottom on a phone, switching as
8
- * the viewport does. Both close on Escape and on a press outside, and keep focus inside while open.
8
+ * the viewport does. Both close on Escape and on a press outside, and keep focus inside while open; the sheet also
9
+ * closes when swiped down.
9
10
  */
10
11
  const ResponsiveDialog = ({ title, description, open, onClose, actions, children }) => {
11
- const desktop = useIsDesktop();
12
- if (!open) return null;
13
- if (desktop) return /* @__PURE__ */ jsx(Dialog, {
14
- title,
15
- description,
16
- onClose,
17
- actions,
18
- children
19
- });
12
+ if (useIsDesktop()) {
13
+ if (!open) return null;
14
+ return /* @__PURE__ */ jsx(Dialog, {
15
+ title,
16
+ description,
17
+ onClose,
18
+ actions,
19
+ children
20
+ });
21
+ }
20
22
  return /* @__PURE__ */ jsx(Sheet, {
21
23
  title,
22
- open: true,
24
+ open,
23
25
  onClose,
24
26
  children: /* @__PURE__ */ jsxs("div", {
25
27
  className: "pt-3 text-[13px]",
@@ -1,44 +1,44 @@
1
- import { useFocusTrap } from "../lib/use-focus-trap.js";
2
- import { useRef } from "react";
3
1
  import { X } from "lucide-react";
4
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Drawer } from "@base-ui/react/drawer";
5
4
  //#region src/primitives/sheet.tsx
6
- /** A panel that rises from the bottom of the screen, for the filter panel on phones. */
7
- const Sheet = ({ title, open, onClose, children }) => {
8
- const panel = useRef(null);
9
- useFocusTrap(panel, open, onClose);
10
- if (!open) return null;
11
- return /* @__PURE__ */ jsxs("div", {
12
- className: "fixed inset-0 z-[80]",
13
- children: [/* @__PURE__ */ jsx("div", {
14
- className: "absolute inset-0 bg-foreground/40",
15
- onClick: onClose,
16
- "aria-hidden": true
17
- }), /* @__PURE__ */ jsxs("div", {
18
- ref: panel,
19
- role: "dialog",
20
- "aria-modal": "true",
21
- "aria-label": title,
22
- tabIndex: -1,
23
- className: "absolute inset-x-0 bottom-0 flex max-h-[85vh] flex-col rounded-t-xl border-t bg-background shadow-pop outline-none",
24
- children: [/* @__PURE__ */ jsxs("header", {
25
- className: "flex shrink-0 items-center justify-between border-b px-4",
26
- children: [/* @__PURE__ */ jsx("h2", {
27
- className: "text-[15px] font-semibold",
28
- children: title
29
- }), /* @__PURE__ */ jsx("button", {
30
- type: "button",
31
- "aria-label": "Close",
32
- onClick: onClose,
33
- className: "-mr-2 inline-flex size-11 items-center justify-center rounded-md text-muted-foreground hover:bg-muted",
34
- children: /* @__PURE__ */ jsx(X, { className: "size-5" })
35
- })]
36
- }), /* @__PURE__ */ jsx("div", {
37
- className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-6",
38
- children
39
- })]
40
- })]
41
- });
42
- };
5
+ const motion = "transition-[transform,opacity] duration-[400ms] ease-[cubic-bezier(0.32,0.72,0,1)] data-swiping:duration-0 data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] motion-reduce:duration-0";
6
+ /**
7
+ * A panel that rises from the bottom of the screen, for the filter panel and `ResponsiveDialog` on phones. It closes
8
+ * when swiped down, on its close button, on a press outside and on Escape, and keeps focus inside while open (Base UI's
9
+ * `Drawer`).
10
+ */
11
+ const Sheet = ({ title, open, onClose, children }) => /* @__PURE__ */ jsx(Drawer.Root, {
12
+ open,
13
+ onOpenChange: (next) => !next && onClose(),
14
+ children: /* @__PURE__ */ jsxs(Drawer.Portal, { children: [/* @__PURE__ */ jsx(Drawer.Backdrop, { className: `fixed inset-0 z-[80] bg-foreground/40 opacity-[calc(1-var(--drawer-swipe-progress))] data-starting-style:opacity-0 data-ending-style:opacity-0 ${motion}` }), /* @__PURE__ */ jsx(Drawer.Viewport, {
15
+ className: "fixed inset-0 z-[80] flex items-end",
16
+ children: /* @__PURE__ */ jsxs(Drawer.Popup, {
17
+ className: `flex max-h-[85vh] w-full flex-col rounded-t-xl border-t bg-background shadow-pop outline-none [transform:translateY(var(--drawer-swipe-movement-y))] data-starting-style:[transform:translateY(100%)] data-ending-style:[transform:translateY(100%)] data-swiping:select-none ${motion}`,
18
+ children: [
19
+ /* @__PURE__ */ jsx("div", {
20
+ className: "flex shrink-0 justify-center pt-2",
21
+ "aria-hidden": true,
22
+ children: /* @__PURE__ */ jsx("div", { className: "h-1 w-10 rounded-full bg-border-strong" })
23
+ }),
24
+ /* @__PURE__ */ jsxs("header", {
25
+ className: "flex shrink-0 items-center justify-between border-b px-4",
26
+ children: [/* @__PURE__ */ jsx(Drawer.Title, {
27
+ className: "text-[15px] font-semibold",
28
+ children: title
29
+ }), /* @__PURE__ */ jsx(Drawer.Close, {
30
+ "aria-label": "Close",
31
+ className: "-mr-2 inline-flex size-11 items-center justify-center rounded-md text-muted-foreground hover:bg-muted",
32
+ children: /* @__PURE__ */ jsx(X, { className: "size-5" })
33
+ })]
34
+ }),
35
+ /* @__PURE__ */ jsx(Drawer.Content, {
36
+ className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-6",
37
+ children
38
+ })
39
+ ]
40
+ })
41
+ })] })
42
+ });
43
43
  //#endregion
44
44
  export { Sheet };