@phis/ui 0.7.5 → 0.7.8

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 (158) hide show
  1. package/components/controls/phi-form-control.d.ts +3 -1
  2. package/components/controls/phi-form-control.js +15 -4
  3. package/components/forms/auth-admin-settings-labels.d.ts +1 -1
  4. package/components/forms/auth-admin-settings-labels.js +2 -2
  5. package/components/forms/extended-form-field-controls.d.ts +1 -1
  6. package/components/forms/extended-form-field-controls.js +23 -7
  7. package/components/forms/form-descriptor-contract.d.ts +1 -1
  8. package/components/forms/form-descriptor-contract.js +1 -1
  9. package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
  10. package/components/forms/form-descriptor-runtime-client.js +33 -11
  11. package/components/forms/form-media-limits.d.ts +12 -0
  12. package/components/forms/form-media-limits.js +14 -0
  13. package/components/forms/form-provider-contract.d.ts +5 -0
  14. package/components/forms/form-provider-contract.js +9 -2
  15. package/components/forms/form-provider-registry.d.ts +14 -0
  16. package/components/forms/form-record-title.d.ts +14 -0
  17. package/components/forms/form-record-title.js +38 -0
  18. package/components/forms/form-widget-config.d.ts +3 -0
  19. package/components/forms/form-widget-config.js +2 -0
  20. package/components/forms/money-field-currency-key.d.ts +6 -0
  21. package/components/forms/money-field-currency-key.js +14 -0
  22. package/components/forms/money-field.d.ts +26 -3
  23. package/components/forms/money-field.js +54 -4
  24. package/components/forms/phi-form-widget.d.ts +1 -1
  25. package/components/forms/phi-form-widget.js +4 -0
  26. package/components/overlays/phi-overlay-container-client.js +8 -8
  27. package/components/overlays/phi-overlay-title.d.ts +7 -0
  28. package/components/overlays/phi-overlay-title.js +21 -0
  29. package/components/regions/presets/navigation-redirect.d.ts +4 -1
  30. package/components/regions/presets/navigation-redirect.js +6 -3
  31. package/components/tables/client/phi-table-binding.d.ts +3 -1
  32. package/components/tables/client/phi-table-binding.js +90 -49
  33. package/components/tables/client/phi-table-filter-options.d.ts +27 -0
  34. package/components/tables/client/phi-table-filter-options.js +35 -0
  35. package/components/widgets/accessible-areas.d.ts +1 -1
  36. package/components/widgets/accessible-areas.js +1 -1
  37. package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
  38. package/components/widgets/client/shared/phi-rendered-value.js +54 -4
  39. package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
  40. package/components/widgets/client/shared/phi-table-provider.js +22 -0
  41. package/components/widgets/label-sets/admin-users.d.ts +15 -0
  42. package/components/widgets/label-sets/admin-users.js +31 -0
  43. package/constants/core-data-provider-keys.d.ts +7 -0
  44. package/constants/core-data-provider-keys.js +7 -0
  45. package/constants/phi-base-role-metadata.d.ts +2 -2
  46. package/constants/phi-base-role-metadata.js +1 -1
  47. package/constants/runtime-module-ownership.js +3 -0
  48. package/forms.d.ts +1 -1
  49. package/forms.js +1 -1
  50. package/gateway/capability-media-limits.d.ts +10 -0
  51. package/gateway/capability-media-limits.js +40 -0
  52. package/gateway/server-capabilities.js +4 -0
  53. package/helpers/money-amount.d.ts +7 -0
  54. package/helpers/money-amount.js +15 -0
  55. package/helpers/preset-tree-contract-check.d.ts +3 -2
  56. package/helpers/preset-tree-contract-check.js +60 -0
  57. package/helpers/record-title.d.ts +7 -0
  58. package/helpers/record-title.js +25 -0
  59. package/helpers/record-widget.d.ts +15 -0
  60. package/helpers/record-widget.js +57 -0
  61. package/package.json +2 -2
  62. package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
  63. package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
  64. package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
  65. package/plugins/runtime-modules/accounting/data-providers.js +127 -0
  66. package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
  67. package/plugins/runtime-modules/accounting/definition.js +5 -3
  68. package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
  69. package/plugins/runtime-modules/accounting/ids.js +27 -0
  70. package/plugins/runtime-modules/accounting/module.d.ts +52 -0
  71. package/plugins/runtime-modules/accounting/presets.js +23 -4
  72. package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
  73. package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
  74. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
  75. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
  76. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
  77. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
  78. package/plugins/runtime-modules/app/presets.js +3 -6
  79. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +3 -6
  80. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +4 -7
  81. package/plugins/runtime-modules/area-definitions.js +2 -2
  82. package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
  83. package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
  84. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
  85. package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
  86. package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
  87. package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
  88. package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
  89. package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
  90. package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
  91. package/plugins/runtime-modules/builder/controller/client.d.ts +5 -5
  92. package/plugins/runtime-modules/builder/controller/client.js +2 -1
  93. package/plugins/runtime-modules/builder/controller/definition.d.ts +4 -4
  94. package/plugins/runtime-modules/builder/controller/definition.js +7 -0
  95. package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +3 -1
  96. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +2 -1
  97. package/plugins/runtime-modules/builder/controller/draft-status-controller.js +44 -17
  98. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +4 -4
  99. package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +3 -1
  100. package/plugins/runtime-modules/builder/controller/workspace-controller.js +8 -10
  101. package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +10 -0
  102. package/plugins/runtime-modules/builder/developer-workspace-store.js +35 -1
  103. package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +6 -0
  104. package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -6
  105. package/plugins/runtime-modules/builder/persistence.d.ts +4 -1
  106. package/plugins/runtime-modules/builder/persistence.js +10 -3
  107. package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
  108. package/plugins/runtime-modules/core/cards.js +2 -2
  109. package/plugins/runtime-modules/core/client-data-providers.js +5 -0
  110. package/plugins/runtime-modules/core/data-providers.js +14 -0
  111. package/plugins/runtime-modules/core/definition.d.ts +5 -0
  112. package/plugins/runtime-modules/core/form-providers.d.ts +5 -0
  113. package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
  114. package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
  115. package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
  116. package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
  117. package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
  118. package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
  119. package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
  120. package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
  121. package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
  122. package/plugins/runtime-modules/core/widgets/spacer/client.js +3 -3
  123. package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
  124. package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
  125. package/plugins/runtime-modules/groups/data-providers.js +1 -1
  126. package/plugins/runtime-modules/groups/definition.js +1 -1
  127. package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
  128. package/plugins/runtime-modules/groups/page-visibility.js +1 -1
  129. package/plugins/runtime-modules/groups/presets.js +1 -1
  130. package/plugins/runtime-modules/groups/services/options.js +1 -1
  131. package/plugins/runtime-modules/groups/services/table.js +1 -1
  132. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
  133. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +46 -39
  134. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
  135. package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
  136. package/plugins/runtime-modules/revisions/controller/client.js +48 -46
  137. package/plugins/runtime-modules/revisions/services/table.js +3 -1
  138. package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
  139. package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
  140. package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
  141. package/plugins/runtime-modules/user-management/controller/client.js +1 -1
  142. package/plugins/runtime-modules/user-management/data-providers.js +1 -0
  143. package/plugins/runtime-modules/user-management/forms.js +22 -0
  144. package/plugins/runtime-modules/user-management/presets.js +2 -2
  145. package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
  146. package/plugins/runtime-modules/user-management/services/options.js +14 -6
  147. package/plugins/runtime-modules/user-management/services/table.js +12 -3
  148. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
  149. package/styles/builder-scaffold.css +7 -1
  150. package/styles/layout-authoring-scaffold.css +27 -0
  151. package/types/access.d.ts +1 -1
  152. package/types/access.js +7 -7
  153. package/types/core-widget-placements.d.ts +7 -0
  154. package/types/form-descriptor.d.ts +1 -1
  155. package/types/record-widget.d.ts +35 -0
  156. package/types/server-capabilities.d.ts +1 -1
  157. package/types/table-widget.d.ts +20 -0
  158. package/types/table-widget.js +44 -0
