@phis/ui 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +1 -1
  2. package/components/controls/phi-border-control.js +1 -1
  3. package/components/controls/phi-bound-radius-control.js +9 -9
  4. package/components/controls/phi-brand-control.js +1 -1
  5. package/components/controls/phi-cascader-control.d.ts +9 -1
  6. package/components/controls/phi-cascader-control.js +25 -3
  7. package/components/controls/phi-drawer-control-adapter.js +4 -4
  8. package/components/controls/phi-dropdown-control.js +2 -2
  9. package/components/controls/phi-form-control.js +1 -1
  10. package/components/controls/phi-image-control.js +1 -1
  11. package/components/controls/phi-mask-picker-control.js +6 -6
  12. package/components/controls/phi-money-control.d.ts +39 -0
  13. package/components/controls/phi-money-control.js +34 -0
  14. package/components/controls/phi-number-control.d.ts +6 -1
  15. package/components/controls/phi-number-control.js +3 -3
  16. package/components/controls/phi-options-provider.d.ts +7 -0
  17. package/components/controls/phi-options-provider.js +11 -0
  18. package/components/controls/phi-select-control.js +1 -1
  19. package/components/controls/phi-theme-scope-control.js +1 -1
  20. package/components/controls/use-phi-color-control-presets.js +2 -2
  21. package/components/forms/compound-form-controls.js +2 -2
  22. package/components/forms/extended-form-field-controls.d.ts +1 -0
  23. package/components/forms/extended-form-field-controls.js +24 -2
  24. package/components/forms/form-descriptor-runtime-client.js +13 -0
  25. package/components/forms/form-provider-contract.d.ts +43 -0
  26. package/components/forms/form-provider-contract.js +40 -0
  27. package/components/forms/money-field.d.ts +27 -0
  28. package/components/forms/money-field.js +78 -0
  29. package/components/forms/shared-form-provider-registry.js +6 -2
  30. package/components/layouts/clients/phi-flex-layout-client.js +4 -4
  31. package/components/layouts/clients/phi-grid-layout-client.js +3 -3
  32. package/components/layouts/clients/phi-sequence-slot-editor.js +1 -1
  33. package/components/layouts/layout-definitions.d.ts +4 -4
  34. package/components/layouts/phi-page-region-layout.js +1 -1
  35. package/components/layouts/phi-structure-region-layout.js +3 -3
  36. package/components/media/phi-asset-focal-rect-widget.js +4 -4
  37. package/components/media/phi-asset-inspector-section.js +1 -1
  38. package/components/media/phi-media-kind-icon.js +2 -2
  39. package/components/media/phi-media-picker-binding.js +6 -1
  40. package/components/media/phi-media-restricted-icon.js +1 -1
  41. package/components/media/phi-site-font-assets.js +6 -1
  42. package/components/motion/phi-sequence-run.d.ts +14 -1
  43. package/components/motion/phi-sequence-run.js +22 -3
  44. package/components/motion/phi-sequence-viewport.js +3 -1
  45. package/components/overlays/phi-overlay-container-client.js +1 -1
  46. package/components/regions/presets/content-entry-editor-page-tree.js +3 -1
  47. package/components/regions/presets/phi-base-page-column.js +6 -2
  48. package/components/root/phi-config-provider.js +1 -1
  49. package/components/root/phi-root-background.js +1 -1
  50. package/components/root/phi-root-theme-resolver.js +1 -1
  51. package/components/shell/phi-module-icons.js +1 -1
  52. package/components/tables/client/phi-table-binding.js +16 -3
  53. package/components/trees/client/phi-tree-binding.js +6 -2
  54. package/components/widgets/built-in/builder-workspace-preview.js +8 -8
  55. package/components/widgets/client/bullet-list-entries-editor.js +2 -2
  56. package/components/widgets/client/external-document-editor.js +1 -1
  57. package/components/widgets/client/html-editor.js +3 -3
  58. package/components/widgets/client/shared/phi-collection-view-binding.js +10 -2
  59. package/components/widgets/client/shared/phi-rendered-value.d.ts +9 -1
  60. package/components/widgets/client/shared/phi-rendered-value.js +20 -1
  61. package/components/widgets/config/background.d.ts +1 -1
  62. package/components/widgets/config/background.js +1 -1
  63. package/components/widgets/config/choice-shared.d.ts +2 -2
  64. package/components/widgets/inspector-field-row.js +1 -1
  65. package/components/widgets/label-sets/gallery.js +6 -0
  66. package/components/widgets/label-sets/inspector.js +2 -0
  67. package/components/widgets/label-sets/interval.d.ts +4 -0
  68. package/components/widgets/label-sets/interval.js +31 -0
  69. package/components/widgets/label-sets/record.js +6 -1
  70. package/components/widgets/label-sets/slot-upload.d.ts +4 -0
  71. package/components/widgets/label-sets/slot-upload.js +36 -0
  72. package/components/widgets/label-sets/table.js +6 -1
  73. package/components/widgets/label-types/gallery.d.ts +7 -0
  74. package/components/widgets/label-types/gallery.js +6 -0
  75. package/components/widgets/label-types/inspector.d.ts +1 -0
  76. package/components/widgets/label-types/inspector.js +1 -0
  77. package/components/widgets/label-types/interval.d.ts +16 -0
  78. package/components/widgets/label-types/interval.js +21 -0
  79. package/components/widgets/label-types/record.d.ts +3 -0
  80. package/components/widgets/label-types/record.js +2 -0
  81. package/components/widgets/label-types/slot-upload.d.ts +24 -0
  82. package/components/widgets/label-types/slot-upload.js +16 -0
  83. package/components/widgets/label-types/table.d.ts +3 -0
  84. package/components/widgets/label-types/table.js +2 -0
  85. package/components/widgets/shared/card-body-client.js +1 -1
  86. package/components/widgets/shared/result-body-client.js +1 -1
  87. package/constants/media-library-provider-keys.d.ts +8 -1
  88. package/constants/media-library-provider-keys.js +8 -1
  89. package/constants/record-field-kinds.d.ts +6 -0
  90. package/constants/record-field-kinds.js +7 -0
  91. package/constants/runtime-module-ownership.js +2 -1
  92. package/controls.d.ts +7 -0
  93. package/controls.js +4 -0
  94. package/helpers/border-widget-style.d.ts +2 -2
  95. package/helpers/border-widget-style.js +2 -2
  96. package/helpers/cms-dialog.d.ts +43 -7
  97. package/helpers/cms-dialog.js +46 -4
  98. package/helpers/cms-layout-defaults.d.ts +2 -2
  99. package/helpers/cms-page-catalog.d.ts +13 -0
  100. package/helpers/cms-page-catalog.js +18 -2
  101. package/helpers/cms-preset-nodes.d.ts +13 -3
  102. package/helpers/cms-preset-nodes.js +3 -2
  103. package/helpers/cms-preset-page-tree.d.ts +4 -0
  104. package/helpers/cms-preset-page-tree.js +2 -0
  105. package/helpers/layout-style.d.ts +2 -2
  106. package/helpers/money-amount.d.ts +48 -0
  107. package/helpers/money-amount.js +131 -0
  108. package/helpers/page-layout-check.d.ts +4 -1
  109. package/helpers/page-layout-check.js +41 -2
  110. package/helpers/record-fields.d.ts +22 -0
  111. package/helpers/record-fields.js +109 -0
  112. package/helpers/surface-presets.d.ts +6 -6
  113. package/helpers/surface-style.d.ts +1 -1
  114. package/helpers.d.ts +0 -1
  115. package/helpers.js +0 -2
  116. package/module-page-check.d.ts +12 -0
  117. package/module-page-check.js +12 -0
  118. package/module-records.d.ts +7 -2
  119. package/module-records.js +5 -1
  120. package/next/antd-form-context-loader.mjs +31 -0
  121. package/next/config.d.mts +2 -0
  122. package/next/config.mjs +36 -3
  123. package/package.json +11 -2
  124. package/plugins/runtime-modules/accounting/module.d.ts +1 -1
  125. package/plugins/runtime-modules/app/module.d.ts +1 -1
  126. package/plugins/runtime-modules/asset/data-providers.d.ts +0 -65
  127. package/plugins/runtime-modules/asset/data-providers.js +0 -40
  128. package/plugins/runtime-modules/asset/definition.d.ts +0 -60
  129. package/plugins/runtime-modules/asset/ids.d.ts +0 -1
  130. package/plugins/runtime-modules/asset/ids.js +1 -2
  131. package/plugins/runtime-modules/asset/presets.d.ts +1 -0
  132. package/plugins/runtime-modules/asset/server.js +0 -5
  133. package/plugins/runtime-modules/asset/services/collection.js +1 -0
  134. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -2
  135. package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +3 -0
  136. package/plugins/runtime-modules/blog/presets.d.ts +1 -0
  137. package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +4 -1
  138. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +13 -4
  139. package/plugins/runtime-modules/builder/clients/inspector-link-target-field.js +1 -1
  140. package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +14 -1
  141. package/plugins/runtime-modules/builder/clients/inspector-signal-section.js +2 -2
  142. package/plugins/runtime-modules/builder/clients/layout-inspector.js +1 -1
  143. package/plugins/runtime-modules/builder/clients/layout-scaffold-buttons.js +4 -4
  144. package/plugins/runtime-modules/builder/clients/layout-scaffold-overlays.js +1 -1
  145. package/plugins/runtime-modules/builder/clients/region-inspector.js +1 -1
  146. package/plugins/runtime-modules/builder/clients/region-visibility-fields.js +1 -1
  147. package/plugins/runtime-modules/builder/clients/shells-workspace.js +1 -1
  148. package/plugins/runtime-modules/builder/clients/structure-canvas.js +2 -2
  149. package/plugins/runtime-modules/builder/clients/widget-effects-editor.js +1 -1
  150. package/plugins/runtime-modules/builder/clients/widget-inspector.d.ts +4 -1
  151. package/plugins/runtime-modules/builder/clients/widget-inspector.js +3 -2
  152. package/plugins/runtime-modules/builder/offered-page-catalog.js +3 -3
  153. package/plugins/runtime-modules/builder/options-providers.js +7 -0
  154. package/plugins/runtime-modules/builder/page-presets.server.d.ts +6 -0
  155. package/plugins/runtime-modules/builder/page-presets.server.js +8 -0
  156. package/plugins/runtime-modules/builder/pages-workspace.js +12 -1
  157. package/plugins/runtime-modules/builder/render-root-node-scaffold.js +5 -5
  158. package/plugins/runtime-modules/builder/structure-dnd.js +2 -2
  159. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -3
  160. package/plugins/runtime-modules/builder/widgets/test-block/client.js +1 -1
  161. package/plugins/runtime-modules/content-entry-routes.d.ts +1 -0
  162. package/plugins/runtime-modules/contracts.js +41 -1
  163. package/plugins/runtime-modules/core/data-providers.d.ts +60 -0
  164. package/plugins/runtime-modules/core/data-providers.js +41 -0
  165. package/plugins/runtime-modules/core/definition.d.ts +98 -0
  166. package/plugins/runtime-modules/core/form-providers.d.ts +43 -0
  167. package/plugins/runtime-modules/core/server.js +5 -0
  168. package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +6 -3
  169. package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +6 -5
  170. package/plugins/runtime-modules/core/widgets/breadcrumb/plugin.js +1 -1
  171. package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +9 -1
  172. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +29 -3
  173. package/plugins/runtime-modules/core/widgets/button/config.d.ts +34 -0
  174. package/plugins/runtime-modules/core/widgets/button/config.js +16 -0
  175. package/plugins/runtime-modules/core/widgets/button/plugin.js +37 -6
  176. package/plugins/runtime-modules/core/widgets/card/config.d.ts +13 -2
  177. package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +3 -3
  178. package/plugins/runtime-modules/core/widgets/cascader/client.js +1 -1
  179. package/plugins/runtime-modules/core/widgets/cascader/config.d.ts +8 -2
  180. package/plugins/runtime-modules/core/widgets/cascader/config.js +22 -0
  181. package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +1 -1
  182. package/plugins/runtime-modules/core/widgets/description/config.d.ts +13 -2
  183. package/plugins/runtime-modules/core/widgets/description/editor.js +13 -13
  184. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +11 -0
  185. package/plugins/runtime-modules/core/widgets/gallery/authoring.js +12 -3
  186. package/plugins/runtime-modules/core/widgets/gallery/client.d.ts +4 -1
  187. package/plugins/runtime-modules/core/widgets/gallery/client.js +38 -21
  188. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +18 -0
  189. package/plugins/runtime-modules/core/widgets/gallery/config.js +24 -0
  190. package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +1 -1
  191. package/plugins/runtime-modules/core/widgets/gallery/server.js +11 -0
  192. package/plugins/runtime-modules/core/widgets/image/config.d.ts +35 -0
  193. package/plugins/runtime-modules/core/widgets/image/config.js +8 -0
  194. package/plugins/runtime-modules/core/widgets/image/plugin.js +19 -1
  195. package/plugins/runtime-modules/core/widgets/image/server.d.ts +3 -1
  196. package/plugins/runtime-modules/core/widgets/image/server.js +2 -2
  197. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +13 -0
  198. package/plugins/runtime-modules/core/widgets/markdown/config.js +8 -0
  199. package/plugins/runtime-modules/core/widgets/markdown/editor.js +7 -7
  200. package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
  201. package/plugins/runtime-modules/core/widgets/multi-select/config.d.ts +1 -1
  202. package/plugins/runtime-modules/core/widgets/record/authoring.js +1 -1
  203. package/plugins/runtime-modules/core/widgets/record/client.js +8 -2
  204. package/plugins/runtime-modules/core/widgets/record/config.js +4 -0
  205. package/plugins/runtime-modules/core/widgets/result/config.d.ts +11 -0
  206. package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +1 -1
  207. package/plugins/runtime-modules/core/widgets/select-box/config.d.ts +1 -1
  208. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +13 -0
  209. package/plugins/runtime-modules/core/widgets/simple-text/config.js +9 -0
  210. package/plugins/runtime-modules/core/widgets/simple-text/editor.js +1 -1
  211. package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +14 -1
  212. package/plugins/runtime-modules/core/widgets/slot-upload/authoring.js +2 -1
  213. package/plugins/runtime-modules/core/widgets/slot-upload/client.d.ts +3 -1
  214. package/plugins/runtime-modules/core/widgets/slot-upload/client.js +45 -24
  215. package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +12 -4
  216. package/plugins/runtime-modules/core/widgets/slot-upload/config.js +18 -1
  217. package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +4 -2
  218. package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +9 -3
  219. package/plugins/runtime-modules/core/widgets/slot-upload/server.js +17 -3
  220. package/plugins/runtime-modules/core/widgets/spacer/client.js +1 -1
  221. package/plugins/runtime-modules/core/widgets/steps/config.d.ts +1 -1
  222. package/plugins/runtime-modules/core/widgets/table/client.js +4 -4
  223. package/plugins/runtime-modules/core/widgets/table/config.d.ts +37 -0
  224. package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
  225. package/plugins/runtime-modules/descriptor-compiler.d.ts +11 -1
  226. package/plugins/runtime-modules/descriptor-compiler.js +57 -8
  227. package/plugins/runtime-modules/editor/presets.d.ts +1 -0
  228. package/plugins/runtime-modules/groups/definition.d.ts +1 -1
  229. package/plugins/runtime-modules/groups/forms.d.ts +18 -0
  230. package/plugins/runtime-modules/groups/forms.js +2 -2
  231. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +6 -4
  232. package/plugins/runtime-modules/localization/presets.d.ts +1 -0
  233. package/plugins/runtime-modules/news/presets.d.ts +1 -0
  234. package/plugins/runtime-modules/public/module.d.ts +1 -1
  235. package/plugins/runtime-modules/resolver.js +7 -0
  236. package/plugins/runtime-modules/revisions/presets.d.ts +1 -0
  237. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
  238. package/plugins/runtime-modules/theme/presets.d.ts +1 -0
  239. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +25 -2
  240. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +4 -2
  241. package/plugins/runtime-modules/user-management/controller/client.js +6 -1
  242. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +3 -3
  243. package/runtime-render-client.d.ts +1 -1
  244. package/runtime-render-client.js +2 -1
  245. package/server-helpers/cms-page-record.d.ts +26 -0
  246. package/server-helpers/cms-page-record.js +52 -0
  247. package/server-helpers/cms-request.js +48 -4
  248. package/server-helpers/record-fields.d.ts +62 -0
  249. package/server-helpers/record-fields.js +86 -0
  250. package/server-helpers/record-samples.d.ts +21 -0
  251. package/server-helpers/record-samples.js +49 -0
  252. package/styles/builder-scaffold.css +19 -19
  253. package/styles/controls.css +109 -109
  254. package/styles/gradients.css +23 -23
  255. package/styles/layout-affordances.css +15 -15
  256. package/styles/layout-authoring-scaffold.css +20 -20
  257. package/styles/layout.css +9 -9
  258. package/styles/root.css +4 -4
  259. package/styles/shell.css +48 -17
  260. package/theme/antd-css-var-contract.d.ts +86 -80
  261. package/theme/antd-css-var-contract.js +92 -81
  262. package/theme/phi-control-shape.d.ts +1 -1
  263. package/theme/phi-theme-gradients.d.ts +2 -2
  264. package/theme/phi-theme-gradients.js +14 -14
  265. package/theme/phi-theme-palette.d.ts +1 -1
  266. package/theme/phi-theme-palette.js +2 -2
  267. package/theme/phi-theme-tokens.d.ts +8 -5
  268. package/theme/phi-theme-tokens.js +59 -28
  269. package/theme/phi-theme.d.ts +14 -2
  270. package/theme/phi-theme.js +14 -1
  271. package/theme/phi-tokens.d.ts +5 -0
  272. package/theme/phi-tokens.js +9 -0
  273. package/types/cms-module-descriptors.d.ts +9 -0
  274. package/types/cms-plugins.d.ts +27 -1
  275. package/types/collection-provider.d.ts +7 -0
  276. package/types/core-widget-placements.d.ts +42 -0
  277. package/types/record-provider.d.ts +109 -1
  278. package/types/table-widget.d.ts +33 -1
  279. package/types/table-widget.js +1 -0
  280. package/types/tree-widget.d.ts +7 -0
  281. package/types/widget-runtime.d.ts +5 -0
  282. package/types.d.ts +1 -0
  283. /package/plugins/runtime-modules/{asset/services/folder-images.server.d.ts → core/services/media-folder-images.server.d.ts} +0 -0
  284. /package/plugins/runtime-modules/{asset/services/folder-images.server.js → core/services/media-folder-images.server.js} +0 -0
