@phis/ui 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/components/controls/phi-form-control.js +1 -0
  2. package/components/controls/phi-media-asset-tile-control.d.ts +4 -3
  3. package/components/controls/phi-media-picker-control.d.ts +9 -11
  4. package/components/controls/phi-media-picker-control.js +9 -11
  5. package/components/controls/phi-options-provider.d.ts +14 -1
  6. package/components/controls/phi-options-provider.js +73 -2
  7. package/components/forms/form-field-labels.d.ts +3 -3
  8. package/components/forms/form-field-labels.js +13 -5
  9. package/components/forms/media-asset-field-keys.d.ts +9 -1
  10. package/components/forms/media-asset-field-keys.js +13 -1
  11. package/components/media/label-sets/media.js +4 -0
  12. package/components/media/media-folder-name-path.d.ts +14 -0
  13. package/components/media/media-folder-name-path.js +40 -2
  14. package/components/media/media-library-resource.d.ts +70 -0
  15. package/components/media/media-library-resource.js +41 -0
  16. package/components/media/media-widget-labels.d.ts +13 -0
  17. package/components/media/media-widget-labels.js +2 -0
  18. package/components/media/phi-area-upload-widget.d.ts +31 -1
  19. package/components/media/phi-area-upload-widget.js +33 -7
  20. package/components/media/phi-image-preview-data.d.ts +8 -1
  21. package/components/media/phi-image-preview-data.js +29 -0
  22. package/components/media/phi-media-picker-binding.d.ts +22 -20
  23. package/components/media/phi-media-picker-binding.js +20 -33
  24. package/components/media/use-media-library-add-picker.d.ts +94 -0
  25. package/components/media/use-media-library-add-picker.js +40 -0
  26. package/components/widgets/client/shared/phi-choice-controller.js +22 -15
  27. package/constants/media-library-provider-keys.d.ts +7 -0
  28. package/constants/media-library-provider-keys.js +7 -0
  29. package/constants/runtime-module-ownership.js +1 -0
  30. package/helpers/preset-tree-contract-check.d.ts +35 -0
  31. package/helpers/preset-tree-contract-check.js +211 -0
  32. package/module-page-check.d.ts +6 -0
  33. package/module-page-check.js +6 -0
  34. package/package.json +1 -1
  35. package/plugins/runtime-modules/asset/data-providers.d.ts +56 -38
  36. package/plugins/runtime-modules/asset/data-providers.js +4 -32
  37. package/plugins/runtime-modules/asset/definition.d.ts +115 -38
  38. package/plugins/runtime-modules/asset/definition.js +2 -1
  39. package/plugins/runtime-modules/asset/form-providers.d.ts +85 -2
  40. package/plugins/runtime-modules/asset/form-providers.js +70 -11
  41. package/plugins/runtime-modules/asset/form-ui-provider.js +7 -1
  42. package/plugins/runtime-modules/asset/media-asset-field.d.ts +7 -7
  43. package/plugins/runtime-modules/asset/media-asset-field.js +11 -33
  44. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +8 -7
  45. package/plugins/runtime-modules/asset/media-asset-form-control.js +42 -83
  46. package/plugins/runtime-modules/asset/media-assets-field.d.ts +37 -0
  47. package/plugins/runtime-modules/asset/media-assets-field.js +81 -0
  48. package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +27 -0
  49. package/plugins/runtime-modules/asset/media-assets-form-control.js +182 -0
  50. package/plugins/runtime-modules/asset/media-field-picker-labels.d.ts +9 -0
  51. package/plugins/runtime-modules/asset/media-field-picker-labels.js +49 -0
  52. package/plugins/runtime-modules/asset/services/collection.js +12 -0
  53. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +11 -6
  54. package/plugins/runtime-modules/core/widgets/cascader/client.js +13 -12
  55. package/plugins/runtime-modules/core/widgets/checkbox-group/client.js +5 -4
  56. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.d.ts +24 -0
  57. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.js +55 -0
  58. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +26 -2
  59. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +125 -32
  60. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +7 -2
  61. package/plugins/runtime-modules/core/widgets/collection-view/client.js +12 -4
  62. package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +25 -0
  63. package/plugins/runtime-modules/core/widgets/collection-view/config.js +34 -0
  64. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +4 -1
  65. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +3 -2
  66. package/plugins/runtime-modules/core/widgets/collection-view/server.js +20 -18
  67. package/plugins/runtime-modules/core/widgets/multi-select/client.js +6 -4
  68. package/plugins/runtime-modules/descriptor-compiler.d.ts +4 -0
  69. package/plugins/runtime-modules/descriptor-compiler.js +9 -204
  70. package/plugins/runtime-modules/resolver.js +31 -5
  71. package/types/collection-view-widget.d.ts +19 -0
  72. package/types/core-widget-placements.d.ts +9 -0
  73. package/types/media.d.ts +16 -0
