@phis/ui 0.5.3 → 0.5.4
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/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/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 +3 -1
- package/components/tables/client/phi-table-binding.js +16 -3
- package/components/trees/client/phi-tree-binding.js +6 -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 +2 -2
- 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/money-amount.d.ts +48 -0
- package/helpers/money-amount.js +131 -0
- package/helpers/page-layout-check.js +15 -2
- package/helpers/record-fields.d.ts +18 -5
- package/helpers/record-fields.js +38 -13
- package/module-records.d.ts +6 -3
- package/module-records.js +4 -2
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/module.d.ts +1 -1
- 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/offered-page-catalog.js +3 -3
- package/plugins/runtime-modules/builder/options-providers.js +7 -0
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -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/card/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +3 -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 +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
- 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 +3 -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/markdown/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/multi-select/config.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.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 +12 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/config.js +18 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +4 -2
- package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +9 -3
- package/plugins/runtime-modules/core/widgets/slot-upload/server.js +17 -3
- package/plugins/runtime-modules/core/widgets/steps/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +4 -4
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
- 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 +6 -4
- package/plugins/runtime-modules/public/module.d.ts +1 -1
- package/plugins/runtime-modules/resolver.js +5 -0
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +4 -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 +3 -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/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/types/cms-module-descriptors.d.ts +3 -0
- package/types/cms-plugins.d.ts +8 -0
- package/types/collection-provider.d.ts +7 -0
- package/types/core-widget-placements.d.ts +32 -0
- package/types/record-provider.d.ts +19 -3
- 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
|
@@ -19,6 +19,8 @@ function parsePhiCascaderWidgetConfig(config) {
|
|
|
19
19
|
separator: readString(config.separator) ?? "/",
|
|
20
20
|
rootValue: readString(config.rootValue) ?? "/",
|
|
21
21
|
normalize: readNormalizeMode(config.normalize),
|
|
22
|
+
expandTrigger: readString(config.expandTrigger) === "hover" ? "hover" : "click",
|
|
23
|
+
select: readString(config.select) === "options" ? "options" : "any",
|
|
22
24
|
...parsePhiChoiceOptionsConfig(config),
|
|
23
25
|
};
|
|
24
26
|
}
|
|
@@ -51,6 +53,24 @@ export const PHI_CASCADER_WIDGET_DEFINITION = {
|
|
|
51
53
|
{ value: "path", label: "Path" },
|
|
52
54
|
],
|
|
53
55
|
},
|
|
56
|
+
{
|
|
57
|
+
key: "expandTrigger",
|
|
58
|
+
type: "choice",
|
|
59
|
+
label: "Opens",
|
|
60
|
+
options: [
|
|
61
|
+
{ value: "click", label: "On click" },
|
|
62
|
+
{ value: "hover", label: "On hover" },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: "select",
|
|
67
|
+
type: "choice",
|
|
68
|
+
label: "Choosable",
|
|
69
|
+
options: [
|
|
70
|
+
{ value: "any", label: "Every level" },
|
|
71
|
+
{ value: "options", label: "Only the options" },
|
|
72
|
+
],
|
|
73
|
+
},
|
|
54
74
|
...PHI_CONTROL_PRESENTATION_FIELDS,
|
|
55
75
|
...PHI_CONTROL_STATE_FIELDS,
|
|
56
76
|
],
|
|
@@ -60,6 +80,8 @@ export const PHI_CASCADER_WIDGET_DEFINITION = {
|
|
|
60
80
|
separator: "/",
|
|
61
81
|
rootValue: "/",
|
|
62
82
|
normalize: "raw",
|
|
83
|
+
expandTrigger: "click",
|
|
84
|
+
select: "any",
|
|
63
85
|
optionsProvider: null,
|
|
64
86
|
options: [],
|
|
65
87
|
},
|
|
@@ -49,7 +49,7 @@ export declare const PHI_CHECKBOX_GROUP_WIDGET_DEFINITION: {
|
|
|
49
49
|
key: string;
|
|
50
50
|
type: "collection";
|
|
51
51
|
label: string;
|
|
52
|
-
editorPlacement: "
|
|
52
|
+
editorPlacement: "inspector" | "toolbar";
|
|
53
53
|
itemKeyField: string;
|
|
54
54
|
itemLabelField: string;
|
|
55
55
|
defaultItem: {
|
|
@@ -103,7 +103,7 @@ export declare const PHI_DESCRIPTION_WIDGET_DEFINITION: {
|
|
|
103
103
|
heading?: string;
|
|
104
104
|
} & {
|
|
105
105
|
type: "record-field";
|
|
106
|
-
kinds: readonly import("../../../../../
|
|
106
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
107
107
|
}) | ({
|
|
108
108
|
key: string;
|
|
109
109
|
label: string;
|
|
@@ -147,7 +147,7 @@ export declare const PHI_ENTRY_LIST_WIDGET_DEFINITION: {
|
|
|
147
147
|
heading?: string;
|
|
148
148
|
} & {
|
|
149
149
|
type: "record-field";
|
|
150
|
-
kinds: readonly import("../../../../../
|
|
150
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
151
151
|
}) | ({
|
|
152
152
|
key: string;
|
|
153
153
|
label: string;
|
|
@@ -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";
|
|
@@ -114,7 +116,7 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
|
|
|
114
116
|
heading?: string;
|
|
115
117
|
} & {
|
|
116
118
|
type: "record-field";
|
|
117
|
-
kinds: readonly import("../../../../../
|
|
119
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
118
120
|
}) | ({
|
|
119
121
|
key: string;
|
|
120
122
|
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. */
|
|
@@ -163,7 +163,7 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
|
|
|
163
163
|
heading?: string;
|
|
164
164
|
} & {
|
|
165
165
|
type: "record-field";
|
|
166
|
-
kinds: readonly import("../../../../../
|
|
166
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
167
167
|
}) | ({
|
|
168
168
|
key: string;
|
|
169
169
|
label: string;
|
|
@@ -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: {
|
|
@@ -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
|
{
|
|
@@ -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;
|
|
@@ -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: {
|
|
@@ -121,7 +121,7 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
|
|
|
121
121
|
heading?: string;
|
|
122
122
|
} & {
|
|
123
123
|
type: "record-field";
|
|
124
|
-
kinds: readonly import("../../../../../
|
|
124
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
125
125
|
}) | ({
|
|
126
126
|
key: string;
|
|
127
127
|
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;
|
|
@@ -3,13 +3,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { PhiTextControl } from "../../../../../controls";
|
|
4
4
|
import { PHI_SLOT_UPLOAD_WIDGET_DEFINITION } from "./config";
|
|
5
5
|
import { PhiSlotUploadWidgetClient } from "./client";
|
|
6
|
+
import { PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS } from "../../../../../components/widgets/label-types/slot-upload";
|
|
6
7
|
/**
|
|
7
8
|
* What an author states: where the file goes. What it takes is not among the fields, because the slot
|
|
8
9
|
* declares that and Core answers with it -- offering it here would be offering a way to disagree.
|
|
9
10
|
*/
|
|
10
11
|
export const PHI_SLOT_UPLOAD_WIDGET_BUILDER_PLUGIN = {
|
|
11
12
|
...PHI_SLOT_UPLOAD_WIDGET_DEFINITION,
|
|
12
|
-
renderEditor: ({ config }) => _jsx(PhiSlotUploadWidgetClient, { config: config }),
|
|
13
|
+
renderEditor: ({ config }) => (_jsx(PhiSlotUploadWidgetClient, { config: config, labels: PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS })),
|
|
13
14
|
renderEditorTools: ({ config, authoring }) => {
|
|
14
15
|
const updateConfig = authoring?.updateConfig;
|
|
15
16
|
if (!updateConfig) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PhiSlotUploadWidgetConfig } from "./config";
|
|
2
|
+
import { type PhiSlotUploadWidgetLabels } from "../../../../../components/widgets/label-types/slot-upload";
|
|
2
3
|
export type PhiSlotUploadWidgetClientProps = {
|
|
3
4
|
config?: PhiSlotUploadWidgetConfig;
|
|
5
|
+
labels: PhiSlotUploadWidgetLabels;
|
|
4
6
|
};
|
|
5
|
-
export declare function PhiSlotUploadWidgetClient({ config }: PhiSlotUploadWidgetClientProps): import("react").JSX.Element;
|
|
7
|
+
export declare function PhiSlotUploadWidgetClient({ config, labels }: PhiSlotUploadWidgetClientProps): import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { PhiEntryListControl } from "../../../../../components/controls/phi-entry-list-control";
|
|
4
4
|
import { PhiProgressControl } from "../../../../../components/controls/phi-progress-control";
|
|
5
5
|
import { PhiButtonControl } from "../../../../../components/controls/phi-button-control";
|
|
@@ -11,10 +11,29 @@ import { usePhiSignalListener } from "../../../../../components/runtime/runtime-
|
|
|
11
11
|
import { emitPhiSignalCapability, usePhiSignalEmitter, usePhiSignalIdentity, } from "../../../../../components/runtime/runtime-signal-identity";
|
|
12
12
|
import { readPhiTableBindingParamsSignalValue } from "../../../../../types/table-signal-values";
|
|
13
13
|
import { findPhiSignalListenRoute } from "../../../../../helpers/signal-listen-routes";
|
|
14
|
+
import { formatPhiSlotUploadWidgetLabel, } from "../../../../../components/widgets/label-types/slot-upload";
|
|
14
15
|
import { PhiFlexControl } from "../../../../../components/controls/phi-flex-control";
|
|
15
16
|
import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
|
|
16
17
|
import { PhiIcon } from "../../../../../components/shell/phi-icon";
|
|
17
|
-
|
|
18
|
+
import { PhiImageControl } from "../../../../../components/controls/phi-image-control";
|
|
19
|
+
import { PhiLabeledControl } from "../../../../../components/controls/phi-labeled-control";
|
|
20
|
+
import { resolvePhiImagePresentation } from "../../../../../components/media/image-presentation";
|
|
21
|
+
import { PhiMediaKind, resolvePhiMediaKindFromContentType } from "../../../../../constants/media";
|
|
22
|
+
/** The side of the square a picture of the slot is shown at, beside its type and size. */
|
|
23
|
+
const THUMBNAIL_SIZE = 48;
|
|
24
|
+
/*
|
|
25
|
+
* A picture is shown, everything else is named: its type and size are said either way, because a
|
|
26
|
+
* thumbnail tells which picture it is but not whether it is the 40 MB original somebody meant to shrink.
|
|
27
|
+
* The address is Core's delivery path for the file, drawn as it is rather than through the optimiser:
|
|
28
|
+
* a slot's file is not a public Asset, so the optimiser may not take its bytes.
|
|
29
|
+
*/
|
|
30
|
+
function SlotFileTitle({ file, text }) {
|
|
31
|
+
if (resolvePhiMediaKindFromContentType(file.contentType) !== PhiMediaKind.Image) {
|
|
32
|
+
return text;
|
|
33
|
+
}
|
|
34
|
+
return (_jsxs(PhiFlexControl, { align: "center", gap: 8, children: [_jsx(PhiImageControl, { presentation: resolvePhiImagePresentation({ sourceKind: "url", sourceUrl: file.contentPath, fit: "cover" }), source: "url", alt: "", width: THUMBNAIL_SIZE, height: THUMBNAIL_SIZE, loading: "lazy", style: { flex: "none", borderRadius: "var(--phi-border-radius-sm)", overflow: "hidden" } }), _jsx("span", { children: text })] }));
|
|
35
|
+
}
|
|
36
|
+
export function PhiSlotUploadWidgetClient({ config, labels }) {
|
|
18
37
|
const addon = config?.addon?.trim() ?? "";
|
|
19
38
|
const table = config?.table?.trim() ?? "";
|
|
20
39
|
const slotName = config?.slot?.trim() ?? "";
|
|
@@ -55,10 +74,12 @@ export function PhiSlotUploadWidgetClient({ config }) {
|
|
|
55
74
|
});
|
|
56
75
|
const body = await response.json().catch(() => null);
|
|
57
76
|
if (!response.ok) {
|
|
58
|
-
throw new Error(typeof body?.error === "string"
|
|
77
|
+
throw new Error(typeof body?.error === "string"
|
|
78
|
+
? body.error
|
|
79
|
+
: formatPhiSlotUploadWidgetLabel(labels.serverAnswered, response.status));
|
|
59
80
|
}
|
|
60
81
|
return body ?? {};
|
|
61
|
-
}, []);
|
|
82
|
+
}, [labels.serverAnswered]);
|
|
62
83
|
usePhiSignalListener(useCallback((signal) => {
|
|
63
84
|
if (!findPhiSignalListenRoute(listenRoutes, signal, signalIdentity.receiver))
|
|
64
85
|
return;
|
|
@@ -89,14 +110,14 @@ export function PhiSlotUploadWidgetClient({ config }) {
|
|
|
89
110
|
const declared = (body.slots ?? [])
|
|
90
111
|
.find((entry) => entry.name === slotName);
|
|
91
112
|
setSlot(declared ?? null);
|
|
92
|
-
setSlotFailure(declared ? null :
|
|
113
|
+
setSlotFailure(declared ? null : formatPhiSlotUploadWidgetLabel(labels.slotMissing, slotName));
|
|
93
114
|
})
|
|
94
115
|
.catch((error) => {
|
|
95
116
|
if (live)
|
|
96
|
-
setSlotFailure(error instanceof Error ? error.message :
|
|
117
|
+
setSlotFailure(error instanceof Error ? error.message : labels.unreachable);
|
|
97
118
|
});
|
|
98
119
|
return () => { live = false; };
|
|
99
|
-
}, [base, read, slotName]);
|
|
120
|
+
}, [base, labels.slotMissing, labels.unreachable, read, slotName]);
|
|
100
121
|
// Reads rather than stores: what to do with the answer belongs to whoever asked, and an effect that
|
|
101
122
|
// only subscribes is one the rules about effects are happy with.
|
|
102
123
|
const readFiles = useCallback(async (owner) => {
|
|
@@ -117,9 +138,9 @@ export function PhiSlotUploadWidgetClient({ config }) {
|
|
|
117
138
|
setLoaded({ ownerId, files: await readFiles(ownerId) });
|
|
118
139
|
}
|
|
119
140
|
catch (error) {
|
|
120
|
-
setFailure(error instanceof Error ? error.message :
|
|
141
|
+
setFailure(error instanceof Error ? error.message : labels.unreachable);
|
|
121
142
|
}
|
|
122
|
-
}, [ownerId, readFiles]);
|
|
143
|
+
}, [labels.unreachable, ownerId, readFiles]);
|
|
123
144
|
useEffect(() => {
|
|
124
145
|
if (!base || !ownerId) {
|
|
125
146
|
return;
|
|
@@ -130,10 +151,10 @@ export function PhiSlotUploadWidgetClient({ config }) {
|
|
|
130
151
|
setLoaded({ ownerId, files }); })
|
|
131
152
|
.catch((error) => {
|
|
132
153
|
if (live)
|
|
133
|
-
setFailure(error instanceof Error ? error.message :
|
|
154
|
+
setFailure(error instanceof Error ? error.message : labels.unreachable);
|
|
134
155
|
});
|
|
135
156
|
return () => { live = false; };
|
|
136
|
-
}, [base, ownerId, readFiles]);
|
|
157
|
+
}, [base, labels.unreachable, ownerId, readFiles]);
|
|
137
158
|
/*
|
|
138
159
|
* The session, begun and settled at the Add-on's root; the transfer between them is Core's own and
|
|
139
160
|
* the same one every Media surface runs, progress and refusals included.
|
|
@@ -201,23 +222,23 @@ export function PhiSlotUploadWidgetClient({ config }) {
|
|
|
201
222
|
await read(`${base}/${encodeURIComponent(ownerId)}/${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
202
223
|
}
|
|
203
224
|
catch {
|
|
204
|
-
setFailure(
|
|
225
|
+
setFailure(labels.removeFailed);
|
|
205
226
|
return;
|
|
206
227
|
}
|
|
207
228
|
announceChanged();
|
|
208
229
|
await reload();
|
|
209
|
-
}, [announceChanged, base, ownerId, read, reload]);
|
|
230
|
+
}, [announceChanged, base, labels.removeFailed, ownerId, read, reload]);
|
|
210
231
|
if (!base || !slotName) {
|
|
211
|
-
return _jsx(
|
|
232
|
+
return (_jsx(PhiLabeledControl, { label: config?.label, children: _jsx(PhiTypographyControl, { type: "secondary", children: labels.unconfigured }) }));
|
|
212
233
|
}
|
|
213
|
-
return (_jsxs(PhiFlexControl, { vertical: true, gap: 8, "data-phis-slot-upload": slotName, children: [ownerId === null ? (_jsx(PhiTypographyControl, { type: "secondary", children:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
234
|
+
return (_jsx(PhiLabeledControl, { label: config?.label, fill: true, children: _jsxs(PhiFlexControl, { vertical: true, gap: 8, "data-phis-slot-upload": slotName, children: [ownerId === null ? (_jsx(PhiTypographyControl, { type: "secondary", children: labels.noRow })) : (_jsxs(_Fragment, { children: [_jsx("input", { ref: fileInputRef, type: "file", hidden: true, multiple: slot?.cardinality === "many", accept: slot?.contentTypes.join(","), onChange: (event) => {
|
|
235
|
+
for (const file of Array.from(event.target.files ?? []))
|
|
236
|
+
void upload.upload(file);
|
|
237
|
+
// Cleared so choosing the same file again is a change, and uploads again.
|
|
238
|
+
event.target.value = "";
|
|
239
|
+
} }), _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: "upload", size: "inherit" }), label: labels.choose, onClick: () => fileInputRef.current?.click() })] })), upload.items.filter((item) => item.status === "uploading").map((item) => (_jsx(PhiProgressControl, { percent: item.progress, size: "small" }, item.localId))), slotFailure ?? failure ? (_jsx(PhiTypographyControl, { type: "danger", role: "alert", children: slotFailure ?? failure })) : null, _jsx(PhiEntryListControl, { emptyDescription: labels.empty, entries: [...files].map((file) => ({
|
|
240
|
+
key: String(file.id),
|
|
241
|
+
title: (_jsx(SlotFileTitle, { file: file, text: formatPhiSlotUploadWidgetLabel(labels.fileTitle, file.contentType, file.byteSize) })),
|
|
242
|
+
action: (_jsx(PhiButtonControl, { size: "small", icon: _jsx(PhiIcon, { name: "delete", size: "inherit" }), ariaLabel: labels.remove, tooltip: labels.remove, onClick: () => { void remove(file.id); } })),
|
|
243
|
+
})) })] }) }));
|
|
223
244
|
}
|
|
@@ -2,6 +2,8 @@ import { type PhiSignalRouteSet } from "../../../../../types/signals";
|
|
|
2
2
|
import { type PhiCmsWidgetConfigBase } from "../../../../../widget-config";
|
|
3
3
|
export declare const PHI_SLOT_UPLOAD_WIDGET_TYPE: string;
|
|
4
4
|
export type PhiSlotUploadWidgetConfig = PhiCmsWidgetConfigBase & {
|
|
5
|
+
/** What the field is called where it stands -- "Cover picture", "Further pictures". Absent draws none. */
|
|
6
|
+
label?: string;
|
|
5
7
|
/** The Add-on that owns the table, by package name -- `@scope/name`. */
|
|
6
8
|
addon?: string;
|
|
7
9
|
table?: string;
|
|
@@ -11,7 +13,7 @@ export type PhiSlotUploadWidgetConfig = PhiCmsWidgetConfigBase & {
|
|
|
11
13
|
/** How the row reaches this field. Wired where the widget is placed, like every other Signal. */
|
|
12
14
|
signalRoutes?: PhiSignalRouteSet | null;
|
|
13
15
|
};
|
|
14
|
-
declare function parsePhiSlotUploadWidgetConfig(config: Record<string, unknown>): PhiSlotUploadWidgetConfig;
|
|
16
|
+
export declare function parsePhiSlotUploadWidgetConfig(config: Record<string, unknown>): PhiSlotUploadWidgetConfig;
|
|
15
17
|
export declare const PHI_SLOT_UPLOAD_WIDGET_DEFINITION: {
|
|
16
18
|
kind: "widget";
|
|
17
19
|
pluginKey: string;
|
|
@@ -21,15 +23,22 @@ export declare const PHI_SLOT_UPLOAD_WIDGET_DEFINITION: {
|
|
|
21
23
|
category: "media";
|
|
22
24
|
description: string;
|
|
23
25
|
iconFamily: string;
|
|
24
|
-
fields: {
|
|
26
|
+
fields: ({
|
|
25
27
|
key: string;
|
|
26
28
|
type: "string";
|
|
27
29
|
label: string;
|
|
28
|
-
|
|
30
|
+
description: string;
|
|
31
|
+
} | {
|
|
32
|
+
key: string;
|
|
33
|
+
type: "string";
|
|
34
|
+
label: string;
|
|
35
|
+
description?: undefined;
|
|
36
|
+
})[];
|
|
29
37
|
defaultConfig: {
|
|
30
38
|
ownerParam: string;
|
|
31
39
|
};
|
|
32
40
|
parseConfig: typeof parsePhiSlotUploadWidgetConfig;
|
|
41
|
+
translatesOwnText: true;
|
|
33
42
|
runtimeSignals: {
|
|
34
43
|
emits: {
|
|
35
44
|
id: string;
|
|
@@ -45,4 +54,3 @@ export declare const PHI_SLOT_UPLOAD_WIDGET_DEFINITION: {
|
|
|
45
54
|
}[];
|
|
46
55
|
};
|
|
47
56
|
};
|
|
48
|
-
export {};
|
|
@@ -15,9 +15,23 @@ import { readRenderableBlockConfig, readString, } from "../../../../../widget-co
|
|
|
15
15
|
const PHI_SLOT_UPLOAD_WIDGET_TYPE_KEY = "slot-upload";
|
|
16
16
|
const PHI_SLOT_UPLOAD_WIDGET_PLUGIN_KEY = resolvePhiCmsWidgetPluginKey(PHI_SLOT_UPLOAD_WIDGET_TYPE_KEY);
|
|
17
17
|
export const PHI_SLOT_UPLOAD_WIDGET_TYPE = buildPhiCmsWidgetNamespacedTypeKey(PHI_SLOT_UPLOAD_WIDGET_PLUGIN_KEY, PHI_SLOT_UPLOAD_WIDGET_TYPE_KEY);
|
|
18
|
-
|
|
18
|
+
/*
|
|
19
|
+
* The label is read strictly: a stored value that is not text is a mistake in the document, and a field
|
|
20
|
+
* that renders anyway hides it. Absent, null and blank all mean the field carries no label.
|
|
21
|
+
*/
|
|
22
|
+
function readLabel(value) {
|
|
23
|
+
if (value === undefined || value === null)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (typeof value !== "string") {
|
|
26
|
+
throw new Error(`Invalid Slot upload label ${JSON.stringify(value)}. Expected text.`);
|
|
27
|
+
}
|
|
28
|
+
return value.trim() || undefined;
|
|
29
|
+
}
|
|
30
|
+
export function parsePhiSlotUploadWidgetConfig(config) {
|
|
31
|
+
const label = readLabel(config.label);
|
|
19
32
|
return {
|
|
20
33
|
...readRenderableBlockConfig(config),
|
|
34
|
+
...(label === undefined ? {} : { label }),
|
|
21
35
|
addon: readString(config.addon),
|
|
22
36
|
table: readString(config.table),
|
|
23
37
|
slot: readString(config.slot),
|
|
@@ -35,6 +49,7 @@ export const PHI_SLOT_UPLOAD_WIDGET_DEFINITION = {
|
|
|
35
49
|
description: "Puts a file into a declared slot on a row of an Add-on's table.",
|
|
36
50
|
iconFamily: "media",
|
|
37
51
|
fields: [
|
|
52
|
+
{ key: "label", type: "string", label: "Label", description: "What the field is called where it stands." },
|
|
38
53
|
{ key: "addon", type: "string", label: "Add-on" },
|
|
39
54
|
{ key: "table", type: "string", label: "Table" },
|
|
40
55
|
{ key: "slot", type: "string", label: "Slot" },
|
|
@@ -42,6 +57,8 @@ export const PHI_SLOT_UPLOAD_WIDGET_DEFINITION = {
|
|
|
42
57
|
],
|
|
43
58
|
defaultConfig: { ownerParam: "id" },
|
|
44
59
|
parseConfig: parsePhiSlotUploadWidgetConfig,
|
|
60
|
+
// The label is written into the config, so the Widget translates it on the server.
|
|
61
|
+
translatesOwnText: true,
|
|
45
62
|
runtimeSignals: {
|
|
46
63
|
emits: [
|
|
47
64
|
// So whatever shows the row can read it again. What changed is the row, not this widget.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
+
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
2
4
|
import { PHI_SLOT_UPLOAD_WIDGET_DEFINITION } from "./config";
|
|
3
5
|
import { PhiSlotUploadWidget } from "./server";
|
|
4
6
|
export const PHI_SLOT_UPLOAD_WIDGET_PLUGIN = {
|
|
5
7
|
...PHI_SLOT_UPLOAD_WIDGET_DEFINITION,
|
|
6
|
-
render: ({ config }) => _jsx(PhiSlotUploadWidget, { config: config }),
|
|
7
|
-
renderPreview: ({ config }) => (_jsx(PhiSlotUploadWidget, { config: { ...config, renderMode: "preview" } })),
|
|
8
|
+
render: ({ widget, config, runtime }) => (_jsx(PhiSlotUploadWidget, { config: config, runtime: runtime, translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate) })),
|
|
9
|
+
renderPreview: ({ widget, config, runtime }) => (_jsx(PhiSlotUploadWidget, { config: { ...config, renderMode: "preview" }, runtime: runtime, translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate) })),
|
|
8
10
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { PhiBlockRuntime } from "../../../../../types";
|
|
1
3
|
import { type PhiSlotUploadWidgetConfig } from "./config";
|
|
2
4
|
/**
|
|
3
5
|
* Handed to the Render Client by type: what a slot holds depends on who is asking and on which row a
|
|
4
|
-
* surface is about, and neither is knowable where a page is rendered for a cache.
|
|
6
|
+
* surface is about, and neither is knowable where a page is rendered for a cache. Its texts are read
|
|
7
|
+
* here, in the page's language, and travel with it: the field's own captions from its Label Set, the
|
|
8
|
+
* label somebody wrote into the config through the Site's translation unless the node says not to.
|
|
5
9
|
*/
|
|
6
|
-
export declare function PhiSlotUploadWidget({ config }: {
|
|
10
|
+
export declare function PhiSlotUploadWidget({ config, runtime, translate, }: {
|
|
7
11
|
config?: PhiSlotUploadWidgetConfig;
|
|
8
|
-
|
|
12
|
+
runtime: PhiBlockRuntime;
|
|
13
|
+
translate?: boolean;
|
|
14
|
+
}): Promise<import("react").JSX.Element>;
|