@protobase/ui 0.19.11 → 0.19.12

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.
@@ -104,7 +104,6 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
104
104
  const { basePath } = useRouter();
105
105
  const { address, go, open } = useAppAddress();
106
106
  const view = meta.views[model.name];
107
- const singular = view?.names?.singular ?? humanize(model.name);
108
107
  const title = recordTitle(model, view, stored.record, recordKey);
109
108
  const { state: auth } = useAuth();
110
109
  const linesModel = useMemo(() => findLinesResource(meta.resources, model), [meta.resources, model]);
@@ -153,7 +152,7 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
153
152
  const sidebarFields = layout.flatMap((item) => item.kind === "sidebar" ? item.fields : []);
154
153
  const hasStatus = model.fields.status?.type === "enum";
155
154
  const statusValue = stored.record.status;
156
- const status = hasStatus && statusValue !== null && statusValue !== void 0 && statusValue !== "" ? String(statusValue) : void 0;
155
+ const status = hasStatus && !sidebarFields.includes("status") && statusValue !== null && statusValue !== void 0 && statusValue !== "" ? String(statusValue) : void 0;
157
156
  const updatedAt = auditField(model, "updated");
158
157
  const hint = (name) => view?.fields[name];
159
158
  const visible = (name) => fieldAccess(stored.permissions, name) !== "hidden";
@@ -264,29 +263,23 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
264
263
  snapshot: stored.record
265
264
  }) : void 0;
266
265
  const formControls = shown === "form" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
267
- editor.dirty && /* @__PURE__ */ jsx("span", {
268
- className: "text-xs text-muted-foreground",
269
- children: "Unsaved changes"
270
- }),
271
- editor.dirty && !leavesForm && /* @__PURE__ */ jsx(Button, {
272
- className: "max-md:min-h-11",
273
- disabled: editor.saving,
274
- onClick: editor.discard,
275
- children: "Discard"
276
- }),
277
- leavesForm && /* @__PURE__ */ jsx(AppLink, {
278
- to: readAddress,
279
- className: cn(buttonClass(), "max-md:min-h-11"),
280
- onClick: (event) => inApp(event) && editor.discard(),
281
- children: "Cancel"
282
- }),
283
266
  /* @__PURE__ */ jsxs(Button, {
284
267
  variant: "primary",
285
- className: "max-md:min-h-11 max-md:flex-1",
268
+ className: "max-md:min-h-11 max-md:flex-1 md:w-full",
286
269
  loading: editor.saving,
287
270
  disabled: !editor.dirty && editor.phase !== "saved",
288
271
  onClick: () => void save(),
289
272
  children: [editor.phase === "saved" && /* @__PURE__ */ jsx(Check, { className: "size-4" }), editor.phase === "saved" ? "Saved" : "Save"]
273
+ }),
274
+ leavesForm && /* @__PURE__ */ jsx(AppLink, {
275
+ to: readAddress,
276
+ className: cn(buttonClass(), "max-md:min-h-11 md:w-full"),
277
+ onClick: (event) => inApp(event) && editor.discard(),
278
+ children: "Cancel"
279
+ }),
280
+ editor.dirty && /* @__PURE__ */ jsx("span", {
281
+ className: "text-xs text-muted-foreground max-md:order-first",
282
+ children: "Unsaved changes"
290
283
  })
291
284
  ] });