@@ -332,27 +332,32 @@ function PhiInspectorChoiceFieldControl({ field, config, value, defaultValue, di
332
332
  // The Inspector's own fields declare searchability too -- the navigation pickers have said
333
333
  // `search: { enabled: true }` for a while -- so the raw text goes to the hook here as well.
334
334
  const [searchDraft, setSearchDraft] = useState("");
335
+ // What the field holds, read once for the provider and for the control below.
336
+ const multiple = field.mode === "multiple" || field.valueType === "string[]";
337
+ const emptyOptionValue = field.emptyOption?.value;
338
+ const selectedValues = multiple ? readInspectorChoiceMultiValue(value, defaultValue) : [];
339
+ const selectedValue = multiple
340
+ ? undefined
341
+ : value == null
342
+ ? emptyOptionValue ?? readInspectorChoiceSingleValue(undefined, defaultValue)
343
+ : readInspectorChoiceSingleValue(value, defaultValue);
335
344
  const providerResult = usePhiControlOptionsProvider({
336
345
  options: staticOptions,
337
346
  optionsProvider: field.filter?.widgetType ? null : field.optionsProvider,
338
347
  sourceConfig: field.filter?.widgetType ? null : config,
339
348
  searchDraft,
349
+ selectedValues: multiple ? selectedValues : selectedValue,
340
350
  });
341
351
  const renderChoiceRow = (control) => renderPhiInspectorConfigFieldControl(field, _jsxs(PhiFlexControl, { vertical: true, gap: 4, style: { minWidth: 0, width: "100%" }, children: [control, providerResult.warning ? (_jsx(PhiTypographyControl, { type: "warning", children: providerResult.warning })) : null] }));
342
352
  const resolvedOptions = useMemo(() => resolveInspectorChoiceOptions(field, widgetReferenceOptions, providerResult.options), [field, providerResult.options, widgetReferenceOptions]);
343
353
  const cascader = useMemo(() => field.presentation === "cascader" ? buildPhiInspectorChoiceCascader(resolvedOptions) : null, [field.presentation, resolvedOptions]);
344
- if (field.mode === "multiple" || field.valueType === "string[]") {
345
- const selectedValues = readInspectorChoiceMultiValue(value, defaultValue);
354
+ if (multiple) {
346
355
  const options = selectedValues.reduce((items, entry) => ensureInspectorChoiceOption(items, entry), resolvedOptions);
347
356
  return renderChoiceRow(_jsx(PhiMultiSelectControl, { value: selectedValues, options: options, placeholder: field.placeholder, allowCustom: field.allowCustom, disabled: disabled || !onChange, style: { width: "100%" }, onChange: (nextValues) => onChange?.({
348
357
  [field.key]: nextValues,
349
358
  ...(field.patchOnChange ?? {}),
350
359
  }) }));
351
360
  }
352
- const emptyOptionValue = field.emptyOption?.value;
353
- const selectedValue = value == null
354
- ? emptyOptionValue ?? readInspectorChoiceSingleValue(undefined, defaultValue)
355
- : readInspectorChoiceSingleValue(value, defaultValue);
356
361
  /*
357
362
  * The options as a hierarchy by their `parentValue`. Every level can be chosen -- a Folder that holds
358
363
  * others is a Folder too -- and what is stored is the chosen option's own value. The empty option is
@@ -8,20 +8,21 @@ import { usePhiControlOptionsProvider } from "../../../../../components/controls
8
8
  export function PhiCascaderWidget({ config, signalsEnabled = true, }) {
9
9
  const { token } = usePhiConfig();
10
10
  const minWidth = token.controlHeight * 6;
11
+ const separator = config?.separator ?? "/";
12
+ const rootValue = config?.rootValue ?? "/";
13
+ const normalize = config?.normalize ?? "raw";
14
+ const normalizeFallback = (raw) => normalizePhiCascaderValue(normalizePhiCascaderValue(raw), { separator, rootValue, normalize });
15
+ // A pick, held against the fallback it replaced; declared first so the provider hears what is held.
16
+ // Without a configured value the fallback is the provider's own answer, so only a pick is told.
17
+ const [picked, setPicked] = useState(null);
18
+ const configuredValue = config?.value == null ? null : normalizeFallback(config.value);
11
19
  const resolvedOptions = usePhiControlOptionsProvider({
12
20
  options: config?.options,
13
21
  optionsProvider: config?.optionsProvider,
22
+ selectedValues: configuredValue == null || picked?.source === configuredValue ? picked?.value : configuredValue,
14
23
  });
15
- const fallbackValue = normalizePhiCascaderValue(config?.value ?? resolvedOptions.value);
16
- const separator = config?.separator ?? "/";
17
- const rootValue = config?.rootValue ?? "/";
18
- const normalize = config?.normalize ?? "raw";
19
- const normalizedFallbackValue = normalizePhiCascaderValue(fallbackValue, { separator, rootValue, normalize });
20
- const [state, setState] = useState(() => ({
21
- source: normalizedFallbackValue,
22
- value: normalizedFallbackValue,
23
- }));
24
- const value = state.source === normalizedFallbackValue ? state.value : normalizedFallbackValue;
24
+ const normalizedFallbackValue = normalizeFallback(config?.value ?? resolvedOptions.value);
25
+ const value = picked?.source === normalizedFallbackValue ? picked.value : normalizedFallbackValue;
25
26
  const controlSignals = usePhiControlSignalController({
26
27
  key: config?.key ?? "cascader",
27
28
  signalRoutes: config?.signalRoutes,
@@ -31,7 +32,7 @@ export function PhiCascaderWidget({ config, signalsEnabled = true, }) {
31
32
  initialDisabled: config?.disabled === true,
32
33
  initialReadOnly: config?.readOnly === true,
33
34
  clearValue: config?.allowRoot === false ? normalizedFallbackValue : rootValue,
34
- onSetValue: (nextValue) => setState({
35
+ onSetValue: (nextValue) => setPicked({
35
36
  source: normalizedFallbackValue,
36
37
  value: normalizePhiCascaderValue(nextValue, { separator, rootValue, normalize }),
37
38
  }),
@@ -42,7 +43,7 @@ export function PhiCascaderWidget({ config, signalsEnabled = true, }) {
42
43
  return;
43
44
  }
44
45
  const normalizedNextValue = normalizePhiCascaderValue(nextValue, { separator, rootValue, normalize });
45
- setState({
46
+ setPicked({
46
47
  source: normalizedFallbackValue,
47
48
  value: normalizedNextValue,
48
49
  });
@@ -9,14 +9,15 @@ function equalValues(left, right) {
9
9
  return left.length === right.length && left.every((entry, index) => entry === right[index]);
10
10
  }
11
11
  export function PhiCheckboxGroupWidget({ config, value: controlledValue, disabled, readOnly, signalsEnabled = true, onChange, }) {
12
- const resolvedOptions = usePhiControlOptionsProvider({
13
- options: config?.options,
14
- optionsProvider: config?.optionsProvider,
15
- });
16
12
  const fallbackValue = useMemo(() => controlledValue ?? config?.value ?? [], [config?.value, controlledValue]);
17
13
  const fallbackKey = fallbackValue.join("\u001f");
18
14
  const [state, setState] = useState(() => ({ sourceKey: fallbackKey, value: fallbackValue }));
19
15
  const value = state.sourceKey === fallbackKey ? state.value : fallbackValue;
16
+ const resolvedOptions = usePhiControlOptionsProvider({
17
+ options: config?.options,
18
+ optionsProvider: config?.optionsProvider,
19
+ selectedValues: value,
20
+ });
20
21
  const controlSignals = usePhiControlSignalController({
21
22
  key: config?.key ?? "checkbox-group",
22
23
  signalRoutes: config?.signalRoutes,
@@ -0,0 +1,24 @@
1
+ import type { PhiCollectionProviderResourceDescriptor } from "../../../../../types/collection-provider";
2
+ import type { PhiCmsCollectionViewWidgetConfig } from "../../../../../types/collection-view-widget";
3
+ /** The panel the `upload` action opens, by the resource's declaration (`panelKey`). */
4
+ export declare const PHI_MEDIA_RENDERER_UPLOAD_PANEL_KEY = "upload";
5
+ /**
6
+ * What the resource lets the renderer offer on its own, without a tool in the placement: a tile's
7
+ * delete (`delete`, scope `item`) and adding what an upload made (`add`, which takes `itemKeys`, the
8
+ * Asset ids).
9
+ */
10
+ export type PhiMediaRendererResourceActions = {
11
+ delete: boolean;
12
+ add: boolean;
13
+ };
14
+ export declare function readPhiMediaRendererResourceActions(resource: Pick<PhiCollectionProviderResourceDescriptor, "actions"> | null | undefined): PhiMediaRendererResourceActions;
15
+ /**
16
+ * Why the placement's tools cannot be drawn for this resource, or `null`: a filter or an action the
17
+ * renderer has no control for, or one the bound resource does not declare -- a Folder filter on a
18
+ * gallery of references, a lock on a resource that cannot lock. The resource is the one the Server read
19
+ * from the Area's registry; where the Area declares none, nothing is declared and every tool is refused.
20
+ */
21
+ export declare function readPhiMediaRendererToolFailure(input: {
22
+ config: Pick<PhiCmsCollectionViewWidgetConfig, "features">;
23
+ resource: Pick<PhiCollectionProviderResourceDescriptor, "actions" | "query"> | null | undefined;
24
+ }): string | null;
@@ -0,0 +1,55 @@
1
+ /*
2
+ * What the Media renderer's tools are, apart from the drawing (`asset-binding.tsx`): which a placement
3
+ * may name, and which of them the bound resource declares. Pure, so the rules are tested without a
4
+ * render.
5
+ */
6
+ /** The filters the Media renderer draws a control for. */
7
+ const PHI_MEDIA_RENDERER_FILTER_KEYS = ["kind", "presentationFlags", "folderId"];
8
+ /**
9
+ * The tool actions the Media renderer draws: `upload` opens the resource's upload panel, `add` the Media
10
+ * library's picker whose pick goes to the resource's `add` action, `createFolder` and `lockFolder`
11
+ * (with `unlockFolder`) sit beside the Folder filter.
12
+ */
13
+ const PHI_MEDIA_RENDERER_ACTION_KEYS = ["upload", "add", "createFolder", "lockFolder"];
14
+ /** The panel the `upload` action opens, by the resource's declaration (`panelKey`). */
15
+ export const PHI_MEDIA_RENDERER_UPLOAD_PANEL_KEY = "upload";
16
+ export function readPhiMediaRendererResourceActions(resource) {
17
+ const keys = new Set((resource?.actions ?? []).map((action) => action.key));
18
+ return { delete: keys.has("delete"), add: keys.has("add") };
19
+ }
20
+ /**
21
+ * Why the placement's tools cannot be drawn for this resource, or `null`: a filter or an action the
22
+ * renderer has no control for, or one the bound resource does not declare -- a Folder filter on a
23
+ * gallery of references, a lock on a resource that cannot lock. The resource is the one the Server read
24
+ * from the Area's registry; where the Area declares none, nothing is declared and every tool is refused.
25
+ */
26
+ export function readPhiMediaRendererToolFailure(input) {
27
+ const { features } = input.config;
28
+ const declaredFilters = new Set((input.resource?.query.filterFields ?? []).map((filter) => filter.key));
29
+ const declaredActions = new Map((input.resource?.actions ?? []).map((action) => [action.key, action]));
30
+ for (const filter of features.filters ?? []) {
31
+ if (!PHI_MEDIA_RENDERER_FILTER_KEYS.includes(filter.key)) {
32
+ return `Asset collection filter "${filter.key}" is not supported.`;
33
+ }
34
+ if (!declaredFilters.has(filter.key)) {
35
+ return `The bound resource declares no filter "${filter.key}".`;
36
+ }
37
+ }
38
+ const configuredActions = [
39
+ ...(features.actions?.toolbar ?? []),
40
+ ...(features.filters ?? []).flatMap((filter) => filter.actions ?? []),
41
+ ];
42
+ for (const action of configuredActions) {
43
+ if (!PHI_MEDIA_RENDERER_ACTION_KEYS.includes(action.key)) {
44
+ return `Asset collection action "${action.key}" is not supported.`;
45
+ }
46
+ const needed = action.key === "lockFolder" ? ["lockFolder", "unlockFolder"] : [action.key];
47
+ const missing = needed.find((key) => !declaredActions.has(key));
48
+ if (missing)
49
+ return `The bound resource declares no action "${missing}".`;
50
+ if (action.key === "upload" && declaredActions.get("upload")?.panelKey !== PHI_MEDIA_RENDERER_UPLOAD_PANEL_KEY) {
51
+ return `The bound resource's "upload" action opens no "${PHI_MEDIA_RENDERER_UPLOAD_PANEL_KEY}" panel.`;
52
+ }
53
+ }
54
+ return null;
55
+ }
@@ -1,12 +1,36 @@
1
1
  import type { PhiCmsInstanceId } from "../../../../../types/cms-instance-id";
2
- import type { PhiCollectionViewBindingModel } from "../../../../../types/collection-provider";
2
+ import type { PhiCollectionProviderResourceDescriptor, PhiCollectionViewBindingModel } from "../../../../../types/collection-provider";
3
3
  import type { PhiCmsCollectionViewWidgetConfig } from "../../../../../types/collection-view-widget";
4
4
  import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
5
- export declare function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabels, widgetId, renderMode, }: {
5
+ /**
6
+ * The Media renderer (`PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY`): the items of a Collection as Media tiles,
7
+ * for whichever Provider names it -- the Media library's own Collection, and any Collection of Assets
8
+ * (a gallery of references) whose resource names it as its `itemRendererKey`, or whose placement does.
9
+ *
10
+ * - **Items** are read in the Media tile shape (`PhiMediaCollectionItem`, `readPhiMediaCollectionItems`);
11
+ * the Media library's own as its whole tiles.
12
+ * - **Tools** follow what the resource declares (`readPhiMediaRendererToolFailure`): a Folder, lock,
13
+ * new-Folder or flag tool the placement names but the resource does not declare is a failure, not a
14
+ * control that does nothing. A tile's delete is the resource's `delete`, in the words the placement's
15
+ * `presentation.labels.grid` gives (a gallery's "Remove from gallery").
16
+ * - **Upload** is the resource's `upload` panel, the Media library's multi-upload wall, into
17
+ * `features.media.folderPath` with `{param}` filled from the binding params. Where the resource
18
+ * declares `add`, what arrived is added to it (`itemKeys`, the Asset ids) -- the Provider's answer shows
19
+ * it at once, then the Collection is read again -- and leaves the wall, so it is not shown twice.
20
+ * - **Choose from Media library** (toolbar action `add`) opens the library's picker on the same Folder;
21
+ * the pick goes to the same `add` action.
22
+ * - **The Asset Controller's store** (the selection, the Space selector) is fed by the Media library's
23
+ * own Collection only; a tile of another Collection is not selected.
24
+ *
25
+ * Drag reordering (`features.reorder`) is the Collection View's, around these tiles.
26
+ */
27
+ export declare function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabels, widgetId, renderMode, resource, }: {
6
28
  config: PhiCmsCollectionViewWidgetConfig;
7
29
  binding: PhiCollectionViewBindingModel;
8
30
  labels?: unknown;
9
31
  widgetId?: PhiCmsInstanceId | null;
10
32
  /** Handed on by the Collection View, so a configuration this renderer cannot serve is said its way. */
11
33
  renderMode: PhiRenderableBlockRenderMode;
34
+ /** The bound resource as the Area declares it (the Collection View's Server half read it); `null`: none. */
35
+ resource?: PhiCollectionProviderResourceDescriptor | null;
12
36
  }): import("react").JSX.Element;
@@ -3,6 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
3
3
  import { isPhiRecord } from "../../../../../helpers/is-record";
4
4
  import { useCallback, useEffect, useMemo, useState } from "react";
5
5
  import { PhiMediaAssetFlags, PhiMediaKind } from "../../../../../constants/media";
6
+ import { PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS } from "../../../../../constants/media-library-provider-keys";
6
7
  import { createPhiSignalSubcontrolAddress } from "../../../../../types/signals";
7
8
  import { normalizePhiCssSize } from "../../../../../components/layouts/phi-layout-contract";
8
9
  import { PhiAlertControl } from "../../../../../components/controls/phi-alert-control";
@@ -25,10 +26,14 @@ import { PhiWidgetFailure } from "../../../../../components/widgets/shared/widge
25
26
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
26
27
  import { PHI_ASSET_CONTROLLER_STORE_KEY } from "../../../../../components/media/asset-controller-signals";
27
28
  import { applyPhiAssetCollectionData } from "../../../../../components/media/asset-collection-runtime";
28
- import { readPhiMediaAssetTiles, readPhiMediaFolders } from "../../../../../components/media/phi-image-preview-data";
29
+ import { readPhiMediaAssetTiles, readPhiMediaCollectionItems, readPhiMediaFolders, } from "../../../../../components/media/phi-image-preview-data";
29
30
  import { PhiAssetFolderControl } from "../../../../../components/media/phi-asset-folder-control";
30
31
  import { isPhiMediaFolderIdLocked, isPhiMediaFolderLockedError, } from "../../../../../components/media/media-folder-lock";
31
32
  import { PhiAreaUploadBinding } from "../../../../../components/media/phi-area-upload-widget";
33
+ import { PhiMediaPickerControl } from "../../../../../components/controls/phi-media-picker-control";
34
+ import { usePhiMediaLibraryAddPicker } from "../../../../../components/media/use-media-library-add-picker";
35
+ import { resolvePhiMediaFolderPathTemplate, splitPhiMediaFolderNamePath, } from "../../../../../components/media/media-folder-name-path";
36
+ import { PHI_MEDIA_RENDERER_UPLOAD_PANEL_KEY, readPhiMediaRendererResourceActions, readPhiMediaRendererToolFailure, } from "./asset-binding-tools";
32
37
  import { PHI_MEDIA_WIDGET_DEFAULT_LABELS } from "../../../../../components/media/media-widget-labels";
33
38
  import { setPhiImagePreviewSelection, usePhiImagePreviewStore } from "../../../../../components/media/phi-image-preview-store";
34
39
  const ASSET_FLAG_VALUES = [
@@ -62,7 +67,29 @@ function overlayPhiAssetLabels(base, override) {
62
67
  }
63
68
  return result;
64
69
  }
65
- export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabels, widgetId, renderMode, }) {
70
+ /**
71
+ * The Media renderer (`PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY`): the items of a Collection as Media tiles,
72
+ * for whichever Provider names it -- the Media library's own Collection, and any Collection of Assets
73
+ * (a gallery of references) whose resource names it as its `itemRendererKey`, or whose placement does.
74
+ *
75
+ * - **Items** are read in the Media tile shape (`PhiMediaCollectionItem`, `readPhiMediaCollectionItems`);
76
+ * the Media library's own as its whole tiles.
77
+ * - **Tools** follow what the resource declares (`readPhiMediaRendererToolFailure`): a Folder, lock,
78
+ * new-Folder or flag tool the placement names but the resource does not declare is a failure, not a
79
+ * control that does nothing. A tile's delete is the resource's `delete`, in the words the placement's
80
+ * `presentation.labels.grid` gives (a gallery's "Remove from gallery").
81
+ * - **Upload** is the resource's `upload` panel, the Media library's multi-upload wall, into
82
+ * `features.media.folderPath` with `{param}` filled from the binding params. Where the resource
83
+ * declares `add`, what arrived is added to it (`itemKeys`, the Asset ids) -- the Provider's answer shows
84
+ * it at once, then the Collection is read again -- and leaves the wall, so it is not shown twice.
85
+ * - **Choose from Media library** (toolbar action `add`) opens the library's picker on the same Folder;
86
+ * the pick goes to the same `add` action.
87
+ * - **The Asset Controller's store** (the selection, the Space selector) is fed by the Media library's
88
+ * own Collection only; a tile of another Collection is not selected.
89
+ *
90
+ * Drag reordering (`features.reorder`) is the Collection View's, around these tiles.
91
+ */
92
+ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabels, widgetId, renderMode, resource, }) {
66
93
  /*
67
94
  * The English defaults, under what the server half loaded for this Widget (`rawLabels`, the Media Label
68
95
  * Set in the reader's language), under what the Widget's own configuration says.
@@ -70,17 +97,24 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
70
97
  const labels = useMemo(() => overlayPhiAssetLabels(overlayPhiAssetLabels(PHI_MEDIA_WIDGET_DEFAULT_LABELS, rawLabels), config.presentation.labels), [config.presentation.labels, rawLabels]);
71
98
  const { token } = usePhiConfig();
72
99
  const { showMessage } = usePhiApplicationFeedback();
73
- const selectionState = usePhiImagePreviewStore(PHI_ASSET_CONTROLLER_STORE_KEY);
100
+ // The Media library's own Collection, the one whose answer is the Asset Controller's store.
101
+ const isMediaLibrary = config.source?.providerKey === PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection;
102
+ const resourceActions = readPhiMediaRendererResourceActions(resource);
103
+ const toolFailure = readPhiMediaRendererToolFailure({ config, resource });
104
+ const storeState = usePhiImagePreviewStore(PHI_ASSET_CONTROLLER_STORE_KEY);
74
105
  const query = binding.query;
75
106
  const setQuery = binding.setQuery;
107
+ const sourceName = `The collection "${config.source?.resourceKey ?? "unknown"}"`;
76
108
  // A Collection carries items of no particular type; they are read as tiles, not cast to them.
77
- const assets = useMemo(() => readPhiMediaAssetTiles(binding.data?.items ?? []), [binding.data?.items]);
109
+ const mediaTiles = useMemo(() => isMediaLibrary ? readPhiMediaAssetTiles(binding.data?.items ?? []) : null, [binding.data?.items, isMediaLibrary]);
110
+ const assets = useMemo(() => mediaTiles ?? readPhiMediaCollectionItems(binding.data?.items ?? [], sourceName), [binding.data?.items, mediaTiles, sourceName]);
78
111
  const folders = useMemo(() => readPhiMediaFolders(binding.data?.meta?.folders), [binding.data?.meta?.folders]);
79
112
  const queryKind = query.filters?.kind;
80
113
  const queryFlags = query.filters?.presentationFlags;
81
114
  const queryFolderId = query.filters?.folderId;
82
115
  const state = {
83
- ...selectionState,
116
+ selectedAssetId: isMediaLibrary ? storeState.selectedAssetId : null,
117
+ selectedVariantKey: storeState.selectedVariantKey,
84
118
  searchQuery: query.search ?? "",
85
119
  folderId: typeof queryFolderId === "number" ? queryFolderId : null,
86
120
  kinds: readAssetKinds(queryKind),
@@ -93,13 +127,13 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
93
127
  pagination: { total: binding.data?.total ?? 0 },
94
128
  loading: binding.loading,
95
129
  error: binding.error,
96
- uploadPanelOpen: binding.openPanelKey === "upload",
130
+ uploadPanelOpen: binding.openPanelKey === PHI_MEDIA_RENDERER_UPLOAD_PANEL_KEY,
97
131
  };
98
132
  useEffect(() => {
99
- if (binding.data) {
133
+ if (isMediaLibrary && binding.data) {
100
134
  applyPhiAssetCollectionData(binding.data);
101
135
  }
102
- }, [binding.data]);
136
+ }, [binding.data, isMediaLibrary]);
103
137
  const onSearchChange = useCallback((search) => setQuery((current) => ({ ...current, page: 1, search })), [setQuery]);
104
138
  const { draft: searchDraft, setDraft: setSearchDraft } = usePhiSearchDraft({
105
139
  query: state.searchQuery,
@@ -118,8 +152,9 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
118
152
  const spaceSelectionAllowed = usePhiMediaSpaceSelectionAllowed();
119
153
  const activeSpaceAddress = typeof query.filters?.spaceId === "string" && query.filters.spaceId
120
154
  ? query.filters.spaceId
121
- : selectionState.activeSpace?.address ?? null;
122
- const spaceOptions = useMemo(() => buildPhiMediaSpaceOptions(selectionState.spaces, labels.space), [labels.space, selectionState.spaces]);
155
+ : storeState.activeSpace?.address ?? null;
156
+ // The Spaces are the Media library's to answer; another Collection's items are of the Site Space.
157
+ const spaceOptions = useMemo(() => buildPhiMediaSpaceOptions(isMediaLibrary ? storeState.spaces : [], labels.space), [isMediaLibrary, labels.space, storeState.spaces]);
123
158
  const presentation = config.presentation;
124
159
  const features = config.features;
125
160
  const controlSize = presentation.controlSize ?? "small";
@@ -127,12 +162,15 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
127
162
  const gap = normalizePhiCssSize(presentation.gap) ?? token.paddingSM;
128
163
  const minColumnWidth = normalizePhiCssSize(presentation.minColumnWidth) ?? 102;
129
164
  const selfContained = features.tools.mode === "self-contained";
130
- const unsupportedFilter = features.filters?.find((filter) => !["kind", "presentationFlags", "folderId"].includes(filter.key));
131
- const configuredActions = [
132
- ...(features.actions?.toolbar ?? []),
133
- ...(features.filters ?? []).flatMap((filter) => filter.actions ?? []),
134
- ];
135
- const unsupportedAction = configuredActions.find((action) => action.key !== "upload" && action.key !== "createFolder" && action.key !== "lockFolder");
165
+ /*
166
+ * Where an upload goes and the picker opens (`features.media.folderPath`), its `{param}` names filled
167
+ * from the binding params the Provider is asked with -- what a Controller told this Collection about the
168
+ * record it shows. Resolved per render, so a new set of params moves both.
169
+ */
170
+ const bindingParams = config.source?.params;
171
+ const folderPath = useMemo(() => resolvePhiMediaFolderPathTemplate(splitPhiMediaFolderNamePath(features.media?.folderPath), isPhiRecord(bindingParams) ? bindingParams : {}), [bindingParams, features.media?.folderPath]);
172
+ const mediaType = features.media?.mediaType ?? null;
173
+ const uploadAcceptance = useMemo(() => mediaType ? { kinds: [mediaType] } : undefined, [mediaType]);
136
174
  const folderOptions = useMemo(() => buildPhiMediaFolderCascaderOptions(state.folders, { lockedLabel: labels.tool.folderLockedLabel }), [labels.tool.folderLockedLabel, state.folders]);
137
175
  /*
138
176
  * The Folder the listing is filtered to, locked: Core refuses a new Folder in it, an upload into it and
@@ -159,10 +197,42 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
159
197
  valueType: "json",
160
198
  typeKey: "collection-action",
161
199
  });
162
- if (unsupportedFilter || unsupportedAction) {
163
- return (_jsx(PhiWidgetFailure, { renderMode: renderMode, widgetType: PhiCmsWidgetType.CollectionView, widgetId: widgetId, title: unsupportedFilter
164
- ? `Asset collection filter "${unsupportedFilter.key}" is not supported.`
165
- : `Asset collection action "${unsupportedAction?.key ?? "unknown"}" is not supported.` }));
200
+ /*
201
+ * Adds Assets of the Media library to the bound resource (its `add` action, `itemKeys` the Asset ids):
202
+ * what an upload made, or what was picked. The Provider answers the Collection as it now stands, which
203
+ * the binding shows at once; then it is read again.
204
+ */
205
+ const addAssets = useCallback(async (assetIds) => {
206
+ try {
207
+ const data = await binding.activate({ actionKey: "add", itemKeys: [...assetIds], query });
208
+ if (data.error)
209
+ throw new Error(data.error);
210
+ binding.reload();
211
+ }
212
+ catch (error) {
213
+ showMessage({
214
+ level: "error",
215
+ content: error instanceof Error && error.message ? error.message : labels.grid.addFailedText,
216
+ durationSeconds: 2.8,
217
+ });
218
+ }
219
+ }, [binding, labels.grid.addFailedText, query, showMessage]);
220
+ /*
221
+ * The Media library's picker, for the toolbar action `add`: the Site Space only, opening on the
222
+ * resolved Folder path (read, nothing written), the kind `features.media.mediaType` names (images where
223
+ * none). Every Asset of the Site Space is delivered publicly from the start (`defaultMediaDeliveryPolicy`
224
+ * in phis-server), so there is nothing to grey out; what the resource's `add` takes, it decides. A pick
225
+ * is added; the picker has no upload of its own here -- the Collection's upload panel is that.
226
+ */
227
+ const readFolderPath = useCallback(() => folderPath, [folderPath]);
228
+ const libraryPicker = usePhiMediaLibraryAddPicker({
229
+ mediaType,
230
+ labels,
231
+ folderPath: folderPath.length > 0 ? readFolderPath : null,
232
+ onAssetSelect: (picked) => { void addAssets([picked.id]); },
233
+ });
234
+ if (toolFailure) {
235
+ return (_jsx(PhiWidgetFailure, { renderMode: renderMode, widgetType: PhiCmsWidgetType.CollectionView, widgetId: widgetId, title: toolFailure }));
166
236
  }
167
237
  function readActionFailure(error, fallback) {
168
238
  if (isPhiMediaFolderLockedError(error))
@@ -217,9 +287,13 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
217
287
  setDeletingAssetIds((current) => current.filter((id) => id !== asset.id));
218
288
  }
219
289
  }
