@protobase/ui 0.45.11 → 0.45.13

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/app/app.js CHANGED
@@ -47,6 +47,7 @@ import { OrganizationPage } from "../organizations/organization-page.js";
47
47
  import { OrganizationsPage } from "../organizations/organizations-page.js";
48
48
  import { actingUser } from "../roles/acting-user.js";
49
49
  import { useActiveRole } from "../roles/use-active-role.js";
50
+ import { startAddress } from "./start-address.js";
50
51
  import { ProjectLogo } from "./project-logo.js";
51
52
  import { PluginGate, usePluginsOff } from "../plugins/plugin-gate.js";
52
53
  import { PluginNotice } from "../plugins/plugin-notice.js";
@@ -59,7 +60,7 @@ import { NewVersionToast } from "./new-version/new-version-toast.js";
59
60
  import { RuntimeUpdateButton } from "./runtime/runtime-update.js";
60
61
  import { StaffBanner } from "./staff-banner.js";
61
62
  import { useNavRecent } from "./use-nav-recent.js";
62
- import { useCallback, useEffect, useState } from "react";
63
+ import { useCallback, useEffect, useMemo, useState } from "react";
63
64
  import { viewOfList } from "@protobase/schema/internal";
64
65
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
65
66
  import { connectRoute } from "@protobase/schema";
@@ -93,23 +94,13 @@ const Routes = ({ workspace, sidebarMode, assistant, runtime }) => {
93
94
  });
94
95
  useLiveUpdates(meta);
95
96
  const groups = navFromMeta(meta, basePath, recent);
96
- const firstPage = Object.keys(meta.pages)[0];
97
- const firstResource = Object.keys(meta.resources)[0];
97
+ const start = useMemo(() => startAddress(meta), [meta]);
98
98
  const page = address?.kind === "page" ? meta.pages[address.page] : void 0;
99
99
  useEffect(() => {
100
- if (path !== "/") return;
101
- if (firstPage) go({
102
- kind: "page",
103
- page: firstPage
104
- }, { replace: true });
105
- else if (firstResource) go({
106
- kind: "list",
107
- resource: firstResource
108
- }, { replace: true });
100
+ if (path === "/" && start) go(start, { replace: true });
109
101
  }, [
110
102
  path,
111
- firstPage,
112
- firstResource,
103
+ start,
113
104
  go
114
105
  ]);
115
106
  const resource = address?.kind === "page" ? void 0 : address?.resource;
package/dist/app/main.js CHANGED
@@ -2,6 +2,7 @@ import { browserLocale } from "../locale/active-locale.js";
2
2
  import { nativeBridgeOf } from "./native-auth-fetch.js";
3
3
  import { uiFromModule } from "./pages/ui-from-module.js";
4
4
  import { App } from "./app.js";
5
+ import { showKeyboardAccessoryBar } from "./native-keyboard.js";
5
6
  import { applyNativeViewport } from "./native-viewport.js";
6
7
  import { pageApiOrigin } from "./page-api-origin.js";
7
8
  import { StrictMode } from "react";
@@ -13,7 +14,10 @@ import "../styles.css";
13
14
  const root = document.getElementById("root");
14
15
  if (!root) throw new Error("index.html needs an element with id \"root\"");
15
16
  const nativeBridge = nativeBridgeOf(window);
