@phis/ui 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/components/controls/phi-media-asset-tile-control.d.ts +4 -3
  2. package/components/controls/phi-media-picker-control.d.ts +9 -11
  3. package/components/controls/phi-media-picker-control.js +9 -11
  4. package/components/forms/form-field-labels.d.ts +3 -3
  5. package/components/forms/form-field-labels.js +13 -5
  6. package/components/forms/media-asset-field-keys.d.ts +9 -1
  7. package/components/forms/media-asset-field-keys.js +13 -1
  8. package/components/media/label-sets/media.js +4 -0
  9. package/components/media/media-folder-name-path.d.ts +14 -0
  10. package/components/media/media-folder-name-path.js +40 -2
  11. package/components/media/media-library-resource.d.ts +70 -0
  12. package/components/media/media-library-resource.js +41 -0
  13. package/components/media/media-widget-labels.d.ts +13 -0
  14. package/components/media/media-widget-labels.js +2 -0
  15. package/components/media/phi-area-upload-widget.d.ts +31 -1
  16. package/components/media/phi-area-upload-widget.js +33 -7
  17. package/components/media/phi-image-preview-data.d.ts +8 -1
  18. package/components/media/phi-image-preview-data.js +29 -0
  19. package/components/media/phi-media-picker-binding.d.ts +22 -20
  20. package/components/media/phi-media-picker-binding.js +20 -33
  21. package/components/media/use-media-library-add-picker.d.ts +94 -0
  22. package/components/media/use-media-library-add-picker.js +40 -0
  23. package/constants/media-library-provider-keys.d.ts +7 -0
  24. package/constants/media-library-provider-keys.js +7 -0
  25. package/constants/runtime-module-ownership.js +1 -0
  26. package/helpers/preset-tree-contract-check.d.ts +35 -0
  27. package/helpers/preset-tree-contract-check.js +211 -0
  28. package/module-page-check.d.ts +6 -0
  29. package/module-page-check.js +6 -0
  30. package/package.json +1 -1
  31. package/plugins/runtime-modules/asset/data-providers.d.ts +56 -38
  32. package/plugins/runtime-modules/asset/data-providers.js +4 -32
  33. package/plugins/runtime-modules/asset/definition.d.ts +115 -38
  34. package/plugins/runtime-modules/asset/definition.js +2 -1
  35. package/plugins/runtime-modules/asset/form-providers.d.ts +85 -2
  36. package/plugins/runtime-modules/asset/form-providers.js +70 -11
  37. package/plugins/runtime-modules/asset/form-ui-provider.js +7 -1
  38. package/plugins/runtime-modules/asset/media-asset-field.d.ts +7 -7
  39. package/plugins/runtime-modules/asset/media-asset-field.js +11 -33
  40. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +8 -7
  41. package/plugins/runtime-modules/asset/media-asset-form-control.js +42 -83
  42. package/plugins/runtime-modules/asset/media-assets-field.d.ts +37 -0
  43. package/plugins/runtime-modules/asset/media-assets-field.js +81 -0
  44. package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +27 -0
  45. package/plugins/runtime-modules/asset/media-assets-form-control.js +182 -0
  46. package/plugins/runtime-modules/asset/media-field-picker-labels.d.ts +9 -0
  47. package/plugins/runtime-modules/asset/media-field-picker-labels.js +49 -0
  48. package/plugins/runtime-modules/asset/services/collection.js +12 -0
  49. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.d.ts +24 -0
  50. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.js +55 -0
  51. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +26 -2
  52. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +125 -32
  53. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +7 -2
  54. package/plugins/runtime-modules/core/widgets/collection-view/client.js +12 -4
  55. package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +25 -0
  56. package/plugins/runtime-modules/core/widgets/collection-view/config.js +34 -0
  57. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +4 -1
  58. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +3 -2
  59. package/plugins/runtime-modules/core/widgets/collection-view/server.js +20 -18
  60. package/plugins/runtime-modules/descriptor-compiler.d.ts +4 -0
  61. package/plugins/runtime-modules/descriptor-compiler.js +9 -204
  62. package/plugins/runtime-modules/resolver.js +31 -5
  63. package/types/collection-view-widget.d.ts +19 -0
  64. package/types/core-widget-placements.d.ts +9 -0
  65. package/types/media.d.ts +16 -0
@@ -1,18 +1,14 @@
1
1
  import { isPhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../../constants/cms-areas";
2
2
  import { collectPhiTourDefinitionErrors } from "../../types/tours";
3
3
  import { PhiCmsPageType, PhiCmsRegionType, PhiCmsStatus } from "../../constants/phi-cms";
4
- import { PhiCmsLayoutType } from "../../constants/cms-layout-type-keys";
5
- import { createPhiPresetCmsInstanceId, createPhiPresetCmsPageId, isPhiCmsInstanceId, readPhiCmsInstanceIdDescriptor, } from "../../types/cms-instance-id";
4
+ import { createPhiPresetCmsInstanceId, createPhiPresetCmsPageId, readPhiCmsInstanceIdDescriptor, } from "../../types/cms-instance-id";
6
5
  import { resolvePhiRuntimeModuleSourceLocale } from "../../types/runtime-module-locale";
7
6
  import { canPhiViewerAccess, PHI_VIEWER_ACCESS_ANYONE, } from "../../types/access";
8
7
  import { mergePhiCmsShellTrees, omitPhiCmsShellCompositionNodes, } from "./shell-tree-composition";
9
8
  import { resolvePhiRuntimeModuleAreaRoutePath } from "../../helpers/runtime-module-route-path";
10
9
  import { createPhiPageReference } from "../../types/references";
11
10
  import { choosePhiAreaRootApplicant, describePhiAreaShellSettingsError, orderPhiAreaPathClaimsByCover, isPhiAssignablePublicRoutePath, } from "../../helpers/cms-area-config";
12
- import { resolvePhiLayoutCreationPreset } from "../../helpers/cms-layout-defaults";
13
- import { PHI_DIALOG_BLEED_BODY_CONFIG, PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH, isPhiFormSingleColumn, } from "../../helpers/cms-dialog";
14
- import { PhiCmsWidgetType } from "../../constants/cms-widget-types";
15
- import { buildPhiBasePageLayoutNode, PHI_BASE_PAGE_LAYOUT_NODE_ID, } from "../../components/regions/presets/phi-base-page-layout";
11
+ import { checkPhiPresetTreeContract } from "../../helpers/preset-tree-contract-check";
16
12
  import { concatPhiCmsTreeControllerSettings } from "../../helpers/cms-tree-controller-settings";
17
13
  import { createPhiModuleMediaResolver } from "../../helpers/module-media";
18
14
  const PHI_CMS_REGION_TYPE_VALUES = new Set(Object.values(PhiCmsRegionType));
@@ -1523,150 +1519,18 @@ function createSyntheticPresetPage({ siteId, area, path, flags = 0, }) {
1523
1519
  layoutConfig: {},
1524
1520
  };
1525
1521
  }
1526
- function stablePresetNodeJson(value) {
1527
- if (Array.isArray(value)) {
1528
- return `[${value.map(stablePresetNodeJson).join(",")}]`;
1529
- }
1530
- if (value && typeof value === "object") {
1531
- return `{${Object.entries(value)
1532
- .filter(([, entry]) => entry !== undefined)
1533
- .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
1534
- .map(([key, entry]) => `${JSON.stringify(key)}:${stablePresetNodeJson(entry)}`)
1535
- .join(",")}}`;
1536
- }
1537
- return JSON.stringify(value) ?? "undefined";
1538
- }
1539
- /**
1540
- * Equal id must mean equal node: the shared page scaffold carries the same instance id in every
1541
- * built-in preset tree, which stays sound only while every copy is the canonical node. A preset that
1542
- * wants different chrome gets its own Layout node in a slot -- a deviating copy of the scaffold is a
1543
- * contract violation, not a customisation.
1544
- */
1545
- function assertPhiCmsBasePageLayoutNode(tree, layoutsById) {
1546
- for (const node of [...tree.overlays, ...tree.contentWidgets]) {
1547
- if (node.id === PHI_BASE_PAGE_LAYOUT_NODE_ID) {
1548
- throw new Error("The base page layout instance id is reserved for the scaffold Layout node.");
1549
- }
1550
- }
1551
- const node = layoutsById.get(PHI_BASE_PAGE_LAYOUT_NODE_ID);
1552
- if (!node) {
1553
- return;
1554
- }
1555
- const canonical = buildPhiBasePageLayoutNode(tree.page);
1556
- const mismatch = Object.keys(canonical)
1557
- .find((key) => stablePresetNodeJson(node[key]) !== stablePresetNodeJson(canonical[key]));
1558
- if (mismatch) {
1559
- throw new Error(`Preset tree carries a deviating base page layout node: "${String(mismatch)}" is ` +
1560
- `${stablePresetNodeJson(node[mismatch])}, canonical is ${stablePresetNodeJson(canonical[mismatch])}.`);
1561
- }
1562
- }
1563
1522
  /**
1523
+ * The preset tree contract, enforced: the first of `checkPhiPresetTreeContract`'s findings
1524
+ * (`helpers/preset-tree-contract-check.ts`, which a Module runs in its own tests from
1525
+ * `@phis/ui/module/page-check`) is thrown, and the Page answers 500.
1526
+ *
1564
1527
  * `forms` are the Forms the compiler can see -- the ones the catalog's Modules ship, by id. A Form it
1565
1528
  * cannot see (one stored on the Site, one of a Module outside the catalog) is not judged.
1566
1529
  */
