@phis/ui 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/cms/phi-cms-root-layout.js +1 -1
- package/components/controls/phi-button-control.d.ts +3 -1
- package/components/controls/phi-button-control.js +2 -2
- package/components/controls/phi-collapse-control.d.ts +6 -2
- package/components/controls/phi-collapse-control.js +2 -2
- package/components/controls/phi-dialog-control.d.ts +11 -5
- package/components/controls/phi-dialog-control.js +19 -13
- package/components/controls/phi-menu-control-vocabulary.d.ts +7 -0
- package/components/controls/phi-menu-control-vocabulary.js +10 -0
- package/components/controls/phi-menu-control.d.ts +4 -1
- package/components/controls/phi-menu-control.js +6 -1
- package/components/controls/phi-text-control.d.ts +6 -1
- package/components/controls/phi-text-control.js +2 -1
- package/components/layouts/clients/phi-split-card-layout-client.js +13 -5
- package/components/layouts/clients/phi-three-column-layout-client.js +9 -3
- package/components/layouts/split-card-geometry.js +6 -2
- package/components/media/aspect-ratios.d.ts +2 -2
- package/components/menus/phi-account-menu.js +3 -1
- package/components/navigation/phi-link.js +7 -2
- package/components/navigation/use-phi-protected-mail.d.ts +11 -0
- package/components/navigation/use-phi-protected-mail.js +29 -0
- package/components/regions/clients/cms-region-container-client.js +5 -1
- package/components/regions/phi-cms-region-shell.d.ts +1 -0
- package/components/regions/phi-cms-region-shell.js +11 -0
- package/components/regions/presets/phi-area-shell-preset-nodes.d.ts +5 -0
- package/components/regions/presets/phi-area-shell-preset-nodes.js +19 -3
- package/components/root/phi-config-provider.js +16 -0
- package/components/shell/phi-cms-shell.d.ts +3 -1
- package/components/shell/phi-cms-shell.js +7 -3
- package/components/shell/phi-nav-link.js +7 -2
- package/components/shell/phi-shell-sider-drawer.d.ts +17 -0
- package/components/shell/phi-shell-sider-drawer.js +88 -0
- package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -0
- package/components/widgets/helpers/internal-reference-resolver.server.js +4 -1
- package/components/widgets/label-sets/inspector.js +2 -0
- package/components/widgets/label-sets/search-results.d.ts +4 -0
- package/components/widgets/label-sets/search-results.js +35 -0
- package/components/widgets/label-types/inspector.d.ts +2 -0
- package/components/widgets/label-types/inspector.js +1 -0
- package/components/widgets/label-types/search-results.d.ts +15 -0
- package/components/widgets/label-types/search-results.js +10 -0
- package/components/widgets/server/navigation-request.js +13 -1
- package/components/widgets/shared/card-body-client.d.ts +2 -0
- package/components/widgets/shared/card-body-client.js +8 -7
- package/components/widgets/shared/card-vocabulary.d.ts +36 -0
- package/components/widgets/shared/card-vocabulary.js +52 -0
- package/components/widgets/shared/markdown-body-client.d.ts +29 -0
- package/components/widgets/shared/markdown-body-client.js +60 -5
- package/components/widgets/shared/markdown-image-vocabulary.d.ts +31 -0
- package/components/widgets/shared/markdown-image-vocabulary.js +68 -0
- package/components/widgets/shared/markdown-render.d.ts +5 -0
- package/components/widgets/shared/markdown-render.js +123 -8
- package/components/widgets/shared/markdown-sections.d.ts +40 -0
- package/components/widgets/shared/markdown-sections.js +111 -0
- package/constants/cms-widget-types.d.ts +2 -0
- package/constants/cms-widget-types.js +4 -0
- package/gateway/site-area.d.ts +10 -7
- package/gateway/site-area.js +13 -11
- package/gateway/site-config.js +7 -1
- package/gateway/site-read-marker-listeners.d.ts +24 -0
- package/gateway/site-read-marker-listeners.js +22 -0
- package/gateway/site-search.d.ts +37 -0
- package/gateway/site-search.js +116 -0
- package/helpers/external-href.js +1 -1
- package/helpers/protected-mail.d.ts +16 -0
- package/helpers/protected-mail.js +81 -0
- package/next/areas/app.js +5 -1
- package/next/areas/public.js +5 -1
- package/next/seo-routes.js +2 -2
- package/package.json +2 -2
- package/plugins/runtime-modules/app/presets.js +23 -0
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +2 -1
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +3 -2
- package/plugins/runtime-modules/builder/clients/region-inspector.js +20 -1
- package/plugins/runtime-modules/client-manifests/common.js +8 -0
- package/plugins/runtime-modules/core/authoring-widgets.js +4 -0
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +8 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +22 -1
- package/plugins/runtime-modules/core/widgets/card/editor.js +9 -1
- package/plugins/runtime-modules/core/widgets/card/plugin.js +18 -0
- package/plugins/runtime-modules/core/widgets/card/server.js +9 -1
- package/plugins/runtime-modules/core/widgets/description/plugin.js +10 -0
- package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +2 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/header-navigation/client.d.ts +6 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/client.js +40 -13
- package/plugins/runtime-modules/core/widgets/header-navigation/config.d.ts +26 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/config.js +27 -0
- package/plugins/runtime-modules/core/widgets/header-navigation/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/server.d.ts +2 -2
- package/plugins/runtime-modules/core/widgets/header-navigation/server.js +3 -1
- package/plugins/runtime-modules/core/widgets/html/plugin.js +16 -1
- package/plugins/runtime-modules/core/widgets/html/server.d.ts +6 -0
- package/plugins/runtime-modules/core/widgets/html/server.js +12 -4
- package/plugins/runtime-modules/core/widgets/image/client.js +11 -7
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.js +46 -1
- package/plugins/runtime-modules/core/widgets/markdown/plugin.js +16 -0
- package/plugins/runtime-modules/core/widgets/markdown/server.js +22 -8
- package/plugins/runtime-modules/core/widgets/search-box/authoring.d.ts +6 -0
- package/plugins/runtime-modules/core/widgets/search-box/authoring.js +10 -0
- package/plugins/runtime-modules/core/widgets/search-box/client.d.ts +21 -0
- package/plugins/runtime-modules/core/widgets/search-box/client.js +17 -0
- package/plugins/runtime-modules/core/widgets/search-box/config.d.ts +63 -0
- package/plugins/runtime-modules/core/widgets/search-box/config.js +48 -0
- package/plugins/runtime-modules/core/widgets/search-box/plugin.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/search-box/plugin.js +11 -0
- package/plugins/runtime-modules/core/widgets/search-box/server.d.ts +21 -0
- package/plugins/runtime-modules/core/widgets/search-box/server.js +48 -0
- package/plugins/runtime-modules/core/widgets/search-results/authoring.d.ts +6 -0
- package/plugins/runtime-modules/core/widgets/search-results/authoring.js +10 -0
- package/plugins/runtime-modules/core/widgets/search-results/client.d.ts +34 -0
- package/plugins/runtime-modules/core/widgets/search-results/client.js +32 -0
- package/plugins/runtime-modules/core/widgets/search-results/config.d.ts +41 -0
- package/plugins/runtime-modules/core/widgets/search-results/config.js +39 -0
- package/plugins/runtime-modules/core/widgets/search-results/plugin.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/search-results/plugin.js +10 -0
- package/plugins/runtime-modules/core/widgets/search-results/server.d.ts +20 -0
- package/plugins/runtime-modules/core/widgets/search-results/server.js +73 -0
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +11 -0
- package/plugins/runtime-modules/core/widgets/simple-text/server.js +11 -1
- package/plugins/runtime-modules/core/widgets.js +17 -0
- package/plugins/runtime-modules/public/presets.d.ts +16 -0
- package/plugins/runtime-modules/public/presets.js +22 -0
- package/plugins/runtime-modules/public-base-page-references.d.ts +1 -0
- package/plugins/runtime-modules/public-base-page-references.js +1 -0
- package/plugins/runtime-modules/search-page-references.d.ts +20 -0
- package/plugins/runtime-modules/search-page-references.js +35 -0
- package/plugins/runtime-modules/search-page-tree.d.ts +14 -0
- package/plugins/runtime-modules/search-page-tree.js +63 -0
- package/server-helpers/search-index.d.ts +28 -0
- package/server-helpers/search-index.js +299 -0
- package/server-helpers/search-text.d.ts +40 -0
- package/server-helpers/search-text.js +152 -0
- package/server-helpers.d.ts +1 -0
- package/server-helpers.js +1 -0
- package/styles/controls.css +108 -10
- package/styles/layout.css +35 -0
- package/styles/shell.css +142 -0
- package/theme/phi-tokens.d.ts +6 -0
- package/theme/phi-tokens.js +6 -0
- package/theme.d.ts +1 -0
- package/theme.js +6 -0
- package/types/cms-plugins.d.ts +20 -2
- package/types/core-widget-placements.d.ts +5 -0
|
@@ -5,7 +5,7 @@ import type { PhiImageAssetVariantKeyValue } from "../../../../../types/media";
|
|
|
5
5
|
import { type PhiLinkTarget } from "../../../../../types/references";
|
|
6
6
|
import { type PhiBackgroundOverlay } from "../../../../../components/widgets/config/background";
|
|
7
7
|
import { type PhiBulletListEntry, type PhiBulletListStyle } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
|
|
8
|
-
import { type PhiCardBillingPeriod, type PhiCardHeadingLevel, type PhiCardHoverEffect, type PhiCardIconPlacement, type PhiCardTextAlign, type PhiCardBadgeStyle, type PhiCardVariant, type PhiCardWidgetBody } from "../../../../../components/widgets/shared/card-vocabulary";
|
|
8
|
+
import { type PhiCardBillingPeriod, type PhiCardHeadingLevel, type PhiCardHoverEffect, type PhiCardIconPlacement, type PhiCardTextAlign, type PhiCardBadgeStyle, type PhiCardMediaAspectRatio, type PhiCardVariant, type PhiCardWidgetBody } from "../../../../../components/widgets/shared/card-vocabulary";
|
|
9
9
|
import { type PhiSignalRouteSet } from "../../../../../types/signals";
|
|
10
10
|
import { type PhiCmsWidgetConfigBase } from "../../../../../components/widgets/config/parser-primitives";
|
|
11
11
|
type PhiCardImageSource = {
|
|
@@ -56,6 +56,11 @@ export type PhiCmsCardWidgetConfig = PhiCmsWidgetConfigBase & PhiCardImageSource
|
|
|
56
56
|
iconBackground?: string;
|
|
57
57
|
/** The picture's words for a reader who cannot see it; an Asset brings its own. */
|
|
58
58
|
alt?: string;
|
|
59
|
+
/**
|
|
60
|
+
* How tall the picture stands (`PHI_CARD_MEDIA_ASPECT_RATIOS`); absent is `auto`, the proportion of the
|
|
61
|
+
* file shown -- for a Media picture the Card variant's 3:2.
|
|
62
|
+
*/
|
|
63
|
+
mediaAspectRatio?: PhiCardMediaAspectRatio;
|
|
59
64
|
/** How much of the picture shows, in percent; the card's ground shows through the rest. */
|
|
60
65
|
imageOpacity?: number;
|
|
61
66
|
/**
|
|
@@ -120,6 +125,7 @@ export declare const PHI_CARD_WIDGET_DEFINITION: {
|
|
|
120
125
|
};
|
|
121
126
|
defaultConfig: {
|
|
122
127
|
body: "text";
|
|
128
|
+
mediaAspectRatio: "auto";
|
|
123
129
|
imageOpacity: number;
|
|
124
130
|
headingLevel: "h3";
|
|
125
131
|
textAlign: "start";
|
|
@@ -145,6 +151,7 @@ export declare const PHI_CARD_WIDGET_DEFINITION: {
|
|
|
145
151
|
};
|
|
146
152
|
actionLabel: string;
|
|
147
153
|
body: "text";
|
|
154
|
+
mediaAspectRatio: "auto";
|
|
148
155
|
imageOpacity: number;
|
|
149
156
|
headingLevel: "h3";
|
|
150
157
|
textAlign: "start";
|
|
@@ -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_VARIANTS, readPhiCardBillingPeriod, } from "../../../../../components/widgets/shared/card-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";
|
|
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";
|
|
@@ -52,6 +52,7 @@ function parsePhiCmsCardWidgetConfig(config) {
|
|
|
52
52
|
iconColor: readString(config.iconColor),
|
|
53
53
|
iconBackground: readString(config.iconBackground),
|
|
54
54
|
alt: readString(config.alt),
|
|
55
|
+
mediaAspectRatio: readChoice(readString(config.mediaAspectRatio), PHI_CARD_MEDIA_ASPECT_RATIOS),
|
|
55
56
|
imageOpacity: readPhiCardImageOpacity(config.imageOpacity),
|
|
56
57
|
imageOverlay: readPhiCardImageOverlay(config.imageOverlay),
|
|
57
58
|
linkTarget: readPhiLinkTarget(config.linkTarget) ?? undefined,
|
|
@@ -78,6 +79,7 @@ function parsePhiCmsCardWidgetConfig(config) {
|
|
|
78
79
|
}
|
|
79
80
|
const PHI_CARD_DEFAULT_CONFIG = {
|
|
80
81
|
body: "text",
|
|
82
|
+
mediaAspectRatio: "auto",
|
|
81
83
|
imageOpacity: 100,
|
|
82
84
|
headingLevel: "h3",
|
|
83
85
|
textAlign: "start",
|
|
@@ -177,6 +179,25 @@ export const PHI_CARD_WIDGET_DEFINITION = {
|
|
|
177
179
|
],
|
|
178
180
|
},
|
|
179
181
|
{ key: "image", type: "image", heading: "Image", label: "Image" },
|
|
182
|
+
/*
|
|
183
|
+
* Automatic is the Card variant's 3:2 for a Media picture, so a row of cards stands at one height; a
|
|
184
|
+
* step crops every card it is set on into the same box, Original shows the whole picture.
|
|
185
|
+
*/
|
|
186
|
+
{
|
|
187
|
+
key: "mediaAspectRatio",
|
|
188
|
+
type: "choice",
|
|
189
|
+
label: "Proportion",
|
|
190
|
+
options: [
|
|
191
|
+
{ value: "auto", label: "Automatic" },
|
|
192
|
+
{ value: "original", label: "Original" },
|
|
193
|
+
{ value: "phi", label: "φ (golden)" },
|
|
194
|
+
{ value: "3:2", label: "3:2" },
|
|
195
|
+
{ value: "4:3", label: "4:3" },
|
|
196
|
+
{ value: "16:9", label: "16:9" },
|
|
197
|
+
{ value: "2:1", label: "2:1" },
|
|
198
|
+
{ value: "1:1", label: "1:1" },
|
|
199
|
+
],
|
|
200
|
+
},
|
|
180
201
|
{
|
|
181
202
|
key: "imageOpacity",
|
|
182
203
|
type: "number",
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { buildPhiMediaAssetContentDeliveryUrl } from "../../../../../constants/media";
|
|
5
5
|
import { resolvePhiImagePresentation } from "../../../../../components/media/image-presentation";
|
|
6
|
+
import { resolvePhiCardImageVariantKey, resolvePhiCardMediaAspectRatioCss, resolvePhiCardMediaAspectRatioValue, } from "../../../../../components/widgets/shared/card-vocabulary";
|
|
6
7
|
import { usePhiAuthoringAssetDetails } from "../../../../../components/media/use-authoring-asset-details";
|
|
7
8
|
import { PhiInlineTextEditor } from "../../../../../components/controls/phi-inline-text-editor";
|
|
8
9
|
import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
|
|
@@ -112,7 +113,13 @@ export function PhiCardWidgetEditor({ config, onChange }) {
|
|
|
112
113
|
const presentation = resolvePhiImagePresentation({
|
|
113
114
|
sourceKind: config.sourceKind,
|
|
114
115
|
assetId,
|
|
115
|
-
|
|
116
|
+
/* The card's own variant, else the Card variant where its box is that variant's proportion. */
|
|
117
|
+
variantKey: resolvePhiCardImageVariantKey({
|
|
118
|
+
sourceKind: config.sourceKind,
|
|
119
|
+
variantKey: config.sourceKind === "asset" ? config.variantKey : null,
|
|
120
|
+
mediaAspectRatio: config.mediaAspectRatio,
|
|
121
|
+
}),
|
|
122
|
+
frameAspectRatio: resolvePhiCardMediaAspectRatioValue(config.mediaAspectRatio),
|
|
116
123
|
variantVersion: asset?.variantVersion ?? (config.sourceKind === "asset" ? config.variantVersion : null),
|
|
117
124
|
deliveryRevision: asset?.deliveryRevision,
|
|
118
125
|
originalUrl: assetId == null ? null : buildPhiMediaAssetContentDeliveryUrl(assetId),
|
|
@@ -148,6 +155,7 @@ export function PhiCardWidgetEditor({ config, onChange }) {
|
|
|
148
155
|
}, config: {
|
|
149
156
|
// A card that states no Surface has none, on the canvas as on the page: "None" is its contents.
|
|
150
157
|
surface: config.surface ?? null,
|
|
158
|
+
mediaAspectRatio: resolvePhiCardMediaAspectRatioCss(config.mediaAspectRatio),
|
|
151
159
|
image: presentation.url
|
|
152
160
|
? {
|
|
153
161
|
presentation,
|
|
@@ -1,6 +1,7 @@
|
|
|
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 { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
|
|
4
5
|
import { PhiCardWidget } from "./server";
|
|
5
6
|
import { PHI_CARD_WIDGET_DEFINITION, PHI_CARD_WIDGET_PLUGIN_TYPE } from "./config";
|
|
6
7
|
function renderPhiCard({ widget, config, runtime, links }, preview) {
|
|
@@ -14,6 +15,23 @@ function renderPhiCard({ widget, config, runtime, links }, preview) {
|
|
|
14
15
|
}
|
|
15
16
|
export const PHI_CARD_WIDGET_PLUGIN = {
|
|
16
17
|
...PHI_CARD_WIDGET_DEFINITION,
|
|
18
|
+
/*
|
|
19
|
+
* The card's words as the render draws them (SEARCH.md): the texts it translates, translated the same
|
|
20
|
+
* way; the figure and the prices as written, which the render never translates either.
|
|
21
|
+
*/
|
|
22
|
+
searchText: async ({ widget, config, runtime }) => {
|
|
23
|
+
const plan = config.body === "plan";
|
|
24
|
+
const translated = await translatePhiSearchWidgetTexts(runtime, [
|
|
25
|
+
config.eyebrow,
|
|
26
|
+
config.title,
|
|
27
|
+
config.description,
|
|
28
|
+
config.meta,
|
|
29
|
+
config.badge,
|
|
30
|
+
config.actionEnabled ? config.actionLabel : undefined,
|
|
31
|
+
...(plan ? (config.features ?? []).map((entry) => entry.text) : []),
|
|
32
|
+
], { translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate) });
|
|
33
|
+
return [...translated, config.value ?? "", ...(plan ? [config.price ?? "", config.priceYearly ?? ""] : [])];
|
|
34
|
+
},
|
|
17
35
|
/*
|
|
18
36
|
* Not the passive renderers' preview: that one is inert, and an inert card answers no pointer, so its
|
|
19
37
|
* hover effect could not be seen where it is chosen. The card's own preview leads nowhere instead.
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { trBulk, trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
3
3
|
import { isPhiMediaSvgContentType } from "../../../../../constants/media";
|
|
4
4
|
import { resolvePhiImagePresentation } from "../../../../../components/media/image-presentation";
|
|
5
|
+
import { resolvePhiCardImageVariantKey, resolvePhiCardMediaAspectRatioCss, resolvePhiCardMediaAspectRatioValue, } from "../../../../../components/widgets/shared/card-vocabulary";
|
|
5
6
|
import { resolvePhiPublicAssetReference } from "../../../../../components/widgets/helpers/internal-reference-resolver.server";
|
|
6
7
|
import { resolvePhiLinkHref } from "../../../../../helpers/link-target";
|
|
7
8
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
@@ -60,7 +61,13 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
60
61
|
const presentation = resolvePhiImagePresentation({
|
|
61
62
|
sourceKind: config?.sourceKind,
|
|
62
63
|
assetId: resolvedAsset?.id,
|
|
63
|
-
|
|
64
|
+
/* The card's own variant, else the Card variant where its box is that variant's proportion. */
|
|
65
|
+
variantKey: resolvePhiCardImageVariantKey({
|
|
66
|
+
sourceKind: config?.sourceKind,
|
|
67
|
+
variantKey: config?.sourceKind === "asset" ? config?.variantKey : null,
|
|
68
|
+
mediaAspectRatio: config?.mediaAspectRatio,
|
|
69
|
+
}),
|
|
70
|
+
frameAspectRatio: resolvePhiCardMediaAspectRatioValue(config?.mediaAspectRatio),
|
|
64
71
|
variantVersion: resolvedAsset?.variantVersion,
|
|
65
72
|
deliveryRevision: resolvedAsset?.deliveryRevision,
|
|
66
73
|
originalUrl: resolvedAsset?.deliveryUrl,
|
|
@@ -74,6 +81,7 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
74
81
|
const actionLink = preview || !actionEnabled ? null : resolvePhiLinkHref(config?.actionLinkTarget, links);
|
|
75
82
|
const clientConfig = {
|
|
76
83
|
surface: config?.surface ?? null,
|
|
84
|
+
mediaAspectRatio: resolvePhiCardMediaAspectRatioCss(config?.mediaAspectRatio),
|
|
77
85
|
image: presentation.url
|
|
78
86
|
? {
|
|
79
87
|
presentation,
|
|
@@ -1,12 +1,22 @@
|
|
|
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 { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
|
|
4
5
|
import { PhiDescriptionWidget } from "./server";
|
|
5
6
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
6
7
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
|
|
7
8
|
import { PHI_DESCRIPTION_WIDGET_DEFINITION, PHI_DESCRIPTION_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
8
9
|
export const PHI_DESCRIPTION_WIDGET_PLUGIN = {
|
|
9
10
|
...PHI_DESCRIPTION_WIDGET_DEFINITION,
|
|
11
|
+
// Every sentence the render draws, translated the way it translates them: a Preset's globally, an author's for the Site.
|
|
12
|
+
searchText: ({ widget, config, runtime }) => translatePhiSearchWidgetTexts(runtime, [
|
|
13
|
+
config.eyebrow,
|
|
14
|
+
config.title,
|
|
15
|
+
config.description,
|
|
16
|
+
config.asideTitle,
|
|
17
|
+
...(config.asideItems ?? []).map((item) => item.text),
|
|
18
|
+
config.footer,
|
|
19
|
+
], { translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate), textSource: config.textSource }),
|
|
10
20
|
render: ({ widget, config, runtime }) => (_jsx(PhiDescriptionWidget, { labels: {
|
|
11
21
|
eyebrow: config.eyebrow,
|
|
12
22
|
title: config.title,
|
|
@@ -11,7 +11,8 @@ function inlineText(inlines) {
|
|
|
11
11
|
return inline.text;
|
|
12
12
|
if (inline.kind === "break")
|
|
13
13
|
return " ";
|
|
14
|
-
|
|
14
|
+
// A teaser is plain text, so a protected address (`helpers/protected-mail.ts`) is left out of it.
|
|
15
|
+
if (inline.kind === "image" || inline.kind === "mail_text")
|
|
15
16
|
return "";
|
|
16
17
|
return inlineText(inline.children);
|
|
17
18
|
}).join("");
|
|
@@ -338,8 +338,8 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
|
|
|
338
338
|
type: "choice";
|
|
339
339
|
label: string;
|
|
340
340
|
options: {
|
|
341
|
-
value: "
|
|
342
|
-
label: "
|
|
341
|
+
value: "3:2" | "4:3" | "16:9" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
|
|
342
|
+
label: "3:2" | "4:3" | "16:9" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
|
|
343
343
|
}[];
|
|
344
344
|
visibleWhen: {
|
|
345
345
|
field: string;
|
|
@@ -362,7 +362,7 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
|
|
|
362
362
|
params: {};
|
|
363
363
|
};
|
|
364
364
|
preview: false;
|
|
365
|
-
aspectRatio: "
|
|
365
|
+
aspectRatio: "3:2" | "4:3" | "16:9" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
|
|
366
366
|
fit: "cover";
|
|
367
367
|
};
|
|
368
368
|
parseConfig: typeof parsePhiCmsGalleryWidgetConfig;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { CSSProperties } from "react";
|
|
2
|
+
import type { PhiMenuSelectionStyle } from "../../../../../components/controls/phi-menu-control-vocabulary";
|
|
2
3
|
import type { PhiClientBlockBaseProps, PhiBlockRuntime, PhiNoLabels } from "../../../../../types";
|
|
3
4
|
import { type PhiMenuTheme, type PhiNavItem } from "../../../../../components/shell/shell-types";
|
|
5
|
+
import type { PhiHeaderNavigationPhoneMenu } from "./config";
|
|
4
6
|
export type PhiHeaderNavigationWidgetClientProps = PhiClientBlockBaseProps<PhiNoLabels, Record<string, never>, Pick<PhiBlockRuntime, "site" | "locale" | "area">> & {
|
|
5
7
|
runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area">;
|
|
6
8
|
items: PhiNavItem[];
|
|
7
9
|
menuTheme?: PhiMenuTheme;
|
|
8
10
|
height?: CSSProperties["height"];
|
|
9
11
|
align?: "left" | "center";
|
|
12
|
+
selectionStyle?: PhiMenuSelectionStyle;
|
|
13
|
+
/** Below 768px: the entries behind a menu button (the default), or the row as on a wider screen. */
|
|
14
|
+
phoneMenu?: PhiHeaderNavigationPhoneMenu;
|
|
10
15
|
interactive?: boolean;
|
|
11
16
|
};
|
|
12
|
-
export declare function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align, interactive, }: PhiHeaderNavigationWidgetClientProps): import("react").JSX.Element | null;
|
|
17
|
+
export declare function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align, selectionStyle, phoneMenu, interactive, }: PhiHeaderNavigationWidgetClientProps): import("react").JSX.Element | null;
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useState } from "react";
|
|
3
4
|
import { collectPhiSelectedNavKeys } from "../../../../../helpers/nav-selection";
|
|
4
5
|
import { PhiMenuControl } from "../../../../../components/controls/phi-menu-control";
|
|
5
6
|
import { usePhiConfig } from "../../../../../components/root/phi-config-provider";
|
|
6
7
|
import { mapPhiNavItems } from "../../../../../components/shell/menu-items";
|
|
7
8
|
import {} from "../../../../../components/shell/shell-types";
|
|
8
9
|
import { usePhiPathname } from "../../../../../components/runtime/use-phi-pathname";
|
|
9
|
-
|
|
10
|
+
import { PhiButtonControl } from "../../../../../components/controls/phi-button-control";
|
|
11
|
+
import { PhiDialogControl } from "../../../../../components/controls/phi-dialog-control";
|
|
12
|
+
import { PhiIcon } from "../../../../../components/shell/phi-icon";
|
|
13
|
+
export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align = "left", selectionStyle = "auto", phoneMenu = "button", interactive = true, }) {
|
|
10
14
|
const { token } = usePhiConfig();
|
|
11
15
|
const pathname = usePhiPathname();
|
|
12
16
|
const availableLocales = runtime.site.availableLocales.map((option) => option.code);
|
|
13
17
|
const selectedKeys = collectPhiSelectedNavKeys(pathname, items, availableLocales);
|
|
14
18
|
const menuItems = mapPhiNavItems(runtime.locale.current, runtime.area, pathname, items, availableLocales, { interactive });
|
|
15
19
|
const resolvedHeight = typeof height === "number" ? `${height}px` : (height ?? "100%");
|
|
20
|
+
/*
|
|
21
|
+
* The Page the Drawer was opened on: following an entry to another Page closes it without an effect
|
|
22
|
+
* having to notice the navigation (the Shell's Sider drawer does the same).
|
|
23
|
+
*/
|
|
24
|
+
const [openedOn, setOpenedOn] = useState(null);
|
|
25
|
+
const drawerOpen = openedOn != null && openedOn === pathname;
|
|
26
|
+
const closeDrawer = useCallback(() => setOpenedOn(null), []);
|
|
27
|
+
// An entry chosen in the Drawer is where the reader is going, the Page they are on included.
|
|
28
|
+
const closeOnLink = useCallback((event) => {
|
|
29
|
+
if (event.target instanceof Element && event.target.closest("a[href]"))
|
|
30
|
+
closeDrawer();
|
|
31
|
+
}, [closeDrawer]);
|
|
16
32
|
if (menuItems.length === 0) {
|
|
17
33
|
return null;
|
|
18
34
|
}
|
|
@@ -37,7 +53,12 @@ export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, hei
|
|
|
37
53
|
textDecoration: "none",
|
|
38
54
|
}, children: item.label }, item.key))) }));
|
|
39
55
|
}
|
|
40
|
-
return (
|
|
56
|
+
return (_jsxs("div", {
|
|
57
|
+
/*
|
|
58
|
+
* Both forms are drawn and `styles/shell.css` shows one: whether this is a phone is the Shell's
|
|
59
|
+
* container width, which a Widget's own box cannot answer. The row is the wider screen's.
|
|
60
|
+
*/
|
|
61
|
+
className: phoneMenu === "button" ? "phi-header-nav phi-header-nav--phone-button" : "phi-header-nav", style: {
|
|
41
62
|
display: "flex",
|
|
42
63
|
alignItems: "stretch",
|
|
43
64
|
width: "100%",
|
|
@@ -46,14 +67,20 @@ export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, hei
|
|
|
46
67
|
minHeight: 0,
|
|
47
68
|
flex: 1,
|
|
48
69
|
justifyContent: align === "center" ? "center" : "flex-start",
|
|
49
|
-
}, children: _jsx(PhiMenuControl, { mode: "
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
}, children: [phoneMenu === "button" ? (_jsxs("span", { className: "phi-header-nav__button", children: [_jsx(PhiButtonControl, { type: "text", ariaLabel: "Open navigation", ariaExpanded: drawerOpen, icon: _jsx(PhiIcon, { name: "menu", size: "inherit" }), onClick: () => setOpenedOn(pathname) }), _jsx(PhiDialogControl, { open: drawerOpen, presentation: "drawer", placement: "right", size: "min(20rem, 85vw)", onDismiss: closeDrawer, children: _jsx("nav", { "aria-label": "Navigation", onClickCapture: closeOnLink, children: _jsx(PhiMenuControl, { mode: "inline", menuTheme: menuTheme, selectionStyle: selectionStyle, selectedKeys: selectedKeys, items: menuItems, fontSize: token.fontSize, style: { borderInlineEnd: "none" } }) }) })] })) : null, _jsx("div", { className: "phi-header-nav__row", style: {
|
|
71
|
+
display: "flex",
|
|
72
|
+
alignItems: "stretch",
|
|
73
|
+
flex: "1 1 auto",
|
|
74
|
+
minWidth: 0,
|
|
75
|
+
justifyContent: align === "center" ? "center" : "flex-start",
|
|
76
|
+
}, children: _jsx(PhiMenuControl, { mode: "horizontal", menuTheme: menuTheme, selectionStyle: selectionStyle, selectedKeys: selectedKeys, items: menuItems, fontSize: token.fontSize, style: {
|
|
77
|
+
display: "flex",
|
|
78
|
+
alignItems: "center",
|
|
79
|
+
justifyContent: align === "center" ? "center" : "flex-start",
|
|
80
|
+
minHeight: 0,
|
|
81
|
+
flex: "1 1 auto",
|
|
82
|
+
paddingInline: 0,
|
|
83
|
+
height: resolvedHeight,
|
|
84
|
+
lineHeight: resolvedHeight,
|
|
85
|
+
} }) })] }));
|
|
59
86
|
}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { CSSProperties } from "react";
|
|
2
|
+
import { type PhiMenuSelectionStyle } from "../../../../../components/controls/phi-menu-control-vocabulary";
|
|
2
3
|
import { type PhiCmsWidgetConfigBase } from "../../../../../components/widgets/config/parser-primitives";
|
|
3
4
|
export type PhiCmsHeaderNavigationWidgetConfig = PhiCmsWidgetConfigBase & {
|
|
4
5
|
navKey?: string;
|
|
5
6
|
align?: "left" | "center";
|
|
7
|
+
/** How the current entry is marked (`PHI_MENU_SELECTION_STYLES`); absent is `auto`. */
|
|
8
|
+
selectionStyle?: PhiMenuSelectionStyle;
|
|
9
|
+
/**
|
|
10
|
+
* How the entries stand on a phone (below 768px): behind a menu button that opens them in a Drawer, the
|
|
11
|
+
* default, or in the row as on a wider screen, where what does not fit folds into "…".
|
|
12
|
+
*/
|
|
13
|
+
phoneMenu?: PhiHeaderNavigationPhoneMenu;
|
|
6
14
|
};
|
|
15
|
+
export type PhiHeaderNavigationPhoneMenu = "button" | "row";
|
|
7
16
|
declare function parsePhiCmsHeaderNavigationWidgetConfig(config: Record<string, unknown>): PhiCmsHeaderNavigationWidgetConfig;
|
|
8
|
-
export type PhiHeaderNavigationWidgetRenderableConfig = Pick<PhiCmsHeaderNavigationWidgetConfig, "align"> & {
|
|
17
|
+
export type PhiHeaderNavigationWidgetRenderableConfig = Pick<PhiCmsHeaderNavigationWidgetConfig, "align" | "selectionStyle" | "phoneMenu"> & {
|
|
9
18
|
height?: CSSProperties["height"];
|
|
10
19
|
};
|
|
11
20
|
export declare const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION: {
|
|
@@ -17,6 +26,11 @@ export declare const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION: {
|
|
|
17
26
|
category: "navigation";
|
|
18
27
|
iconFamily: string;
|
|
19
28
|
slotSizePolicy: "fill";
|
|
29
|
+
defaultConfig: {
|
|
30
|
+
align: "left";
|
|
31
|
+
selectionStyle: "auto";
|
|
32
|
+
phoneMenu: "button";
|
|
33
|
+
};
|
|
20
34
|
fields: ({
|
|
21
35
|
key: string;
|
|
22
36
|
type: "choice";
|
|
@@ -46,6 +60,17 @@ export declare const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION: {
|
|
|
46
60
|
presentation?: undefined;
|
|
47
61
|
optionsProvider?: undefined;
|
|
48
62
|
placeholder?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
key: string;
|
|
65
|
+
type: "choice";
|
|
66
|
+
label: string;
|
|
67
|
+
presentation: "segmented";
|
|
68
|
+
options: {
|
|
69
|
+
value: string;
|
|
70
|
+
label: string;
|
|
71
|
+
}[];
|
|
72
|
+
optionsProvider?: undefined;
|
|
73
|
+
placeholder?: undefined;
|
|
49
74
|
})[];
|
|
50
75
|
parseConfig: typeof parsePhiCmsHeaderNavigationWidgetConfig;
|
|
51
76
|
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
|
|
2
2
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
3
3
|
import { PHI_AUTHORING_OPTION_PROVIDER_KEYS } from "../../../../../constants/authoring-option-provider-keys";
|
|
4
|
+
import { PHI_MENU_SELECTION_STYLES, } from "../../../../../components/controls/phi-menu-control-vocabulary";
|
|
4
5
|
import { readRenderableBlockConfig, readString, } from "../../../../../components/widgets/config/parser-primitives";
|
|
5
6
|
function parsePhiCmsHeaderNavigationWidgetConfig(config) {
|
|
6
7
|
return {
|
|
7
8
|
...readRenderableBlockConfig(config),
|
|
8
9
|
navKey: readString(config.navKey),
|
|
9
10
|
align: readString(config.align) === "center" ? "center" : "left",
|
|
11
|
+
selectionStyle: PHI_MENU_SELECTION_STYLES.find((style) => style === readString(config.selectionStyle)),
|
|
12
|
+
phoneMenu: readString(config.phoneMenu) === "row" ? "row" : "button",
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
15
|
export const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION = {
|
|
@@ -18,6 +21,8 @@ export const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION = {
|
|
|
18
21
|
category: "navigation",
|
|
19
22
|
iconFamily: "navigation",
|
|
20
23
|
slotSizePolicy: "fill",
|
|
24
|
+
/* What the Inspector shows chosen where a header states nothing, and what an absent value renders as. */
|
|
25
|
+
defaultConfig: { align: "left", selectionStyle: "auto", phoneMenu: "button" },
|
|
21
26
|
fields: [
|
|
22
27
|
{
|
|
23
28
|
key: "navKey",
|
|
@@ -43,6 +48,28 @@ export const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION = {
|
|
|
43
48
|
{ value: "center", label: "Center" },
|
|
44
49
|
],
|
|
45
50
|
},
|
|
51
|
+
/* Automatic is a bar in light mode and a rounded ground in dark mode, where a bar is hard to see. */
|
|
52
|
+
{
|
|
53
|
+
key: "selectionStyle",
|
|
54
|
+
type: "choice",
|
|
55
|
+
label: "Current entry",
|
|
56
|
+
presentation: "segmented",
|
|
57
|
+
options: [
|
|
58
|
+
{ value: "auto", label: "Automatic" },
|
|
59
|
+
{ value: "underline", label: "Underline" },
|
|
60
|
+
{ value: "pill", label: "Pill" },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: "phoneMenu",
|
|
65
|
+
type: "choice",
|
|
66
|
+
label: "On a phone",
|
|
67
|
+
presentation: "segmented",
|
|
68
|
+
options: [
|
|
69
|
+
{ value: "button", label: "Menu button" },
|
|
70
|
+
{ value: "row", label: "Row" },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
46
73
|
],
|
|
47
74
|
parseConfig: parsePhiCmsHeaderNavigationWidgetConfig,
|
|
48
75
|
};
|
|
@@ -4,7 +4,7 @@ import { PhiHeaderNavigationWidget } from "./server";
|
|
|
4
4
|
import { resolvePhiRenderableBlockGeometry } from "../../../../../types/renderable-block-geometry";
|
|
5
5
|
export const PHI_HEADER_NAVIGATION_WIDGET_PLUGIN = {
|
|
6
6
|
...PHI_HEADER_NAVIGATION_WIDGET_DEFINITION,
|
|
7
|
-
render: ({ widget, runtime, regionConfig, config }) => (_jsx(PhiHeaderNavigationWidget, { runtime: runtime, navKey: config.navKey ?? `${runtime.area}:header`, height: resolvePhiRenderableBlockGeometry(regionConfig).block.size?.css, align: config.align, interactive: true }, `widget-${widget.id}`)),
|
|
7
|
+
render: ({ widget, runtime, regionConfig, config }) => (_jsx(PhiHeaderNavigationWidget, { runtime: runtime, navKey: config.navKey ?? `${runtime.area}:header`, height: resolvePhiRenderableBlockGeometry(regionConfig).block.size?.css, align: config.align, selectionStyle: config.selectionStyle, phoneMenu: config.phoneMenu, interactive: true }, `widget-${widget.id}`)),
|
|
8
8
|
renderPreview: ({ widget, runtime, regionConfig, config }) => (_jsx(PhiHeaderNavigationWidget, { runtime: runtime, navKey: config.navKey ?? `${runtime.area}:header`, height: resolvePhiRenderableBlockGeometry(regionConfig).block.size?.css, align: config.align, interactive: false }, `widget-${widget.id}`)),
|
|
9
9
|
};
|
|
10
10
|
export { PHI_HEADER_NAVIGATION_WIDGET_PLUGIN_TYPE };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PhiBlockRuntime } from "../../../../../types";
|
|
2
2
|
import type { PhiHeaderNavigationWidgetClientProps } from "./client";
|
|
3
|
-
export type PhiHeaderNavigationWidgetProps = Pick<PhiHeaderNavigationWidgetClientProps, "menuTheme" | "height" | "align" | "interactive"> & {
|
|
3
|
+
export type PhiHeaderNavigationWidgetProps = Pick<PhiHeaderNavigationWidgetClientProps, "menuTheme" | "height" | "align" | "selectionStyle" | "phoneMenu" | "interactive"> & {
|
|
4
4
|
runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area" | "viewer" | "request">;
|
|
5
5
|
navKey?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, align, interactive, }: PhiHeaderNavigationWidgetProps): Promise<import("react").JSX.Element | null>;
|
|
7
|
+
export declare function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, align, selectionStyle, phoneMenu, interactive, }: PhiHeaderNavigationWidgetProps): Promise<import("react").JSX.Element | null>;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
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
|
-
export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, align, interactive = true, }) {
|
|
5
|
+
export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, align, selectionStyle, phoneMenu, interactive = true, }) {
|
|
6
6
|
const items = await resolvePhiNavigationItems(runtime, navKey?.trim() || `${runtime.area}:header`);
|
|
7
7
|
if (items == null) {
|
|
8
8
|
return null;
|
|
@@ -13,6 +13,8 @@ export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, he
|
|
|
13
13
|
menuTheme,
|
|
14
14
|
height,
|
|
15
15
|
align,
|
|
16
|
+
selectionStyle,
|
|
17
|
+
phoneMenu,
|
|
16
18
|
interactive,
|
|
17
19
|
} }));
|
|
18
20
|
}
|
|
@@ -1,10 +1,25 @@
|
|
|
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 { readPhiHtmlSearchText } from "../../../../../server-helpers/search-text";
|
|
4
5
|
import { PHI_HTML_WIDGET_DEFINITION, PHI_HTML_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
5
|
-
import { PhiHtmlWidget } from "./server";
|
|
6
|
+
import { PhiHtmlWidget, resolvePhiHtmlWidgetTranslatedHtml } from "./server";
|
|
6
7
|
export const PHI_HTML_WIDGET_PLUGIN = {
|
|
7
8
|
...PHI_HTML_WIDGET_DEFINITION,
|
|
9
|
+
// The fragment the render draws, read without its tags (SEARCH.md); a source that cannot be read contributes nothing.
|
|
10
|
+
searchText: async ({ widget, config, runtime }) => {
|
|
11
|
+
try {
|
|
12
|
+
const html = await resolvePhiHtmlWidgetTranslatedHtml({
|
|
13
|
+
...config,
|
|
14
|
+
resolvedContent: widget.resolvedContent ?? null,
|
|
15
|
+
preferSource: hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
|
|
16
|
+
}, runtime);
|
|
17
|
+
return readPhiHtmlSearchText(html);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
},
|
|
8
23
|
render: ({ widget, config, runtime }) => {
|
|
9
24
|
const noTranslate = hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate);
|
|
10
25
|
return (_jsx(PhiHtmlWidget, { blockId: widget.id, config: {
|
|
@@ -14,4 +14,10 @@ export type PhiHtmlWidgetConfig = PhiHtmlWidgetClientConfig & PhiRenderableBlock
|
|
|
14
14
|
export type PhiHtmlWidgetProps = PhiServerBlockBaseProps<PhiHtmlWidgetLabels, PhiHtmlWidgetConfig> & {
|
|
15
15
|
blockId: PhiCmsInstanceId;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* The fragment as the reader gets it: read from its source, its references resolved, sanitised and
|
|
19
|
+
* translated for the render's language. Empty where the Widget has nothing to show. The render draws it;
|
|
20
|
+
* the search index reads its words (SEARCH.md).
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolvePhiHtmlWidgetTranslatedHtml(config: PhiHtmlWidgetConfig | undefined, runtime: PhiHtmlWidgetProps["runtime"]): Promise<string>;
|
|
17
23
|
export declare function PhiHtmlWidget({ blockId, config, runtime, }: PhiHtmlWidgetProps): Promise<import("react").JSX.Element | null>;
|
|
@@ -19,7 +19,12 @@ const loadRemoteHtml = cache(async function loadRemoteHtml(resolvedUrl, revalida
|
|
|
19
19
|
throw new Error(`Failed to load HTML from ${resolvedUrl}: ${response.status}`);
|
|
20
20
|
return response.text();
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The fragment as the reader gets it: read from its source, its references resolved, sanitised and
|
|
24
|
+
* translated for the render's language. Empty where the Widget has nothing to show. The render draws it;
|
|
25
|
+
* the search index reads its words (SEARCH.md).
|
|
26
|
+
*/
|
|
27
|
+
export async function resolvePhiHtmlWidgetTranslatedHtml(config, runtime) {
|
|
23
28
|
const sourceMode = config?.sourceMode ?? (config?.sourceUrl?.trim() ? "url" : "inline");
|
|
24
29
|
const sourceUrl = config?.sourceUrl?.trim() ?? "";
|
|
25
30
|
/*
|
|
@@ -48,11 +53,14 @@ export async function PhiHtmlWidget({ blockId, config, runtime, }) {
|
|
|
48
53
|
}))
|
|
49
54
|
: "";
|
|
50
55
|
if (!sourceHtml) {
|
|
51
|
-
return
|
|
56
|
+
return "";
|
|
52
57
|
}
|
|
53
|
-
|
|
58
|
+
return (sourceMode !== "url" && config?.resolvedContent != null) || config?.preferSource === true
|
|
54
59
|
? sourceHtml
|
|
55
|
-
:
|
|
60
|
+
: translateSemanticHtml(sourceHtml, sourceMode === "url" ? config?.sourceLocale?.trim() : undefined, runtime.locale.current);
|
|
61
|
+
}
|
|
62
|
+
export async function PhiHtmlWidget({ blockId, config, runtime, }) {
|
|
63
|
+
const translatedHtml = await resolvePhiHtmlWidgetTranslatedHtml(config, runtime);
|
|
56
64
|
if (!translatedHtml) {
|
|
57
65
|
return null;
|
|
58
66
|
}
|
|
@@ -8,6 +8,7 @@ import { PhiEmptyControl } from "../../../../../components/controls/phi-empty-co
|
|
|
8
8
|
import { PhiImageControl } from "../../../../../components/controls/phi-image-control";
|
|
9
9
|
import { PhiFlexControl } from "../../../../../components/controls/phi-flex-control";
|
|
10
10
|
import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
|
|
11
|
+
import { PHI_LAYOUT_SURFACE_RADIUS } from "../../../../../components/layouts/phi-layout-contract";
|
|
11
12
|
function formatImageSize(value) {
|
|
12
13
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
13
14
|
return `${value}px`;
|
|
@@ -68,11 +69,15 @@ export function PhiImageWidget({ labels, config, resolvedAsset, focalRect, autho
|
|
|
68
69
|
const renderedWidth = formatImageSize(width);
|
|
69
70
|
const renderedHeight = formatImageSize(height);
|
|
70
71
|
const maskStyle = resolvePhiMaskStyle(config?.mask);
|
|
72
|
+
/*
|
|
73
|
+
* A picture is a surface: a corner the author left unstated is the Theme's surface step, as a Layout's
|
|
74
|
+
* and a Markdown picture's are (THEME.md "Control shape"); a corner the author stated keeps its value.
|
|
75
|
+
*/
|
|
71
76
|
const radiusStyle = {
|
|
72
|
-
borderTopLeftRadius: config?.borderTopLeftRadius,
|
|
73
|
-
borderTopRightRadius: config?.borderTopRightRadius,
|
|
74
|
-
borderBottomLeftRadius: config?.borderBottomLeftRadius,
|
|
75
|
-
borderBottomRightRadius: config?.borderBottomRightRadius,
|
|
77
|
+
borderTopLeftRadius: config?.borderTopLeftRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
|
|
78
|
+
borderTopRightRadius: config?.borderTopRightRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
|
|
79
|
+
borderBottomLeftRadius: config?.borderBottomLeftRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
|
|
80
|
+
borderBottomRightRadius: config?.borderBottomRightRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
|
|
76
81
|
};
|
|
77
82
|
if (!renderUrl) {
|
|
78
83
|
return (_jsxs(PhiFlexControl, { align: "center", justify: "center", vertical: true, gap: 6, style: {
|
|
@@ -90,8 +95,7 @@ export function PhiImageWidget({ labels, config, resolvedAsset, focalRect, autho
|
|
|
90
95
|
return (_jsx(PhiImageControl, { presentation: presentation, source: sourceKind === "asset" ? "asset" : config?.trusted === true ? "trusted-url" : "url", alt: alt, title: title || undefined, width: width, height: height, blurDataUrl: resolvedAsset?.blurDataUrl, optimizable: optimizable, sizes: config?.sizes, preload: config?.preload === true && isPublicAsset, preview: (config?.previewMode ?? "none") === "lightbox", zoom: config?.previewMode === "native", style: {
|
|
91
96
|
...radiusStyle,
|
|
92
97
|
...maskStyle,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
: undefined,
|
|
98
|
+
// Every corner has a radius now, the Theme's at least, so the box always clips its picture.
|
|
99
|
+
overflow: "hidden",
|
|
96
100
|
}, imageStyle: radiusStyle }));
|
|
97
101
|
}
|