@@ -0,0 +1,435 @@
1
+ import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
2
+ import { PhiCmsFlags, PhiCmsPageType } from "../../../../constants/phi-cms";
3
+ import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
4
+ import { createPhiSignalAddress, PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../types/signals";
5
+ import { buildPhiBasePageContentScaffold, PHI_BASE_PAGE_LAYOUT_NODE_ID, } from "../../../../components/regions/presets/phi-base-page-layout";
6
+ import { buildPhiWidgetLabelTranslatorOptions } from "../../../../components/widgets/label-sets/runtime-options";
7
+ import { PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY, PHI_ACCOUNTING_PRODUCTS_PAGE_LAYOUT_IDS, PHI_ACCOUNTING_PRODUCTS_PAGE_OVERLAY_IDS, PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS, PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY, } from "../ids";
8
+ import { getPhiAccountingProductsPageLabels } from "./accounting-products-label-set";
9
+ const SYNTHETIC_ACCOUNTING_PRODUCTS_REGION_IDS = { regionContent: -571 };
10
+ /**
11
+ * The row action that opens the terms side by side, and the Provider action the dialog's Release runs: the
12
+ * dialog and its record answer to the row's announcement, the record runs the action of the same key.
13
+ */
14
+ const RELEASE_ACTION_KEY = "release";
15
+ const STATE_COLORS = {
16
+ draft: "default",
17
+ active: "success",
18
+ withdrawn: "warning",
19
+ locked: "error",
20
+ };
21
+ /**
22
+ * The Site's product directory (phis-server SERVER_ADDONS.md, `products:v1`).
23
+ *
24
+ * Every product of every supplier Add-on, in every state, for whoever the Accounting Area lets in --
25
+ * Admin, Maintainer and Accountant, the holders of Core's `accounting` access, which is also what Core
26
+ * asks of each act. The operator releases a publisher's terms and locks or unlocks; title, summary and
27
+ * picture stay the supplier's and are not edited here.
28
+ *
29
+ * The picture is a small column of its own and the icon stands ahead of the title, both the server's `icon`
30
+ * variant (`imageListPath`, `iconListPath`: 64 x 64, fitted whole, with their cache revisions).
31
+ * Releasing opens a dialog named after the product, whose record sets the terms in force beside the ones
32
+ * waiting; its Release runs the Provider's release on that record, and the dialog closes and the Table
33
+ * reads again. The dialog is the confirmation, so the release asks nothing more; lock and unlock stay the
34
+ * row's own acts with a question naming the product.
35
+ */
36
+ export async function buildPhiDefaultAccountingProductsPageTree({ page, runtime, }) {
37
+ const labels = await getPhiAccountingProductsPageLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
38
+ const scaffold = buildPhiBasePageContentScaffold({
39
+ page,
40
+ regionId: SYNTHETIC_ACCOUNTING_PRODUCTS_REGION_IDS.regionContent,
41
+ });
42
+ const nodes = createPhiCmsPresetNodes(page);
43
+ const termsOverlayAddress = createPhiSignalAddress("cms", PHI_ACCOUNTING_PRODUCTS_PAGE_OVERLAY_IDS.overlayTerms);
44
+ const termsRecordAddress = createPhiSignalAddress("cms", PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS.widgetTerms);
45
+ const tableAddress = createPhiSignalAddress("cms", PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS.widgetTable);
46
+ const columns = [
47
+ {
48
+ key: "picture",
49
+ fieldKey: "imageListPath",
50
+ title: labels.columns.picture,
51
+ renderer: "image",
52
+ sizing: { mode: "content" },
53
+ },
54
+ // The icon stands for the product, so it stands ahead of its name rather than in a column of its own.
55
+ {
56
+ key: "title",
57
+ fieldKey: "title",
58
+ imageFieldKey: "iconListPath",
59
+ title: labels.columns.title,
60
+ sizing: { mode: "fill", minWidth: 200 },
61
+ },
62
+ { key: "id", fieldKey: "id", title: labels.columns.id, renderer: "code", sizing: { mode: "content" } },
63
+ { key: "supplier", fieldKey: "supplier", title: labels.columns.supplier, renderer: "code", sizing: { mode: "content" } },
64
+ { key: "type", fieldKey: "type", title: labels.columns.kind, renderer: "badge", sizing: { mode: "content" } },
65
+ {
66
+ key: "state",
67
+ fieldKey: "state",
68
+ title: labels.columns.state,
69
+ renderer: "badge",
70
+ valueMap: labels.states,
71
+ tagColorMap: STATE_COLORS,
72
+ sizing: { mode: "content" },
73
+ },
74
+ {
75
+ key: "sale",
76
+ fieldKey: "sale",
77
+ title: labels.columns.sale,
78
+ renderer: "badge",
79
+ valueMap: labels.sales,
80
+ sizing: { mode: "content" },
81
+ },
82
+ { key: "free", fieldKey: "free", title: labels.columns.free, renderer: "checkbox", sizing: { mode: "content" } },
83
+ {
84
+ key: "accountRequired",
85
+ fieldKey: "accountRequired",
86
+ title: labels.columns.account,
87
+ renderer: "checkbox",
88
+ sizing: { mode: "content" },
89
+ },
90
+ { key: "partCount", fieldKey: "partCount", title: labels.columns.parts, align: "right", sizing: { mode: "content" } },
91
+ {
92
+ key: "awaitingRelease",
93
+ fieldKey: "awaitingRelease",
94
+ title: labels.columns.waiting,
95
+ renderer: "checkbox",
96
+ sizing: { mode: "content" },
97
+ },
98
+ ];
99
+ // In force on the left, waiting on the right: the record's two columns are the comparison.
100
+ const termField = (key, text, presentation) => [
101
+ { key: `inForce${key}`, fieldKey: `inForce${key}`, label: text.inForce, ...presentation },
102
+ { key: `pending${key}`, fieldKey: `pending${key}`, label: text.waiting, ...presentation },
103
+ ];
104
+ const termsDialog = nodes.dialog({
105
+ id: PHI_ACCOUNTING_PRODUCTS_PAGE_OVERLAY_IDS.overlayTerms,
106
+ bodyLayoutNodeId: PHI_ACCOUNTING_PRODUCTS_PAGE_LAYOUT_IDS.layoutTerms,
107
+ sortOrder: 0,
108
+ label: "accounting product terms modal",
109
+ body: { config: { anchor: { horizontal: "left", vertical: "top" } } },
110
+ config: {
111
+ // Until the record names the product ("Terms: @acme/books:pro").
112
+ title: labels.terms.title,
113
+ mountPolicy: "lazy-keep",
114
+ // Which row action this dialog is for; left unsaid, a Table action opens nothing.
115
+ openActionKey: RELEASE_ACTION_KEY,
116
+ signalRoutes: {
117
+ emits: [{
118
+ routeKey: "accounting-products-terms-open-change",
119
+ capabilityId: "openChange",
120
+ scope: "page",
121
+ channel: "state",
122
+ action: "change",
123
+ valueType: "boolean",
124
+ receiver: termsRecordAddress,
125
+ }],
126
+ listens: [{
127
+ routeKey: "accounting-products-terms-open",
128
+ capabilityId: "open",
129
+ scope: "page",
130
+ channel: "action",
131
+ action: "activate",
132
+ valueType: "json",
133
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
134
+ receiver: termsOverlayAddress,
135
+ }, {
136
+ routeKey: "accounting-products-terms-title",
137
+ capabilityId: "title",
138
+ scope: "page",
139
+ channel: "title",
140
+ action: "change",
141
+ valueType: "string",
142
+ receiver: termsOverlayAddress,
143
+ }, {
144
+ routeKey: "accounting-products-terms-close",
145
+ capabilityId: "close",
146
+ scope: "page",
147
+ channel: "dialog",
148
+ action: "close",
149
+ valueType: "none",
150
+ receiver: termsOverlayAddress,
151
+ }],
152
+ },
153
+ },
154
+ commands: {
155
+ footerLayoutNodeId: PHI_ACCOUNTING_PRODUCTS_PAGE_LAYOUT_IDS.layoutTermsFooter,
156
+ widgetId: PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS.widgetTermsCommands,
157
+ label: "accounting product terms commands",
158
+ // The Label Set's words, already in the reader's language.
159
+ flags: PhiCmsFlags.NoTranslate,
160
+ config: {
161
+ key: "accounting-products-terms-commands",
162
+ buttons: [
163
+ { key: "cancel", emits: [{ capabilityId: "close", value: null }], label: labels.actions.cancel, icon: "close" },
164
+ {
165
+ key: "release",
166
+ // The record runs the action of this key on the product it shows.
167
+ emits: [{ capabilityId: "release", value: RELEASE_ACTION_KEY }],
168
+ label: labels.terms.release,
169
+ variant: "primary",
170
+ icon: "antd:safety-certificate",
171
+ },
172
+ ],
173
+ signalRoutes: {
174
+ emits: [{
175
+ routeKey: "accounting-products-terms-cancel",
176
+ capabilityId: "close",
177
+ scope: "page",
178
+ channel: "dialog",
179
+ action: "close",
180
+ valueType: "none",
181
+ receiver: termsOverlayAddress,
182
+ }, {
183
+ routeKey: "accounting-products-terms-release",
184
+ capabilityId: "release",
185
+ scope: "page",
186
+ channel: "action",
187
+ action: "activate",
188
+ valueType: "string",
189
+ receiver: termsRecordAddress,
190
+ }],
191
+ },
192
+ },
193
+ },
194
+ });
195
+ return {
196
+ page: nodes.page({ pageType: PhiCmsPageType.Standard }),
197
+ pageMeta: {
198
+ title: { msgId: 0, source: "Products", value: labels.pageTitle },
199
+ description: {
200
+ msgId: 0,
201
+ source: "Every product the Site's Add-ons supply: release their terms, lock and unlock them.",
202
+ value: labels.pageDescription,
203
+ },
204
+ },
205
+ overlays: [termsDialog.overlay],
206
+ regions: [scaffold.region],
207
+ layoutNodes: [scaffold.layoutNode, ...termsDialog.layouts],
208
+ contentWidgets: [
209
+ nodes.widget({
210
+ id: PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS.widgetTable,
211
+ parentLayoutNodeId: PHI_BASE_PAGE_LAYOUT_NODE_ID,
212
+ typeKey: "table",
213
+ slotIndex: PHI_CMS_DEFAULT_SLOT_INDEX,
214
+ sortOrder: 0,
215
+ label: labels.widgetLabel,
216
+ config: {
217
+ source: {
218
+ providerKey: PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY,
219
+ resourceKey: PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY,
220
+ },
221
+ presentation: {
222
+ layout: { mode: "auto", overflowX: "auto" },
223
+ columns,
224
+ footer: {
225
+ template: labels.footer,
226
+ values: [{ key: "products", value: { source: "core", fieldKey: "totalRows" } }],
227
+ align: "start",
228
+ },
229
+ emptyState: { title: labels.empty.title, description: labels.empty.text },
230
+ controlSize: "small",
231
+ },
232
+ features: {
233
+ search: { enabled: true, placeholder: labels.search, debounceMs: 250 },
234
+ filters: [
235
+ {
236
+ key: "supplier",
237
+ type: "text",
238
+ label: labels.filters.supplier,
239
+ placeholder: labels.filters.supplierPlaceholder,
240
+ },
241
+ {
242
+ key: "state",
243
+ type: "select",
244
+ multiple: true,
245
+ label: labels.filters.state,
246
+ options: ["draft", "active", "withdrawn", "locked"]
247
+ .map((value) => ({ value, label: labels.states[value] })),
248
+ },
249
+ {
250
+ key: "pendingTerms",
251
+ type: "boolean",
252
+ control: "switch",
253
+ label: labels.filters.waiting,
254
+ labelPlacement: "inline",
255
+ defaultValue: false,
256
+ },
257
+ ],
258
+ pagination: { enabled: true, pageSize: 25, pageSizes: [25, 50, 100] },
259
+ sorting: { mode: "none" },
260
+ tools: { mode: "self-contained", reload: true },
261
+ actions: {
262
+ rowLayout: "compact",
263
+ row: [
264
+ {
265
+ // Opens the terms dialog, whose Release runs the Provider's action of this key.
266
+ key: RELEASE_ACTION_KEY,
267
+ label: labels.actions.release,
268
+ icon: "antd:safety-certificate",
269
+ display: "icon",
270
+ execution: "signal",
271
+ disabledWhen: { source: "row", valuePath: "awaitingRelease", operator: "falsy" },
272
+ },
273
+ {
274
+ key: "lock",
275
+ label: labels.actions.lock,
276
+ icon: "antd:lock",
277
+ display: "icon",
278
+ mode: "danger",
279
+ execution: "provider",
280
+ disabledWhen: { source: "row", valuePath: "locked", operator: "truthy" },
281
+ confirm: {
282
+ title: labels.lock.title,
283
+ description: labels.lock.description,
284
+ okText: labels.actions.lock,
285
+ cancelText: labels.actions.cancel,
286
+ },
287
+ },
288
+ {
289
+ key: "unlock",
290
+ label: labels.actions.unlock,
291
+ icon: "antd:unlock",
292
+ display: "icon",
293
+ execution: "provider",
294
+ disabledWhen: { source: "row", valuePath: "locked", operator: "falsy" },
295
+ confirm: {
296
+ title: labels.unlock.title,
297
+ description: labels.unlock.description,
298
+ okText: labels.actions.unlock,
299
+ cancelText: labels.actions.cancel,
300
+ },
301
+ },
302
+ ],
303
+ },
304
+ },
305
+ signalRoutes: {
306
+ emits: [{
307
+ routeKey: "accounting-products-table-terms-record",
308
+ capabilityId: "actionActivate",
309
+ scope: "page",
310
+ channel: "action",
311
+ action: "activate",
312
+ valueType: "json",
313
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
314
+ receiver: termsRecordAddress,
315
+ }, {
316
+ routeKey: "accounting-products-table-terms-overlay",
317
+ capabilityId: "actionActivate",
318
+ scope: "page",
319
+ channel: "action",
320
+ action: "activate",
321
+ valueType: "json",
322
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
323
+ receiver: termsOverlayAddress,
324
+ }],
325
+ // Read again once the dialog released a product's terms.
326
+ listens: [{
327
+ routeKey: "accounting-products-table-reload",
328
+ capabilityId: "reload",
329
+ scope: "page",
330
+ channel: "reload",
331
+ action: "activate",
332
+ valueType: "none",
333
+ receiver: tableAddress,
334
+ }],
335
+ },
336
+ },
337
+ }),
338
+ ...termsDialog.widgets,
339
+ // What the release does, which the row's own question used to say.
340
+ nodes.widget({
341
+ id: PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS.widgetTermsNote,
342
+ parentLayoutNodeId: PHI_ACCOUNTING_PRODUCTS_PAGE_LAYOUT_IDS.layoutTerms,
343
+ typeKey: "simple-text",
344
+ slotIndex: 0,
345
+ label: "accounting product terms note",
346
+ flags: PhiCmsFlags.NoTranslate,
347
+ config: { text: labels.release.description, tone: "secondary" },
348
+ }),
349
+ nodes.widget({
350
+ id: PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS.widgetTerms,
351
+ parentLayoutNodeId: PHI_ACCOUNTING_PRODUCTS_PAGE_LAYOUT_IDS.layoutTerms,
352
+ typeKey: "record",
353
+ slotIndex: 1,
354
+ label: "accounting product terms record",
355
+ config: {
356
+ source: {
357
+ providerKey: PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY,
358
+ resourceKey: PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY,
359
+ },
360
+ openActionKey: RELEASE_ACTION_KEY,
361
+ // The dialog's Release: the Provider's release, on the product shown.
362
+ actions: [{ key: RELEASE_ACTION_KEY }],
363
+ titleFromRecord: { template: labels.terms.titleOf, field: "id" },
364
+ presentation: {
365
+ appearance: "grid",
366
+ columns: 2,
367
+ fields: [
368
+ { key: "title", fieldKey: "title", label: labels.terms.product, full: true },
369
+ { key: "id", fieldKey: "id", label: labels.columns.id, renderer: "code", full: true },
370
+ ...termField("Sale", labels.terms.sale, { renderer: "badge", valueMap: labels.sales }),
371
+ ...termField("ReferralUrl", labels.terms.referral, { renderer: "link" }),
372
+ ...termField("Free", labels.terms.free, { renderer: "checkbox" }),
373
+ ...termField("AccountRequired", labels.terms.account, { renderer: "checkbox" }),
374
+ ...termField("Parts", labels.terms.parts, { renderer: "tags" }),
375
+ ],
376
+ },
377
+ signalRoutes: {
378
+ emits: [{
379
+ routeKey: "accounting-products-terms-record-title",
380
+ capabilityId: "recordTitle",
381
+ scope: "page",
382
+ channel: "title",
383
+ action: "change",
384
+ valueType: "string",
385
+ receiver: termsOverlayAddress,
386
+ }, {
387
+ // Released: the dialog is done, and the row has left what the filters may show.
388
+ routeKey: "accounting-products-terms-released-close",
389
+ capabilityId: "actionSuccess",
390
+ scope: "page",
391
+ channel: "dialog",
392
+ action: "close",
393
+ valueType: "none",
394
+ receiver: termsOverlayAddress,
395
+ }, {
396
+ routeKey: "accounting-products-terms-released-reload",
397
+ capabilityId: "actionSuccess",
398
+ scope: "page",
399
+ channel: "reload",
400
+ action: "activate",
401
+ valueType: "none",
402
+ receiver: tableAddress,
403
+ }],
404
+ listens: [{
405
+ routeKey: "accounting-products-terms-record-open",
406
+ capabilityId: "recordOpen",
407
+ scope: "page",
408
+ channel: "action",
409
+ action: "activate",
410
+ valueType: "json",
411
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
412
+ receiver: termsRecordAddress,
413
+ }, {
414
+ routeKey: "accounting-products-terms-record-closed",
415
+ capabilityId: "close",
416
+ scope: "page",
417
+ channel: "state",
418
+ action: "change",
419
+ valueType: "boolean",
420
+ receiver: termsRecordAddress,
421
+ }, {
422
+ routeKey: "accounting-products-terms-record-release",
423
+ capabilityId: "actionActivate",
424
+ scope: "page",
425
+ channel: "action",
426
+ action: "activate",
427
+ valueType: "string",
428
+ receiver: termsRecordAddress,
429
+ }],
430
+ },
431
+ },
432
+ }),
433
+ ],
434
+ };
435
+ }
@@ -9,12 +9,9 @@ export const PHI_APP_RUNTIME_MODULE_AREA_SHELLS = [
9
9
  shellPresetVersion: 1,
10
10
  area: "app",
11
11
  /*
12
- * The Site shell with a left sider added, rather than a shell of its own.
13
- *
14
- * App's header and footer are Public's -- one Brand, one account trigger, one description of both.
15
- * What App has that Public does not is somewhere for the Modules a signed-in person works with,
16
- * and that is the whole of the overlay. Nothing is omitted from the base, so the two trees cannot
17
- * disagree about a Region: composition refuses a Region type stated twice.
12
+ * The App variant of the Site shell, with the App's left sider added. The Site shell owns the
13
+ * header and footer and the overlay owns the sidebar. Composition refuses a Region type stated
14
+ * twice.
18
15
  */
19
16
  loadTree: async ({ page, runtime }) => {
20
17
  const [{ buildPhiDefaultSiteAreaPresetTree }, { buildPhiDefaultAppAreaPresetTree }, { mergePhiCmsShellTrees },] = await Promise.all([
@@ -3,15 +3,12 @@ import type { PhiBlockRuntime } from "../../../../types";
3
3
  /**
4
4
  * The App's own left sider, laid over the Site shell rather than replacing it.
5
5
  *
6
- * App shares its header and its footer with Public -- the same Brand, the same account trigger -- and
7
- * the one thing it does not share is a place for the Modules a signed-in person works with. This adds
8
- * that place and nothing else, so the Site shell stays the single description of everything above and
9
- * below it.
6
+ * The Site shell builds the App's header and footer. This overlay gives the signed-in person's
7
+ * Modules a place in the App's own sidebar.
10
8
  *
11
9
  * The sider is where the Area's navigation belongs, and the reason is in SETTINGS.md section 3: a
12
10
  * shell Region outlives a move between Pages, while a Page-owned one is built again for each of them.
13
- * Navigation placed in the latter rebuilds itself under the hand that just used it. The search box
14
- * stands above it for the same reason (SEARCH.md): a member searches from wherever they are.
11
+ * Navigation placed in the latter rebuilds itself under the hand that just used it.
15
12
  */
16
13
  export declare function buildPhiDefaultAppAreaPresetTree({ page, runtime, }: {
17
14
  page: PhiCmsPageNode;
@@ -14,19 +14,16 @@ const SYNTHETIC_APP_WIDGET_IDS = createPhiPresetCmsInstanceIdMap({
14
14
  domain: "area",
15
15
  ownerModuleId: PHI_APP_RUNTIME_MODULE_ID,
16
16
  presetKey: "app-area-preset",
17
- }, ["widgetSiderLeftNav", "widgetSiderLeftSearch"]);
17
+ }, ["widgetSiderLeftNav"]);
18
18
  /**
19
19
  * The App's own left sider, laid over the Site shell rather than replacing it.
20
20
  *
21
- * App shares its header and its footer with Public -- the same Brand, the same account trigger -- and
22
- * the one thing it does not share is a place for the Modules a signed-in person works with. This adds
23
- * that place and nothing else, so the Site shell stays the single description of everything above and
24
- * below it.
21
+ * The Site shell builds the App's header and footer. This overlay gives the signed-in person's
22
+ * Modules a place in the App's own sidebar.
25
23
  *
26
24
  * The sider is where the Area's navigation belongs, and the reason is in SETTINGS.md section 3: a
27
25
  * shell Region outlives a move between Pages, while a Page-owned one is built again for each of them.
28
- * Navigation placed in the latter rebuilds itself under the hand that just used it. The search box
29
- * stands above it for the same reason (SEARCH.md): a member searches from wherever they are.
26
+ * Navigation placed in the latter rebuilds itself under the hand that just used it.
30
27
  */
31
28
  export async function buildPhiDefaultAppAreaPresetTree({ page, runtime, }) {
32
29
  const nodes = createPhiCmsPresetNodes(page);
@@ -2,7 +2,7 @@ import { PHI_SHARED_PACKAGE_NAME } from "../../constants/package";
2
2
  import { createPhiRuntimeModuleId } from "../../constants/module-identity";
3
3
  import { createPhiCoreRuntimeControllerAddress } from "../../components/runtime/core-runtime-controller-address";
4
4
  import { PHI_DEFAULT_PUB_AREA_PRESET_KEY } from "./preset-contracts/pub-area";
5
- import { PHI_VIEWER_ACCESS_ACCOUNTING, PHI_VIEWER_ACCESS_ANYONE, PHI_VIEWER_ACCESS_AUTHENTICATED, PHI_VIEWER_ACCESS_CONTENT_EDITING, PHI_VIEWER_ACCESS_DEVELOPER_TOOLS, PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING, PHI_VIEWER_ACCESS_SITE_ADMIN, } from "../../types/access";
5
+ import { PHI_VIEWER_ACCESS_ACCOUNTING, PHI_VIEWER_ACCESS_ANYONE, PHI_VIEWER_ACCESS_AUTHENTICATED, PHI_VIEWER_ACCESS_CONTENT_EDITING, PHI_VIEWER_ACCESS_SITE_MAINTENANCE, PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING, PHI_VIEWER_ACCESS_SITE_ADMIN, } from "../../types/access";
6
6
  /*
7
7
  * The Modules named here are named by id, as data. Importing their `ids.ts` bound every file that
8
8
  * reads this one -- the Foundation among them -- to the Module folders at compile time (MODULES.md,
@@ -269,7 +269,7 @@ export const PHI_ADMIN_RUNTIME_AREA_DEFINITIONS = [
269
269
  baseModuleId: PHI_ADMIN_RUNTIME_MODULE_ID,
270
270
  shellPresetKey: "admin-area-preset",
271
271
  shellProviders: "base",
272
- accessPolicy: PHI_VIEWER_ACCESS_DEVELOPER_TOOLS,
272
+ accessPolicy: PHI_VIEWER_ACCESS_SITE_MAINTENANCE,
273
273
  navigationSurfaces: [
274
274
  {
275
275
  navKey: "admin:sidebar",
@@ -1,5 +1,7 @@
1
1
  import type { PhiMediaAssetTile, PhiMediaKindValue } from "../../../types/media";
2
2
  import { type PhiConfigReader } from "../../../components/widgets/config/strict-config-reader";
3
+ import type { PhiMediaUploadAcceptance } from "../../../components/media/phi-media-upload";
4
+ import type { PhiAddonMediaLimits } from "../../../types/server-capabilities";
3
5
  export type PhiMediaAssetFieldConfig = {
4
6
  /** Which kind of Asset the picker lists. */
5
7
  mediaType: PhiMediaKindValue;
@@ -48,3 +50,16 @@ export declare function isPhiMediaAssetFieldSelectable(config: PhiMediaAssetFiel
48
50
  * could not name reaches it unrefused.
49
51
  */
50
52
  export declare function readPhiMediaAssetFieldUploadRefusal(config: PhiMediaAssetFieldConfig, asset: Pick<PhiMediaAssetTile, "kind" | "deliveryPolicy" | "lifecycleStatus">): "kind" | "notPublic" | null;
53
+ /**
54
+ * Whether the Add-on behind the Form takes the field's kind at all (`PhiAddonMediaLimits.kinds`). A field
55
+ * whose kind it does not take refuses every file before it is sent, with the upload's own "type not
56
+ * allowed": the kind is the field's, so no file of another kind is what it was opened for either.
57
+ */
58
+ export declare function isPhiMediaFieldKindTaken(mediaType: PhiMediaKindValue, limits: PhiAddonMediaLimits | undefined): boolean;
59
+ /**
60
+ * What an upload in a Media field takes: files of the field's kind, one or several, and -- where the
61
+ * Add-on behind the Form states one -- no larger than its `maxFileBytes`, refused before it is sent with
62
+ * the upload's own "too large" (`readPhiMediaUploadRejection`). Shared by `media-asset` and
63
+ * `media-assets`, so the two fields cannot apply one limit two ways.
64
+ */
65
+ export declare function readPhiMediaFieldUploadAcceptance(mediaType: PhiMediaKindValue, multiple: boolean, limits: PhiAddonMediaLimits | undefined): PhiMediaUploadAcceptance;
@@ -56,3 +56,24 @@ export function readPhiMediaAssetFieldUploadRefusal(config, asset) {
56
56
  return "kind";
57
57
  return isPhiMediaAssetFieldSelectable(config, asset) ? null : "notPublic";
58
58
  }
59
+ /**
60
+ * Whether the Add-on behind the Form takes the field's kind at all (`PhiAddonMediaLimits.kinds`). A field
61
+ * whose kind it does not take refuses every file before it is sent, with the upload's own "type not
62
+ * allowed": the kind is the field's, so no file of another kind is what it was opened for either.
63
+ */
64
+ export function isPhiMediaFieldKindTaken(mediaType, limits) {
65
+ return limits?.kinds == null || limits.kinds.includes(mediaType);
66
+ }
67
+ /**
68
+ * What an upload in a Media field takes: files of the field's kind, one or several, and -- where the
69
+ * Add-on behind the Form states one -- no larger than its `maxFileBytes`, refused before it is sent with
70
+ * the upload's own "too large" (`readPhiMediaUploadRejection`). Shared by `media-asset` and
71
+ * `media-assets`, so the two fields cannot apply one limit two ways.
72
+ */
73
+ export function readPhiMediaFieldUploadAcceptance(mediaType, multiple, limits) {
74
+ return {
75
+ kinds: [mediaType],
76
+ multiple,
77
+ ...(limits?.maxFileBytes != null ? { maxBytes: limits.maxFileBytes } : {}),
78
+ };
79
+ }
@@ -16,6 +16,10 @@ import type { PhiFormFieldProviderProps } from "../../../components/forms/form-p
16
16
  * or, for a `publicOnly` field, one that is not public is left in the list unchosen, and the field says
17
17
  * why. While the file is on its way the Form's submit is held, as the upload field holds it, and closing
18
18
  * the picker stops it.
19
+ * The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) are applied before a file is
20
+ * sent: one larger than its `maxFileBytes` is refused as too large, and where its `kinds` leave out the
21
+ * field's kind every file is refused as of a type not allowed -- the upload's own refusals, in the
22
+ * picker's upload words.
19
23
  * `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
20
24
  * Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
21
25
  * who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
@@ -17,7 +17,7 @@ import { PHI_SEARCH_WIDGET_DEFAULT_LABELS } from "../../../components/widgets/la
17
17
  import { isPhiMediaAssetPublic } from "../../../constants/media";
18
18
  import { PHI_FORM_MEDIA_ASSET_LABEL_KEYS } from "./form-providers";
19
19
  import { readPhiMediaFieldPickerLabels } from "./media-field-picker-labels";
20
- import { isPhiMediaAssetFieldSelectable, readPhiMediaAssetFieldConfig, readPhiMediaAssetFieldUploadRefusal, readPhiMediaAssetFieldValue, } from "./media-asset-field";
20
+ import { isPhiMediaAssetFieldSelectable, isPhiMediaFieldKindTaken, readPhiMediaAssetFieldConfig, readPhiMediaAssetFieldUploadRefusal, readPhiMediaAssetFieldValue, readPhiMediaFieldUploadAcceptance, } from "./media-asset-field";
21
21
  const DEFAULT_LABELS = {
22
22
  choose: "Choose",
23
23
  change: "Change",
@@ -42,6 +42,10 @@ const PREVIEW_SIZE = 72;
42
42
  * or, for a `publicOnly` field, one that is not public is left in the list unchosen, and the field says
43
43
  * why. While the file is on its way the Form's submit is held, as the upload field holds it, and closing
44
44
  * the picker stops it.
45
+ * The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) are applied before a file is
46
+ * sent: one larger than its `maxFileBytes` is refused as too large, and where its `kinds` leave out the
47
+ * field's kind every file is refused as of a type not allowed -- the upload's own refusals, in the
48
+ * picker's upload words.
45
49
  * `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
46
50
  * Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
47
51
  * who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
@@ -58,7 +62,7 @@ const PREVIEW_SIZE = 72;
58
62
  * field reads (`usePhiAuthoringAssetDetails`), so the preview shows what is stored. Where that read is
59
63
  * refused, the field says so and still lets the value be changed or removed.
60
64
  */
61
- export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, }) => {
65
+ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, mediaLimits, }) => {
62
66
  const config = useMemo(() => readPhiMediaAssetFieldConfig(field.config), [field.config]);
63
67
  const assetId = readPhiMediaAssetFieldValue(value);
64
68
  const asset = usePhiAuthoringAssetDetails(assetId);
@@ -70,7 +74,8 @@ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readO
70
74
  // picker's upload words (`readPhiMediaFieldPickerLabels`).
71
75
  const pendingLabel = labels?.[PHI_FORM_UPLOAD_LABEL_KEYS.pending]?.trim() || PHI_MEDIA_UPLOAD_FIELD_DEFAULT_LABELS.pending;
72
76
  const [uploadNotice, setUploadNotice] = useState(null);
73
- const acceptance = useMemo(() => ({ kinds: [config.mediaType], multiple: false }), [config.mediaType]);
77
+ const acceptance = useMemo(() => readPhiMediaFieldUploadAcceptance(config.mediaType, false, mediaLimits), [config.mediaType, mediaLimits]);
78
+ const kindTaken = isPhiMediaFieldKindTaken(config.mediaType, mediaLimits);
74
79
  const [uploading, setUploading] = useState(false);
75
80
  useEffect(() => {
76
81
  if (!formContext || !uploading)
@@ -105,12 +110,12 @@ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readO
105
110
  multiple: false,
106
111
  allowDelete: false,
107
112
  ...(intoStartFolder ? { folderPath: openedFolderPath.join(" / ") } : {}),
108
- }, labels: pickerUploadLabels, acceptance: acceptance, showFinished: false, siteSpaceOnly: true, collectionContext: { folders: [], folderId, presentationFlags: null, query: {} }, onUploadingChange: setUploading, onAssetUploaded: (tile) => {
113
+ }, labels: pickerUploadLabels, acceptance: acceptance, ...(kindTaken ? {} : { refuseFile: () => pickerUploadLabels.refusals.errorTypeNotAllowed }), showFinished: false, siteSpaceOnly: true, collectionContext: { folders: [], folderId, presentationFlags: null, query: {} }, onUploadingChange: setUploading, onAssetUploaded: (tile) => {
109
114
  const refusal = readPhiMediaAssetFieldUploadRefusal(config, tile);
110
115
  setUploadNotice(refusal === "kind" ? pickerUploadLabels.refusals.errorTypeNotAllowed : refusal ? notPublic : null);
111
116
  onUploaded(refusal ? null : tile);
112
117
  } })),
113
- }), [acceptance, config, notPublic, openedFolderPath, pickerUploadLabels, uploadNotice]);
118
+ }), [acceptance, config, kindTaken, notPublic, openedFolderPath, pickerUploadLabels, uploadNotice]);
114
119
  const pickerLabels = useMemo(() => ({ ...mediaLabels, picker: { ...mediaLabels.picker, triggerLabel: assetId == null ? choose : change } }), [assetId, change, choose, mediaLabels]);
115
120
  const picker = usePhiMediaPickerBinding({
116
121
  config: {