@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
@@ -2,6 +2,7 @@ export type PhiColorPickerLabels = {
2
2
  custom: string;
3
3
  colors: {
4
4
  primary: string;
5
+ status: string;
5
6
  text: string;
6
7
  red: string;
7
8
  volcano: string;
@@ -2,6 +2,7 @@ export const PHI_COLOR_PICKER_DEFAULT_LABELS = {
2
2
  custom: "Custom",
3
3
  colors: {
4
4
  primary: "Primary",
5
+ status: "Status",
5
6
  text: "Text",
6
7
  red: "Red",
7
8
  volcano: "Volcano",
package/controls.d.ts CHANGED
@@ -39,7 +39,7 @@ export type { PhiCollectionHeaderControlProps } from "./components/controls/phi-
39
39
  export { PhiCollectionViewControl } from "./components/controls/phi-collection-view-control";
40
40
  export type { PhiCollectionViewControlProps } from "./components/controls/phi-collection-view-control";
41
41
  export { PhiMediaAssetCollectionSkeletonControl, PhiMediaAssetTileControl, } from "./components/controls/phi-media-asset-tile-control";
42
- export type { PhiMediaAssetCollectionSkeletonControlProps, PhiMediaAssetTileControlProps, } from "./components/controls/phi-media-asset-tile-control";
42
+ export type { PhiMediaAssetCollectionSkeletonControlProps, PhiMediaAssetTileControlAsset, PhiMediaAssetTileControlProps, } from "./components/controls/phi-media-asset-tile-control";
43
43
  export { PhiMediaSourceItemTileControl } from "./components/controls/phi-media-source-item-tile-control";
44
44
  export type { PhiMediaSourceItemTileControlProps } from "./components/controls/phi-media-source-item-tile-control";
45
45
  export { PhiVideoEmbedControl } from "./components/controls/phi-video-embed-control";
@@ -9,5 +9,11 @@ export declare function resolvePhiCmsWidgetContentBindingForConfig(binding: PhiC
9
9
  * Whether a bound Widget has nothing to show on the live Site: no published content and no value of its
10
10
  * own. That is a Widget the Site created whose content was never published -- the Builder's placeholder
11
11
  * is not live until somebody publishes it. A preset node keeps its shipped value and is never empty.
12
+ *
13
+ * A Widget that names a field of the page record (`binding.recordField`) on a Page about a record is
14
+ * not judged: it shows the record's field there, not content of its own, and draws nothing itself where
15
+ * the record lacks the field. Its own content only stands in on a Page about no record, and is judged there.
12
16
  */
13
- export declare function isPhiCmsWidgetContentUnpublished(binding: PhiCmsWidgetContentBinding | null | undefined, widget: Pick<PhiCmsContentWidgetNode, "config" | "resolvedContent">): boolean;
17
+ export declare function isPhiCmsWidgetContentUnpublished(binding: PhiCmsWidgetContentBinding | null | undefined, widget: Pick<PhiCmsContentWidgetNode, "config" | "resolvedContent">, page: {
18
+ aboutRecord: boolean;
19
+ }): boolean;
@@ -25,8 +25,16 @@ export function resolvePhiCmsWidgetContentBindingForConfig(binding, config) {
25
25
  * Whether a bound Widget has nothing to show on the live Site: no published content and no value of its
26
26
  * own. That is a Widget the Site created whose content was never published -- the Builder's placeholder
27
27
  * is not live until somebody publishes it. A preset node keeps its shipped value and is never empty.
28
+ *
29
+ * A Widget that names a field of the page record (`binding.recordField`) on a Page about a record is
30
+ * not judged: it shows the record's field there, not content of its own, and draws nothing itself where
31
+ * the record lacks the field. Its own content only stands in on a Page about no record, and is judged there.
28
32
  */
29
- export function isPhiCmsWidgetContentUnpublished(binding, widget) {
33
+ export function isPhiCmsWidgetContentUnpublished(binding, widget, page) {
30
34
  const applied = resolvePhiCmsWidgetContentBindingForConfig(binding, widget.config);
31
- return applied != null && widget.resolvedContent == null && !hasConfigValue(widget.config, applied.sourceField);
35
+ if (applied == null)
36
+ return false;
37
+ if (page.aboutRecord && applied.recordField && hasConfigValue(widget.config, applied.recordField))
38
+ return false;
39
+ return widget.resolvedContent == null && !hasConfigValue(widget.config, applied.sourceField);
32
40
  }
@@ -25,5 +25,30 @@ export declare function collectPhiCmsNodeFeatureNamespaces(visibleWhen: PhiRunti
25
25
  * wrongly on the server.
26
26
  */
27
27
  export declare function readPhiCmsServerPageConditionState(runtime: Pick<PhiBlockRuntime, "page" | "request">): PhiRuntimePageConditionState | null;
28
+ /** Whether a condition reads the record the Page is about, which only the server can answer. */
29
+ export declare function readsPhiCmsNodeRecord(visibleWhen: PhiRuntimeConditionExpression | null): boolean;
30
+ /**
31
+ * What a `record` condition is judged against in one render.
32
+ *
33
+ * `fields` is the record the Page is about, each field as the value it has -- the same fields, by the same
34
+ * keys, a Widget's `recordField` reads -- or null on a Page that is about no record. `live` is whether the
35
+ * node renders for the live Site: there, a node that asks about a record that is not there stays away.
36
+ * In the Builder it is drawn, because a template open without a record is still to be edited, and its
37
+ * bound Widgets show their own content in the record's place.
38
+ */
39
+ export type PhiCmsNodeRecordConditionState = {
40
+ fields: Readonly<Record<string, unknown>> | null;
41
+ live: boolean;
42
+ };
43
+ /**
44
+ * A node's condition with every `record` part answered, before anything else of it is.
45
+ *
46
+ * `false` is a condition that cannot hold whatever the rest of it says, `null` one that holds whatever
47
+ * the rest says (or no condition at all), and an expression is what is left to answer -- the parts that
48
+ * do not read the record, as `resolvePhiCmsNodeVisibility` and, where it has to, the gate take them.
49
+ * The record is answered here and taken out, not handed on: the gate runs in the browser, which never
50
+ * sees the record, so a part about it would leave the node waiting for an answer nobody can give.
51
+ */
52
+ export declare function settlePhiCmsNodeRecordConditions(visibleWhen: PhiRuntimeConditionExpression | null, record: PhiCmsNodeRecordConditionState): PhiRuntimeConditionExpression | null | false;
28
53
  export type PhiCmsNodeVisibility = "render" | "omit" | "gate";
29
54
  export declare function resolvePhiCmsNodeVisibility(visibleWhen: PhiRuntimeConditionExpression | null, page: PhiRuntimePageConditionState | null, features?: PhiRuntimeFeatureState | null): PhiCmsNodeVisibility;
@@ -1,4 +1,4 @@
1
- import { collectPhiRuntimeValueConditions, evaluatePhiRuntimeConditionExpression, readPhiRuntimeConditionExpression, } from "../types/runtime-condition";
1
+ import { collectPhiRuntimeValueConditions, evaluatePhiRuntimeConditionExpression, matchesPhiRuntimeValueCondition, readPhiRuntimeConditionExpression, } from "../types/runtime-condition";
2
2
  /**
3
3
  * Whether a node appears at all, read from the node's own config rather than the Widget's.
4
4
  *
@@ -48,6 +48,40 @@ export function readPhiCmsServerPageConditionState(runtime) {
48
48
  }
49
49
  return { path: runtime.page?.path ?? "", query };
50
50
  }
51
+ /** Whether a condition reads the record the Page is about, which only the server can answer. */
52
+ export function readsPhiCmsNodeRecord(visibleWhen) {
53
+ return collectPhiRuntimeValueConditions(visibleWhen).some((condition) => condition.source === "record");
54
+ }
55
+ /**
56
+ * A node's condition with every `record` part answered, before anything else of it is.
57
+ *
58
+ * `false` is a condition that cannot hold whatever the rest of it says, `null` one that holds whatever
59
+ * the rest says (or no condition at all), and an expression is what is left to answer -- the parts that
60
+ * do not read the record, as `resolvePhiCmsNodeVisibility` and, where it has to, the gate take them.
61
+ * The record is answered here and taken out, not handed on: the gate runs in the browser, which never
62
+ * sees the record, so a part about it would leave the node waiting for an answer nobody can give.
63
+ */
64
+ export function settlePhiCmsNodeRecordConditions(visibleWhen, record) {
65
+ if (!visibleWhen || !readsPhiCmsNodeRecord(visibleWhen))
66
+ return visibleWhen;
67
+ if ("source" in visibleWhen) {
68
+ if (record.fields == null)
69
+ return record.live ? false : null;
70
+ return matchesPhiRuntimeValueCondition(visibleWhen, { record: record.fields }) ? null : false;
71
+ }
72
+ const decisive = visibleWhen.match === "all" ? false : null;
73
+ const rest = [];
74
+ for (const condition of visibleWhen.conditions) {
75
+ const settled = settlePhiCmsNodeRecordConditions(condition, record);
76
+ if (settled === decisive)
77
+ return decisive;
78
+ if (settled)
79
+ rest.push(settled);
80
+ }
81
+ if (rest.length === 0)
82
+ return visibleWhen.match === "all" ? null : false;
83
+ return rest.length === 1 ? rest[0] : { match: visibleWhen.match, conditions: rest };
84
+ }
51
85
  /**
52
86
  * How much of a node's condition this render can settle on its own.
53
87
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -521,7 +521,7 @@
521
521
  "@lexical/rich-text": "0.50.0",
522
522
  "@lexical/selection": "0.50.0",
523
523
  "@lexical/utils": "0.50.0",
524
- "@phis/contracts": "^0.8.0",
524
+ "@phis/contracts": "^0.8.1",
525
525
  "dayjs": "^1.11.23",
526
526
  "dom-serializer": "^2.0.0",
527
527
  "htmlparser2": "^10.1.0",
@@ -5,7 +5,7 @@ export const PHI_ACCOUNTING_RUNTIME_MODULE_DEFINITION = definePhiAreaBaseRuntime
5
5
  area: "accounting",
6
6
  moduleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
7
7
  serverBinding: PHI_CORE_SERVER_BINDING,
8
- description: "Locked Accounting Area shell, navigation surface, and accounting workspace route.",
8
+ description: "Locked Accounting Area shell, navigation surface, and root route.",
9
9
  category: "foundation",
10
10
  icon: "antd:profile",
11
11
  });
@@ -1,9 +1,12 @@
1
- import { PHI_BASE_PAGE_LAYOUT_VERSION } from "../../../components/regions/presets/phi-base-page-layout";
2
1
  import { buildPhiAreaRootRoutePresetDescriptor } from "../area-root-route";
3
2
  import { PhiCmsRegionType } from "../../../constants/phi-cms";
4
3
  import { PHI_DEFAULT_PUB_AREA_COMPOSITION_NODE_KEYS } from "../preset-contracts/pub-area";
5
4
  import { PHI_ACCOUNTING_RUNTIME_MODULE_ID } from "./ids";
6
- /* What the Accounting base Module brings: the Site shell for its Area, the Area root and the overview. */
5
+ /*
6
+ * What the Accounting base Module brings: the Site shell for its Area and the Area root. No Page of its
7
+ * own -- the Dashboard Module's entry stands first in the sidebar, so the root lands there, and every other
8
+ * Accounting Page is a Module's.
9
+ */
7
10
  export const PHI_ACCOUNTING_RUNTIME_MODULE_AREA_SHELLS = [
8
11
  {
9
12
  ownerModuleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
@@ -41,14 +44,4 @@ export const PHI_ACCOUNTING_RUNTIME_MODULE_ROUTES = [
41
44
  area: "accounting",
42
45
  title: "Accounting",
43
46
  }),
44
- {
45
- ownerModuleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
46
- presetKey: "accounting-overview-page",
47
- presetVersion: 1 + PHI_BASE_PAGE_LAYOUT_VERSION,
48
- area: "accounting",
49
- title: "Overview",
50
- path: "/overview",
51
- loadTree: ({ page, runtime }) => import("./trees/phi-default-accounting-page-tree")
52
- .then((module) => module.buildPhiDefaultAccountingPageTree({ page, runtime })),
53
- },
54
47
  ];
@@ -117,16 +117,7 @@ export declare const PHI_ACCOUNTING_RUNTIME_AREA_DEFINITIONS: {
117
117
  label: {
118
118
  defaultMessage: string;
119
119
  };
120
- items: ({
121
- itemKey: string;
122
- label: {
123
- defaultMessage: string;
124
- };
125
- icon: string;
126
- routePresetKey: string;
127
- standing?: undefined;
128
- target?: undefined;
129
- } | {
120
+ items: {
130
121
  itemKey: string;
131
122
  label: {
132
123
  defaultMessage: string;
@@ -137,9 +128,8 @@ export declare const PHI_ACCOUNTING_RUNTIME_AREA_DEFINITIONS: {
137
128
  kind: "area";
138
129
  area: "admin";
139
130
  };
140
- routePresetKey?: undefined;
141
- })[];
142
- exportedItemKeys: string[];
131
+ }[];
132
+ exportedItemKeys: never[];
143
133
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
144
134
  })[];
145
135
  }[];
@@ -331,16 +321,7 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
331
321
  label: {
332
322
  defaultMessage: string;
333
323
  };
334
- items: ({
335
- itemKey: string;
336
- label: {
337
- defaultMessage: string;
338
- };
339
- icon: string;
340
- routePresetKey: string;
341
- standing?: undefined;
342
- target?: undefined;
343
- } | {
324
+ items: {
344
325
  itemKey: string;
345
326
  label: {
346
327
  defaultMessage: string;
@@ -351,9 +332,8 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
351
332
  kind: "area";
352
333
  area: "admin";
353
334
  };
354
- routePresetKey?: undefined;
355
- })[];
356
- exportedItemKeys: string[];
335
+ }[];
336
+ exportedItemKeys: never[];
357
337
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
358
338
  })[];
359
339
  } | {
@@ -603,16 +583,7 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
603
583
  label: {
604
584
  defaultMessage: string;
605
585
  };
606
- items: ({
607
- itemKey: string;
608
- label: {
609
- defaultMessage: string;
610
- };
611
- icon: string;
612
- routePresetKey: string;
613
- standing?: undefined;
614
- target?: undefined;
615
- } | {
586
+ items: {
616
587
  itemKey: string;
617
588
  label: {
618
589
  defaultMessage: string;
@@ -623,9 +594,8 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
623
594
  kind: "area";
624
595
  area: "admin";
625
596
  };
626
- routePresetKey?: undefined;
627
- })[];
628
- exportedItemKeys: string[];
597
+ }[];
598
+ exportedItemKeys: never[];
629
599
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
630
600
  })[];
631
601
  } | {
@@ -244,12 +244,11 @@ export const PHI_ACCOUNTING_RUNTIME_AREA_DEFINITIONS = [
244
244
  navigationSurfaces: [{
245
245
  navKey: "accounting:sidebar",
246
246
  label: label("Accounting sidebar navigation"),
247
- items: [{
248
- itemKey: "@phis/ui/modules/accounting/nav/home",
249
- label: label("Overview"),
250
- icon: "antd:audit",
251
- routePresetKey: "accounting-overview-page",
252
- },
247
+ /*
248
+ * No entry of its own for the Area, as in the App: the root forwards to the first Module entry a
249
+ * viewer can see -- the Dashboard's -- and the Overview that used to stand here was a placeholder.
250
+ */
251
+ items: [
253
252
  // The way into the Admin, as the Builder has one; shown to whoever the Admin lets in.
254
253
  {
255
254
  itemKey: "@phis/ui/modules/accounting/nav/admin",
@@ -257,8 +256,9 @@ export const PHI_ACCOUNTING_RUNTIME_AREA_DEFINITIONS = [
257
256
  icon: "antd:cluster",
258
257
  standing: "last",
259
258
  target: { kind: "area", area: "admin" },
260
- }],
261
- exportedItemKeys: ["@phis/ui/modules/accounting/nav/home"],
259
+ },
260
+ ],
261
+ exportedItemKeys: [],
262
262
  anchors: sidebarAnchors(),
263
263
  }, accountNavigationSurface(PHI_ACCOUNTING_ACCOUNT_NAV_ITEM_KEY, "accounting:account")],
264
264
  },
@@ -9,13 +9,8 @@ import { dispatchPhiSignalCapability, usePhiSignalEmitter, } from "../../../../c
9
9
  import { PHI_ASSET_CONTROLLER_STORE_KEY, PHI_ASSET_SIGNAL_CHANNELS, } from "../../../../components/media/asset-controller-signals";
10
10
  import { normalizeMediaFocalRect } from "../../../../components/media/focal-rect";
11
11
  import { buildPhiMediaFolderNamesById, resolvePhiMediaFolderIdFromValue, combinePhiMediaFlagValues, } from "../../../../components/media/media-folder-options";
12
+ import { splitPhiMediaFolderNamePath } from "../../../../components/media/media-folder-name-path";
12
13
  const ASSET_FORM_FLAG_VALUES = Object.values(PhiMediaAssetFlags);
13
- function splitPhiMediaFolderNamePath(value) {
14
- return (value ?? "")
15
- .split("/")
16
- .map((segment) => segment.trim())
17
- .filter(Boolean);
18
- }
19
14
  function buildPhiMediaFolderNamePath(folders, folderId) {
20
15
  const names = buildPhiMediaFolderNamesById(folders, folderId);
21
16
  return names.length > 0 ? `/${names.join("/")}` : "";
@@ -146,6 +146,14 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
146
146
  mode?: undefined;
147
147
  valueType?: undefined;
148
148
  options?: undefined;
149
+ } | {
150
+ key: string;
151
+ type: "string";
152
+ label: string;
153
+ description: string;
154
+ mode?: undefined;
155
+ valueType?: undefined;
156
+ options?: undefined;
149
157
  })[];
150
158
  })[];
