@phis/ui 0.7.5 → 0.7.8

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 (158) hide show
  1. package/components/controls/phi-form-control.d.ts +3 -1
  2. package/components/controls/phi-form-control.js +15 -4
  3. package/components/forms/auth-admin-settings-labels.d.ts +1 -1
  4. package/components/forms/auth-admin-settings-labels.js +2 -2
  5. package/components/forms/extended-form-field-controls.d.ts +1 -1
  6. package/components/forms/extended-form-field-controls.js +23 -7
  7. package/components/forms/form-descriptor-contract.d.ts +1 -1
  8. package/components/forms/form-descriptor-contract.js +1 -1
  9. package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
  10. package/components/forms/form-descriptor-runtime-client.js +33 -11
  11. package/components/forms/form-media-limits.d.ts +12 -0
  12. package/components/forms/form-media-limits.js +14 -0
  13. package/components/forms/form-provider-contract.d.ts +5 -0
  14. package/components/forms/form-provider-contract.js +9 -2
  15. package/components/forms/form-provider-registry.d.ts +14 -0
  16. package/components/forms/form-record-title.d.ts +14 -0
  17. package/components/forms/form-record-title.js +38 -0
  18. package/components/forms/form-widget-config.d.ts +3 -0
  19. package/components/forms/form-widget-config.js +2 -0
  20. package/components/forms/money-field-currency-key.d.ts +6 -0
  21. package/components/forms/money-field-currency-key.js +14 -0
  22. package/components/forms/money-field.d.ts +26 -3
  23. package/components/forms/money-field.js +54 -4
  24. package/components/forms/phi-form-widget.d.ts +1 -1
  25. package/components/forms/phi-form-widget.js +4 -0
  26. package/components/overlays/phi-overlay-container-client.js +8 -8
  27. package/components/overlays/phi-overlay-title.d.ts +7 -0
  28. package/components/overlays/phi-overlay-title.js +21 -0
  29. package/components/regions/presets/navigation-redirect.d.ts +4 -1
  30. package/components/regions/presets/navigation-redirect.js +6 -3
  31. package/components/tables/client/phi-table-binding.d.ts +3 -1
  32. package/components/tables/client/phi-table-binding.js +90 -49
  33. package/components/tables/client/phi-table-filter-options.d.ts +27 -0
  34. package/components/tables/client/phi-table-filter-options.js +35 -0
  35. package/components/widgets/accessible-areas.d.ts +1 -1
  36. package/components/widgets/accessible-areas.js +1 -1
  37. package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
  38. package/components/widgets/client/shared/phi-rendered-value.js +54 -4
  39. package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
  40. package/components/widgets/client/shared/phi-table-provider.js +22 -0
  41. package/components/widgets/label-sets/admin-users.d.ts +15 -0
  42. package/components/widgets/label-sets/admin-users.js +31 -0
  43. package/constants/core-data-provider-keys.d.ts +7 -0
  44. package/constants/core-data-provider-keys.js +7 -0
  45. package/constants/phi-base-role-metadata.d.ts +2 -2
  46. package/constants/phi-base-role-metadata.js +1 -1
  47. package/constants/runtime-module-ownership.js +3 -0
  48. package/forms.d.ts +1 -1
  49. package/forms.js +1 -1
  50. package/gateway/capability-media-limits.d.ts +10 -0
  51. package/gateway/capability-media-limits.js +40 -0
  52. package/gateway/server-capabilities.js +4 -0
  53. package/helpers/money-amount.d.ts +7 -0
  54. package/helpers/money-amount.js +15 -0
  55. package/helpers/preset-tree-contract-check.d.ts +3 -2
  56. package/helpers/preset-tree-contract-check.js +60 -0
  57. package/helpers/record-title.d.ts +7 -0
  58. package/helpers/record-title.js +25 -0
  59. package/helpers/record-widget.d.ts +15 -0
  60. package/helpers/record-widget.js +57 -0
  61. package/package.json +2 -2
  62. package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
  63. package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
  64. package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
  65. package/plugins/runtime-modules/accounting/data-providers.js +127 -0
  66. package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
  67. package/plugins/runtime-modules/accounting/definition.js +5 -3
  68. package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
  69. package/plugins/runtime-modules/accounting/ids.js +27 -0
  70. package/plugins/runtime-modules/accounting/module.d.ts +52 -0
  71. package/plugins/runtime-modules/accounting/presets.js +23 -4
  72. package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
  73. package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
  74. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
  75. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
  76. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
  77. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
  78. package/plugins/runtime-modules/app/presets.js +3 -6
  79. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +3 -6
  80. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +4 -7
  81. package/plugins/runtime-modules/area-definitions.js +2 -2
  82. package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
  83. package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
  84. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
  85. package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
  86. package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
  87. package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
  88. package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
  89. package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
  90. package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
  91. package/plugins/runtime-modules/builder/controller/client.d.ts +5 -5
  92. package/plugins/runtime-modules/builder/controller/client.js +2 -1
  93. package/plugins/runtime-modules/builder/controller/definition.d.ts +4 -4
  94. package/plugins/runtime-modules/builder/controller/definition.js +7 -0
  95. package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +3 -1
  96. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +2 -1
  97. package/plugins/runtime-modules/builder/controller/draft-status-controller.js +44 -17
  98. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +4 -4
  99. package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +3 -1
  100. package/plugins/runtime-modules/builder/controller/workspace-controller.js +8 -10
  101. package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +10 -0
  102. package/plugins/runtime-modules/builder/developer-workspace-store.js +35 -1
  103. package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +6 -0
  104. package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -6
  105. package/plugins/runtime-modules/builder/persistence.d.ts +4 -1
  106. package/plugins/runtime-modules/builder/persistence.js +10 -3
  107. package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
  108. package/plugins/runtime-modules/core/cards.js +2 -2
  109. package/plugins/runtime-modules/core/client-data-providers.js +5 -0
  110. package/plugins/runtime-modules/core/data-providers.js +14 -0
  111. package/plugins/runtime-modules/core/definition.d.ts +5 -0
  112. package/plugins/runtime-modules/core/form-providers.d.ts +5 -0
  113. package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
  114. package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
  115. package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
  116. package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
  117. package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
  118. package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
  119. package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
  120. package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
  121. package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
  122. package/plugins/runtime-modules/core/widgets/spacer/client.js +3 -3
  123. package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
  124. package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
  125. package/plugins/runtime-modules/groups/data-providers.js +1 -1
  126. package/plugins/runtime-modules/groups/definition.js +1 -1
  127. package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
  128. package/plugins/runtime-modules/groups/page-visibility.js +1 -1
  129. package/plugins/runtime-modules/groups/presets.js +1 -1
  130. package/plugins/runtime-modules/groups/services/options.js +1 -1
  131. package/plugins/runtime-modules/groups/services/table.js +1 -1
  132. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
  133. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +46 -39
  134. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
  135. package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
  136. package/plugins/runtime-modules/revisions/controller/client.js +48 -46
  137. package/plugins/runtime-modules/revisions/services/table.js +3 -1
  138. package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
  139. package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
  140. package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
  141. package/plugins/runtime-modules/user-management/controller/client.js +1 -1
  142. package/plugins/runtime-modules/user-management/data-providers.js +1 -0
  143. package/plugins/runtime-modules/user-management/forms.js +22 -0
  144. package/plugins/runtime-modules/user-management/presets.js +2 -2
  145. package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
  146. package/plugins/runtime-modules/user-management/services/options.js +14 -6
  147. package/plugins/runtime-modules/user-management/services/table.js +12 -3
  148. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
  149. package/styles/builder-scaffold.css +7 -1
  150. package/styles/layout-authoring-scaffold.css +27 -0
  151. package/types/access.d.ts +1 -1
  152. package/types/access.js +7 -7
  153. package/types/core-widget-placements.d.ts +7 -0
  154. package/types/form-descriptor.d.ts +1 -1
  155. package/types/record-widget.d.ts +35 -0
  156. package/types/server-capabilities.d.ts +1 -1
  157. package/types/table-widget.d.ts +20 -0
  158. package/types/table-widget.js +44 -0
@@ -1,8 +1,9 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { formatPhisMoney } from "@phis/contracts/payments";
4
4
  import { formatPhiDate, formatPhiDateTime } from "../../../../helpers/format-date-time";
5
- import { readPhiMoneyValue } from "../../../../helpers/money-amount";
5
+ import { readPhiInternalPath } from "../../../../helpers/internal-path";
6
+ import { readPhiMoneyValues } from "../../../../helpers/money-amount";
6
7
  import { formatPhiInterval, readPhiIntervalValue } from "../../label-types/interval";
7
8
  import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../root/phi-intl-locale";
8
9
  import { PhiFlexControl } from "../../../controls/phi-flex-control";
@@ -10,6 +11,7 @@ import { PhiTagControl } from "../../../controls/phi-tag-control";
10
11
  import { PhiTypographyControl } from "../../../controls/phi-typography-control";
11
12
  import { PhiLink } from "../../../navigation/phi-link";
12
13
  import { PhiIcon } from "../../../shell/phi-icon";
14
+ import { usePhiConfig } from "../../../root/phi-config-provider";
13
15
  import { isPhiRecord } from "../../../../helpers/is-record";
14
16
  /**
15
17
  * **A flag being read is a mark, not a switch.**
@@ -43,8 +45,54 @@ function PhiRenderedDate({ value, withTime }) {
43
45
  return withTime ? formatPhiDateTime(value, locale, timeZone) : formatPhiDate(value, locale, timeZone);
44
46
  }
45
47
  /** The reader's locale, not the server's or the browser's, and the currency's own places. */
48
+ /** One amount, or a price list's amounts in its order, side by side. */
46
49
  function PhiRenderedMoney({ value }) {
47
- return formatPhisMoney(value, usePhiIntlLocale());
50
+ const locale = usePhiIntlLocale();
51
+ return value.map((amount) => formatPhisMoney(amount, locale)).join(" · ");
52
+ }
53
+ /**
54
+ * The square a picture is drawn in, in a cell and in a record alike: a line of a list. The server's `icon`
55
+ * variant is 64 x 64, two device pixels for each of these on a high-density screen.
56
+ */
57
+ const PHI_RENDERED_IMAGE_SIZE = 32;
58
+ /**
59
+ * **A picture in a list is the address the server answered, drawn as it is.**
60
+ *
61
+ * The value is a Site-relative address that already names a variant cut to size and carries its cache
62
+ * revision, so the browser loads it once and keeps it; anything else -- an absolute address, another
63
+ * host, an Asset id -- draws nothing, so a Provider cannot make a list load pictures from elsewhere. A
64
+ * plain `<img>` and not `next/image`: the variant is already the size it is shown at, and the optimiser
65
+ * would fetch it again without the reader's session and cut it a second time. Lazy and decoded off the
66
+ * main thread, because a page of a hundred rows holds a hundred of them.
67
+ *
68
+ * The `alt` is empty: in a list the picture stands beside the name it belongs to -- ahead of the value it
69
+ * illustrates, or in a column whose heading says what it is, with the row's name in its own cell --
70
+ * so it is decorative, and a screen reader that read a name again for it would read every row twice.
71
+ * Fitted whole, never cropped: an icon or a logo that loses an edge is another mark. The corner is the
72
+ * small step of the scale, as for any element inside a surface (THEME.md, "Control shape").
73
+ */
74
+ function PhiRenderedImage({ address }) {
75
+ const { token } = usePhiConfig();
76
+ return (_jsx("img", { alt: "", src: address, width: PHI_RENDERED_IMAGE_SIZE, height: PHI_RENDERED_IMAGE_SIZE, loading: "lazy", decoding: "async", style: {
77
+ display: "block",
78
+ flexShrink: 0,
79
+ width: PHI_RENDERED_IMAGE_SIZE,
80
+ height: PHI_RENDERED_IMAGE_SIZE,
81
+ objectFit: "contain",
82
+ borderRadius: token.borderRadiusSM,
83
+ } }));
84
+ }
85
+ /** The picture an address names, or nothing for a value that is no address on this Site. */
86
+ function renderPhiImage(value) {
87
+ const address = readPhiInternalPath(value);
88
+ return address ? _jsx(PhiRenderedImage, { address: address }) : null;
89
+ }
90
+ export function renderPhiValueWithLead(content, lead) {
91
+ const icon = typeof lead.icon === "string" && lead.icon.trim() ? _jsx(PhiIcon, { name: lead.icon }) : null;
92
+ const image = renderPhiImage(lead.image);
93
+ if (!icon && !image)
94
+ return content;
95
+ return (_jsxs(PhiFlexControl, { align: "center", gap: 6, style: { display: "inline-flex" }, children: [image, icon, content] }));
48
96
  }
49
97
  export function renderPhiValueContent(value, definition, labels, presentation = "cell") {
50
98
  if (value == null || value === "")
@@ -54,13 +102,15 @@ export function renderPhiValueContent(value, definition, labels, presentation =
54
102
  * nothing rather than its JSON -- a cell that says `{"currency":"CHF"}` is no amount of money.
55
103
  */
56
104
  if (definition.renderer === "money") {
57
- const money = readPhiMoneyValue(value);
105
+ const money = readPhiMoneyValues(value);
58
106
  return money ? _jsx(PhiRenderedMoney, { value: money }) : null;
59
107
  }
60
108
  if (definition.renderer === "interval") {
61
109
  const interval = readPhiIntervalValue(value);
62
110
  return interval ? formatPhiInterval(interval, labels.interval) : null;
63
111
  }
112
+ if (definition.renderer === "image")
113
+ return renderPhiImage(value);
64
114
  const normalizedValue = normalizePhiRenderedText(value);
65
115
  const displayValue = definition.valueMap?.[normalizedValue] ?? normalizedValue;
66
116
  if (definition.renderer === "email" || definition.renderer === "link") {
@@ -1,6 +1,6 @@
1
1
  import { type ComponentType, type ReactNode } from "react";
2
2
  import { type PhiRuntimeDataProviderKey } from "../../../../types/runtime-data-provider";
3
- import type { PhiTableProviderMutationRequest, PhiTableProviderMutationResult, PhiTableProviderRecordRequest, PhiTableProviderQueryRequest, PhiTableProviderQueryResult, PhiTableProviderResourceDescriptor } from "../../../../types/table-widget";
3
+ import { type PhiTableProviderMutationRequest, type PhiTableProviderMutationResult, type PhiTableProviderRecordRequest, type PhiTableProviderQueryRequest, type PhiTableProviderQueryResult, type PhiTableProviderResourceDescriptor } from "../../../../types/table-widget";
4
4
  import type { PhiProviderResourceSource } from "../../../../types/runtime-data-provider";
5
5
  export type PhiTableProviderRegistration = {
6
6
  key: PhiRuntimeDataProviderKey;
@@ -24,3 +24,12 @@ export declare function usePhiTableProvider(source: PhiProviderResourceSource |
24
24
  resource: PhiTableProviderResourceDescriptor | null;
25
25
  bindingError: string | null;
26
26
  };
27
+ /** A mutation as a Widget states it: the source it is bound to adds the resource, its params and the abort. */
28
+ export type PhiTableProviderMutationInput<TRequest extends PhiTableProviderMutationRequest = PhiTableProviderMutationRequest> = TRequest extends unknown ? Omit<TRequest, "resourceKey" | "params" | "signal"> : never;
29
+ /**
30
+ * One mutation through a bound source's Provider Client, and its answer read strictly: a Provider without
31
+ * `mutate` is read-only, and an answer outside `PhiTableProviderMutationResult` is the Provider's failure,
32
+ * not an accepted change. What the answer then means for what is on screen -- rows patched, a view read
33
+ * again, a dialog closed -- is the caller's: the Table's Binding and the record Widget both ask here.
34
+ */
35
+ export declare function requestPhiTableProviderMutation(provider: PhiTableProviderRegistration, source: PhiProviderResourceSource, request: PhiTableProviderMutationInput, signal: AbortSignal): Promise<PhiTableProviderMutationResult>;
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { createContext, createElement, useContext, useMemo, } from "react";
4
4
  import { isPhiRuntimeDataProviderKey, } from "../../../../types/runtime-data-provider";
5
+ import { PhiTableProviderError, readPhiTableProviderMutationResult, } from "../../../../types/table-widget";
5
6
  const EMPTY_TABLE_PROVIDER_REGISTRY = new Map();
6
7
  const PhiTableProviderRegistryContext = createContext(EMPTY_TABLE_PROVIDER_REGISTRY);
7
8
  export function createPhiTableProviderClient(registration) {
@@ -69,3 +70,24 @@ export function usePhiTableProvider(source) {
69
70
  : null,
70
71
  };
71
72
  }
73
+ /**
74
+ * One mutation through a bound source's Provider Client, and its answer read strictly: a Provider without
75
+ * `mutate` is read-only, and an answer outside `PhiTableProviderMutationResult` is the Provider's failure,
76
+ * not an accepted change. What the answer then means for what is on screen -- rows patched, a view read
77
+ * again, a dialog closed -- is the caller's: the Table's Binding and the record Widget both ask here.
78
+ */
79
+ export async function requestPhiTableProviderMutation(provider, source, request, signal) {
80
+ if (!provider.mutate) {
81
+ throw new PhiTableProviderError("provider-read-only", `Table Provider "${source.providerKey}" is read-only.`);
82
+ }
83
+ const result = readPhiTableProviderMutationResult(await provider.mutate({
84
+ ...request,
85
+ resourceKey: source.resourceKey,
86
+ params: source.params,
87
+ signal,
88
+ }));
89
+ if (!result) {
90
+ throw new PhiTableProviderError("invalid-mutation-result", "Table Provider returned an invalid mutation result.");
91
+ }
92
+ return result;
93
+ }
@@ -16,6 +16,19 @@ export declare function getPhiAdminUsersTableWidgetLabels(options: PhiGlobalTran
16
16
  addonRoles: {
17
17
  all: string;
18
18
  };
19
+ addonRoleTexts: {
20
+ via: string;
21
+ impliedBy: string;
22
+ siteAccess: {
23
+ "site-maintenance": string;
24
+ "structure-authoring": string;
25
+ "content-editing": string;
26
+ publishing: string;
27
+ "site-media": string;
28
+ support: string;
29
+ accounting: string;
30
+ };
31
+ };
19
32
  filters: {
20
33
  addonRole: string;
21
34
  addonRoleHint: string;
@@ -71,6 +84,8 @@ export declare function getPhiAdminUsersTableWidgetLabels(options: PhiGlobalTran
71
84
  addonRoles: string;
72
85
  addonRolesPlaceholder: string;
73
86
  addonRolesHint: string;
87
+ impliedAddonRoles: string;
88
+ impliedAddonRolesHint: string;
74
89
  changePassword: string;
75
90
  createPasswordHint: string;
76
91
  authOnlyHint: string;
@@ -26,6 +26,15 @@ const PHI_ADMIN_USERS_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
26
26
  column_roles: "Roles",
27
27
  column_addon_roles: "Add-on roles",
28
28
  addon_roles_all: "all roles",
29
+ addon_role_via: "%1 (via %2)",
30
+ addon_role_implied_by: "Implied by %1",
31
+ site_access_site_maintenance: "Site maintenance",
32
+ site_access_structure_authoring: "Structure authoring",
33
+ site_access_content_editing: "Content editing",
34
+ site_access_publishing: "Publishing",
35
+ site_access_site_media: "Site media",
36
+ site_access_support: "Support",
37
+ site_access_accounting: "Accounting",
29
38
  filter_addon_role: "Add-on",
30
39
  filter_addon_role_hint: definePhiMessageLabel("Show users who hold any role of an Add-on. Site Admins hold every role."),
31
40
  column_user_flags: "User flags",
@@ -62,6 +71,8 @@ const PHI_ADMIN_USERS_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
62
71
  editor_addon_roles: "Add-on roles",
63
72
  editor_addon_roles_placeholder: "Choose Add-on roles",
64
73
  editor_addon_roles_hint: definePhiMessageLabel("A Site Admin holds every Add-on role. Your own Add-on roles cannot be changed here."),
74
+ editor_implied_addon_roles: "Add-on roles through Core roles",
75
+ editor_implied_addon_roles_hint: definePhiMessageLabel("Held without a grant while the person has the Core role that implies them. They cannot be removed here."),
65
76
  editor_change_password: "Require password reset",
66
77
  editor_create_password_hint: definePhiMessageLabel("New users are created with a temporary password and receive a reset link."),
67
78
  editor_auth_only_hint: definePhiMessageLabel("Leave roles empty for an auth-only account."),
@@ -110,6 +121,24 @@ export async function getPhiAdminUsersTableWidgetLabels(options) {
110
121
  addonRoles: {
111
122
  all: labels.addon_roles_all,
112
123
  },
124
+ /*
125
+ * The words for an Add-on role held through a Site access (`PhiAddonRoleTexts`), which the users page
126
+ * preset hands to the Table's and the edit form's Providers. One word per Site access an Add-on may hang a
127
+ * role on: every one but site-admin, who holds every role already.
128
+ */
129
+ addonRoleTexts: {
130
+ via: labels.addon_role_via,
131
+ impliedBy: labels.addon_role_implied_by,
132
+ siteAccess: {
133
+ "site-maintenance": labels.site_access_site_maintenance,
134
+ "structure-authoring": labels.site_access_structure_authoring,
135
+ "content-editing": labels.site_access_content_editing,
136
+ publishing: labels.site_access_publishing,
137
+ "site-media": labels.site_access_site_media,
138
+ support: labels.site_access_support,
139
+ accounting: labels.site_access_accounting,
140
+ },
141
+ },
113
142
  filters: {
114
143
  addonRole: labels.filter_addon_role,
115
144
  addonRoleHint: labels.filter_addon_role_hint,
@@ -165,6 +194,8 @@ export async function getPhiAdminUsersTableWidgetLabels(options) {
165
194
  addonRoles: labels.editor_addon_roles,
166
195
  addonRolesPlaceholder: labels.editor_addon_roles_placeholder,
167
196
  addonRolesHint: labels.editor_addon_roles_hint,
197
+ impliedAddonRoles: labels.editor_implied_addon_roles,
198
+ impliedAddonRolesHint: labels.editor_implied_addon_roles_hint,
168
199
  changePassword: labels.editor_change_password,
169
200
  createPasswordHint: labels.editor_create_password_hint,
170
201
  authOnlyHint: labels.editor_auth_only_hint,
@@ -21,4 +21,11 @@ export declare const PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS: {
21
21
  readonly contentEntryCategories: `${string}/${string}`;
22
22
  /** One published entry and its relatives, read on the server; the binding names the kind and slug. */
23
23
  readonly contentEntry: `${string}/${string}`;
24
+ /**
25
+ * The Site's members, for a select that names a person by user id -- a licence granted on somebody's
26
+ * behalf: searched by name or address on the server, a page at a time, each option the user id as
27
+ * text and the name the person is shown under. For staff holding the Site access `accounting` or
28
+ * `support`; anybody else is refused by Core and gets no options (FORMS.md, "Options providers").
29
+ */
30
+ readonly siteMembers: `${string}/${string}`;
24
31
  };
@@ -22,4 +22,11 @@ export const PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS = {
22
22
  contentEntryCategories: createPhiSharedRuntimeDataProviderKey("tables", "content-entry-categories"),
23
23
  /** One published entry and its relatives, read on the server; the binding names the kind and slug. */
24
24
  contentEntry: createPhiSharedRuntimeDataProviderKey("records", "content-entry"),
25
+ /**
26
+ * The Site's members, for a select that names a person by user id -- a licence granted on somebody's
27
+ * behalf: searched by name or address on the server, a page at a time, each option the user id as
28
+ * text and the name the person is shown under. For staff holding the Site access `accounting` or
29
+ * `support`; anybody else is refused by Core and gets no options (FORMS.md, "Options providers").
30
+ */
31
+ siteMembers: createPhiSharedRuntimeDataProviderKey("options", "core-site-members"),
25
32
  };
@@ -3,8 +3,8 @@ export declare const PHI_BASE_ROLE_OPTIONS: readonly [{
3
3
  readonly value: "admin";
4
4
  readonly flag: number;
5
5
  }, {
6
- readonly label: "Developer";
7
- readonly value: "developer";
6
+ readonly label: "Maintainer";
7
+ readonly value: "maintainer";
8
8
  readonly flag: number;
9
9
  }, {
10
10
  readonly label: "Builder";
@@ -1,7 +1,7 @@
1
1
  import { PhiBaseRole } from "./phi-base-roles";
2
2
  export const PHI_BASE_ROLE_OPTIONS = [
3
3
  { label: "Admin", value: "admin", flag: PhiBaseRole.Admin },
4
- { label: "Developer", value: "developer", flag: PhiBaseRole.Developer },
4
+ { label: "Maintainer", value: "maintainer", flag: PhiBaseRole.Maintainer },
5
5
  { label: "Builder", value: "builder", flag: PhiBaseRole.Builder },
6
6
  { label: "Author", value: "author", flag: PhiBaseRole.Author },
7
7
  { label: "Publisher", value: "publisher", flag: PhiBaseRole.Publisher },
@@ -170,6 +170,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
170
170
  "forms/user-management/edit": ["user-management", "edit"],
171
171
  "options/admin-site-locales": ["localization", "admin-site-locales"],
172
172
  "options/core-site-locales": ["core", "site-locales"],
173
+ "options/core-site-members": ["core", "site-members"],
173
174
  "options/user-management-addon-roles": ["user-management", "addon-roles"],
174
175
  "options/user-management-addon-role-choices": ["user-management", "addon-role-choices"],
175
176
  "options/builder-area-root-route": ["builder", "area-root-route"],
@@ -257,6 +258,8 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
257
258
  "signals/timeline-binding-params": ["core", "timeline-binding-params"],
258
259
  "signals/tree-mutation": ["core", "tree-mutation"],
259
260
  "signals/tree-state": ["core", "tree-state"],
261
+ // The Site's product directory, the Accounting Area's own Page.
262
+ "tables/accounting-products": ["accounting", "products"],
260
263
  "tables/builder-navigation": ["builder", "navigation"],
261
264
  "tables/runtime-modules": ["builder", "runtime-modules"],
262
265
  "tables/builder-signal-routes": ["builder", "signal-routes"],
package/forms.d.ts CHANGED
@@ -12,7 +12,7 @@ export { PHI_FORM_CONTROLLER_KEY, PHI_FORM_SIGNAL_CHANNELS, PHI_RUNTIME_FORM_CON
12
12
  export { PHI_FORM_BUILDER_CONTROLLER_INSTANCE_KEY, PHI_FORM_BUILDER_CONTROLLER_KEY, PHI_FORM_BUILDER_CONTROLLER_PLUGIN_KEY, PHI_FORM_BUILDER_CONTROLLER_TYPE, createPhiFormBuilderControllerAddress, } from "./components/forms/form-builder-controller-address";
13
13
  export { PHI_FORM_BUILDER_CONTROLLER_DEFINITION, parsePhiFormBuilderControllerConfig, } from "./components/forms/form-builder-controller-definition";
14
14
  export { PHI_AUTH_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_HANDLER_PROVIDER_KEYS, PHI_FORM_VALIDATION_PROVIDER_KEYS, PHI_SHARED_FORM_FIELD_TYPE_PROVIDER_DESCRIPTORS, PHI_SHARED_FORM_VALIDATION_PROVIDER_DESCRIPTORS, createPhiSharedFormProviderKey, } from "./components/forms/form-provider-contract";
15
- export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MIN_WIDTH, PHI_FORM_RESPONSIVE_MODES, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, resolvePhiFormFieldExtent, resolvePhiFormFieldRanges, phiFormGridColumn, resolvePhiFormGridPlacement, phiFormGridRangesOverlap, resolvePhiFormLayout, resolvePhiFormResponsiveGridRange, resolvePhiFormText, parsePhiFormDescriptor, } from "./components/forms/form-descriptor-contract";
15
+ export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MIN_WIDTH, PHI_FORM_RESPONSIVE_MODES, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, resolvePhiFormFieldExtent, resolvePhiFormFieldRanges, phiFormGridColumn, resolvePhiFormGridPlacement, phiFormGridRangesOverlap, resolvePhiFormLayout, resolvePhiFormResponsiveGridRange, resolvePhiFormErrorText, resolvePhiFormText, parsePhiFormDescriptor, } from "./components/forms/form-descriptor-contract";
16
16
  export { PHI_CONFIRM_FORM_DESCRIPTOR, PHI_CONTACT_FORM_DESCRIPTOR, PHI_FORM_LABEL_SET_KEYS, PHI_LOGIN_FORM_DESCRIPTOR, PHI_REGISTRATION_FORM_DESCRIPTOR, PHI_RESET_PASSWORD_CONFIRM_FORM_DESCRIPTOR, PHI_RESET_PASSWORD_FORM_DESCRIPTOR, PHI_UNSUBSCRIBE_FORM_DESCRIPTOR, } from "./components/forms/shared-form-descriptors";
17
17
  export { PHI_SHARED_FORM_IDS } from "./components/forms/shared-form-ids";
18
18
  export { flattenPhiFormLabels } from "./components/forms/form-labels";
package/forms.js CHANGED
@@ -7,7 +7,7 @@ export { PHI_FORM_CONTROLLER_KEY, PHI_FORM_SIGNAL_CHANNELS, PHI_RUNTIME_FORM_CON
7
7
  export { PHI_FORM_BUILDER_CONTROLLER_INSTANCE_KEY, PHI_FORM_BUILDER_CONTROLLER_KEY, PHI_FORM_BUILDER_CONTROLLER_PLUGIN_KEY, PHI_FORM_BUILDER_CONTROLLER_TYPE, createPhiFormBuilderControllerAddress, } from "./components/forms/form-builder-controller-address";
8
8
  export { PHI_FORM_BUILDER_CONTROLLER_DEFINITION, parsePhiFormBuilderControllerConfig, } from "./components/forms/form-builder-controller-definition";
9
9
  export { PHI_AUTH_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_HANDLER_PROVIDER_KEYS, PHI_FORM_VALIDATION_PROVIDER_KEYS, PHI_SHARED_FORM_FIELD_TYPE_PROVIDER_DESCRIPTORS, PHI_SHARED_FORM_VALIDATION_PROVIDER_DESCRIPTORS, createPhiSharedFormProviderKey, } from "./components/forms/form-provider-contract";
10
- export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MIN_WIDTH, PHI_FORM_RESPONSIVE_MODES, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, resolvePhiFormFieldExtent, resolvePhiFormFieldRanges, phiFormGridColumn, resolvePhiFormGridPlacement, phiFormGridRangesOverlap, resolvePhiFormLayout, resolvePhiFormResponsiveGridRange, resolvePhiFormText, parsePhiFormDescriptor, } from "./components/forms/form-descriptor-contract";
10
+ export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MIN_WIDTH, PHI_FORM_RESPONSIVE_MODES, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, resolvePhiFormFieldExtent, resolvePhiFormFieldRanges, phiFormGridColumn, resolvePhiFormGridPlacement, phiFormGridRangesOverlap, resolvePhiFormLayout, resolvePhiFormResponsiveGridRange, resolvePhiFormErrorText, resolvePhiFormText, parsePhiFormDescriptor, } from "./components/forms/form-descriptor-contract";
11
11
  export { PHI_CONFIRM_FORM_DESCRIPTOR, PHI_CONTACT_FORM_DESCRIPTOR, PHI_FORM_LABEL_SET_KEYS, PHI_LOGIN_FORM_DESCRIPTOR, PHI_REGISTRATION_FORM_DESCRIPTOR, PHI_RESET_PASSWORD_CONFIRM_FORM_DESCRIPTOR, PHI_RESET_PASSWORD_FORM_DESCRIPTOR, PHI_UNSUBSCRIBE_FORM_DESCRIPTOR, } from "./components/forms/shared-form-descriptors";
12
12
  export { PHI_SHARED_FORM_IDS } from "./components/forms/shared-form-ids";
13
13
  /*
@@ -0,0 +1,10 @@
1
+ import type { PhiAddonMediaLimits } from "../types/server-capabilities";
2
+ /**
3
+ * The Media limits of a provider in the capability snapshot (`PhiCapabilityProvider.media`), read as
4
+ * strictly as phis-server admits them from the manifest: absent is no limit of the Add-on's own; anything
5
+ * stated is an object with no other keys, `maxFileBytes` and `maxPerField` positive whole numbers, and
6
+ * `kinds` a non-empty list of `PhiMediaKind` values without duplicates. Anything else throws, as every
7
+ * other malformed part of the snapshot does -- a limit read past would be a Media field that takes what
8
+ * the Add-on refuses on save.
9
+ */
10
+ export declare function readPhiCapabilityProviderMediaLimits(value: unknown): PhiAddonMediaLimits | undefined;
@@ -0,0 +1,40 @@
1
+ import { PhiMediaKind } from "../constants/media";
2
+ import { isPhiRecord } from "../helpers/is-record";
3
+ const MEDIA_LIMIT_KEYS = new Set(["maxFileBytes", "kinds", "maxPerField"]);
4
+ const MEDIA_KINDS = new Set(Object.values(PhiMediaKind));
5
+ function isPositiveWholeNumber(value) {
6
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
7
+ }
8
+ /**
9
+ * The Media limits of a provider in the capability snapshot (`PhiCapabilityProvider.media`), read as
10
+ * strictly as phis-server admits them from the manifest: absent is no limit of the Add-on's own; anything
11
+ * stated is an object with no other keys, `maxFileBytes` and `maxPerField` positive whole numbers, and
12
+ * `kinds` a non-empty list of `PhiMediaKind` values without duplicates. Anything else throws, as every
13
+ * other malformed part of the snapshot does -- a limit read past would be a Media field that takes what
14
+ * the Add-on refuses on save.
15
+ */
16
+ export function readPhiCapabilityProviderMediaLimits(value) {
17
+ if (value === undefined)
18
+ return undefined;
19
+ if (!isPhiRecord(value)) {
20
+ throw new Error("Invalid server capability provider media limits.");
21
+ }
22
+ const record = value;
23
+ if (Object.keys(record).some((key) => !MEDIA_LIMIT_KEYS.has(key))) {
24
+ throw new Error("Invalid server capability provider media limits.");
25
+ }
26
+ const { maxFileBytes, kinds, maxPerField } = record;
27
+ if ((maxFileBytes !== undefined && !isPositiveWholeNumber(maxFileBytes)) ||
28
+ (maxPerField !== undefined && !isPositiveWholeNumber(maxPerField)) ||
29
+ (kinds !== undefined && (!Array.isArray(kinds) ||
30
+ kinds.length === 0 ||
31
+ kinds.some((kind) => typeof kind !== "string" || !MEDIA_KINDS.has(kind)) ||
32
+ new Set(kinds).size !== kinds.length))) {
33
+ throw new Error("Invalid server capability provider media limits.");
34
+ }
35
+ return {
36
+ ...(maxFileBytes !== undefined ? { maxFileBytes } : {}),
37
+ ...(kinds !== undefined ? { kinds: [...kinds] } : {}),
38
+ ...(maxPerField !== undefined ? { maxPerField } : {}),
39
+ };
40
+ }
@@ -1,4 +1,5 @@
1
1
  import "server-only";
2
+ import { readPhiCapabilityProviderMediaLimits } from "./capability-media-limits";
2
3
  import { fetchPhiSiteApi } from "./site-api-request";
3
4
  import { readPhiSiteReadCache } from "./site-read-cache";
4
5
  const PROVIDER_ID_PATTERN = /^@[^/]+\/[^/]+(?:\/[^/]+)*$/;
@@ -40,11 +41,14 @@ function parseProvider(value) {
40
41
  !Array.isArray(record.capabilities)) {
41
42
  throw new Error("Invalid server capability provider.");
42
43
  }
44
+ // The Add-on's manifest `media`, which the Media fields of its Module apply (FORMS.md); absent for Core.
45
+ const media = readPhiCapabilityProviderMediaLimits(record.media);
43
46
  return {
44
47
  providerId: record.providerId,
45
48
  state: record.state,
46
49
  diagnosticCode: record.diagnosticCode,
47
50
  capabilities: record.capabilities.map(parseCapability),
51
+ ...(media ? { media } : {}),
48
52
  };
49
53
  }
50
54
  function parseSnapshot(value) {
@@ -10,6 +10,13 @@ export declare function isPhiMinorAmount(value: unknown): value is string;
10
10
  * integer, which is how a row out of JSON often carries it. The answer is always the contract's shape.
11
11
  */
12
12
  export declare function readPhiMoneyValue(value: unknown): PhisPaymentMoney | null;
13
+ /**
14
+ * The amounts a value handed over as money holds, in its order, or `null` where it is none: one amount as
15
+ * `readPhiMoneyValue` reads it, or a price list as the `money` Form field holds one -- minor units per
16
+ * currency code (`{ CHF: "1990", GBP: "1590" }`), each a currency a payment accepts. A list with no entry,
17
+ * or with one entry that is not an amount, is none: half a price list drawn would read as the whole.
18
+ */
19
+ export declare function readPhiMoneyValues(value: unknown): readonly PhisPaymentMoney[] | null;
13
20
  /** `-1`, `0` or `1` as `left` is less than, equal to or more than `right`; both minor amounts. */
14
21
  export declare function comparePhiMinorAmounts(left: string, right: string): number;
15
22
  /**
@@ -40,6 +40,21 @@ export function readPhiMoneyValue(value) {
40
40
  const text = typeof minor === "number" && Number.isSafeInteger(minor) && minor >= 0 ? String(minor) : minor;
41
41
  return isPhiMinorAmount(text) ? { currency, minor: text } : null;
42
42
  }
43
+ /**
44
+ * The amounts a value handed over as money holds, in its order, or `null` where it is none: one amount as
45
+ * `readPhiMoneyValue` reads it, or a price list as the `money` Form field holds one -- minor units per
46
+ * currency code (`{ CHF: "1990", GBP: "1590" }`), each a currency a payment accepts. A list with no entry,
47
+ * or with one entry that is not an amount, is none: half a price list drawn would read as the whole.
48
+ */
49
+ export function readPhiMoneyValues(value) {
50
+ const one = readPhiMoneyValue(value);
51
+ if (one)
52
+ return [one];
53
+ if (typeof value !== "object" || value === null || Array.isArray(value))
54
+ return null;
55
+ const amounts = Object.entries(value).map(([currency, minor]) => readPhiMoneyValue({ currency, minor }));
56
+ return amounts.length > 0 && amounts.every((amount) => amount !== null) ? amounts : null;
57
+ }
43
58
  /** `-1`, `0` or `1` as `left` is less than, equal to or more than `right`; both minor amounts. */
44
59
  export function comparePhiMinorAmounts(left, right) {
45
60
  const difference = BigInt(left) - BigInt(right);
@@ -11,8 +11,9 @@ import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../types/cms";
11
11
  * The rules: every node a preset instance id, none twice, every parent, Region root, Overlay root and Page
12
12
  * root resolved; the base page layout node only as the canonical scaffold; an actions Footer the canonical
13
13
  * Flex preset; a modal's body and actions the dialog's (`helpers/cms-dialog.ts`), and a modal at the default
14
- * `PHI_DIALOG_WIDTH` not holding only Forms of one column. The findings come in the order the compiler used
15
- * to throw them, so its first is the error it always gave.
14
+ * `PHI_DIALOG_WIDTH` not holding only Forms of one column; a Form's or a record Widget's title from its
15
+ * record read, sent, and heard where it goes. The findings come in the order the compiler used to throw them, so its first is the
16
+ * error it always gave.
16
17
  *
17
18
  * `page` is the Page the tree was asked for: a tree whose Page or Regions belong to another is refused.
18
19
  * `forms` are the Forms the caller can see, by id or as definitions; a Form not among them -- one stored on
@@ -4,6 +4,8 @@ import { PhiCmsWidgetType } from "../constants/cms-widget-types";
4
4
  import { isPhiCmsInstanceId, readPhiCmsInstanceIdDescriptor } from "../types/cms-instance-id";
5
5
  import { PHI_DIALOG_BLEED_BODY_CONFIG, PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH, isPhiFormSingleColumn, } from "./cms-dialog";
6
6
  import { resolvePhiLayoutCreationPreset } from "./cms-layout-defaults";
7
+ import { PHI_FORM_RECORD_TITLE_CAPABILITY, readPhiFormWidgetTitleFromRecord, } from "../components/forms/form-record-title";
8
+ import { readPhiRecordWidgetTitleFromRecord } from "./record-widget";
7
9
  function stablePresetNodeJson(value) {
8
10
  if (Array.isArray(value)) {
9
11
  return `[${value.map(stablePresetNodeJson).join(",")}]`;
@@ -112,6 +114,7 @@ export function checkPhiPresetTreeContract(tree, options = {}) {
112
114
  if (forms)
113
115
  checkDialogWidth(overlay, tree, forms, report);
114
116
  }
117
+ checkRecordTitles(tree, forms, report);
115
118
  for (const rootLayoutNodeId of [
116
119
  tree.page.heroRootLayoutNodeId,
117
120
  tree.page.headerBottomRootLayoutNodeId,
@@ -209,3 +212,60 @@ function checkDialogWidth(overlay, tree, forms, report) {
209
212
  "(PHI_DIALOG_WIDTH). Hand the Form to `dialog` as `body.form`, or state `width: PHI_DIALOG_WIDTH_SINGLE_COLUMN`.");
210
213
  }
211
214
  }
215
+ function readRoutes(config, side) {
216
+ const routes = config.signalRoutes?.[side];
217
+ return Array.isArray(routes) ? routes.filter((route) => route != null && typeof route === "object") : [];
218
+ }
219
+ /*
220
+ * A title from the record shown (`helpers/record-title.ts`), end to end, for the record Form and the record
221
+ * Widget alike, since every break is silent: no `source` reads nothing, no `recordTitle` route names
222
+ * nothing, a route without the option carries nothing, an Overlay not listening on `title` drops it. Where
223
+ * the Form is known, the field is one of its own -- a record answers for the Form's fields; a record
224
+ * Widget reads the whole row its Provider answers, so any field of it may name the dialog.
225
+ */
226
+ function checkRecordTitles(tree, forms, report) {
227
+ const overlaysById = new Map(tree.overlays.map((overlay) => [`cms:${overlay.id}`, overlay]));
228
+ for (const widget of tree.contentWidgets) {
229
+ const isForm = widget.widgetType === PhiCmsWidgetType.Form;
230
+ if (!isForm && widget.widgetType !== PhiCmsWidgetType.Record)
231
+ continue;
232
+ const name = `Preset ${isForm ? "Form" : "Record"} "${widget.id}"`;
233
+ const routes = readRoutes(widget.config, "emits").filter((route) => route.capabilityId === PHI_FORM_RECORD_TITLE_CAPABILITY);
234
+ let title;
235
+ try {
236
+ title = isForm
237
+ ? readPhiFormWidgetTitleFromRecord(widget.config.titleFromRecord)
238
+ : readPhiRecordWidgetTitleFromRecord(widget.config.titleFromRecord);
239
+ }
240
+ catch (error) {
241
+ report(widget.id, `${name}: ${error.message}`);
242
+ continue;
243
+ }
244
+ if (!title) {
245
+ if (routes.length > 0)
246
+ report(widget.id, `${name} routes "recordTitle" but takes no titleFromRecord, so it announces nothing.`);
247
+ continue;
248
+ }
249
+ if (widget.config.source == null)
250
+ report(widget.id, `${name} takes its title from a record it never reads: titleFromRecord needs a source.`);
251
+ if (routes.length === 0)
252
+ report(widget.id, `${name} takes a titleFromRecord that goes nowhere: no route on "recordTitle".`);
253
+ const formId = String(widget.config.formId);
254
+ const descriptor = isForm ? forms?.get(formId)?.descriptor : undefined;
255
+ if (descriptor && !descriptor.fields.some((field) => field.key === title.field)) {
256
+ report(widget.id, `${name} takes its title from "${title.field}", which is no field of "${formId}".`);
257
+ }
258
+ for (const route of routes) {
259
+ if (route.action !== "change" || route.valueType !== "string") {
260
+ report(widget.id, `${name} route "${String(route.routeKey)}" must carry "recordTitle" as change/string.`);
261
+ continue;
262
+ }
263
+ // An Overlay of this tree hears it on its `title` input; another receiver is the Page's choice.
264
+ const overlay = overlaysById.get(String(route.receiver));
265
+ const keys = ["receiver", "scope", "channel", "action", "valueType"];
266
+ if (overlay && !readRoutes(overlay.config, "listens").some((listen) => listen.capabilityId === "title" && keys.every((key) => listen[key] === route[key]))) {
267
+ report(widget.id, `${name} sends its title to Overlay "${overlay.id}", which has no "title" route on ${String(route.scope)} ${String(route.channel)}/change.`);
268
+ }
269
+ }
270
+ }
271
+ }
@@ -0,0 +1,7 @@
1
+ /** The sentence's rule: `%1` exactly once and no other placeholder, or the reason it is refused. */
2
+ export declare function checkPhiRecordTitleTemplate(source: string): string | null;
3
+ /**
4
+ * The sentence with the record's value in it, or "" where the record has no text or number there: an
5
+ * empty title is the Overlay's own. The value goes in as it is -- never translated, `$` and `%1` included.
6
+ */
7
+ export declare function fillPhiRecordTitle(template: string, value: unknown): string;
@@ -0,0 +1,25 @@
1
+ /*
2
+ * A dialog named by the record it shows ("Gallery: Private Cloud", "Terms: @acme/books:pro"): a sentence
3
+ * with `%1` once, and the value of one field of the record standing there. The record Form and the record
4
+ * Widget both announce it on `recordTitle` after every read (FORMS.md, TABLES.md); they differ only in
5
+ * where the sentence comes from -- a Form text, or the record Widget's own placement -- so the two rules
6
+ * they share are here.
7
+ */
8
+ /** The sentence's rule: `%1` exactly once and no other placeholder, or the reason it is refused. */
9
+ export function checkPhiRecordTitleTemplate(source) {
10
+ const placeholders = source.match(/%\d+/gu) ?? [];
11
+ return placeholders.length === 1 && placeholders[0] === "%1"
12
+ ? null
13
+ : `must hold %1 exactly once and no other placeholder: ${JSON.stringify(source)}.`;
14
+ }
15
+ /**
16
+ * The sentence with the record's value in it, or "" where the record has no text or number there: an
17
+ * empty title is the Overlay's own. The value goes in as it is -- never translated, `$` and `%1` included.
18
+ */
19
+ export function fillPhiRecordTitle(template, value) {
20
+ const text = typeof value === "string"
21
+ ? value.trim()
22
+ : typeof value === "number" && Number.isFinite(value) ? String(value) : "";
23
+ // A replacer, so a `$` in the value stays the value.
24
+ return text ? template.replace("%1", () => text) : "";
25
+ }
@@ -0,0 +1,15 @@
1
+ import type { PhiRecordWidgetConfig, PhiRecordWidgetTitleFromRecord } from "../types/record-widget";
2
+ import type { PhiTableProviderResourceDescriptor } from "../types/table-widget";
3
+ /**
4
+ * The placement's `titleFromRecord`, or null where it states none. Strict, as the Form's: no field, or a
5
+ * sentence without exactly one `%1`, is refused rather than read as no title.
6
+ */
7
+ export declare function readPhiRecordWidgetTitleFromRecord(value: unknown): PhiRecordWidgetTitleFromRecord | null;
8
+ /**
9
+ * What the record Widget's actions ask of its resource, as the errors it shows instead of the record --
10
+ * the Table's binding check (`validatePhiTableWidgetBinding`) for the one scope a record has. Each action
11
+ * is the resource's, of scope `row`, named once, and drawn as the danger a destructive one is. A
12
+ * confirmation the resource requires is not asked for here: the record on screen, named in the dialog's
13
+ * title, and the press beside it are that confirmation, and a `confirm` would ask a second time.
14
+ */
15
+ export declare function validatePhiRecordWidgetBinding(config: Pick<PhiRecordWidgetConfig, "actions">, resource: Pick<PhiTableProviderResourceDescriptor, "resourceKey" | "actions">): string[];