@phis/ui 0.7.1 → 0.7.2

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 (46) 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/use-phi-color-control-presets.d.ts +2 -2
  4. package/components/controls/use-phi-color-control-presets.js +16 -2
  5. package/components/layouts/clients/phi-flex-layout-client.js +12 -2
  6. package/components/media/media-folder-name-path.d.ts +17 -0
  7. package/components/media/media-folder-name-path.js +36 -0
  8. package/components/media/media-upload-flow.d.ts +30 -0
  9. package/components/media/media-upload-flow.js +104 -4
  10. package/components/media/media-upload-refusals.js +5 -2
  11. package/components/media/phi-area-upload-widget.js +4 -0
  12. package/components/widgets/client/shared/phi-command-buttons.d.ts +12 -0
  13. package/components/widgets/client/shared/phi-command-buttons.js +23 -3
  14. package/components/widgets/config/command-buttons.js +3 -0
  15. package/components/widgets/label-sets/color-picker.js +2 -0
  16. package/components/widgets/label-types/color-picker.d.ts +1 -0
  17. package/components/widgets/label-types/color-picker.js +1 -0
  18. package/helpers/cms-content-binding.d.ts +7 -1
  19. package/helpers/cms-content-binding.js +10 -2
  20. package/helpers/cms-node-visibility.d.ts +25 -0
  21. package/helpers/cms-node-visibility.js +35 -1
  22. package/package.json +2 -2
  23. package/plugins/runtime-modules/accounting/definition.js +1 -1
  24. package/plugins/runtime-modules/accounting/presets.js +5 -12
  25. package/plugins/runtime-modules/area-definitions.d.ts +9 -39
  26. package/plugins/runtime-modules/area-definitions.js +8 -8
  27. package/plugins/runtime-modules/asset/controller/runtime.js +1 -6
  28. package/plugins/runtime-modules/asset/widgets/area-upload/config.js +7 -1
  29. package/plugins/runtime-modules/builder/data-providers.js +1 -0
  30. package/plugins/runtime-modules/builder/services/runtime-modules-table.d.ts +1 -0
  31. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +4 -0
  32. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -5
  33. package/plugins/runtime-modules/core/widgets/image/config.d.ts +1 -0
  34. package/plugins/runtime-modules/core/widgets/image/config.js +1 -0
  35. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -1
  36. package/plugins/runtime-modules/core/widgets/markdown/config.js +1 -0
  37. package/plugins/runtime-modules/core/widgets/markdown/plugin.js +0 -1
  38. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
  39. package/plugins/runtime-modules/core/widgets/simple-text/config.js +1 -0
  40. package/plugins/runtime-modules/core/widgets/table/client.js +8 -1
  41. package/server-helpers/cms-node-record.d.ts +18 -0
  42. package/server-helpers/cms-node-record.js +28 -0
  43. package/types/cms-plugins.d.ts +6 -0
  44. package/types/core-widget-placements.d.ts +6 -0
  45. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.d.ts +0 -6
  46. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +0 -49