151
159
  handlers: ({
@@ -68,5 +68,13 @@ export declare const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR: {
68
68
  mode?: undefined;
69
69
  valueType?: undefined;
70
70
  options?: undefined;
71
+ } | {
72
+ key: string;
73
+ type: "string";
74
+ label: string;
75
+ description: string;
76
+ mode?: undefined;
77
+ valueType?: undefined;
78
+ options?: undefined;
71
79
  })[];
72
80
  };
@@ -61,5 +61,11 @@ export const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR = {
61
61
  label: "Public only",
62
62
  description: "Offer only Assets that are delivered publicly. The picker greys out the others; the Server that takes the value decides.",
63
63
  },
64
+ {
65
+ key: "folderPath",
66
+ type: "string",
67
+ label: "Folder path",
68
+ description: "The Site Folder the picker opens on and uploads into, by its path (\"Shop Images / Products\"); missing Folders are created on the first upload. {key} puts in a value of the Form; a name whose value is empty is left out. Empty: the root.",
69
+ },
64
70
  ],
65
71
  };
@@ -2,15 +2,38 @@ import type { PhiMediaAssetTile, PhiMediaKindValue } from "../../../types/media"
2
2
  export type PhiMediaAssetFieldConfig = {
3
3
  /** Which kind of Asset the picker lists. */
4
4
  mediaType: PhiMediaKindValue;
5
- /** Whether Assets that are not delivered publicly are greyed out in the picker. */
5
+ /**
6
+ * Whether Assets that are not delivered publicly are greyed out in the picker -- and an uploaded one
7
+ * that is not is left unchosen. Core delivers what goes into the Site Space publicly by default.
8
+ */
6
9
  publicOnly: boolean;
10
+ /**
11
+ * The Folder of the Site Space the picker opens on, by its path of names from the root ("Shop Images /
12
+ * Products"): it opens on the deepest of them that is there, and an upload from there creates the
13
+ * missing ones and goes into the whole path. Empty: the Folder the picker last showed, at first the
14
+ * root. A path and not an id, so a Module's Form states it for every Site.
15
+ *
16
+ * A name may hold placeholders, `{key}`, read from the Form's values when the picker opens
17
+ * (`resolvePhiMediaAssetFieldFolderPath`): "Shop Images / {category} / {product}". These are the names
18
+ * as written, placeholders unresolved.
19
+ */
20
+ folderPath: readonly string[];
7
21
  };