@@ -43,6 +43,7 @@ export function insertPhiPresetPageTarget(roots, target) {
43
43
  sourcePreset,
44
44
  ...(target.defaultPageFlags ? { defaultPageFlags: target.defaultPageFlags } : {}),
45
45
  ...(target.landingPage ? { landingPage: true } : {}),
46
+ ...(target.pageRecord ? { pageRecord: { providerKey: target.pageRecord.providerKey } } : {}),
46
47
  });
47
48
  return;
48
49
  }
@@ -64,6 +65,7 @@ export function insertPhiPresetPageTarget(roots, target) {
64
65
  sourcePreset,
65
66
  ...(target.defaultPageFlags ? { defaultPageFlags: target.defaultPageFlags } : {}),
66
67
  ...(target.landingPage ? { landingPage: true } : {}),
68
+ ...(target.pageRecord ? { pageRecord: { providerKey: target.pageRecord.providerKey } } : {}),
67
69
  });
68
70
  }
69
71
  /**
@@ -23,8 +23,8 @@ export declare const PHI_GLASS_LAYOUT_EFFECT_DEFINITIONS: {
23
23
  };
24
24
  export declare const PHI_SHADOW_DEFINITIONS: {
25
25
  readonly none: "none";
26
- readonly soft: "var(--ant-box-shadow-tertiary)";
27
- readonly strong: "var(--ant-box-shadow)";
26
+ readonly soft: "var(--phi-box-shadow-tertiary)";
27
+ readonly strong: "var(--phi-box-shadow)";
28
28
  };
29
29
  export declare function resolvePhiShadow(value: PhiShadow | null | undefined): CSSProperties["boxShadow"] | undefined;
30
30
  export declare function resolvePhiLayoutEffectStyle({ effect, background, }: {
@@ -0,0 +1,48 @@
1
+ import { type PhisPaymentMoney } from "@phis/contracts/payments";
2
+ /** The largest minor amount the contract carries. */
3
+ export declare const PHI_MINOR_AMOUNT_MAX = "9999999999999999";
4
+ /** The currency's exponent, or `undefined` for a code that is not an ISO 4217 currency a payment accepts. */
5
+ export declare function readPhiCurrencyExponent(currency: string): number | undefined;
6
+ export declare function isPhiMinorAmount(value: unknown): value is string;
7
+ /**
8
+ * A value a Provider handed over as an amount of money, or `null` where it is none: `{ currency, minor }`
9
+ * with a currency a payment accepts and `minor` as the contract writes it or as a safe non-negative
10
+ * integer, which is how a row out of JSON often carries it. The answer is always the contract's shape.
11
+ */
12
+ export declare function readPhiMoneyValue(value: unknown): PhisPaymentMoney | null;
13
+ /** `-1`, `0` or `1` as `left` is less than, equal to or more than `right`; both minor amounts. */
14
+ export declare function comparePhiMinorAmounts(left: string, right: string): number;
15
+ /**
16
+ * A major amount written with a point (`"19.9"`, `"19."`, `".5"`) as the minor amount it states, or
17
+ * `null` where it states none or one the contract cannot carry.
18
+ *
19
+ * A fraction longer than the currency has is rounded half up on its digits, the way the Control rounds
20
+ * it when the field is left: `"12.345"` francs are `"1235"` Rappen.
21
+ */
22
+ export declare function phiMajorToMinorAmount(major: string, exponent: number): string | null;
23
+ /**
24
+ * A major amount (`"1234.5"`) written the way the locale writes it, with as many places as the currency
25
+ * has: `1’234.50` in de-CH, `1.234,50` in de-DE, `1,234.50` in en.
26
+ *
27
+ * The whole part is formatted as a `bigint`, so no digit passes through a float; the fraction is the
28
+ * amount's own digits behind the locale's separator. What is not a major amount is returned as it came.
29
+ */
30
+ export declare function formatPhiMajorAmount(major: string, locale: string, exponent: number): string;
31
+ /**
32
+ * What somebody typed, in the locale's way of writing numbers, as a major amount with a point.
33
+ *
34
+ * Group separators and spaces are dropped. The decimal separator is the locale's, and the point or the
35
+ * comma is read as one too wherever the locale does not group with it: somebody in fr-CH who types
36
+ * `12.50` means twelve and a half, while in de-DE `1.250` is one thousand two hundred and fifty, as it
37
+ * would be written there. The result may still not be a number -- `"1.2.3"` -- and the Control then
38
+ * keeps the last amount it could read.
39
+ */
40
+ export declare function parsePhiLocaleAmount(text: string, locale: string): string;
41
+ /**
42
+ * Where the currency stands beside the number in the locale, and as what: its ISO code, which no
43
+ * reader confuses with another currency's the way `$` is confused, and which nobody translates.
44
+ */
45
+ export declare function resolvePhiCurrencyAffix(locale: string, currency: string): {
46
+ placement: "prefix" | "suffix";
47
+ text: string;
48
+ };
@@ -0,0 +1,131 @@
1
+ import { PHIS_PAYMENT_CURRENCY_EXPONENTS, phisMinorToMajorAmount } from "@phis/contracts/payments";
2
+ /*
3
+ * An amount of money as the contract keeps it and as a person reads it.
4
+ *
5
+ * The contract keeps minor units as a canonical integer string (`PhisPaymentMoney.minor`: `"1990"` for
6
+ * 19.90 francs), and a person reads major units written the way their language writes numbers. Between
7
+ * the two lies a power of ten that is the currency's (`PHIS_PAYMENT_CURRENCY_EXPONENTS`: two for the
8
+ * franc, none for the yen, three for the dinar) -- never a fixed hundred.
9
+ *
10
+ * Every conversion here is done on the digits. `12.35 * 100` is `1234.9999999999998` in a float, and a
11
+ * price rounded down by one Rappen on every save is not a rounding error anybody notices until the
12
+ * books do not add up. So a major amount is split at its point, the fraction padded to the exponent,
13
+ * and the digits joined; nothing is multiplied. The way back, and showing an amount as money, are the
14
+ * contract's (`phisMinorToMajorAmount`, `formatPhisMoney` in `@phis/contracts/payments`), so that a
15
+ * Table, a record and a shop write the same amount the same way.
16
+ */
17
+ /** A minor amount as phis-server accepts one (`requirePhisPaymentMinor`): no sign, no leading zero, 16 digits at most. */
18
+ const PHI_MINOR_AMOUNT_PATTERN = /^(0|[1-9][0-9]{0,15})$/u;
19
+ /** The largest minor amount the contract carries. */
20
+ export const PHI_MINOR_AMOUNT_MAX = "9999999999999999";
21
+ const PHI_MAJOR_AMOUNT_PATTERN = /^([0-9]*)(?:\.([0-9]*))?$/u;
22
+ /** The currency's exponent, or `undefined` for a code that is not an ISO 4217 currency a payment accepts. */
23
+ export function readPhiCurrencyExponent(currency) {
24
+ return Object.hasOwn(PHIS_PAYMENT_CURRENCY_EXPONENTS, currency) ? PHIS_PAYMENT_CURRENCY_EXPONENTS[currency] : undefined;
25
+ }
26
+ export function isPhiMinorAmount(value) {
27
+ return typeof value === "string" && PHI_MINOR_AMOUNT_PATTERN.test(value);
28
+ }
29
+ /**
30
+ * A value a Provider handed over as an amount of money, or `null` where it is none: `{ currency, minor }`
31
+ * with a currency a payment accepts and `minor` as the contract writes it or as a safe non-negative
32
+ * integer, which is how a row out of JSON often carries it. The answer is always the contract's shape.
33
+ */
34
+ export function readPhiMoneyValue(value) {
35
+ if (typeof value !== "object" || value === null || Array.isArray(value))
36
+ return null;
37
+ const { currency, minor } = value;
38
+ if (typeof currency !== "string" || readPhiCurrencyExponent(currency) === undefined)
39
+ return null;
40
+ const text = typeof minor === "number" && Number.isSafeInteger(minor) && minor >= 0 ? String(minor) : minor;
41
+ return isPhiMinorAmount(text) ? { currency, minor: text } : null;
42
+ }
43
+ /** `-1`, `0` or `1` as `left` is less than, equal to or more than `right`; both minor amounts. */
44
+ export function comparePhiMinorAmounts(left, right) {
45
+ const difference = BigInt(left) - BigInt(right);
46
+ return difference < 0n ? -1 : difference > 0n ? 1 : 0;
47
+ }
48
+ /**
49
+ * A major amount written with a point (`"19.9"`, `"19."`, `".5"`) as the minor amount it states, or
50
+ * `null` where it states none or one the contract cannot carry.
51
+ *
52
+ * A fraction longer than the currency has is rounded half up on its digits, the way the Control rounds
53
+ * it when the field is left: `"12.345"` francs are `"1235"` Rappen.
54
+ */
55
+ export function phiMajorToMinorAmount(major, exponent) {
56
+ const match = PHI_MAJOR_AMOUNT_PATTERN.exec(major.trim());
57
+ if (!match)
58
+ return null;
59
+ const whole = match[1] ?? "";
60
+ const fraction = match[2] ?? "";
61
+ if (whole === "" && fraction === "")
62
+ return null;
63
+ const kept = fraction.slice(0, exponent).padEnd(exponent, "0");
64
+ const roundsUp = fraction.length > exponent && fraction.charCodeAt(exponent) >= "5".charCodeAt(0);
65
+ const minor = (BigInt(`${whole}${kept}` || "0") + (roundsUp ? 1n : 0n)).toString();
66
+ return PHI_MINOR_AMOUNT_PATTERN.test(minor) ? minor : null;
67
+ }
68
+ const symbolsByLocale = new Map();
69
+ /** The locale's decimal and group separators, in Latin digits so that what is typed can be read back. */
70
+ function readPhiAmountSymbols(locale) {
71
+ const cached = symbolsByLocale.get(locale);
72
+ if (cached)
73
+ return cached;
74
+ const parts = new Intl.NumberFormat(locale, { numberingSystem: "latn" }).formatToParts(1234567.5);
75
+ const symbols = {
76
+ decimal: parts.find((part) => part.type === "decimal")?.value ?? ".",
77
+ group: parts.find((part) => part.type === "group")?.value ?? "",
78
+ };
79
+ symbolsByLocale.set(locale, symbols);
80
+ return symbols;
81
+ }
82
+ /**
83
+ * A major amount (`"1234.5"`) written the way the locale writes it, with as many places as the currency
84
+ * has: `1’234.50` in de-CH, `1.234,50` in de-DE, `1,234.50` in en.
85
+ *
86
+ * The whole part is formatted as a `bigint`, so no digit passes through a float; the fraction is the
87
+ * amount's own digits behind the locale's separator. What is not a major amount is returned as it came.
88
+ */
89
+ export function formatPhiMajorAmount(major, locale, exponent) {
90
+ const minor = phiMajorToMinorAmount(major, exponent);
91
+ if (minor === null)
92
+ return major;
93
+ const [whole = "0", fraction = ""] = phisMinorToMajorAmount(minor, exponent).split(".");
94
+ const formattedWhole = new Intl.NumberFormat(locale, { numberingSystem: "latn", maximumFractionDigits: 0 }).format(BigInt(whole));
95
+ return exponent === 0 ? formattedWhole : `${formattedWhole}${readPhiAmountSymbols(locale).decimal}${fraction}`;
96
+ }
97
+ /**
98
+ * What somebody typed, in the locale's way of writing numbers, as a major amount with a point.
99
+ *
100
+ * Group separators and spaces are dropped. The decimal separator is the locale's, and the point or the
101
+ * comma is read as one too wherever the locale does not group with it: somebody in fr-CH who types
102
+ * `12.50` means twelve and a half, while in de-DE `1.250` is one thousand two hundred and fifty, as it
103
+ * would be written there. The result may still not be a number -- `"1.2.3"` -- and the Control then
104
+ * keeps the last amount it could read.
105
+ */
106
+ export function parsePhiLocaleAmount(text, locale) {
107
+ const { decimal, group } = readPhiAmountSymbols(locale);
108
+ let result = "";
109
+ for (const character of text) {
110
+ if (character >= "0" && character <= "9") {
111
+ result += character;
112
+ }
113
+ else if (character === decimal || ((character === "." || character === ",") && character !== group)) {
114
+ result += ".";
115
+ }
116
+ }
117
+ return result;
118
+ }
119
+ /**
120
+ * Where the currency stands beside the number in the locale, and as what: its ISO code, which no
121
+ * reader confuses with another currency's the way `$` is confused, and which nobody translates.
122
+ */
123
+ export function resolvePhiCurrencyAffix(locale, currency) {
124
+ const parts = new Intl.NumberFormat(locale, { style: "currency", currency, currencyDisplay: "code" }).formatToParts(1);
125
+ const currencyIndex = parts.findIndex((part) => part.type === "currency");
126
+ const numberIndex = parts.findIndex((part) => part.type === "integer");
127
+ return {
128
+ placement: currencyIndex !== -1 && numberIndex !== -1 && currencyIndex > numberIndex ? "suffix" : "prefix",
129
+ text: parts[currencyIndex]?.value.trim() || currency,
130
+ };
131
+ }
@@ -7,7 +7,10 @@ import type { PhiResolvedCmsPageTree } from "../types/cms";
7
7
  * on what an author saves in the Builder: there the scale is what the Inspector offers, and a value off it
