@phis/ui 0.5.4 → 0.5.5

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 (94) hide show
  1. package/components/cms/phi-cms-layout-renderer.js +17 -7
  2. package/components/layouts/clients/phi-flex-layout-client.js +17 -2
  3. package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
  4. package/components/layouts/clients/phi-layout-anchored-overlay.js +2 -0
  5. package/components/regions/presets/content-entry-editor-page-tree.js +2 -0
  6. package/components/regions/presets/content-entry-public-page-trees.js +2 -0
  7. package/components/widgets/builder/stack-tabs.d.ts +2 -1
  8. package/components/widgets/builder/stack-tabs.js +18 -2
  9. package/components/widgets/config/choice-shared.d.ts +0 -48
  10. package/components/widgets/config/choice-shared.js +0 -1
  11. package/components/widgets/config/stack-tabs.js +4 -3
  12. package/helpers/config-text-fields.d.ts +49 -0
  13. package/helpers/config-text-fields.js +122 -0
  14. package/helpers/preset-text-source-check.d.ts +22 -0
  15. package/helpers/preset-text-source-check.js +45 -0
  16. package/helpers/text-source.d.ts +14 -5
  17. package/helpers/text-source.js +16 -3
  18. package/module-page-check.d.ts +1 -0
  19. package/module-page-check.js +1 -0
  20. package/package.json +1 -1
  21. package/plugins/runtime/phi-slot-child-frame-view.js +1 -1
  22. package/plugins/runtime/slot-size-policy.d.ts +8 -2
  23. package/plugins/runtime/slot-size-policy.js +51 -16
  24. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +2 -0
  25. package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
  26. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -0
  27. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +11 -0
  28. package/plugins/runtime-modules/core/widgets/button/config.d.ts +0 -1
  29. package/plugins/runtime-modules/core/widgets/button/config.js +0 -1
  30. package/plugins/runtime-modules/core/widgets/button/plugin.js +6 -25
  31. package/plugins/runtime-modules/core/widgets/card/config.d.ts +17 -1
  32. package/plugins/runtime-modules/core/widgets/card/config.js +16 -1
  33. package/plugins/runtime-modules/core/widgets/card/plugin.js +8 -10
  34. package/plugins/runtime-modules/core/widgets/card/server.d.ts +1 -2
  35. package/plugins/runtime-modules/core/widgets/card/server.js +16 -28
  36. package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -0
  37. package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +7 -1
  38. package/plugins/runtime-modules/core/widgets/checkbox-group/config.js +1 -1
  39. package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -0
  40. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
  41. package/plugins/runtime-modules/core/widgets/entry-list/config.js +0 -1
  42. package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -3
  43. package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +1 -3
  44. package/plugins/runtime-modules/core/widgets/entry-list/server.js +3 -3
  45. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -0
  46. package/plugins/runtime-modules/core/widgets/image/server.js +5 -9
  47. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -0
  48. package/plugins/runtime-modules/core/widgets/markdown-toc/server.js +3 -5
  49. package/plugins/runtime-modules/core/widgets/quick-links/plugin.js +2 -4
  50. package/plugins/runtime-modules/core/widgets/quick-links/server.d.ts +2 -5
  51. package/plugins/runtime-modules/core/widgets/quick-links/server.js +2 -6
  52. package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
  53. package/plugins/runtime-modules/core/widgets/result/config.js +0 -1
  54. package/plugins/runtime-modules/core/widgets/result/plugin.js +2 -4
  55. package/plugins/runtime-modules/core/widgets/result/server.d.ts +2 -3
  56. package/plugins/runtime-modules/core/widgets/result/server.js +11 -33
  57. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
  58. package/plugins/runtime-modules/core/widgets/slider/config.d.ts +11 -0
  59. package/plugins/runtime-modules/core/widgets/slider/config.js +1 -1
  60. package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +0 -1
  61. package/plugins/runtime-modules/core/widgets/slot-upload/config.js +0 -2
  62. package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +2 -4
  63. package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +3 -4
  64. package/plugins/runtime-modules/core/widgets/slot-upload/server.js +5 -13
  65. package/plugins/runtime-modules/core/widgets/spacer/config.d.ts +1 -1
  66. package/plugins/runtime-modules/core/widgets/spacer/config.js +1 -1
  67. package/plugins/runtime-modules/core/widgets/steps/config.d.ts +7 -2
  68. package/plugins/runtime-modules/core/widgets/steps/config.js +1 -2
  69. package/plugins/runtime-modules/core/widgets/steps/plugin.js +6 -30
  70. package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -0
  71. package/plugins/runtime-modules/core/widgets/table/config.js +1 -1
  72. package/plugins/runtime-modules/core/widgets/timeline/config.d.ts +8 -1
  73. package/plugins/runtime-modules/core/widgets/timeline/config.js +1 -2
  74. package/plugins/runtime-modules/core/widgets/timeline/plugin.js +6 -37
  75. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -0
  76. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -0
  77. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -0
  78. package/plugins/runtime-modules/page-preset-overlays.d.ts +18 -0
  79. package/plugins/runtime-modules/page-preset-overlays.js +70 -0
  80. package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +1 -0
  81. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -0
  82. package/plugins/runtime-modules/search/widgets/search-box/server.js +3 -5
  83. package/plugins/runtime-modules/search/widgets/search-results/server.js +3 -5
  84. package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +4 -0
  85. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +2 -0
  86. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +2 -0
  87. package/server-helpers/cms-request.js +34 -12
  88. package/server-helpers/cms-widget-texts.d.ts +14 -0
  89. package/server-helpers/cms-widget-texts.js +117 -0
  90. package/server-helpers/search-index.js +12 -3
  91. package/styles/root.css +6 -2
  92. package/types/cms-plugins.d.ts +30 -5
  93. package/types/core-widget-placements.d.ts +5 -0
  94. package/types/slot-size-policy.d.ts +19 -2
