@phis/ui 0.7.4 → 0.7.7

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 (124) hide show
  1. package/components/controls/phi-form-control.d.ts +3 -1
  2. package/components/controls/phi-form-control.js +5 -4
  3. package/components/controls/phi-options-provider.d.ts +14 -1
  4. package/components/controls/phi-options-provider.js +73 -2
  5. package/components/forms/auth-admin-settings-labels.d.ts +1 -1
  6. package/components/forms/auth-admin-settings-labels.js +2 -2
  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-registry.d.ts +8 -0
  14. package/components/forms/form-record-title.d.ts +14 -0
  15. package/components/forms/form-record-title.js +38 -0
  16. package/components/forms/form-widget-config.d.ts +3 -0
  17. package/components/forms/form-widget-config.js +2 -0
  18. package/components/forms/phi-form-widget.d.ts +1 -1
  19. package/components/forms/phi-form-widget.js +4 -0
  20. package/components/overlays/phi-overlay-container-client.js +8 -8
  21. package/components/overlays/phi-overlay-title.d.ts +7 -0
  22. package/components/overlays/phi-overlay-title.js +21 -0
  23. package/components/tables/client/phi-table-binding.d.ts +3 -1
  24. package/components/tables/client/phi-table-binding.js +90 -49
  25. package/components/tables/client/phi-table-filter-options.d.ts +27 -0
  26. package/components/tables/client/phi-table-filter-options.js +35 -0
  27. package/components/widgets/accessible-areas.d.ts +1 -1
  28. package/components/widgets/accessible-areas.js +1 -1
  29. package/components/widgets/client/shared/phi-choice-controller.js +22 -15
  30. package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
  31. package/components/widgets/client/shared/phi-rendered-value.js +49 -1
  32. package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
  33. package/components/widgets/client/shared/phi-table-provider.js +22 -0
  34. package/components/widgets/label-sets/admin-users.d.ts +15 -0
  35. package/components/widgets/label-sets/admin-users.js +31 -0
  36. package/constants/core-data-provider-keys.d.ts +7 -0
  37. package/constants/core-data-provider-keys.js +7 -0
  38. package/constants/phi-base-role-metadata.d.ts +2 -2
  39. package/constants/phi-base-role-metadata.js +1 -1
  40. package/constants/runtime-module-ownership.js +3 -0
  41. package/forms.d.ts +1 -1
  42. package/forms.js +1 -1
  43. package/gateway/capability-media-limits.d.ts +10 -0
  44. package/gateway/capability-media-limits.js +40 -0
  45. package/gateway/server-capabilities.js +4 -0
  46. package/helpers/preset-tree-contract-check.d.ts +3 -2
  47. package/helpers/preset-tree-contract-check.js +60 -0
  48. package/helpers/record-title.d.ts +7 -0
  49. package/helpers/record-title.js +25 -0
  50. package/helpers/record-widget.d.ts +15 -0
  51. package/helpers/record-widget.js +57 -0
  52. package/package.json +2 -2
  53. package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
  54. package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
  55. package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
  56. package/plugins/runtime-modules/accounting/data-providers.js +127 -0
  57. package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
  58. package/plugins/runtime-modules/accounting/definition.js +5 -3
  59. package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
  60. package/plugins/runtime-modules/accounting/ids.js +27 -0
  61. package/plugins/runtime-modules/accounting/module.d.ts +52 -0
  62. package/plugins/runtime-modules/accounting/presets.js +23 -4
  63. package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
  64. package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
  65. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
  66. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
  67. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
  68. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
  69. package/plugins/runtime-modules/area-definitions.js +2 -2
  70. package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
  71. package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
  72. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
  73. package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
  74. package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
  75. package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
  76. package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
  77. package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
  78. package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
  79. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +11 -6
  80. package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
  81. package/plugins/runtime-modules/core/cards.js +2 -2
  82. package/plugins/runtime-modules/core/client-data-providers.js +5 -0
  83. package/plugins/runtime-modules/core/data-providers.js +14 -0
  84. package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
  85. package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
  86. package/plugins/runtime-modules/core/widgets/cascader/client.js +13 -12
  87. package/plugins/runtime-modules/core/widgets/checkbox-group/client.js +5 -4
  88. package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
  89. package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
  90. package/plugins/runtime-modules/core/widgets/multi-select/client.js +6 -4
  91. package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
  92. package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
  93. package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
  94. package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
  95. package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
  96. package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
  97. package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
  98. package/plugins/runtime-modules/groups/data-providers.js +1 -1
  99. package/plugins/runtime-modules/groups/definition.js +1 -1
  100. package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
  101. package/plugins/runtime-modules/groups/page-visibility.js +1 -1
  102. package/plugins/runtime-modules/groups/presets.js +1 -1
  103. package/plugins/runtime-modules/groups/services/options.js +1 -1
  104. package/plugins/runtime-modules/groups/services/table.js +1 -1
  105. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
  106. package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
  107. package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
  108. package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
  109. package/plugins/runtime-modules/user-management/controller/client.js +1 -1
  110. package/plugins/runtime-modules/user-management/data-providers.js +1 -0
  111. package/plugins/runtime-modules/user-management/forms.js +22 -0
  112. package/plugins/runtime-modules/user-management/presets.js +2 -2
  113. package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
  114. package/plugins/runtime-modules/user-management/services/options.js +14 -6
  115. package/plugins/runtime-modules/user-management/services/table.js +12 -3
  116. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
  117. package/types/access.d.ts +1 -1
  118. package/types/access.js +7 -7
  119. package/types/core-widget-placements.d.ts +7 -0
  120. package/types/form-descriptor.d.ts +1 -1
  121. package/types/record-widget.d.ts +35 -0
  122. package/types/server-capabilities.d.ts +1 -1
  123. package/types/table-widget.d.ts +20 -0
  124. package/types/table-widget.js +44 -0
@@ -1,6 +1,6 @@
1
1
  import { type FormInstance } from "antd";
2
2
  import type { PhiFormDescriptor } from "../../types/form-descriptor";
