@protobase/ui 0.54.6 → 0.55.1

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 (36) hide show
  1. package/dist/app/app.js +1 -1
  2. package/dist/app/create/create-values.js +5 -5
  3. package/dist/app/displays/virtual-cards.js +1 -1
  4. package/dist/app/field-editor.js +1 -1
  5. package/dist/app/field-types/built-in-fields.js +6 -0
  6. package/dist/app/field-types/members/member-chip.js +20 -0
  7. package/dist/app/field-types/members/member-ids.js +13 -0
  8. package/dist/app/field-types/members/members-display.js +44 -0
  9. package/dist/app/field-types/members/members-editor.js +44 -0
  10. package/dist/app/field-types/members/members-field.js +16 -0
  11. package/dist/app/field-types/members/messages.js +18 -0
  12. package/dist/app/field-types/members/use-members-field.js +18 -0
  13. package/dist/app/field-types/shown-widget.js +11 -6
  14. package/dist/app/picker/picker-combobox.js +140 -0
  15. package/dist/app/relation-picker.js +27 -124
  16. package/dist/data-grid/use-virtual-rows.js +5 -2
  17. package/dist/filter-panel/facet-combobox.js +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/live/field-values.js +22 -1
  20. package/dist/organizations/organizations-page.js +1 -1
  21. package/dist/package.js +1 -1
  22. package/dist/shell/assets/app-DxuzNqzR.js +9 -0
  23. package/dist/shell/assets/{index-IMD8ceia.js → index-DprdVbQM.js} +2 -2
  24. package/dist/shell/assets/{records-map-TXpdTT7s.js → records-map-DhDIjikh.js} +2 -2
  25. package/dist/shell/assets/shared-protobase-ui-uXIvgyTZ.js +2 -0
  26. package/dist/shell/index.html +3 -3
  27. package/dist/shell/protobase.shell.json +1 -1
  28. package/dist/shell/protobase.sw.js +2 -2
  29. package/dist/shell-source-maps/assets/app-DxuzNqzR.js.map +1 -0
  30. package/dist/shell-source-maps/assets/{index-IMD8ceia.js.map → index-DprdVbQM.js.map} +1 -1
  31. package/dist/shell-source-maps/assets/{records-map-TXpdTT7s.js.map → records-map-DhDIjikh.js.map} +1 -1
  32. package/dist/shell-source-maps/assets/{shared-protobase-ui-BHIhZYVr.js.map → shared-protobase-ui-uXIvgyTZ.js.map} +1 -1
  33. package/package.json +4 -4
  34. package/dist/shell/assets/app-Y_3vlU3f.js +0 -9
  35. package/dist/shell/assets/shared-protobase-ui-BHIhZYVr.js +0 -2
  36. package/dist/shell-source-maps/assets/app-Y_3vlU3f.js.map +0 -1
package/dist/index.js CHANGED
@@ -14,11 +14,11 @@ import { Textarea } from "./primitives/textarea.js";
14
14
  import { useList } from "./data/use-list.js";
15
15
  import { OtpInput } from "./primitives/otp-input.js";
16
16
  import { definePlugin, defineUi } from "./app/pages/project-ui.js";
17
+ import { useMembers } from "./people/use-members.js";
17
18
  import { Markdown } from "./markdown/markdown.js";
18
19
  import { ActionInputError } from "./app/pages/action-inputs/input-errors.js";
19
20
  import { useLayoutRecord } from "./app/pages/record-scope.js";
20
21
  import { useFacets, useHistogram, useSeries } from "./data/use-aggregates.js";
21
- import { useMembers } from "./people/use-members.js";
22
22
  import { LogoMark } from "./app-shell/logo.js";
23
23
  import { SignInPrompt } from "./auth/sign-in-prompt.js";
24
24
  import { useListDisplay } from "./app/displays/display-context.js";
@@ -12,7 +12,19 @@ const textEdited = /* @__PURE__ */ new Set([
12
12
  "currency",
13
13
  "country"
14
14
  ]);
15
- const isEditable = (field) => !field.readOnly && field.type !== "json" && field.type !== "uuid" && field.type !== "timestamp" && field.type !== "relation";
15
+ const uneditable = /* @__PURE__ */ new Set([
16
+ "uuid",
17
+ "timestamp",
18
+ "relation"
19
+ ]);
20
+ /**
21
+ * Whether a form edits the field: not read-only, nor of a type it shows only. JSON is edited only by the field type the
22
+ * view's `hints` choose for it (`.widget(name)`), as there is no built-in input for it.
23
+ */
24
+ const isEditable = (field, hints) => {
25
+ if (field.readOnly || uneditable.has(field.type)) return false;
26
+ return field.type !== "json" || hints?.widget !== void 0;
27
+ };
16
28
  /** A field a record's form cannot leave empty: written through the API, never null and no boolean, which always holds a value. */
17
29
  const isRequiredOnEdit = (field) => !field.readOnly && !field.nullable && field.type !== "boolean";
18
30
  const numeric = /* @__PURE__ */ new Set([
@@ -20,6 +32,14 @@ const numeric = /* @__PURE__ */ new Set([
20
32
  "bigint",
21
33
  "decimal"
22
34
  ]);
35
+ const jsonValue = (text) => {
36
+ try {
37
+ return JSON.parse(text);
38
+ } catch (error) {
39
+ if (error instanceof SyntaxError) return text;
40
+ throw error;
41
+ }
42
+ };
23
43
  const numberText = (text, decimal) => parseNumberText(text, decimal) ?? text;
24
44
  /**
25
45
  * The JSON value to send for an edited field: integers become numbers, empty optional fields become null, and numbers
@@ -34,6 +54,7 @@ const toPatchValue = (field, draft, decimal = localeDecimal()) => {
34
54
  if (field.type === "integer") return Number(text);
35
55
  if (field.type === "relation") return typeof draft === "number" ? draft : text;
36
56
  if (textEdited.has(field.type) || field.type === "enum") return text;
57
+ if (field.type === "json") return jsonValue(text);
37
58
  throw new Error(`Not implemented: editing ${field.type} fields`);
38
59
  };
39
60
  /** The value a draft stands for, as the API gives one: null when empty, a boolean or number where the field holds one. */
@@ -2,12 +2,12 @@ import { formatTag } from "../locale/active-locale.js";
2
2
  import { useAuth } from "../auth/auth-provider.js";
3
3
  import { Button } from "../primitives/button.js";
4
4
  import { Input } from "../primitives/input.js";
5
+ import { isAdmin } from "../auth/user-to-shell.js";
5
6
  import { PageHeader } from "../app-shell/page-header.js";
6
7
  import { AccountSection, SectionError } from "../account/account-section.js";
7
8
  import { useAction } from "./use-action.js";
8
9
  import { text } from "./messages.js";
9
10
  import { roleLabel } from "./organization-paths.js";
10
- import { isAdmin } from "../auth/user-to-shell.js";
11
11
  import { reopenIn } from "./use-organizations.js";
12
12
  import { OrganizationRow } from "./organization-row.js";
13
13
  import { AllOrganizations } from "./all-organizations.js";
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.54.6";
2
+ var version = "0.55.1";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };