@phis/ui 0.7.2 → 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 (60) hide show
  1. package/components/controls/phi-collection-reorder-context.d.ts +21 -0
  2. package/components/controls/phi-collection-reorder-context.js +6 -0
  3. package/components/controls/phi-collection-sortable-layout-control.d.ts +17 -0
  4. package/components/controls/phi-collection-sortable-layout-control.js +72 -0
  5. package/components/controls/phi-collection-view-control.d.ts +1 -1
  6. package/components/controls/phi-collection-view-control.js +15 -1
  7. package/components/controls/phi-media-asset-tile-control.d.ts +12 -5
  8. package/components/controls/phi-media-picker-control.d.ts +14 -1
  9. package/components/controls/phi-media-picker-control.js +11 -2
  10. package/components/forms/compound-form-controls.d.ts +1 -1
  11. package/components/forms/compound-form-controls.js +6 -4
  12. package/components/forms/form-field-labels.d.ts +3 -1
  13. package/components/forms/form-field-labels.js +19 -6
  14. package/components/forms/form-provider-contract.js +2 -1
  15. package/components/forms/media-asset-field-keys.d.ts +4 -1
  16. package/components/forms/media-asset-field-keys.js +4 -1
  17. package/components/forms/table-field-keys.d.ts +8 -0
  18. package/components/forms/table-field-keys.js +8 -0
  19. package/components/forms/table-field-labels.d.ts +16 -0
  20. package/components/forms/table-field-labels.js +16 -0
  21. package/components/forms/table-field-text.d.ts +9 -0
  22. package/components/forms/table-field-text.js +20 -0
  23. package/components/forms/upload-field-refusal-labels.d.ts +10 -0
  24. package/components/forms/upload-field-refusal-labels.js +24 -0
  25. package/components/forms/upload-form-control.js +3 -16
  26. package/components/media/media-upload-flow.d.ts +13 -1
  27. package/components/media/media-upload-flow.js +16 -0
  28. package/components/media/phi-media-picker-binding.d.ts +48 -1
  29. package/components/media/phi-media-picker-binding.js +99 -6
  30. package/components/media/phi-media-upload.d.ts +7 -1
  31. package/components/media/phi-media-upload.js +17 -5
  32. package/components/widgets/client/shared/phi-collection-reorder.d.ts +45 -0
  33. package/components/widgets/client/shared/phi-collection-reorder.js +110 -0
  34. package/components/widgets/client/shared/phi-collection-view-binding.js +2 -1
  35. package/components/widgets/label-sets/collection-view.d.ts +4 -0
  36. package/components/widgets/label-sets/collection-view.js +16 -0
  37. package/components/widgets/label-sets/table.d.ts +6 -0
  38. package/components/widgets/label-sets/table.js +10 -0
  39. package/components/widgets/label-types/collection-view.d.ts +8 -0
  40. package/components/widgets/label-types/collection-view.js +4 -0
  41. package/controls.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/plugins/runtime-modules/asset/definition.d.ts +8 -0
  44. package/plugins/runtime-modules/asset/form-providers.d.ts +8 -0
  45. package/plugins/runtime-modules/asset/form-providers.js +6 -0
  46. package/plugins/runtime-modules/asset/media-asset-field.d.ts +34 -4
  47. package/plugins/runtime-modules/asset/media-asset-field.js +50 -3
  48. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +13 -0
  49. package/plugins/runtime-modules/asset/media-asset-form-control.js +81 -5
  50. package/plugins/runtime-modules/builder/page-meta-form.js +6 -6
  51. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +5 -0
  52. package/plugins/runtime-modules/core/widgets/collection-view/client.js +50 -4
  53. package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +28 -2
  54. package/plugins/runtime-modules/core/widgets/collection-view/config.js +13 -0
  55. package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +1 -1
  56. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +4 -1
  57. package/plugins/runtime-modules/core/widgets/collection-view/server.js +19 -4
  58. package/types/collection-provider.d.ts +7 -0
  59. package/types/collection-view-widget.d.ts +11 -0
  60. package/types/core-widget-placements.d.ts +5 -0
@@ -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
  }
@@ -96,6 +96,13 @@ export type PhiCollectionProviderActionRequest = {
96
96
  itemKey?: string | number | null;
97
97
  item?: Record<string, unknown> | null;
98
98
  selectedItemKeys?: (string | number)[];
99
+ /**
100
+ * Every item key of the collection, in the order a reader dragged them into (`collection-view`'s
101
+ * `features.reorder`): the whole collection, never a page of it or a search's share. Sent with the
102
+ * reorder action's key; the Provider stores the order or refuses, and answers the collection as it
103
+ * now stands.
104
+ */
105
+ itemKeys?: (string | number)[];
99
106
  query?: PhiCollectionProviderQuery;
100
107
  params?: Record<string, unknown>;
101
108
  signal: AbortSignal;
@@ -41,6 +41,17 @@ export type PhiCmsCollectionViewWidgetConfig = PhiCmsWidgetConfigBase & {
41
41
  actions?: {
42
42
  toolbar?: PhiCmsCollectionToolbarActionPresentation[];
43
43
  };
44
+ /**
45
+ * Drag reordering of the items, written back through the bound Provider's action `actionKey`
46
+ * (`"reorder"` by default) with every item key in the new order (`itemKeys`). The Widget stores no
47
+ * order: the Provider's is the order, applied at once on a drop and taken back if refused. Offered
48
+ * in `grid` and `stack` only, and only while the whole collection is shown -- no search text, no
49
+ * filter set apart from the Widget's own initial query, everything on one page.
50
+ */
51
+ reorder?: {
52
+ enabled: boolean;
53
+ actionKey?: string;
54
+ };
44
55
  pagination?: {
45
56
  enabled: boolean;
46
57
  pageSize?: number;
@@ -384,6 +384,11 @@ export type PhiCollectionViewWidgetPlacement = PhiWidgetPlacementBase & {
384
384
  actions?: {
385
385
  toolbar?: PhiCmsCollectionToolbarActionPresentation[];
386
386
  };
387
+ /** Drag reordering through the bound Provider's action (`PhiCmsCollectionViewWidgetConfig`). */
388
+ reorder?: {
389
+ enabled: boolean;
390
+ actionKey?: string;
391
+ };
387
392
  pagination?: {
388
393
  enabled: boolean;
389
394
  pageSize?: number;