@phis/ui 0.7.5 → 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.
- package/components/controls/phi-form-control.d.ts +3 -1
- package/components/controls/phi-form-control.js +4 -4
- package/components/forms/auth-admin-settings-labels.d.ts +1 -1
- package/components/forms/auth-admin-settings-labels.js +2 -2
- package/components/forms/form-descriptor-contract.d.ts +1 -1
- package/components/forms/form-descriptor-contract.js +1 -1
- package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
- package/components/forms/form-descriptor-runtime-client.js +33 -11
- package/components/forms/form-media-limits.d.ts +12 -0
- package/components/forms/form-media-limits.js +14 -0
- package/components/forms/form-provider-registry.d.ts +8 -0
- package/components/forms/form-record-title.d.ts +14 -0
- package/components/forms/form-record-title.js +38 -0
- package/components/forms/form-widget-config.d.ts +3 -0
- package/components/forms/form-widget-config.js +2 -0
- package/components/forms/phi-form-widget.d.ts +1 -1
- package/components/forms/phi-form-widget.js +4 -0
- package/components/overlays/phi-overlay-container-client.js +8 -8
- package/components/overlays/phi-overlay-title.d.ts +7 -0
- package/components/overlays/phi-overlay-title.js +21 -0
- package/components/tables/client/phi-table-binding.d.ts +3 -1
- package/components/tables/client/phi-table-binding.js +90 -49
- package/components/tables/client/phi-table-filter-options.d.ts +27 -0
- package/components/tables/client/phi-table-filter-options.js +35 -0
- package/components/widgets/accessible-areas.d.ts +1 -1
- package/components/widgets/accessible-areas.js +1 -1
- package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
- package/components/widgets/client/shared/phi-rendered-value.js +49 -1
- package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
- package/components/widgets/client/shared/phi-table-provider.js +22 -0
- package/components/widgets/label-sets/admin-users.d.ts +15 -0
- package/components/widgets/label-sets/admin-users.js +31 -0
- package/constants/core-data-provider-keys.d.ts +7 -0
- package/constants/core-data-provider-keys.js +7 -0
- package/constants/phi-base-role-metadata.d.ts +2 -2
- package/constants/phi-base-role-metadata.js +1 -1
- package/constants/runtime-module-ownership.js +3 -0
- package/forms.d.ts +1 -1
- package/forms.js +1 -1
- package/gateway/capability-media-limits.d.ts +10 -0
- package/gateway/capability-media-limits.js +40 -0
- package/gateway/server-capabilities.js +4 -0
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +60 -0
- package/helpers/record-title.d.ts +7 -0
- package/helpers/record-title.js +25 -0
- package/helpers/record-widget.d.ts +15 -0
- package/helpers/record-widget.js +57 -0
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
- package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
- package/plugins/runtime-modules/accounting/data-providers.js +127 -0
- package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
- package/plugins/runtime-modules/accounting/definition.js +5 -3
- package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
- package/plugins/runtime-modules/accounting/ids.js +27 -0
- package/plugins/runtime-modules/accounting/module.d.ts +52 -0
- package/plugins/runtime-modules/accounting/presets.js +23 -4
- package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
- package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
- package/plugins/runtime-modules/area-definitions.js +2 -2
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
- package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
- package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
- package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
- package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
- package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
- package/plugins/runtime-modules/core/cards.js +2 -2
- package/plugins/runtime-modules/core/client-data-providers.js +5 -0
- package/plugins/runtime-modules/core/data-providers.js +14 -0
- package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
- package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
- package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
- package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
- package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
- package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
- package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
- package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
- package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
- package/plugins/runtime-modules/groups/data-providers.js +1 -1
- package/plugins/runtime-modules/groups/definition.js +1 -1
- package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
- package/plugins/runtime-modules/groups/page-visibility.js +1 -1
- package/plugins/runtime-modules/groups/presets.js +1 -1
- package/plugins/runtime-modules/groups/services/options.js +1 -1
- package/plugins/runtime-modules/groups/services/table.js +1 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
- package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
- package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
- package/plugins/runtime-modules/user-management/controller/client.js +1 -1
- package/plugins/runtime-modules/user-management/data-providers.js +1 -0
- package/plugins/runtime-modules/user-management/forms.js +22 -0
- package/plugins/runtime-modules/user-management/presets.js +2 -2
- package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
- package/plugins/runtime-modules/user-management/services/options.js +14 -6
- package/plugins/runtime-modules/user-management/services/table.js +12 -3
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
- package/types/access.d.ts +1 -1
- package/types/access.js +7 -7
- package/types/core-widget-placements.d.ts +7 -0
- package/types/form-descriptor.d.ts +1 -1
- package/types/record-widget.d.ts +35 -0
- package/types/server-capabilities.d.ts +1 -1
- package/types/table-widget.d.ts +20 -0
- 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),
|
|
@@ -132,12 +132,12 @@ function PhiResolvedFormFieldControl({ id, provider, field, label, description,
|
|
|
132
132
|
const controlLabel = field.controlLabel
|
|
133
133
|
? resolvePhiFormText(field.controlLabel, labels, formConfig)
|
|
134
134
|
: undefined;
|
|
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 }), 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] }));
|
|
136
136
|
}
|
|
137
137
|
// One empty object for every form without controllers, so the fields drawn are not recomputed on
|
|
138
138
|
// every render for a new `{}`.
|
|
139
139
|
const PHI_FORM_NO_CONTROLLER_STATES = Object.freeze({});
|
|
140
|
-
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) {
|
|
141
141
|
const contributedRegistry = usePhiFormProviderRegistry();
|
|
142
142
|
const activeRegistry = useMemo(() => registry ?? (contributedRegistry
|
|
143
143
|
? extendPhiFormProviderRegistry(PHI_SHARED_FORM_PROVIDER_REGISTRY, contributedRegistry)
|
|
@@ -518,6 +518,6 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
|
|
|
518
518
|
...resolveHoneypotStyle(provider.presentation),
|
|
519
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
|
|
520
520
|
? resolvePhiFormText(field.placeholder, labels, formConfig)
|
|
521
|
-
: 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));
|
|
522
522
|
}) }) }));
|
|
523
523
|
});
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
?
|
|
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
|
}
|
|
@@ -18,6 +18,7 @@ import { PhiDrawerControl } from "../controls/phi-drawer-control";
|
|
|
18
18
|
import { PhiAlertControl } from "../controls/phi-alert-control";
|
|
19
19
|
import { usePhiOverlayZonesLoaderIfAny } from "./phi-overlay-zones-loader";
|
|
20
20
|
import { PhiDialogBodyProvider } from "./phi-dialog-body-context";
|
|
21
|
+
import { usePhiOverlayTitle } from "./phi-overlay-title";
|
|
21
22
|
import { usePhiPathname } from "../runtime/use-phi-pathname";
|
|
22
23
|
function renderOverlayZonesFailure(failure) {
|
|
23
24
|
return (_jsx(PhiAlertControl, { level: "error", title: "This content could not be shown.", description: failure }));
|
|
@@ -59,7 +60,7 @@ export function PhiOverlayContainerClient({ overlayId, overlayType, config: rawC
|
|
|
59
60
|
const [hasOpened, setHasOpened] = useState(false);
|
|
60
61
|
const [runtimeControlSizeOverride, setRuntimeControlSizeOverride] = useState(null);
|
|
61
62
|
const [runtimeSizeOverride, setRuntimeSizeOverride] = useState(null);
|
|
62
|
-
const
|
|
63
|
+
const { title: runtimeTitle, tell: tellTitle, forget: forgetTitle } = usePhiOverlayTitle(config);
|
|
63
64
|
/*
|
|
64
65
|
* Whether work the Overlay holds is under way -- a Form in the Body saving. While it is, a reader's
|
|
65
66
|
* dismissal (close button, mask, Escape) is not taken: closing would abandon the save's answer. A
|
|
@@ -73,9 +74,6 @@ export function PhiOverlayContainerClient({ overlayId, overlayType, config: rawC
|
|
|
73
74
|
const runtimeSize = runtimeSizeOverride?.config === config
|
|
74
75
|
? runtimeSizeOverride.value
|
|
75
76
|
: null;
|
|
76
|
-
const runtimeTitle = runtimeTitleOverride?.config === config
|
|
77
|
-
? runtimeTitleOverride.value
|
|
78
|
-
: config.title;
|
|
79
77
|
const emittedOpenRef = useRef(false);
|
|
80
78
|
const openedAtPathname = useRef(null);
|
|
81
79
|
const pathname = usePhiPathname();
|
|
@@ -116,8 +114,11 @@ export function PhiOverlayContainerClient({ overlayId, overlayType, config: rawC
|
|
|
116
114
|
// A closed Overlay holds no work; a busy state left behind would refuse the next dismissal.
|
|
117
115
|
if (!nextOpen)
|
|
118
116
|
setBusy(false);
|
|
117
|
+
// Nor a title told for the opening that ends: the next one starts from its own (`usePhiOverlayTitle`).
|
|
118
|
+
if (!nextOpen)
|
|
119
|
+
forgetTitle();
|
|
119
120
|
setOpen(nextOpen);
|
|
120
|
-
}, []);
|
|
121
|
+
}, [forgetTitle]);
|
|
121
122
|
/*
|
|
122
123
|
* The zones of a deferred Overlay, asked for when it opens and kept afterwards.
|
|
123
124
|
*
|
|
@@ -217,8 +218,7 @@ export function PhiOverlayContainerClient({ overlayId, overlayType, config: rawC
|
|
|
217
218
|
updateOpen(typeof signal.value === "boolean" ? signal.value : !open);
|
|
218
219
|
}
|
|
219
220
|
else if (route.capabilityId === "title" && signal.valueType === "string") {
|
|
220
|
-
|
|
221
|
-
setRuntimeTitleOverride({ config, value: nextTitle || null });
|
|
221
|
+
tellTitle(signal.value);
|
|
222
222
|
}
|
|
223
223
|
else if (route.capabilityId === "controlSize" && overlayType === "modal") {
|
|
224
224
|
const nextControlSize = readPhiControlSize(signal.value);
|
|
@@ -237,7 +237,7 @@ export function PhiOverlayContainerClient({ overlayId, overlayType, config: rawC
|
|
|
237
237
|
if (nextSize)
|
|
238
238
|
setRuntimeSizeOverride({ config, value: nextSize });
|
|
239
239
|
}
|
|
240
|
-
}, [config, listenRoutes, open, overlayType, receiver, updateOpen]), useMemo(() => ({
|
|
240
|
+
}, [config, listenRoutes, open, overlayType, receiver, tellTitle, updateOpen]), useMemo(() => ({
|
|
241
241
|
scopes: [signalScope],
|
|
242
242
|
receiver,
|
|
243
243
|
}), [receiver, signalScope]), receiver);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
/*
|
|
3
|
+
* The title an Overlay shows: the one its config states, or one it was told on its `title` input.
|
|
4
|
+
*
|
|
5
|
+
* A told title stands for the opening it was told for: closing forgets it, so the next opening -- for
|
|
6
|
+
* another row, with a Form that has not read that row yet -- starts from the Overlay's own title rather
|
|
7
|
+
* than from the last row's name. A title told while the Overlay is closed is for the opening that comes
|
|
8
|
+
* next, which is how a Controller names the mode it is about to open in. An empty title is no title:
|
|
9
|
+
* the Overlay shows its own again, which is what a Form answers for a record that has no value to name
|
|
10
|
+
* it by. A changed config, or a remount, starts from the config's title as well.
|
|
11
|
+
*/
|
|
12
|
+
export function usePhiOverlayTitle(config) {
|
|
13
|
+
const [told, setTold] = useState(null);
|
|
14
|
+
const title = told?.config === config ? told.value : config.title;
|
|
15
|
+
const tell = useCallback((value) => {
|
|
16
|
+
const next = typeof value === "string" ? value.trim() : "";
|
|
17
|
+
setTold(next ? { config, value: next } : null);
|
|
18
|
+
}, [config]);
|
|
19
|
+
const forget = useCallback(() => setTold(null), []);
|
|
20
|
+
return { title, tell, forget };
|
|
21
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { PhiTableProviderActionMutationRequest, PhiTableProviderDropMutationRequest, PhiTableProviderFieldMutationRequest, PhiTableProviderMutationRequest, PhiTableProviderMutationResult, PhiTableProviderQueryResult, PhiTableProviderResourceDescriptor, PhiTableProviderRowMoveMutationRequest, PhiTableProviderRowPatchMutationRequest, PhiTableQuery, PhiTableQueryValue, PhiTableRowIdentity, PhiTableSummaryValue } from "../../../types/table-widget";
|
|
2
2
|
import type { PhiProviderResourceSource } from "../../../types/runtime-data-provider";
|
|
3
3
|
import { PhiTableProviderError } from "../../../types/table-widget";
|
|
4
|
+
import { type PhiTableProviderMutationInput } from "../../widgets/client/shared/phi-table-provider";
|
|
4
5
|
type TableRow = Record<string, unknown>;
|
|
5
|
-
type MutationInput<TRequest extends PhiTableProviderMutationRequest> =
|
|
6
|
+
type MutationInput<TRequest extends PhiTableProviderMutationRequest> = PhiTableProviderMutationInput<TRequest>;
|
|
6
7
|
export type PhiTableBindingInput = {
|
|
7
8
|
source: PhiProviderResourceSource | null;
|
|
8
9
|
initialQuery?: PhiTableQuery;
|
|
@@ -32,6 +33,7 @@ export declare function usePhiTableBinding({ source, initialQuery, externalQuery
|
|
|
32
33
|
query: PhiTableQuery;
|
|
33
34
|
resolvedQuery: PhiTableQuery;
|
|
34
35
|
setQuery: import("react").Dispatch<import("react").SetStateAction<PhiTableQuery>>;
|
|
36
|
+
changePage: (page: number, pageSize: number) => void;
|
|
35
37
|
selectedRowIdentities: readonly PhiTableRowIdentity[];
|
|
36
38
|
setSelectedRowIdentities: import("react").Dispatch<import("react").SetStateAction<readonly PhiTableRowIdentity[]>>;
|
|
37
39
|
expandedRowIdentities: readonly PhiTableRowIdentity[];
|