3
- import type { PhiFormProviderRegistry } from "../forms/form-provider-registry";
3
+ import type { PhiFormFieldProviderProps, PhiFormProviderRegistry } from "../forms/form-provider-registry";
4
4
  export type PhiFormControlProps = {
5
5
  descriptor: PhiFormDescriptor;
6
6
  registry?: PhiFormProviderRegistry;
@@ -22,6 +22,8 @@ export type PhiFormControlProps = {
22
22
  * dropped: what the form holds for it goes out with the submit unchanged.
23
23
  */
24
24
  unavailableFieldKeys?: readonly string[];
25
+ /** The Media limits of the Add-on the Form's Module is bound to, handed to every field (`PhiFormFieldProviderProps`). */
26
+ mediaLimits?: PhiFormFieldProviderProps["mediaLimits"];
25
27
  form?: PhiFormControlFormInstance;
26
28
  onValuesChange?: (changedValues: Record<string, unknown>, allValues: Record<string, unknown>) => void;
27
29
  onSubmit: (values: Record<string, unknown>) => void | Promise<void>;
@@ -72,7 +72,7 @@ function pickPhiFormWatchedValues(values, keys) {
72
72
  }
73
73
  return picked;
74
74
  }
75
- function PhiResolvedFormFieldControl({ id, provider, field, label, description, labels, formConfig, placeholder, disabled, readOnly, value, checked, onChange, formContext, formValues, }) {
75
+ function PhiResolvedFormFieldControl({ id, provider, field, label, description, labels, formConfig, placeholder, disabled, readOnly, value, checked, onChange, formContext, formValues, mediaLimits, }) {
76
76
  const staticOptions = useMemo(() => field.options?.map((option) => ({
77
77
  ...option,
78
78
  label: resolvePhiFormText(option.label, labels, formConfig),
@@ -101,6 +101,7 @@ function PhiResolvedFormFieldControl({ id, provider, field, label, description,
101
101
  sourceConfig,
102
102
  searchDraft,
103
103
  formValues,
104
+ selectedValues: value,
104
105
  });
105
106
  /*
106
107
  * A required parent changed, so what this field holds was chosen from a list that no longer applies.
@@ -131,12 +132,12 @@ function PhiResolvedFormFieldControl({ id, provider, field, label, description,
131
132
  const controlLabel = field.controlLabel
132
133
  ? resolvePhiFormText(field.controlLabel, labels, formConfig)
133
134
  : undefined;
134
- return (_jsxs(_Fragment, { children: [_jsx(Control, { id: id, field: field, label: label, description: description, controlLabel: controlLabel, labels: labels, formConfig: formConfig, placeholder: placeholder, options: resolvedOptions.options, onSearch: resolvedOptions.search.enabled ? setSearchDraft : undefined, filterOptionsLocally: resolvedOptions.search.filterLocally, disabled: disabled, readOnly: readOnly, value: value, checked: checked, onChange: onChange, formContext: formContext }), resolvedOptions.warning ? (_jsx(PhiAlertControl, { level: "warning", showIcon: true, title: resolvedOptions.warning })) : null] }));
135
+ return (_jsxs(_Fragment, { children: [_jsx(Control, { id: id, field: field, label: label, description: description, controlLabel: controlLabel, labels: labels, formConfig: formConfig, placeholder: placeholder, options: resolvedOptions.options, onSearch: resolvedOptions.search.enabled ? setSearchDraft : undefined, filterOptionsLocally: resolvedOptions.search.filterLocally, disabled: disabled, readOnly: readOnly, value: value, checked: checked, onChange: onChange, formContext: formContext, ...(mediaLimits ? { mediaLimits } : {}) }), resolvedOptions.warning ? (_jsx(PhiAlertControl, { level: "warning", showIcon: true, title: resolvedOptions.warning })) : null] }));
135
136
  }
136
137
  // One empty object for every form without controllers, so the fields drawn are not recomputed on
137
138
  // every render for a new `{}`.
138
139
  const PHI_FORM_NO_CONTROLLER_STATES = Object.freeze({});
139
- export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, registry, labels, formConfig, initialValues, submitOnEnter, disabled = false, readOnly = false, conditionControllerStates = PHI_FORM_NO_CONTROLLER_STATES, unavailableFieldKeys, form: providedForm, onValuesChange, onSubmit, onSubmittingChange, onValidationFailed, onFormReady, onStateChange, onBlurCapture, }, ref) {
140
+ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, registry, labels, formConfig, initialValues, submitOnEnter, disabled = false, readOnly = false, conditionControllerStates = PHI_FORM_NO_CONTROLLER_STATES, unavailableFieldKeys, mediaLimits, form: providedForm, onValuesChange, onSubmit, onSubmittingChange, onValidationFailed, onFormReady, onStateChange, onBlurCapture, }, ref) {
140
141
  const contributedRegistry = usePhiFormProviderRegistry();
141
142
  const activeRegistry = useMemo(() => registry ?? (contributedRegistry
142
143
  ? extendPhiFormProviderRegistry(PHI_SHARED_FORM_PROVIDER_REGISTRY, contributedRegistry)
@@ -517,6 +518,6 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
517
518
  ...resolveHoneypotStyle(provider.presentation),
518
519
  }, children: _jsx(Form.Item, { name: field.key, messageVariables: { label: labelText ?? field.key }, hidden: hidden, valuePropName: provider.valuePropName, dependencies: dependencies, required: required, rules: resolvedRules.length === 0 ? undefined : resolvedRules, style: { marginBottom: 0 }, children: _jsx(PhiResolvedFormFieldControl, { provider: provider, field: field, label: providerLabel, description: providerDescription, labels: labels, formConfig: formConfig, placeholder: field.placeholder
519
520
  ? resolvePhiFormText(field.placeholder, labels, formConfig)
520
- : undefined, disabled: disabled || submitting || readOnly || field.config?.disabled === true || fieldDisabled !== "not-matched", readOnly: readOnly, formContext: fieldFormContext, formValues: formValues }) }) })] }, field.key));
521
+ : undefined, disabled: disabled || submitting || readOnly || field.config?.disabled === true || fieldDisabled !== "not-matched", readOnly: readOnly, formContext: fieldFormContext, formValues: formValues, mediaLimits: mediaLimits }) }) })] }, field.key));
521
522
  }) }) }));
522
523
  });
@@ -44,6 +44,17 @@ export type PhiControlOptionsProviderContext<TValue extends string | number = st
44
44
  * knowing which field supplies it or where that field lives.
45
45
  */
46
46
  dependencies: Record<string, unknown>;
47
+ /**
48
+ * The values the control holds right now: one for a single choice, every one for a multiple choice,
49
+ * none while nothing is chosen.
50
+ *
51
+ * For a provider that answers with one page of a longer list. What the field holds need not be on
52
+ * that page, and a control that cannot find a value among its options shows the raw value -- an id
53
+ * instead of a name. Such a provider loads the names of these values alongside the page. Not part of
54
+ * the default load key: a provider that answers with everything it has would ask again on every
55
+ * choice for nothing, so one that needs them takes them into `resolveLoadKey` itself.
56
+ */
57
+ selected: readonly TValue[];
47
58
  /**
48
59
  * The reader's language and the Site's time zone (`usePhiIntlLocale`, `usePhiIntlTimeZone`), for a
49
60
  * provider whose option labels are words, amounts or dates. The hook puts both into every load key,
@@ -109,7 +120,7 @@ export declare function createPhiStaticControlOptionsProviderClient<TValue exten
109
120
  export declare function PhiControlOptionsProviderIsolationBoundary({ children }: {
110
121
  children: ReactNode;
111
122
  }): import("react").FunctionComponentElement<import("react").ProviderProps<ReadonlyMap<`${string}/${string}`, AnyOptionsProviderRegistration>>>;
112
- export declare function usePhiControlOptionsProvider<TValue extends string | number = string>({ options, optionsProvider, sourceConfig, searchDraft, formValues, }: {
123
+ export declare function usePhiControlOptionsProvider<TValue extends string | number = string>({ options, optionsProvider, sourceConfig, searchDraft, formValues, selectedValues, }: {
113
124
  options?: readonly {
114
125
  value: TValue;
115
126
  label?: string;
@@ -130,6 +141,8 @@ export declare function usePhiControlOptionsProvider<TValue extends string | num
130
141
  * passes none, and a `form` dependency simply has no value there.
131
142
  */
132
143
  formValues?: Record<string, unknown> | null;
144
+ /** What the control holds -- one value, a list, or nothing -- as it holds it; read into `selected`. */
145
+ selectedValues?: unknown;
133
146
  }): PhiResolvedControlOptions<TValue> & {
134
147
  search: PhiControlOptionsSearchState;
135
148
  };
@@ -8,6 +8,9 @@ const PhiControlOptionsProviderRegistryContext = createContext(EMPTY_OPTIONS_PRO
8
8
  const EMPTY_PROVIDER_SNAPSHOT = null;
9
9
  /** Shared, so a provider without dependencies keeps the same object across renders. */
10
10
  const EMPTY_DEPENDENCY_VALUES = Object.freeze({});
11
+ /** Shared for the same reason: a control that holds nothing hands every provider the same list. */
12
+ const EMPTY_SELECTED_VALUES = Object.freeze([]);
13
+ const EMPTY_REMEMBERED_OPTIONS = new Map();
11
14
  /** One pause, not one request per keystroke. */
12
15
  const PHI_OPTIONS_SEARCH_DEBOUNCE_MS = 250;
13
16
  const IN_FLIGHT_PROVIDER_LOADS = new WeakMap();
@@ -45,6 +48,41 @@ function normalizeStaticOptions(options) {
45
48
  parentValue: option.parentValue,
46
49
  }));
47
50
  }
51
+ /**
52
+ * What a control holds, as `selected`: read here once, like the search policy. `null` and the `""` a
53
+ * cleared select reports are no value, and only a string or a number can be an option's value.
54
+ */
55
+ function readSelectedValues(value) {
56
+ const entries = Array.isArray(value) ? value : [value];
57
+ return entries.filter((entry) => (typeof entry === "string" && entry !== "") || (typeof entry === "number" && Number.isFinite(entry)));
58
+ }
59
+ function areSameControlOptions(left, right) {
60
+ const leftEntries = Object.entries(left);
61
+ return leftEntries.length === Object.keys(right).length
62
+ && leftEntries.every(([key, entry]) => Object.is(entry, right[key]));
63
+ }
64
+ /**
65
+ * The last option seen for each chosen value; a value no longer chosen is forgotten. Answers with
66
+ * `remembered` itself while nothing changed -- by content, as a resolver may build options afresh -- so
67
+ * storing it during the render does not render again.
68
+ */
69
+ function rememberSelectedOptions(remembered, selected, options) {
70
+ if (selected.length === 0) {
71
+ return remembered.size === 0 ? remembered : EMPTY_REMEMBERED_OPTIONS;
72
+ }
73
+ const next = new Map();
74
+ for (const value of selected) {
75
+ const known = options.find((option) => option.value === value) ?? remembered.get(value);
76
+ if (known)
77
+ next.set(value, known);
78
+ }
79
+ const unchanged = next.size === remembered.size
80
+ && [...next].every(([value, option]) => {
81
+ const previous = remembered.get(value);
82
+ return previous !== undefined && (previous === option || areSameControlOptions(previous, option));
83
+ });
84
+ return unchanged ? remembered : next;
85
+ }
48
86
  export function readPhiControlOptionsProviderParam(provider, key) {
49
87
  const value = provider?.params?.[key];
50
88
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
@@ -130,9 +168,14 @@ export function createPhiStaticControlOptionsProviderClient(registration) {
130
168
  export function PhiControlOptionsProviderIsolationBoundary({ children }) {
131
169
  return createElement(PhiControlOptionsProviderRegistryContext.Provider, { value: EMPTY_OPTIONS_PROVIDER_REGISTRY }, children);
132
170
  }
133
- export function usePhiControlOptionsProvider({ options, optionsProvider, sourceConfig, searchDraft = "", formValues, }) {
171
+ export function usePhiControlOptionsProvider({ options, optionsProvider, sourceConfig, searchDraft = "", formValues, selectedValues, }) {
134
172
  const registry = useContext(PhiControlOptionsProviderRegistryContext);
135
173
  const staticOptions = useMemo(() => normalizeStaticOptions(options), [options]);
174
+ // Keyed by content, so a value list built afresh on every render is still the same `selected`.
175
+ const selectedKey = JSON.stringify(readSelectedValues(selectedValues));
176
+ const selected = useMemo(() => selectedKey === "[]"
177
+ ? EMPTY_SELECTED_VALUES
178
+ : Object.freeze(JSON.parse(selectedKey)), [selectedKey]);
136
179
  /*
137
180
  * The declared search policy, applied in one place. A field states whether its provider can be
138
181
  * searched and from how many characters; the load mode states who narrows the list. Debouncing lives
@@ -188,6 +231,8 @@ export function usePhiControlOptionsProvider({ options, optionsProvider, sourceC
188
231
  // keystroke, so taking the search into account is the searching provider's own decision.
189
232
  search,
190
233
  dependencies: dependencyValues,
234
+ // Not in the default load key either: a provider that answers with all it has must not reload per choice.
235
+ selected,
191
236
  locale,
192
237
  timeZone,
193
238
  snapshot: providerSnapshot,
@@ -241,7 +286,7 @@ export function usePhiControlOptionsProvider({ options, optionsProvider, sourceC
241
286
  providerLoadKey,
242
287
  registeredProvider,
243
288
  ]);
244
- return useMemo(() => {
289
+ const resolved = useMemo(() => {
245
290
  if (!optionsProvider?.providerKey) {
246
291
  return { options: staticOptions, search: searchState };
247
292
  }
@@ -278,6 +323,7 @@ export function usePhiControlOptionsProvider({ options, optionsProvider, sourceC
278
323
  sourceConfig,
279
324
  search,
280
325
  dependencies: dependencyValues,
326
+ selected,
281
327
  locale,
282
328
  timeZone,
283
329
  snapshot: providerSnapshot,
@@ -290,6 +336,7 @@ export function usePhiControlOptionsProvider({ options, optionsProvider, sourceC
290
336
  searchState,
291
337
  dependenciesSatisfied,
292
338
  dependencyValues,
339
+ selected,
293
340
  locale,
294
341
  timeZone,
295
342
  asyncData,
@@ -301,4 +348,28 @@ export function usePhiControlOptionsProvider({ options, optionsProvider, sourceC
301
348
  sourceConfig,
302
349
  staticOptions,
303
350
  ]);
351
+ /*
352
+ * A chosen value keeps the option it was last seen with, for every provider: any answer can leave it
353
+ * out -- the empty list while a new search loads, the next page -- and the control would show the raw
354
+ * value. Added to the list, because the Select finds a chosen value's label among `options`. Filtering
355
+ * locally, the Select hides it like any option that does not match; where the provider answered the
356
+ * search (`filterLocally: false`) it stays at the end, marked as chosen -- the price of keeping its
357
+ * name, and a multiple choice shows its tags while the person types. Stored during the render, so the
358
+ * label survives the very render that drops it; empty until an option resolved, on the server as on
359
+ * the client, so hydration matches.
360
+ */
361
+ const [rememberedOptions, setRememberedOptions] = useState(EMPTY_REMEMBERED_OPTIONS);
362
+ const nextRememberedOptions = rememberSelectedOptions(rememberedOptions, selected, resolved.options);
363
+ if (nextRememberedOptions !== rememberedOptions) {
364
+ setRememberedOptions(nextRememberedOptions);
365
+ }
366
+ return useMemo(() => {
367
+ const missing = selected
368
+ .filter((value) => !resolved.options.some((option) => option.value === value))
369
+ .flatMap((value) => {
370
+ const option = nextRememberedOptions.get(value);
371
+ return option ? [option] : [];
372
+ });
373
+ return missing.length === 0 ? resolved : { ...resolved, options: [...resolved.options, ...missing] };
374
+ }, [nextRememberedOptions, resolved, selected]);
304
375
  }
@@ -49,7 +49,7 @@ export declare function getPhiAuthAdminSettingsLabels(options: PhiGlobalTranslat
49
49
  };
50
50
  roles: {
51
51
  admin: string;
52
- developer: string;
52
+ maintainer: string;
53
53
  builder: string;
54
54
  author: string;
55
55
  publisher: string;
@@ -36,7 +36,7 @@ const PHI_AUTH_ADMIN_SETTINGS_LABEL_SET = definePhiLabelSet({
36
36
  totp_roles_label: "Required for roles",
37
37
  totp_roles_hint: definePhiMessageLabel("Leave empty to require two-factor authentication for every site member."),
38
38
  role_admin: "Admin",
39
- role_developer: "Developer",
39
+ role_maintainer: "Maintainer",
40
40
  role_builder: "Builder",
41
41
  role_author: "Author",
42
42
  role_publisher: "Publisher",
@@ -152,7 +152,7 @@ export async function getPhiAuthAdminSettingsLabels(options) {
152
152
  },
153
153
  roles: {
154
154
  admin: labels.role_admin,
155
- developer: labels.role_developer,
155
+ maintainer: labels.role_maintainer,
156
156
  builder: labels.role_builder,
157
157
  author: labels.role_author,
158
158
  publisher: labels.role_publisher,
@@ -1,6 +1,6 @@
1
1
  import type { PhiFormFieldPlacementDescriptor, PhiFormGridRange } from "@phis/contracts/forms";
2
2
  import { type PhiFormResponsiveMode, type PhiResolvedFormLayout } from "@phis/contracts/forms";
3
- export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MODES, PHI_FORM_ROW_END_HALF, PHI_FORM_ROW_FULL, PHI_FORM_SIDE_END_HALF, PHI_FORM_SIDE_START_HALF, PHI_FORM_STACKED_END_HALF, PHI_FORM_STACKED_FULL, PHI_FORM_STACKED_LAYOUT, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, parsePhiFormDescriptor, phiFormFlowHalfColumns, resolvePhiFormLayout, resolvePhiFormResponsiveGridRange, resolvePhiFormText, type PhiFormResponsiveMode, type PhiResolvedFormLayout, type PhiResolvedFormResponsiveGridRange, } from "@phis/contracts/forms";
3
+ export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MODES, PHI_FORM_ROW_END_HALF, PHI_FORM_ROW_FULL, PHI_FORM_SIDE_END_HALF, PHI_FORM_SIDE_START_HALF, PHI_FORM_STACKED_END_HALF, PHI_FORM_STACKED_FULL, PHI_FORM_STACKED_LAYOUT, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, parsePhiFormDescriptor, phiFormFlowHalfColumns, resolvePhiFormLayout, resolvePhiFormErrorText, resolvePhiFormResponsiveGridRange, resolvePhiFormText, type PhiFormResponsiveMode, type PhiResolvedFormLayout, type PhiResolvedFormResponsiveGridRange, } from "@phis/contracts/forms";
4
4
  export declare function shouldPhiFormSubmitOnKeyDown(input: {
5
5
  key: string;
6
6
  defaultPrevented: boolean;
@@ -5,7 +5,7 @@ import { PHI_CONTAINER_BREAKPOINT_COL3, PHI_CONTAINER_BREAKPOINT_CONTENT, } from
5
5
  * stores descriptors and reads them by the same rules. What stays below is how this renderer turns the
6
6
  * grid into rows and CSS, which is nobody else's business.
7
7
  */
8
- export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MODES, PHI_FORM_ROW_END_HALF, PHI_FORM_ROW_FULL, PHI_FORM_SIDE_END_HALF, PHI_FORM_SIDE_START_HALF, PHI_FORM_STACKED_END_HALF, PHI_FORM_STACKED_FULL, PHI_FORM_STACKED_LAYOUT, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, parsePhiFormDescriptor, phiFormFlowHalfColumns, resolvePhiFormLayout, resolvePhiFormResponsiveGridRange, resolvePhiFormText, } from "@phis/contracts/forms";
8
+ export { PHI_FORM_DEFAULT_LAYOUT, PHI_FORM_GRID_LAST_LINE, PHI_FORM_RESPONSIVE_MODES, PHI_FORM_ROW_END_HALF, PHI_FORM_ROW_FULL, PHI_FORM_SIDE_END_HALF, PHI_FORM_SIDE_START_HALF, PHI_FORM_STACKED_END_HALF, PHI_FORM_STACKED_FULL, PHI_FORM_STACKED_LAYOUT, assertPhiFormLabelSetKey, createPhiFormLabelText, createPhiFormLiteralText, parsePhiFormDescriptor, phiFormFlowHalfColumns, resolvePhiFormLayout, resolvePhiFormErrorText, resolvePhiFormResponsiveGridRange, resolvePhiFormText, } from "@phis/contracts/forms";
9
9
  export function shouldPhiFormSubmitOnKeyDown(input) {
10
10
  return input.key === "Enter" &&
11
11
  !input.defaultPrevented &&
@@ -1,6 +1,7 @@
1
1
  import type { PhiSignalAddress } from "../../types/signals";
2
2
  import type { PhiFormDescriptor } from "../../types/form-descriptor";
3
3
  import type { PhiCmsFormWidgetConfig } from "./form-widget-config";
4
+ import { type PhiFormControlProps } from "../controls/phi-form-control";
4
5
  export type PhiFormDescriptorRuntimeClientProps = {
5
6
  descriptor: PhiFormDescriptor;
6
7
  labels?: Readonly<Record<string, string>>;
@@ -11,5 +12,7 @@ export type PhiFormDescriptorRuntimeClientProps = {
11
12
  widgetConfig?: PhiCmsFormWidgetConfig;
12
13
  /** The fields whose field type belongs to a Module that is not active in this Area. */
13
14
  unavailableFieldKeys?: readonly string[];
15
+ /** The Media limits of the Add-on the Form's Module is bound to, for its Media fields (FORMS.md). */
16
+ mediaLimits?: PhiFormControlProps["mediaLimits"];
14
17
  };
15
- export declare function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, unavailableFieldKeys, }: PhiFormDescriptorRuntimeClientProps): import("react").JSX.Element;
18
+ export declare function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, unavailableFieldKeys, mediaLimits, }: PhiFormDescriptorRuntimeClientProps): import("react").JSX.Element;
@@ -13,7 +13,8 @@ import { usePhiTableProvider } from "../widgets/client/shared/phi-table-provider
13
13
  import { usePhiIntlLocale, usePhiIntlTimeZone } from "../root/phi-intl-locale";
14
14
  import { PhiFormControl } from "../controls/phi-form-control";
15
15
  import { readPhiRuntimeFormValuesSignalValue } from "./runtime-form-state";
16
- import { resolvePhiFormText } from "./form-descriptor-contract";
16
+ import { resolvePhiFormErrorText, resolvePhiFormText } from "./form-descriptor-contract";
17
+ import { PHI_FORM_RECORD_TITLE_CAPABILITY, resolvePhiFormRecordTitle } from "./form-record-title";
17
18
  import { PhiFormWidgetSubmitOutlet, usePhiFormWidgetSubmit } from "./phi-form-widget-frame";
18
19
  import { usePhiRuntimeFormClient } from "./runtime-form-client";
19
20
  import { PhiAlertControl } from "../controls/phi-alert-control";
@@ -27,7 +28,7 @@ import { usePhiInDialogBody } from "../overlays/phi-dialog-body-context";
27
28
  /** How long before its window closes a token is renewed rather than sent: the request takes time too. */
28
29
  const PHI_FORM_GUARD_EXPIRY_MARGIN_MS = 60_000;
29
30
  const EMPTY_FORM_VALUES = {};
30
- export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, unavailableFieldKeys, }) {
31
+ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, unavailableFieldKeys, mediaLimits, }) {
31
32
  const formClient = usePhiRuntimeFormClient({ controllerAddress: formControllerAddress });
32
33
  const formRef = useRef(null);
33
34
  const submitCorrelationRef = useRef(null);
@@ -133,6 +134,23 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
133
134
  const emitCapability = useCallback((capabilityId, value = null, correlationId) => {
134
135
  emitPhiSignalCapability(emitSignal, widgetConfig?.signalRoutes?.emits, capabilityId, value, correlationId);
135
136
  }, [emitSignal, widgetConfig]);
137
+ /*
138
+ * The title the record gives the dialog, where the placement takes one (`titleFromRecord`): announced
139
+ * after every read, and empty as a row is asked for, so the last row's name does not stand over the
140
+ * next one while it loads. Empty is the Overlay's own title.
141
+ */
142
+ const titleFromRecord = widgetConfig?.titleFromRecord ?? null;
143
+ const formConfig = widgetConfig?.formConfig;
144
+ const announceRecordTitle = useCallback((values, correlationId) => {
145
+ if (!titleFromRecord)
146
+ return;
147
+ emitCapability(PHI_FORM_RECORD_TITLE_CAPABILITY, resolvePhiFormRecordTitle(titleFromRecord, values, labels, formConfig), correlationId);
148
+ }, [emitCapability, formConfig, labels, titleFromRecord]);
149
+ // For the read on mount, which must not run again because the words around it changed.
150
+ const announceRecordTitleRef = useRef(announceRecordTitle);
151
+ useEffect(() => {
152
+ announceRecordTitleRef.current = announceRecordTitle;
153
+ }, [announceRecordTitle]);
136
154
  /*
137
155
  * That the values now in the form have already been rejected, and nothing has changed since.
138
156
  *
@@ -184,7 +202,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
184
202
  recordLoadRef.current?.abort();
185
203
  recordLoadRef.current = null;
186
204
  }, []);
187
- const loadRecord = useCallback(async (rowIdentity) => {
205
+ const loadRecord = useCallback(async (rowIdentity, correlationId) => {
188
206
  setLoading(true);
189
207
  setError(null);
190
208
  const abortController = beginRecordLoad();
@@ -196,6 +214,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
196
214
  recordIdentityRef.current = rowIdentity;
197
215
  setRecord(values);
198
216
  setRecordKey(rowIdentity == null ? "singleton" : String(rowIdentity));
217
+ announceRecordTitle(values, correlationId);
199
218
  }
200
219
  catch (readError) {
201
220
  if (!signal.aborted) {
@@ -206,7 +225,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
206
225
  if (!signal.aborted)
207
226
  setLoading(false);
208
227
  }
209
- }, [beginRecordLoad, readRecord]);
228
+ }, [announceRecordTitle, beginRecordLoad, readRecord]);
210
229
  useEffect(() => {
211
230
  if (!source || widgetConfig?.openActionKey)
212
231
  return;
@@ -218,6 +237,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
218
237
  setRecord(values);
219
238
  setRecordKey("singleton");
220
239
  setError(null);
240
+ announceRecordTitleRef.current(values);
221
241
  }).catch((readError) => {
222
242
  if (!abortController.signal.aborted) {
223
243
  setError(readError instanceof Error ? readError.message : "Form record loading failed.");
@@ -253,7 +273,8 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
253
273
  const action = readPhiTableActionSignalValue(signal.value);
254
274
  if (!action || action.actionKey !== (widgetConfig?.openActionKey ?? "edit") || action.rowIdentity == null)
255
275
  return;
256
- void loadRecord(action.rowIdentity);
276
+ announceRecordTitle(null, signal.correlationId);
277
+ void loadRecord(action.rowIdentity, signal.correlationId);
257
278
  emitCapability("conditionStateRequest", null, signal.correlationId);
258
279
  }
259
280
  else if (route.capabilityId === "close") {
@@ -263,7 +284,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
263
284
  else if (route.capabilityId === "reload") {
264
285
  const rowIdentity = recordIdentityRef.current;
265
286
  if (rowIdentity != null)
266
- void loadRecord(rowIdentity);
287
+ void loadRecord(rowIdentity, signal.correlationId);
267
288
  }
268
289
  else if (route.capabilityId === "submit") {
269
290
  /*
@@ -297,7 +318,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
297
318
  setConditionControllerStates((current) => ({ ...current, [signal.sender]: next.state }));
298
319
  }
299
320
  }
300
- }, [conditionControllerAddresses, emitCapability, formControllerAddress, identity.receiver, loadRecord, requestReset, requestSubmit, widgetConfig]), useMemo(() => {
321
+ }, [announceRecordTitle, conditionControllerAddresses, emitCapability, formControllerAddress, identity.receiver, loadRecord, requestReset, requestSubmit, widgetConfig]), useMemo(() => {
301
322
  const listenRoutes = widgetConfig?.signalRoutes?.listens ?? [];
302
323
  return listenRoutes.length === 0 ? null : {
303
324
  scopes: Array.from(new Set(listenRoutes.map((route) => route.scope))),
@@ -467,7 +488,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
467
488
  activeForm.setFieldsValue(pendingValuesRef.current);
468
489
  pendingValuesRef.current = null;
469
490
  }
470
- }, conditionControllerStates: conditionControllerStates, unavailableFieldKeys: unavailableFieldKeys, onValuesChange: (changed, all) => {
491
+ }, conditionControllerStates: conditionControllerStates, unavailableFieldKeys: unavailableFieldKeys, mediaLimits: mediaLimits, onValuesChange: (changed, all) => {
471
492
  // A value moved, so whatever validation refused before is no longer what is being asked.
472
493
  rejectedRef.current = false;
473
494
  runtimeBinding.onValuesChange(changed, all);
@@ -523,14 +544,15 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
523
544
  /*
524
545
  * The code first: it is the only part of a refusal that can be said in the visitor's
525
546
  * language, because the descriptor maps it to a label. `error` is what the handler wrote
526
- * for a log, and it stands in only where the code is absent or nothing maps it.
547
+ * for a log, and it stands in only where the code is absent or nothing maps it. A mapped
548
+ * text may name values of the same answer (`product`), filled after it is translated.
527
549
  */
528
550
  const code = typeof result.payload?.code === "string" ? result.payload.code : null;
529
551
  if (code === PHI_FORM_GUARD_EXPIRED_CODE && descriptor.guard)
530
552
  renewGuard();
531
553
  const declared = code ? descriptor.errors?.[code] : undefined;
532
554
  const message = declared
533
- ? resolvePhiFormText(declared, labels)
555
+ ? resolvePhiFormErrorText(declared, result.payload, labels)
534
556
  : typeof result.payload?.error === "string"
535
557
  ? result.payload.error
536
558
  : "Form submission failed.";
@@ -540,7 +562,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
540
562
  reportSuccess(correlationId);
541
563
  const rowIdentity = recordIdentityRef.current;
542
564
  if (source && (rowIdentity != null || !widgetConfig?.openActionKey)) {
543
- void loadRecord(rowIdentity);
565
+ void loadRecord(rowIdentity, correlationId);
544
566
  }
545
567
  }
546
568
  catch (submitError) {
@@ -0,0 +1,12 @@
1
+ import type { PhiCmsRuntimeRenderRegistry } from "../../types/cms-plugins";
2
+ import type { PhiRuntimeModuleId } from "../../types/cms-module-descriptors";
3
+ import type { PhiAddonMediaLimits } from "../../types/server-capabilities";
4
+ /**
5
+ * The Media limits a Form's Media fields apply: those of the Add-on the Form's own Module is bound to
6
+ * (its server binding's `providerId`), as the capability snapshot hands them on from the Add-on's
7
+ * manifest (`PhiCapabilityProvider.media`). The Form's Module and not the field's: the `media-asset`
8
+ * field belongs to the Media library and stands in Forms of any Module, and what it may take is the
9
+ * question of whoever stores the Form's value. `undefined` for a Core-bound Module, an Add-on that states
10
+ * none, and wherever there is no snapshot.
11
+ */
12
+ export declare function resolvePhiFormMediaLimits(registry: Pick<PhiCmsRuntimeRenderRegistry, "runtimeModuleCatalog" | "serverCapabilities">, ownerModuleId: PhiRuntimeModuleId): PhiAddonMediaLimits | undefined;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The Media limits a Form's Media fields apply: those of the Add-on the Form's own Module is bound to
3
+ * (its server binding's `providerId`), as the capability snapshot hands them on from the Add-on's
4
+ * manifest (`PhiCapabilityProvider.media`). The Form's Module and not the field's: the `media-asset`
5
+ * field belongs to the Media library and stands in Forms of any Module, and what it may take is the
6
+ * question of whoever stores the Form's value. `undefined` for a Core-bound Module, an Add-on that states
7
+ * none, and wherever there is no snapshot.
8
+ */
9
+ export function resolvePhiFormMediaLimits(registry, ownerModuleId) {
10
+ const providerId = registry.runtimeModuleCatalog.get(ownerModuleId)?.definition.serverBinding.providerId;
11
+ if (!providerId)
12
+ return undefined;
13
+ return registry.serverCapabilities?.providers.find((provider) => provider.providerId === providerId)?.media;
14
+ }
@@ -2,6 +2,7 @@ import { type ComponentType, type ReactNode } from "react";
2
2
  import type { PhiFormControlRule } from "../controls/phi-form-control-contract";
3
3
  import type { PhiFormFieldDescriptor, PhiFormFieldTypeProviderDescriptor, PhiFormProviderKey, PhiFormValidationProviderDescriptor, PhiFormValidationRuleDescriptor } from "../../types/form-descriptor";
4
4
  import type { PhiControlOption } from "../controls/phi-control-options";
5
+ import type { PhiAddonMediaLimits } from "../../types/server-capabilities";
5
6
  export type PhiFormFieldProviderProps = {
6
7
  /**
7
8
  * The DOM id the form gives this field, unique on the page: the field's label points at it. A
@@ -37,6 +38,13 @@ export type PhiFormFieldProviderProps = {
37
38
  };
38
39
  /** What the Widget was placed with, for text a field takes from its placement rather than its form. */
39
40
  formConfig?: Readonly<Record<string, unknown>>;
41
+ /**
42
+ * The Media limits of the Add-on the Form's Module is bound to, as its manifest states them and the
43
+ * capability snapshot hands them on (`PhiCapabilityProvider.media`). Absent for a Form of a Core-bound
44
+ * Module and for an Add-on that states none. The Media fields apply them (FORMS.md); other fields have
45
+ * nothing to do with them.
46
+ */
47
+ mediaLimits?: PhiAddonMediaLimits;
40
48
  };
41
49
  export type PhiFormFieldTypeProvider = Omit<PhiFormFieldTypeProviderDescriptor, "ownerModuleId"> & {
42
50
  Control: ComponentType<PhiFormFieldProviderProps>;
@@ -0,0 +1,14 @@
1
+ import { type PhiFormTextDescriptor } from "@phis/contracts/forms";
2
+ export type PhiFormWidgetTitleFromRecord = {
3
+ template: PhiFormTextDescriptor;
4
+ field: string;
5
+ };
6
+ /** The Form Widget output that carries the title: `change`, `string`. */
7
+ export declare const PHI_FORM_RECORD_TITLE_CAPABILITY = "recordTitle";
8
+ /**
9
+ * The placement's `titleFromRecord`, or null where it states none. Strict: no field, or a source text
10
+ * without exactly one `%1`, is refused -- the translation is not there to read, so the fallback is.
11
+ */
12
+ export declare function readPhiFormWidgetTitleFromRecord(value: unknown): PhiFormWidgetTitleFromRecord | null;
13
+ /** The title a record gives, in the reader's language, or "" without a record or a text or number there. */
14
+ export declare function resolvePhiFormRecordTitle(titleFromRecord: PhiFormWidgetTitleFromRecord, record: Readonly<Record<string, unknown>> | null, labels?: Readonly<Record<string, string>>, formConfig?: Readonly<Record<string, unknown>>): string;
@@ -0,0 +1,38 @@
1
+ import { resolvePhiFormText } from "@phis/contracts/forms";
2
+ import { isPhiRecord } from "../../helpers/is-record";
3
+ import { checkPhiRecordTitleTemplate, fillPhiRecordTitle } from "../../helpers/record-title";
4
+ /** The Form Widget output that carries the title: `change`, `string`. */
5
+ export const PHI_FORM_RECORD_TITLE_CAPABILITY = "recordTitle";
6
+ function readTemplate(value) {
7
+ if (isPhiRecord(value) && value.kind === "literal" && typeof value.value === "string") {
8
+ return { kind: "literal", value: value.value };
9
+ }
10
+ if (isPhiRecord(value) && (value.kind === "label" || value.kind === "config") &&
11
+ typeof value.key === "string" && value.key.trim() && typeof value.fallback === "string") {
12
+ return { kind: value.kind, key: value.key.trim(), fallback: value.fallback };
13
+ }
14
+ throw new Error(`Form titleFromRecord.template ${JSON.stringify(value)} is no Form text ({ kind: "label", key, fallback }).`);
15
+ }
16
+ /**
17
+ * The placement's `titleFromRecord`, or null where it states none. Strict: no field, or a source text
18
+ * without exactly one `%1`, is refused -- the translation is not there to read, so the fallback is.
19
+ */
20
+ export function readPhiFormWidgetTitleFromRecord(value) {
21
+ if (value == null)
22
+ return null;
23
+ if (!isPhiRecord(value))
24
+ throw new Error(`Form titleFromRecord ${JSON.stringify(value)} is no { template, field }.`);
25
+ const field = typeof value.field === "string" ? value.field.trim() : "";
26
+ if (!field)
27
+ throw new Error("Form titleFromRecord.field must name the record field the title takes its value from.");
28
+ const template = readTemplate(value.template);
29
+ const templateError = checkPhiRecordTitleTemplate(template.kind === "literal" ? template.value : template.fallback);
30
+ if (templateError)
31
+ throw new Error(`Form titleFromRecord.template ${templateError}`);
32
+ return { template, field };
33
+ }
34
+ /** The title a record gives, in the reader's language, or "" without a record or a text or number there. */
35
+ export function resolvePhiFormRecordTitle(titleFromRecord, record, labels, formConfig) {
36
+ const value = record?.[titleFromRecord.field];
37
+ return fillPhiRecordTitle(resolvePhiFormText(titleFromRecord.template, labels, formConfig), value);
38
+ }
@@ -2,6 +2,7 @@ import type { PhiCmsFormWidgetCardConfig, PhiCmsFormWidgetFeedbackConfig, PhiCms
2
2
  import { type PhiProviderResourceSource } from "../../types/runtime-data-provider";
3
3
  import { type PhiFormId } from "../../types/form-id";
4
4
  import { readPhiSignalRouteSet } from "../../types/signals";
5
+ import { type PhiFormWidgetTitleFromRecord } from "./form-record-title";
5
6
  import { type PhiCmsWidgetConfigBase } from "../widgets/config/parser-primitives";
6
7
  export type PhiCmsFormWidgetConfig = PhiCmsWidgetConfigBase & {
7
8
  formId: PhiFormId | null;
@@ -53,6 +54,8 @@ export type PhiCmsFormWidgetConfig = PhiCmsWidgetConfigBase & {
53
54
  * in the Builder starts as the Table-driven kind.
54
55
  */
55
56
  openActionKey?: string;
57
+ /** The title its record gives the dialog, announced on `recordTitle` (`form-record-title.ts`). */
58
+ titleFromRecord: PhiFormWidgetTitleFromRecord | null;
56
59
  signalRoutes: ReturnType<typeof readPhiSignalRouteSet>;
57
60
  };
58
61
  export declare function parsePhiFormWidgetConfig(rawConfig: Record<string, unknown>): PhiCmsFormWidgetConfig;
@@ -2,6 +2,7 @@ import { isPhiRecord } from "../../helpers/is-record";
2
2
  import { readPhiProviderResourceSource, } from "../../types/runtime-data-provider";
3
3
  import { isPhiFormId, normalizePhiFormId } from "../../types/form-id";
4
4
  import { readPhiSignalRouteSet } from "../../types/signals";
5
+ import { readPhiFormWidgetTitleFromRecord } from "./form-record-title";
5
6
  import { readRenderableBlockConfig, } from "../widgets/config/parser-primitives";
6
7
  import { PHI_LAYOUT } from "../../theme/phi-tokens";
7
8
  function readRecord(value) {
@@ -118,6 +119,7 @@ export function parsePhiFormWidgetConfig(rawConfig) {
118
119
  openActionKey: typeof rawConfig.openActionKey === "string" && rawConfig.openActionKey.trim()
119
120
  ? rawConfig.openActionKey.trim()
120
121
  : undefined,
122
+ titleFromRecord: readPhiFormWidgetTitleFromRecord(rawConfig.titleFromRecord),
121
123
  signalRoutes: readPhiSignalRouteSet(rawConfig.signalRoutes),
122
124
  };
123
125
  }
@@ -6,7 +6,7 @@ import type { PhiCmsFormWidgetConfig } from "./form-widget-config";
6
6
  import { type PhiRuntimeFeatureState } from "../../types/runtime-condition";
7
7
  export type PhiFormWidgetProps = {
8
8
  runtime: Pick<PhiBlockRuntime, "site" | "locale"> & Partial<Pick<PhiBlockRuntime, "area">>;
9
- registry: Pick<PhiCmsRuntimeRenderRegistry, "formDefinitionsById" | "uiProviderModuleIds" | "activeModuleIds" | "ownerModuleIdByFormFieldTypeKey">;
9
+ registry: Pick<PhiCmsRuntimeRenderRegistry, "formDefinitionsById" | "uiProviderModuleIds" | "activeModuleIds" | "ownerModuleIdByFormFieldTypeKey" | "runtimeModuleCatalog" | "serverCapabilities">;
10
10
  formId: PhiFormId;
11
11
  formInstanceKey?: string | number | null;
12
12
  config?: PhiCmsFormWidgetConfig;
@@ -8,6 +8,7 @@ import { createPhiRuntimeFormControllerAddress } from "./runtime-form-controller
8
8
  import { PhiRuntimeModuleRenderClientHost } from "../runtime/runtime-module-render-client-manifest";
9
9
  import { PhiRuntimeRenderClientType } from "../../constants/runtime-render-client-types";
10
10
  import { readPhiFormFieldProviderModules } from "./form-field-provider-modules";
11
+ import { resolvePhiFormMediaLimits } from "./form-media-limits";
11
12
  import { resolvePhiFormText } from "./form-descriptor-contract";
12
13
  import { PHI_FORM_DEFAULT_SUBMIT_LABEL } from "../../types/form-descriptor";
13
14
  import { readPhiRuntimeConditionValue, } from "../../types/runtime-condition";
@@ -49,6 +50,8 @@ export async function PhiFormWidget({ runtime, registry, formId, formInstanceKey
49
50
  activeModuleIds: registry.activeModuleIds,
50
51
  uiProviderModuleIds: registry.uiProviderModuleIds,
51
52
  });
53
+ // What the Add-on behind the Form's Module takes as Media, for its Media fields (FORMS.md).
54
+ const mediaLimits = resolvePhiFormMediaLimits(registry, ownerModuleId);
52
55
  /*
53
56
  * Both reads happen here, on the server, and both are the form's own: what it is called, and what it
54
57
  * already knows. Asking for either after hydration is a blank card for as long as the page takes to
@@ -111,5 +114,6 @@ export async function PhiFormWidget({ runtime, registry, formId, formInstanceKey
111
114
  formControllerAddress: renderOptions.formControllerAddress,
112
115
  widgetConfig: config,
113
116
  ...(unavailableFieldKeys.length > 0 ? { unavailableFieldKeys } : {}),
117
+ ...(mediaLimits ? { mediaLimits } : {}),
114
118
  } }));
115
119
  }