@phis/ui 0.5.3 → 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/controls/phi-cascader-control.d.ts +9 -1
- package/components/controls/phi-cascader-control.js +25 -3
- package/components/controls/phi-money-control.d.ts +39 -0
- package/components/controls/phi-money-control.js +34 -0
- package/components/controls/phi-number-control.d.ts +6 -1
- package/components/controls/phi-number-control.js +3 -3
- package/components/controls/phi-options-provider.d.ts +7 -0
- package/components/controls/phi-options-provider.js +11 -0
- package/components/forms/extended-form-field-controls.d.ts +1 -0
- package/components/forms/extended-form-field-controls.js +23 -1
- package/components/forms/form-descriptor-runtime-client.js +13 -0
- package/components/forms/form-provider-contract.d.ts +43 -0
- package/components/forms/form-provider-contract.js +40 -0
- package/components/forms/money-field.d.ts +27 -0
- package/components/forms/money-field.js +78 -0
- package/components/forms/shared-form-provider-registry.js +4 -0
- 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/media/phi-media-picker-binding.js +6 -1
- package/components/media/phi-site-font-assets.js +6 -1
- package/components/motion/phi-sequence-run.d.ts +14 -1
- package/components/motion/phi-sequence-run.js +22 -3
- package/components/motion/phi-sequence-viewport.js +3 -1
- package/components/regions/presets/content-entry-editor-page-tree.js +5 -1
- package/components/regions/presets/content-entry-public-page-trees.js +2 -0
- package/components/tables/client/phi-table-binding.js +16 -3
- package/components/trees/client/phi-tree-binding.js +6 -2
- package/components/widgets/builder/stack-tabs.d.ts +2 -1
- package/components/widgets/builder/stack-tabs.js +18 -2
- package/components/widgets/client/shared/phi-collection-view-binding.js +10 -2
- package/components/widgets/client/shared/phi-rendered-value.d.ts +9 -1
- package/components/widgets/client/shared/phi-rendered-value.js +20 -1
- package/components/widgets/config/choice-shared.d.ts +1 -49
- package/components/widgets/config/choice-shared.js +0 -1
- package/components/widgets/config/stack-tabs.js +4 -3
- package/components/widgets/label-sets/gallery.js +6 -0
- package/components/widgets/label-sets/interval.d.ts +4 -0
- package/components/widgets/label-sets/interval.js +31 -0
- package/components/widgets/label-sets/record.js +6 -1
- package/components/widgets/label-sets/slot-upload.d.ts +4 -0
- package/components/widgets/label-sets/slot-upload.js +36 -0
- package/components/widgets/label-sets/table.js +6 -1
- package/components/widgets/label-types/gallery.d.ts +7 -0
- package/components/widgets/label-types/gallery.js +6 -0
- package/components/widgets/label-types/interval.d.ts +16 -0
- package/components/widgets/label-types/interval.js +21 -0
- package/components/widgets/label-types/record.d.ts +3 -0
- package/components/widgets/label-types/record.js +2 -0
- package/components/widgets/label-types/slot-upload.d.ts +24 -0
- package/components/widgets/label-types/slot-upload.js +16 -0
- package/components/widgets/label-types/table.d.ts +3 -0
- package/components/widgets/label-types/table.js +2 -0
- package/constants/record-field-kinds.d.ts +1 -1
- package/constants/record-field-kinds.js +1 -1
- package/constants/runtime-module-ownership.js +1 -0
- package/controls.d.ts +7 -0
- package/controls.js +4 -0
- package/helpers/cms-dialog.d.ts +39 -3
- package/helpers/cms-dialog.js +46 -4
- package/helpers/cms-page-catalog.d.ts +8 -0
- package/helpers/cms-page-catalog.js +18 -2
- package/helpers/cms-preset-nodes.d.ts +13 -3
- package/helpers/cms-preset-nodes.js +3 -2
- package/helpers/config-text-fields.d.ts +49 -0
- package/helpers/config-text-fields.js +122 -0
- package/helpers/money-amount.d.ts +48 -0
- package/helpers/money-amount.js +131 -0
- package/helpers/page-layout-check.js +15 -2
- package/helpers/preset-text-source-check.d.ts +22 -0
- package/helpers/preset-text-source-check.js +45 -0
- package/helpers/record-fields.d.ts +18 -5
- package/helpers/record-fields.js +38 -13
- 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/module-records.d.ts +6 -3
- package/module-records.js +4 -2
- package/package.json +2 -2
- 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/module.d.ts +1 -1
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +2 -0
- package/plugins/runtime-modules/app/module.d.ts +1 -1
- package/plugins/runtime-modules/asset/services/collection.js +1 -0
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -2
- package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +3 -0
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
- package/plugins/runtime-modules/builder/offered-page-catalog.js +3 -3
- package/plugins/runtime-modules/builder/options-providers.js +7 -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 +17 -3
- package/plugins/runtime-modules/contracts.d.ts +1 -1
- package/plugins/runtime-modules/core/definition.d.ts +43 -0
- package/plugins/runtime-modules/core/form-providers.d.ts +43 -0
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +6 -3
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +6 -5
- package/plugins/runtime-modules/core/widgets/breadcrumb/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +9 -1
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +29 -3
- 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 +18 -2
- 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 +4 -3
- package/plugins/runtime-modules/core/widgets/cascader/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/cascader/config.d.ts +8 -2
- package/plugins/runtime-modules/core/widgets/cascader/config.js +22 -0
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +8 -2
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +2 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +2 -2
- 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/authoring.js +12 -3
- package/plugins/runtime-modules/core/widgets/gallery/client.js +10 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/image/server.js +5 -9
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +2 -1
- package/plugins/runtime-modules/core/widgets/markdown-toc/server.js +3 -5
- package/plugins/runtime-modules/core/widgets/multi-select/config.d.ts +1 -1
- 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/record/client.js +8 -2
- package/plugins/runtime-modules/core/widgets/record/config.js +4 -0
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +2 -2
- 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/segmented/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/select-box/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +2 -1
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +1 -1
- 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/authoring.js +2 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/client.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/client.js +45 -24
- package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +11 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/config.js +16 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +2 -2
- package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +8 -3
- package/plugins/runtime-modules/core/widgets/slot-upload/server.js +9 -3
- 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 +8 -3
- 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/client.js +4 -4
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +6 -3
- package/plugins/runtime-modules/core/widgets/table/config.js +4 -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 +11 -1
- package/plugins/runtime-modules/descriptor-compiler.js +49 -8
- package/plugins/runtime-modules/groups/definition.d.ts +1 -1
- package/plugins/runtime-modules/groups/forms.d.ts +18 -0
- package/plugins/runtime-modules/groups/forms.js +2 -2
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +8 -4
- 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/module.d.ts +1 -1
- package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +1 -0
- package/plugins/runtime-modules/resolver.js +5 -0
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +5 -2
- 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 +6 -2
- package/plugins/runtime-modules/user-management/controller/client.js +6 -1
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +5 -3
- package/runtime-render-client.d.ts +1 -1
- package/runtime-render-client.js +2 -1
- package/server-helpers/cms-page-record.d.ts +2 -2
- package/server-helpers/cms-page-record.js +15 -5
- 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/record-fields.d.ts +1 -1
- package/server-helpers/record-fields.js +1 -2
- package/server-helpers/record-samples.d.ts +4 -4
- package/server-helpers/record-samples.js +10 -2
- package/server-helpers/search-index.js +12 -3
- package/styles/root.css +6 -2
- package/types/cms-module-descriptors.d.ts +3 -0
- package/types/cms-plugins.d.ts +38 -5
- package/types/collection-provider.d.ts +7 -0
- package/types/core-widget-placements.d.ts +37 -0
- package/types/record-provider.d.ts +19 -3
- package/types/slot-size-policy.d.ts +19 -2
- package/types/table-widget.d.ts +33 -1
- package/types/table-widget.js +1 -0
- package/types/tree-widget.d.ts +7 -0
- package/types/widget-runtime.d.ts +1 -1
- package/types.d.ts +1 -0
|
@@ -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,
|
|
@@ -8,6 +8,7 @@ import { PHI_GALLERY_WIDGET_DEFINITION, } from "./config";
|
|
|
8
8
|
import { resolvePhiSpacingScaleValue } from "../../../../../components/widgets/config/spacing-options";
|
|
9
9
|
import { PHI_SEQUENCE_SETTINGS_DEFAULTS } from "../../../../../components/widgets/config/sequence-settings";
|
|
10
10
|
import { resolvePhiGalleryFrame } from "./defaults";
|
|
11
|
+
import { formatPhiGalleryWidgetLabel, PHI_GALLERY_WIDGET_DEFAULT_LABELS, } from "../../../../../components/widgets/label-types/gallery";
|
|
11
12
|
/** How many dots stand for "more than one page" on the canvas, which does not know how many pictures there are. */
|
|
12
13
|
const EDITOR_DOT_COUNT = 3;
|
|
13
14
|
/**
|
|
@@ -27,6 +28,16 @@ function PhiGalleryWidgetEditor({ config }) {
|
|
|
27
28
|
const showDots = controls === "dots" || controls === "both";
|
|
28
29
|
const folderId = config?.source?.params?.folderId;
|
|
29
30
|
const hasFolder = folderId != null && folderId !== "";
|
|
31
|
+
const recordField = config?.recordField;
|
|
32
|
+
/*
|
|
33
|
+
* Where a field of the page record is named, the pictures are that field's and the Folder only stands
|
|
34
|
+
* in on a Page about no record; saying "no folder chosen" there sent the author looking for a setting
|
|
35
|
+
* that decides nothing.
|
|
36
|
+
*/
|
|
37
|
+
const labels = PHI_GALLERY_WIDGET_DEFAULT_LABELS;
|
|
38
|
+
const hint = recordField
|
|
39
|
+
? formatPhiGalleryWidgetLabel(labels.canvasRecordField, recordField)
|
|
40
|
+
: hasFolder ? labels.canvasFolder : labels.canvasNoFolder;
|
|
30
41
|
const { aspectRatio } = resolvePhiGalleryFrame(config);
|
|
31
42
|
const arrowStyle = {
|
|
32
43
|
position: "absolute",
|
|
@@ -63,8 +74,6 @@ function PhiGalleryWidgetEditor({ config }) {
|
|
|
63
74
|
height: token.marginXS,
|
|
64
75
|
borderRadius: token.borderRadiusSM,
|
|
65
76
|
background: page === 0 ? token.colorPrimary : token.colorFill,
|
|
66
|
-
} }, page))) })) : null, _jsx(PhiTypographyControl, { type: "secondary", style: { fontSize: token.fontSizeSM }, children:
|
|
67
|
-
? "The public pictures of the chosen media folder, read when the page is drawn."
|
|
68
|
-
: "No folder chosen yet. Pick one in the inspector; its public pictures are read when the page is drawn." })] }));
|
|
77
|
+
} }, page))) })) : null, _jsx(PhiTypographyControl, { type: "secondary", style: { fontSize: token.fontSizeSM }, children: hint })] }));
|
|
69
78
|
}
|
|
70
79
|
export const PHI_GALLERY_WIDGET_BUILDER_PLUGIN = createPhiCmsBuilderWidgetPlugin(PHI_GALLERY_WIDGET_DEFINITION, ({ config }) => _jsx(PhiGalleryWidgetEditor, { config: config ?? undefined }));
|
|
@@ -8,6 +8,8 @@ import { readPhiAspectRatio, resolvePhiImagePresentation } from "../../../../../
|
|
|
8
8
|
import { PHI_GALLERY_WIDGET_DEFAULT_LABELS, } from "../../../../../components/widgets/label-types/gallery";
|
|
9
9
|
import { isPhiMediaSvgContentType } from "../../../../../constants/media";
|
|
10
10
|
import { resolvePhiGalleryFrame } from "./defaults";
|
|
11
|
+
/** A thumbnail's width in pixels: also what the optimiser is told to size it for. */
|
|
12
|
+
const PHI_GALLERY_THUMBNAIL_WIDTH = 80;
|
|
11
13
|
function GalleryPicture({ item, variantKey, fit, preview, sizes, aspectRatio, }) {
|
|
12
14
|
// The frame's proportion is known, so the crop can keep the whole focal rectangle in view.
|
|
13
15
|
const frameAspectRatio = readPhiAspectRatio(aspectRatio);
|
|
@@ -54,10 +56,17 @@ export function PhiGalleryWidget({ config, images: imagesInput, pictures, labels
|
|
|
54
56
|
// What a picture of this window is worth of the viewport, for the optimiser's choice of rendition.
|
|
55
57
|
const sizes = span === 1 ? "100vw" : `(max-width: 768px) 100vw, ${Math.ceil(100 / span)}vw`;
|
|
56
58
|
const { aspectRatio, fit } = resolvePhiGalleryFrame(config);
|
|
59
|
+
const thumbnails = config?.thumbnails === true
|
|
60
|
+
? items.map((item) => ({
|
|
61
|
+
key: item.key,
|
|
62
|
+
label: (item.kind === "asset" ? item.image.altText : item.picture.alt) ?? "",
|
|
63
|
+
content: (_jsx(GalleryPicture, { item: item, variantKey: config?.variantKey, fit: fit, preview: false, sizes: `${PHI_GALLERY_THUMBNAIL_WIDTH}px`, aspectRatio: aspectRatio })),
|
|
64
|
+
}))
|
|
65
|
+
: undefined;
|
|
57
66
|
const frameStyle = {
|
|
58
67
|
minWidth: 0,
|
|
59
68
|
borderRadius: token.borderRadius,
|
|
60
69
|
overflow: "hidden",
|
|
61
70
|
};
|
|
62
|
-
return (_jsx(PhiSequenceRun, { items: items.map((item) => (_jsx(GalleryPicture, { item: item, variantKey: config?.variantKey, fit: fit, preview: config?.preview === true, sizes: sizes, aspectRatio: aspectRatio }, item.key))), settings: config, labels: labels, itemStyle: frameStyle }));
|
|
71
|
+
return (_jsx(PhiSequenceRun, { items: items.map((item) => (_jsx(GalleryPicture, { item: item, variantKey: config?.variantKey, fit: fit, preview: config?.preview === true, sizes: sizes, aspectRatio: aspectRatio }, item.key))), settings: config, labels: labels, itemStyle: frameStyle, thumbnails: thumbnails, thumbnailWidth: PHI_GALLERY_THUMBNAIL_WIDTH }));
|
|
63
72
|
}
|
|
@@ -24,6 +24,8 @@ export type PhiCmsGalleryWidgetConfig = PhiCmsWidgetConfigBase & PhiSequenceSett
|
|
|
24
24
|
variantKey?: PhiImageAssetVariantKeyValue;
|
|
25
25
|
/** Opens a picture larger over the page when clicked. */
|
|
26
26
|
preview?: boolean;
|
|
27
|
+
/** A row of small pictures under the main one; acts only while one picture is visible. Absent is off. */
|
|
28
|
+
thumbnails?: boolean;
|
|
27
29
|
/** The frame's proportion for originals; a variant brings its own. */
|
|
28
30
|
aspectRatio?: PhiMediaAspectRatio;
|
|
29
31
|
fit?: "cover" | "contain";
|
|
@@ -51,6 +53,7 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
|
|
|
51
53
|
type: "string" | "url" | "icon";
|
|
52
54
|
emptyValue?: "";
|
|
53
55
|
placeholder?: string;
|
|
56
|
+
text?: false | "label" | "message";
|
|
54
57
|
}) | ({
|
|
55
58
|
key: string;
|
|
56
59
|
label: string;
|
|
@@ -114,7 +117,7 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
|
|
|
114
117
|
heading?: string;
|
|
115
118
|
} & {
|
|
116
119
|
type: "record-field";
|
|
117
|
-
kinds: readonly import("../../../../../
|
|
120
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
118
121
|
}) | ({
|
|
119
122
|
key: string;
|
|
120
123
|
label: string;
|
|
@@ -60,6 +60,7 @@ export function parsePhiCmsGalleryWidgetConfig(raw) {
|
|
|
60
60
|
const fit = readMember(raw.fit, ["cover", "contain"], "fit");
|
|
61
61
|
const variantKey = readVariantKey(raw.variantKey);
|
|
62
62
|
const preview = readFlag(raw.preview, "preview");
|
|
63
|
+
const thumbnails = readFlag(raw.thumbnails, "thumbnails");
|
|
63
64
|
const recordField = readRecordField(raw.recordField);
|
|
64
65
|
return {
|
|
65
66
|
...readRenderableBlockConfig(raw),
|
|
@@ -68,6 +69,7 @@ export function parsePhiCmsGalleryWidgetConfig(raw) {
|
|
|
68
69
|
...(recordField === undefined ? {} : { recordField }),
|
|
69
70
|
...(variantKey === undefined ? {} : { variantKey }),
|
|
70
71
|
...(preview === undefined ? {} : { preview }),
|
|
72
|
+
...(thumbnails === undefined ? {} : { thumbnails }),
|
|
71
73
|
...(aspectRatio === undefined ? {} : { aspectRatio }),
|
|
72
74
|
...(fit === undefined ? {} : { fit }),
|
|
73
75
|
};
|
|
@@ -137,6 +139,12 @@ export const PHI_GALLERY_WIDGET_DEFINITION = {
|
|
|
137
139
|
...PHI_GALLERY_SEQUENCE_FIELDS.window,
|
|
138
140
|
...PHI_GALLERY_SEQUENCE_FIELDS.movement,
|
|
139
141
|
...PHI_GALLERY_SEQUENCE_FIELDS.controls,
|
|
142
|
+
{
|
|
143
|
+
key: "thumbnails",
|
|
144
|
+
type: "boolean",
|
|
145
|
+
label: "Thumbnails",
|
|
146
|
+
description: "A row of small pictures under the main one, in place of the dots. Acts only while one picture is shown at a time.",
|
|
147
|
+
},
|
|
140
148
|
],
|
|
141
149
|
/*
|
|
142
150
|
* Bound to the Folder Provider from the start, so the inspector asks for a folder and nothing else.
|
|
@@ -6,7 +6,7 @@ import type { PhiCmsGalleryWidgetConfig } from "./config";
|
|
|
6
6
|
export type PhiGalleryWidgetServerProps = {
|
|
7
7
|
runtime: PhiBlockRuntime;
|
|
8
8
|
/** Where the record binding is answered; absent outside a page render, where nothing is bound. */
|
|
9
|
-
registry?: Pick<PhiCmsRuntimeRenderRegistry, "recordProviderLoadersByKey" | "recordFieldsLoadersByKey" | "
|
|
9
|
+
registry?: Pick<PhiCmsRuntimeRenderRegistry, "recordProviderLoadersByKey" | "recordFieldsLoadersByKey" | "recordDeclarationsByKey">;
|
|
10
10
|
config: PhiCmsGalleryWidgetConfig;
|
|
11
11
|
widgetId?: PhiCmsInstanceId | null;
|
|
12
12
|
/** Whether the pictures' descriptions go through the Site's translation; off where the Widget says so. */
|
|
@@ -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,
|
|
@@ -100,6 +100,7 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
|
|
|
100
100
|
type: "string" | "url" | "icon";
|
|
101
101
|
emptyValue?: "";
|
|
102
102
|
placeholder?: string;
|
|
103
|
+
text?: false | "label" | "message";
|
|
103
104
|
}) | ({
|
|
104
105
|
key: string;
|
|
105
106
|
label: string;
|
|
@@ -163,7 +164,7 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
|
|
|
163
164
|
heading?: string;
|
|
164
165
|
} & {
|
|
165
166
|
type: "record-field";
|
|
166
|
-
kinds: readonly import("../../../../../
|
|
167
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
167
168
|
}) | ({
|
|
168
169
|
key: string;
|
|
169
170
|
label: string;
|
|
@@ -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: [] } } }));
|
|
@@ -77,7 +77,7 @@ export declare const PHI_MULTI_SELECT_WIDGET_DEFINITION: {
|
|
|
77
77
|
key: string;
|
|
78
78
|
type: "collection";
|
|
79
79
|
label: string;
|
|
80
|
-
editorPlacement: "
|
|
80
|
+
editorPlacement: "inspector" | "toolbar";
|
|
81
81
|
itemKeyField: string;
|
|
82
82
|
itemLabelField: string;
|
|
83
83
|
defaultItem: {
|
|
@@ -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,
|
|
@@ -5,6 +5,7 @@ import { readPhiDotPath } from "../../../../../helpers/dot-path";
|
|
|
5
5
|
import { PhiDescriptionListControl } from "../../../../../components/controls/phi-description-list-control";
|
|
6
6
|
import { PhiEmptyControl } from "../../../../../components/controls/phi-empty-control";
|
|
7
7
|
import { PhiSkeletonControl } from "../../../../../components/controls/phi-skeleton-control";
|
|
8
|
+
import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../../../components/root/phi-intl-locale";
|
|
8
9
|
import { usePhiSignalListener } from "../../../../../components/runtime/runtime-signal-bus";
|
|
9
10
|
import { usePhiSignalIdentity } from "../../../../../components/runtime/runtime-signal-identity";
|
|
10
11
|
import { renderPhiValueContent } from "../../../../../components/widgets/client/shared/phi-rendered-value";
|
|
@@ -30,6 +31,9 @@ export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAU
|
|
|
30
31
|
*/
|
|
31
32
|
const listenRoutes = useMemo(() => config.signalRoutes?.listens ?? [], [config.signalRoutes?.listens]);
|
|
32
33
|
const { provider, resource, bindingError } = usePhiTableProvider(config.source);
|
|
34
|
+
// Sent with the read and part of what makes one new: an open record is read again after a switch.
|
|
35
|
+
const locale = usePhiIntlLocale();
|
|
36
|
+
const timeZone = usePhiIntlTimeZone();
|
|
33
37
|
const [selectedRowIdentity, setSelectedRowIdentity] = useState(null);
|
|
34
38
|
const [record, setRecord] = useState(null);
|
|
35
39
|
const [loading, setLoading] = useState(false);
|
|
@@ -63,6 +67,8 @@ export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAU
|
|
|
63
67
|
resourceKey: config.source.resourceKey,
|
|
64
68
|
rowIdentity,
|
|
65
69
|
params: config.source.params,
|
|
70
|
+
locale,
|
|
71
|
+
timeZone,
|
|
66
72
|
signal: abortController.signal,
|
|
67
73
|
});
|
|
68
74
|
if (!abortController.signal.aborted) {
|
|
@@ -85,7 +91,7 @@ export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAU
|
|
|
85
91
|
setLoading(false);
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
|
-
}, [bindingError, config.source, labels, provider, resource?.recordRead]);
|
|
94
|
+
}, [bindingError, config.source, labels, locale, provider, resource?.recordRead, timeZone]);
|
|
89
95
|
usePhiSignalListener(useCallback((signal) => {
|
|
90
96
|
const route = listenRoutes.find((candidate) => candidate.channel === signal.channel &&
|
|
91
97
|
candidate.action === signal.action &&
|
|
@@ -137,6 +143,6 @@ export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAU
|
|
|
137
143
|
key: field.key,
|
|
138
144
|
label: field.label,
|
|
139
145
|
full: field.full,
|
|
140
|
-
value: renderPhiValueContent(readPhiDotPath(record, field.fieldKey), field, "block"),
|
|
146
|
+
value: renderPhiValueContent(readPhiDotPath(record, field.fieldKey), field, labels, "block"),
|
|
141
147
|
})) }));
|
|
142
148
|
}
|
|
@@ -17,6 +17,8 @@ const PHI_RECORD_VALUE_RENDERERS = [
|
|
|
17
17
|
"switch",
|
|
18
18
|
"checkbox",
|
|
19
19
|
"icon",
|
|
20
|
+
"money",
|
|
21
|
+
"interval",
|
|
20
22
|
];
|
|
21
23
|
function readRecordValueRenderer(value) {
|
|
22
24
|
return typeof value === "string" && PHI_RECORD_VALUE_RENDERERS.includes(value)
|
|
@@ -179,6 +181,8 @@ export const PHI_RECORD_WIDGET_DEFINITION = {
|
|
|
179
181
|
{ value: "switch", label: "Switch" },
|
|
180
182
|
{ value: "checkbox", label: "Checkbox" },
|
|
181
183
|
{ value: "icon", label: "Icon" },
|
|
184
|
+
{ value: "money", label: "Money" },
|
|
185
|
+
{ value: "interval", label: "Interval" },
|
|
182
186
|
],
|
|
183
187
|
},
|
|
184
188
|
{
|
|
@@ -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;
|
|
@@ -112,7 +112,7 @@ export declare const PHI_RESULT_WIDGET_DEFINITION: {
|
|
|
112
112
|
heading?: string;
|
|
113
113
|
} & {
|
|
114
114
|
type: "record-field";
|
|
115
|
-
kinds: readonly import("../../../../../
|
|
115
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
116
116
|
}) | ({
|
|
117
117
|
key: string;
|
|
118
118
|
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.
|
|
@@ -68,7 +68,7 @@ export declare const PHI_SEGMENTED_WIDGET_DEFINITION: {
|
|
|
68
68
|
key: string;
|
|
69
69
|
type: "collection";
|
|
70
70
|
label: string;
|
|
71
|
-
editorPlacement: "
|
|
71
|
+
editorPlacement: "inspector" | "toolbar";
|
|
72
72
|
itemKeyField: string;
|
|
73
73
|
itemLabelField: string;
|
|
74
74
|
defaultItem: {
|
|
@@ -70,7 +70,7 @@ export declare const PHI_SELECT_BOX_WIDGET_DEFINITION: {
|
|
|
70
70
|
key: string;
|
|
71
71
|
type: "collection";
|
|
72
72
|
label: string;
|
|
73
|
-
editorPlacement: "
|
|
73
|
+
editorPlacement: "inspector" | "toolbar";
|
|
74
74
|
itemKeyField: string;
|
|
75
75
|
itemLabelField: string;
|
|
76
76
|
defaultItem: {
|
|
@@ -58,6 +58,7 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
|
|
|
58
58
|
type: "string" | "url" | "icon";
|
|
59
59
|
emptyValue?: "";
|
|
60
60
|
placeholder?: string;
|
|
61
|
+
text?: false | "label" | "message";
|
|
61
62
|
}) | ({
|
|
62
63
|
key: string;
|
|
63
64
|
label: string;
|
|
@@ -121,7 +122,7 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
|
|
|
121
122
|
heading?: string;
|
|
122
123
|
} & {
|
|
123
124
|
type: "record-field";
|
|
124
|
-
kinds: readonly import("../../../../../
|
|
125
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
125
126
|
}) | ({
|
|
126
127
|
key: string;
|
|
127
128
|
label: string;
|
|
@@ -28,7 +28,7 @@ export const PHI_SIMPLE_TEXT_WIDGET_PLUGIN = {
|
|
|
28
28
|
*/
|
|
29
29
|
const recordField = await resolvePhiWidgetRecordField({ registry, runtime, key: config.recordField, kinds: PHI_RECORD_TEXT_FIELD_KINDS });
|
|
30
30
|
if (recordField.bound) {
|
|
31
|
-
const text = recordField.field ? formatPhiRecordFieldText(recordField.field, runtime.locale.current) : "";
|
|
31
|
+
const text = recordField.field ? formatPhiRecordFieldText(recordField.field, runtime.locale.current, runtime.site.timeZone) : "";
|
|
32
32
|
return text
|
|
33
33
|
? _jsx(PhiSimpleTextWidget, { blockId: widget.id, translate: false, labels: { text }, config: config, runtime: runtime }, `widget-${widget.id}`)
|
|
34
34
|
: null;
|
|
@@ -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: {
|