@phis/ui 0.5.2 → 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/README.md +1 -1
- package/components/controls/phi-border-control.js +1 -1
- package/components/controls/phi-bound-radius-control.js +9 -9
- package/components/controls/phi-brand-control.js +1 -1
- package/components/controls/phi-cascader-control.d.ts +9 -1
- package/components/controls/phi-cascader-control.js +25 -3
- package/components/controls/phi-drawer-control-adapter.js +4 -4
- package/components/controls/phi-dropdown-control.js +2 -2
- package/components/controls/phi-form-control.js +1 -1
- package/components/controls/phi-image-control.js +1 -1
- package/components/controls/phi-mask-picker-control.js +6 -6
- 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/controls/phi-select-control.js +1 -1
- package/components/controls/phi-theme-scope-control.js +1 -1
- package/components/controls/use-phi-color-control-presets.js +2 -2
- package/components/forms/compound-form-controls.js +2 -2
- package/components/forms/extended-form-field-controls.d.ts +1 -0
- package/components/forms/extended-form-field-controls.js +24 -2
- 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 +6 -2
- package/components/layouts/clients/phi-flex-layout-client.js +4 -4
- package/components/layouts/clients/phi-grid-layout-client.js +3 -3
- package/components/layouts/clients/phi-sequence-slot-editor.js +1 -1
- package/components/layouts/layout-definitions.d.ts +4 -4
- package/components/layouts/phi-page-region-layout.js +1 -1
- package/components/layouts/phi-structure-region-layout.js +3 -3
- package/components/media/phi-asset-focal-rect-widget.js +4 -4
- package/components/media/phi-asset-inspector-section.js +1 -1
- package/components/media/phi-media-kind-icon.js +2 -2
- package/components/media/phi-media-picker-binding.js +6 -1
- package/components/media/phi-media-restricted-icon.js +1 -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/overlays/phi-overlay-container-client.js +1 -1
- package/components/regions/presets/content-entry-editor-page-tree.js +3 -1
- package/components/regions/presets/phi-base-page-column.js +6 -2
- package/components/root/phi-config-provider.js +1 -1
- package/components/root/phi-root-background.js +1 -1
- package/components/root/phi-root-theme-resolver.js +1 -1
- package/components/shell/phi-module-icons.js +1 -1
- package/components/tables/client/phi-table-binding.js +16 -3
- package/components/trees/client/phi-tree-binding.js +6 -2
- package/components/widgets/built-in/builder-workspace-preview.js +8 -8
- package/components/widgets/client/bullet-list-entries-editor.js +2 -2
- package/components/widgets/client/external-document-editor.js +1 -1
- package/components/widgets/client/html-editor.js +3 -3
- 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/background.d.ts +1 -1
- package/components/widgets/config/background.js +1 -1
- package/components/widgets/config/choice-shared.d.ts +2 -2
- package/components/widgets/inspector-field-row.js +1 -1
- package/components/widgets/label-sets/gallery.js +6 -0
- package/components/widgets/label-sets/inspector.js +2 -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/inspector.d.ts +1 -0
- package/components/widgets/label-types/inspector.js +1 -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/components/widgets/shared/card-body-client.js +1 -1
- package/components/widgets/shared/result-body-client.js +1 -1
- package/constants/media-library-provider-keys.d.ts +8 -1
- package/constants/media-library-provider-keys.js +8 -1
- package/constants/record-field-kinds.d.ts +6 -0
- package/constants/record-field-kinds.js +7 -0
- package/constants/runtime-module-ownership.js +2 -1
- package/controls.d.ts +7 -0
- package/controls.js +4 -0
- package/helpers/border-widget-style.d.ts +2 -2
- package/helpers/border-widget-style.js +2 -2
- package/helpers/cms-dialog.d.ts +43 -7
- package/helpers/cms-dialog.js +46 -4
- package/helpers/cms-layout-defaults.d.ts +2 -2
- package/helpers/cms-page-catalog.d.ts +13 -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/cms-preset-page-tree.d.ts +4 -0
- package/helpers/cms-preset-page-tree.js +2 -0
- package/helpers/layout-style.d.ts +2 -2
- package/helpers/money-amount.d.ts +48 -0
- package/helpers/money-amount.js +131 -0
- package/helpers/page-layout-check.d.ts +4 -1
- package/helpers/page-layout-check.js +41 -2
- package/helpers/record-fields.d.ts +22 -0
- package/helpers/record-fields.js +109 -0
- package/helpers/surface-presets.d.ts +6 -6
- package/helpers/surface-style.d.ts +1 -1
- package/helpers.d.ts +0 -1
- package/helpers.js +0 -2
- package/module-page-check.d.ts +12 -0
- package/module-page-check.js +12 -0
- package/module-records.d.ts +7 -2
- package/module-records.js +5 -1
- package/next/antd-form-context-loader.mjs +31 -0
- package/next/config.d.mts +2 -0
- package/next/config.mjs +36 -3
- package/package.json +11 -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/data-providers.d.ts +0 -65
- package/plugins/runtime-modules/asset/data-providers.js +0 -40
- package/plugins/runtime-modules/asset/definition.d.ts +0 -60
- package/plugins/runtime-modules/asset/ids.d.ts +0 -1
- package/plugins/runtime-modules/asset/ids.js +1 -2
- package/plugins/runtime-modules/asset/presets.d.ts +1 -0
- package/plugins/runtime-modules/asset/server.js +0 -5
- 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/blog/presets.d.ts +1 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +4 -1
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +13 -4
- package/plugins/runtime-modules/builder/clients/inspector-link-target-field.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +14 -1
- package/plugins/runtime-modules/builder/clients/inspector-signal-section.js +2 -2
- package/plugins/runtime-modules/builder/clients/layout-inspector.js +1 -1
- package/plugins/runtime-modules/builder/clients/layout-scaffold-buttons.js +4 -4
- package/plugins/runtime-modules/builder/clients/layout-scaffold-overlays.js +1 -1
- package/plugins/runtime-modules/builder/clients/region-inspector.js +1 -1
- package/plugins/runtime-modules/builder/clients/region-visibility-fields.js +1 -1
- package/plugins/runtime-modules/builder/clients/shells-workspace.js +1 -1
- package/plugins/runtime-modules/builder/clients/structure-canvas.js +2 -2
- package/plugins/runtime-modules/builder/clients/widget-effects-editor.js +1 -1
- package/plugins/runtime-modules/builder/clients/widget-inspector.d.ts +4 -1
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +3 -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/page-presets.server.d.ts +6 -0
- package/plugins/runtime-modules/builder/page-presets.server.js +8 -0
- package/plugins/runtime-modules/builder/pages-workspace.js +12 -1
- package/plugins/runtime-modules/builder/render-root-node-scaffold.js +5 -5
- package/plugins/runtime-modules/builder/structure-dnd.js +2 -2
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -3
- package/plugins/runtime-modules/builder/widgets/test-block/client.js +1 -1
- package/plugins/runtime-modules/content-entry-routes.d.ts +1 -0
- package/plugins/runtime-modules/contracts.js +41 -1
- package/plugins/runtime-modules/core/data-providers.d.ts +60 -0
- package/plugins/runtime-modules/core/data-providers.js +41 -0
- package/plugins/runtime-modules/core/definition.d.ts +98 -0
- package/plugins/runtime-modules/core/form-providers.d.ts +43 -0
- package/plugins/runtime-modules/core/server.js +5 -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 +34 -0
- package/plugins/runtime-modules/core/widgets/button/config.js +16 -0
- package/plugins/runtime-modules/core/widgets/button/plugin.js +37 -6
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +13 -2
- 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 +13 -2
- package/plugins/runtime-modules/core/widgets/description/editor.js +13 -13
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/gallery/authoring.js +12 -3
- package/plugins/runtime-modules/core/widgets/gallery/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/gallery/client.js +38 -21
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +18 -0
- package/plugins/runtime-modules/core/widgets/gallery/config.js +24 -0
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.js +11 -0
- package/plugins/runtime-modules/core/widgets/image/config.d.ts +35 -0
- package/plugins/runtime-modules/core/widgets/image/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/image/plugin.js +19 -1
- package/plugins/runtime-modules/core/widgets/image/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/image/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +13 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/markdown/editor.js +7 -7
- package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
- package/plugins/runtime-modules/core/widgets/multi-select/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/record/authoring.js +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 +11 -0
- 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 +13 -0
- package/plugins/runtime-modules/core/widgets/simple-text/config.js +9 -0
- package/plugins/runtime-modules/core/widgets/simple-text/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +14 -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/spacer/client.js +1 -1
- 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 +37 -0
- 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 +57 -8
- package/plugins/runtime-modules/editor/presets.d.ts +1 -0
- 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/localization/presets.d.ts +1 -0
- package/plugins/runtime-modules/news/presets.d.ts +1 -0
- package/plugins/runtime-modules/public/module.d.ts +1 -1
- package/plugins/runtime-modules/resolver.js +7 -0
- package/plugins/runtime-modules/revisions/presets.d.ts +1 -0
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
- package/plugins/runtime-modules/theme/presets.d.ts +1 -0
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +25 -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 +26 -0
- package/server-helpers/cms-page-record.js +52 -0
- package/server-helpers/cms-request.js +48 -4
- package/server-helpers/record-fields.d.ts +62 -0
- package/server-helpers/record-fields.js +86 -0
- package/server-helpers/record-samples.d.ts +21 -0
- package/server-helpers/record-samples.js +49 -0
- package/styles/builder-scaffold.css +19 -19
- package/styles/controls.css +109 -109
- package/styles/gradients.css +23 -23
- package/styles/layout-affordances.css +15 -15
- package/styles/layout-authoring-scaffold.css +20 -20
- package/styles/layout.css +9 -9
- package/styles/root.css +4 -4
- package/styles/shell.css +48 -17
- package/theme/antd-css-var-contract.d.ts +86 -80
- package/theme/antd-css-var-contract.js +92 -81
- package/theme/phi-control-shape.d.ts +1 -1
- package/theme/phi-theme-gradients.d.ts +2 -2
- package/theme/phi-theme-gradients.js +14 -14
- package/theme/phi-theme-palette.d.ts +1 -1
- package/theme/phi-theme-palette.js +2 -2
- package/theme/phi-theme-tokens.d.ts +8 -5
- package/theme/phi-theme-tokens.js +59 -28
- package/theme/phi-theme.d.ts +14 -2
- package/theme/phi-theme.js +14 -1
- package/theme/phi-tokens.d.ts +5 -0
- package/theme/phi-tokens.js +9 -0
- package/types/cms-module-descriptors.d.ts +9 -0
- package/types/cms-plugins.d.ts +27 -1
- package/types/collection-provider.d.ts +7 -0
- package/types/core-widget-placements.d.ts +42 -0
- package/types/record-provider.d.ts +109 -1
- 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 +5 -0
- package/types.d.ts +1 -0
- /package/plugins/runtime-modules/{asset/services/folder-images.server.d.ts → core/services/media-folder-images.server.d.ts} +0 -0
- /package/plugins/runtime-modules/{asset/services/folder-images.server.js → core/services/media-folder-images.server.js} +0 -0
|
@@ -76,7 +76,7 @@ export function PhiMarkdownWidgetEditor({ blockId, config, onChange, onSourceLoc
|
|
|
76
76
|
* leaves of a control's height. Stated, the clear button finds the first line by it, as it does in
|
|
77
77
|
* every field that states one; left to Ant Design it hung at its own offset, half a line above.
|
|
78
78
|
*/
|
|
79
|
-
paddingBlock: "calc((var(--
|
|
79
|
+
paddingBlock: "calc((var(--phi-control-height) - 1lh) / 2)",
|
|
80
80
|
}, style: {
|
|
81
81
|
/*
|
|
82
82
|
* As wide as the slot: the Widget fills its inline axis (`fill-inline`), so the frame decides the
|
|
@@ -86,14 +86,14 @@ export function PhiMarkdownWidgetEditor({ blockId, config, onChange, onSourceLoc
|
|
|
86
86
|
width: "100%",
|
|
87
87
|
height: MARKDOWN_EDITOR_HEIGHT,
|
|
88
88
|
minWidth: 0,
|
|
89
|
-
padding: "var(--
|
|
90
|
-
border: "1px solid var(--
|
|
89
|
+
padding: "var(--phi-padding-sm)",
|
|
90
|
+
border: "1px solid var(--phi-color-border-secondary)",
|
|
91
91
|
/*
|
|
92
|
-
* The Control shape, and not `--
|
|
92
|
+
* The Control shape, and not `--phi-border-radius`.
|
|
93
93
|
*
|
|
94
94
|
* The field is `borderless`, so this style is the box: it draws the border, the ground and the
|
|
95
95
|
* corner the Control would have drawn itself. The corner is the trap. On a Control element
|
|
96
|
-
* `--
|
|
96
|
+
* `--phi-border-radius` does not mean the surface radius -- Ant Design ships a component token in
|
|
97
97
|
* CSS variable mode as a LOCAL redefinition of the same variable on that element, so what is
|
|
98
98
|
* read here is the Control shape, and under `pill` that is the full radius. Inline, where no
|
|
99
99
|
* rule in `styles/control-shape.css` can reach it: a Markdown editor several rows tall came out
|
|
@@ -103,9 +103,9 @@ export function PhiMarkdownWidgetEditor({ blockId, config, onChange, onSourceLoc
|
|
|
103
103
|
* held at every height (THEME.md, "Control shape").
|
|
104
104
|
*/
|
|
105
105
|
borderRadius: "var(--phi-control-radius-grown-md)",
|
|
106
|
-
background: "var(--
|
|
106
|
+
background: "var(--phi-color-bg-container)",
|
|
107
107
|
resize: "none",
|
|
108
|
-
fontFamily: "var(--
|
|
108
|
+
fontFamily: "var(--phi-font-family-code, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace)",
|
|
109
109
|
lineHeight: 1.6,
|
|
110
110
|
} }));
|
|
111
111
|
}
|
|
@@ -4,6 +4,7 @@ import { resolveMarkdownRenderData } from "../../../../../components/widgets/sha
|
|
|
4
4
|
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
5
5
|
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
6
6
|
import { readPhiMarkdownSearchText, translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
|
|
7
|
+
import { resolvePhiWidgetRecordField } from "../../../../../server-helpers/record-fields";
|
|
7
8
|
import { PhiMarkdownWidget } from "./server";
|
|
8
9
|
import { PHI_MARKDOWN_WIDGET_DEFINITION, PHI_MARKDOWN_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
9
10
|
export const PHI_MARKDOWN_WIDGET_PLUGIN = {
|
|
@@ -27,13 +28,25 @@ export const PHI_MARKDOWN_WIDGET_PLUGIN = {
|
|
|
27
28
|
});
|
|
28
29
|
return [...eyebrow, ...readPhiMarkdownSearchText(data.blocks)];
|
|
29
30
|
},
|
|
30
|
-
render: ({ widget, config, runtime }) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
render: async ({ widget, config, runtime, registry }) => {
|
|
32
|
+
/*
|
|
33
|
+
* A field of the page record takes the text's place: inline, in the page's language already, and
|
|
34
|
+
* nothing where the record does not have it.
|
|
35
|
+
*/
|
|
36
|
+
const recordField = await resolvePhiWidgetRecordField({ registry, runtime, key: config.recordField, kinds: ["markdown", "text"] });
|
|
37
|
+
if (recordField.bound) {
|
|
38
|
+
return recordField.field?.value.trim()
|
|
39
|
+
? (_jsx(PhiMarkdownWidget, { config: { ...config, widgetId: widget.id, sourceMode: "inline", markdown: recordField.field.value, resolvedContent: null, translate: false }, runtime: runtime }, `widget-${widget.id}`))
|
|
40
|
+
: null;
|
|
41
|
+
}
|
|
42
|
+
return (_jsx(PhiMarkdownWidget, { config: {
|
|
43
|
+
...config,
|
|
44
|
+
widgetId: widget.id,
|
|
45
|
+
resolvedContent: widget.resolvedContent ?? null,
|
|
46
|
+
preferSource: hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
|
|
47
|
+
translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
|
|
48
|
+
}, runtime: runtime }, `widget-${widget.id}`));
|
|
49
|
+
},
|
|
37
50
|
renderPreview: ({ widget, config, runtime }) => (_jsx(PhiWidgetInertPreview, { children: _jsx(PhiMarkdownWidget, { config: {
|
|
38
51
|
...config,
|
|
39
52
|
widgetId: widget.id,
|
|
@@ -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: {
|
|
@@ -16,5 +16,5 @@ export const PHI_RECORD_WIDGET_BUILDER_PLUGIN = createPhiCmsBuilderWidgetPlugin(
|
|
|
16
16
|
key: field.key,
|
|
17
17
|
label: field.label,
|
|
18
18
|
full: field.full,
|
|
19
|
-
value: _jsx("span", { style: { color: "var(--
|
|
19
|
+
value: _jsx("span", { style: { color: "var(--phi-color-text-tertiary)" }, children: field.fieldKey }),
|
|
20
20
|
})) })));
|
|
@@ -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
|
{
|
|
@@ -110,6 +110,17 @@ export declare const PHI_RESULT_WIDGET_DEFINITION: {
|
|
|
110
110
|
editorPlacement?: "inspector" | "geometry" | "toolbar";
|
|
111
111
|
visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
|
|
112
112
|
heading?: string;
|
|
113
|
+
} & {
|
|
114
|
+
type: "record-field";
|
|
115
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
116
|
+
}) | ({
|
|
117
|
+
key: string;
|
|
118
|
+
label: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
required?: boolean;
|
|
121
|
+
editorPlacement?: "inspector" | "geometry" | "toolbar";
|
|
122
|
+
visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
|
|
123
|
+
heading?: string;
|
|
113
124
|
} & {
|
|
114
125
|
type: "dimension";
|
|
115
126
|
widthKey?: 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: {
|
|
@@ -23,6 +23,8 @@ export type PhiCmsSimpleTextWidgetConfig = PhiCmsWidgetConfigBase & {
|
|
|
23
23
|
disabled?: boolean;
|
|
24
24
|
/** `"preset"` while the words are a Preset's and translated globally (`helpers/text-source.ts`). */
|
|
25
25
|
textSource?: PhiTextSource;
|
|
26
|
+
/** A text, number or date field of the page record to show instead of the Widget's own text. */
|
|
27
|
+
recordField?: string;
|
|
26
28
|
};
|
|
27
29
|
declare function parsePhiCmsSimpleTextWidgetConfig(config: Record<string, unknown>): PhiCmsSimpleTextWidgetConfig;
|
|
28
30
|
export type PhiSimpleTextWidgetRenderableConfig = PhiCmsSimpleTextWidgetConfig & {
|
|
@@ -117,6 +119,17 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
|
|
|
117
119
|
editorPlacement?: "inspector" | "geometry" | "toolbar";
|
|
118
120
|
visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
|
|
119
121
|
heading?: string;
|
|
122
|
+
} & {
|
|
123
|
+
type: "record-field";
|
|
124
|
+
kinds: readonly import("../../../../../module-records").PhiRecordFieldKind[];
|
|
125
|
+
}) | ({
|
|
126
|
+
key: string;
|
|
127
|
+
label: string;
|
|
128
|
+
description?: string;
|
|
129
|
+
required?: boolean;
|
|
130
|
+
editorPlacement?: "inspector" | "geometry" | "toolbar";
|
|
131
|
+
visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
|
|
132
|
+
heading?: string;
|
|
120
133
|
} & {
|
|
121
134
|
type: "dimension";
|
|
122
135
|
widthKey?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_RECORD_TEXT_FIELD_KINDS } from "../../../../../helpers/record-fields";
|
|
1
2
|
import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
|
|
2
3
|
import { readPhiTextSource } from "../../../../../helpers/text-source";
|
|
3
4
|
import { PHI_SIMPLE_TEXT_MARKS } from "../../../../../types/core-widget-placements";
|
|
@@ -32,6 +33,7 @@ function parsePhiCmsSimpleTextWidgetConfig(config) {
|
|
|
32
33
|
letterSpacing: readPhiLetterSpacingStep(config.letterSpacing),
|
|
33
34
|
disabled: readBoolean(config.disabled),
|
|
34
35
|
textSource: readPhiTextSource(config.textSource),
|
|
36
|
+
recordField: readString(config.recordField),
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
export const PHI_SIMPLE_TEXT_WIDGET_DEFINITION = {
|
|
@@ -52,6 +54,13 @@ export const PHI_SIMPLE_TEXT_WIDGET_DEFINITION = {
|
|
|
52
54
|
fields: [
|
|
53
55
|
...PHI_RENDERABLE_BLOCK_GEOMETRY_FIELDS,
|
|
54
56
|
{ key: "text", type: "string", label: "Text", required: true },
|
|
57
|
+
{
|
|
58
|
+
key: "recordField",
|
|
59
|
+
type: "record-field",
|
|
60
|
+
label: "Record field",
|
|
61
|
+
description: "Shows a field of the record this page is about instead of the text. The text stands in where the page has no record.",
|
|
62
|
+
kinds: PHI_RECORD_TEXT_FIELD_KINDS,
|
|
63
|
+
},
|
|
55
64
|
{ key: "href", type: "url", label: "Href" },
|
|
56
65
|
{ key: "icon", type: "icon", label: "Icon", editorPlacement: "toolbar" },
|
|
57
66
|
{ key: "color", type: "color", label: "Color", mode: "single", editorPlacement: "toolbar" },
|
|
@@ -122,7 +122,7 @@ export function PhiSimpleTextWidgetEditor({ text, config, onChangeText, }) {
|
|
|
122
122
|
* form and wrong here -- the Widget stands on whatever its Region is painted with. Code text is
|
|
123
123
|
* the exception, because there the fill is part of how the text reads.
|
|
124
124
|
*/
|
|
125
|
-
backgroundColor: hasPhiSimpleTextMark(config, "code") ? "var(--
|
|
125
|
+
backgroundColor: hasPhiSimpleTextMark(config, "code") ? "var(--phi-color-fill-secondary, rgba(0, 0, 0, 0.04))" : "transparent",
|
|
126
126
|
}, fitContent: true, style: {
|
|
127
127
|
minWidth: 0,
|
|
128
128
|
flex: "0 0 auto",
|
|
@@ -2,6 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
3
|
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
4
|
import { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
|
|
5
|
+
import { formatPhiRecordFieldText, PHI_RECORD_TEXT_FIELD_KINDS } from "../../../../../helpers/record-fields";
|
|
6
|
+
import { resolvePhiWidgetRecordField } from "../../../../../server-helpers/record-fields";
|
|
5
7
|
import { PhiSimpleTextWidget } from "./server";
|
|
6
8
|
import { PHI_SIMPLE_TEXT_WIDGET_DEFINITION, PHI_SIMPLE_TEXT_WIDGET_PLUGIN_TYPE, resolvePhiSimpleTextWidgetText, } from "./config";
|
|
7
9
|
export const PHI_SIMPLE_TEXT_WIDGET_PLUGIN = {
|
|
@@ -16,10 +18,21 @@ export const PHI_SIMPLE_TEXT_WIDGET_PLUGIN = {
|
|
|
16
18
|
textSource: config.textSource,
|
|
17
19
|
});
|
|
18
20
|
},
|
|
19
|
-
render: ({ widget, config, runtime }) => {
|
|
21
|
+
render: async ({ widget, config, runtime, registry }) => {
|
|
20
22
|
const noTranslate = hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate);
|
|
21
23
|
// A record's text is already translated; only the Widget's own still has to be.
|
|
22
24
|
const hasResolvedText = Boolean(widget.resolvedContent?.textFields.text);
|
|
25
|
+
/*
|
|
26
|
+
* A field of the page record takes the text's place, in the page's language already. A record
|
|
27
|
+
* without the field leaves nothing to show; a Page about no record shows the Widget's own text.
|
|
28
|
+
*/
|
|
29
|
+
const recordField = await resolvePhiWidgetRecordField({ registry, runtime, key: config.recordField, kinds: PHI_RECORD_TEXT_FIELD_KINDS });
|
|
30
|
+
if (recordField.bound) {
|
|
31
|
+
const text = recordField.field ? formatPhiRecordFieldText(recordField.field, runtime.locale.current, runtime.site.timeZone) : "";
|
|
32
|
+
return text
|
|
33
|
+
? _jsx(PhiSimpleTextWidget, { blockId: widget.id, translate: false, labels: { text }, config: config, runtime: runtime }, `widget-${widget.id}`)
|
|
34
|
+
: null;
|
|
35
|
+
}
|
|
23
36
|
return (_jsx(PhiSimpleTextWidget, { blockId: widget.id, translate: !noTranslate && !hasResolvedText, textSource: config.textSource, labels: {
|
|
24
37
|
text: resolvePhiSimpleTextWidgetText({
|
|
25
38
|
...config,
|
|
@@ -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>;
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "server-only";
|
|
2
3
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../runtime-render-client";
|
|
4
|
+
import { getPhiSlotUploadWidgetLabels } from "../../../../../components/widgets/label-sets/slot-upload";
|
|
5
|
+
import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
|
|
6
|
+
import { trBulk, trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
3
7
|
import { PHI_SLOT_UPLOAD_WIDGET_TYPE } from "./config";
|
|
4
8
|
/**
|
|
5
9
|
* Handed to the Render Client by type: what a slot holds depends on who is asking and on which row a
|
|
6
|
-
* surface is about, and neither is knowable where a page is rendered for a cache.
|
|
10
|
+
* surface is about, and neither is knowable where a page is rendered for a cache. Its texts are read
|
|
11
|
+
* here, in the page's language, and travel with it: the field's own captions from its Label Set, the
|
|
12
|
+
* label somebody wrote into the config through the Site's translation unless the node says not to.
|
|
7
13
|
*/
|
|
8
|
-
export function PhiSlotUploadWidget({ config }) {
|
|
9
|
-
|
|
14
|
+
export async function PhiSlotUploadWidget({ config, runtime, translate = true, }) {
|
|
15
|
+
const label = config?.label?.trim();
|
|
16
|
+
const [labels, translatedLabel] = await Promise.all([
|
|
17
|
+
getPhiSlotUploadWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime)),
|
|
18
|
+
translate && label
|
|
19
|
+
? (runtime.locale.current ? trBulkForLocale(runtime.locale.current, [label]) : trBulk([label]))
|
|
20
|
+
.then(([text]) => text?.trim() || label)
|
|
21
|
+
: Promise.resolve(label),
|
|
22
|
+
]);
|
|
23
|
+
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PHI_SLOT_UPLOAD_WIDGET_TYPE, componentProps: { config: config && translatedLabel ? { ...config, label: translatedLabel } : config, labels } }));
|
|
10
24
|
}
|