8
22
  /**
9
- * The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list, or a
10
- * `publicOnly` that is not a boolean, is a `PhiConfigError` naming the field, never a default put in its
11
- * place -- a typo in `mediaType` would otherwise quietly offer another kind of file.
23
+ * The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list, a
24
+ * `publicOnly` that is not a boolean, or a `folderPath` that is not a text or holds a brace that opens no
25
+ * placeholder (`{}`, `{a`, `a}`, `{a{b}}`) is a `PhiConfigError` naming the field, never a default put in
26
+ * its place -- a typo in `mediaType` would otherwise quietly offer another kind of file, and a broken
27
+ * placeholder would become a Folder named after it.
12
28
  */
13
29
  export declare function readPhiMediaAssetFieldConfig(config: Readonly<Record<string, unknown>> | undefined): PhiMediaAssetFieldConfig;
30
+ /**
31
+ * The Folder path a `folderPath` names for the Form's values as they are now: each `{key}` the value
32
+ * under `key` (the Form's current values, those loaded from its record included). A name whose
33
+ * placeholder has no value is left out whole -- "Shop Images / {category} / {product}" without a
34
+ * category is "Shop Images / <product>" -- and a name that comes out empty is left out too.
35
+ */
36
+ export declare function resolvePhiMediaAssetFieldFolderPath(folderPath: readonly string[], values: Readonly<Record<string, unknown>>): string[];
14
37
  /**
15
38
  * The Asset id a Form value holds, or `null`. A value that is not a positive whole number is not an id,
16
39
  * and showing it as one would put a request for Asset `NaN` on the wire.
@@ -18,3 +41,10 @@ export declare function readPhiMediaAssetFieldConfig(config: Readonly<Record<str
18
41
  export declare function readPhiMediaAssetFieldValue(value: unknown): number | null;
19
42
  /** Whether the picker lets one Asset be chosen: always, unless the field offers public Assets only. */