292
285
  return /* @__PURE__ */ jsxs("div", {
@@ -300,17 +293,11 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
300
293
  children: [
301
294
  /* @__PURE__ */ jsx(RecordHeader, {
302
295
  title,
296
+ titleHidden: true,
303
297
  status: status ? {
304
298
  label: enumLabel(status, hint("status")?.valueLabels),
305
299
  tone: toneFor(status)
306
- } : hasStatus ? void 0 : {
307
- label: singular,
308
- tone: "neutral"
309
- },
310
- actions: /* @__PURE__ */ jsx("div", {
311
- className: "hidden items-center gap-4 md:flex",
312
- children: formControls
313
- })
300
+ } : void 0
314
301
  }),
315
302
  editor.message && /* @__PURE__ */ jsx("div", {
316
303
  className: "mt-4",
@@ -323,7 +310,7 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
323
310
  className: "mt-4",
324
311
  children: /* @__PURE__ */ jsx(ErrorBanner, {
325
312
  title: "The lines were changed by someone else",
326
- error: /* @__PURE__ */ new Error("The lines were reloaded. Your new order is kept: Save again to apply it, or Discard to drop it.")
313
+ error: /* @__PURE__ */ new Error("The lines were reloaded. Your new order is kept: Save again to apply it.")
327
314
  })
328
315
  }),
329
316
  shown !== "form" && offersEdit && editor.dirty && /* @__PURE__ */ jsxs("div", {
@@ -361,7 +348,7 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
361
348
  /* @__PURE__ */ jsxs("div", {
362
349
  className: "grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12",
363
350
  children: [/* @__PURE__ */ jsxs("main", {
364
- className: "divide-y divide-border",
351
+ className: cn("divide-y divide-border", !status && "*:first:pt-0!"),
365
352
  children: [layout.flatMap((item, index) => {
366
353
  if (item.kind === "related") return [/* @__PURE__ */ jsx(RelatedSection, {
367
354
  item,
@@ -406,8 +393,12 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
406
393
  locked: shown !== "form"
407
394
  })]
408
395
  }), /* @__PURE__ */ jsxs("aside", {
409
- className: "space-y-4 md:pt-8",
396
+ className: cn("space-y-4", status && "md:pt-8"),
410
397
  children: [
398
+ formControls && /* @__PURE__ */ jsx("div", {
399
+ className: "hidden flex-col items-center gap-2 md:flex",
400
+ children: formControls
401
+ }),
411
402
  /* @__PURE__ */ jsx(RecordActions, {
412
403
  model,
413
404
  stored,
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.19.11";
2
+ var version = "0.19.12";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };
@@ -2,49 +2,55 @@ import { AvatarStack } from "../primitives/avatar.js";
2
2
  import { Badge } from "../primitives/badge.js";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/record-view/record-header.tsx
5
- const RecordHeader = ({ collection, title, status, lastEditedBy, presence = [], actions }) => /* @__PURE__ */ jsxs("header", {
6
- className: "flex flex-col gap-4 border-b border-border pb-6 md:flex-row md:items-end md:justify-between md:gap-6",
7
- children: [/* @__PURE__ */ jsxs("div", { children: [
8
- collection && /* @__PURE__ */ jsx("p", {
9
- className: "mb-1 text-xs text-muted-foreground",
10
- children: collection
11
- }),
12
- /* @__PURE__ */ jsxs("div", {
13
- className: "flex flex-wrap items-center gap-x-3 gap-y-1",
14
- children: [/* @__PURE__ */ jsx("h1", {
15
- className: "text-xl font-semibold tracking-tight text-foreground md:text-2xl",
16
- children: title
17
- }), status && /* @__PURE__ */ jsx(Badge, {
18
- tone: status.tone,
19
- children: status.label
20
- })]
21
- }),
22
- lastEditedBy && /* @__PURE__ */ jsx("p", {
23
- className: "mt-1.5 text-xs text-muted-foreground",
24
- children: lastEditedBy.name ? /* @__PURE__ */ jsxs(Fragment, { children: [
25
- "Last edited by ",
26
- /* @__PURE__ */ jsx("span", {
27
- className: "font-medium text-foreground",
28
- children: lastEditedBy.name
29
- }),
30
- " ",
31
- lastEditedBy.ago
32
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: ["Last updated ", lastEditedBy.ago] })
33
- })
34
- ] }), /* @__PURE__ */ jsxs("div", {
35
- className: "flex items-center gap-4",
36
- children: [presence.length > 0 && /* @__PURE__ */ jsxs("span", {
37
- className: "flex items-center gap-2 text-xs text-muted-foreground",
38
- children: [
39
- /* @__PURE__ */ jsx(AvatarStack, {
40
- people: presence,
41
- size: "md"
42
- }),
43
- presence.length,
44
- " viewing"
45
- ]
46
- }), actions]
47
- })]
48
- });
5
+ const RecordHeader = ({ collection, title, titleHidden, status, lastEditedBy, presence = [], actions }) => {
6
+ if (titleHidden && !collection && !status && !lastEditedBy && presence.length === 0 && !actions) return /* @__PURE__ */ jsx("h1", {
7
+ className: "sr-only",
8
+ children: title
9
+ });
10
+ return /* @__PURE__ */ jsxs("header", {
11
+ className: "flex flex-col gap-4 border-b border-border pb-6 md:flex-row md:items-end md:justify-between md:gap-6",
12
+ children: [/* @__PURE__ */ jsxs("div", { children: [
13
+ collection && /* @__PURE__ */ jsx("p", {
14
+ className: "mb-1 text-xs text-muted-foreground",
15
+ children: collection
16
+ }),
17
+ /* @__PURE__ */ jsxs("div", {
18
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1",
19
+ children: [/* @__PURE__ */ jsx("h1", {
20
+ className: titleHidden ? "sr-only" : "text-xl font-semibold tracking-tight text-foreground md:text-2xl",
21
+ children: title
22
+ }), status && /* @__PURE__ */ jsx(Badge, {
23
+ tone: status.tone,
24
+ children: status.label
25
+ })]
26
+ }),
27
+ lastEditedBy && /* @__PURE__ */ jsx("p", {
28
+ className: "mt-1.5 text-xs text-muted-foreground",
29
+ children: lastEditedBy.name ? /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ "Last edited by ",
31
+ /* @__PURE__ */ jsx("span", {
32
+ className: "font-medium text-foreground",
33
+ children: lastEditedBy.name
34
+ }),
35
+ " ",
36
+ lastEditedBy.ago
37
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: ["Last updated ", lastEditedBy.ago] })
38
+ })
39
+ ] }), /* @__PURE__ */ jsxs("div", {
40
+ className: "flex items-center gap-4",
41
+ children: [presence.length > 0 && /* @__PURE__ */ jsxs("span", {
42
+ className: "flex items-center gap-2 text-xs text-muted-foreground",
43
+ children: [
44
+ /* @__PURE__ */ jsx(AvatarStack, {
45
+ people: presence,
46
+ size: "md"
47
+ }),
48
+ presence.length,
49
+ " viewing"
50
+ ]
51
+ }), actions]
52
+ })]
53
+ });
54
+ };
49
55
  //#endregion
50
56
  export { RecordHeader };