290
+ // The Media library's own tiles only: a selection is the Asset Controller's, which reads that library.
220
291
  function selectAsset(asset) {
221
- setPhiImagePreviewSelection(PHI_ASSET_CONTROLLER_STORE_KEY, asset.id, state.selectedVariantKey ?? null, asset);
222
- selectionSignals.emitCapability("selection", { area: PHI_ASSET_CONTROLLER_STORE_KEY, assetId: asset.id });
292
+ const tile = mediaTiles?.find((entry) => entry.id === asset.id);
293
+ if (!tile)
294
+ return;
295
+ setPhiImagePreviewSelection(PHI_ASSET_CONTROLLER_STORE_KEY, tile.id, state.selectedVariantKey ?? null, tile);
296
+ selectionSignals.emitCapability("selection", { area: PHI_ASSET_CONTROLLER_STORE_KEY, assetId: tile.id });
223
297
  }
224
298
  const filters = selfContained ? (_jsxs(_Fragment, { children: [spaceSelectionAllowed && spaceOptions.length > 1 ? (_jsx(PhiSelectControl, { value: activeSpaceAddress ?? undefined, options: spaceOptions, placeholder: labels.space.label, size: controlSize, style: { minWidth: 140 }, onChange: (value) => {
225
299
  if (typeof value !== "string" || !value)
@@ -293,8 +367,14 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
293
367
  }), features.search?.enabled ? (_jsx(PhiTextControl, { inputType: "search", value: searchDraft, placeholder: features.search.placeholder ?? labels.tool.searchPlaceholder, ariaLabel: features.search.placeholder ?? labels.tool.searchPlaceholder, size: controlSize, style: { flex: "1 1 12rem", minWidth: normalizePhiCssSize(features.search.minWidth) ?? "10rem" }, onChange: (value) => setSearchDraft(value ?? "") })) : null] })) : null;
294
368
  const toolbar = selfContained && ((features.actions?.toolbar?.length ?? 0) > 0 || features.tools.reset || features.tools.reload) ? (_jsxs(PhiToolbarControl, { compact: true, size: controlSize, children: [(features.actions?.toolbar ?? []).map((action) => {
295
369
  const display = action.display ?? "icon";
296
- const label = action.label ?? (action.key === "upload" ? labels.upload.uploadToggleLabel : action.key);
297
- return (_jsx(PhiButtonControl, { label: display === "icon" ? undefined : label, ariaLabel: label, tooltip: action.description, icon: display === "label" || !action.icon ? undefined : resolvePhiButtonIcon(action.icon), type: action.mode === "primary" ? "primary" : "default", danger: action.mode === "danger", size: controlSize, disabled: action.key === "upload" && currentFolderLocked, onClick: action.key === "upload" ? () => binding.setOpenPanelKey(state.uploadPanelOpen ? null : "upload") : undefined }, action.key));
370
+ const label = action.label ?? (action.key === "upload" ? labels.upload.uploadToggleLabel
371
+ : action.key === "add" ? labels.tool.chooseFromLibraryLabel
372
+ : action.key);
373
+ const button = (_jsx(PhiButtonControl, { label: display === "icon" ? undefined : label, ariaLabel: label, tooltip: action.description, icon: display === "label" || !action.icon ? undefined : resolvePhiButtonIcon(action.icon), type: action.mode === "primary" ? "primary" : "default", danger: action.mode === "danger", size: controlSize, disabled: action.key === "upload" && currentFolderLocked, onClick: action.key === "upload" ? () => binding.setOpenPanelKey(state.uploadPanelOpen ? null : PHI_MEDIA_RENDERER_UPLOAD_PANEL_KEY) : undefined }, action.key));
374
+ // The picker opens from its own button: the popover's trigger.
375
+ return action.key === "add"
376
+ ? _jsx(PhiMediaPickerControl, { ...libraryPicker, trigger: _jsx("span", { children: button }) }, action.key)
377
+ : button;
298
378
  }), features.tools.reset ? (_jsx(PhiButtonControl, { ariaLabel: labels.tool.resetLabel, tooltip: labels.tool.resetLabel, icon: resolvePhiButtonIcon("antd:rollback-outlined"), size: controlSize, onClick: () => binding.setQuery({
299
379
  ...(config.initialQuery ?? {}),
300
380
  page: config.initialQuery?.page ?? 1,
@@ -303,18 +383,31 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
303
383
  }) })) : null, features.tools.reload ? (_jsx(PhiButtonControl, { ariaLabel: labels.tool.reloadLabel, tooltip: labels.tool.reloadLabel, icon: resolvePhiButtonIcon("reload"), size: controlSize, onClick: binding.reload })) : null] })) : null;
304
384
  const awaitingInitialPayload = binding.data == null && !state.error;
305
385
  const body = state.error ? null : awaitingInitialPayload ? (_jsx(PhiMediaAssetCollectionSkeletonControl, { mode: mode, gap: gap, minColumnWidth: minColumnWidth })) : state.assets.length === 0 ? (_jsx(PhiEmptyControl, { description: presentation.emptyDescription ?? labels.grid.emptyDescription })) : undefined;
306
- return (_jsx(PhiCollectionViewControl, { title: presentation.title, description: presentation.description, filters: filters, toolbar: toolbar, panel: state.uploadPanelOpen ? (_jsx(PhiAreaUploadBinding, { labels: labels.upload, onUploadComplete: binding.reload, collectionContext: {
307
- folders: state.folders,
308
- folderId: state.folderId,
309
- folderPath: null,
310
- presentationFlags: state.presentationFlags,
311
- query,
312
- } })) : null,
386
+ /*
387
+ * The upload panel: the Media library's wall, into the resolved Folder path where the placement names
388
+ * one. For the Media library's own Collection what arrived stays in the wall, with its delete, and the
389
+ * listing is read again; for a resource that adds, what arrived is added and leaves the wall; for any
390
+ * other the Collection is read again, in case its Provider lists what arrived itself.
391
+ */
392
+ const uploadPanel = state.uploadPanelOpen ? (_jsx(PhiAreaUploadBinding, { labels: labels.upload, config: folderPath.length > 0 ? { folderPath: folderPath.join(" / ") } : null, acceptance: uploadAcceptance, showFinished: isMediaLibrary, siteSpaceOnly: !isMediaLibrary, onUploadComplete: resourceActions.add ? undefined : binding.reload, onAssetUploaded: resourceActions.add ? (asset) => { void addAssets([asset.id]); } : undefined, collectionContext: isMediaLibrary ? {
393
+ folders: state.folders,
394
+ folderId: state.folderId,
395
+ folderPath: null,
396
+ presentationFlags: state.presentationFlags,
397
+ query,
398
+ } : {
399
+ folders: [],
400
+ folderId: null,
401
+ folderPath: null,
402
+ presentationFlags: null,
403
+ query,
404
+ } })) : null;
405
+ return (_jsx(PhiCollectionViewControl, { title: presentation.title, description: presentation.description, filters: filters, toolbar: toolbar, panel: uploadPanel,
313
406
  /*
314
407
  * Only what an action left behind reaches this: a failed read of the source ends the Collection
315
408
  * View before this renderer is drawn. A refusal is the acting person's to read, live or not.
316
409
  */
317
- diagnostics: state.error ? (_jsx(PhiAlertControl, { level: "error", showIcon: true, title: state.error })) : currentFolderLocked ? (_jsx(PhiAlertControl, { level: "info", showIcon: true, title: labels.tool.folderLockedText })) : null, body: body, items: state.assets.map((asset) => (_jsx(PhiMediaAssetTileControl, { asset: asset, minColumnWidth: minColumnWidth, selected: state.selectedAssetId === asset.id, mode: mode, deleting: deletingAssetIds.includes(asset.id), onSelect: selectAsset, onDelete: (nextAsset) => { void deleteAsset(nextAsset); }, deleteLabel: labels.grid.deleteLabel, showTypeLabel: true, showDeleteAction: !isPhiMediaFolderIdLocked(state.folders, asset.folderId), showDimensions: true, showIdLabel: true }, asset.id))), mode: mode, gap: gap, minColumnWidth: minColumnWidth, pagination: features.pagination?.enabled === false ? null : {
410
+ diagnostics: state.error ? (_jsx(PhiAlertControl, { level: "error", showIcon: true, title: state.error })) : currentFolderLocked ? (_jsx(PhiAlertControl, { level: "info", showIcon: true, title: labels.tool.folderLockedText })) : null, body: body, items: state.assets.map((asset) => (_jsx(PhiMediaAssetTileControl, { asset: asset, minColumnWidth: minColumnWidth, selected: state.selectedAssetId === asset.id, mode: mode, deleting: deletingAssetIds.includes(asset.id), ...(isMediaLibrary ? { onSelect: selectAsset } : {}), onDelete: (nextAsset) => { void deleteAsset(nextAsset); }, deleteLabel: labels.grid.deleteLabel, showTypeLabel: true, showDeleteAction: resourceActions.delete && !isPhiMediaFolderIdLocked(state.folders, asset.folderId), showDimensions: true, showIdLabel: true }, asset.id))), mode: mode, gap: gap, minColumnWidth: minColumnWidth, pagination: features.pagination?.enabled === false ? null : {
318
411
  page: state.page,
319
412
  pageSize: state.pageSize,
320
413
  total: state.pagination?.total ?? 0,
@@ -1,6 +1,7 @@
1
1
  import type { PhiCmsInstanceId } from "../../../../../types/cms-instance-id";
2
2
  import { type PhiCollectionViewWidgetLabels } from "../../../../../components/widgets/label-types/collection-view";
3
3
  import type { PhiCmsCollectionViewWidgetConfig } from "../../../../../types/collection-view-widget";
4
+ import type { PhiCollectionProviderResourceDescriptor } from "../../../../../types/collection-provider";
4
5
  import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
5
6
  export type PhiCollectionViewWidgetProps = {
6
7
  config?: PhiCmsCollectionViewWidgetConfig | null;
@@ -8,8 +9,12 @@ export type PhiCollectionViewWidgetProps = {
8
9
  labels?: unknown;
9
10
  /** The Widget's own words (the reorder handle and refusal), loaded where `features.reorder` is on. */
10
11
  reorderLabels?: PhiCollectionViewWidgetLabels;
11
- /** The bound resource's item key path, from its declaration; only where `features.reorder` is on. */
12
- itemIdentityPath?: string | null;
12
+ /**
13
+ * The bound resource as the Area's Modules declare it, read by the Server from the Area's registry:
14
+ * its item key path (what a reorder sends) and the actions, filters and panels its renderer's tools may
15
+ * offer. Handed on to the renderer as `resource`. `null` where the Area declares no such resource.
16
+ */
17
+ resourceDescriptor?: PhiCollectionProviderResourceDescriptor | null;
13
18
  /** Where this draws; the parsed config does not carry it, so the plugin reads it off the node. */
14
19
  renderMode: PhiRenderableBlockRenderMode;
15
20
  preview?: boolean;
@@ -58,7 +58,7 @@ function PhiCollectionViewWidgetPreview({ config, widgetId, renderMode, skeleton
58
58
  }
59
59
  return (_jsx(PhiCollectionViewSkeletonControl, { mode: presentation?.mode ?? "grid", gap: normalizePhiCssSize(presentation?.gap) ?? token.paddingSM, minColumnWidth: normalizePhiCssSize(presentation?.minColumnWidth) ?? 102, active: skeletonActive }));
60
60
  }
61
- function PhiCollectionViewWidgetLive({ config, labels, reorderLabels, itemIdentityPath, widgetId, renderMode, }) {
61
+ function PhiCollectionViewWidgetLive({ config, labels, reorderLabels, resourceDescriptor, widgetId, renderMode, }) {
62
62
  const signalIdentity = usePhiSignalIdentity();
63
63
  usePhiVisualAnchorParts(signalIdentity.receiver?.startsWith("cms:") ? signalIdentity.receiver : null, PHI_COLLECTION_VIEW_VISUAL_ANCHOR_PARTS);
64
64
  /*
@@ -104,7 +104,7 @@ function PhiCollectionViewWidgetLive({ config, labels, reorderLabels, itemIdenti
104
104
  const { binding: presentedBinding, reorder } = usePhiCollectionReorderBinding({
105
105
  config: resolvedConfig,
106
106
  binding,
107
- itemIdentityPath: itemIdentityPath ?? null,
107
+ itemIdentityPath: resourceDescriptor?.itemIdentityPath ?? null,
108
108
  labels: reorderLabels ?? PHI_COLLECTION_VIEW_WIDGET_DEFAULT_LABELS,
109
109
  showMessage,
110
110
  });
@@ -137,8 +137,16 @@ function PhiCollectionViewWidgetLive({ config, labels, reorderLabels, itemIdenti
137
137
  // `createElement` rather than a JSX tag: the renderer is looked up, not written down, and a looked-up
138
138
  // component in tag position reads to React -- and to `react-hooks/static-components` -- as a new
139
139
  // component per render. This is the same call `PhiRuntimeModuleRenderClientHost` makes for a Widget.
140
- // `renderMode` goes along so a renderer's own configuration failures are said the same way.
141
- return (_jsx(PhiCollectionReorderContext.Provider, { value: reorder, children: createElement(ItemRenderer, { config: resolvedConfig ?? config, binding: presentedBinding, labels, widgetId, renderMode }) }));
140
+ // `renderMode` goes along so a renderer's own configuration failures are said the same way, and the
141
+ // resource's declaration so its tools follow what the resource offers (`resource`, null where none).
142
+ return (_jsx(PhiCollectionReorderContext.Provider, { value: reorder, children: createElement(ItemRenderer, {
143
+ config: resolvedConfig ?? config,
144
+ binding: presentedBinding,
145
+ labels,
146
+ widgetId,
147
+ renderMode,
148
+ resource: resourceDescriptor ?? null,
149
+ }) }));
142
150
  }
143
151
  export function PhiCollectionViewWidget(props) {
144
152
  return props.preview
@@ -364,6 +364,31 @@ export declare const PHI_COLLECTION_VIEW_WIDGET_DEFINITION: {
364
364
  defaultItem?: undefined;
365
365
  itemFields?: undefined;
366
366
  precision?: undefined;
367
+ } | {
368
+ key: string;
369
+ type: "choice";
370
+ label: string;
371
+ presentation: "select";
372
+ options: {
373
+ value: "image" | "video" | "markdown" | "other" | "document" | "audio" | "pdf" | "archive" | "font" | "binary";
374
+ label: "image" | "video" | "markdown" | "other" | "document" | "audio" | "pdf" | "archive" | "font" | "binary";
375
+ }[];
376
+ emptyOption: {
377
+ value: string;
378
+ label: string;
379
+ };
380
+ emptyValue: null;
381
+ providerKind?: undefined;
382
+ optionsProvider?: undefined;
383
+ placeholder?: undefined;
384
+ min?: undefined;
385
+ itemKeyField?: undefined;
386
+ itemLabelField?: undefined;
387
+ addLabel?: undefined;
388
+ emptyLabel?: undefined;
389
+ defaultItem?: undefined;
390
+ itemFields?: undefined;
391
+ precision?: undefined;
367
392
  } | {
368
393
  key: string;
369
394
  type: "number";