@phis/ui 0.5.4 → 0.5.5
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 +17 -7
- package/components/layouts/clients/phi-flex-layout-client.js +17 -2
- package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
- package/components/layouts/clients/phi-layout-anchored-overlay.js +2 -0
- package/components/regions/presets/content-entry-editor-page-tree.js +2 -0
- package/components/regions/presets/content-entry-public-page-trees.js +2 -0
- package/components/widgets/builder/stack-tabs.d.ts +2 -1
- package/components/widgets/builder/stack-tabs.js +18 -2
- package/components/widgets/config/choice-shared.d.ts +0 -48
- package/components/widgets/config/choice-shared.js +0 -1
- package/components/widgets/config/stack-tabs.js +4 -3
- package/helpers/config-text-fields.d.ts +49 -0
- package/helpers/config-text-fields.js +122 -0
- package/helpers/preset-text-source-check.d.ts +22 -0
- package/helpers/preset-text-source-check.js +45 -0
- package/helpers/text-source.d.ts +14 -5
- package/helpers/text-source.js +16 -3
- package/module-page-check.d.ts +1 -0
- package/module-page-check.js +1 -0
- package/package.json +1 -1
- package/plugins/runtime/phi-slot-child-frame-view.js +1 -1
- package/plugins/runtime/slot-size-policy.d.ts +8 -2
- package/plugins/runtime/slot-size-policy.js +51 -16
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +2 -0
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -0
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +11 -0
- package/plugins/runtime-modules/core/widgets/button/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/button/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/button/plugin.js +6 -25
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +17 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +16 -1
- package/plugins/runtime-modules/core/widgets/card/plugin.js +8 -10
- package/plugins/runtime-modules/core/widgets/card/server.d.ts +1 -2
- package/plugins/runtime-modules/core/widgets/card/server.js +16 -28
- package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +7 -1
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +1 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.js +3 -3
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/image/server.js +5 -9
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/markdown-toc/server.js +3 -5
- package/plugins/runtime-modules/core/widgets/quick-links/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/quick-links/server.d.ts +2 -5
- package/plugins/runtime-modules/core/widgets/quick-links/server.js +2 -6
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/result/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/result/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/result/server.d.ts +2 -3
- package/plugins/runtime-modules/core/widgets/result/server.js +11 -33
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/slider/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/slider/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/config.js +0 -2
- package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +3 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/server.js +5 -13
- package/plugins/runtime-modules/core/widgets/spacer/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/spacer/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/steps/config.d.ts +7 -2
- package/plugins/runtime-modules/core/widgets/steps/config.js +1 -2
- package/plugins/runtime-modules/core/widgets/steps/plugin.js +6 -30
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/table/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/timeline/config.d.ts +8 -1
- package/plugins/runtime-modules/core/widgets/timeline/config.js +1 -2
- package/plugins/runtime-modules/core/widgets/timeline/plugin.js +6 -37
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -0
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -0
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -0
- package/plugins/runtime-modules/page-preset-overlays.d.ts +18 -0
- package/plugins/runtime-modules/page-preset-overlays.js +70 -0
- package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +1 -0
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -0
- package/plugins/runtime-modules/search/widgets/search-box/server.js +3 -5
- package/plugins/runtime-modules/search/widgets/search-results/server.js +3 -5
- package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +4 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +2 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +2 -0
- package/server-helpers/cms-request.js +34 -12
- package/server-helpers/cms-widget-texts.d.ts +14 -0
- package/server-helpers/cms-widget-texts.js +117 -0
- package/server-helpers/search-index.js +12 -3
- package/styles/root.css +6 -2
- package/types/cms-plugins.d.ts +30 -5
- package/types/core-widget-placements.d.ts +5 -0
- package/types/slot-size-policy.d.ts +19 -2
|
@@ -7,8 +7,6 @@ export type PhiEntryListWidgetProps = PhiServerBlockBaseProps<PhiNoLabels, PhiEn
|
|
|
7
7
|
/** Where the record binding is answered; absent outside a page render, where nothing is bound. */
|
|
8
8
|
registry?: Pick<PhiCmsRuntimeRenderRegistry, "recordProviderLoadersByKey">;
|
|
9
9
|
links?: PhiResolvedLinkTargets | null;
|
|
10
|
-
/** Whether the heading is translated: the node's `NoTranslate` flag, read by the plugin. */
|
|
11
|
-
translate?: boolean;
|
|
12
10
|
widgetId?: PhiCmsInstanceId | null;
|
|
13
11
|
};
|
|
14
12
|
/**
|
|
@@ -27,4 +25,4 @@ export type PhiEntryListWidgetProps = PhiServerBlockBaseProps<PhiNoLabels, PhiEn
|
|
|
27
25
|
* as that record carries. And with nothing related -- or nothing to be related to -- it draws
|
|
28
26
|
* nothing at all: a "more like this" heading over an empty space says something false.
|
|
29
27
|
*/
|
|
30
|
-
export declare function PhiEntryListWidget({ config, runtime, registry, links,
|
|
28
|
+
export declare function PhiEntryListWidget({ config, runtime, registry, links, widgetId, }: PhiEntryListWidgetProps): Promise<import("react").JSX.Element | null>;
|
|
@@ -5,7 +5,6 @@ import { PhiWidgetFailureServer } from "../../../../../components/widgets/shared
|
|
|
5
5
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
6
6
|
import { fetchPhiSiteContentEntries } from "../../../../../gateway/content-entries";
|
|
7
7
|
import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
|
|
8
|
-
import { trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
9
8
|
import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
|
|
10
9
|
import { readPhiBoundContentEntry } from "../../content-entries/record-source.server";
|
|
11
10
|
import { buildPhiEntryViews } from "./view.server";
|
|
@@ -27,7 +26,7 @@ import { pickPhiSequenceSettings } from "../../../../../components/widgets/confi
|
|
|
27
26
|
* as that record carries. And with nothing related -- or nothing to be related to -- it draws
|
|
28
27
|
* nothing at all: a "more like this" heading over an empty space says something false.
|
|
29
28
|
*/
|
|
30
|
-
export async function PhiEntryListWidget({ config, runtime, registry, links,
|
|
29
|
+
export async function PhiEntryListWidget({ config, runtime, registry, links, widgetId, }) {
|
|
31
30
|
const settings = normalizePhiEntryListWidgetConfig(config);
|
|
32
31
|
const renderMode = readPhiRuntimeTreeRenderMode(config ?? {});
|
|
33
32
|
const rt = phiRuntime(runtime);
|
|
@@ -81,7 +80,8 @@ export async function PhiEntryListWidget({ config, runtime, registry, links, tra
|
|
|
81
80
|
// A stacked entry's title is an `h2`; its text's headings start under it.
|
|
82
81
|
headingOffset: 2,
|
|
83
82
|
});
|
|
84
|
-
|
|
83
|
+
// The heading arrives translated (server-helpers/cms-widget-texts.ts).
|
|
84
|
+
const title = settings.title;
|
|
85
85
|
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.EntryList, componentProps: {
|
|
86
86
|
entries: views,
|
|
87
87
|
labels,
|
|
@@ -21,18 +21,16 @@ export async function PhiImageWidgetServer({ runtime, widget, config, translate:
|
|
|
21
21
|
/*
|
|
22
22
|
* The picture's description and title in the page's language, as every other Widget's words.
|
|
23
23
|
*
|
|
24
|
-
* A Content record's text arrives translated already and is taken as it is
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* A Content record's text arrives translated already and is taken as it is, and so does what the
|
|
25
|
+
* Widget's config states for an address (server-helpers/cms-widget-texts.ts). The Asset's own
|
|
26
|
+
* description from the Media library is the Site's text and goes through the Site's translation.
|
|
27
27
|
*/
|
|
28
28
|
const translate = translateWords ?? !hasPhiFlag(widget?.flags ?? 0, PhiCmsFlags.NoTranslate);
|
|
29
29
|
const sourceTexts = [
|
|
30
30
|
recordAlt ? "" : (resolvedAsset?.altText ?? "").trim(),
|
|
31
31
|
recordTitle ? "" : (resolvedAsset?.title ?? "").trim(),
|
|
32
|
-
config?.sourceKind === "asset" ? "" : (config?.alt ?? "").trim(),
|
|
33
|
-
config?.sourceKind === "asset" ? "" : (config?.title ?? "").trim(),
|
|
34
32
|
];
|
|
35
|
-
const [assetAlt, assetTitle
|
|
33
|
+
const [assetAlt, assetTitle] = translate && sourceTexts.some(Boolean)
|
|
36
34
|
? await (runtime.locale.current ? trBulkForLocale(runtime.locale.current, sourceTexts) : trBulk(sourceTexts))
|
|
37
35
|
: sourceTexts;
|
|
38
36
|
const contentResolvedAsset = resolvedAsset
|
|
@@ -42,9 +40,7 @@ export async function PhiImageWidgetServer({ runtime, widget, config, translate:
|
|
|
42
40
|
altText: recordAlt || assetAlt || resolvedAsset.altText,
|
|
43
41
|
}
|
|
44
42
|
: null;
|
|
45
|
-
const translatedConfig = config
|
|
46
|
-
? { ...config, ...(configAlt ? { alt: configAlt } : {}), ...(configTitle ? { title: configTitle } : {}) }
|
|
47
|
-
: config;
|
|
43
|
+
const translatedConfig = config;
|
|
48
44
|
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Image, componentProps: {
|
|
49
45
|
labels,
|
|
50
46
|
config: translatedConfig ?? undefined,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
3
|
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
|
-
import { trForLocale } from "../../../../../server-helpers/translate";
|
|
5
4
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
6
5
|
import { parsePhiCmsMarkdownWidgetConfig } from "../markdown/config";
|
|
7
6
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
|
|
@@ -26,11 +25,10 @@ function filterHeadings(headings, config) {
|
|
|
26
25
|
}
|
|
27
26
|
export async function PhiMarkdownTocWidget({ config, defaultLabels, tree, runtime, }) {
|
|
28
27
|
/*
|
|
29
|
-
* The author's title
|
|
30
|
-
*
|
|
28
|
+
* The author's title arrives translated (server-helpers/cms-widget-texts.ts); the default is a label
|
|
29
|
+
* set's and arrives translated too.
|
|
31
30
|
*/
|
|
32
|
-
const
|
|
33
|
-
const title = ownTitle ? await trForLocale(runtime.locale.current, ownTitle) : defaultLabels.title;
|
|
31
|
+
const title = config?.title?.trim() || defaultLabels.title;
|
|
34
32
|
const targetWidget = resolveTargetMarkdownWidget(tree, config);
|
|
35
33
|
if (!targetWidget) {
|
|
36
34
|
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.MarkdownToc, componentProps: { config: { ...config, title, headings: [] } } }));
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
-
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
2
|
import { PhiQuickLinksWidget } from "./server";
|
|
5
3
|
import { PHI_QUICK_LINKS_WIDGET_DEFINITION, PHI_QUICK_LINKS_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
6
4
|
export const PHI_QUICK_LINKS_WIDGET_PLUGIN = {
|
|
7
5
|
...PHI_QUICK_LINKS_WIDGET_DEFINITION,
|
|
8
|
-
render: ({ widget, runtime, config }) => (_jsx(PhiQuickLinksWidget, { runtime: runtime, navKey: config.navKey, title: config.title,
|
|
9
|
-
renderPreview: ({ widget, runtime, config }) => (_jsx(PhiQuickLinksWidget, { runtime: runtime, navKey: config.navKey, title: config.title,
|
|
6
|
+
render: ({ widget, runtime, config }) => (_jsx(PhiQuickLinksWidget, { runtime: runtime, navKey: config.navKey, title: config.title, columns: config.columns, separator: config.separator }, `widget-${widget.id}`)),
|
|
7
|
+
renderPreview: ({ widget, runtime, config }) => (_jsx(PhiQuickLinksWidget, { runtime: runtime, navKey: config.navKey, title: config.title, columns: config.columns, separator: config.separator, interactive: false }, `widget-${widget.id}`)),
|
|
10
8
|
};
|
|
11
9
|
export { PHI_QUICK_LINKS_WIDGET_PLUGIN_TYPE };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { PhiBlockRuntime } from "../../../../../types";
|
|
2
|
-
import type { PhiTextSource } from "../../../../../helpers/text-source";
|
|
3
2
|
export type PhiQuickLinksWidgetProps = {
|
|
4
3
|
runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area" | "viewer" | "request">;
|
|
5
4
|
navKey?: string;
|
|
5
|
+
/** In the reader's language already: a Widget's arrives translated (server-helpers/cms-widget-texts.ts). */
|
|
6
6
|
title?: string;
|
|
7
|
-
/** Whose words the title is, which decides the store that translates it. */
|
|
8
|
-
textSource?: PhiTextSource;
|
|
9
|
-
translate?: boolean;
|
|
10
7
|
columns?: 1 | 2 | 3;
|
|
11
8
|
separator?: boolean;
|
|
12
9
|
interactive?: boolean;
|
|
13
10
|
};
|
|
14
|
-
export declare function PhiQuickLinksWidget({ runtime, navKey, title,
|
|
11
|
+
export declare function PhiQuickLinksWidget({ runtime, navKey, title, columns, separator, interactive, }: PhiQuickLinksWidgetProps): Promise<import("react").JSX.Element | null>;
|
|
@@ -3,18 +3,14 @@ import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
|
3
3
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
|
|
4
4
|
import { resolvePhiNavigationItems } from "../../../../../components/widgets/server/navigation-request";
|
|
5
5
|
import { mapPhiNavItemsToQuickLinksItems } from "./items";
|
|
6
|
-
|
|
7
|
-
export async function PhiQuickLinksWidget({ runtime, navKey, title, textSource, translate = true, columns = 2, separator = true, interactive = true, }) {
|
|
6
|
+
export async function PhiQuickLinksWidget({ runtime, navKey, title, columns = 2, separator = true, interactive = true, }) {
|
|
8
7
|
const resolvedNavKey = navKey?.trim() ||
|
|
9
8
|
`${runtime.area}:footer`;
|
|
10
9
|
const resolvedNavigationItems = (await resolvePhiNavigationItems(runtime, resolvedNavKey)) ?? [];
|
|
11
10
|
if (resolvedNavigationItems.length === 0) {
|
|
12
11
|
return null;
|
|
13
12
|
}
|
|
14
|
-
const
|
|
15
|
-
const labels = {
|
|
16
|
-
title: ownTitle && translate ? await trWidgetText(runtime.locale.current, ownTitle, textSource) : title,
|
|
17
|
-
};
|
|
13
|
+
const labels = { title };
|
|
18
14
|
const config = {
|
|
19
15
|
columns,
|
|
20
16
|
separator,
|
|
@@ -35,7 +35,6 @@ export declare const PHI_RESULT_WIDGET_DEFINITION: {
|
|
|
35
35
|
category: "content";
|
|
36
36
|
description: string;
|
|
37
37
|
iconFamily: string;
|
|
38
|
-
translatesOwnText: true;
|
|
39
38
|
slotSizePolicy: "intrinsic";
|
|
40
39
|
fields: (({
|
|
41
40
|
key: string;
|
|
@@ -49,6 +48,7 @@ export declare const PHI_RESULT_WIDGET_DEFINITION: {
|
|
|
49
48
|
type: "string" | "url" | "icon";
|
|
50
49
|
emptyValue?: "";
|
|
51
50
|
placeholder?: string;
|
|
51
|
+
text?: false | "label" | "message";
|
|
52
52
|
}) | ({
|
|
53
53
|
key: string;
|
|
54
54
|
label: string;
|
|
@@ -52,7 +52,6 @@ export const PHI_RESULT_WIDGET_DEFINITION = {
|
|
|
52
52
|
* moves nothing. A Result that ends a page still fills one -- by being put in a slot that is that
|
|
53
53
|
* wide, which is the layout's business rather than the widget's.
|
|
54
54
|
*/
|
|
55
|
-
translatesOwnText: true,
|
|
56
55
|
slotSizePolicy: "intrinsic",
|
|
57
56
|
fields: [
|
|
58
57
|
...PHI_RENDERABLE_BLOCK_GEOMETRY_FIELDS,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
-
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
2
|
import { PHI_RESULT_WIDGET_DEFINITION, } from "./config";
|
|
5
3
|
import { PhiResultWidget } from "./server";
|
|
6
4
|
export const PHI_RESULT_WIDGET_PLUGIN = {
|
|
7
5
|
...PHI_RESULT_WIDGET_DEFINITION,
|
|
8
|
-
render: ({ widget, config, runtime }) => (_jsx(PhiResultWidget, { config: config, runtime: runtime
|
|
6
|
+
render: ({ widget, config, runtime }) => (_jsx(PhiResultWidget, { config: config, runtime: runtime }, `widget-${widget.id}`)),
|
|
9
7
|
renderPreview: ({ widget, config, runtime }) => (_jsx(PhiResultWidget, { config: {
|
|
10
8
|
...config,
|
|
11
9
|
renderMode: "preview",
|
|
12
|
-
}, runtime: runtime
|
|
10
|
+
}, runtime: runtime }, `widget-preview-${widget.id}`)),
|
|
13
11
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { PhiBlockRuntime } from "../../../../../types";
|
|
2
2
|
import { type PhiCmsResultWidgetConfig } from "./config";
|
|
3
3
|
export type PhiResultWidgetProps = {
|
|
4
|
+
/** Its own words arrive translated (server-helpers/cms-widget-texts.ts). */
|
|
4
5
|
config?: PhiCmsResultWidgetConfig;
|
|
5
6
|
runtime: PhiBlockRuntime;
|
|
6
|
-
/** Whether the Widget's own text is translated, which the node's `NoTranslate` flag turns off. */
|
|
7
|
-
translate: boolean;
|
|
8
7
|
};
|
|
9
|
-
export declare function PhiResultWidget({ config, runtime
|
|
8
|
+
export declare function PhiResultWidget({ config, runtime }: PhiResultWidgetProps): Promise<import("react").JSX.Element>;
|
|
@@ -5,43 +5,21 @@ import { PHI_RESULT_HOME_LINK_SOURCE_LABEL } from "./config";
|
|
|
5
5
|
import { localizeAreaPath } from "../../../../../helpers/locale";
|
|
6
6
|
import { PhiResultWidgetBody } from "../../../../../components/widgets/shared/result-body";
|
|
7
7
|
/**
|
|
8
|
-
* The
|
|
9
|
-
*
|
|
10
|
-
* A Preset's title and subtitle -- the error pages' "Not found" -- are the platform's and come from the
|
|
11
|
-
* global store; an author's are the Site's. The home link's default label is the Widget's own sentence,
|
|
12
|
-
* so it is the platform's whoever placed the Widget.
|
|
8
|
+
* The home link's label where nobody wrote one: the Widget's own sentence, so the platform's whoever
|
|
9
|
+
* placed the Widget, and translated from the global store.
|
|
13
10
|
*/
|
|
14
|
-
async function
|
|
11
|
+
async function resolveResultHomeLinkLabel(config, runtime) {
|
|
12
|
+
const authored = config?.homeLinkLabel?.trim();
|
|
13
|
+
if (authored)
|
|
14
|
+
return authored;
|
|
15
|
+
const translated = await trWidgetText(runtime.locale.current, PHI_RESULT_HOME_LINK_SOURCE_LABEL, PHI_TEXT_SOURCE_PRESET);
|
|
16
|
+
return translated.trim() || PHI_RESULT_HOME_LINK_SOURCE_LABEL;
|
|
17
|
+
}
|
|
18
|
+
export async function PhiResultWidget({ config, runtime }) {
|
|
15
19
|
const code = config?.code?.trim();
|
|
16
20
|
const title = config?.title?.trim();
|
|
17
21
|
const subTitle = config?.subTitle?.trim();
|
|
18
|
-
const
|
|
19
|
-
const homeLinkLabel = authoredHomeLinkLabel || PHI_RESULT_HOME_LINK_SOURCE_LABEL;
|
|
20
|
-
const shouldTranslate = translate &&
|
|
21
|
-
config?.renderMode !== "preview" &&
|
|
22
|
-
config?.renderMode !== "editor";
|
|
23
|
-
if (!shouldTranslate) {
|
|
24
|
-
return { code, title, subTitle, homeLinkLabel };
|
|
25
|
-
}
|
|
26
|
-
const locale = runtime.locale.current;
|
|
27
|
-
const textSource = config?.textSource;
|
|
28
|
-
const translateText = async (value) => value ? (await trWidgetText(locale, value, textSource)).trim() || value : value;
|
|
29
|
-
const [translatedTitle, translatedSubTitle, translatedHomeLinkLabel] = await Promise.all([
|
|
30
|
-
translateText(title),
|
|
31
|
-
translateText(subTitle),
|
|
32
|
-
authoredHomeLinkLabel
|
|
33
|
-
? translateText(authoredHomeLinkLabel)
|
|
34
|
-
: trWidgetText(locale, PHI_RESULT_HOME_LINK_SOURCE_LABEL, PHI_TEXT_SOURCE_PRESET),
|
|
35
|
-
]);
|
|
36
|
-
return {
|
|
37
|
-
code,
|
|
38
|
-
title: translatedTitle,
|
|
39
|
-
subTitle: translatedSubTitle,
|
|
40
|
-
homeLinkLabel: translatedHomeLinkLabel?.trim() || homeLinkLabel,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export async function PhiResultWidget({ config, runtime, translate }) {
|
|
44
|
-
const { code, title, subTitle, homeLinkLabel } = await resolveResultText({ config, runtime, translate });
|
|
22
|
+
const homeLinkLabel = await resolveResultHomeLinkLabel(config, runtime);
|
|
45
23
|
/*
|
|
46
24
|
* Resolved here rather than configured: the root of the Area this result was rendered in, in the
|
|
47
25
|
* locale it was rendered for. `localizeAreaPath` is the same answer the navigation gives.
|
|
@@ -50,18 +50,21 @@ export declare const PHI_SLIDER_WIDGET_DEFINITION: {
|
|
|
50
50
|
label: string;
|
|
51
51
|
min?: undefined;
|
|
52
52
|
options?: undefined;
|
|
53
|
+
text?: undefined;
|
|
53
54
|
} | {
|
|
54
55
|
key: string;
|
|
55
56
|
type: "number";
|
|
56
57
|
label: string;
|
|
57
58
|
min?: undefined;
|
|
58
59
|
options?: undefined;
|
|
60
|
+
text?: undefined;
|
|
59
61
|
} | {
|
|
60
62
|
key: string;
|
|
61
63
|
type: "number";
|
|
62
64
|
label: string;
|
|
63
65
|
min: number;
|
|
64
66
|
options?: undefined;
|
|
67
|
+
text?: undefined;
|
|
65
68
|
} | {
|
|
66
69
|
key: string;
|
|
67
70
|
type: "choice";
|
|
@@ -71,6 +74,14 @@ export declare const PHI_SLIDER_WIDGET_DEFINITION: {
|
|
|
71
74
|
label: string;
|
|
72
75
|
}[];
|
|
73
76
|
min?: undefined;
|
|
77
|
+
text?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
key: string;
|
|
80
|
+
type: "string";
|
|
81
|
+
label: string;
|
|
82
|
+
text: "label";
|
|
83
|
+
min?: undefined;
|
|
84
|
+
options?: undefined;
|
|
74
85
|
})[];
|
|
75
86
|
defaultConfig: {
|
|
76
87
|
key: string;
|
|
@@ -59,7 +59,7 @@ export const PHI_SLIDER_WIDGET_DEFINITION = {
|
|
|
59
59
|
{ value: "hidden", label: "Hidden" },
|
|
60
60
|
],
|
|
61
61
|
},
|
|
62
|
-
{ key: "tooltipSuffix", type: "string", label: "Tooltip suffix" },
|
|
62
|
+
{ key: "tooltipSuffix", type: "string", label: "Tooltip suffix", text: "label" },
|
|
63
63
|
...PHI_CONTROL_STATE_FIELDS,
|
|
64
64
|
],
|
|
65
65
|
defaultConfig: {
|
|
@@ -57,8 +57,6 @@ export const PHI_SLOT_UPLOAD_WIDGET_DEFINITION = {
|
|
|
57
57
|
],
|
|
58
58
|
defaultConfig: { ownerParam: "id" },
|
|
59
59
|
parseConfig: parsePhiSlotUploadWidgetConfig,
|
|
60
|
-
// The label is written into the config, so the Widget translates it on the server.
|
|
61
|
-
translatesOwnText: true,
|
|
62
60
|
runtimeSignals: {
|
|
63
61
|
emits: [
|
|
64
62
|
// So whatever shows the row can read it again. What changed is the row, not this widget.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
-
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
2
|
import { PHI_SLOT_UPLOAD_WIDGET_DEFINITION } from "./config";
|
|
5
3
|
import { PhiSlotUploadWidget } from "./server";
|
|
6
4
|
export const PHI_SLOT_UPLOAD_WIDGET_PLUGIN = {
|
|
7
5
|
...PHI_SLOT_UPLOAD_WIDGET_DEFINITION,
|
|
8
|
-
render: ({
|
|
9
|
-
renderPreview: ({
|
|
6
|
+
render: ({ config, runtime }) => _jsx(PhiSlotUploadWidget, { config: config, runtime: runtime }),
|
|
7
|
+
renderPreview: ({ config, runtime }) => (_jsx(PhiSlotUploadWidget, { config: { ...config, renderMode: "preview" }, runtime: runtime })),
|
|
10
8
|
};
|
|
@@ -4,11 +4,10 @@ import { type PhiSlotUploadWidgetConfig } from "./config";
|
|
|
4
4
|
/**
|
|
5
5
|
* Handed to the Render Client by type: what a slot holds depends on who is asking and on which row a
|
|
6
6
|
* surface is about, and neither is knowable where a page is rendered for a cache. Its texts are read
|
|
7
|
-
* here, in the page's language, and travel with it: the field's own captions from its Label Set
|
|
8
|
-
* label somebody wrote into the config
|
|
7
|
+
* here, in the page's language, and travel with it: the field's own captions from its Label Set; the
|
|
8
|
+
* label somebody wrote into the config arrives translated (server-helpers/cms-widget-texts.ts).
|
|
9
9
|
*/
|
|
10
|
-
export declare function PhiSlotUploadWidget({ config, runtime,
|
|
10
|
+
export declare function PhiSlotUploadWidget({ config, runtime, }: {
|
|
11
11
|
config?: PhiSlotUploadWidgetConfig;
|
|
12
12
|
runtime: PhiBlockRuntime;
|
|
13
|
-
translate?: boolean;
|
|
14
13
|
}): Promise<import("react").JSX.Element>;
|
|
@@ -3,22 +3,14 @@ import "server-only";
|
|
|
3
3
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../runtime-render-client";
|
|
4
4
|
import { getPhiSlotUploadWidgetLabels } from "../../../../../components/widgets/label-sets/slot-upload";
|
|
5
5
|
import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
|
|
6
|
-
import { trBulk, trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
7
6
|
import { PHI_SLOT_UPLOAD_WIDGET_TYPE } from "./config";
|
|
8
7
|
/**
|
|
9
8
|
* Handed to the Render Client by type: what a slot holds depends on who is asking and on which row a
|
|
10
9
|
* surface is about, and neither is knowable where a page is rendered for a cache. Its texts are read
|
|
11
|
-
* here, in the page's language, and travel with it: the field's own captions from its Label Set
|
|
12
|
-
* label somebody wrote into the config
|
|
10
|
+
* here, in the page's language, and travel with it: the field's own captions from its Label Set; the
|
|
11
|
+
* label somebody wrote into the config arrives translated (server-helpers/cms-widget-texts.ts).
|
|
13
12
|
*/
|
|
14
|
-
export async function PhiSlotUploadWidget({ config, runtime,
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
getPhiSlotUploadWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime)),
|
|
18
|
-
translate && label
|
|
19
|
-
? (runtime.locale.current ? trBulkForLocale(runtime.locale.current, [label]) : trBulk([label]))
|
|
20
|
-
.then(([text]) => text?.trim() || label)
|
|
21
|
-
: Promise.resolve(label),
|
|
22
|
-
]);
|
|
23
|
-
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PHI_SLOT_UPLOAD_WIDGET_TYPE, componentProps: { config: config && translatedLabel ? { ...config, label: translatedLabel } : config, labels } }));
|
|
13
|
+
export async function PhiSlotUploadWidget({ config, runtime, }) {
|
|
14
|
+
const labels = await getPhiSlotUploadWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
|
|
15
|
+
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PHI_SLOT_UPLOAD_WIDGET_TYPE, componentProps: { config, labels } }));
|
|
24
16
|
}
|
|
@@ -10,7 +10,7 @@ export declare const PHI_SPACER_WIDGET_DEFINITION: {
|
|
|
10
10
|
category: "structure";
|
|
11
11
|
icon: string;
|
|
12
12
|
iconFamily: string;
|
|
13
|
-
slotSizePolicy: "
|
|
13
|
+
slotSizePolicy: "rest";
|
|
14
14
|
fields: never[];
|
|
15
15
|
parseConfig: (config: Record<string, unknown>) => PhiSpacerWidgetConfig;
|
|
16
16
|
};
|
|
@@ -9,7 +9,7 @@ export const PHI_SPACER_WIDGET_DEFINITION = {
|
|
|
9
9
|
category: "structure",
|
|
10
10
|
icon: "antd:column-width-outlined",
|
|
11
11
|
iconFamily: "layout",
|
|
12
|
-
slotSizePolicy: "
|
|
12
|
+
slotSizePolicy: "rest",
|
|
13
13
|
fields: [],
|
|
14
14
|
parseConfig: (config) => readRenderableBlockConfig(config),
|
|
15
15
|
};
|
|
@@ -18,13 +18,18 @@ export declare const PHI_STEPS_WIDGET_DEFINITION: {
|
|
|
18
18
|
kind: "widget";
|
|
19
19
|
pluginKey: string;
|
|
20
20
|
typeKey: string;
|
|
21
|
-
translatesOwnText: true;
|
|
22
21
|
title: string;
|
|
23
22
|
description: string;
|
|
24
23
|
category: "content";
|
|
25
24
|
icon: string;
|
|
26
25
|
iconFamily: string;
|
|
27
|
-
slotSizePolicy:
|
|
26
|
+
slotSizePolicy: {
|
|
27
|
+
configField: string;
|
|
28
|
+
byValue: {
|
|
29
|
+
vertical: "intrinsic";
|
|
30
|
+
};
|
|
31
|
+
otherwise: "fill-inline";
|
|
32
|
+
};
|
|
28
33
|
runtimeSignals: {
|
|
29
34
|
emits: ({
|
|
30
35
|
id: string;
|
|
@@ -15,13 +15,12 @@ export const PHI_STEPS_WIDGET_DEFINITION = {
|
|
|
15
15
|
kind: "widget",
|
|
16
16
|
pluginKey: resolvePhiCmsWidgetPluginKey("steps"),
|
|
17
17
|
typeKey: "steps",
|
|
18
|
-
translatesOwnText: true,
|
|
19
18
|
title: "Steps",
|
|
20
19
|
description: "Where a sequence stands, as numbered steps; can follow and drive a Stack.",
|
|
21
20
|
category: "content",
|
|
22
21
|
icon: "antd:ordered-list-outlined",
|
|
23
22
|
iconFamily: "basic",
|
|
24
|
-
slotSizePolicy: "intrinsic",
|
|
23
|
+
slotSizePolicy: { configField: "orientation", byValue: { vertical: "intrinsic" }, otherwise: "fill-inline" },
|
|
25
24
|
runtimeSignals: {
|
|
26
25
|
...PHI_SELECT_CONTROL_SIGNALS,
|
|
27
26
|
},
|
|
@@ -1,38 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
-
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
2
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
5
3
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
|
|
6
|
-
import { trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
7
4
|
import { PHI_STEPS_WIDGET_DEFINITION } from "./config";
|
|
8
|
-
|
|
9
|
-
* The steps'
|
|
10
|
-
* they are
|
|
11
|
-
* at runtime, and those are the Stack's to translate.
|
|
5
|
+
/*
|
|
6
|
+
* The steps' titles and the lines under them arrive translated (server-helpers/cms-widget-texts.ts); the
|
|
7
|
+
* values stay as they are, they are what the steps send. Steps that follow a Stack take their titles
|
|
8
|
+
* from its slots at runtime, and those are the Stack's to translate.
|
|
12
9
|
*/
|
|
13
|
-
async function translatePhiStepsConfig(config, runtime, translate) {
|
|
14
|
-
if (!translate || config.options.length === 0)
|
|
15
|
-
return config;
|
|
16
|
-
const texts = config.options.flatMap((option) => [option.label, option.description ?? ""]);
|
|
17
|
-
const translated = await trBulkForLocale(runtime.locale.current, texts);
|
|
18
|
-
return {
|
|
19
|
-
...config,
|
|
20
|
-
options: config.options.map((option, index) => ({
|
|
21
|
-
...option,
|
|
22
|
-
label: translated[index * 2]?.trim() || option.label,
|
|
23
|
-
...(option.description ? { description: translated[index * 2 + 1]?.trim() || option.description } : {}),
|
|
24
|
-
})),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
10
|
export const PHI_STEPS_WIDGET_PLUGIN = {
|
|
28
11
|
...PHI_STEPS_WIDGET_DEFINITION,
|
|
29
|
-
render:
|
|
30
|
-
|
|
31
|
-
config: await translatePhiStepsConfig(config, runtime, !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate)),
|
|
32
|
-
} })),
|
|
33
|
-
renderPreview: async ({ widget, config, runtime }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Steps, componentProps: {
|
|
34
|
-
blockId: widget.id,
|
|
35
|
-
config: await translatePhiStepsConfig(config, runtime, !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate)),
|
|
36
|
-
signalsEnabled: false,
|
|
37
|
-
} })),
|
|
12
|
+
render: ({ widget, config }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Steps, componentProps: { blockId: widget.id, config } })),
|
|
13
|
+
renderPreview: ({ widget, config }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Steps, componentProps: { blockId: widget.id, config, signalsEnabled: false } })),
|
|
38
14
|
};
|
|
@@ -74,6 +74,7 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
|
|
|
74
74
|
type: "string" | "url" | "icon";
|
|
75
75
|
emptyValue?: "";
|
|
76
76
|
placeholder?: string;
|
|
77
|
+
text?: false | "label" | "message";
|
|
77
78
|
}) | ({
|
|
78
79
|
key: string;
|
|
79
80
|
label: string;
|
|
@@ -386,6 +387,7 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
|
|
|
386
387
|
type: "string" | "url" | "icon";
|
|
387
388
|
emptyValue?: "";
|
|
388
389
|
placeholder?: string;
|
|
390
|
+
text?: false | "label" | "message";
|
|
389
391
|
} | {
|
|
390
392
|
visibleWhen: {
|
|
391
393
|
field: string;
|
|
@@ -765,6 +767,7 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
|
|
|
765
767
|
type: "string" | "url" | "icon";
|
|
766
768
|
emptyValue?: "";
|
|
767
769
|
placeholder?: string;
|
|
770
|
+
text?: false | "label" | "message";
|
|
768
771
|
} | {
|
|
769
772
|
visibleWhen: {
|
|
770
773
|
field: string;
|
|
@@ -24,7 +24,7 @@ const PHI_TABLE_DISABLED_CONDITION_CONFIG_FIELDS = [
|
|
|
24
24
|
{ value: "contains", label: "Contains" },
|
|
25
25
|
] },
|
|
26
26
|
{ key: "value", type: "string", label: "String Value" },
|
|
27
|
-
{ key: "reason", type: "string", label: "Disabled Reason" },
|
|
27
|
+
{ key: "reason", type: "string", label: "Disabled Reason", text: "message" },
|
|
28
28
|
];
|
|
29
29
|
function buildPhiTableConditionExpressionConfigFields(key, label, match, emptyLabel) {
|
|
30
30
|
return [
|
|
@@ -17,7 +17,6 @@ export declare const PHI_TIMELINE_WIDGET_DEFINITION: {
|
|
|
17
17
|
kind: "widget";
|
|
18
18
|
pluginKey: string;
|
|
19
19
|
typeKey: string;
|
|
20
|
-
translatesOwnText: true;
|
|
21
20
|
title: string;
|
|
22
21
|
description: string;
|
|
23
22
|
category: "content";
|
|
@@ -52,11 +51,19 @@ export declare const PHI_TIMELINE_WIDGET_DEFINITION: {
|
|
|
52
51
|
type: "string";
|
|
53
52
|
label: string;
|
|
54
53
|
required: true;
|
|
54
|
+
text?: undefined;
|
|
55
55
|
} | {
|
|
56
56
|
key: string;
|
|
57
57
|
type: "string";
|
|
58
58
|
label: string;
|
|
59
59
|
required?: undefined;
|
|
60
|
+
text?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
key: string;
|
|
63
|
+
type: "string";
|
|
64
|
+
label: string;
|
|
65
|
+
text: "message";
|
|
66
|
+
required?: undefined;
|
|
60
67
|
})[];
|
|
61
68
|
providerKind?: undefined;
|
|
62
69
|
heading?: undefined;
|
|
@@ -26,7 +26,6 @@ export const PHI_TIMELINE_WIDGET_DEFINITION = {
|
|
|
26
26
|
kind: "widget",
|
|
27
27
|
pluginKey: resolvePhiCmsWidgetPluginKey("timeline"),
|
|
28
28
|
typeKey: "timeline",
|
|
29
|
-
translatesOwnText: true,
|
|
30
29
|
title: "Timeline",
|
|
31
30
|
description: "What happened, in order: entries with a time, a title and a line of text.",
|
|
32
31
|
category: "content",
|
|
@@ -63,7 +62,7 @@ export const PHI_TIMELINE_WIDGET_DEFINITION = {
|
|
|
63
62
|
itemFields: [
|
|
64
63
|
{ key: "key", type: "string", label: "Key", required: true },
|
|
65
64
|
{ key: "title", type: "string", label: "Title" },
|
|
66
|
-
{ key: "content", type: "string", label: "Text" },
|
|
65
|
+
{ key: "content", type: "string", label: "Text", text: "message" },
|
|
67
66
|
],
|
|
68
67
|
},
|
|
69
68
|
{ key: "entriesProvider", type: "data-provider", providerKind: "timeline", label: "Entries Source" },
|