@phis/ui 0.5.4 → 0.5.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 +17 -7
- package/components/controls/phi-anchor-nav-control.js +18 -1
- 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/components/widgets/shared/card-body-client.d.ts +6 -2
- package/components/widgets/shared/card-body-client.js +27 -20
- package/components/widgets/shared/card-vocabulary.d.ts +7 -0
- package/components/widgets/shared/card-vocabulary.js +6 -0
- package/components/widgets/shared/markdown-body-client.js +7 -2
- package/constants/module-identity.d.ts +8 -0
- package/constants/module-identity.js +13 -0
- package/gateway/server-module-media.d.ts +12 -0
- package/gateway/server-module-media.js +83 -0
- package/helpers/cms-navigation-catalog.js +4 -1
- package/helpers/cms-page-catalog.d.ts +7 -0
- package/helpers/cms-preset-page-tree.js +16 -1
- package/helpers/config-text-fields.d.ts +49 -0
- package/helpers/config-text-fields.js +122 -0
- package/helpers/module-media-check.d.ts +23 -0
- package/helpers/module-media-check.js +32 -0
- package/helpers/module-media.d.ts +7 -0
- package/helpers/module-media.js +15 -0
- package/helpers/preset-text-source-check.d.ts +22 -0
- package/helpers/preset-text-source-check.js +45 -0
- package/helpers/route-address-check.d.ts +35 -0
- package/helpers/route-address-check.js +28 -0
- package/helpers/text-source.d.ts +14 -5
- package/helpers/text-source.js +16 -3
- package/module-page-check.d.ts +3 -0
- package/module-page-check.js +3 -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/area-shell-presets.server.js +2 -0
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
- package/plugins/runtime-modules/builder/navigation-folder-drop.js +2 -1
- package/plugins/runtime-modules/builder/options-providers.js +7 -1
- package/plugins/runtime-modules/builder/page-presets.server.js +2 -0
- 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/breadcrumb/server.js +9 -2
- 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 +24 -2
- package/plugins/runtime-modules/core/widgets/card/config.js +35 -3
- package/plugins/runtime-modules/core/widgets/card/editor.js +2 -0
- 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 +18 -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/descriptor-compiler.d.ts +23 -3
- package/plugins/runtime-modules/descriptor-compiler.js +107 -12
- 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-area.js +9 -1
- package/server-helpers/cms-request.js +49 -14
- package/server-helpers/cms-root.js +2 -0
- package/server-helpers/cms-widget-texts.d.ts +14 -0
- package/server-helpers/cms-widget-texts.js +117 -0
- package/server-helpers/module-folder-targets.d.ts +7 -0
- package/server-helpers/module-folder-targets.js +15 -0
- package/server-helpers/search-index.js +12 -3
- package/styles/root.css +6 -2
- package/types/cms-module-descriptors.d.ts +24 -0
- package/types/cms-plugins.d.ts +30 -5
- package/types/core-widget-placements.d.ts +5 -0
- package/types/module-media.d.ts +31 -0
- package/types/module-media.js +11 -0
- package/types/slot-size-policy.d.ts +19 -2
- package/types.d.ts +1 -0
|
@@ -8,7 +8,7 @@ import { readPhiMediaImageSourceConfig } from "../../../../../components/widgets
|
|
|
8
8
|
import { PHI_SURFACE_CARD } from "../../../../../helpers/surface-presets";
|
|
9
9
|
import { normalizePhiBackgroundWidgetConfig } from "../../../../../components/widgets/config/background";
|
|
10
10
|
import { buildPhiBulletListFields, readPhiBulletListEntries, readPhiBulletListStyle, } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
|
|
11
|
-
import { PHI_CARD_HEADING_LEVELS, PHI_CARD_HOVER_EFFECTS, PHI_CARD_ICON_PLACEMENTS, PHI_CARD_TEXT_ALIGNS, PHI_CARD_BADGE_STYLES, PHI_CARD_MEDIA_ASPECT_RATIOS, PHI_CARD_VARIANTS, readPhiCardBillingPeriod, } from "../../../../../components/widgets/shared/card-vocabulary";
|
|
11
|
+
import { PHI_CARD_HEADING_LEVELS, PHI_CARD_HOVER_EFFECTS, PHI_CARD_ICON_PLACEMENTS, PHI_CARD_ICON_SIZES, PHI_CARD_TEXT_ALIGNS, PHI_CARD_BADGE_STYLES, PHI_CARD_MEDIA_ASPECT_RATIOS, PHI_CARD_VARIANTS, readPhiCardBillingPeriod, } from "../../../../../components/widgets/shared/card-vocabulary";
|
|
12
12
|
import { readPhiControlLabel } from "../../../../../components/widgets/config/common-action-field";
|
|
13
13
|
import { PHI_CARD_SIGNALS } from "../../../../../components/widgets/signals/control-signal-capabilities";
|
|
14
14
|
import { readPhiSignalRouteSet } from "../../../../../types/signals";
|
|
@@ -51,6 +51,8 @@ function parsePhiCmsCardWidgetConfig(config) {
|
|
|
51
51
|
iconPlacement: readChoice(readString(config.iconPlacement), PHI_CARD_ICON_PLACEMENTS),
|
|
52
52
|
iconColor: readString(config.iconColor),
|
|
53
53
|
iconBackground: readString(config.iconBackground),
|
|
54
|
+
iconSize: readChoice(readString(config.iconSize), PHI_CARD_ICON_SIZES),
|
|
55
|
+
iconFramed: readBoolean(config.iconFramed),
|
|
54
56
|
alt: readString(config.alt),
|
|
55
57
|
mediaAspectRatio: readChoice(readString(config.mediaAspectRatio), PHI_CARD_MEDIA_ASPECT_RATIOS),
|
|
56
58
|
imageOpacity: readPhiCardImageOpacity(config.imageOpacity),
|
|
@@ -84,6 +86,8 @@ const PHI_CARD_DEFAULT_CONFIG = {
|
|
|
84
86
|
headingLevel: "h3",
|
|
85
87
|
textAlign: "start",
|
|
86
88
|
badgeStyle: "none",
|
|
89
|
+
// Shown on in the Inspector; the reader treats an absent value as framed all the same.
|
|
90
|
+
iconFramed: true,
|
|
87
91
|
};
|
|
88
92
|
export const PHI_CARD_WIDGET_DEFINITION = {
|
|
89
93
|
kind: "widget",
|
|
@@ -94,7 +98,22 @@ export const PHI_CARD_WIDGET_DEFINITION = {
|
|
|
94
98
|
description: "Content card with a picture or an icon, a heading or a figure, and a link.",
|
|
95
99
|
icon: "antd:idcard-outlined",
|
|
96
100
|
iconFamily: "basic",
|
|
97
|
-
|
|
101
|
+
/*
|
|
102
|
+
* The card's words are written on the canvas, not in Inspector fields, so the card names them for the
|
|
103
|
+
* renderer's translation (TRANSLATIONS.md, "Widget config text"); a plan line's values stay out of it.
|
|
104
|
+
*/
|
|
105
|
+
configTexts: [
|
|
106
|
+
{ key: "eyebrow", register: "label" },
|
|
107
|
+
{ key: "title", register: "label" },
|
|
108
|
+
{ key: "description", register: "message" },
|
|
109
|
+
{ key: "meta", register: "label" },
|
|
110
|
+
{ key: "actionLabel", register: "label" },
|
|
111
|
+
{ key: "badge", register: "label" },
|
|
112
|
+
{ key: "pricePeriod", register: "label" },
|
|
113
|
+
{ key: "pricePeriodYearly", register: "label" },
|
|
114
|
+
{ key: "alt", register: "label" },
|
|
115
|
+
{ key: "features", item: "text", values: "values", register: "message" },
|
|
116
|
+
],
|
|
98
117
|
/*
|
|
99
118
|
* A card fills its slot both ways, as a Layout does.
|
|
100
119
|
*
|
|
@@ -224,6 +243,18 @@ export const PHI_CARD_WIDGET_DEFINITION = {
|
|
|
224
243
|
// Shown with an icon, and not under the Center variant, which puts it over the picture itself.
|
|
225
244
|
visibleWhen: [{ field: "icon", notEquals: null }, { field: "variant", notEquals: "center" }],
|
|
226
245
|
},
|
|
246
|
+
{
|
|
247
|
+
key: "iconSize",
|
|
248
|
+
type: "choice",
|
|
249
|
+
label: "Icon size",
|
|
250
|
+
options: [
|
|
251
|
+
{ value: "default", label: "Default" },
|
|
252
|
+
{ value: "large", label: "Large" },
|
|
253
|
+
{ value: "xlarge", label: "Extra large" },
|
|
254
|
+
],
|
|
255
|
+
visibleWhen: { field: "icon", notEquals: null },
|
|
256
|
+
},
|
|
257
|
+
{ key: "iconFramed", type: "boolean", label: "Icon ground", visibleWhen: { field: "icon", notEquals: null } },
|
|
227
258
|
/* Left empty, the Theme's: the secondary text colour on its quietest fill. */
|
|
228
259
|
{
|
|
229
260
|
key: "iconColor",
|
|
@@ -239,7 +270,8 @@ export const PHI_CARD_WIDGET_DEFINITION = {
|
|
|
239
270
|
label: "Background",
|
|
240
271
|
mode: "single",
|
|
241
272
|
defaultToken: "colorFillQuaternary",
|
|
242
|
-
|
|
273
|
+
// Without a ground there is nothing to colour.
|
|
274
|
+
visibleWhen: [{ field: "icon", notEquals: null }, { field: "iconFramed", notEquals: false }],
|
|
243
275
|
},
|
|
244
276
|
/*
|
|
245
277
|
* Where the whole card leads, and how it answers the pointer: only a card that leads somewhere has
|
|
@@ -170,6 +170,8 @@ export function PhiCardWidgetEditor({ config, onChange }) {
|
|
|
170
170
|
iconPlacement: config.iconPlacement,
|
|
171
171
|
iconColor: config.iconColor,
|
|
172
172
|
iconBackground: config.iconBackground,
|
|
173
|
+
iconSize: config.iconSize,
|
|
174
|
+
iconFramed: config.iconFramed,
|
|
173
175
|
textAlign: config.textAlign,
|
|
174
176
|
headingLevel: config.headingLevel,
|
|
175
177
|
/*
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
-
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
|
-
import { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
|
|
5
2
|
import { PhiCardWidget } from "./server";
|
|
6
3
|
import { PHI_CARD_WIDGET_DEFINITION, PHI_CARD_WIDGET_PLUGIN_TYPE } from "./config";
|
|
7
4
|
function renderPhiCard({ widget, config, runtime, links }, preview) {
|
|
@@ -11,17 +8,17 @@ function renderPhiCard({ widget, config, runtime, links }, preview) {
|
|
|
11
8
|
description: config.description,
|
|
12
9
|
meta: config.meta,
|
|
13
10
|
actionLabel: config.actionLabel,
|
|
14
|
-
}, config: config, runtime: runtime, links: links,
|
|
11
|
+
}, config: config, runtime: runtime, links: links, preview: preview }, `widget-${widget.id}`));
|
|
15
12
|
}
|
|
16
13
|
export const PHI_CARD_WIDGET_PLUGIN = {
|
|
17
14
|
...PHI_CARD_WIDGET_DEFINITION,
|
|
18
15
|
/*
|
|
19
|
-
* The card's words as the render draws them (SEARCH.md):
|
|
20
|
-
*
|
|
16
|
+
* The card's words as the render draws them (SEARCH.md): they arrive translated by the same pass the
|
|
17
|
+
* render's do; the figure and the prices as written, which the render never translates either.
|
|
21
18
|
*/
|
|
22
|
-
searchText:
|
|
19
|
+
searchText: ({ config }) => {
|
|
23
20
|
const plan = config.body === "plan";
|
|
24
|
-
|
|
21
|
+
return [
|
|
25
22
|
config.eyebrow,
|
|
26
23
|
config.title,
|
|
27
24
|
config.description,
|
|
@@ -29,8 +26,9 @@ export const PHI_CARD_WIDGET_PLUGIN = {
|
|
|
29
26
|
config.badge,
|
|
30
27
|
config.actionEnabled ? config.actionLabel : undefined,
|
|
31
28
|
...(plan ? (config.features ?? []).map((entry) => entry.text) : []),
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
config.value,
|
|
30
|
+
...(plan ? [config.price, config.priceYearly] : []),
|
|
31
|
+
].filter((text) => typeof text === "string" && text.trim().length > 0);
|
|
34
32
|
},
|
|
35
33
|
/*
|
|
36
34
|
* Not the passive renderers' preview: that one is inert, and an inert card answers no pointer, so its
|
|
@@ -14,8 +14,7 @@ export type PhiCardWidgetLabels = {
|
|
|
14
14
|
export type PhiCardWidgetProps = PhiServerBlockBaseProps<PhiCardWidgetLabels, PhiCmsCardWidgetConfig> & {
|
|
15
15
|
links?: PhiResolvedLinkTargets | null;
|
|
16
16
|
};
|
|
17
|
-
export declare function PhiCardWidget({ labels, config, runtime, links,
|
|
18
|
-
translate: boolean;
|
|
17
|
+
export declare function PhiCardWidget({ labels, config, runtime, links, preview, }: PhiCardWidgetProps & {
|
|
19
18
|
/**
|
|
20
19
|
* The Builder's preview: the card answers the pointer as it will live -- its hover effect is what the
|
|
21
20
|
* author is looking at -- but leads nowhere and says nothing, so a click cannot leave the Builder.
|
|
@@ -10,8 +10,7 @@ import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runt
|
|
|
10
10
|
import { getPhiCardWidgetLabelsForRuntime } from "../../../../../components/widgets/label-sets/card";
|
|
11
11
|
import { PhiBulletListControl } from "../../../../../components/controls/phi-bullet-list-control";
|
|
12
12
|
import { buildPhiBulletListTree, resolvePhiBulletListStyle, } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
|
|
13
|
-
|
|
14
|
-
export async function PhiCardWidget({ labels, config, runtime, links, translate, preview = false, }) {
|
|
13
|
+
export async function PhiCardWidget({ labels, config, runtime, links, preview = false, }) {
|
|
15
14
|
/*
|
|
16
15
|
* The button's words: the author's, or none where they emptied them for an icon-only button, or the
|
|
17
16
|
* label set's when they never wrote any -- which is translated there, not here.
|
|
@@ -24,7 +23,17 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
24
23
|
const resolvedAsset = config?.sourceKind === "asset" && typeof config.assetId === "number"
|
|
25
24
|
? await resolvePhiPublicAssetReference({ runtime, assetId: config.assetId }).catch(() => null)
|
|
26
25
|
: null;
|
|
27
|
-
|
|
26
|
+
/*
|
|
27
|
+
* The card's own words arrive translated, `{site.name}` and a plan line's values filled in
|
|
28
|
+
* (server-helpers/cms-widget-texts.ts, the Card's `configTexts`). Only the Media library's
|
|
29
|
+
* description of an Asset is read here, and translated in the Site's store like every Asset's.
|
|
30
|
+
*/
|
|
31
|
+
const ownAlt = config?.alt?.trim();
|
|
32
|
+
const assetAlt = !ownAlt ? resolvedAsset?.altText?.trim() : undefined;
|
|
33
|
+
const alt = ownAlt || (assetAlt
|
|
34
|
+
? (await (runtime?.locale.current ? trBulkForLocale(runtime.locale.current, [assetAlt]) : trBulk([assetAlt])))[0]?.trim() || assetAlt
|
|
35
|
+
: undefined);
|
|
36
|
+
const translatedByKey = new Map([
|
|
28
37
|
["eyebrow", labels.eyebrow ?? config?.eyebrow],
|
|
29
38
|
["title", labels.title ?? config?.title],
|
|
30
39
|
["description", labels.description ?? config?.description],
|
|
@@ -33,33 +42,12 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
33
42
|
["badge", labels.badge ?? config?.badge],
|
|
34
43
|
["pricePeriod", plan ? labels.pricePeriod ?? config?.pricePeriod : undefined],
|
|
35
44
|
["pricePeriodYearly", plan ? labels.pricePeriodYearly ?? config?.pricePeriodYearly : undefined],
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
];
|
|
39
|
-
/*
|
|
40
|
-
* A plan's features, masked as every list entry is: their values stand as `%1` onwards and never reach
|
|
41
|
-
* a translator, and `{site.name}` is filled after (`helpers/text-placeholders.ts`).
|
|
42
|
-
*/
|
|
43
|
-
const features = plan ? (config?.features ?? []).filter((entry) => Boolean(entry.text)) : [];
|
|
44
|
-
const maskedFeatures = features.map((entry) => maskPhiTextPlaceholders(entry.text, entry.values?.length ?? 0));
|
|
45
|
-
const sourceTexts = [...textEntries.map(([, value]) => value ?? ""), ...maskedFeatures.map((masked) => masked.text)];
|
|
46
|
-
const translatedTexts = translate
|
|
47
|
-
? await (runtime?.locale.current
|
|
48
|
-
? trBulkForLocale(runtime.locale.current, sourceTexts)
|
|
49
|
-
: trBulk(sourceTexts))
|
|
50
|
-
: sourceTexts;
|
|
51
|
-
const translatedByKey = new Map(textEntries.map(([key], index) => [key, translatedTexts[index] || undefined]));
|
|
52
|
-
const translatedFeatures = features.map((entry, index) => ({
|
|
53
|
-
...entry,
|
|
54
|
-
text: resolvePhiTextPlaceholders(translatedTexts[textEntries.length + index] ?? entry.text, maskedFeatures[index].names, runtime, entry.values),
|
|
55
|
-
}));
|
|
45
|
+
["alt", alt],
|
|
46
|
+
]);
|
|
47
|
+
const translatedFeatures = plan ? (config?.features ?? []).filter((entry) => Boolean(entry.text)) : [];
|
|
56
48
|
/* Drawn here, so the list Control never reaches the browser with the Card (`listContent`). */
|
|
57
49
|
const featureList = translatedFeatures.length > 0 ? (_jsx(PhiBulletListControl, { listStyle: resolvePhiBulletListStyle(config?.featureList), items: buildPhiBulletListTree(translatedFeatures, (entry) => entry.text) })) : null;
|
|
58
|
-
|
|
59
|
-
* The figure is left out of the translation on purpose: a Site's own number is not a word, and
|
|
60
|
-
* `translate` is a per-Widget switch, so a stat card that turned it off to protect the figure would
|
|
61
|
-
* lose its title's translation with it.
|
|
62
|
-
*/
|
|
50
|
+
// The figure is not translated: a Site's own number is not a word (`value` is no text field).
|
|
63
51
|
const value = config?.value;
|
|
64
52
|
const presentation = resolvePhiImagePresentation({
|
|
65
53
|
sourceKind: config?.sourceKind,
|
|
@@ -105,6 +93,8 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
105
93
|
iconPlacement: config?.iconPlacement,
|
|
106
94
|
iconColor: config?.iconColor,
|
|
107
95
|
iconBackground: config?.iconBackground,
|
|
96
|
+
iconSize: config?.iconSize,
|
|
97
|
+
iconFramed: config?.iconFramed,
|
|
108
98
|
textAlign: config?.textAlign,
|
|
109
99
|
headingLevel: config?.headingLevel,
|
|
110
100
|
href: link?.href,
|
|
@@ -20,6 +20,7 @@ export declare const PHI_CASCADER_WIDGET_BUILDER_PLUGIN: {
|
|
|
20
20
|
requiredDataProviders?: readonly import("@phis/contracts/controls").PhiRuntimeDataProviderKey[] | undefined;
|
|
21
21
|
contentBinding?: (import("../../../../../types").PhiCmsWidgetContentBinding | null) | undefined;
|
|
22
22
|
translatesOwnText?: true | undefined;
|
|
23
|
+
configTexts?: readonly import("../../../../../types/cms-plugins").PhiCmsWidgetConfigText[] | undefined;
|
|
23
24
|
slotSizePolicy: import("../../../../../types").PhiSlotSizePolicy;
|
|
24
25
|
requiredRegionOwnership?: import("../../../../../helpers/cms-region-keys").PhiCmsRegionOwnership | undefined;
|
|
25
26
|
creationConfig?: Partial<PhiCascaderWidgetConfig> | undefined;
|
|
@@ -14,7 +14,13 @@ export declare const PHI_CHECKBOX_GROUP_WIDGET_DEFINITION: {
|
|
|
14
14
|
kind: "widget";
|
|
15
15
|
pluginKey: string;
|
|
16
16
|
typeKey: string;
|
|
17
|
-
slotSizePolicy:
|
|
17
|
+
slotSizePolicy: {
|
|
18
|
+
configField: string;
|
|
19
|
+
byValue: {
|
|
20
|
+
true: "intrinsic";
|
|
21
|
+
};
|
|
22
|
+
otherwise: "fill-inline";
|
|
23
|
+
};
|
|
18
24
|
title: string;
|
|
19
25
|
description: string;
|
|
20
26
|
category: "form";
|
|
@@ -18,7 +18,7 @@ export const PHI_CHECKBOX_GROUP_WIDGET_DEFINITION = {
|
|
|
18
18
|
kind: "widget",
|
|
19
19
|
pluginKey: resolvePhiCmsWidgetPluginKey("checkbox-group"),
|
|
20
20
|
typeKey: "checkbox-group",
|
|
21
|
-
slotSizePolicy: "intrinsic",
|
|
21
|
+
slotSizePolicy: { configField: "vertical", byValue: { true: "intrinsic" }, otherwise: "fill-inline" },
|
|
22
22
|
title: "Checkbox Group",
|
|
23
23
|
description: "Reusable multi-choice checkbox group with static or provider-backed options.",
|
|
24
24
|
category: "form",
|
|
@@ -69,7 +69,6 @@ export declare const PHI_ENTRY_LIST_WIDGET_DEFINITION: {
|
|
|
69
69
|
description: string;
|
|
70
70
|
category: "content";
|
|
71
71
|
tags: string[];
|
|
72
|
-
translatesOwnText: true;
|
|
73
72
|
icon: string;
|
|
74
73
|
slotSizePolicy: "fill-inline";
|
|
75
74
|
fields: (({
|
|
@@ -84,6 +83,7 @@ export declare const PHI_ENTRY_LIST_WIDGET_DEFINITION: {
|
|
|
84
83
|
type: "string" | "url" | "icon";
|
|
85
84
|
emptyValue?: "";
|
|
86
85
|
placeholder?: string;
|
|
86
|
+
text?: false | "label" | "message";
|
|
87
87
|
}) | ({
|
|
88
88
|
key: string;
|
|
89
89
|
label: string;
|
|
@@ -85,7 +85,6 @@ export const PHI_ENTRY_LIST_WIDGET_DEFINITION = {
|
|
|
85
85
|
category: "content",
|
|
86
86
|
tags: ["news", "blog", "content", "list"],
|
|
87
87
|
// The heading is the Site's own words; the entries arrive translated from Core.
|
|
88
|
-
translatesOwnText: true,
|
|
89
88
|
icon: "antd:read",
|
|
90
89
|
slotSizePolicy: "fill-inline",
|
|
91
90
|
fields: [
|
|
@@ -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 { definePhiPassiveWidgetRenderers } from "../../../../../plugins/factories/widget-renderers";
|
|
5
3
|
import { PHI_ENTRY_LIST_WIDGET_DEFINITION } from "./config";
|
|
6
4
|
import { PhiEntryListWidget } from "./server";
|
|
7
5
|
export const PHI_ENTRY_LIST_WIDGET_PLUGIN = {
|
|
8
6
|
...PHI_ENTRY_LIST_WIDGET_DEFINITION,
|
|
9
7
|
// `links` carries the detail route, resolved with every other target of the page before anything drew.
|
|
10
|
-
...definePhiPassiveWidgetRenderers(({ widget, config, runtime, registry, links }) => (_jsx(PhiEntryListWidget, { config: config, runtime: runtime, registry: registry, links: links,
|
|
8
|
+
...definePhiPassiveWidgetRenderers(({ widget, config, runtime, registry, links }) => (_jsx(PhiEntryListWidget, { config: config, runtime: runtime, registry: registry, links: links, widgetId: widget.id }, `widget-${widget.id}`))),
|
|
11
9
|
};
|
|
@@ -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.
|