@@ -25,9 +25,30 @@ const PHI_SLOT_CHILD_DEFAULT_POLICY = {
25
25
  function normalizePhiSlotPolicyAxis(axis, fallback) {
26
26
  return axis === "fill" || axis === "fixed" || axis === "intrinsic" ? axis : fallback;
27
27
  }
28
- export function resolvePhiSlotSizePolicy(policy, kind) {
28
+ /**
29
+ * The value a by-config policy holds for this config.
30
+ *
31
+ * Only a top-level config field with a string or boolean value is read (a boolean as the key `"true"` or
32
+ * `"false"`); a missing field, any other value, an unknown value and no config at all give `otherwise`. A policy that is already a value passes through.
33
+ */
34
+ function resolvePhiSlotSizePolicyValue(policy, config) {
35
+ if (policy == null || typeof policy === "string" || !("configField" in policy)) {
36
+ return policy;
37
+ }
38
+ const field = config?.[policy.configField];
39
+ const selected = typeof field === "boolean" ? String(field) : field;
40
+ return typeof selected === "string" && Object.hasOwn(policy.byValue, selected)
41
+ ? policy.byValue[selected]
42
+ : policy.otherwise;
43
+ }
44
+ /**
45
+ * `config` is the config of the block whose policy this is; a by-config policy reads its field there.
46
+ * A caller without the block's config passes `null` and gets `otherwise`.
47
+ */
48
+ export function resolvePhiSlotSizePolicy(policy, kind, config) {
29
49
  const fallback = PHI_SLOT_CHILD_DEFAULT_POLICY[kind];
30
- if (policy == null) {
50
+ const value = resolvePhiSlotSizePolicyValue(policy, config);
51
+ if (value == null) {
31
52
  return fallback;
32
53
  }
33
54
  /*
@@ -38,39 +59,46 @@ export function resolvePhiSlotSizePolicy(policy, kind) {
38
59
  * Layout asked, so nothing moved -- but the word has to mean what it says now that every definition
39
60
  * has to say it.
40
61
  */
41
- if (policy === "intrinsic") {
62
+ if (value === "intrinsic") {
42
63
  return {
43
64
  inline: "intrinsic",
44
65
  block: "intrinsic",
45
66
  };
46
67
  }
47
- if (policy === "fill") {
68
+ if (value === "fill") {
48
69
  return {
49
70
  inline: "fill",
50
71
  block: "fill",
51
72
  };
52
73
  }
53
- if (policy === "fill-inline") {
74
+ if (value === "rest") {
75
+ return {
76
+ inline: "fill",
77
+ block: "fill",
78
+ takesRest: true,
79
+ };
80
+ }
81
+ if (value === "fill-inline") {
54
82
  return {
55
83
  inline: "fill",
56
84
  block: "intrinsic",
57
85
  };
58
86
  }
59
- if (policy === "fill-block") {
87
+ if (value === "fill-block") {
60
88
  return {
61
89
  inline: "intrinsic",
62
90
  block: "fill",
63
91
  };
64
92
  }
65
- if (policy === "fixed") {
93
+ if (value === "fixed") {
66
94
  return {
67
95
  inline: "fixed",
68
96
  block: "fixed",
69
97
  };
70
98
  }
71
99
  return {
72
- inline: normalizePhiSlotPolicyAxis(policy.inline, fallback.inline),
73
- block: normalizePhiSlotPolicyAxis(policy.block, fallback.block),
100
+ inline: normalizePhiSlotPolicyAxis(value.inline, fallback.inline),
101
+ block: normalizePhiSlotPolicyAxis(value.block, fallback.block),
74
102
  };
75
103
  }
76
104
  export function resolvePhiSlotChildExplicitAxes(geometry) {
@@ -100,7 +128,11 @@ export function resolvePhiSlotChildExplicitAxes(geometry) {
100
128
  export function resolvePhiEffectiveSlotSizePolicy(policy, explicit) {
101
129
  const inline = explicit?.explicitInlineSize === true ? "fixed" : policy.inline;
102
130
  const block = explicit?.explicitBlockSize === true ? "fixed" : policy.block;
103
- return inline === policy.inline && block === policy.block ? policy : { inline, block };
131
+ if (inline === policy.inline && block === policy.block) {
132
+ return policy;
133
+ }
134
+ // The flag is carried as it stands: the Flex Layout asks for it together with a main axis that still fills.
135
+ return policy.takesRest === true ? { inline, block, takesRest: true } : { inline, block };
104
136
  }
105
137
  export function resolvePhiSlotChildSizeConstraints(geometry) {
106
138
  return {
@@ -121,13 +153,14 @@ export function resolvePhiSlotChildSizeConstraints(geometry) {
121
153
  * `Cannot assign to read only property 'config'` and take the Widget's whole render with it. The account
122
154
  * menu was lost to exactly that shape, from a different source; see the Account Widget plugin.
123
155
  *
124
- * Six resolved values carry the same information and share nothing, so there is no reference to fill in.
156
+ * Resolved values carry the same information and share nothing, so there is no reference to fill in.
157
+ * The policy is built here as a plain object, `takesRest` included.
125
158
  */
126
159
  export function resolvePhiSlotChildSizingForConfig(kind, slotSizePolicy, config) {
127
160
  const geometry = resolvePhiRenderableBlockGeometry(config);
128
161
  const explicit = resolvePhiSlotChildExplicitAxes(geometry);
129
162
  return {
130
- policy: resolvePhiEffectiveSlotSizePolicy(resolvePhiSlotSizePolicy(slotSizePolicy, kind), explicit),
163
+ policy: resolvePhiEffectiveSlotSizePolicy(resolvePhiSlotSizePolicy(slotSizePolicy, kind, config), explicit),
131
164
  ...explicit,
132
165
  ...resolvePhiSlotChildSizeConstraints(geometry),
133
166
  queriesRoom: phiBlockGeometryQueriesRoom(geometry),
@@ -149,6 +182,7 @@ export function buildPhiSlotChildDataAttributes(policy, options) {
149
182
  return {
150
183
  "data-phi-slot-size-inline": policy.inline,
151
184
  "data-phi-slot-size-block": policy.block,
185
+ "data-phi-slot-rest": policy.takesRest === true ? "true" : undefined,
152
186
  "data-phi-layout-fill-slot": fillInline || fillBlock ? "true" : undefined,
153
187
  "data-phi-layout-explicit-width": explicitInlineSize ? "true" : undefined,
154
188
  "data-phi-layout-explicit-height": explicitBlockSize ? "true" : undefined,
@@ -161,7 +195,7 @@ export function buildPhiSlotChildDataAttributes(policy, options) {
161
195
  export function resolvePhiSlotChildSizing(child, fallbackKind = "widget") {
162
196
  if (!isValidElement(child)) {
163
197
  return {
164
- policy: resolvePhiSlotSizePolicy(undefined, fallbackKind),
198
+ policy: resolvePhiSlotSizePolicy(undefined, fallbackKind, null),
165
199
  explicitInlineSize: false,
166
200
  explicitBlockSize: false,
167
201
  queriesRoom: false,
@@ -194,7 +228,7 @@ export function resolvePhiSlotChildSizing(child, fallbackKind = "widget") {
194
228
  || configExplicit.explicitBlockSize,
195
229
  };
196
230
  return {
197
- policy: resolvePhiEffectiveSlotSizePolicy(resolvePhiSlotSizePolicy(props.slotSizePolicy, resolvedKind), explicit),
231
+ policy: resolvePhiEffectiveSlotSizePolicy(resolvePhiSlotSizePolicy(props.slotSizePolicy, resolvedKind, props.config), explicit),
198
232
  ...explicit,
199
233
  ...configConstraints,
200
234
  queriesRoom,
@@ -211,14 +245,15 @@ export function resolvePhiSlotChildSizing(child, fallbackKind = "widget") {
211
245
  props["data-phi-slot-size-block"] === "intrinsic"
212
246
  ? props["data-phi-slot-size-block"]
213
247
  : undefined,
214
- }, fallbackKind);
248
+ }, fallbackKind, props.config);
249
+ const dataPolicy = props["data-phi-slot-rest"] === "true" ? { ...policy, takesRest: true } : policy;
215
250
  const explicit = {
216
251
  explicitInlineSize: props["data-phi-layout-explicit-width"] === "true" || configExplicit.explicitInlineSize,
217
252
  explicitBlockSize: props["data-phi-layout-explicit-height"] === "true" || configExplicit.explicitBlockSize,
218
253
  };
219
254
  return {
220
255
  // Idempotent: an element that already wrote the effective policy into its attributes says the same again.
221
- policy: resolvePhiEffectiveSlotSizePolicy(policy, explicit),
256
+ policy: resolvePhiEffectiveSlotSizePolicy(dataPolicy, explicit),
222
257
  ...explicit,
223
258
  queriesRoom,
224
259
  minInlineSize: configConstraints.minInlineSize ??
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { createPhiPresetCmsInstanceIdMap } from "../../../../types/cms-instance-id";
2
3
  import { PHI_SURFACE_CARD } from "../../../../helpers/surface-presets";
3
4
  import { PHI_ACCOUNTING_RUNTIME_MODULE_ID } from "../ids";
@@ -36,6 +37,7 @@ export async function buildPhiDefaultAccountingPageTree({ page, }) {
36
37
  label: "Accounting",
37
38
  config: {
38
39
  eyebrow: "Accounting",
40
+ textSource: PHI_TEXT_SOURCE_PRESET,
39
41
  title: "Accounting",
40
42
  description: "Invoices and billing workflows for this site.",
41
43
  variant: "compact",
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { isPhiAuthoredTextField, readPhiTextSource } from "../../../../helpers/text-source";
3
+ import { PHI_TEXT_SOURCE_PRESET, isPhiAuthoredTextField, readPhiTextSource } from "../../../../helpers/text-source";
4
4
  import { useEffect } from "react";
5
5
  import { PhiGeometryControl } from "../../../../components/controls/phi-geometry-control";
6
6
  import { PhiSurfaceControl } from "../../../../components/controls/phi-surface-control";
@@ -88,7 +88,7 @@ export function PhiDeveloperBuilderWidgetInspectorWidgetClient({ section, builde
88
88
  * An author writing into a Preset's text makes the Widget's words the Site's: from here on the
89
89
  * Site's store translates them, not the global one (`helpers/text-source.ts`).
90
90
  */
91
- if (readPhiTextSource(currentWidgetSettingsConfigRecord.textSource) != null
91
+ if (readPhiTextSource(currentWidgetSettingsConfigRecord.textSource) === PHI_TEXT_SOURCE_PRESET
92
92
  && isPhiAuthoredTextField(field)) {
93
93
  patch.textSource = undefined;
94
94
  }
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsFlags } from "../../../../constants/phi-cms";
3
4
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
@@ -468,6 +469,7 @@ export async function buildPhiBuilderInspectorAreaOverlayTree({ page, runtime, }
468
469
  label: "Builder effects commands",
469
470
  config: {
470
471
  key: "builder-effects-commands",
472
+ textSource: PHI_TEXT_SOURCE_PRESET,
471
473
  ...PHI_DIALOG_COMMANDS_CONFIG,
472
474
  /*
473
475
  * The two buttons as one group, the way the Area settings footer states it: they are the two
@@ -597,6 +599,7 @@ export async function buildPhiBuilderInspectorAreaOverlayTree({ page, runtime, }
597
599
  label: "Builder signal wiring commands",
598
600
  config: {
599
601
  key: "builder-signal-wiring-commands",
602
+ textSource: PHI_TEXT_SOURCE_PRESET,
600
603
  ...PHI_DIALOG_COMMANDS_CONFIG,
601
604
  /*
602
605
  * The two buttons as one group, the way the Area settings footer states it: they are the two
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { createPhiPresetCmsInstanceIdMap, } from "../../../../types/cms-instance-id";
2
3
  import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, PHI_CMS_THREE_COLUMN_LAYOUT_SLOT_INDEX, } from "../../../../constants/cms-layout-types";
3
4
  import { PhiCmsFlags, PhiCmsRegionType, PhiCmsStatus } from "../../../../constants/phi-cms";
@@ -511,6 +512,7 @@ export async function buildPhiDefaultBuilderAreaPresetTree({ page, runtime, }) {
511
512
  label: "dev builder area selector",
512
513
  config: {
513
514
  key: "builder-area-selector",
515
+ textSource: PHI_TEXT_SOURCE_PRESET,
514
516
  value: "public",
515
517
  /*
516
518
  * Disabled is the selector's resting state: only Builder pages that edit one Area at a
@@ -564,6 +566,7 @@ export async function buildPhiDefaultBuilderAreaPresetTree({ page, runtime, }) {
564
566
  label: labels.themeSwitch.debug,
565
567
  defaultChecked: false,
566
568
  key: "debugScaffold",
569
+ textSource: PHI_TEXT_SOURCE_PRESET,
567
570
  /*
568
571
  * Disabled is the switch's resting state, the same way the Area selector rests: only the
569
572
  * pages that draw a canvas arm it, via the workspace controller's "enabled" signal
@@ -1195,6 +1198,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1195
1198
  label: siderFullHeightLabel,
1196
1199
  defaultChecked: true,
1197
1200
  key: "dev-structure-sider-full-height-switch",
1201
+ textSource: PHI_TEXT_SOURCE_PRESET,
1198
1202
  signalRoutes: {
1199
1203
  emits: [
1200
1204
  {
@@ -1307,6 +1311,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1307
1311
  label: "dev area settings action",
1308
1312
  config: {
1309
1313
  key: "areaSettingsAction",
1314
+ textSource: PHI_TEXT_SOURCE_PRESET,
1310
1315
  compact: true,
1311
1316
  showLabels: true,
1312
1317
  buttons: [{
@@ -1338,6 +1343,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1338
1343
  label: "Area settings commands",
1339
1344
  config: {
1340
1345
  key: "area-settings-commands",
1346
+ textSource: PHI_TEXT_SOURCE_PRESET,
1341
1347
  ...PHI_DIALOG_COMMANDS_CONFIG,
1342
1348
  /*
1343
1349
  * The two buttons as one group rather than as two things that happen to stand near
@@ -1398,6 +1404,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1398
1404
  label: "dev pages select",
1399
1405
  config: {
1400
1406
  key: "pageSelect",
1407
+ textSource: PHI_TEXT_SOURCE_PRESET,
1401
1408
  // Folders open under the pointer and choose nothing: only a Page is offered.
1402
1409
  expandTrigger: "hover",
1403
1410
  select: "options",
@@ -1432,6 +1439,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1432
1439
  text: "",
1433
1440
  placeholder: labels.pages.form.title,
1434
1441
  key: "pageTitle",
1442
+ textSource: PHI_TEXT_SOURCE_PRESET,
1435
1443
  signalRoutes: {
1436
1444
  listens: [
1437
1445
  {
@@ -1459,6 +1467,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1459
1467
  label: "dev pages meta toolbar",
1460
1468
  config: {
1461
1469
  key: "pageMetaToolbar",
1470
+ textSource: PHI_TEXT_SOURCE_PRESET,
1462
1471
  signalRoutes: {
1463
1472
  emits: [
1464
1473
  {
@@ -1715,6 +1724,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1715
1724
  label: "Builder module usage commands",
1716
1725
  config: {
1717
1726
  key: "module-usage-commands",
1727
+ textSource: PHI_TEXT_SOURCE_PRESET,
1718
1728
  ...PHI_DIALOG_COMMANDS_CONFIG,
1719
1729
  buttons: [
1720
1730
  { key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: modulesLabels?.usage.cancel ?? "Keep it on", icon: "close" },
@@ -1811,6 +1821,7 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
1811
1821
  label: "Builder public route collision commands",
1812
1822
  config: {
1813
1823
  key: "public-routes-commands",
1824
+ textSource: PHI_TEXT_SOURCE_PRESET,
1814
1825
  ...PHI_DIALOG_COMMANDS_CONFIG,
1815
1826
  buttons: [
1816
1827
  { key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: modulesLabels?.publicRoutes.cancel ?? "Cancel", icon: "close" },
@@ -47,7 +47,6 @@ export declare const PHI_BUTTON_WIDGET_DEFINITION: {
47
47
  category: "form";
48
48
  icon: string;
49
49
  iconFamily: string;
50
- translatesOwnText: true;
51
50
  slotSizePolicy: "intrinsic";
52
51
  runtimeSignals: {
53
52
  emits: ({
@@ -46,7 +46,6 @@ export const PHI_BUTTON_WIDGET_DEFINITION = {
46
46
  category: "form",
47
47
  icon: "antd:edit-outlined",
48
48
  iconFamily: "form",
49
- translatesOwnText: true,
50
49
  slotSizePolicy: "intrinsic",
51
50
  runtimeSignals: {
52
51
  ...PHI_BUTTON_CONTROL_SIGNALS,
@@ -1,33 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { PhiCmsFlags } from "../../../../../constants/phi-cms";
3
- import { hasPhiFlag } from "../../../../../helpers/flags";
4
2
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
5
3
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
6
4
  import { PHI_BUTTON_WIDGET_DEFINITION } from "./config";
7
5
  import { getPhiCommonControlLabelsForRuntime } from "../../../../../components/widgets/label-sets/common-controls";
8
6
  import { isPhiExternalHref } from "../../../../../helpers/external-href";
9
7
  import { resolvePhiLinkHref } from "../../../../../helpers/link-target";
10
- import { trBulkForLocale } from "../../../../../server-helpers/translate";
11
8
  import { resolvePhiWidgetRecordField } from "../../../../../server-helpers/record-fields";
12
- /**
13
- * The Button's own words in the reader's language.
14
- *
15
- * Every Widget translates the text written into it itself; nothing does it for them on the way in. The
16
- * common control labels beside it are a global label set and arrive translated already.
17
- */
18
- async function translatePhiButtonConfig(config, runtime, translate) {
19
- if (!translate)
20
- return config;
21
- const entries = [["label", config.label], ["tooltip", config.tooltip]]
22
- .filter((entry) => Boolean(entry[1]?.trim()));
23
- if (entries.length === 0)
24
- return config;
25
- const translated = await trBulkForLocale(runtime.locale.current, entries.map(([, text]) => text));
26
- return {
27
- ...config,
28
- ...Object.fromEntries(entries.map(([key, text], index) => [key, translated[index]?.trim() || text])),
29
- };
30
- }
31
9
  /**
32
10
  * What the page record says of the Button, where it names a field for its value or its link: a Button on
33
11
  * a template sends what the record it stands beside is called and leads where that record leads, not a
@@ -58,8 +36,11 @@ export const PHI_BUTTON_WIDGET_PLUGIN = {
58
36
  if (!bound)
59
37
  return null;
60
38
  const { link: recordLink } = bound;
61
- const translated = await translatePhiButtonConfig(bound.config, runtime, !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate));
62
- /* The record's words stand in for an empty label only, and are the record's own: not translated. */
39
+ /*
40
+ * The Button's own words arrive translated (server-helpers/cms-widget-texts.ts). The record's stand
41
+ * in for an empty label only, and are the record's own: not translated.
42
+ */
43
+ const translated = bound.config;
63
44
  const config = recordLink?.label && !translated.label?.trim() ? { ...translated, label: recordLink.label } : translated;
64
45
  return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Button, componentProps: {
65
46
  blockId: widget.id,
@@ -72,7 +53,7 @@ export const PHI_BUTTON_WIDGET_PLUGIN = {
72
53
  },
73
54
  renderPreview: async ({ widget, config, runtime, links }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Button, componentProps: {
74
55
  blockId: widget.id,
75
- config: await translatePhiButtonConfig(config, runtime, !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate)),
56
+ config,
76
57
  labels: await getPhiCommonControlLabelsForRuntime(runtime),
77
58
  link: resolvePhiLinkHref(config.linkTarget, links),
78
59
  disabled: true,
@@ -102,7 +102,22 @@ export declare const PHI_CARD_WIDGET_DEFINITION: {
102
102
  description: string;
103
103
  icon: string;
104
104
  iconFamily: string;
105
- translatesOwnText: true;
105
+ configTexts: ({
106
+ key: string;
107
+ register: "label";
108
+ item?: undefined;
109
+ values?: undefined;
110
+ } | {
111
+ key: string;
112
+ register: "message";
113
+ item?: undefined;
114
+ values?: undefined;
115
+ } | {
116
+ key: string;
117
+ item: string;
118
+ values: string;
119
+ register: "message";
120
+ })[];
106
121
  slotSizePolicy: "fill";
107
122
  surface: "own";
108
123
  runtimeSignals: {
@@ -169,6 +184,7 @@ export declare const PHI_CARD_WIDGET_DEFINITION: {
169
184
  type: "string" | "url" | "icon";
170
185
  emptyValue?: "";
171
186
  placeholder?: string;
187
+ text?: false | "label" | "message";
172
188
  }) | ({
173
189
  key: string;
174
190
  label: string;
@@ -94,7 +94,22 @@ export const PHI_CARD_WIDGET_DEFINITION = {
94
94
  description: "Content card with a picture or an icon, a heading or a figure, and a link.",
95
95
  icon: "antd:idcard-outlined",
96
96
  iconFamily: "basic",
97
- translatesOwnText: true,
97
+ /*
98
+ * The card's words are written on the canvas, not in Inspector fields, so the card names them for the
99
+ * renderer's translation (TRANSLATIONS.md, "Widget config text"); a plan line's values stay out of it.
100
+ */
101
+ configTexts: [
102
+ { key: "eyebrow", register: "label" },
103
+ { key: "title", register: "label" },
104
+ { key: "description", register: "message" },
105
+ { key: "meta", register: "label" },
106
+ { key: "actionLabel", register: "label" },
107
+ { key: "badge", register: "label" },
108
+ { key: "pricePeriod", register: "label" },
109
+ { key: "pricePeriodYearly", register: "label" },
110
+ { key: "alt", register: "label" },
111
+ { key: "features", item: "text", values: "values", register: "message" },
112
+ ],
98
113
  /*
99
114
  * A card fills its slot both ways, as a Layout does.
100
115
  *
@@ -1,7 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { PhiCmsFlags } from "../../../../../constants/phi-cms";
3
- import { hasPhiFlag } from "../../../../../helpers/flags";
4
- import { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
5
2
  import { PhiCardWidget } from "./server";
6
3
  import { PHI_CARD_WIDGET_DEFINITION, PHI_CARD_WIDGET_PLUGIN_TYPE } from "./config";
7
4
  function renderPhiCard({ widget, config, runtime, links }, preview) {
@@ -11,17 +8,17 @@ function renderPhiCard({ widget, config, runtime, links }, preview) {
11
8
  description: config.description,
12
9
  meta: config.meta,
13
10
  actionLabel: config.actionLabel,
14
- }, config: config, runtime: runtime, links: links, translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate), preview: preview }, `widget-${widget.id}`));
11
+ }, config: config, runtime: runtime, links: links, preview: preview }, `widget-${widget.id}`));
15
12
  }
16
13
  export const PHI_CARD_WIDGET_PLUGIN = {
17
14
  ...PHI_CARD_WIDGET_DEFINITION,
18
15
  /*
19
- * The card's words as the render draws them (SEARCH.md): the texts it translates, translated the same
20
- * way; the figure and the prices as written, which the render never translates either.
16
+ * The card's words as the render draws them (SEARCH.md): they arrive translated by the same pass the
17
+ * render's do; the figure and the prices as written, which the render never translates either.
21
18
  */
22
- searchText: async ({ widget, config, runtime }) => {
19
+ searchText: ({ config }) => {
23
20
  const plan = config.body === "plan";
24
- const translated = await translatePhiSearchWidgetTexts(runtime, [
21
+ return [
25
22
  config.eyebrow,
26
23
  config.title,
27
24
  config.description,
@@ -29,8 +26,9 @@ export const PHI_CARD_WIDGET_PLUGIN = {
29
26
  config.badge,
30
27
  config.actionEnabled ? config.actionLabel : undefined,
31
28
  ...(plan ? (config.features ?? []).map((entry) => entry.text) : []),
32
- ], { translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate) });
33
- return [...translated, config.value ?? "", ...(plan ? [config.price ?? "", config.priceYearly ?? ""] : [])];
29
+ config.value,
30
+ ...(plan ? [config.price, config.priceYearly] : []),
31
+ ].filter((text) => typeof text === "string" && text.trim().length > 0);
34
32
  },
35
33
  /*
36
34
  * Not the passive renderers' preview: that one is inert, and an inert card answers no pointer, so its
@@ -14,8 +14,7 @@ export type PhiCardWidgetLabels = {
14
14
  export type PhiCardWidgetProps = PhiServerBlockBaseProps<PhiCardWidgetLabels, PhiCmsCardWidgetConfig> & {
15
15
  links?: PhiResolvedLinkTargets | null;
16
16
  };
17
- export declare function PhiCardWidget({ labels, config, runtime, links, translate, preview, }: PhiCardWidgetProps & {
18
- translate: boolean;
17
+ export declare function PhiCardWidget({ labels, config, runtime, links, preview, }: PhiCardWidgetProps & {
19
18
  /**
20
19
  * The Builder's preview: the card answers the pointer as it will live -- its hover effect is what the
21
20
  * author is looking at -- but leads nowhere and says nothing, so a click cannot leave the Builder.
@@ -10,8 +10,7 @@ import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runt
10
10
  import { getPhiCardWidgetLabelsForRuntime } from "../../../../../components/widgets/label-sets/card";
11
11
  import { PhiBulletListControl } from "../../../../../components/controls/phi-bullet-list-control";
12
12
  import { buildPhiBulletListTree, resolvePhiBulletListStyle, } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
13
- import { maskPhiTextPlaceholders, resolvePhiTextPlaceholders } from "../../../../../helpers/text-placeholders";
14
- export async function PhiCardWidget({ labels, config, runtime, links, translate, preview = false, }) {
13
+ export async function PhiCardWidget({ labels, config, runtime, links, preview = false, }) {
15
14
  /*
16
15
  * The button's words: the author's, or none where they emptied them for an icon-only button, or the
17
16
  * label set's when they never wrote any -- which is translated there, not here.
@@ -24,7 +23,17 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
24
23
  const resolvedAsset = config?.sourceKind === "asset" && typeof config.assetId === "number"
25
24
  ? await resolvePhiPublicAssetReference({ runtime, assetId: config.assetId }).catch(() => null)
26
25
  : null;
27
- const textEntries = [
26
+ /*
27
+ * The card's own words arrive translated, `{site.name}` and a plan line's values filled in
28
+ * (server-helpers/cms-widget-texts.ts, the Card's `configTexts`). Only the Media library's
29
+ * description of an Asset is read here, and translated in the Site's store like every Asset's.
30
+ */
31
+ const ownAlt = config?.alt?.trim();
32
+ const assetAlt = !ownAlt ? resolvedAsset?.altText?.trim() : undefined;
33
+ const alt = ownAlt || (assetAlt
34
+ ? (await (runtime?.locale.current ? trBulkForLocale(runtime.locale.current, [assetAlt]) : trBulk([assetAlt])))[0]?.trim() || assetAlt
35
+ : undefined);
36
+ const translatedByKey = new Map([
28
37
  ["eyebrow", labels.eyebrow ?? config?.eyebrow],
29
38
  ["title", labels.title ?? config?.title],
30
39
  ["description", labels.description ?? config?.description],
@@ -33,33 +42,12 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
33
42
  ["badge", labels.badge ?? config?.badge],
34
43
  ["pricePeriod", plan ? labels.pricePeriod ?? config?.pricePeriod : undefined],
35
44
  ["pricePeriodYearly", plan ? labels.pricePeriodYearly ?? config?.pricePeriodYearly : undefined],
36
- // What a screen reader says for the picture, in the page's language like every other word here.
37
- ["alt", (config?.alt ?? resolvedAsset?.altText ?? "").trim() || undefined],
38
- ];
39
- /*
40
- * A plan's features, masked as every list entry is: their values stand as `%1` onwards and never reach
41
- * a translator, and `{site.name}` is filled after (`helpers/text-placeholders.ts`).
42
- */
43
- const features = plan ? (config?.features ?? []).filter((entry) => Boolean(entry.text)) : [];
44
- const maskedFeatures = features.map((entry) => maskPhiTextPlaceholders(entry.text, entry.values?.length ?? 0));
45
- const sourceTexts = [...textEntries.map(([, value]) => value ?? ""), ...maskedFeatures.map((masked) => masked.text)];
46
- const translatedTexts = translate
47
- ? await (runtime?.locale.current
48
- ? trBulkForLocale(runtime.locale.current, sourceTexts)
49
- : trBulk(sourceTexts))
50
- : sourceTexts;
51
- const translatedByKey = new Map(textEntries.map(([key], index) => [key, translatedTexts[index] || undefined]));
52
- const translatedFeatures = features.map((entry, index) => ({
53
- ...entry,
54
- text: resolvePhiTextPlaceholders(translatedTexts[textEntries.length + index] ?? entry.text, maskedFeatures[index].names, runtime, entry.values),
55
- }));
45
+ ["alt", alt],
46
+ ]);
47
+ const translatedFeatures = plan ? (config?.features ?? []).filter((entry) => Boolean(entry.text)) : [];
56
48
  /* Drawn here, so the list Control never reaches the browser with the Card (`listContent`). */
57
49
  const featureList = translatedFeatures.length > 0 ? (_jsx(PhiBulletListControl, { listStyle: resolvePhiBulletListStyle(config?.featureList), items: buildPhiBulletListTree(translatedFeatures, (entry) => entry.text) })) : null;
58
- /*
59
- * The figure is left out of the translation on purpose: a Site's own number is not a word, and
60
- * `translate` is a per-Widget switch, so a stat card that turned it off to protect the figure would
61
- * lose its title's translation with it.
62
- */
50
+ // The figure is not translated: a Site's own number is not a word (`value` is no text field).
63
51
  const value = config?.value;
64
52
  const presentation = resolvePhiImagePresentation({
65
53
  sourceKind: config?.sourceKind,
@@ -20,6 +20,7 @@ export declare const PHI_CASCADER_WIDGET_BUILDER_PLUGIN: {
20
20
  requiredDataProviders?: readonly import("@phis/contracts/controls").PhiRuntimeDataProviderKey[] | undefined;
21
21
  contentBinding?: (import("../../../../../types").PhiCmsWidgetContentBinding | null) | undefined;
22
22
  translatesOwnText?: true | undefined;
23
+ configTexts?: readonly import("../../../../../types/cms-plugins").PhiCmsWidgetConfigText[] | undefined;
23
24
  slotSizePolicy: import("../../../../../types").PhiSlotSizePolicy;
24
25
  requiredRegionOwnership?: import("../../../../../helpers/cms-region-keys").PhiCmsRegionOwnership | undefined;
25
26
  creationConfig?: Partial<PhiCascaderWidgetConfig> | undefined;
@@ -14,7 +14,13 @@ export declare const PHI_CHECKBOX_GROUP_WIDGET_DEFINITION: {
14
14
  kind: "widget";
15
15
  pluginKey: string;
16
16
  typeKey: string;
17
- slotSizePolicy: "intrinsic";
17
+ slotSizePolicy: {
18
+ configField: string;
19
+ byValue: {
20
+ true: "intrinsic";
21
+ };
22
+ otherwise: "fill-inline";
23
+ };
18
24
  title: string;
19
25
  description: string;
20
26
  category: "form";
@@ -18,7 +18,7 @@ export const PHI_CHECKBOX_GROUP_WIDGET_DEFINITION = {
18
18
  kind: "widget",
19
19
  pluginKey: resolvePhiCmsWidgetPluginKey("checkbox-group"),
20
20
  typeKey: "checkbox-group",
21
- slotSizePolicy: "intrinsic",
21
+ slotSizePolicy: { configField: "vertical", byValue: { true: "intrinsic" }, otherwise: "fill-inline" },
22
22
  title: "Checkbox Group",
23
23
  description: "Reusable multi-choice checkbox group with static or provider-backed options.",
24
24
  category: "form",
@@ -40,6 +40,7 @@ export declare const PHI_DESCRIPTION_WIDGET_DEFINITION: {
40
40
  type: "string" | "url" | "icon";
41
41
  emptyValue?: "";
42
42
  placeholder?: string;
43
+ text?: false | "label" | "message";
43
44
  }) | ({
44
45
  key: string;
45
46
  label: string;
@@ -69,7 +69,6 @@ export declare const PHI_ENTRY_LIST_WIDGET_DEFINITION: {
69
69
  description: string;
70
70
  category: "content";
71
71
  tags: string[];
72
- translatesOwnText: true;
73
72
  icon: string;
74
73
  slotSizePolicy: "fill-inline";
75
74
  fields: (({
@@ -84,6 +83,7 @@ export declare const PHI_ENTRY_LIST_WIDGET_DEFINITION: {
84
83
  type: "string" | "url" | "icon";
85
84
  emptyValue?: "";
86
85
  placeholder?: string;
86
+ text?: false | "label" | "message";
87
87
  }) | ({
88
88
  key: string;
89
89
  label: string;
@@ -85,7 +85,6 @@ export const PHI_ENTRY_LIST_WIDGET_DEFINITION = {
85
85
  category: "content",
86
86
  tags: ["news", "blog", "content", "list"],
87
87
  // The heading is the Site's own words; the entries arrive translated from Core.
88
- translatesOwnText: true,
89
88
  icon: "antd:read",
90
89
  slotSizePolicy: "fill-inline",
91
90
  fields: [
@@ -1,11 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { PhiCmsFlags } from "../../../../../constants/phi-cms";
3
- import { hasPhiFlag } from "../../../../../helpers/flags";
4
2
  import { definePhiPassiveWidgetRenderers } from "../../../../../plugins/factories/widget-renderers";
5
3
  import { PHI_ENTRY_LIST_WIDGET_DEFINITION } from "./config";
6
4
  import { PhiEntryListWidget } from "./server";
7
5
  export const PHI_ENTRY_LIST_WIDGET_PLUGIN = {
8
6
  ...PHI_ENTRY_LIST_WIDGET_DEFINITION,
9
7
  // `links` carries the detail route, resolved with every other target of the page before anything drew.
10
- ...definePhiPassiveWidgetRenderers(({ widget, config, runtime, registry, links }) => (_jsx(PhiEntryListWidget, { config: config, runtime: runtime, registry: registry, links: links, translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate), widgetId: widget.id }, `widget-${widget.id}`))),
8
+ ...definePhiPassiveWidgetRenderers(({ widget, config, runtime, registry, links }) => (_jsx(PhiEntryListWidget, { config: config, runtime: runtime, registry: registry, links: links, widgetId: widget.id }, `widget-${widget.id}`))),
11
9
  };