@phis/ui 0.6.4 → 0.6.6
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/cms/phi-cms-layout-renderer.js +11 -2
- package/components/controls/phi-image-control.js +9 -1
- package/components/controls/phi-multi-select-control.js +4 -2
- package/components/controls/phi-options-provider.d.ts +1 -0
- package/components/controls/phi-options-provider.js +1 -0
- package/components/controls/phi-select-control.d.ts +21 -0
- package/components/controls/phi-select-control.js +2 -2
- package/components/controls/phi-status-dot-control.d.ts +15 -0
- package/components/controls/phi-status-dot-control.js +25 -0
- package/components/controls/phi-table-control.js +8 -1
- package/components/controls/phi-tree-control.js +5 -4
- package/components/controls/phi-tree-select-control.js +1 -0
- package/components/forms/auth-admin-settings-labels.d.ts +4 -0
- package/components/forms/auth-admin-settings-labels.js +11 -3
- package/components/forms/form-provider-contract.d.ts +1 -1
- package/components/forms/form-provider-contract.js +1 -1
- package/components/layouts/clients/phi-split-card-half.d.ts +4 -1
- package/components/layouts/clients/phi-split-card-half.js +2 -2
- package/components/layouts/clients/phi-split-card-layout-client.d.ts +6 -3
- package/components/layouts/clients/phi-split-card-layout-client.js +5 -3
- package/components/layouts/clients/phi-three-column-layout-client.d.ts +20 -1
- package/components/layouts/clients/phi-three-column-layout-client.js +31 -15
- package/components/layouts/layout-definitions.d.ts +96 -0
- package/components/layouts/layout-definitions.js +40 -2
- package/components/layouts/plugins/split-card-layout-plugin.js +1 -1
- package/components/layouts/plugins/three-column-layout-plugin.js +1 -1
- package/components/layouts/split-card-geometry.d.ts +9 -4
- package/components/layouts/split-card-geometry.js +29 -13
- package/components/media/media-folder-options.d.ts +10 -0
- package/components/media/media-folder-options.js +14 -0
- package/components/navigation/phi-link.d.ts +7 -1
- package/components/navigation/phi-link.js +6 -2
- package/components/root/phi-root-theme-resolver.js +2 -0
- package/components/shell/phi-antd-icon.d.ts +1 -0
- package/components/shell/phi-antd-icon.js +3 -0
- package/components/widgets/client/shared/phi-rendered-value.js +1 -1
- package/components/widgets/inspector-field-row.js +4 -1
- package/components/widgets/label-sets/account.js +6 -2
- package/components/widgets/label-sets/admin-users.d.ts +3 -0
- package/components/widgets/label-sets/admin-users.js +8 -2
- package/components/widgets/label-sets/effects.js +5 -1
- package/components/widgets/label-sets/gallery.js +2 -2
- package/components/widgets/label-sets/inspector.js +4 -0
- package/components/widgets/label-sets/observability-logs.js +2 -2
- package/components/widgets/label-sets/profile.js +2 -1
- package/components/widgets/label-types/gallery.d.ts +2 -3
- package/components/widgets/label-types/gallery.js +1 -4
- package/components/widgets/label-types/inspector.d.ts +4 -0
- package/components/widgets/label-types/inspector.js +2 -0
- package/components/widgets/shared/markdown-body-client.js +1 -1
- package/components/widgets/shared/markdown-image-vocabulary.js +1 -1
- package/constants/cms-layout-proportions.d.ts +6 -0
- package/constants/cms-layout-proportions.js +17 -0
- package/constants/runtime-module-ownership.js +1 -0
- package/helpers/page-reference-tree.js +8 -0
- package/helpers/table-action-links.d.ts +11 -0
- package/helpers/table-action-links.js +14 -0
- package/helpers/table-action-row-link.d.ts +8 -0
- package/helpers/table-action-row-link.js +14 -0
- package/package.json +2 -2
- package/plugins/factories/widget-renderers.d.ts +7 -1
- package/plugins/factories/widget-renderers.js +12 -2
- package/plugins/runtime-modules/asset/authoring-widgets.js +2 -2
- package/plugins/runtime-modules/asset/data-providers.js +1 -1
- package/plugins/runtime-modules/asset/services/options.js +7 -11
- package/plugins/runtime-modules/asset/widgets/area-upload/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets/image-inspector/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets/media-picker/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets.js +4 -4
- package/plugins/runtime-modules/auth/admin-settings-forms.js +47 -1
- package/plugins/runtime-modules/auth/authoring-widgets.js +4 -8
- package/plugins/runtime-modules/auth/data-providers.js +2 -0
- package/plugins/runtime-modules/auth/widgets/auth-workflow/plugin.js +0 -6
- package/plugins/runtime-modules/auth/widgets/logout/plugin.js +0 -2
- package/plugins/runtime-modules/auth/widgets/security/plugin.js +0 -2
- package/plugins/runtime-modules/auth/widgets.js +5 -3
- package/plugins/runtime-modules/avatar/authoring-widgets.js +2 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar/plugin.js +0 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/plugin.js +0 -2
- package/plugins/runtime-modules/avatar/widgets.js +2 -2
- package/plugins/runtime-modules/builder/authoring-widgets.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-choice-cascader.d.ts +28 -0
- package/plugins/runtime-modules/builder/clients/inspector-choice-cascader.js +98 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +27 -3
- package/plugins/runtime-modules/builder/clients/inspector-record-field-options.d.ts +17 -0
- package/plugins/runtime-modules/builder/clients/inspector-record-field-options.js +21 -0
- package/plugins/runtime-modules/builder/clients/inspector-translate-switch.d.ts +24 -0
- package/plugins/runtime-modules/builder/clients/inspector-translate-switch.js +29 -0
- package/plugins/runtime-modules/builder/clients/layout-inspector.d.ts +1 -1
- package/plugins/runtime-modules/builder/clients/layout-inspector.js +4 -2
- package/plugins/runtime-modules/builder/clients/widget-inspector.d.ts +1 -1
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +6 -6
- package/plugins/runtime-modules/builder/plugin-meta-labels.js +17 -0
- package/plugins/runtime-modules/builder/render-root-node-scaffold.js +12 -2
- package/plugins/runtime-modules/builder/widgets/structure-region/plugin.js +0 -2
- package/plugins/runtime-modules/builder/widgets.js +3 -3
- package/plugins/runtime-modules/contracts.js +8 -4
- package/plugins/runtime-modules/core/authoring-widgets.js +2 -2
- package/plugins/runtime-modules/core/data-providers.d.ts +7 -3
- package/plugins/runtime-modules/core/data-providers.js +11 -1
- package/plugins/runtime-modules/core/definition.d.ts +8 -4
- package/plugins/runtime-modules/core/form-providers.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/breadcrumb/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/cascader/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/draft-status/client.d.ts +2 -1
- package/plugins/runtime-modules/core/widgets/draft-status/client.js +4 -3
- package/plugins/runtime-modules/core/widgets/gallery/authoring.js +6 -8
- package/plugins/runtime-modules/core/widgets/gallery/client.js +4 -0
- package/plugins/runtime-modules/core/widgets/gallery/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -4
- package/plugins/runtime-modules/core/widgets/image/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.js +24 -22
- package/plugins/runtime-modules/core/widgets/record/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/client.d.ts +9 -5
- package/plugins/runtime-modules/core/widgets/simple-text/client.js +5 -7
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +63 -4
- package/plugins/runtime-modules/core/widgets/simple-text/config.js +45 -11
- package/plugins/runtime-modules/core/widgets/simple-text/editor.js +2 -2
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.d.ts +13 -0
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +23 -4
- package/plugins/runtime-modules/core/widgets/simple-text/server.d.ts +4 -2
- package/plugins/runtime-modules/core/widgets/simple-text/server.js +7 -6
- package/plugins/runtime-modules/core/widgets/table/client.js +4 -4
- package/plugins/runtime-modules/core/widgets/table/config.js +12 -4
- package/plugins/runtime-modules/core/widgets/table/plugin.js +21 -1
- package/plugins/runtime-modules/core/widgets/thread-conversation/plugin.js +0 -2
- package/plugins/runtime-modules/core/widgets/tree/config.js +2 -1
- package/plugins/runtime-modules/core/widgets/tree/plugin.js +16 -1
- package/plugins/runtime-modules/core/widgets.js +1 -1
- package/plugins/runtime-modules/observability/data-providers.js +1 -1
- package/plugins/runtime-modules/theme/authoring-widgets.js +5 -5
- package/plugins/runtime-modules/theme/brand-theme-model.d.ts +4 -1
- package/plugins/runtime-modules/theme/brand-theme-model.js +6 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +17 -0
- package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +0 -5
- package/plugins/runtime-modules/theme/widgets.js +4 -4
- package/plugins/runtime-modules/threads/labels.js +6 -2
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +28 -7
- package/plugins/runtime-modules/user-management/addon-roles.js +42 -17
- package/plugins/runtime-modules/user-management/client-data-providers.js +6 -0
- package/plugins/runtime-modules/user-management/data-providers.js +11 -2
- package/plugins/runtime-modules/user-management/forms.js +40 -1
- package/plugins/runtime-modules/user-management/ids.d.ts +1 -0
- package/plugins/runtime-modules/user-management/ids.js +1 -0
- package/plugins/runtime-modules/user-management/services/options.d.ts +14 -3
- package/plugins/runtime-modules/user-management/services/options.js +52 -16
- package/plugins/runtime-modules/user-management/services/table.js +8 -24
- package/plugins/runtime-modules/user-management/services/users-query.d.ts +9 -0
- package/plugins/runtime-modules/user-management/services/users-query.js +29 -0
- package/plugins/runtime-modules/video/widgets/embed/plugin.js +0 -2
- package/plugins/runtime-modules/video/widgets.js +1 -1
- package/styles/controls.css +20 -0
- package/styles/layout.css +4 -4
- package/theme/phi-link-mark.d.ts +26 -0
- package/theme/phi-link-mark.js +26 -0
- package/theme/phi-theme-tokens.d.ts +3 -2
- package/theme/phi-theme-tokens.js +3 -1
- package/types/cms-config.d.ts +12 -4
- package/types/cms-config.js +3 -0
- package/types/cms-plugins.d.ts +26 -4
- package/types/core-widget-placements.d.ts +4 -4
- package/types/site-config.d.ts +3 -0
- package/types/table-widget.d.ts +17 -1
- package/types/tree.d.ts +2 -0
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/authoring.d.ts +0 -2
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/authoring.js +0 -6
- package/plugins/runtime-modules/asset/widgets/image-inspector/authoring.d.ts +0 -2
- package/plugins/runtime-modules/asset/widgets/image-inspector/authoring.js +0 -6
- package/plugins/runtime-modules/auth/widgets/auth-methods/authoring.d.ts +0 -7
- package/plugins/runtime-modules/auth/widgets/auth-methods/authoring.js +0 -12
- package/plugins/runtime-modules/auth/widgets/auth-workflow/authoring.d.ts +0 -7
- package/plugins/runtime-modules/auth/widgets/auth-workflow/authoring.js +0 -12
- package/plugins/runtime-modules/auth/widgets/logout/authoring.d.ts +0 -3
- package/plugins/runtime-modules/auth/widgets/logout/authoring.js +0 -8
- package/plugins/runtime-modules/auth/widgets/security/authoring.d.ts +0 -3
- package/plugins/runtime-modules/auth/widgets/security/authoring.js +0 -8
- package/plugins/runtime-modules/avatar/widgets/account-avatar/authoring.d.ts +0 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar/authoring.js +0 -6
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/authoring.d.ts +0 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/authoring.js +0 -6
- package/plugins/runtime-modules/builder/widgets/structure-region/internal-builder.d.ts +0 -22
- package/plugins/runtime-modules/builder/widgets/structure-region/internal-builder.js +0 -8
- package/plugins/runtime-modules/core/widgets/form-preview/authoring.d.ts +0 -10
- package/plugins/runtime-modules/core/widgets/form-preview/authoring.js +0 -15
- package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.d.ts +0 -3
- package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.js +0 -9
- package/plugins/runtime-modules/theme/widgets/brand-controls/authoring.d.ts +0 -76
- package/plugins/runtime-modules/theme/widgets/brand-controls/authoring.js +0 -30
|
@@ -6,14 +6,14 @@ export const PHI_AVATAR_RUNTIME_MODULE_WIDGETS = [
|
|
|
6
6
|
definePhiFirstPartyWidget({
|
|
7
7
|
definition: PHI_ACCOUNT_AVATAR_WIDGET_DEFINITION,
|
|
8
8
|
ownerModuleId: PHI_AVATAR_RUNTIME_MODULE_ID,
|
|
9
|
-
renderPolicies: { runtime: "custom", preview: "
|
|
9
|
+
renderPolicies: { runtime: "custom", preview: "visualPlaceholder", authoring: "custom" },
|
|
10
10
|
loadRuntime: () => import("./widgets/account-avatar/plugin").then((module) => module.PHI_ACCOUNT_AVATAR_WIDGET_PLUGIN),
|
|
11
11
|
loadPreview: () => import("./widgets/account-avatar/plugin").then((module) => module.PHI_ACCOUNT_AVATAR_WIDGET_PLUGIN),
|
|
12
12
|
}),
|
|
13
13
|
definePhiFirstPartyWidget({
|
|
14
14
|
definition: PHI_ACCOUNT_AVATAR_PICKER_WIDGET_DEFINITION,
|
|
15
15
|
ownerModuleId: PHI_AVATAR_RUNTIME_MODULE_ID,
|
|
16
|
-
renderPolicies: { runtime: "custom", preview: "
|
|
16
|
+
renderPolicies: { runtime: "custom", preview: "visualPlaceholder", authoring: "custom" },
|
|
17
17
|
loadRuntime: () => import("./widgets/account-avatar-picker/plugin").then((module) => module.PHI_ACCOUNT_AVATAR_PICKER_WIDGET_PLUGIN),
|
|
18
18
|
loadPreview: () => import("./widgets/account-avatar-picker/plugin").then((module) => module.PHI_ACCOUNT_AVATAR_PICKER_WIDGET_PLUGIN),
|
|
19
19
|
}),
|
|
@@ -14,6 +14,6 @@ export default createPhiAuthoringWidgetModule([
|
|
|
14
14
|
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_SHELLS_WORKSPACE_WIDGET_DEFINITION, () => import("./widgets/shells-workspace/authoring").then((module) => module.PHI_BUILDER_SHELLS_WORKSPACE_WIDGET_BUILDER_PLUGIN)),
|
|
15
15
|
definePhiAuthoringWidgetModuleLoader(PHI_DEVELOPER_BUILDER_PAGES_HEADER_WIDGET_DEFINITION, () => import("./widgets/developer-builder-pages-header/authoring").then((module) => module.PHI_DEVELOPER_BUILDER_PAGES_HEADER_WIDGET_BUILDER_PLUGIN)),
|
|
16
16
|
definePhiAuthoringWidgetModuleLoader(PHI_HELLO_WORLD_WIDGET_DEFINITION, () => import("./widgets/hello-world/authoring").then((module) => module.PHI_HELLO_WORLD_WIDGET_BUILDER_PLUGIN)),
|
|
17
|
-
definePhiAuthoringWidgetModuleLoader(PHI_STRUCTURE_REGION_WIDGET_DEFINITION, () =>
|
|
17
|
+
definePhiAuthoringWidgetModuleLoader(PHI_STRUCTURE_REGION_WIDGET_DEFINITION, () => Promise.resolve(PHI_STRUCTURE_REGION_WIDGET_DEFINITION)),
|
|
18
18
|
definePhiAuthoringWidgetModuleLoader(PHI_TEST_BLOCK_WIDGET_DEFINITION, () => import("./widgets/test-block/authoring").then((module) => module.PHI_TEST_BLOCK_WIDGET_BUILDER_PLUGIN)),
|
|
19
19
|
]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type PhiCascaderOption } from "../../../../components/controls/phi-cascader-control";
|
|
2
|
+
import type { PhiControlOption } from "../../../../components/controls/phi-control-options";
|
|
3
|
+
export declare const PHI_INSPECTOR_CHOICE_CASCADER_SEPARATOR = "\u241F";
|
|
4
|
+
export declare const PHI_INSPECTOR_CHOICE_CASCADER_ROOT = "\u241E";
|
|
5
|
+
export type PhiInspectorChoiceCascader = {
|
|
6
|
+
/** The options as the Cascader takes them: each one's path as its value, parents before children. */
|
|
7
|
+
options: PhiCascaderOption[];
|
|
8
|
+
/** The path each option's value stands at. */
|
|
9
|
+
pathByValue: ReadonlyMap<string, string>;
|
|
10
|
+
/** The option behind each path, for writing back what was chosen. */
|
|
11
|
+
optionByPath: ReadonlyMap<string, PhiControlOption>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The options as a tree, by `parentValue`. An option whose `parentValue` names no option in the list,
|
|
15
|
+
* or whose chain of parents leads back to itself, stands at the top level; the first of two options
|
|
16
|
+
* with the same value is the one offered.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildPhiInspectorChoiceCascader(options: readonly PhiControlOption[]): PhiInspectorChoiceCascader;
|
|
19
|
+
/**
|
|
20
|
+
* What the Cascader is handed as its value: the stored value's path, or the stored value itself where no
|
|
21
|
+
* option has it -- shown as it is, the way a Select shows a value it has no option for.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readPhiInspectorChoiceCascaderPath(cascader: PhiInspectorChoiceCascader, value: string | null | undefined): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The value a chosen path writes back: the chosen option's own value. A path that names no option -- a
|
|
26
|
+
* search text, the empty root -- or a disabled option writes nothing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readPhiInspectorChoiceCascaderValue(cascader: PhiInspectorChoiceCascader, path: string): string | null;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { normalizePhiCascaderValue, } from "../../../../components/controls/phi-cascader-control";
|
|
2
|
+
/*
|
|
3
|
+
* A choice field shown as a cascader (`presentation: "cascader"`): the options stand in a hierarchy by
|
|
4
|
+
* their `parentValue`, and `PhiCascaderControl` builds its levels from path values. The paths are this
|
|
5
|
+
* file's own -- the values from the top down, joined -- and never leave it: the field stores the chosen
|
|
6
|
+
* option's `value`, as a Select would.
|
|
7
|
+
*
|
|
8
|
+
* The separator and the root are characters no option value carries, so a value that is itself a path
|
|
9
|
+
* (`/shop/cart`) stays one segment.
|
|
10
|
+
*/
|
|
11
|
+
export const PHI_INSPECTOR_CHOICE_CASCADER_SEPARATOR = "␟";
|
|
12
|
+
export const PHI_INSPECTOR_CHOICE_CASCADER_ROOT = "␞";
|
|
13
|
+
function normalizePath(segments) {
|
|
14
|
+
return normalizePhiCascaderValue(segments.join(PHI_INSPECTOR_CHOICE_CASCADER_SEPARATOR), {
|
|
15
|
+
separator: PHI_INSPECTOR_CHOICE_CASCADER_SEPARATOR,
|
|
16
|
+
rootValue: PHI_INSPECTOR_CHOICE_CASCADER_ROOT,
|
|
17
|
+
normalize: "raw",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The options as a tree, by `parentValue`. An option whose `parentValue` names no option in the list,
|
|
22
|
+
* or whose chain of parents leads back to itself, stands at the top level; the first of two options
|
|
23
|
+
* with the same value is the one offered.
|
|
24
|
+
*/
|
|
25
|
+
export function buildPhiInspectorChoiceCascader(options) {
|
|
26
|
+
const byValue = new Map();
|
|
27
|
+
for (const option of options) {
|
|
28
|
+
const value = String(option.value);
|
|
29
|
+
if (!byValue.has(value))
|
|
30
|
+
byValue.set(value, option);
|
|
31
|
+
}
|
|
32
|
+
const rawParentOf = (value) => {
|
|
33
|
+
const parentValue = byValue.get(value)?.parentValue;
|
|
34
|
+
if (parentValue == null)
|
|
35
|
+
return null;
|
|
36
|
+
const parent = String(parentValue);
|
|
37
|
+
return byValue.has(parent) ? parent : null;
|
|
38
|
+
};
|
|
39
|
+
// The parent an option keeps: none where following the parents from there comes back to the option.
|
|
40
|
+
const parentOf = new Map();
|
|
41
|
+
for (const value of byValue.keys()) {
|
|
42
|
+
const parent = rawParentOf(value);
|
|
43
|
+
let current = parent;
|
|
44
|
+
const seen = new Set();
|
|
45
|
+
while (current != null && current !== value && !seen.has(current)) {
|
|
46
|
+
seen.add(current);
|
|
47
|
+
current = rawParentOf(current);
|
|
48
|
+
}
|
|
49
|
+
parentOf.set(value, current === value ? null : parent);
|
|
50
|
+
}
|
|
51
|
+
const segmentsOf = (value) => {
|
|
52
|
+
const segments = [];
|
|
53
|
+
for (let current = value; current != null; current = parentOf.get(current) ?? null) {
|
|
54
|
+
segments.unshift(current);
|
|
55
|
+
}
|
|
56
|
+
return segments;
|
|
57
|
+
};
|
|
58
|
+
const entries = [...byValue.entries()].map(([value, option]) => {
|
|
59
|
+
const segments = segmentsOf(value);
|
|
60
|
+
return { value, option, depth: segments.length, path: normalizePath(segments) };
|
|
61
|
+
});
|
|
62
|
+
// The Cascader names a level after the option inserted at it first, so a parent goes in before its children.
|
|
63
|
+
const ordered = entries
|
|
64
|
+
.map((entry, index) => ({ entry, index }))
|
|
65
|
+
.sort((left, right) => left.entry.depth - right.entry.depth || left.index - right.index)
|
|
66
|
+
.map(({ entry }) => entry);
|
|
67
|
+
const pathByValue = new Map();
|
|
68
|
+
const optionByPath = new Map();
|
|
69
|
+
const cascaderOptions = [];
|
|
70
|
+
for (const { value, option, path } of ordered) {
|
|
71
|
+
pathByValue.set(value, path);
|
|
72
|
+
optionByPath.set(path, option);
|
|
73
|
+
cascaderOptions.push({
|
|
74
|
+
value: path,
|
|
75
|
+
label: option.label,
|
|
76
|
+
...(option.description ? { description: option.description } : {}),
|
|
77
|
+
...(option.icon ? { icon: option.icon } : {}),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return { options: cascaderOptions, pathByValue, optionByPath };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* What the Cascader is handed as its value: the stored value's path, or the stored value itself where no
|
|
84
|
+
* option has it -- shown as it is, the way a Select shows a value it has no option for.
|
|
85
|
+
*/
|
|
86
|
+
export function readPhiInspectorChoiceCascaderPath(cascader, value) {
|
|
87
|
+
if (value == null || value === "")
|
|
88
|
+
return undefined;
|
|
89
|
+
return cascader.pathByValue.get(value) ?? value;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The value a chosen path writes back: the chosen option's own value. A path that names no option -- a
|
|
93
|
+
* search text, the empty root -- or a disabled option writes nothing.
|
|
94
|
+
*/
|
|
95
|
+
export function readPhiInspectorChoiceCascaderValue(cascader, path) {
|
|
96
|
+
const option = cascader.optionByPath.get(path);
|
|
97
|
+
return option && option.disabled !== true ? String(option.value) : null;
|
|
98
|
+
}
|
|
@@ -6,6 +6,7 @@ import { readPhiDotPath } from "../../../../helpers/dot-path";
|
|
|
6
6
|
import { PhiCheckboxGroupControl } from "../../../../components/controls/phi-checkbox-group-control";
|
|
7
7
|
import { PhiDividerControl } from "../../../../components/controls/phi-divider-control";
|
|
8
8
|
import { usePhiConfig } from "../../../../components/root/phi-config-provider";
|
|
9
|
+
import { PHI_INSPECTOR_RECORD_FIELD_NONE, buildPhiInspectorRecordFieldOptions, readPhiInspectorRecordFieldChoice, } from "./inspector-record-field-options";
|
|
9
10
|
import { readPhiLengthValue } from "../../../../types";
|
|
10
11
|
import { normalizePhiPaddingWidgetConfig, } from "../../../../types/cms-config";
|
|
11
12
|
import { PhiColorFieldControl } from "../../../../components/controls/phi-color-field-control";
|
|
@@ -16,6 +17,8 @@ import { PhiDimensionControl } from "../../../../components/controls/phi-dimensi
|
|
|
16
17
|
import { PhiLengthControl } from "../../../../components/controls/phi-length-control";
|
|
17
18
|
import { parsePhiControlOptionsProviderConfig, } from "../../../../components/controls/phi-control-options";
|
|
18
19
|
import { usePhiControlOptionsProvider } from "../../../../components/controls/phi-options-provider";
|
|
20
|
+
import { PhiCascaderControl } from "../../../../components/controls/phi-cascader-control";
|
|
21
|
+
import { PHI_INSPECTOR_CHOICE_CASCADER_ROOT, PHI_INSPECTOR_CHOICE_CASCADER_SEPARATOR, buildPhiInspectorChoiceCascader, readPhiInspectorChoiceCascaderPath, readPhiInspectorChoiceCascaderValue, } from "./inspector-choice-cascader";
|
|
19
22
|
import { PhiTextControl } from "../../../../components/controls/phi-text-control";
|
|
20
23
|
import { PhiNumberControl } from "../../../../components/controls/phi-number-control";
|
|
21
24
|
import { PhiMultiSelectControl } from "../../../../components/controls/phi-multi-select-control";
|
|
@@ -337,6 +340,7 @@ function PhiInspectorChoiceFieldControl({ field, config, value, defaultValue, di
|
|
|
337
340
|
});
|
|
338
341
|
const renderChoiceRow = (control) => renderPhiInspectorConfigFieldControl(field, _jsxs(PhiFlexControl, { vertical: true, gap: 4, style: { minWidth: 0, width: "100%" }, children: [control, providerResult.warning ? (_jsx(PhiTypographyControl, { type: "warning", children: providerResult.warning })) : null] }));
|
|
339
342
|
const resolvedOptions = useMemo(() => resolveInspectorChoiceOptions(field, widgetReferenceOptions, providerResult.options), [field, providerResult.options, widgetReferenceOptions]);
|
|
343
|
+
const cascader = useMemo(() => field.presentation === "cascader" ? buildPhiInspectorChoiceCascader(resolvedOptions) : null, [field.presentation, resolvedOptions]);
|
|
340
344
|
if (field.mode === "multiple" || field.valueType === "string[]") {
|
|
341
345
|
const selectedValues = readInspectorChoiceMultiValue(value, defaultValue);
|
|
342
346
|
const options = selectedValues.reduce((items, entry) => ensureInspectorChoiceOption(items, entry), resolvedOptions);
|
|
@@ -349,6 +353,28 @@ function PhiInspectorChoiceFieldControl({ field, config, value, defaultValue, di
|
|
|
349
353
|
const selectedValue = value == null
|
|
350
354
|
? emptyOptionValue ?? readInspectorChoiceSingleValue(undefined, defaultValue)
|
|
351
355
|
: readInspectorChoiceSingleValue(value, defaultValue);
|
|
356
|
+
/*
|
|
357
|
+
* The options as a hierarchy by their `parentValue`. Every level can be chosen -- a Folder that holds
|
|
358
|
+
* others is a Folder too -- and what is stored is the chosen option's own value. The empty option is
|
|
359
|
+
* the Cascader's clear, not a level.
|
|
360
|
+
*/
|
|
361
|
+
if (cascader) {
|
|
362
|
+
const writeChoice = (next) => onChange?.({
|
|
363
|
+
[field.key]: next,
|
|
364
|
+
...buildPhiInspectorOptionPresetPatch(field.optionPresets, value, next),
|
|
365
|
+
...(field.patchOnChange ?? {}),
|
|
366
|
+
});
|
|
367
|
+
return renderChoiceRow(_jsx(PhiCascaderControl, { value: readPhiInspectorChoiceCascaderPath(cascader, emptyOptionValue != null && selectedValue === emptyOptionValue ? undefined : selectedValue), options: cascader.options, allowRoot: false, allowClear: field.emptyOption != null, select: "any", separator: PHI_INSPECTOR_CHOICE_CASCADER_SEPARATOR, rootValue: PHI_INSPECTOR_CHOICE_CASCADER_ROOT, placeholder: field.placeholder ?? field.emptyOption?.label ?? (cascader.options.length === 0 ? labels.noMatchingOptions : undefined), disabled: disabled || !onChange, style: { width: "100%" }, onChange: (path) => {
|
|
368
|
+
if (path === PHI_INSPECTOR_CHOICE_CASCADER_ROOT) {
|
|
369
|
+
if (field.emptyOption)
|
|
370
|
+
writeChoice(field.emptyValue);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const next = readPhiInspectorChoiceCascaderValue(cascader, path);
|
|
374
|
+
if (next != null)
|
|
375
|
+
writeChoice(next);
|
|
376
|
+
} }));
|
|
377
|
+
}
|
|
352
378
|
const options = ensureInspectorChoiceOption(field.emptyOption ? [field.emptyOption, ...resolvedOptions] : resolvedOptions, field.allowCustom ? selectedValue : null);
|
|
353
379
|
return renderChoiceRow(_jsx(PhiSelectControl, { options: options, onSearch: providerResult.search.enabled ? setSearchDraft : undefined, filterOptionsLocally: providerResult.search.filterLocally, placeholder: field.placeholder
|
|
354
380
|
?? (field.presentation === "autocomplete" || field.allowCustom
|
|
@@ -617,9 +643,7 @@ function renderPhiInspectorConfigFieldBody({ field, value, defaultValue, config,
|
|
|
617
643
|
if (pageRecordFields.length === 0 && typeof value !== "string") {
|
|
618
644
|
return null;
|
|
619
645
|
}
|
|
620
|
-
return renderPhiInspectorConfigFieldControl(field, _jsx(PhiSelectControl, {
|
|
621
|
-
.filter((recordField) => field.kinds.includes(recordField.kind))
|
|
622
|
-
.map((recordField) => ({ value: recordField.key, label: recordField.label, description: recordField.description })), placeholder: fieldLabels.selectRecordField, value: typeof value === "string" ? value : undefined, disabled: disabled || !onChange, style: { width: "100%" }, onChange: (recordFieldKey) => onChange?.({ [field.key]: typeof recordFieldKey === "string" ? recordFieldKey : undefined }) }));
|
|
646
|
+
return renderPhiInspectorConfigFieldControl(field, _jsx(PhiSelectControl, { options: buildPhiInspectorRecordFieldOptions(field.kinds, pageRecordFields, fieldLabels.recordFieldNone), value: readPhiInspectorRecordFieldChoice(value) ?? PHI_INSPECTOR_RECORD_FIELD_NONE, disabled: disabled || !onChange, style: { width: "100%" }, onChange: (recordFieldKey) => onChange?.({ [field.key]: readPhiInspectorRecordFieldChoice(recordFieldKey) }) }));
|
|
623
647
|
}
|
|
624
648
|
if (field.type === "video-provider") {
|
|
625
649
|
return renderPhiInspectorConfigFieldControl(field, _jsx(PhiSelectControl
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PhiRecordFieldDescriptor, PhiRecordFieldKind } from "../../../../types/record-provider";
|
|
2
|
+
/** The value the "None" entry stands under: a Widget bound to no field shows its own content. */
|
|
3
|
+
export declare const PHI_INSPECTOR_RECORD_FIELD_NONE = "";
|
|
4
|
+
/**
|
|
5
|
+
* The entries of a record-field select: "None" first, then the fields of the page's record a Widget of
|
|
6
|
+
* these kinds can draw.
|
|
7
|
+
*
|
|
8
|
+
* "None" is an entry rather than an empty select, because it is a choice with a meaning -- the Widget
|
|
9
|
+
* shows what it holds itself -- and an empty box with a placeholder read as a setting nobody had made.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildPhiInspectorRecordFieldOptions(kinds: readonly PhiRecordFieldKind[], fields: readonly PhiRecordFieldDescriptor[], noneLabel: string): {
|
|
12
|
+
description?: string | undefined;
|
|
13
|
+
value: string;
|
|
14
|
+
label: string;
|
|
15
|
+
}[];
|
|
16
|
+
/** The stored key for a select value: "None" stores nothing. */
|
|
17
|
+
export declare function readPhiInspectorRecordFieldChoice(value: unknown): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The value the "None" entry stands under: a Widget bound to no field shows its own content. */
|
|
2
|
+
export const PHI_INSPECTOR_RECORD_FIELD_NONE = "";
|
|
3
|
+
/**
|
|
4
|
+
* The entries of a record-field select: "None" first, then the fields of the page's record a Widget of
|
|
5
|
+
* these kinds can draw.
|
|
6
|
+
*
|
|
7
|
+
* "None" is an entry rather than an empty select, because it is a choice with a meaning -- the Widget
|
|
8
|
+
* shows what it holds itself -- and an empty box with a placeholder read as a setting nobody had made.
|
|
9
|
+
*/
|
|
10
|
+
export function buildPhiInspectorRecordFieldOptions(kinds, fields, noneLabel) {
|
|
11
|
+
return [
|
|
12
|
+
{ value: PHI_INSPECTOR_RECORD_FIELD_NONE, label: noneLabel },
|
|
13
|
+
...fields
|
|
14
|
+
.filter((field) => kinds.includes(field.kind))
|
|
15
|
+
.map((field) => ({ value: field.key, label: field.label, ...(field.description ? { description: field.description } : {}) })),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
/** The stored key for a select value: "None" stores nothing. */
|
|
19
|
+
export function readPhiInspectorRecordFieldChoice(value) {
|
|
20
|
+
return typeof value === "string" && value !== PHI_INSPECTOR_RECORD_FIELD_NONE ? value : undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the Inspector offers "Translate text" for a node.
|
|
3
|
+
*
|
|
4
|
+
* Only a plugin that translates its own words has the switch at all: every other node's words go through
|
|
5
|
+
* the renderer's pass, which the switch does not govern. And not while the node names a field of the page
|
|
6
|
+
* record (`recordField`): the record's value arrives in the page's language and the render never sends it
|
|
7
|
+
* to a translator, so a switch there would be one that changes nothing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPhiInspectorTranslateSwitchShown(plugin: {
|
|
10
|
+
translatesOwnText?: boolean;
|
|
11
|
+
} | null | undefined, config: Readonly<Record<string, unknown>> | null | undefined): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Where among a Widget's visible settings fields "Translate text" stands, as the index it is inserted at.
|
|
14
|
+
*
|
|
15
|
+
* Right after the field that binds the Widget's words to the page record, where there is one: the two
|
|
16
|
+
* answer the same question -- where the words come from -- and the switch only shows while that field is
|
|
17
|
+
* None. Without one, it closes the Widget's own fields, before the next headed group: it is about the
|
|
18
|
+
* words above it, and a group under a heading -- the Badge, the Link target -- is a part of its own. A
|
|
19
|
+
* heading over the very first field names the Widget's own group rather than starting another.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolvePhiInspectorTranslateSwitchIndex(fields: readonly {
|
|
22
|
+
key: string;
|
|
23
|
+
heading?: string;
|
|
24
|
+
}[]): number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the Inspector offers "Translate text" for a node.
|
|
3
|
+
*
|
|
4
|
+
* Only a plugin that translates its own words has the switch at all: every other node's words go through
|
|
5
|
+
* the renderer's pass, which the switch does not govern. And not while the node names a field of the page
|
|
6
|
+
* record (`recordField`): the record's value arrives in the page's language and the render never sends it
|
|
7
|
+
* to a translator, so a switch there would be one that changes nothing.
|
|
8
|
+
*/
|
|
9
|
+
export function isPhiInspectorTranslateSwitchShown(plugin, config) {
|
|
10
|
+
if (!plugin?.translatesOwnText)
|
|
11
|
+
return false;
|
|
12
|
+
const recordField = config?.recordField;
|
|
13
|
+
return !(typeof recordField === "string" && recordField.trim().length > 0);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Where among a Widget's visible settings fields "Translate text" stands, as the index it is inserted at.
|
|
17
|
+
*
|
|
18
|
+
* Right after the field that binds the Widget's words to the page record, where there is one: the two
|
|
19
|
+
* answer the same question -- where the words come from -- and the switch only shows while that field is
|
|
20
|
+
* None. Without one, it closes the Widget's own fields, before the next headed group: it is about the
|
|
21
|
+
* words above it, and a group under a heading -- the Badge, the Link target -- is a part of its own. A
|
|
22
|
+
* heading over the very first field names the Widget's own group rather than starting another.
|
|
23
|
+
*/
|
|
24
|
+
export function resolvePhiInspectorTranslateSwitchIndex(fields) {
|
|
25
|
+
const headed = fields.findIndex((field, index) => index > 0 && field.heading != null);
|
|
26
|
+
const ownGroupEnd = headed === -1 ? fields.length : headed;
|
|
27
|
+
const recordField = fields.findIndex((field) => field.key === "recordField");
|
|
28
|
+
return recordField !== -1 && recordField < ownGroupEnd ? recordField + 1 : ownGroupEnd;
|
|
29
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PhiBackgroundControlProps } from "../../../../components/controls/phi-background-control";
|
|
2
2
|
import type { PhiInspectorSurfaceLabels } from "./inspector-surface-labels";
|
|
3
|
-
import type
|
|
3
|
+
import { type PhiInspectorWidgetLabels } from "../../../../components/widgets/label-types/inspector";
|
|
4
4
|
import type { PhiBackgroundWidgetLabels } from "../../../../components/widgets/label-types/background";
|
|
5
5
|
import type { PhiBorderWidgetLabels } from "../../../../components/widgets/label-types/border";
|
|
6
6
|
import type { PhiPaddingWidgetLabels } from "../../../../components/widgets/label-types/padding";
|
|
@@ -3,6 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { usePhiBaseLayoutOwnSlotController } from "../../../../components/layouts/phi-layout-slot-state";
|
|
5
5
|
import { PhiSurfaceControl } from "../../../../components/controls/phi-surface-control";
|
|
6
|
+
import { PHI_INSPECTOR_WIDGET_DEFAULT_LABELS } from "../../../../components/widgets/label-types/inspector";
|
|
7
|
+
import { isPhiInspectorTranslateSwitchShown } from "./inspector-translate-switch";
|
|
6
8
|
import { PhiViewportVisibilityControl } from "../../../../components/controls/phi-viewport-visibility-control";
|
|
7
9
|
import { PhiPlacementMatrixControl } from "../../../../components/controls/phi-placement-matrix-control";
|
|
8
10
|
import { PhiInspectorSectionContent } from "./inspector-section-content";
|
|
@@ -165,10 +167,10 @@ export function PhiDeveloperBuilderLayoutInspectorWidgetClient({ section, builde
|
|
|
165
167
|
slots: textSlots,
|
|
166
168
|
disabled: isPreviewMode,
|
|
167
169
|
onChange: onConfigPatch,
|
|
168
|
-
})), selectedStructurePlugin
|
|
170
|
+
})), isPhiInspectorTranslateSwitchShown(selectedStructurePlugin, currentDraftRecord)
|
|
169
171
|
? renderPhiInspectorSwitchRow({
|
|
170
172
|
key: "translate-text",
|
|
171
|
-
label:
|
|
173
|
+
label: (fieldLabels ?? PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.fields).translateText,
|
|
172
174
|
checked: !hasPhiFlag(currentDraft?.node.flags ?? 0, PhiCmsFlags.NoTranslate),
|
|
173
175
|
disabled: isPreviewMode,
|
|
174
176
|
...(onTranslateChange ? { onChange: onTranslateChange } : {}),
|
|
@@ -17,7 +17,7 @@ import type { PhiRecordFieldDescriptor } from "../../../../types/record-provider
|
|
|
17
17
|
import type { PhiBuilderWidgetMeta } from "../../../../types/builder";
|
|
18
18
|
import type { PhiSignalRoute } from "../../../../types/signals";
|
|
19
19
|
import { type PhiInspectorWidgetReferenceOption } from "./inspector-config-field";
|
|
20
|
-
import type
|
|
20
|
+
import { type PhiInspectorWidgetLabels } from "../../../../components/widgets/label-types/inspector";
|
|
21
21
|
type PhiDeveloperBuilderWidgetInspectorWidgetClientProps = {
|
|
22
22
|
section?: string;
|
|
23
23
|
builderMode?: PhiDeveloperBuilderMode;
|
|
@@ -15,6 +15,8 @@ import { buildPhiInspectorConfigPathPatch, isPhiInspectorConfigFieldVisible, rea
|
|
|
15
15
|
import { PhiTypographyControl } from "../../../../components/controls/phi-typography-control";
|
|
16
16
|
import { PhiCmsFlags } from "../../../../constants/phi-cms";
|
|
17
17
|
import { hasPhiFlag } from "../../../../helpers/flags";
|
|
18
|
+
import { PHI_INSPECTOR_WIDGET_DEFAULT_LABELS } from "../../../../components/widgets/label-types/inspector";
|
|
19
|
+
import { isPhiInspectorTranslateSwitchShown, resolvePhiInspectorTranslateSwitchIndex } from "./inspector-translate-switch";
|
|
18
20
|
const PHI_GAP_SM = "var(--phi-padding-sm)";
|
|
19
21
|
export function PhiDeveloperBuilderWidgetInspectorWidgetClient({ section, builderMode = "editor", selectedStructureNodeKey = null, selectedStructureNodeKind = null, selectedStructureNodeTitle = null, selectedStructureWidgetMeta = null, currentDraft = null, widgetReferenceOptions = [], signalRouteScope = "widget", onConfigChange, onGeometryChange, onSurfaceChange, onTranslateChange, geometryLabels, surfaceLabels, backgroundLabels, borderLabels, renderMediaPicker, signalsLabels, colorPickerLabels, iconPickerLabels, fieldLabels, dataProviderDescriptors = [], calendarAdapterDescriptors = [], videoProviderDescriptors = [], pageRecordFields = [], }) {
|
|
20
22
|
const isPreviewMode = builderMode === "preview";
|
|
@@ -58,9 +60,7 @@ export function PhiDeveloperBuilderWidgetInspectorWidgetClient({ section, builde
|
|
|
58
60
|
if (ownSlot.state === "hidden")
|
|
59
61
|
ownSlot.show();
|
|
60
62
|
}, [ownSlot, section, surfaceSectionHidden]);
|
|
61
|
-
|
|
62
|
-
const headedFieldIndex = settingsFields.findIndex((field, index) => index > 0 && field.heading != null);
|
|
63
|
-
const firstHeadedFieldIndex = headedFieldIndex === -1 ? settingsFields.length : headedFieldIndex;
|
|
63
|
+
const translateSwitchIndex = resolvePhiInspectorTranslateSwitchIndex(settingsFields);
|
|
64
64
|
const renderSettingsField = (field) => {
|
|
65
65
|
const lock = resolvePhiInspectorFieldLock(field, selectedStructureWidgetMeta?.fields ?? [], currentWidgetSettingsConfigRecord);
|
|
66
66
|
return renderPhiInspectorConfigField({
|
|
@@ -108,15 +108,15 @@ export function PhiDeveloperBuilderWidgetInspectorWidgetClient({ section, builde
|
|
|
108
108
|
{
|
|
109
109
|
key: "settings",
|
|
110
110
|
title: "Settings",
|
|
111
|
-
children: selectedStructureWidgetMeta == null ? (_jsxs(PhiTypographyControl, { type: "danger", children: ["Widget metadata for ", selectedStructureNodeKey ?? selectedStructureNodeTitle ?? "this widget", " is not available from the active Canvas modules."] })) : settingsFields.length === 0 ? (_jsx(PhiTypographyControl, { type: "secondary", children: "This widget does not declare configurable settings." })) : (_jsxs("div", { style: { display: "grid", gap: PHI_GAP_SM, width: "100%" }, children: [settingsFields.slice(0,
|
|
111
|
+
children: selectedStructureWidgetMeta == null ? (_jsxs(PhiTypographyControl, { type: "danger", children: ["Widget metadata for ", selectedStructureNodeKey ?? selectedStructureNodeTitle ?? "this widget", " is not available from the active Canvas modules."] })) : settingsFields.length === 0 ? (_jsx(PhiTypographyControl, { type: "secondary", children: "This widget does not declare configurable settings." })) : (_jsxs("div", { style: { display: "grid", gap: PHI_GAP_SM, width: "100%" }, children: [settingsFields.slice(0, translateSwitchIndex).map(renderSettingsField), isPhiInspectorTranslateSwitchShown(selectedStructureWidgetMeta, currentDraft?.config)
|
|
112
112
|
? renderPhiInspectorSwitchRow({
|
|
113
113
|
key: "translate-text",
|
|
114
|
-
label:
|
|
114
|
+
label: (fieldLabels ?? PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.fields).translateText,
|
|
115
115
|
checked: !hasPhiFlag(currentDraft?.flags ?? 0, PhiCmsFlags.NoTranslate),
|
|
116
116
|
disabled: isPreviewMode,
|
|
117
117
|
...(onTranslateChange ? { onChange: onTranslateChange } : {}),
|
|
118
118
|
})
|
|
119
|
-
: null, settingsFields.slice(
|
|
119
|
+
: null, settingsFields.slice(translateSwitchIndex).map(renderSettingsField)] })),
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
122
|
key: "geometry",
|
|
@@ -54,6 +54,23 @@ function mapPhiConfigFieldText(field, mapText) {
|
|
|
54
54
|
...(mapped.placeholder == null ? {} : { placeholder: mapOptionalText(mapped.placeholder, mapText) }),
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
/* What a field shows while it is empty is read like its label, so it is translated with it. */
|
|
58
|
+
if (mapped.type === "string" || mapped.type === "url" || mapped.type === "icon") {
|
|
59
|
+
return mapped.placeholder == null ? mapped : { ...mapped, placeholder: mapOptionalText(mapped.placeholder, mapText) };
|
|
60
|
+
}
|
|
61
|
+
if (mapped.type === "dimension") {
|
|
62
|
+
return {
|
|
63
|
+
...mapped,
|
|
64
|
+
...(mapped.widthPlaceholder == null ? {} : { widthPlaceholder: mapOptionalText(mapped.widthPlaceholder, mapText) }),
|
|
65
|
+
...(mapped.heightPlaceholder == null ? {} : { heightPlaceholder: mapOptionalText(mapped.heightPlaceholder, mapText) }),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (mapped.type === "flags") {
|
|
69
|
+
return {
|
|
70
|
+
...mapped,
|
|
71
|
+
options: mapped.options.map((option) => ({ ...option, label: mapOptionalText(option.label, mapText) ?? option.label })),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
57
74
|
if (mapped.type === "collection") {
|
|
58
75
|
return {
|
|
59
76
|
...mapped,
|
|
@@ -26,6 +26,7 @@ import { buildPhiBuilderPreviewPageNode, buildPhiBuilderRootLayoutRenderNode, bu
|
|
|
26
26
|
import { resolvePhiRenderableBlockGeometry } from "../../../types/renderable-block-geometry";
|
|
27
27
|
import { resolvePhiRootScaffoldProperties } from "./builder-geometry";
|
|
28
28
|
import { PhiWidgetPreviewFallback } from "../../../components/widgets/built-in/widget-preview";
|
|
29
|
+
import { PhiWidgetEditorPlaceholder } from "../../../components/widgets/builder/widget-editor-placeholder";
|
|
29
30
|
import { splitPhiCmsLayoutNamespacedTypeKey } from "../../../constants/cms-layout-types";
|
|
30
31
|
import { PhiBuilderDemandControllerRegistration } from "./demand-controller-registration";
|
|
31
32
|
import { buildPhiBuilderRootNodeRenderableTree } from "./root-node-renderable-tree";
|
|
@@ -570,14 +571,23 @@ function resolvePhiAuthoringLayoutRenderer(plugin, definition, renderMode) {
|
|
|
570
571
|
? plugin.render
|
|
571
572
|
: null;
|
|
572
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* The house placeholder on the canvas, for a Widget that leaves `renderEditor` out: its name, its type
|
|
576
|
+
* and its description, still. Leaving it out is the declaration; nothing else falls back to it.
|
|
577
|
+
*/
|
|
578
|
+
function renderPhiAuthoringWidgetPlaceholder(plugin) {
|
|
579
|
+
return function PhiAuthoringWidgetPlaceholder({ widget }) {
|
|
580
|
+
return _jsx(PhiWidgetEditorPlaceholder, { widget: widget, pluginTitle: plugin.title, summary: plugin.description });
|
|
581
|
+
};
|
|
582
|
+
}
|
|
573
583
|
function resolvePhiAuthoringWidgetRenderer(plugin, definition) {
|
|
574
584
|
switch (definition.renderPolicies.authoring) {
|
|
575
585
|
case "custom":
|
|
576
|
-
return plugin.renderEditor;
|
|
586
|
+
return plugin.renderEditor ?? renderPhiAuthoringWidgetPlaceholder(plugin);
|
|
577
587
|
case "usePreview":
|
|
578
588
|
// `loadAuthoring` supplies the explicit client-safe preview adapter. It is never the server
|
|
579
589
|
// plugin's `renderPreview()` implementation or an implicit runtime fallback.
|
|
580
|
-
return plugin.renderEditor;
|
|
590
|
+
return plugin.renderEditor ?? renderPhiAuthoringWidgetPlaceholder(plugin);
|
|
581
591
|
}
|
|
582
592
|
}
|
|
583
593
|
function resolvePhiAuthoringLayoutConfigParser(plugin) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
|
|
3
|
-
import { renderPhiWidgetPreviewPlaceholder } from "../../../../../plugins/factories/widget-renderers";
|
|
4
3
|
import { getPhiEffectsWidgetLabels } from "../../../../../components/widgets/label-sets/effects";
|
|
5
4
|
import { getPhiAuthoringToolsLabels } from "../../../../../components/widgets/label-sets/authoring-tools";
|
|
6
5
|
import { getPhiMediaWidgetLabels } from "../../../../../components/media/label-sets/media";
|
|
@@ -79,5 +78,4 @@ export const PHI_STRUCTURE_REGION_WIDGET_PLUGIN = {
|
|
|
79
78
|
fallbackMinHeight: config.fallbackMinHeight,
|
|
80
79
|
}, structureDraftsByArea: structureDraftsByArea, pageDraftsByScope: pageDraftsByScope, effectsLabels: effectsLabels, authoringToolsLabels: authoringToolsLabels, serverPreview: _jsx(PhiBuilderRegionServerPreview, { snapshot: snapshot, draft: resolvedPreviewDraft, regionKey: regionKey, runtime: runtime, registry: registry }) }) }));
|
|
81
80
|
},
|
|
82
|
-
renderPreview: ({ widget }) => renderPhiWidgetPreviewPlaceholder(widget),
|
|
83
81
|
};
|
|
@@ -31,14 +31,14 @@ export const PHI_RUNTIME_MODULE_WIDGETS = [
|
|
|
31
31
|
definePhiFirstPartyWidget({
|
|
32
32
|
definition: PHI_BUILDER_PAGES_WORKSPACE_WIDGET_DEFINITION,
|
|
33
33
|
ownerModuleId: PHI_BUILDER_RUNTIME_MODULE_ID,
|
|
34
|
-
renderPolicies: { "runtime": "custom", "preview": "
|
|
34
|
+
renderPolicies: { "runtime": "custom", "preview": "custom", "authoring": "usePreview" },
|
|
35
35
|
loadRuntime: () => import("./widgets/pages-workspace/plugin").then((module) => module.PHI_BUILDER_PAGES_WORKSPACE_WIDGET_PLUGIN),
|
|
36
36
|
loadPreview: () => import("./widgets/pages-workspace/preview-plugin").then((module) => module.PHI_BUILDER_PAGES_WORKSPACE_WIDGET_PREVIEW_PLUGIN),
|
|
37
37
|
}),
|
|
38
38
|
definePhiFirstPartyWidget({
|
|
39
39
|
definition: PHI_BUILDER_SHELLS_WORKSPACE_WIDGET_DEFINITION,
|
|
40
40
|
ownerModuleId: PHI_BUILDER_RUNTIME_MODULE_ID,
|
|
41
|
-
renderPolicies: { "runtime": "custom", "preview": "
|
|
41
|
+
renderPolicies: { "runtime": "custom", "preview": "custom", "authoring": "usePreview" },
|
|
42
42
|
loadRuntime: () => import("./widgets/shells-workspace/plugin").then((module) => module.PHI_BUILDER_SHELLS_WORKSPACE_WIDGET_PLUGIN),
|
|
43
43
|
loadPreview: () => import("./widgets/shells-workspace/preview-plugin").then((module) => module.PHI_BUILDER_SHELLS_WORKSPACE_WIDGET_PREVIEW_PLUGIN),
|
|
44
44
|
}),
|
|
@@ -59,7 +59,7 @@ export const PHI_RUNTIME_MODULE_WIDGETS = [
|
|
|
59
59
|
definePhiFirstPartyWidget({
|
|
60
60
|
definition: PHI_STRUCTURE_REGION_WIDGET_DEFINITION,
|
|
61
61
|
ownerModuleId: PHI_BUILDER_RUNTIME_MODULE_ID,
|
|
62
|
-
renderPolicies: { "runtime": "custom", "preview": "
|
|
62
|
+
renderPolicies: { "runtime": "custom", "preview": "visualPlaceholder", "authoring": "custom" },
|
|
63
63
|
loadRuntime: () => import("./widgets/structure-region/plugin").then((module) => module.PHI_STRUCTURE_REGION_WIDGET_PLUGIN),
|
|
64
64
|
loadPreview: () => import("./widgets/structure-region/plugin").then((module) => module.PHI_STRUCTURE_REGION_WIDGET_PLUGIN),
|
|
65
65
|
}),
|
|
@@ -428,16 +428,20 @@ function assertPhiRuntimeModuleServerBinding(definition) {
|
|
|
428
428
|
throw new Error(`${definition.moduleId}: required server capabilities must be unique versioned namespaced ids.`);
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
function assertPhiRuntimeModuleRenderPolicies(moduleId, type, policies) {
|
|
431
|
+
function assertPhiRuntimeModuleRenderPolicies(moduleId, type, policies, kind) {
|
|
432
432
|
if (!policies || typeof policies !== "object") {
|
|
433
433
|
throw new Error(`${moduleId}: artifact "${type}" has no render policies.`);
|
|
434
434
|
}
|
|
435
435
|
if (policies.runtime !== "custom") {
|
|
436
436
|
throw new Error(`${moduleId}: artifact "${type}" declares an invalid Runtime render policy.`);
|
|
437
437
|
}
|
|
438
|
-
if (!["custom", "runtimeReadOnly", "
|
|
438
|
+
if (!["custom", "runtimeReadOnly", "visualPlaceholder"].includes(policies.preview)) {
|
|
439
439
|
throw new Error(`${moduleId}: artifact "${type}" declares an invalid Preview render policy.`);
|
|
440
440
|
}
|
|
441
|
+
// The house placeholder stands in for a Widget; a Layout holds Regions and has no such stand-in.
|
|
442
|
+
if (kind === "layout" && policies.preview === "visualPlaceholder") {
|
|
443
|
+
throw new Error(`${moduleId}: layout "${type}" declares the Widget-only Preview policy "visualPlaceholder".`);
|
|
444
|
+
}
|
|
441
445
|
if (!["custom", "usePreview"].includes(policies.authoring)) {
|
|
442
446
|
throw new Error(`${moduleId}: artifact "${type}" declares an invalid Authoring render policy.`);
|
|
443
447
|
}
|
|
@@ -876,7 +880,7 @@ function assertPhiRuntimeModuleArtifacts(widgets, layouts, moduleId, ownerProvid
|
|
|
876
880
|
if (typeof widget.loadRuntime !== "function" || typeof widget.loadPreview !== "function") {
|
|
877
881
|
throw new Error(`${moduleId}: owned widget "${type}" must declare Runtime and Preview loaders.`);
|
|
878
882
|
}
|
|
879
|
-
assertPhiRuntimeModuleRenderPolicies(moduleId, type, widget.renderPolicies);
|
|
883
|
+
assertPhiRuntimeModuleRenderPolicies(moduleId, type, widget.renderPolicies, "widget");
|
|
880
884
|
assertPhiSignalPluginMetaContract(widget.definition.runtimeSignals, `${type}.runtimeSignals`);
|
|
881
885
|
assertOwnedAccessPolicy(moduleId, ownerProviderId, widget.accessPolicy, `widget "${type}"`);
|
|
882
886
|
widgetTypes.add(type);
|
|
@@ -902,7 +906,7 @@ function assertPhiRuntimeModuleArtifacts(widgets, layouts, moduleId, ownerProvid
|
|
|
902
906
|
if (typeof layout.loadRuntime !== "function") {
|
|
903
907
|
throw new Error(`${moduleId}: owned layout "${type}" must declare a Runtime loader.`);
|
|
904
908
|
}
|
|
905
|
-
assertPhiRuntimeModuleRenderPolicies(moduleId, type, layout.renderPolicies);
|
|
909
|
+
assertPhiRuntimeModuleRenderPolicies(moduleId, type, layout.renderPolicies, "layout");
|
|
906
910
|
assertPhiSignalPluginMetaContract(layout.definition.runtimeSignals, `${type}.runtimeSignals`);
|
|
907
911
|
assertOwnedAccessPolicy(moduleId, ownerProviderId, layout.accessPolicy, `layout "${type}"`);
|
|
908
912
|
layoutTypes.add(type);
|
|
@@ -73,7 +73,7 @@ export default createPhiAuthoringWidgetModule([
|
|
|
73
73
|
definePhiAuthoringWidgetModuleLoader(PHI_DIMENSION_WIDGET_DEFINITION, () => import("./widgets/dimension/authoring").then((module) => module.PHI_DIMENSION_WIDGET_BUILDER_PLUGIN)),
|
|
74
74
|
definePhiAuthoringWidgetModuleLoader(PHI_LENGTH_WIDGET_DEFINITION, () => import("./widgets/length/authoring").then((module) => module.PHI_LENGTH_WIDGET_BUILDER_PLUGIN)),
|
|
75
75
|
definePhiAuthoringWidgetModuleLoader(PHI_FORM_WIDGET_DEFINITION, () => import("./widgets/form/authoring").then((module) => module.PHI_FORM_WIDGET_BUILDER_PLUGIN)),
|
|
76
|
-
definePhiAuthoringWidgetModuleLoader(PHI_FORM_PREVIEW_WIDGET_DEFINITION, () =>
|
|
76
|
+
definePhiAuthoringWidgetModuleLoader(PHI_FORM_PREVIEW_WIDGET_DEFINITION, () => Promise.resolve(PHI_FORM_PREVIEW_WIDGET_DEFINITION)),
|
|
77
77
|
definePhiAuthoringWidgetModuleLoader(PHI_HEADER_NAVIGATION_WIDGET_DEFINITION, () => import("./widgets/header-navigation/authoring").then((module) => module.PHI_HEADER_NAVIGATION_WIDGET_BUILDER_PLUGIN)),
|
|
78
78
|
definePhiAuthoringWidgetModuleLoader(PHI_HTML_WIDGET_DEFINITION, () => import("./widgets/html/authoring").then((module) => module.PHI_HTML_WIDGET_BUILDER_PLUGIN)),
|
|
79
79
|
definePhiAuthoringWidgetModuleLoader(PHI_ICON_WIDGET_DEFINITION, () => import("./widgets/icon/authoring").then((module) => module.PHI_ICON_WIDGET_BUILDER_PLUGIN)),
|
|
@@ -106,7 +106,7 @@ export default createPhiAuthoringWidgetModule([
|
|
|
106
106
|
definePhiAuthoringWidgetModuleLoader(PHI_ENTRY_LIST_WIDGET_DEFINITION, () => import("./widgets/entry-list/authoring").then((module) => module.PHI_ENTRY_LIST_WIDGET_BUILDER_PLUGIN)),
|
|
107
107
|
definePhiAuthoringWidgetModuleLoader(PHI_ENTRY_DETAIL_WIDGET_DEFINITION, () => import("./widgets/entry-detail/authoring").then((module) => module.PHI_ENTRY_DETAIL_WIDGET_BUILDER_PLUGIN)),
|
|
108
108
|
definePhiAuthoringWidgetModuleLoader(PHI_ENTRY_HEADER_WIDGET_DEFINITION, () => import("./widgets/entry-header/authoring").then((module) => module.PHI_ENTRY_HEADER_WIDGET_BUILDER_PLUGIN)),
|
|
109
|
-
definePhiAuthoringWidgetModuleLoader(PHI_THREAD_CONVERSATION_WIDGET_DEFINITION, () =>
|
|
109
|
+
definePhiAuthoringWidgetModuleLoader(PHI_THREAD_CONVERSATION_WIDGET_DEFINITION, () => Promise.resolve(PHI_THREAD_CONVERSATION_WIDGET_DEFINITION)),
|
|
110
110
|
definePhiAuthoringWidgetModuleLoader(PHI_FLOAT_BUTTON_WIDGET_DEFINITION, () => import("./widgets/float-button/authoring").then((module) => module.PHI_FLOAT_BUTTON_WIDGET_BUILDER_PLUGIN)),
|
|
111
111
|
definePhiAuthoringWidgetModuleLoader(PHI_SPACER_WIDGET_DEFINITION, () => import("./widgets/spacer/authoring").then((module) => module.PHI_SPACER_WIDGET_BUILDER_PLUGIN)),
|
|
112
112
|
definePhiAuthoringWidgetModuleLoader(PHI_SWITCH_WIDGET_DEFINITION, () => import("./widgets/switch/authoring").then((module) => module.PHI_SWITCH_WIDGET_BUILDER_PLUGIN)),
|
|
@@ -342,10 +342,11 @@ export declare const PHI_CORE_RUNTIME_DATA_PROVIDER_DESCRIPTORS: ({
|
|
|
342
342
|
type: "choice";
|
|
343
343
|
heading: string;
|
|
344
344
|
label: string;
|
|
345
|
+
description: string;
|
|
346
|
+
presentation: "cascader";
|
|
345
347
|
optionsProvider: {
|
|
346
348
|
providerKey: `${string}/${string}`;
|
|
347
349
|
};
|
|
348
|
-
description?: undefined;
|
|
349
350
|
options?: undefined;
|
|
350
351
|
min?: undefined;
|
|
351
352
|
max?: undefined;
|
|
@@ -355,6 +356,7 @@ export declare const PHI_CORE_RUNTIME_DATA_PROVIDER_DESCRIPTORS: ({
|
|
|
355
356
|
label: string;
|
|
356
357
|
description: string;
|
|
357
358
|
heading?: undefined;
|
|
359
|
+
presentation?: undefined;
|
|
358
360
|
optionsProvider?: undefined;
|
|
359
361
|
options?: undefined;
|
|
360
362
|
min?: undefined;
|
|
@@ -363,24 +365,26 @@ export declare const PHI_CORE_RUNTIME_DATA_PROVIDER_DESCRIPTORS: ({
|
|
|
363
365
|
key: string;
|
|
364
366
|
type: "choice";
|
|
365
367
|
label: string;
|
|
368
|
+
description: string;
|
|
366
369
|
options: {
|
|
367
370
|
value: string;
|
|
368
371
|
label: string;
|
|
369
372
|
}[];
|
|
370
373
|
heading?: undefined;
|
|
374
|
+
presentation?: undefined;
|
|
371
375
|
optionsProvider?: undefined;
|
|
372
|
-
description?: undefined;
|
|
373
376
|
min?: undefined;
|
|
374
377
|
max?: undefined;
|
|
375
378
|
} | {
|
|
376
379
|
key: string;
|
|
377
380
|
type: "number";
|
|
378
381
|
label: string;
|
|
382
|
+
description: string;
|
|
379
383
|
min: number;
|
|
380
384
|
max: number;
|
|
381
385
|
heading?: undefined;
|
|
386
|
+
presentation?: undefined;
|
|
382
387
|
optionsProvider?: undefined;
|
|
383
|
-
description?: undefined;
|
|
384
388
|
options?: undefined;
|
|
385
389
|
})[];
|
|
386
390
|
resources?: undefined;
|