@protobase/ui 0.12.22 → 0.13.3

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.
Files changed (63) hide show
  1. package/dist/app/create/create-page.js +1 -0
  2. package/dist/app/current-address.d.ts +3 -2
  3. package/dist/app/current-address.js +2 -1
  4. package/dist/app/delete/use-delete-flow.js +2 -1
  5. package/dist/app/displays/card-carousel.js +4 -1
  6. package/dist/app/displays/card-layout.js +19 -0
  7. package/dist/app/displays/card-photos.js +6 -3
  8. package/dist/app/displays/cards-display.js +16 -11
  9. package/dist/app/displays/list-cards.js +50 -0
  10. package/dist/app/displays/list-displays.js +4 -3
  11. package/dist/app/displays/map-display.js +83 -23
  12. package/dist/app/displays/map-groups.js +1 -8
  13. package/dist/app/displays/record-card.js +8 -6
  14. package/dist/app/displays/use-map-records.js +44 -0
  15. package/dist/app/displays/virtual-cards.js +138 -0
  16. package/dist/app/embedded-list/embedded-columns.js +52 -0
  17. package/dist/app/embedded-list/embedded-display.js +26 -0
  18. package/dist/app/embedded-list/embedded-list.js +157 -0
  19. package/dist/app/embedded-list/use-embedded-display.js +23 -0
  20. package/dist/app/embedded-list/use-embedded-rows.js +33 -0
  21. package/dist/app/file-field.js +16 -13
  22. package/dist/app/list-page.js +19 -6
  23. package/dist/app/list-scroll.js +25 -0
  24. package/dist/app/map/map-area.js +53 -0
  25. package/dist/app/map/records-map.js +91 -38
  26. package/dist/app/pages/blocks/table.js +21 -41
  27. package/dist/app/pages/field-value.js +22 -9
  28. package/dist/app/record-page.js +2 -1
  29. package/dist/app/related-section.js +30 -52
  30. package/dist/app/router.js +1 -0
  31. package/dist/app/use-record-editor.js +2 -1
  32. package/dist/data/api-provider.d.ts +2 -0
  33. package/dist/data/query-keys.js +9 -0
  34. package/dist/data/use-update-record.js +1 -0
  35. package/dist/data-grid/cells.js +8 -5
  36. package/dist/data-grid/data-grid.js +19 -39
  37. package/dist/data-grid/geometry.js +7 -9
  38. package/dist/data-grid/use-grid-scroll.js +8 -1
  39. package/dist/data-grid/use-virtual-rows.js +31 -0
  40. package/dist/live/columns-from-model.js +6 -4
  41. package/dist/live/file-image.js +35 -0
  42. package/dist/live/file-values.js +17 -1
  43. package/dist/live/grid-loader.js +26 -10
  44. package/dist/package.js +1 -1
  45. package/dist/record-view/section.js +24 -17
  46. package/dist/shell/assets/app-CfuMqqAY.js +66 -0
  47. package/dist/shell/assets/index-CYWfU_c1.css +2 -0
  48. package/dist/shell/assets/{index-B8MhIaLr.js → index-DCTyUhH-.js} +3 -3
  49. package/dist/shell/assets/maplibre-gl-DP9hPAtI.js +1 -0
  50. package/dist/shell/assets/record-map-Dgn4pFlE.js +814 -0
  51. package/dist/shell/assets/records-map-3O6u05bx.js +1 -0
  52. package/dist/shell/assets/shared-protobase-ui-C84DU2o6.js +1 -0
  53. package/dist/shell/index.html +5 -5
  54. package/dist/shell/protobase.shell.json +1 -1
  55. package/package.json +5 -5
  56. package/dist/app/pages/record-table.js +0 -114
  57. package/dist/app/pages/use-relation-labels.js +0 -30
  58. package/dist/shell/assets/app-BYw-8qpE.js +0 -66
  59. package/dist/shell/assets/index-CdSIk0BQ.css +0 -2
  60. package/dist/shell/assets/navigation-control-CGS0pamh.js +0 -814
  61. package/dist/shell/assets/record-map-9Y3IL_dg.js +0 -1
  62. package/dist/shell/assets/records-map-DXIWowJ3.js +0 -1
  63. package/dist/shell/assets/shared-protobase-ui-Bol6wL_S.js +0 -1
@@ -4,11 +4,12 @@ import { withLabels } from "./relation-labels.js";
4
4
  //#region src/live/grid-loader.ts
5
5
  const exactBelow = 5e3;
6
6
  /**
7
- * Loads fixed-size pages by number. Sequential scrolling follows `next_page_token`; a jump asks `:seek` for the
8
- * page at that row position. Every page is cached by TanStack Query.
7
+ * Loads fixed-size pages by number. The page after a cached or loading one follows that page's `next_page_token`; a
8
+ * jump to a page whose predecessor is neither asks `:seek` for the page at that row position, so the pages of one jump
9
+ * are read on from a single seek. Every page is cached by TanStack Query.
9
10
  */