8
8
  * is the author's to choose.
9
9
  *
10
- * It reads the stated config only and resolves nothing: a distance is a step of `PHI_SPACE` or nothing.
10
+ * It reads the stated config only and resolves nothing: a distance is a step of `PHI_SPACE` or nothing, and
11
+ * a Layout's config is one its own parser takes -- a Grid of five columns is refused, for the Grid takes 1,
12
+ * 2, 3, 4 or 6, and on a live page a Layout whose config is refused is left out without a message. Widget
13
+ * configs are not parsed here; their parsers live with the Widgets.
11
14
  */
12
15
  export type PhiPageLayoutFinding = {
13
16
  /** The node's label, or its id where it has none. */
@@ -1,5 +1,6 @@
1
1
  import { PhiCmsRegionType } from "../constants/phi-cms";
2
- import { PHI_SPACE } from "../theme/antd-css-var-contract";
2
+ import { PHI_PAGE, PHI_SPACE } from "../theme/antd-css-var-contract";
3
+ import { parsePhiCmsCarouselLayoutConfig, parsePhiCmsCollapsibleLayoutConfig, parsePhiCmsContentLayoutConfig, parsePhiCmsFlexLayoutConfig, parsePhiCmsFlexVerticalLayoutConfig, parsePhiCmsGridLayoutConfig, parsePhiCmsMasonryLayoutConfig, parsePhiCmsSplitCardLayoutConfig, parsePhiCmsStackLayoutConfig, parsePhiCmsThreeColumnLayoutConfig, } from "../types/cms-config";
3
4
  import { readPhiSurface } from "../types/surface";
4
5
  const SPACING_KEYS = ["padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "gap"];
5
6
  const PADDING_KEYS = SPACING_KEYS.filter((key) => key !== "gap");
@@ -8,9 +9,29 @@ const PRESET_STEPS = ["xxs", "xs", "sm", "base", "md"];
8
9
  const EMPHASIS_STEPS = ["lg", "xl", "xxl"];
9
10
  /** Layouts that bring a padding of their own by default (LAYOUTING.md): stated, or they keep it. */
10
11
  const DEFAULT_PADDED_LAYOUTS = new Set(["grid", "masonry", "three-column"]);
12
+ /** The strict parser of each Layout type that has one in the contract layer (the plugins' `parseConfig`). */
13
+ const LAYOUT_CONFIG_PARSERS = {
14
+ content: parsePhiCmsContentLayoutConfig,
15
+ flex: parsePhiCmsFlexLayoutConfig,
16
+ "flex-vertical": parsePhiCmsFlexVerticalLayoutConfig,
17
+ masonry: parsePhiCmsMasonryLayoutConfig,
18
+ stack: parsePhiCmsStackLayoutConfig,
19
+ carousel: parsePhiCmsCarouselLayoutConfig,
20
+ collapsible: parsePhiCmsCollapsibleLayoutConfig,
21
+ grid: parsePhiCmsGridLayoutConfig,
22
+ "three-column": parsePhiCmsThreeColumnLayoutConfig,
23
+ "split-card": parsePhiCmsSplitCardLayoutConfig,
24
+ };
25
+ /*
26
+ * The Theme's Page inset (`PHI_PAGE.padding`, THEME.md "Page padding") is a step of the spacing scale per
27
+ * side and screen, chosen by the Theme: a distance like any other, at the preset level.
28
+ */
29
+ const PAGE_INSET_REFERENCES = new Set(Object.values(PHI_PAGE.padding));
11
30
  function stepOf(value) {
12
31
  if (value === 0 || value === "0")
13
32
  return "none";
33
+ if (PAGE_INSET_REFERENCES.has(value))
34
+ return "page";
14
35
  for (const [step, reference] of Object.entries(PHI_SPACE)) {
15
36
  if (value === reference)
16
37
  return step;
@@ -64,10 +85,28 @@ export function checkPhiPagePresetLayout(tree) {
64
85
  // A band under the Header keeps its sides on the small step without a Surface; nothing above or below.
65
86
  const headerBottomRootId = tree.regions
66
87
  .find((region) => region.regionType === PhiCmsRegionType.HeaderBottom)?.rootLayoutNodeId;
88
+ /*
89
+ * An Overlay's footer is the dialog's action row, built by `dialog` on `createPhiCmsPresetNodes` and held
90
+ * to its own contract by the descriptor compiler (OVERLAYS.md, "Structured dialogs"): its inset is the
91
+ * dialog's, not a Page Layout's, so the Surface rule below does not apply to it.
92
+ */
93
+ const overlayFooterIds = new Set(tree.overlays.flatMap((overlay) => overlay.footerLayoutNodeId == null ? [] : [overlay.footerLayoutNodeId]));
67
94
  for (const node of tree.layoutNodes) {
68
95
  const config = (node.config ?? {});
69
96
  const typeKey = typeKeyOf(node);
70
97
  const surface = readPhiSurface(config.surface);
98
+ const parse = Object.hasOwn(LAYOUT_CONFIG_PARSERS, typeKey) ? LAYOUT_CONFIG_PARSERS[typeKey] : undefined;
99
+ if (parse) {
100
+ try {
101
+ parse(config);
102
+ }
103
+ catch (error) {
104
+ findings.push({
105
+ node: nameOf(node),
106
+ message: `its config is refused: ${error instanceof Error ? error.message : String(error)}`,
107
+ });
108
+ }
109
+ }
71
110
  for (const key of SPACING_KEYS) {
72
111
  const value = config[key];
73
112
  if (value == null)
@@ -102,7 +141,7 @@ export function checkPhiPagePresetLayout(tree) {
102
141
  }
103
142
  continue;
104
143
  }
105
- if (!surface && typeKey !== "content") {
144
+ if (!surface && typeKey !== "content" && !overlayFooterIds.has(node.id)) {
106
145
  if (hasPadding(config)) {
107
146
  findings.push({
108
147
  node: nameOf(node),
@@ -0,0 +1,22 @@
1
+ import type { PhiRuntimeModuleCatalogEntry } from "../types/cms-plugins";
2
+ import type { PhiRuntimeDataProviderKey } from "../types/runtime-data-provider";
3
+ import type { PhiRecordDeclaration, PhiRecordField, PhiRecordFieldKind, PhiRecordFieldValueByKind } from "../types/record-provider";
4
+ /** `value` as a field of `kind`, or `undefined` where it is not one. */
5
+ export declare function readPhiRecordFieldValue<K extends PhiRecordFieldKind>(kind: K, value: unknown): PhiRecordFieldValueByKind[K] | undefined;
6
+ /**
7
+ * The kinds a line of text can show: a text as it is, a number, a date and an amount of money in the
8
+ * page's language.
9
+ */
10
+ export declare const PHI_RECORD_TEXT_FIELD_KINDS: readonly ["text", "number", "date", "money"];
11
+ /**
12
+ * A text, number, date or money field as the words a page shows, written for `locale`; a date on the
13
+ * calendar of the Site's `timeZone`, as every other date the page shows (`formatPhiDate`).
14
+ */
15
+ export declare function formatPhiRecordFieldText(field: Extract<PhiRecordField, {
16
+ kind: (typeof PHI_RECORD_TEXT_FIELD_KINDS)[number];
17
+ }>, locale: string, timeZone: string): string;
18
+ /**
19
+ * The declarations of the `record` Providers these Modules describe, by key: what a render's registry
20
+ * answers a record's fields from (`recordDeclarationsByKey`).
21
+ */
22
+ export declare function buildPhiRecordDeclarationsByKey(entries: readonly Pick<PhiRuntimeModuleCatalogEntry, "definition">[]): ReadonlyMap<PhiRuntimeDataProviderKey, PhiRecordDeclaration>;
@@ -0,0 +1,109 @@
1
+ import { formatPhisMoney } from "@phis/contracts/payments";
2
+ import { formatPhiDate } from "./format-date-time";
3
+ import { isPhiMinorAmount, readPhiCurrencyExponent } from "./money-amount";
4
+ /*
5
+ * A record field's value, checked against its declared kind (`types/record-provider.ts`).
6
+ *
7
+ * A Module hands these over and a Core Widget draws them unseen, so the kind is the whole agreement: a
8
+ * value that is not of its kind answers `undefined` and is not drawn.
9
+ */
10
+ function isRecord(value) {
11
+ return typeof value === "object" && value !== null && !Array.isArray(value);
12
+ }
13
+ /** An address a record may name: absolute over http(s), or Site-relative. Never a scheme of its own. */
14
+ function readAddress(value) {
15
+ if (typeof value !== "string")
16
+ return undefined;
17
+ const address = value.trim();
18
+ return /^https?:\/\//iu.test(address) || (address.startsWith("/") && !address.startsWith("//")) ? address : undefined;
19
+ }
20
+ function readPicture(value) {
21
+ if (!isRecord(value))
22
+ return undefined;
23
+ const src = readAddress(value.src);
24
+ if (!src)
25
+ return undefined;
26
+ return typeof value.alt === "string" && value.alt ? { src, alt: value.alt } : { src };
27
+ }
28
+ const TAG_TONES = ["default", "success", "warning", "error"];
29
+ function readTag(value) {
30
+ if (!isRecord(value) || typeof value.label !== "string" || !value.label.trim())
31
+ return undefined;
32
+ if (value.tone === undefined)
33
+ return { label: value.label };
34
+ return typeof value.tone === "string" && TAG_TONES.includes(value.tone)
35
+ ? { label: value.label, tone: value.tone }
36
+ : undefined;
37
+ }
38
+ function readLink(value) {
39
+ if (!isRecord(value))
40
+ return undefined;
41
+ const href = readAddress(value.href);
42
+ if (!href)
43
+ return undefined;
44
+ return typeof value.label === "string" && value.label ? { href, label: value.label } : { href };
45
+ }
46
+ /** The contract's money exactly: a currency a payment accepts and `minor` as an integer string. */
47
+ function readMoney(value) {
48
+ if (!isRecord(value) || typeof value.currency !== "string" || readPhiCurrencyExponent(value.currency) === undefined) {
49
+ return undefined;
50
+ }
51
+ return isPhiMinorAmount(value.minor) ? { currency: value.currency, minor: value.minor } : undefined;
52
+ }
53
+ function readAll(value, read) {
54
+ if (!Array.isArray(value))
55
+ return undefined;
56
+ const entries = value.map(read);
57
+ return entries.every((entry) => entry !== undefined) ? entries : undefined;
58
+ }
59
+ export function readPhiRecordFieldValue(kind, value) {
60
+ switch (kind) {
61
+ case "text":
62
+ case "markdown":
63
+ return typeof value === "string" ? value : undefined;
64
+ case "picture":
65
+ return readPicture(value);
66
+ case "pictures":
67
+ return readAll(value, readPicture);
68
+ case "list":
69
+ return readAll(value, (entry) => (typeof entry === "string" ? entry : undefined));
70
+ case "tag":
71
+ return readTag(value);
72
+ case "date":
73
+ return typeof value === "string" && !Number.isNaN(Date.parse(value)) ? value : undefined;
74
+ case "number":
75
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
76
+ case "money":
77
+ return readMoney(value);
78
+ case "link":
79
+ return readLink(value);
80
+ }
81
+ }
82
+ /**
83
+ * The kinds a line of text can show: a text as it is, a number, a date and an amount of money in the
84
+ * page's language.
85
+ */
86
+ export const PHI_RECORD_TEXT_FIELD_KINDS = ["text", "number", "date", "money"];
87
+ /**
88
+ * A text, number, date or money field as the words a page shows, written for `locale`; a date on the
89
+ * calendar of the Site's `timeZone`, as every other date the page shows (`formatPhiDate`).
90
+ */
91
+ export function formatPhiRecordFieldText(field, locale, timeZone) {
92
+ switch (field.kind) {
93
+ case "text":
94
+ return field.value;
95
+ case "number":
96
+ return new Intl.NumberFormat(locale).format(field.value);
97
+ case "date":
98
+ return formatPhiDate(field.value, locale, timeZone);
99
+ case "money":
100
+ return formatPhisMoney(field.value, locale);
101
+ }
102
+ }
103
+ /**
104
+ * The declarations of the `record` Providers these Modules describe, by key: what a render's registry
105
+ * answers a record's fields from (`recordDeclarationsByKey`).
106
+ */
107
+ export function buildPhiRecordDeclarationsByKey(entries) {
108
+ return new Map(entries.flatMap((entry) => (entry.definition.dataProviders ?? []).flatMap((provider) => provider.kind === "record" && provider.record ? [[provider.key, provider.record]] : [])));
109
+ }
@@ -11,7 +11,7 @@ export declare const PHI_SURFACE_CARD: {
11
11
  readonly background: {
12
12
  readonly base: {
13
13
  readonly kind: "color";
14
- readonly color: "var(--ant-color-bg-container)";
14
+ readonly color: "var(--phi-color-bg-container)";
15
15
  };
16
16
  readonly overlay: null;
17
17
  readonly filter: null;
@@ -20,7 +20,7 @@ export declare const PHI_SURFACE_CARD: {
20
20
  readonly border: {
21
21
  readonly borderWidth: 1;
22
22
  readonly borderStyle: "solid";
23
- readonly borderColor: "var(--ant-color-border-secondary)";
23
+ readonly borderColor: "var(--phi-color-border-secondary)";
24
24
  };
25
25
  readonly shadow: "soft";
26
26
  };
@@ -33,7 +33,7 @@ export declare const PHI_SURFACE_WASH: {
33
33
  readonly background: {
34
34
  readonly base: {
35
35
  readonly kind: "color";
36
- readonly color: "var(--ant-color-fill-quaternary)";
36
+ readonly color: "var(--phi-color-fill-quaternary)";
37
37
  };
38
38
  readonly overlay: null;
39
39
  readonly filter: null;
@@ -46,7 +46,7 @@ export declare const PHI_SURFACE_PRESETS: {
46
46
  readonly background: {
47
47
  readonly base: {
48
48
  readonly kind: "color";
49
- readonly color: "var(--ant-color-bg-container)";
49
+ readonly color: "var(--phi-color-bg-container)";
50
50
  };
51
51
  readonly overlay: null;
52
52
  readonly filter: null;
@@ -55,7 +55,7 @@ export declare const PHI_SURFACE_PRESETS: {
55
55
  readonly border: {
56
56
  readonly borderWidth: 1;
57
57
  readonly borderStyle: "solid";
58
- readonly borderColor: "var(--ant-color-border-secondary)";
58
+ readonly borderColor: "var(--phi-color-border-secondary)";
59
59
  };
60
60
  readonly shadow: "soft";
61
61
  };
@@ -63,7 +63,7 @@ export declare const PHI_SURFACE_PRESETS: {
63
63
  readonly background: {
64
64
  readonly base: {
65
65
  readonly kind: "color";
66
- readonly color: "var(--ant-color-fill-quaternary)";
66
+ readonly color: "var(--phi-color-fill-quaternary)";
67
67
  };
68
68
  readonly overlay: null;
69
69
  readonly filter: null;
@@ -51,7 +51,7 @@ export type PhiSurfaceStyleOptions = {
51
51
  groundLayer?: boolean;
52
52
  };
53
53
  /** The ground a toned Surface paints where it states none: the container ground of the tone's mode. */
54
- export declare const PHI_SURFACE_TONE_GROUND = "var(--ant-color-bg-container)";
54
+ export declare const PHI_SURFACE_TONE_GROUND = "var(--phi-color-bg-container)";
55
55
  /**
56
56
  * Whether a Surface takes its tone's ground (`PHI_SURFACE_TONE_GROUND`): it asks for a mode of its own and
57
57
  * its Background paints nothing. A stated ground wins, and the Theme's Overlay (`base.kind: "theme"`) is
package/helpers.d.ts CHANGED
@@ -10,7 +10,6 @@ export * from "./helpers/widget-dimension-plugin-fields";
10
10
  export * from "./helpers/translation-format";
11
11
  export { buildPhiCmsLayoutNode, buildPhiCmsWidgetNode, } from "./helpers/cms-node-factories";
12
12
  export * from "./helpers/cms-preset-nodes";
13
- export { checkPhiPagePresetLayout, type PhiPageLayoutFinding } from "./helpers/page-layout-check";
14
13
  export * from "./helpers/cms-dialog";
15
14
  export { buildPhiSettingsPageShellTree, type PhiSettingsPageShellFormSection, type PhiSettingsPageShellOverlay, type PhiSettingsPageShellPanel, type PhiSettingsPageShellSection, type PhiSettingsPageShellWidgetSection, } from "./components/regions/presets/phi-settings-page-shell-tree";
16
15
  export * from "./helpers/format-date-time";
package/helpers.js CHANGED
@@ -10,8 +10,6 @@ export * from "./helpers/widget-dimension-plugin-fields";
10
10
  export * from "./helpers/translation-format";
11
11
  export { buildPhiCmsLayoutNode, buildPhiCmsWidgetNode, } from "./helpers/cms-node-factories";
12
12
  export * from "./helpers/cms-preset-nodes";
13
- /* The Page rule as a check, for a package to run over the trees its presets build (THIRD_PARTY_MODULES.md 6b). */
14
- export { checkPhiPagePresetLayout } from "./helpers/page-layout-check";
15
13
  export * from "./helpers/cms-dialog";
16
14
  /*
17
15
  * The one Settings page shell (SETTINGS.md section 4). Public because the contract holds for every
@@ -0,0 +1,12 @@
1
+ /**
2
+ * What a Module package needs to check its own preset Pages in its own verify step, and nothing else
3
+ * (THIRD_PARTY_MODULES.md, "Checking a Page preset").
4
+ *
5
+ * Narrow because it is verify-time tooling: it carries the Layout config parsers, which a Site's runtime
6
+ * must not load for this. A package runs the check in its own tests over the trees its route presets
7
+ * build, and treats a finding as an error; it is never called while a Site serves a request, and so it is
8
+ * never part of `@phis/ui/helpers`.
9
+ *
10
+ * No `server-only` here, on purpose: a test in a package loads this door without a mock.
11
+ */
12
+ export { checkPhiPagePresetLayout, type PhiPageLayoutFinding } from "./helpers/page-layout-check";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * What a Module package needs to check its own preset Pages in its own verify step, and nothing else
3
+ * (THIRD_PARTY_MODULES.md, "Checking a Page preset").
4
+ *
5
+ * Narrow because it is verify-time tooling: it carries the Layout config parsers, which a Site's runtime
6
+ * must not load for this. A package runs the check in its own tests over the trees its route presets
7
+ * build, and treats a finding as an error; it is never called while a Site serves a request, and so it is
8
+ * never part of `@phis/ui/helpers`.
9
+ *
10
+ * No `server-only` here, on purpose: a test in a package loads this door without a mock.
11
+ */
12
+ export { checkPhiPagePresetLayout } from "./helpers/page-layout-check";
@@ -6,7 +6,10 @@
6
6
  * Server half every route of the Site imports. A Provider's resolver is the package's own function; the
7
7
  * types say what it is asked with, `fetchPhiSiteApi` asks Core with the credentials the context carries,
8
8
  * and `resolvePhiRecordSource` is how one of the package's Server Widgets reads the record its binding
9
- * names -- once per request, however many Widgets are bound to it.
9
+ * names -- once per request, however many Widgets are bound to it. `resolvePhiPageRecordFields` reads the
10
+ * declared fields of the record the Page is about, through the same read; `readPhiPageRecordField` picks
11
+ * one of them by kind, and `resolvePhiWidgetRecordField` is the whole step a bound Widget takes -- the
12
+ * same one Core's own Widgets take.
10
13
  *
11
14
  * `PhiWidgetFailureServer` is what such a Widget renders when that read, or its binding, fails: the error
12
15
  * card in the Builder, nothing on a live page, and the `cms.widget.unavailable` warning either way. It is
@@ -14,8 +17,10 @@
14
17
  * in `@phis/ui/runtime/data-provider-client`.
15
18
  */
16
19
  import "server-only";
17
- export type { PhiRuntimeModuleRecordProviderServerDefinition, PhiRuntimeRecordProviderContext, PhiRuntimeRecordProviderResolver, } from "./types/record-provider";
20
+ export type { PhiRecordFieldKind } from "./constants/record-field-kinds";
21
+ export type { PhiRecordField, PhiRecordFieldValueByKind, PhiRecordLink, PhiRecordPicture, PhiRecordSample, PhiRecordTag, PhiRuntimeModuleRecordProviderServerDefinition, PhiRuntimeRecordFieldsReader, PhiRuntimeRecordProviderContext, PhiRuntimeRecordProviderResolver, PhiRuntimeRecordSamplesReader, } from "./types/record-provider";
18
22
  export { resolvePhiRecordSource, type PhiRecordSourceResult } from "./server-helpers/record-source";
23
+ export { readPhiPageRecordField, resolvePhiPageRecordFields, resolvePhiWidgetRecordField, type PhiPageRecordFieldsResult, type PhiWidgetRecordField, } from "./server-helpers/record-fields";
19
24
  export { fetchPhiSiteApi, type PhiSiteApiRequest } from "./gateway/site-api-request";
20
25
  export { PhiWidgetFailureServer } from "./components/widgets/shared/widget-failure.server";
21
26
  export type { PhiWidgetFailureProps } from "./components/widgets/shared/widget-failure";
package/module-records.js CHANGED
@@ -6,7 +6,10 @@
6
6
  * Server half every route of the Site imports. A Provider's resolver is the package's own function; the
7
7
  * types say what it is asked with, `fetchPhiSiteApi` asks Core with the credentials the context carries,
8
8
  * and `resolvePhiRecordSource` is how one of the package's Server Widgets reads the record its binding
9
- * names -- once per request, however many Widgets are bound to it.
9
+ * names -- once per request, however many Widgets are bound to it. `resolvePhiPageRecordFields` reads the
10
+ * declared fields of the record the Page is about, through the same read; `readPhiPageRecordField` picks
11
+ * one of them by kind, and `resolvePhiWidgetRecordField` is the whole step a bound Widget takes -- the
12
+ * same one Core's own Widgets take.
10
13
  *
11
14
  * `PhiWidgetFailureServer` is what such a Widget renders when that read, or its binding, fails: the error
12
15
  * card in the Builder, nothing on a live page, and the `cms.widget.unavailable` warning either way. It is
@@ -15,5 +18,6 @@
15
18
  */
16
19
  import "server-only";
17
20
  export { resolvePhiRecordSource } from "./server-helpers/record-source";
21
+ export { readPhiPageRecordField, resolvePhiPageRecordFields, resolvePhiWidgetRecordField, } from "./server-helpers/record-fields";
18
22
  export { fetchPhiSiteApi } from "./gateway/site-api-request";
19
23
  export { PhiWidgetFailureServer } from "./components/widgets/shared/widget-failure.server";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A build-time patch for one line of Ant Design 6.7 (`antd/es/form/context.js`), applied by the Turbopack
3
+ * rule `withPhiNextConfig` sets (next/config.mjs). Remove it, the rule and the export once Ant Design
4
+ * imports the Form provider directly (TODOS.md, "At the next release").
5
+ *
6
+ * Since 6.7.0 every Button reads the Form's variant (`form/hooks/useVariants` -> `form/context`), and that
7
+ * file takes `FormProvider` from `@rc-component/form`'s entry, which declares no `sideEffects` and assigns
8
+ * statics on import -- so each page with a Button loaded the whole Form engine and `async-validator`
9
+ * (about 42 kB). `FormContext` is where the provider lives and imports React alone.
10
+ *
11
+ * Exact text only: a file that reads differently is left as it is, with a warning, so a changed Ant Design
12
+ * is never patched by guesswork.
13
+ */
14
+ export const PHI_ANTD_FORM_CONTEXT_IMPORT = "import { FormProvider as RcFormProvider } from '@rc-component/form';";
15
+ export const PHI_ANTD_FORM_CONTEXT_PATCHED_IMPORT =
16
+ "import { FormProvider as RcFormProvider } from '@rc-component/form/es/FormContext';";
17
+
18
+ export function patchPhiAntdFormContext(source) {
19
+ const occurrences = source.split(PHI_ANTD_FORM_CONTEXT_IMPORT).length - 1;
20
+ return occurrences === 1 ? source.replace(PHI_ANTD_FORM_CONTEXT_IMPORT, PHI_ANTD_FORM_CONTEXT_PATCHED_IMPORT) : null;
21
+ }
22
+
23
+ export default function phiAntdFormContextLoader(source) {
24
+ const patched = patchPhiAntdFormContext(source);
25
+ if (patched !== null) return patched;
26
+ this.emitWarning?.(new Error(
27
+ "@phis/ui: antd/es/form/context.js no longer reads as Ant Design 6.7.0 wrote it; the Form provider patch "
28
+ + "was not applied. Check whether Ant Design imports the provider directly now and remove the patch.",
29
+ ));
30
+ return source;
31
+ }
package/next/config.d.mts CHANGED
@@ -17,6 +17,8 @@ export declare function ensurePhiAntdStaticCss(projectDir?: string): string;
17
17
 
18
18
  /** The host in `config/site-runtime.json`'s `site.publicUrl` under `dir`, or `null` where there is none. */
19
19
  export declare function readPhiSitePublicHost(dir?: string): string | null;
20
+ /** The Turbopack rule patching Ant Design 6.7's Form context import, or `null` for any other Ant Design. */
21
+ export declare function readPhiAntdFormContextPatchRule(dir?: string): Record<string, unknown> | null;
20
22
 
21
23
  /**
22
24
  * A Site's `next.config`, with `@phis/ui/antd-static.css` resolved to the structure generated for its