16
- if (nativeBridge) applyNativeViewport(document);
17
+ if (nativeBridge) {
18
+ applyNativeViewport(document);
19
+ showKeyboardAccessoryBar(nativeBridge);
20
+ }
17
21
  createRoot(root).render(/* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(App, {
18
22
  baseUrl: `${pageApiOrigin() ?? ""}/api/v1`,
19
23
  ui: uiFromModule(projectUi),
@@ -3,6 +3,7 @@
3
3
  export type NativeBridge = {
4
4
  isNativePlatform(): boolean;
5
5
  getPlatform(): string;
6
+ isPluginAvailable(name: string): boolean;
6
7
  nativePromise(plugin: string, method: string, options: object): Promise<unknown>;
7
8
  };
8
9
  //#endregion
@@ -0,0 +1,12 @@
1
+ //#region src/app/native-keyboard.ts
2
+ /**
3
+ * Gives the iOS app's keyboard back the bar above it, with the arrows to the previous and next field and Done, which
4
+ * Capacitor's keyboard plugin hides when it loads and has no setting for. A binary built before it had the plugin,
5
+ * and Android, which has no such bar, are left as they are.
6
+ */
7
+ const showKeyboardAccessoryBar = async (bridge) => {
8
+ if (bridge.getPlatform() !== "ios" || !bridge.isPluginAvailable("Keyboard")) return;
9
+ await bridge.nativePromise("Keyboard", "setAccessoryBarVisible", { isVisible: true });
10
+ };
11
+ //#endregion
12
+ export { showKeyboardAccessoryBar };
@@ -0,0 +1,33 @@
1
+ import { navFromMeta } from "./nav-from-meta.js";
2
+ //#region src/app/start-address.ts
3
+ /**
4
+ * Where the app opens at `/`: the first sidebar entry the caller sees that opens what it names; with none, the first
5
+ * page, else the first resource's list.
6
+ */
7
+ const startAddress = (meta) => {
8
+ const first = navFromMeta(meta).flatMap((group) => group.items).find((item) => !item.problem);
9
+ if (first && meta.pages[first.id]) return {
10
+ kind: "page",
11
+ page: first.id
12
+ };
13
+ if (first) {
14
+ const [resource, list] = first.id.split("/");
15
+ return {
16
+ kind: "list",
17
+ resource,
18
+ ...list !== void 0 && { list }
19
+ };
20
+ }
21
+ const firstPage = Object.keys(meta.pages)[0];
22
+ if (firstPage) return {
23
+ kind: "page",
24
+ page: firstPage
25
+ };
26
+ const firstResource = Object.keys(meta.resources)[0];
27
+ return firstResource ? {
28
+ kind: "list",
29
+ resource: firstResource
30
+ } : void 0;
31
+ };
32
+ //#endregion
33
+ export { startAddress };
@@ -7,6 +7,9 @@ export type AuthLayoutProps = {
7
7
  size?: 'sm' | 'md';
8
8
  children: ReactNode;
9
9
  };
10
- /** The frame of the sign-in and first-run pages and of public forms: logo, title and a card. */
10
+ /**
11
+ * The frame of the sign-in and first-run pages and of public forms: logo, title and a card. On a page as short as a
12
+ * phone's above its keyboard the logo and most of the margins go, so the card still shows whole above the keyboard.
13
+ */
11
14
  export declare const AuthLayout: ({ title, description, size, children }: AuthLayoutProps) => import("react").JSX.Element;
12
15
  //#endregion
@@ -2,17 +2,20 @@ import { cn } from "../lib/cn.js";
2
2
  import { LogoMark } from "../app-shell/logo.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/auth/auth-layout.tsx
5
- /** The frame of the sign-in and first-run pages and of public forms: logo, title and a card. */
5
+ /**
6
+ * The frame of the sign-in and first-run pages and of public forms: logo, title and a card. On a page as short as a
7
+ * phone's above its keyboard the logo and most of the margins go, so the card still shows whole above the keyboard.
8
+ */
6
9
  const AuthLayout = ({ title, description, size = "sm", children }) => /* @__PURE__ */ jsx("div", {
7
- className: "flex min-h-full w-full items-center justify-center bg-surface px-4 pb-[calc(2.5rem+var(--pb-safe-bottom))] pt-[calc(2.5rem+var(--pb-safe-top))]",
10
+ className: "flex min-h-full w-full items-center justify-center bg-surface px-4 pb-[calc(2.5rem+var(--pb-safe-bottom))] pt-[calc(2.5rem+var(--pb-safe-top))] short:pb-[calc(1rem+var(--pb-safe-bottom))] short:pt-[calc(1rem+var(--pb-safe-top))]",
8
11
  children: /* @__PURE__ */ jsxs("div", {
9
12
  className: cn("w-full", size === "sm" ? "max-w-sm" : "max-w-lg"),
10
13
  children: [/* @__PURE__ */ jsxs("div", {
11
- className: "mb-6 flex flex-col items-center text-center",
14
+ className: "mb-6 flex flex-col items-center text-center short:mb-4",
12
15
  children: [
13
- /* @__PURE__ */ jsx(LogoMark, { className: "size-10" }),
16
+ /* @__PURE__ */ jsx(LogoMark, { className: "size-10 short:hidden" }),
14
17
  /* @__PURE__ */ jsx("h1", {
15
- className: "mt-4 text-xl font-semibold tracking-tight",
18
+ className: "mt-4 text-xl font-semibold tracking-tight short:mt-0",
16
19
  children: title
17
20
  }),
18
21
  description && /* @__PURE__ */ jsx("p", {
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.45.11";
2
+ var version = "0.45.13";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };