@phis/ui 0.7.1 → 0.7.3

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.
Files changed (102) hide show
  1. package/components/cms/phi-cms-layout-renderer.d.ts +1 -0
  2. package/components/cms/phi-cms-layout-renderer.js +35 -6
  3. package/components/controls/phi-collection-reorder-context.d.ts +21 -0
  4. package/components/controls/phi-collection-reorder-context.js +6 -0
  5. package/components/controls/phi-collection-sortable-layout-control.d.ts +17 -0
  6. package/components/controls/phi-collection-sortable-layout-control.js +72 -0
  7. package/components/controls/phi-collection-view-control.d.ts +1 -1
  8. package/components/controls/phi-collection-view-control.js +15 -1
  9. package/components/controls/phi-media-asset-tile-control.d.ts +12 -5
  10. package/components/controls/phi-media-picker-control.d.ts +14 -1
  11. package/components/controls/phi-media-picker-control.js +11 -2
  12. package/components/controls/use-phi-color-control-presets.d.ts +2 -2
  13. package/components/controls/use-phi-color-control-presets.js +16 -2
  14. package/components/forms/compound-form-controls.d.ts +1 -1
  15. package/components/forms/compound-form-controls.js +6 -4
  16. package/components/forms/form-field-labels.d.ts +3 -1
  17. package/components/forms/form-field-labels.js +19 -6
  18. package/components/forms/form-provider-contract.js +2 -1
  19. package/components/forms/media-asset-field-keys.d.ts +4 -1
  20. package/components/forms/media-asset-field-keys.js +4 -1
  21. package/components/forms/table-field-keys.d.ts +8 -0
  22. package/components/forms/table-field-keys.js +8 -0
  23. package/components/forms/table-field-labels.d.ts +16 -0
  24. package/components/forms/table-field-labels.js +16 -0
  25. package/components/forms/table-field-text.d.ts +9 -0
  26. package/components/forms/table-field-text.js +20 -0
  27. package/components/forms/upload-field-refusal-labels.d.ts +10 -0
  28. package/components/forms/upload-field-refusal-labels.js +24 -0
  29. package/components/forms/upload-form-control.js +3 -16
  30. package/components/layouts/clients/phi-flex-layout-client.js +12 -2
  31. package/components/media/media-folder-name-path.d.ts +17 -0
  32. package/components/media/media-folder-name-path.js +36 -0
  33. package/components/media/media-upload-flow.d.ts +42 -0
  34. package/components/media/media-upload-flow.js +120 -4
  35. package/components/media/media-upload-refusals.js +5 -2
  36. package/components/media/phi-area-upload-widget.js +4 -0
  37. package/components/media/phi-media-picker-binding.d.ts +48 -1
  38. package/components/media/phi-media-picker-binding.js +99 -6
  39. package/components/media/phi-media-upload.d.ts +7 -1
  40. package/components/media/phi-media-upload.js +17 -5
  41. package/components/widgets/client/shared/phi-collection-reorder.d.ts +45 -0
  42. package/components/widgets/client/shared/phi-collection-reorder.js +110 -0
  43. package/components/widgets/client/shared/phi-collection-view-binding.js +2 -1
  44. package/components/widgets/client/shared/phi-command-buttons.d.ts +12 -0
  45. package/components/widgets/client/shared/phi-command-buttons.js +23 -3
  46. package/components/widgets/config/command-buttons.js +3 -0
  47. package/components/widgets/label-sets/collection-view.d.ts +4 -0
  48. package/components/widgets/label-sets/collection-view.js +16 -0
  49. package/components/widgets/label-sets/color-picker.js +2 -0
  50. package/components/widgets/label-sets/table.d.ts +6 -0
  51. package/components/widgets/label-sets/table.js +10 -0
  52. package/components/widgets/label-types/collection-view.d.ts +8 -0
  53. package/components/widgets/label-types/collection-view.js +4 -0
  54. package/components/widgets/label-types/color-picker.d.ts +1 -0
  55. package/components/widgets/label-types/color-picker.js +1 -0
  56. package/controls.d.ts +1 -1
  57. package/helpers/cms-content-binding.d.ts +7 -1
  58. package/helpers/cms-content-binding.js +10 -2
  59. package/helpers/cms-node-visibility.d.ts +25 -0
  60. package/helpers/cms-node-visibility.js +35 -1
  61. package/package.json +2 -2
  62. package/plugins/runtime-modules/accounting/definition.js +1 -1
  63. package/plugins/runtime-modules/accounting/presets.js +5 -12
  64. package/plugins/runtime-modules/area-definitions.d.ts +9 -39
  65. package/plugins/runtime-modules/area-definitions.js +8 -8
  66. package/plugins/runtime-modules/asset/controller/runtime.js +1 -6
  67. package/plugins/runtime-modules/asset/definition.d.ts +8 -0
  68. package/plugins/runtime-modules/asset/form-providers.d.ts +8 -0
  69. package/plugins/runtime-modules/asset/form-providers.js +6 -0
  70. package/plugins/runtime-modules/asset/media-asset-field.d.ts +34 -4
  71. package/plugins/runtime-modules/asset/media-asset-field.js +50 -3
  72. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +13 -0
  73. package/plugins/runtime-modules/asset/media-asset-form-control.js +81 -5
  74. package/plugins/runtime-modules/asset/widgets/area-upload/config.js +7 -1
  75. package/plugins/runtime-modules/builder/data-providers.js +1 -0
  76. package/plugins/runtime-modules/builder/page-meta-form.js +6 -6
  77. package/plugins/runtime-modules/builder/services/runtime-modules-table.d.ts +1 -0
  78. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +4 -0
  79. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -5
  80. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +5 -0
  81. package/plugins/runtime-modules/core/widgets/collection-view/client.js +50 -4
  82. package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +28 -2
  83. package/plugins/runtime-modules/core/widgets/collection-view/config.js +13 -0
  84. package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +1 -1
  85. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +4 -1
  86. package/plugins/runtime-modules/core/widgets/collection-view/server.js +19 -4
  87. package/plugins/runtime-modules/core/widgets/image/config.d.ts +1 -0
  88. package/plugins/runtime-modules/core/widgets/image/config.js +1 -0
  89. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -1
  90. package/plugins/runtime-modules/core/widgets/markdown/config.js +1 -0
  91. package/plugins/runtime-modules/core/widgets/markdown/plugin.js +0 -1
  92. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
  93. package/plugins/runtime-modules/core/widgets/simple-text/config.js +1 -0
  94. package/plugins/runtime-modules/core/widgets/table/client.js +8 -1
  95. package/server-helpers/cms-node-record.d.ts +18 -0
  96. package/server-helpers/cms-node-record.js +28 -0
  97. package/types/cms-plugins.d.ts +6 -0
  98. package/types/collection-provider.d.ts +7 -0
  99. package/types/collection-view-widget.d.ts +11 -0
  100. package/types/core-widget-placements.d.ts +11 -0
  101. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.d.ts +0 -6
  102. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +0 -49
@@ -1,19 +1,25 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useMemo } from "react";
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { PhiButtonControl } from "../../../components/controls/phi-button-control";
5
5
  import { PhiFlexControl } from "../../../components/controls/phi-flex-control";
6
6
  import { PhiMediaAssetTileControl } from "../../../components/controls/phi-media-asset-tile-control";
7
7
  import { PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS } from "../../../components/forms/media-asset-field-keys";
8
+ import { PHI_FORM_UPLOAD_LABEL_KEYS } from "../../../components/forms/upload-field-keys";
9
+ import { readPhiFormUploadRefusalLabels } from "../../../components/forms/upload-field-refusal-labels";
8
10
  import { PhiMediaPickerControl } from "../../../components/controls/phi-media-picker-control";
9
11
  import { PhiTypographyControl } from "../../../components/controls/phi-typography-control";
10
12
  import { PHI_MEDIA_WIDGET_DEFAULT_LABELS } from "../../../components/media/media-widget-labels";
11
- import { usePhiMediaPickerBinding } from "../../../components/media/phi-media-picker-binding";
13
+ import { usePhiMediaPickerBinding, } from "../../../components/media/phi-media-picker-binding";
14
+ import { normalizePhiImagePreviewTile } from "../../../components/media/phi-image-preview-data";
15
+ import { usePhiMediaUpload } from "../../../components/media/phi-media-upload";
16
+ import { readPhiMediaUploadFolderPathReach, } from "../../../components/media/media-upload-flow";
17
+ import { PHI_MEDIA_UPLOAD_FIELD_DEFAULT_LABELS } from "../../../components/media/media-upload-labels";
12
18
  import { usePhiAuthoringAssetDetails } from "../../../components/media/use-authoring-asset-details";
13
19
  import { PHI_SEARCH_WIDGET_DEFAULT_LABELS } from "../../../components/widgets/label-types/search";
14
20
  import { isPhiMediaAssetPublic } from "../../../constants/media";
15
21
  import { PHI_FORM_MEDIA_ASSET_LABEL_KEYS } from "./form-providers";
16
- import { isPhiMediaAssetFieldSelectable, readPhiMediaAssetFieldConfig, readPhiMediaAssetFieldValue, } from "./media-asset-field";
22
+ import { isPhiMediaAssetFieldSelectable, readPhiMediaAssetFieldConfig, readPhiMediaAssetFieldUploadRefusal, readPhiMediaAssetFieldValue, resolvePhiMediaAssetFieldFolderPath, } from "./media-asset-field";
17
23
  const DEFAULT_LABELS = {
18
24
  choose: "Choose",
19
25
  change: "Change",
@@ -31,6 +37,19 @@ const PREVIEW_SIZE = 72;
31
37
  * value is the Asset id as a number, `null` for none, and the field keeps no copy of it: what it keeps is
32
38
  * the picker's open state.
33
39
  *
40
+ * Inside the picker a file from the reader's machine can go up too, into the Folder the picker shows, by
41
+ * the upload every surface sends with (`usePhiMediaUpload`, Core's upload session); what it made is
42
+ * chosen as a picked tile would be. It goes into the Site Space, like everything the field offers, and
43
+ * Core delivers what goes there publicly. What comes back is asked what a pick is asked: an Asset of
44
+ * another kind (a file the browser could not name reaches Core unrefused) or, for a `publicOnly` field,
45
+ * one that is not public is left in the list unchosen, and the field says why. While the file is on its
46
+ * way the Form's submit is held, as the upload field holds it, and closing the picker stops it.
47
+ * `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
48
+ * Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
49
+ * who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
50
+ * path that is there. An upload from there goes into the whole path, the missing Folders created the way
51
+ * `area-upload` creates them (`resolvePhiMediaUploadFolderPathId`).
52
+ *
34
53
  * Only the Site Space is offered, in every Area (`siteSpaceOnly`): a Form stores a reference everybody
35
54
  * who reads the stored value will follow, and a personal or a group Space cannot honestly stand behind
36
55
  * that. `config.publicOnly` greys out the Assets that are not delivered publicly, from the delivery
@@ -41,13 +60,63 @@ const PREVIEW_SIZE = 72;
41
60
  * field reads (`usePhiAuthoringAssetDetails`), so the preview shows what is stored. Where that read is
42
61
  * refused, the field says so and still lets the value be changed or removed.
43
62
  */
44
- export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readOnly, onChange, }) => {
63
+ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, }) => {
45
64
  const config = useMemo(() => readPhiMediaAssetFieldConfig(field.config), [field.config]);
46
65
  const assetId = readPhiMediaAssetFieldValue(value);
47
66
  const asset = usePhiAuthoringAssetDetails(assetId);
48
67
  const read = (key) => labels?.[PHI_FORM_MEDIA_ASSET_LABEL_KEYS[key]]?.trim() || DEFAULT_LABELS[key];
49
68
  const choose = read("choose");
50
69
  const change = read("change");
70
+ const notPublic = read("notPublic");
71
+ // The upload's refusals and its hold are the upload field's words, read for this field too.
72
+ const refusals = useMemo(() => readPhiFormUploadRefusalLabels(labels), [labels]);
73
+ const pendingLabel = labels?.[PHI_FORM_UPLOAD_LABEL_KEYS.pending]?.trim() || PHI_MEDIA_UPLOAD_FIELD_DEFAULT_LABELS.pending;
74
+ const [uploadNotice, setUploadNotice] = useState(null);
75
+ const acceptance = useMemo(() => ({ kinds: [config.mediaType], multiple: false }), [config.mediaType]);
76
+ const transfer = usePhiMediaUpload({
77
+ labels: refusals,
78
+ acceptance,
79
+ onRejected: (message) => setUploadNotice(message),
80
+ });
81
+ const { upload: sendFile, cancel: cancelUpload, uploading } = transfer;
82
+ const uploadProgress = transfer.items.find((item) => item.status === "uploading")?.progress ?? null;
83
+ useEffect(() => {
84
+ if (!formContext || !uploading)
85
+ return;
86
+ formContext.holdSubmit(field.key, pendingLabel);
87
+ return () => formContext.holdSubmit(field.key, null);
88
+ }, [field.key, formContext, pendingLabel, uploading]);
89
+ /*
90
+ * The start Folder as the Form's values name it when the picker opens (`{key}` placeholders), kept for
91
+ * the upload into it: the path the picker opened on is the path the file goes to.
92
+ */
93
+ const startFolderPath = config.folderPath;
94
+ const startFolderPathRef = useRef([]);
95
+ const openOnFolder = useCallback(async (signal) => {
96
+ const path = resolvePhiMediaAssetFieldFolderPath(startFolderPath, formContext?.getValues() ?? {});
97
+ startFolderPathRef.current = path;
98
+ return path.length > 0 ? readPhiMediaUploadFolderPathReach(path, signal) : { folderId: null, complete: true };
99
+ }, [formContext, startFolderPath]);
100
+ const upload = useMemo(() => ({
101
+ accept: transfer.accept,
102
+ progress: uploadProgress,
103
+ notice: uploadNotice,
104
+ send: async (file, folderId, intoStartFolder) => {
105
+ setUploadNotice(null);
106
+ // No Space is named, which Core answers with the Site Space -- the only one the field offers.
107
+ const asset = await sendFile(file, intoStartFolder ? { folderPath: startFolderPathRef.current } : { folderId });
108
+ if (!asset)
109
+ return null;
110
+ const tile = normalizePhiImagePreviewTile(asset, []);
111
+ const refusal = readPhiMediaAssetFieldUploadRefusal(config, tile);
112
+ if (refusal) {
113
+ setUploadNotice(refusal === "kind" ? refusals.errorTypeNotAllowed : notPublic);
114
+ return null;
115
+ }
116
+ return tile;
117
+ },
118
+ cancel: cancelUpload,
119
+ }), [cancelUpload, config, notPublic, refusals, sendFile, transfer.accept, uploadNotice, uploadProgress]);
51
120
  // The picker's words come from the Media Label Set, which the Form Widget read for this Form
52
121
  // (`resolvePhiFormFieldLabels`); outside a Form that read them, the English defaults stand.
53
122
  const pickerLabels = useMemo(() => {
@@ -76,9 +145,14 @@ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readO
76
145
  importFailedText: readPicker("importFailedText", base.picker.importFailedText),
77
146
  loadMoreLabel: readPicker("loadMoreLabel", base.picker.loadMoreLabel),
78
147
  },
148
+ upload: {
149
+ ...base.upload,
150
+ uploadToggleLabel: readPicker("uploadLabel", base.upload.uploadToggleLabel),
151
+ refusals,
152
+ },
79
153
  space: { ...base.space, label: readPicker("spaceLabel", base.space.label) },
80
154
  };
81
- }, [assetId, change, choose, labels]);
155
+ }, [assetId, change, choose, labels, refusals]);
82
156
  const picker = usePhiMediaPickerBinding({
83
157
  config: {
84
158
  mediaType: config.mediaType,
@@ -93,6 +167,8 @@ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readO
93
167
  isAssetSelectable: config.publicOnly ? (candidate) => isPhiMediaAssetFieldSelectable(config, candidate) : undefined,
94
168
  onAssetSelect: (picked) => onChange?.(picked.id),
95
169
  onAssetClear: () => onChange?.(null),
170
+ upload,
171
+ openOnFolder: startFolderPath.length > 0 ? openOnFolder : null,
96
172
  });
97
173
  const locked = disabled || readOnly;
98
174
  return (_jsxs(PhiFlexControl, { vertical: true, gap: "small", children: [assetId == null ? null : (_jsxs(PhiFlexControl, { align: "center", gap: "small", children: [asset ? (_jsx(PhiFlexControl, { style: { width: PREVIEW_SIZE, flex: "none" }, children: _jsx(PhiMediaAssetTileControl, { asset: asset, minColumnWidth: PREVIEW_SIZE, size: "small", showTypeLabel: false, showDimensions: false }) })) : null, _jsx(PhiFlexControl, { vertical: true, children: asset == null ? (_jsxs(_Fragment, { children: [_jsx(PhiTypographyControl, { ellipsis: true, children: `#${assetId}` }), _jsx(PhiTypographyControl, { type: "secondary", children: read("unavailable") })] })) : config.publicOnly && !isPhiMediaAssetPublic(asset.deliveryPolicy, asset.lifecycleStatus) ? (_jsx(PhiTypographyControl, { type: "danger", children: read("notPublic") })) : null })] })), readOnly ? null : (_jsxs(PhiFlexControl, { gap: "small", children: [_jsx(PhiMediaPickerControl, { ...picker, disabled: locked }), assetId == null ? null : (_jsx(PhiButtonControl, { label: read("remove"), disabled: locked, onClick: () => onChange?.(null) }))] })), config.publicOnly && !readOnly ? (_jsx(PhiTypographyControl, { type: "secondary", children: read("publicOnlyHint") })) : null] }));
@@ -30,7 +30,7 @@ export const PHI_AREA_UPLOAD_WIDGET_DEFINITION = {
30
30
  kind: "widget",
31
31
  pluginKey: resolvePhiCmsWidgetPluginKey("area-upload"),
32
32
  typeKey: "area-upload",
33
- // An upload goes into the folder the Asset Controller holds, so the Controller is where this is.
33
+ // Without a folderPath an upload goes into the folder the Asset Controller holds, so the Controller is where this is.
34
34
  requiredRuntimeControllers: requirePhiAssetController,
35
35
  title: "Area Upload",
36
36
  description: "Dropzone and temporary upload wall for area-scoped media assets.",
@@ -42,6 +42,12 @@ export const PHI_AREA_UPLOAD_WIDGET_DEFINITION = {
42
42
  { key: "allowDelete", type: "boolean", label: "Allow Delete" },
43
43
  { key: "multiple", type: "boolean", label: "Multiple" },
44
44
  { key: "accept", type: "string", label: "Accept" },
45
+ /*
46
+ * A Folder of the Site Space by its path of names, "Shop Images / Products": every upload goes there,
47
+ * whichever Folder the Controller has open, and the Folders it names that are missing are created on
48
+ * the first upload. A path and not an id, so a preset can state it for every Site; it is resolved
49
+ * when an upload begins (`resolvePhiMediaUploadInitOptions`). Empty: the Controller's Folder.
50
+ */
45
51
  { key: "folderPath", type: "string", label: "Folder Path" },
46
52
  { key: "presentationFlags", type: "number", label: "Flags", min: 0, precision: 0 },
47
53
  ],
@@ -170,6 +170,7 @@ export const PHI_BUILDER_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
170
170
  { key: "description", title: "Description", type: "string" },
171
171
  { key: "category", title: "Category", type: "string" },
172
172
  { key: "isBaseModule", title: "Area Base module", type: "boolean", required: true },
173
+ { key: "alwaysActive", title: "Always active", type: "boolean", required: true },
173
174
  { key: "baseAreaKey", title: "Base area", type: "string" },
174
175
  /*
175
176
  * One optional boolean per Area: `true`/`false` is the Module's activation there, absence
@@ -272,7 +272,7 @@ const effectsDescriptors = {
272
272
  columns: transitionColumns,
273
273
  add: {
274
274
  enabled: true,
275
- label: "Add",
275
+ label: label("add", "Add"),
276
276
  defaultRow: {
277
277
  type: "fade",
278
278
  mode: "in",
@@ -316,10 +316,10 @@ const effectsDescriptors = {
316
316
  transitionEasing: "ease-out",
317
317
  },
318
318
  },
319
- remove: { enabled: true, label: "Remove transition" },
319
+ remove: { enabled: true, label: label("removeTransition", "Remove transition") },
320
320
  reorder: true,
321
321
  bordered: true,
322
- emptyText: "No transitions configured.",
322
+ emptyText: label("table.emptyTransitions", "No transitions configured."),
323
323
  layout: { mode: "auto", overflowX: "auto" },
324
324
  },
325
325
  },
@@ -410,7 +410,7 @@ const effectsDescriptors = {
410
410
  columns: viewportColumns,
411
411
  add: {
412
412
  enabled: true,
413
- label: "Add",
413
+ label: label("add", "Add"),
414
414
  defaultRow: {
415
415
  property: "translate",
416
416
  axis: "y",
@@ -448,10 +448,10 @@ const effectsDescriptors = {
448
448
  viewportPerspectivePx: 800,
449
449
  },
450
450
  },
451
- remove: { enabled: true, label: "Remove viewport effect" },
451
+ remove: { enabled: true, label: label("removeViewportEffect", "Remove viewport effect") },
452
452
  reorder: true,
453
453
  bordered: true,
454
- emptyText: "No viewport effects configured.",
454
+ emptyText: label("table.emptyViewportEffects", "No viewport effects configured."),
455
455
  layout: { mode: "auto", overflowX: "auto" },
456
456
  },
457
457
  },
@@ -18,6 +18,7 @@ export declare function buildRuntimeModuleRows(state: PhiDeveloperBuilderWorkspa
18
18
  description: string;
19
19
  category: string;
20
20
  isBaseModule: boolean;
21
+ alwaysActive: boolean;
21
22
  baseAreaKey: "public" | "app" | "admin" | "builder" | "editor" | "accounting" | null;
22
23
  }[];
23
24
  /** What the Modules table says when a Module that brings its own shell is switched on over a stored one. */
@@ -101,6 +101,7 @@ export function buildRuntimeModuleRows(state, categoryLabels, view, serverUnavai
101
101
  .replaceAll("%1", unavailable.missingCapabilities.join(", ") || unavailable.diagnosticCode),
102
102
  category: serverUnavailableLabels?.category ?? "Server part missing",
103
103
  isBaseModule: false,
104
+ alwaysActive: false,
104
105
  baseAreaKey: null,
105
106
  ...Object.fromEntries(PHI_CMS_AREA_KEYS.map((areaKey) => [`area_${areaKey}`, null])),
106
107
  };
@@ -121,6 +122,8 @@ export function buildRuntimeModuleRows(state, categoryLabels, view, serverUnavai
121
122
  description: definition.description,
122
123
  category: categoryLabels?.[readPhiRuntimeModuleCategory(definition.category)] ?? definition.category,
123
124
  isBaseModule: baseAreaKey != null,
125
+ // Its Area checkboxes hold no choice either: they show where it runs, disabled as a Base module's own Area is.
126
+ alwaysActive: definition.activation === "always",
124
127
  baseAreaKey,
125
128
  ...Object.fromEntries(PHI_CMS_AREA_KEYS.map((areaKey) => [
126
129
  `area_${areaKey}`,
@@ -177,6 +180,7 @@ function buildUnresolvedRuntimeModuleRows(state, view, labels) {
177
180
  description: labels?.missingHint ?? "Not part of this build. The next save drops it from the Site.",
178
181
  category: labels?.missing ?? "Not in this build",
179
182
  isBaseModule: false,
183
+ alwaysActive: false,
180
184
  baseAreaKey: null,
181
185
  ...Object.fromEntries(PHI_CMS_AREA_KEYS.map((areaKey) => [
182
186
  `area_${areaKey}`,
@@ -1573,7 +1573,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1573
1573
  * One checkbox column per Area: the switch is the Module everywhere, these are
1574
1574
  * the per-Area refinement. A Module not eligible for an Area carries null there
1575
1575
  * and the cell renders empty; the Area whose Base module the row is stays
1576
- * checked and disabled.
1576
+ * checked and disabled, and so does every Area of a Module that is always active.
1577
1577
  */
1578
1578
  ...PHI_CMS_AREA_KEYS.map((areaKey) => ({
1579
1579
  key: `area_${areaKey}`,
@@ -1583,10 +1583,11 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1583
1583
  editor: {
1584
1584
  control: "checkbox",
1585
1585
  disabledWhen: {
1586
- source: "row",
1587
- valuePath: "baseAreaKey",
1588
- operator: "equals",
1589
- value: areaKey,
1586
+ match: "any",
1587
+ conditions: [
1588
+ { source: "row", valuePath: "baseAreaKey", operator: "equals", value: areaKey },
1589
+ { source: "row", valuePath: "alwaysActive", operator: "truthy" },
1590
+ ],
1590
1591
  },
1591
1592
  },
1592
1593
  })),
@@ -1,10 +1,15 @@
1
1
  import type { PhiCmsInstanceId } from "../../../../../types/cms-instance-id";
2
+ import { type PhiCollectionViewWidgetLabels } from "../../../../../components/widgets/label-types/collection-view";
2
3
  import type { PhiCmsCollectionViewWidgetConfig } from "../../../../../types/collection-view-widget";
3
4
  import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
4
5
  export type PhiCollectionViewWidgetProps = {
5
6
  config?: PhiCmsCollectionViewWidgetConfig | null;
6
7
  widgetId?: PhiCmsInstanceId | null;
7
8
  labels?: unknown;
9
+ /** The Widget's own words (the reorder handle and refusal), loaded where `features.reorder` is on. */
10
+ reorderLabels?: PhiCollectionViewWidgetLabels;
11
+ /** The bound resource's item key path, from its declaration; only where `features.reorder` is on. */
12
+ itemIdentityPath?: string | null;
8
13
  /** Where this draws; the parsed config does not carry it, so the plugin reads it off the node. */
9
14
  renderMode: PhiRenderableBlockRenderMode;
10
15
  preview?: boolean;
@@ -1,7 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createElement } from "react";
3
+ import { createElement, useCallback, useMemo, useState } from "react";
4
4
  import { PhiCollectionViewSkeletonControl } from "../../../../../components/controls/phi-collection-view-control";
5
+ import { PhiCollectionReorderContext } from "../../../../../components/controls/phi-collection-reorder-context";
6
+ import { usePhiCollectionReorderBinding } from "../../../../../components/widgets/client/shared/phi-collection-reorder";
7
+ import { usePhiApplicationFeedback } from "../../../../../components/runtime/use-phi-application-feedback";
8
+ import { PHI_COLLECTION_VIEW_WIDGET_DEFAULT_LABELS, } from "../../../../../components/widgets/label-types/collection-view";
5
9
  import { normalizePhiCssSize } from "../../../../../components/layouts/phi-layout-contract";
6
10
  import { usePhiConfig } from "../../../../../components/root/phi-config-provider";
7
11
  import { usePhiRuntimeModuleState } from "../../../../../components/runtime/runtime-module-context";
@@ -14,6 +18,10 @@ import { usePhiCollectionViewBinding } from "../../../../../components/widgets/c
14
18
  import { PhiCollectionSourceFailureText, readPhiCollectionViewDeclaredFailure, } from "../../../../../components/widgets/shared/collection-source-failure";
15
19
  import { PhiWidgetFailure } from "../../../../../components/widgets/shared/widget-failure-client";
16
20
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
21
+ import { usePhiSignalListener } from "../../../../../components/runtime/runtime-signal-bus";
22
+ import { findPhiSignalListenRoute, resolvePhiSignalListenFilter } from "../../../../../helpers/signal-listen-routes";
23
+ import { readPhiTableBindingParamsSignalValue } from "../../../../../types/table-signal-values";
24
+ import { isPhiRecord } from "../../../../../helpers/is-record";
17
25
  /**
18
26
  * The parts of a Collection View a Tour can point at, as `cms:<instanceId>:<part>` (design/TOURS.md): the
19
27
  * filters and search, the toolbar, the items and the pagination. A part the view does not draw is simply
@@ -50,10 +58,35 @@ function PhiCollectionViewWidgetPreview({ config, widgetId, renderMode, skeleton
50
58
  }
51
59
  return (_jsx(PhiCollectionViewSkeletonControl, { mode: presentation?.mode ?? "grid", gap: normalizePhiCssSize(presentation?.gap) ?? token.paddingSM, minColumnWidth: normalizePhiCssSize(presentation?.minColumnWidth) ?? 102, active: skeletonActive }));
52
60
  }
53
- function PhiCollectionViewWidgetLive({ config, labels, widgetId, renderMode, }) {
61
+ function PhiCollectionViewWidgetLive({ config, labels, reorderLabels, itemIdentityPath, widgetId, renderMode, }) {
54
62
  const signalIdentity = usePhiSignalIdentity();
55
63
  usePhiVisualAnchorParts(signalIdentity.receiver?.startsWith("cms:") ? signalIdentity.receiver : null, PHI_COLLECTION_VIEW_VISUAL_ANCHOR_PARTS);
56
- const source = config?.source ?? null;
64
+ /*
65
+ * The binding params, as the Table takes them (`bindingParamsChange`): the configured `source.params`
66
+ * until a received `{ params }` is laid over them, and handed to the Provider as `source.params`. A
67
+ * new set starts the list over -- first page, the initial query, nothing of the old answer shown
68
+ * (`usePhiCollectionViewBinding`). The chosen set is tagged with the configuration it was laid over, so
69
+ * a Builder edit of the configured params is a new starting point.
70
+ */
71
+ const configuredSource = config?.source ?? null;
72
+ const configuredBindingParams = useMemo(() => isPhiRecord(configuredSource?.params) ? configuredSource.params : {}, [configuredSource]);
73
+ const bindingParamsSeed = JSON.stringify(configuredBindingParams);
74
+ const [chosenBindingParams, setChosenBindingParams] = useState(null);
75
+ const bindingParams = chosenBindingParams?.seed === bindingParamsSeed
76
+ ? chosenBindingParams.params
77
+ : configuredBindingParams;
78
+ const source = useMemo(() => configuredSource ? { ...configuredSource, params: bindingParams } : null, [bindingParams, configuredSource]);
79
+ // What the renderer reads of the binding is the source the Provider is asked with.
80
+ const resolvedConfig = useMemo(() => config ? { ...config, source } : config, [config, source]);
81
+ const listenRoutes = useMemo(() => config?.signalRoutes?.listens ?? [], [config?.signalRoutes?.listens]);
82
+ usePhiSignalListener(useCallback((signal) => {
83
+ const route = findPhiSignalListenRoute(listenRoutes, signal, signalIdentity.receiver);
84
+ if (route?.capabilityId !== "bindingParamsChange")
85
+ return;
86
+ const next = readPhiTableBindingParamsSignalValue(signal.value);
87
+ if (next)
88
+ setChosenBindingParams({ seed: bindingParamsSeed, params: { ...bindingParams, ...next.params } });
89
+ }, [bindingParams, bindingParamsSeed, listenRoutes, signalIdentity.receiver]), useMemo(() => resolvePhiSignalListenFilter(listenRoutes), [listenRoutes]), signalIdentity.receiver);
57
90
  const { resource, bindingError, queryError, binding } = usePhiCollectionViewBinding({
58
91
  source,
59
92
  initialQuery: config?.initialQuery,
@@ -62,6 +95,19 @@ function PhiCollectionViewWidgetLive({ config, labels, widgetId, renderMode, })
62
95
  // The provider ships a renderer with its resource; a Site may name another Module's instead. Both are
63
96
  // ordinary Render Clients, so neither side has to know the other exists.
64
97
  const rendererKey = config?.itemRendererKey ?? resource?.itemRendererKey ?? null;
98
+ /*
99
+ * Drag reordering (`features.reorder`) goes around whatever the renderer draws: the renderer gets the
100
+ * binding with the items in the dropped order while the Provider writes it, and its Collection Control
101
+ * puts the handles on (`PhiCollectionReorderContext`). The Widget keeps no order of its own.
102
+ */
103
+ const { showMessage } = usePhiApplicationFeedback();
104
+ const { binding: presentedBinding, reorder } = usePhiCollectionReorderBinding({
105
+ config: resolvedConfig,
106
+ binding,
107
+ itemIdentityPath: itemIdentityPath ?? null,
108
+ labels: reorderLabels ?? PHI_COLLECTION_VIEW_WIDGET_DEFAULT_LABELS,
109
+ showMessage,
110
+ });
65
111
  const ItemRenderer = usePhiRuntimeModuleRenderClient(rendererKey);
66
112
  usePhiControlSignalController({
67
113
  key: "collectionReload",
@@ -92,7 +138,7 @@ function PhiCollectionViewWidgetLive({ config, labels, widgetId, renderMode, })
92
138
  // component in tag position reads to React -- and to `react-hooks/static-components` -- as a new
93
139
  // component per render. This is the same call `PhiRuntimeModuleRenderClientHost` makes for a Widget.
94
140
  // `renderMode` goes along so a renderer's own configuration failures are said the same way.
95
- return createElement(ItemRenderer, { config, binding, labels, widgetId, renderMode });
141
+ return (_jsx(PhiCollectionReorderContext.Provider, { value: reorder, children: createElement(ItemRenderer, { config: resolvedConfig ?? config, binding: presentedBinding, labels, widgetId, renderMode }) }));
96
142
  }
97
143
  export function PhiCollectionViewWidget(props) {
98
144
  return props.preview
@@ -28,12 +28,19 @@ export declare const PHI_COLLECTION_VIEW_WIDGET_DEFINITION: {
28
28
  valueSchema: `${string}/signals/${string}`;
29
29
  valueSchemaFrom?: undefined;
30
30
  })[];
31
- listens: {
31
+ listens: ({
32
32
  id: string;
33
33
  channel: string;
34
34
  action: "activate";
35
35
  valueType: "none";
36
- }[];
36
+ valueSchema?: undefined;
37
+ } | {
38
+ id: string;
39
+ channel: string;
40
+ action: "change";
41
+ valueType: "json";
42
+ valueSchema: `${string}/signals/${string}`;
43
+ })[];
37
44
  };
38
45
  fields: ({
39
46
  key: string;
@@ -338,6 +345,25 @@ export declare const PHI_COLLECTION_VIEW_WIDGET_DEFINITION: {
338
345
  options?: undefined;
339
346
  min?: undefined;
340
347
  precision?: undefined;
348
+ } | {
349
+ key: string;
350
+ type: "string";
351
+ label: string;
352
+ placeholder: string;
353
+ providerKind?: undefined;
354
+ presentation?: undefined;
355
+ optionsProvider?: undefined;
356
+ emptyOption?: undefined;
357
+ emptyValue?: undefined;
358
+ options?: undefined;
359
+ min?: undefined;
360
+ itemKeyField?: undefined;
361
+ itemLabelField?: undefined;
362
+ addLabel?: undefined;
363
+ emptyLabel?: undefined;
364
+ defaultItem?: undefined;
365
+ itemFields?: undefined;
366
+ precision?: undefined;
341
367
  } | {
342
368
  key: string;
343
369
  type: "number";
@@ -109,6 +109,7 @@ function normalizePhiCmsCollectionViewWidgetConfig(config) {
109
109
  const search = isPhiRecord(features.search) ? features.search : null;
110
110
  const actions = isPhiRecord(features.actions) ? features.actions : {};
111
111
  const pagination = isPhiRecord(features.pagination) ? features.pagination : null;
112
+ const reorder = isPhiRecord(features.reorder) ? features.reorder : null;
112
113
  return {
113
114
  presentation: {
114
115
  title: readString(presentation.title),
@@ -134,6 +135,10 @@ function normalizePhiCmsCollectionViewWidgetConfig(config) {
134
135
  } : undefined,
135
136
  filters: readFilters(features.filters),
136
137
  actions: { toolbar: readToolbarActions(actions.toolbar) },
138
+ reorder: reorder ? {
139
+ enabled: readBoolean(reorder.enabled) ?? false,
140
+ actionKey: readString(reorder.actionKey)?.trim() || undefined,
141
+ } : undefined,
137
142
  pagination: pagination ? {
138
143
  enabled: readBoolean(pagination.enabled) ?? true,
139
144
  pageSize: readNumber(pagination.pageSize),
@@ -175,6 +180,8 @@ export const PHI_COLLECTION_VIEW_WIDGET_DEFINITION = {
175
180
  ],
176
181
  listens: [
177
182
  { id: "reload", channel: "reload", action: "activate", valueType: "none" },
183
+ // Laid over `source.params` and handed to the Provider, as the Table takes them.
184
+ { id: "bindingParamsChange", channel: "bindingParams", action: "change", valueType: "json", valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableBindingParams },
178
185
  ],
179
186
  },
180
187
  fields: [
@@ -334,6 +341,12 @@ export const PHI_COLLECTION_VIEW_WIDGET_DEFINITION = {
334
341
  },
335
342
  ],
336
343
  },
344
+ /*
345
+ * Drag reordering through the bound Provider's action (`itemKeys`, every key in the new order); off
346
+ * in masonry, while a search or a filter narrows the list, and while it spans more than one page.
347
+ */
348
+ { key: "features.reorder.enabled", type: "boolean", label: "Drag Reordering" },
349
+ { key: "features.reorder.actionKey", type: "string", label: "Reorder Action Key", placeholder: "reorder" },
337
350
  { key: "features.pagination.enabled", type: "boolean", label: "Pagination" },
338
351
  { key: "features.pagination.pageSize", type: "number", label: "Page Size", min: 1, precision: 0 },
339
352
  { key: "features.pagination.compact", type: "boolean", label: "Compact Pagination" },
@@ -5,7 +5,7 @@ import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
5
5
  import { PHI_COLLECTION_VIEW_WIDGET_DEFINITION, PHI_COLLECTION_VIEW_WIDGET_PLUGIN_TYPE, } from "./config";
6
6
  export const PHI_COLLECTION_VIEW_WIDGET_PLUGIN = {
7
7
  ...PHI_COLLECTION_VIEW_WIDGET_DEFINITION,
8
- render: ({ widget, runtime, config }) => (_jsx(PhiCollectionViewWidgetServer, { runtime: runtime, config: config, widgetId: widget.id, renderMode: readPhiRuntimeTreeRenderMode(widget.config) }, `widget-${widget.id}`)),
8
+ render: ({ widget, runtime, registry, config }) => (_jsx(PhiCollectionViewWidgetServer, { runtime: runtime, registry: registry, config: config, widgetId: widget.id, renderMode: readPhiRuntimeTreeRenderMode(widget.config) }, `widget-${widget.id}`)),
9
9
  renderPreview: ({ widget, runtime, registry, config }) => (_jsx(PhiWidgetInertPreview, { children: _jsx(PhiCollectionViewWidgetServer, { runtime: runtime, registry: registry, config: config, widgetId: widget.id, renderMode: readPhiRuntimeTreeRenderMode(widget.config), preview: true }, `widget-${widget.id}`) })),
10
10
  };
11
11
  export { PHI_COLLECTION_VIEW_WIDGET_PLUGIN_TYPE };
@@ -5,7 +5,10 @@ import type { PhiCmsInstanceId } from "../../../../../types/cms-instance-id";
5
5
  import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
6
6
  export type PhiCollectionViewWidgetServerProps = {
7
7
  runtime: Pick<PhiBlockRuntime, "locale">;
8
- /** The Area's declarations, which the preview judges the binding against; absent outside a page render. */
8
+ /**
9
+ * The Area's declarations: the preview judges the binding against them, and a Widget that offers
10
+ * reordering reads the bound resource's `itemIdentityPath` there. Absent outside a page render.
11
+ */
9
12
  registry?: Pick<PhiCmsRuntimeRenderRegistry, "dataProviderDescriptorsByKey">;
10
13
  config?: PhiCmsCollectionViewWidgetConfig | null;
11
14
  widgetId?: PhiCmsInstanceId | null;
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
3
3
  import { PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS } from "../../../../../constants/media-library-provider-keys";
4
4
  import { getPhiMediaWidgetLabels } from "../../../../../components/media/label-sets/media";
5
+ import { getPhiCollectionViewWidgetLabels } from "../../../../../components/widgets/label-sets/collection-view";
5
6
  import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
6
7
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
7
8
  import { readPhiCollectionViewDeclaredFailure } from "../../../../../components/widgets/shared/collection-source-failure";
@@ -32,8 +33,22 @@ export async function PhiCollectionViewWidgetServer({ runtime, config, widgetId,
32
33
  * Foundation's and loaded here -- only for a Widget bound to that collection, so no other source pays.
33
34
  * `config.presentation.labels` still lays over them.
34
35
  */
35
- const labels = config?.source?.providerKey === PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection
36
- ? await getPhiMediaWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime))
37
- : undefined;
38
- return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.CollectionView, componentProps: { config, widgetId, renderMode, preview: false, labels } }));
36
+ const translatorOptions = buildPhiWidgetLabelTranslatorOptions(runtime);
37
+ const [labels, reorderLabels] = await Promise.all([
38
+ config?.source?.providerKey === PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection
39
+ ? getPhiMediaWidgetLabels(translatorOptions)
40
+ : undefined,
41
+ // The Widget's own words, only for one that offers reordering.
42
+ config?.features.reorder?.enabled ? getPhiCollectionViewWidgetLabels(translatorOptions) : undefined,
43
+ ]);
44
+ /*
45
+ * Which field of an item is its key, as the bound resource declares it: what a reorder sends as
46
+ * `itemKeys`. The Provider's Client registration does not carry it, the declaration does.
47
+ */
48
+ const source = config?.source;
49
+ const providerDescriptor = source ? registry?.dataProviderDescriptorsByKey.get(source.providerKey) : undefined;
50
+ const itemIdentityPath = config?.features.reorder?.enabled && providerDescriptor?.kind === "collection"
51
+ ? providerDescriptor.resources.find((resource) => resource.resourceKey === source?.resourceKey)?.itemIdentityPath ?? null
52
+ : null;
53
+ return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.CollectionView, componentProps: { config, widgetId, renderMode, preview: false, labels, reorderLabels, itemIdentityPath } }));
39
54
  }
@@ -166,6 +166,7 @@ export declare const PHI_IMAGE_WIDGET_DEFINITION: {
166
166
  field: string;
167
167
  value: string;
168
168
  };
169
+ recordField: string;
169
170
  };
170
171
  defaultConfig: PhiCmsImageWidgetConfig;
171
172
  parseConfig: typeof parsePhiCmsImageWidgetConfig;
@@ -174,6 +174,7 @@ export const PHI_IMAGE_WIDGET_DEFINITION = {
174
174
  sourceField: "assetId",
175
175
  translatable: true,
176
176
  skipWhenConfigFieldValue: { field: "sourceKind", value: "url" },
177
+ recordField: "recordField",
177
178
  },
178
179
  defaultConfig: normalizePhiImageWidgetConfig(null),
179
180
  parseConfig: parsePhiCmsImageWidgetConfig,
@@ -52,7 +52,6 @@ export type PhiCmsMarkdownWidgetConfig = PhiCmsWidgetConfigBase & {
52
52
  /** How the text's lists are set. */
53
53
  list?: PhiBulletListStyle;
54
54
  resolvedContent?: PhiCmsResolvedContent | null;
55
- preferSource?: boolean;
56
55
  };
57
56
  export declare function parsePhiCmsMarkdownWidgetConfig(config: Record<string, unknown>): PhiCmsMarkdownWidgetConfig;
58
57
  export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
@@ -92,6 +91,7 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
92
91
  field: string;
93
92
  value: string;
94
93
  };
94
+ recordField: string;
95
95
  };
96
96
  fields: (({
97
97
  key: string;
@@ -106,6 +106,7 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
106
106
  field: "sourceMode",
107
107
  value: "url",
108
108
  },
109
+ recordField: "recordField",
109
110
  },
110
111
  fields: [
111
112
  { key: "eyebrow", type: "string", heading: "Text", label: "Eyebrow" },
@@ -43,7 +43,6 @@ export const PHI_MARKDOWN_WIDGET_PLUGIN = {
43
43
  ...config,
44
44
  widgetId: widget.id,
45
45
  resolvedContent: widget.resolvedContent ?? null,
46
- preferSource: hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
47
46
  translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
48
47
  }, runtime: runtime }, `widget-${widget.id}`));
49
48
  },
@@ -50,6 +50,7 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
50
50
  storage: "text";
51
51
  sourceField: string;
52
52
  translatable: true;
53
+ recordField: string;
53
54
  };
54
55
  fields: (({
55
56
  key: string;
@@ -49,6 +49,7 @@ export const PHI_SIMPLE_TEXT_WIDGET_DEFINITION = {
49
49
  storage: "text",
50
50
  sourceField: "text",
51
51
  translatable: true,
52
+ recordField: "recordField",
52
53
  },
53
54
  fields: [
54
55
  ...PHI_RENDERABLE_BLOCK_GEOMETRY_FIELDS,