1567
1530
  export function assertPhiCmsPresetTreeContract(tree, expectedPage, forms) {
1568
- const layoutIds = new Set();
1569
- const allIds = new Set();
1570
- if (expectedPage &&
1571
- (tree.page.siteId !== expectedPage.siteId ||
1572
- tree.page.areaMask !== expectedPage.areaMask ||
1573
- tree.page.path !== expectedPage.path)) {
1574
- throw new Error("Preset loader returned a Page outside its requested context.");
1575
- }
1576
- for (const node of tree.overlays) {
1577
- if (!isPhiCmsInstanceId(node.id) || readPhiCmsInstanceIdDescriptor(node.id)?.origin !== "preset") {
1578
- throw new Error(`Preset Overlay has invalid instance id "${String(node.id)}".`);
1579
- }
1580
- if (allIds.has(node.id)) {
1581
- throw new Error(`Preset tree contains duplicate instance id "${node.id}".`);
1582
- }
1583
- allIds.add(node.id);
1584
- }
1585
- for (const node of tree.layoutNodes) {
1586
- if (!isPhiCmsInstanceId(node.id) || readPhiCmsInstanceIdDescriptor(node.id)?.origin !== "preset") {
1587
- throw new Error(`Preset layout node has invalid instance id "${String(node.id)}".`);
1588
- }
1589
- if (allIds.has(node.id)) {
1590
- throw new Error(`Preset tree contains duplicate instance id "${node.id}".`);
1591
- }
1592
- allIds.add(node.id);
1593
- layoutIds.add(node.id);
1594
- }
1595
- for (const node of tree.contentWidgets) {
1596
- if (!isPhiCmsInstanceId(node.id) || readPhiCmsInstanceIdDescriptor(node.id)?.origin !== "preset") {
1597
- throw new Error(`Preset widget node has invalid instance id "${String(node.id)}".`);
1598
- }
1599
- if (allIds.has(node.id)) {
1600
- throw new Error(`Preset tree contains duplicate instance id "${node.id}".`);
1601
- }
1602
- allIds.add(node.id);
1603
- }
1604
- for (const node of tree.layoutNodes) {
1605
- if (node.parentLayoutNodeId != null && !layoutIds.has(node.parentLayoutNodeId)) {
1606
- throw new Error(`Preset layout "${node.id}" has unresolved parent "${node.parentLayoutNodeId}".`);
1607
- }
1608
- }
1609
- for (const node of tree.contentWidgets) {
1610
- if (!layoutIds.has(node.parentLayoutNodeId)) {
1611
- throw new Error(`Preset widget "${node.id}" has unresolved parent "${node.parentLayoutNodeId}".`);
1612
- }
1613
- }
1614
- for (const region of tree.regions) {
1615
- if (expectedPage && region.pageId !== expectedPage.id) {
1616
- throw new Error(`Preset region "${region.regionType}" belongs to a different Page.`);
1617
- }
1618
- if (!layoutIds.has(region.rootLayoutNodeId)) {
1619
- throw new Error(`Preset region "${region.regionType}" has unresolved root "${region.rootLayoutNodeId}".`);
1620
- }
1621
- }
1622
- const layoutsById = new Map(tree.layoutNodes.map((node) => [node.id, node]));
1623
- assertPhiCmsBasePageLayoutNode(tree, layoutsById);
1624
- for (const overlay of tree.overlays) {
1625
- if (!layoutIds.has(overlay.bodyLayoutNodeId)) {
1626
- throw new Error(`Preset Overlay "${overlay.id}" has unresolved Body root "${overlay.bodyLayoutNodeId}".`);
1627
- }
1628
- if (overlay.headerLayoutNodeId != null && !layoutIds.has(overlay.headerLayoutNodeId)) {
1629
- throw new Error(`Preset Overlay "${overlay.id}" has unresolved Header root "${overlay.headerLayoutNodeId}".`);
1630
- }
1631
- if (overlay.footerPresentation === "none") {
1632
- continue;
1633
- }
1634
- const footerLayout = layoutsById.get(overlay.footerLayoutNodeId);
1635
- if (!footerLayout) {
1636
- throw new Error(`Preset Overlay "${overlay.id}" has unresolved Footer root "${overlay.footerLayoutNodeId}".`);
1637
- }
1638
- if (overlay.footerPresentation === "actions") {
1639
- if (footerLayout.widgetType !== PhiCmsLayoutType.Flex) {
1640
- throw new Error(`Preset Overlay "${overlay.id}" actions Footer must use the Phi Flex Layout.`);
1641
- }
1642
- const expectedConfig = resolvePhiLayoutCreationPreset("flex", "overlay-actions");
1643
- const mismatch = Object.entries(expectedConfig).find(([key, value]) => JSON.stringify(footerLayout.config[key]) !== JSON.stringify(value));
1644
- if (mismatch) {
1645
- throw new Error(`Preset Overlay "${overlay.id}" actions Footer does not match the canonical Layout preset at "${mismatch[0]}".`);
1646
- }
1647
- if (overlay.overlayType === "modal") {
1648
- assertPhiCmsDialogCommands(overlay.id, footerLayout.id, tree.contentWidgets);
1649
- }
1650
- }
1651
- }
1652
- for (const overlay of tree.overlays) {
1653
- if (overlay.overlayType === "modal") {
1654
- assertPhiCmsDialogBody(overlay.id, layoutsById.get(overlay.bodyLayoutNodeId));
1655
- if (forms)
1656
- assertPhiCmsDialogWidth(overlay, tree, forms);
1657
- }
1658
- }
1659
- for (const rootLayoutNodeId of [
1660
- tree.page.heroRootLayoutNodeId,
1661
- tree.page.headerBottomRootLayoutNodeId,
1662
- tree.page.siderRightRootLayoutNodeId,
1663
- tree.page.footerTopRootLayoutNodeId,
1664
- tree.page.drawerRightRootLayoutNodeId,
1665
- tree.page.contentRootLayoutNodeId,
1666
- ]) {
1667
- if (rootLayoutNodeId != null && !layoutIds.has(rootLayoutNodeId)) {
1668
- throw new Error(`Preset Page has unresolved root "${rootLayoutNodeId}".`);
1669
- }
1531
+ const [finding] = checkPhiPresetTreeContract(tree, { page: expectedPage, forms });
1532
+ if (finding) {
1533
+ throw new Error(finding.message);
1670
1534
  }
1671
1535
  }
1672
1536
  function assertPhiCmsAreaOverlayTree(descriptor, tree, page, forms) {
@@ -1795,62 +1659,3 @@ export async function instantiatePhiCmsRoutePreset({ binding, catalog, activeMod
1795
1659
  assertPhiCmsPresetTreeContract(tree, page, catalog.formDefinitionsById);
1796
1660
  return tree;
1797
1661
  }
1798
- /*
1799
- * A dialog's body and actions are one answer for every dialog (`helpers/cms-dialog.ts`), checked here as
1800
- * the footer Layout is: a Preset that builds its dialog node by node must arrive at the same look as one
1801
- * that calls `dialog`. A vertical Flex carries the whole body config; a Layout of another kind -- a Stack
1802
- * of tabs -- carries the ground and the inset, which are what make it the dialog's body.
1803
- */
1804
- function assertPhiCmsDialogBody(overlayId, body) {
1805
- // The bleed body is the other answer, for content that runs to the edge; it is matched whole.
1806
- const bleed = PHI_DIALOG_BLEED_BODY_CONFIG.padding === body.config.padding;
1807
- const required = bleed
1808
- ? PHI_DIALOG_BLEED_BODY_CONFIG
1809
- : body.widgetType === PhiCmsLayoutType.FlexVertical
1810
- ? PHI_DIALOG_BODY_CONFIG
1811
- : { surface: PHI_DIALOG_BODY_CONFIG.surface, padding: PHI_DIALOG_BODY_CONFIG.padding };
1812
- const mismatch = Object.entries(required).find(([key, value]) => JSON.stringify(body.config[key]) !== JSON.stringify(value));
1813
- if (mismatch) {
1814
- throw new Error(`Preset Overlay "${overlayId}" Body "${body.id}" does not match the dialog body (${bleed ? "PHI_DIALOG_BLEED_BODY_CONFIG" : "PHI_DIALOG_BODY_CONFIG"}) at "${mismatch[0]}".`);
1815
- }
1816
- }
1817
- function assertPhiCmsDialogCommands(overlayId, footerLayoutId, widgets) {
1818
- for (const widget of widgets) {
1819
- if (widget.parentLayoutNodeId !== footerLayoutId || widget.widgetType !== PhiCmsWidgetType.CommandToolbar)
1820
- continue;
1821
- const mismatch = Object.entries(PHI_DIALOG_COMMANDS_CONFIG).find(([key, value]) => widget.config[key] !== value);
1822
- if (mismatch) {
1823
- throw new Error(`Preset Overlay "${overlayId}" actions "${widget.id}" do not match the dialog actions (PHI_DIALOG_COMMANDS_CONFIG) at "${mismatch[0]}".`);
1824
- }
1825
- }
1826
- }
1827
- /*
1828
- * A dialog is as wide as its Form needs (`helpers/cms-dialog.ts`): one column takes
1829
- * `PHI_DIALOG_WIDTH_SINGLE_COLUMN`, two keep `PHI_DIALOG_WIDTH`. What is refused is the one width a Preset
1830
- * did not choose -- the default, holding nothing but Forms of one column. Any other width was stated, by a
1831
- * caller that knows what else the body holds; a Form the compiler cannot see is not judged.
1832
- */
1833
- function assertPhiCmsDialogWidth(overlay, tree, forms) {
1834
- if (stablePresetNodeJson(overlay.config.width) !== stablePresetNodeJson(PHI_DIALOG_WIDTH))
1835
- return;
1836
- const bodyLayoutIds = new Set([overlay.bodyLayoutNodeId]);
1837
- for (let grown = true; grown;) {
1838
- grown = false;
1839
- for (const node of tree.layoutNodes) {
1840
- if (node.parentLayoutNodeId != null && bodyLayoutIds.has(node.parentLayoutNodeId) && !bodyLayoutIds.has(node.id)) {
1841
- bodyLayoutIds.add(node.id);
1842
- grown = true;
1843
- }
1844
- }
1845
- }
1846
- const formIds = tree.contentWidgets
1847
- .filter((widget) => widget.widgetType === PhiCmsWidgetType.Form && bodyLayoutIds.has(widget.parentLayoutNodeId))
1848
- .map((widget) => widget.config.formId);
1849
- if (formIds.length === 0)
1850
- return;
1851
- const descriptors = formIds.map((formId) => (typeof formId === "string" ? forms.get(formId) : undefined)?.descriptor);
1852
- if (descriptors.every((descriptor) => descriptor != null && isPhiFormSingleColumn(descriptor))) {
1853
- throw new Error(`Preset Overlay "${overlay.id}" holds the one-column Form "${String(formIds[0])}" at the full dialog width ` +
1854
- "(PHI_DIALOG_WIDTH). Hand the Form to `dialog` as `body.form`, or state `width: PHI_DIALOG_WIDTH_SINGLE_COLUMN`.");
1855
- }
1856
- }
@@ -9,7 +9,8 @@ import { PHI_VIEWER_ACCESS_ANYONE, } from "../../types/access";
9
9
  import { stripRenderableBlockDefaults } from "../../helpers/renderable-block-serialization";
10
10
  import { PhiCmsWidgetType } from "../../constants/cms-widget-types";
11
11
  import { parsePhiFormWidgetConfig } from "../../components/forms/form-widget-config";
12
- import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS, } from "../../constants/media-library-provider-keys";
12
+ import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS, PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY, } from "../../constants/media-library-provider-keys";
13
+ import { isPhiRecord } from "../../helpers/is-record";
13
14
  import { buildPhiRecordDeclarationsByKey } from "../../helpers/record-fields";
14
15
  function loadRuntimeWidgetPlugin(entry) {
15
16
  return entry.loadRuntime();
@@ -362,6 +363,18 @@ function collectDataProviderKeysFromValue(value, knownProviderKeys, collected) {
362
363
  collectDataProviderKeysFromValue(entry, knownProviderKeys, collected);
363
364
  }
364
365
  }
366
+ /** The renderer a Collection View's items are drawn by: its own `itemRendererKey`, else its resource's. */
367
+ function readPhiCollectionViewItemRendererKey(config, moduleSet) {
368
+ if (typeof config.itemRendererKey === "string" && config.itemRendererKey)
369
+ return config.itemRendererKey;
370
+ const source = isPhiRecord(config.source) ? config.source : null;
371
+ const descriptor = typeof source?.providerKey === "string"
372
+ ? moduleSet.dataProviderDescriptorsByKey.get(source.providerKey)
373
+ : undefined;
374
+ return descriptor?.kind === "collection"
375
+ ? descriptor.resources.find((resource) => resource.resourceKey === source?.resourceKey)?.itemRendererKey ?? null
376
+ : null;
377
+ }
365
378
  export function collectPhiRuntimeDataProviderKeys({ moduleSet, trees, }) {
366
379
  /*
367
380
  * What the browser mounts. A `record` Provider has no Client half -- it is asked on the server while the
@@ -381,17 +394,30 @@ export function collectPhiRuntimeDataProviderKeys({ moduleSet, trees, }) {
381
394
  collected.add(providerKey);
382
395
  }
383
396
  }
397
+ /*
398
+ * A Collection View the Media renderer draws -- the Media library's own, or another Provider's
399
+ * Collection of Assets whose resource or placement names that renderer -- opens the Media library's
400
+ * picker and its upload wall, which read the library. The renderer is what needs it, so the scan says
401
+ * so here rather than every such resource naming the library's Provider.
402
+ */
403
+ if (widget.widgetType === PhiCmsWidgetType.CollectionView &&
404
+ knownProviderKeys.has(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection) &&
405
+ readPhiCollectionViewItemRendererKey(widgetConfig, moduleSet) === PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY) {
406
+ collected.add(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection);
407
+ }
384
408
  if (widget.widgetType === PhiCmsWidgetType.Form) {
385
409
  const formId = parsePhiFormWidgetConfig(widgetConfig).formId;
386
410
  const form = formId ? moduleSet.formDefinitionsById.get(formId) : null;
387
411
  if (form) {
388
412
  collectDataProviderKeysFromValue(form.descriptor, knownProviderKeys, collected);
389
413
  /*
390
- * A `media-asset` field reads the Media library through the picker, and a field descriptor names
391
- * no Provider of its own to find it by. The field type is what needs it, so the scan says so
392
- * once, here, instead of every Form that has one repeating the Provider in its descriptor.
414
+ * A `media-asset` field reads the Media library through the picker, a `media-assets` field its
415
+ * tiles and picker too, and a field descriptor names no Provider of its own to find it by. The
416
+ * field type is what needs it, so the scan says so once, here, instead of every Form that has
417
+ * one repeating the Provider in its descriptor.
393
418
  */
394
- if (form.descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY) &&
419
+ if (form.descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY ||
420
+ field.fieldProviderKey === PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY) &&
395
421
  knownProviderKeys.has(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection)) {
396
422
  collected.add(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection);
397
423
  }
@@ -4,6 +4,7 @@ import type { PhiCollectionProviderQuery } from "./collection-provider";
4
4
  import type { PhiProviderResourceSource } from "./runtime-data-provider";
5
5
  import type { PhiSignalRouteSet } from "./signals";
6
6
  import type { PhiCssLength } from "./length";
7
+ import type { PhiMediaKindValue } from "./media";
7
8
  import type { PhiCmsWidgetConfigBase } from "../components/widgets/config/parser-primitives";
8
9
  /**
9
10
  * A Collection View's parsed config, as the item renderer it hands its items to receives it.
@@ -52,6 +53,24 @@ export type PhiCmsCollectionViewWidgetConfig = PhiCmsWidgetConfigBase & {
52
53
  enabled: boolean;
53
54
  actionKey?: string;
54
55
  };
56
+ /**
57
+ * Read by the Media renderer (`PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY`) and by no other, whichever
58
+ * Provider it draws: where an upload from its upload panel goes and where its "Choose from Media
59
+ * library" picker opens, and what both offer.
60
+ */
61
+ media?: {
62
+ /**
63
+ * A Folder of the Site Space by its path of names ("Shop Images / {category} / {product}"): an
64
+ * upload goes into it, the missing Folders created, and the picker opens on the deepest of it that
65
+ * is there. `{key}` is the binding param `key` (`source.params` with what `bindingParamsChange`
66
+ * laid over them): a text or a number, trimmed, a `/` in it a `-`, and a name whose placeholder has
67
+ * no value left out whole (`resolvePhiMediaFolderPathTemplate`). Absent: for the Media library's
68
+ * own Collection the Folder its listing has open, for any other the root of the Site Space.
69
+ */
70
+ folderPath?: string;
71
+ /** The one kind the upload takes and the picker lists. Absent: the upload takes every kind, the picker lists images. */
72
+ mediaType?: PhiMediaKindValue;
73
+ };
55
74
  pagination?: {
56
75
  enabled: boolean;
57
76
  pageSize?: number;
@@ -8,6 +8,7 @@ import type { PhiRuntimeConditionExpression } from "./runtime-condition";
8
8
  import type { PhiSignalRoute, PhiSignalValue } from "./signals";
9
9
  import type { PhiCssLength } from "./length";
10
10
  import type { PhiControlSize } from "./control";
11
+ import type { PhiMediaKindValue } from "./media";
11
12
  import type { PhiCollectionProviderQuery } from "./collection-provider";
12
13
  import type { PhiProviderResourceSource } from "./runtime-data-provider";
13
14
  import type { PhiFormId } from "./form-id";
@@ -389,6 +390,14 @@ export type PhiCollectionViewWidgetPlacement = PhiWidgetPlacementBase & {
389
390
  enabled: boolean;
390
391
  actionKey?: string;
391
392
  };
393
+ /**
394
+ * The Media renderer's upload Folder (`{param}` from the binding params) and the kind it takes and its
395
+ * picker lists (`PhiCmsCollectionViewWidgetConfig`).
396
+ */
397
+ media?: {
398
+ folderPath?: string;
399
+ mediaType?: PhiMediaKindValue;
400
+ };
392
401
  pagination?: {
393
402
  enabled: boolean;
394
403
  pageSize?: number;
package/types/media.d.ts CHANGED
@@ -137,6 +137,22 @@ export type PhiMediaAssetTile = {
137
137
  font: PhiFontMetrics | null;
138
138
  folder?: Pick<PhiMediaAssetFolder, "id" | "name"> | null;
139
139
  };
140
+ /**
141
+ * An item of a Collection the Media library's renderer draws (`PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY`), of
142
+ * whichever Provider: what a Media tile reads of an Asset (`PhiMediaAssetTileControlAsset` is this without
143
+ * `folderId`), keyed by the Asset id (`id`, so the resource's `itemIdentityPath` is `"id"`). `kind` is the
144
+ * Media kind of `contentType` (`resolvePhiMediaKindFromContentType`); `deliveryPolicy` and
145
+ * `lifecycleStatus` say whether a visitor is served it, which the tile shows. `folderId` is read where an
146
+ * item has one, for the lock of its Folder; a Collection of references to Assets leaves it out. The
147
+ * renderer reads every item strictly (`readPhiMediaCollectionItems`): an item without one of the
148
+ * required fields is a failure naming the field, never a tile with a filler. `deliveryUrl` is empty for a
149
+ * reference whose Asset the library no longer answers; the tile shows the kind's icon.
150
+ *
151
+ * A whole `PhiMediaAssetTile` -- the Media library's own Collection -- is one of these.
152
+ */
153
+ export type PhiMediaCollectionItem = Pick<PhiMediaAssetTile, "id" | "kind" | "originalName" | "title" | "altText" | "contentType" | "deliveryUrl" | "thumbnailUrl" | "previewUrl" | "deliveryPolicy" | "lifecycleStatus" | "width" | "height" | "blurDataUrl"> & {
154
+ folderId?: number | null;
155
+ };
140
156
  export type PhiMediaPickerState = {
141
157
  query: string;
142
158
  folderId: number | null;