10
11
  const createGridLoader = ({ queryClient, client, resources, views, model, columns, filter, orderBy }) => {
11
- const tokens = /* @__PURE__ */ new Map();
12
+ const pageKey = (number) => keys.page(model.name, filter, orderBy, 40, number);
12
13
  /** The server's total is a planner estimate, off by a lot for small results; settle those exactly. */
13
14
  const firstPageTotal = async (result) => {
14
15
  if (result.nextPageToken === "") return result.items.length;
@@ -20,36 +21,51 @@ const createGridLoader = ({ queryClient, client, resources, views, model, column
20
21
  count: "exact"
21
22
  })).totalSize ?? result.totalSizeEstimate;
22
23
  };
24
+ /** The token that continues after the page before `number`, or undefined when that page is neither cached nor loading. */
25
+ const tokenBefore = async (number) => {
26
+ if (number === 0) return "";
27
+ const key = pageKey(number - 1);
28
+ const cached = queryClient.getQueryData(key);
29
+ if (cached) return cached.nextPageToken;
30
+ if (queryClient.getQueryState(key)?.fetchStatus !== "fetching") return void 0;
31
+ return (await page(number - 1)).nextPageToken;
32
+ };
23
33
  const fetchPage = async (page) => {
24
- const token = tokens.get(page);
34
+ const token = await tokenBefore(page);
35
+ if (page > 0 && token === "") return {
36
+ rows: [],
37
+ total: 0,
38
+ nextPageToken: ""
39
+ };
25
40
  const params = {
26
41
  filter,
27
42
  orderBy,
28
43
  pageSize: 40
29
44
  };
30
- const result = page === 0 || token !== void 0 ? await client.list(model.name, {
45
+ const result = token !== void 0 ? await client.list(model.name, {
31
46
  ...params,
32
- pageToken: token ?? ""
47
+ pageToken: token
33
48
  }) : await client.seek(model.name, {
34
49
  ...params,
35
50
  position: page * 40
36
51
  });
37
52
  if (result.items.length === 0 && page > 0) return {
38
53
  rows: [],
39
- total: 0
54
+ total: 0,
55
+ nextPageToken: ""
40
56
  };
41
- tokens.set(page + 1, result.nextPageToken);
42
57
  const ids = result.items.map((record) => recordId(model, record));
43
58
  return {
44
59
  rows: (await withLabels(queryClient, client, resources, views, model, columns, result.items)).map((record, index) => ({
45
60
  ...record,
46
61
  id: ids[index]
47
62
  })),
48
- total: page === 0 ? await firstPageTotal(result) : result.totalSizeEstimate
63
+ total: page === 0 ? await firstPageTotal(result) : result.totalSizeEstimate,
64
+ nextPageToken: result.nextPageToken
49
65
  };
50
66
  };
51
67
  const page = (number) => queryClient.fetchQuery({
52
- queryKey: keys.page(model.name, filter, orderBy, 40, number),
68
+ queryKey: pageKey(number),
53
69
  staleTime: 6e4,
54
70
  queryFn: () => fetchPage(number)
55
71
  });
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.12.22";
2
+ var version = "0.13.3";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };
@@ -1,21 +1,28 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  //#region src/record-view/section.tsx
3
- const Section = ({ title, help, children }) => /* @__PURE__ */ jsxs("section", {
4
- className: "py-8 first:pt-8",
5
- children: [
6
- /* @__PURE__ */ jsx("h2", {
7
- className: "text-[15px] font-semibold text-foreground",
8
- children: title
9
- }),
10
- help && /* @__PURE__ */ jsx("p", {
11
- className: "mt-1 max-w-xl text-[13px] leading-relaxed text-muted-foreground",
12
- children: help
13
- }),
14
- /* @__PURE__ */ jsx("div", {
15
- className: "mt-5",
16
- children
17
- })
18
- ]
19
- });
3
+ /** A titled part of the record page; `actions` sit at the end of the title's line. */
4
+ const Section = ({ title, help, actions, children }) => {
5
+ const heading = /* @__PURE__ */ jsx("h2", {
6
+ className: "text-[15px] font-semibold text-foreground",
7
+ children: title
8
+ });
9
+ return /* @__PURE__ */ jsxs("section", {
10
+ className: "py-8 first:pt-8",
11
+ children: [
12
+ actions ? /* @__PURE__ */ jsxs("div", {
13
+ className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2",
14
+ children: [heading, actions]
15
+ }) : heading,
16
+ help && /* @__PURE__ */ jsx("p", {
17
+ className: "mt-1 max-w-xl text-[13px] leading-relaxed text-muted-foreground",
18
+ children: help
19
+ }),
20
+ /* @__PURE__ */ jsx("div", {
21
+ className: "mt-5",
22
+ children
23
+ })
24
+ ]
25
+ });
26
+ };
20
27
  //#endregion
21
28
  export { Section };