20
43
  export declare function isPhiMediaAssetFieldSelectable(config: PhiMediaAssetFieldConfig, asset: Pick<PhiMediaAssetTile, "deliveryPolicy" | "lifecycleStatus">): boolean;
44
+ /**
45
+ * Whether an Asset uploaded in the field's picker is one it lets be chosen, and if not, why: of the kind
46
+ * the picker lists, and public where the field offers public Assets only. The same question a pick
47
+ * answers, asked of what the upload made -- Core does not know the field's kind, and a file the browser
48
+ * could not name reaches it unrefused.
49
+ */
50
+ export declare function readPhiMediaAssetFieldUploadRefusal(config: PhiMediaAssetFieldConfig, asset: Pick<PhiMediaAssetTile, "kind" | "deliveryPolicy" | "lifecycleStatus">): "kind" | "notPublic" | null;
@@ -1,5 +1,7 @@
1
1
  import { PhiMediaKind, isPhiMediaAssetPublic } from "../../../constants/media";
2
2
  import { createPhiConfigReader } from "../../../components/widgets/config/strict-config-reader";
3
+ import { splitPhiMediaFolderNamePath } from "../../../components/media/media-folder-name-path";
4
+ import { readPhiDotPath } from "../../../helpers/dot-path";
3
5
  const MEDIA_ASSET_FIELD_KINDS = [
4
6
  PhiMediaKind.Image,
5
7
  PhiMediaKind.Video,
@@ -9,17 +11,51 @@ const MEDIA_ASSET_FIELD_KINDS = [
9
11
  PhiMediaKind.Font,
10
12
  ];
11
13
  /**
12
- * The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list, or a
13
- * `publicOnly` that is not a boolean, is a `PhiConfigError` naming the field, never a default put in its
14
- * place -- a typo in `mediaType` would otherwise quietly offer another kind of file.
14
+ * The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list, a
15
+ * `publicOnly` that is not a boolean, or a `folderPath` that is not a text or holds a brace that opens no
16
+ * placeholder (`{}`, `{a`, `a}`, `{a{b}}`) is a `PhiConfigError` naming the field, never a default put in
17
+ * its place -- a typo in `mediaType` would otherwise quietly offer another kind of file, and a broken
18
+ * placeholder would become a Folder named after it.
15
19
  */
16
20
  export function readPhiMediaAssetFieldConfig(config) {
17
21
  const reader = createPhiConfigReader(config ?? {}, "config");
18
22
  return {
19
23
  mediaType: reader.oneOf("mediaType", MEDIA_ASSET_FIELD_KINDS) ?? PhiMediaKind.Image,
20
24
  publicOnly: reader.boolean("publicOnly") ?? false,
25
+ folderPath: splitPhiMediaFolderNamePath(reader.value("folderPath", "a Folder path whose placeholders read {key}", (value) => typeof value === "string" && isPhiMediaAssetFolderPathTemplate(value) ? value : undefined)),
21
26
  };
22
27
  }
28
+ /* `{key}`: a Form value's key, a dotted path into it for a value that is a record. */
29
+ const PHI_MEDIA_ASSET_FOLDER_PATH_PLACEHOLDER = /\{([A-Za-z0-9_.-]+)\}/gu;
30
+ function isPhiMediaAssetFolderPathTemplate(value) {
31
+ return !/[{}]/u.test(value.replace(PHI_MEDIA_ASSET_FOLDER_PATH_PLACEHOLDER, ""));
32
+ }
33
+ /*
34
+ * A Form value as a Folder name: a text or a number, trimmed, and a `/` in it a `-`, so a value can name
35
+ * a Folder but never add a level of them. Anything else -- empty, absent, a list, a record -- is no name.
36
+ */
37
+ function readPhiMediaAssetFolderPathValue(value) {
38
+ const text = typeof value === "string" ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : "";
39
+ return text.replace(/\//gu, "-").replace(/\s+/gu, " ").trim();
40
+ }
41
+ /**
42
+ * The Folder path a `folderPath` names for the Form's values as they are now: each `{key}` the value
43
+ * under `key` (the Form's current values, those loaded from its record included). A name whose
44
+ * placeholder has no value is left out whole -- "Shop Images / {category} / {product}" without a
45
+ * category is "Shop Images / <product>" -- and a name that comes out empty is left out too.
46
+ */
47
+ export function resolvePhiMediaAssetFieldFolderPath(folderPath, values) {
48
+ return folderPath.flatMap((segment) => {
49
+ let missing = false;
50
+ const resolved = segment.replace(PHI_MEDIA_ASSET_FOLDER_PATH_PLACEHOLDER, (_placeholder, key) => {
51
+ const value = readPhiMediaAssetFolderPathValue(readPhiDotPath(values, key));
52
+ if (!value)
53
+ missing = true;
54
+ return value;
55
+ }).replace(/\s+/gu, " ").trim();
56
+ return missing || !resolved ? [] : [resolved];
57
+ });
58
+ }
23
59
  /**
24
60
  * The Asset id a Form value holds, or `null`. A value that is not a positive whole number is not an id,
25
61
  * and showing it as one would put a request for Asset `NaN` on the wire.
@@ -31,3 +67,14 @@ export function readPhiMediaAssetFieldValue(value) {
31
67
  export function isPhiMediaAssetFieldSelectable(config, asset) {
32
68
  return !config.publicOnly || isPhiMediaAssetPublic(asset.deliveryPolicy, asset.lifecycleStatus);
33
69
  }
70
+ /**
71
+ * Whether an Asset uploaded in the field's picker is one it lets be chosen, and if not, why: of the kind
72
+ * the picker lists, and public where the field offers public Assets only. The same question a pick
73
+ * answers, asked of what the upload made -- Core does not know the field's kind, and a file the browser
74
+ * could not name reaches it unrefused.
75
+ */
76
+ export function readPhiMediaAssetFieldUploadRefusal(config, asset) {
77
+ if (asset.kind !== config.mediaType)
78
+ return "kind";
79
+ return isPhiMediaAssetFieldSelectable(config, asset) ? null : "notPublic";
80
+ }
@@ -8,6 +8,19 @@ import type { PhiFormFieldProviderProps } from "../../../components/forms/form-p
8
8
  * value is the Asset id as a number, `null` for none, and the field keeps no copy of it: what it keeps is
9
9
  * the picker's open state.
10
10
  *
11
+ * Inside the picker a file from the reader's machine can go up too, into the Folder the picker shows, by
12
+ * the upload every surface sends with (`usePhiMediaUpload`, Core's upload session); what it made is
13
+ * chosen as a picked tile would be. It goes into the Site Space, like everything the field offers, and
14
+ * Core delivers what goes there publicly. What comes back is asked what a pick is asked: an Asset of
15
+ * another kind (a file the browser could not name reaches Core unrefused) or, for a `publicOnly` field,
16
+ * one that is not public is left in the list unchosen, and the field says why. While the file is on its
17
+ * way the Form's submit is held, as the upload field holds it, and closing the picker stops it.
18
+ * `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
19
+ * Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
20
+ * who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
21
+ * path that is there. An upload from there goes into the whole path, the missing Folders created the way
22
+ * `area-upload` creates them (`resolvePhiMediaUploadFolderPathId`).
23
+ *
11
24
  * Only the Site Space is offered, in every Area (`siteSpaceOnly`): a Form stores a reference everybody
12
25
  * who reads the stored value will follow, and a personal or a group Space cannot honestly stand behind
13
26
  * that. `config.publicOnly` greys out the Assets that are not delivered publicly, from the delivery