@@ -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.2",
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("/")}` : "";
@@ -30,7 +30,7 @@ export const PHI_AREA_UPLOAD_WIDGET_DEFINITION = {
30
30
  kind: "widget",
31
31
  pluginKey: resolvePhiCmsWidgetPluginKey("area-upload"),
32
32
  typeKey: "area-upload",
33
- // An upload goes into the folder the Asset Controller holds, so the Controller is where this is.
33
+ // Without a folderPath an upload goes into the folder the Asset Controller holds, so the Controller is where this is.
34
34
  requiredRuntimeControllers: requirePhiAssetController,
35
35
  title: "Area Upload",
36
36
  description: "Dropzone and temporary upload wall for area-scoped media assets.",
@@ -42,6 +42,12 @@ export const PHI_AREA_UPLOAD_WIDGET_DEFINITION = {
42
42
  { key: "allowDelete", type: "boolean", label: "Allow Delete" },
43
43
  { key: "multiple", type: "boolean", label: "Multiple" },
44
44
  { key: "accept", type: "string", label: "Accept" },
45
+ /*
46
+ * A Folder of the Site Space by its path of names, "Shop Images / Products": every upload goes there,
47
+ * whichever Folder the Controller has open, and the Folders it names that are missing are created on
48
+ * the first upload. A path and not an id, so a preset can state it for every Site; it is resolved
49
+ * when an upload begins (`resolvePhiMediaUploadInitOptions`). Empty: the Controller's Folder.
50
+ */
45
51
  { key: "folderPath", type: "string", label: "Folder Path" },
46
52
  { key: "presentationFlags", type: "number", label: "Flags", min: 0, precision: 0 },
47
53
  ],
@@ -170,6 +170,7 @@ export const PHI_BUILDER_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
170
170
  { key: "description", title: "Description", type: "string" },
171
171
  { key: "category", title: "Category", type: "string" },
172
172
  { key: "isBaseModule", title: "Area Base module", type: "boolean", required: true },
173
+ { key: "alwaysActive", title: "Always active", type: "boolean", required: true },
173
174
  { key: "baseAreaKey", title: "Base area", type: "string" },
174
175
  /*
175
176
  * One optional boolean per Area: `true`/`false` is the Module's activation there, absence
@@ -18,6 +18,7 @@ export declare function buildRuntimeModuleRows(state: PhiDeveloperBuilderWorkspa
18
18
  description: string;
19
19
  category: string;
20
20
  isBaseModule: boolean;
21
+ alwaysActive: boolean;
21
22
  baseAreaKey: "public" | "app" | "admin" | "builder" | "editor" | "accounting" | null;
22
23
  }[];
23
24
  /** What the Modules table says when a Module that brings its own shell is switched on over a stored one. */
@@ -101,6 +101,7 @@ export function buildRuntimeModuleRows(state, categoryLabels, view, serverUnavai
101
101
  .replaceAll("%1", unavailable.missingCapabilities.join(", ") || unavailable.diagnosticCode),
102
102
  category: serverUnavailableLabels?.category ?? "Server part missing",
103
103
  isBaseModule: false,
104
+ alwaysActive: false,
104
105
  baseAreaKey: null,
105
106
  ...Object.fromEntries(PHI_CMS_AREA_KEYS.map((areaKey) => [`area_${areaKey}`, null])),
106
107
  };
@@ -121,6 +122,8 @@ export function buildRuntimeModuleRows(state, categoryLabels, view, serverUnavai
121
122
  description: definition.description,
122
123
  category: categoryLabels?.[readPhiRuntimeModuleCategory(definition.category)] ?? definition.category,
123
124
  isBaseModule: baseAreaKey != null,
125
+ // Its Area checkboxes hold no choice either: they show where it runs, disabled as a Base module's own Area is.
126
+ alwaysActive: definition.activation === "always",
124
127
  baseAreaKey,
125
128
  ...Object.fromEntries(PHI_CMS_AREA_KEYS.map((areaKey) => [
126
129
  `area_${areaKey}`,
@@ -177,6 +180,7 @@ function buildUnresolvedRuntimeModuleRows(state, view, labels) {
177
180
  description: labels?.missingHint ?? "Not part of this build. The next save drops it from the Site.",
178
181
  category: labels?.missing ?? "Not in this build",
179
182
  isBaseModule: false,
183
+ alwaysActive: false,
180
184
  baseAreaKey: null,
181
185
  ...Object.fromEntries(PHI_CMS_AREA_KEYS.map((areaKey) => [
182
186
  `area_${areaKey}`,
@@ -1573,7 +1573,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1573
1573
  * One checkbox column per Area: the switch is the Module everywhere, these are
1574
1574
  * the per-Area refinement. A Module not eligible for an Area carries null there
1575
1575
  * and the cell renders empty; the Area whose Base module the row is stays
1576
- * checked and disabled.
1576
+ * checked and disabled, and so does every Area of a Module that is always active.
1577
1577
  */
1578
1578
  ...PHI_CMS_AREA_KEYS.map((areaKey) => ({
1579
1579
  key: `area_${areaKey}`,
@@ -1583,10 +1583,11 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1583
1583
  editor: {
1584
1584
  control: "checkbox",
1585
1585
  disabledWhen: {
1586
- source: "row",
1587
- valuePath: "baseAreaKey",
1588
- operator: "equals",
1589
- value: areaKey,
1586
+ match: "any",
1587
+ conditions: [
1588
+ { source: "row", valuePath: "baseAreaKey", operator: "equals", value: areaKey },
1589
+ { source: "row", valuePath: "alwaysActive", operator: "truthy" },
1590
+ ],
1590
1591
  },
1591
1592
  },
1592
1593
  })),
@@ -166,6 +166,7 @@ export declare const PHI_IMAGE_WIDGET_DEFINITION: {
166
166
  field: string;
167
167
  value: string;
168
168
  };
169
+ recordField: string;
169
170
  };
170
171
  defaultConfig: PhiCmsImageWidgetConfig;
171
172
  parseConfig: typeof parsePhiCmsImageWidgetConfig;
@@ -174,6 +174,7 @@ export const PHI_IMAGE_WIDGET_DEFINITION = {
174
174
  sourceField: "assetId",
175
175
  translatable: true,
176
176
  skipWhenConfigFieldValue: { field: "sourceKind", value: "url" },
177
+ recordField: "recordField",
177
178
  },
178
179
  defaultConfig: normalizePhiImageWidgetConfig(null),
179
180
  parseConfig: parsePhiCmsImageWidgetConfig,
@@ -52,7 +52,6 @@ export type PhiCmsMarkdownWidgetConfig = PhiCmsWidgetConfigBase & {
52
52
  /** How the text's lists are set. */
53
53
  list?: PhiBulletListStyle;
54
54
  resolvedContent?: PhiCmsResolvedContent | null;
55
- preferSource?: boolean;
56
55
  };
57
56
  export declare function parsePhiCmsMarkdownWidgetConfig(config: Record<string, unknown>): PhiCmsMarkdownWidgetConfig;
58
57
  export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
@@ -92,6 +91,7 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
92
91
  field: string;
93
92
  value: string;
94
93
  };
94
+ recordField: string;
95
95
  };
96
96
  fields: (({
97
97
  key: string;
@@ -106,6 +106,7 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
106
106
  field: "sourceMode",
107
107
  value: "url",
108
108
  },
109
+ recordField: "recordField",
109
110
  },
110
111
  fields: [
111
112
  { key: "eyebrow", type: "string", heading: "Text", label: "Eyebrow" },
@@ -43,7 +43,6 @@ export const PHI_MARKDOWN_WIDGET_PLUGIN = {
43
43
  ...config,
44
44
  widgetId: widget.id,
45
45
  resolvedContent: widget.resolvedContent ?? null,
46
- preferSource: hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
47
46
  translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
48
47
  }, runtime: runtime }, `widget-${widget.id}`));
49
48
  },
@@ -50,6 +50,7 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
50
50
  storage: "text";
51
51
  sourceField: string;
52
52
  translatable: true;
53
+ recordField: string;
53
54
  };
54
55
  fields: (({
55
56
  key: string;
@@ -49,6 +49,7 @@ export const PHI_SIMPLE_TEXT_WIDGET_DEFINITION = {
49
49
  storage: "text",
50
50
  sourceField: "text",
51
51
  translatable: true,
52
+ recordField: "recordField",
52
53
  },
53
54
  fields: [
54
55
  ...PHI_RENDERABLE_BLOCK_GEOMETRY_FIELDS,
@@ -54,6 +54,7 @@ import { isPhiRecord } from "../../../../../helpers/is-record";
54
54
  */
55
55
  const PHI_TABLE_VISUAL_ANCHOR_PARTS = ["filters", "toolbar", "header", "row-actions", "footer", "pagination"];
56
56
  const PHI_TABLE_ACTION_BUTTON_STYLE = { whiteSpace: "nowrap" };
57
+ const PHI_TABLE_ACTION_CLICK_GUARD_STYLE = { display: "inline-flex" };
57
58
  function formatTableActionTemplate(value, templateValue) {
58
59
  return value && templateValue != null ? formatPhiTableWidgetLabel(value, templateValue) : value;
59
60
  }
@@ -945,8 +946,14 @@ function TableAction({ action, disabled = false, disabledReason, templateValue,
945
946
  * A row is clickable, and an action inside it must not also activate the row, so the click stops at
946
947
  * the element around the button. A confirmed action still gets a handler of its own: the button is
947
948
  * what opens the confirmation, and a button with nothing to call renders disabled.
949
+ *
950
+ * The element around it is exactly the button's box (`inline-flex`). As a block it was a line of the
951
+ * surrounding text tall, and the button sat on that line's baseline: where the line was taller than
952
+ * the button -- a Table in a Collapsible, whose panel sets a line height of 1.5 -- a toolbar action
953
+ * stood lower than the Reload beside it, which has no such element. It keeps a box of its own because
954
+ * a confirmation opens against it.
948
955
  */
949
- const content = (_jsx("span", { onClick: (event) => event.stopPropagation(), children: _jsx(PhiButtonControl, { size: size, type: buttonType, danger: danger, disabled: disabled, style: PHI_TABLE_ACTION_BUTTON_STYLE, icon: showIcon ? icon ?? undefined : undefined, ariaLabel: action.label, label: showLabel ? action.label : null, tooltip: disabledReason ?? (display === "icon" ? action.label : undefined), onClick: () => {
956
+ const content = (_jsx("span", { style: PHI_TABLE_ACTION_CLICK_GUARD_STYLE, onClick: (event) => event.stopPropagation(), children: _jsx(PhiButtonControl, { size: size, type: buttonType, danger: danger, disabled: disabled, style: PHI_TABLE_ACTION_BUTTON_STYLE, icon: showIcon ? icon ?? undefined : undefined, ariaLabel: action.label, label: showLabel ? action.label : null, tooltip: disabledReason ?? (display === "icon" ? action.label : undefined), onClick: () => {
950
957
  if (!action.confirm)
951
958
  onActivate();
952
959
  } }) }));
@@ -0,0 +1,18 @@
1
+ import "server-only";
2
+ import type { PhiBlockRuntime } from "../types";
3
+ import type { PhiCmsRuntimeRenderRegistry } from "../types/cms-plugins";
4
+ import type { PhiResolvedCmsRenderableTree } from "../types/cms";
5
+ /**
6
+ * The fields of the record this Page is about, as a `record` condition reads them, or null where it reads
7
+ * none.
8
+ *
9
+ * Read only for a tree that carries such a condition, and through the same request-memoised read the
10
+ * Widgets bound to the record use (`resolvePhiPageRecordFields`), so a page whose Widgets read the fields
11
+ * already pays nothing more for its conditions. Each field is its value, under its key: `icon` is the
12
+ * picture a Widget with `recordField: "icon"` draws, and a field the record lacks is not there.
13
+ *
14
+ * `null` is a Page that is about no record (`none`). A record whose fields could not be read is a record
15
+ * without any of them -- the bound Widgets draw nothing for it either -- so its conditions are answered
16
+ * against no fields rather than taken for a Page about nothing.
17
+ */
18
+ export declare function resolvePhiCmsTreeRecordConditionFields(tree: Pick<PhiResolvedCmsRenderableTree, "layoutNodes" | "contentWidgets" | "overlays">, registry: Pick<PhiCmsRuntimeRenderRegistry, "recordProviderLoadersByKey" | "recordFieldsLoadersByKey" | "recordDeclarationsByKey">, runtime: PhiBlockRuntime): Promise<Readonly<Record<string, unknown>> | null>;
@@ -0,0 +1,28 @@
1
+ import "server-only";
2
+ import { readPhiCmsNodeVisibleWhen, readsPhiCmsNodeRecord } from "../helpers/cms-node-visibility";
3
+ import { resolvePhiPageRecordFields } from "./record-fields";
4
+ /**
5
+ * The fields of the record this Page is about, as a `record` condition reads them, or null where it reads
6
+ * none.
7
+ *
8
+ * Read only for a tree that carries such a condition, and through the same request-memoised read the
9
+ * Widgets bound to the record use (`resolvePhiPageRecordFields`), so a page whose Widgets read the fields
10
+ * already pays nothing more for its conditions. Each field is its value, under its key: `icon` is the
11
+ * picture a Widget with `recordField: "icon"` draws, and a field the record lacks is not there.
12
+ *
13
+ * `null` is a Page that is about no record (`none`). A record whose fields could not be read is a record
14
+ * without any of them -- the bound Widgets draw nothing for it either -- so its conditions are answered
15
+ * against no fields rather than taken for a Page about nothing.
16
+ */
17
+ export async function resolvePhiCmsTreeRecordConditionFields(tree, registry, runtime) {
18
+ const asks = [...tree.overlays, ...tree.layoutNodes, ...tree.contentWidgets]
19
+ .some((node) => readsPhiCmsNodeRecord(readPhiCmsNodeVisibleWhen(node.config)));
20
+ if (!asks)
21
+ return null;
22
+ const result = await resolvePhiPageRecordFields({ registry, runtime });
23
+ if (result.status === "none")
24
+ return null;
25
+ if (result.status !== "ok")
26
+ return {};
27
+ return Object.fromEntries([...result.fields].map(([key, field]) => [key, field.value]));
28
+ }
@@ -368,6 +368,12 @@ export type PhiCmsWidgetContentBinding = {
368
368
  field: string;
369
369
  value: string | number | boolean | null;
370
370
  };
371
+ /**
372
+ * The config field (a `record-field` field) that names a field of the page record in the content's
373
+ * place. On a Page about a record a Widget that names one shows that field, or nothing where the record
374
+ * lacks it, so it keeps no content of its own there and is never left out as unpublished.
375
+ */
376
+ recordField?: string;
371
377
  };
372
378
  export type PhiCmsWidgetPluginRenderArgs<TConfig> = {
373
379
  widget: PhiCmsContentWidgetNode;
@@ -414,6 +414,12 @@ export type PhiCommandButtonConfig = PhiControlBadgeConfig & {
414
414
  label?: string;
415
415
  tooltip?: string;
416
416
  icon?: string;
417
+ /**
418
+ * The icon's colour, as the colour field stores it -- a Theme role (primary, success, warning, error,
419
+ * info, the text colours) or a colour of the Site's. Absent, the button's own. The button around it
420
+ * keeps its look: Danger and the variant still answer for the frame and the words.
421
+ */
422
+ iconColor?: string;
417
423
  display?: "icon" | "label" | "icon-label";
418
424
  danger?: boolean;
419
425
  disabled?: boolean;
@@ -1,6 +0,0 @@
1
- import type { PhiResolvedCmsPageTree, PhiCmsPageNode } from "../../../../types/cms";
2
- import type { PhiBlockRuntime } from "../../../../types";
3
- export declare function buildPhiDefaultAccountingPageTree({ page, }: {
4
- page: PhiCmsPageNode;
5
- runtime: PhiBlockRuntime;
6
- }): Promise<PhiResolvedCmsPageTree>;
@@ -1,49 +0,0 @@
1
- import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
2
- import { createPhiPresetCmsInstanceIdMap } from "../../../../types/cms-instance-id";
3
- import { PHI_SURFACE_CARD } from "../../../../helpers/surface-presets";
4
- import { PHI_ACCOUNTING_RUNTIME_MODULE_ID } from "../ids";
5
- import { PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS } from "../../../../constants/cms-layout-types";
6
- import { PhiCmsPageType } from "../../../../constants/phi-cms";
7
- import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
8
- import { buildPhiBasePageContentScaffold, PHI_BASE_PAGE_LAYOUT_NODE_ID } from "../../../../components/regions/presets/phi-base-page-layout";
9
- const SYNTHETIC_ACCOUNTING_REGION_IDS = {
10
- regionContent: -451,
11
- };
12
- const SYNTHETIC_ACCOUNTING_WIDGET_IDS = createPhiPresetCmsInstanceIdMap({
13
- domain: "page",
14
- ownerModuleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
15
- presetKey: "accounting-overview-page",
16
- }, [
17
- "widgetOverview",
18
- ]);
19
- export async function buildPhiDefaultAccountingPageTree({ page, }) {
20
- const scaffold = buildPhiBasePageContentScaffold({
21
- page,
22
- regionId: SYNTHETIC_ACCOUNTING_REGION_IDS.regionContent,
23
- });
24
- const nodes = createPhiCmsPresetNodes(page);
25
- return {
26
- page: nodes.page({ pageType: PhiCmsPageType.Standard }),
27
- overlays: [],
28
- regions: [scaffold.region],
29
- layoutNodes: [scaffold.layoutNode],
30
- contentWidgets: [
31
- nodes.widget({
32
- id: SYNTHETIC_ACCOUNTING_WIDGET_IDS.widgetOverview,
33
- parentLayoutNodeId: PHI_BASE_PAGE_LAYOUT_NODE_ID,
34
- typeKey: "card",
35
- slotIndex: PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS[0].slotIndex,
36
- sortOrder: 0,
37
- label: "Accounting",
38
- config: {
39
- eyebrow: "Accounting",
40
- textSource: PHI_TEXT_SOURCE_PRESET,
41
- title: "Accounting",
42
- description: "Invoices and billing workflows for this site.",
43
- variant: "compact",
44
- surface: PHI_SURFACE_CARD,
45
- },
46
- }),
47
- ],
48
- };
49
- }