@phis/ui 0.4.3 → 0.4.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 (282) hide show
  1. package/README.md +9 -3
  2. package/cms/plugins.d.ts +1 -0
  3. package/cms/plugins.js +2 -0
  4. package/components/cms/phi-cms-root-layout.js +30 -1
  5. package/components/controls/phi-anchor-nav-control.js +4 -1
  6. package/components/controls/phi-background-control.d.ts +6 -1
  7. package/components/controls/phi-background-control.js +30 -7
  8. package/components/controls/phi-bullet-list-control.d.ts +7 -2
  9. package/components/controls/phi-bullet-list-control.js +4 -3
  10. package/components/controls/phi-button-control.d.ts +13 -1
  11. package/components/controls/phi-button-control.js +21 -3
  12. package/components/controls/phi-color-control.js +4 -2
  13. package/components/controls/phi-drawer-control-adapter.js +3 -2
  14. package/components/controls/phi-dropdown-control.js +2 -2
  15. package/components/controls/phi-inline-text-editor.js +7 -1
  16. package/components/controls/phi-length-control.js +1 -1
  17. package/components/controls/phi-media-asset-tile-control.js +10 -10
  18. package/components/controls/phi-progress-control.d.ts +10 -2
  19. package/components/controls/phi-progress-control.js +6 -2
  20. package/components/controls/phi-ribbon-control.d.ts +16 -4
  21. package/components/controls/phi-ribbon-control.js +14 -8
  22. package/components/controls/phi-ribbon-wrap-control.d.ts +32 -0
  23. package/components/controls/phi-ribbon-wrap-control.js +31 -0
  24. package/components/controls/phi-segmented-control.d.ts +4 -1
  25. package/components/controls/phi-segmented-control.js +13 -2
  26. package/components/controls/phi-select-control.js +5 -2
  27. package/components/controls/phi-series-chart-control.d.ts +48 -0
  28. package/components/controls/phi-series-chart-control.js +82 -0
  29. package/components/controls/phi-surface-control.d.ts +2 -0
  30. package/components/controls/phi-surface-control.js +16 -1
  31. package/components/controls/phi-switch-control.d.ts +4 -1
  32. package/components/controls/phi-switch-control.js +8 -2
  33. package/components/controls/phi-tag-control.d.ts +4 -1
  34. package/components/controls/phi-tag-control.js +11 -3
  35. package/components/controls/phi-text-control.js +57 -3
  36. package/components/controls/phi-tree-control.js +1 -1
  37. package/components/controls/phi-truncated-hover-text.d.ts +15 -0
  38. package/components/controls/phi-truncated-hover-text.js +25 -0
  39. package/components/forms/link-target-form-control.d.ts +1 -1
  40. package/components/forms/link-target-form-control.js +2 -45
  41. package/components/forms/phi-form-widget-frame.js +4 -2
  42. package/components/layouts/clients/phi-three-column-layout-client.js +10 -1
  43. package/components/layouts/phi-layout-view-model.js +10 -1
  44. package/components/navigation/phi-link.js +6 -1
  45. package/components/regions/clients/cms-region-container-client.js +16 -1
  46. package/components/regions/phi-cms-region-container.js +7 -0
  47. package/components/regions/phi-cms-region-shell.d.ts +22 -1
  48. package/components/regions/phi-cms-region-shell.js +131 -23
  49. package/components/root/phi-config-provider.d.ts +13 -0
  50. package/components/root/phi-config-provider.js +12 -1
  51. package/components/root/phi-root-background.d.ts +7 -0
  52. package/components/root/phi-root-background.js +20 -1
  53. package/components/root/phi-root-layout.d.ts +1 -0
  54. package/components/root/phi-root-layout.js +1 -0
  55. package/components/root/phi-root-theme-resolver.js +15 -1
  56. package/components/root/phi-shell-chrome-overlay.d.ts +18 -1
  57. package/components/root/phi-shell-chrome-overlay.js +26 -4
  58. package/components/runtime/runtime-module-context.d.ts +12 -1
  59. package/components/runtime/runtime-module-context.js +6 -1
  60. package/components/shell/phi-antd-icon.d.ts +1 -0
  61. package/components/shell/phi-antd-icon.js +3 -0
  62. package/components/shell/phi-cms-shell.d.ts +7 -1
  63. package/components/shell/phi-cms-shell.js +4 -2
  64. package/components/shell/use-phi-shell-header-bands.d.ts +5 -0
  65. package/components/shell/use-phi-shell-header-bands.js +64 -0
  66. package/components/shell/use-phi-shell-sticky-bottom.d.ts +18 -0
  67. package/components/shell/use-phi-shell-sticky-bottom.js +54 -0
  68. package/components/shell/use-phi-shell-sticky-top.js +61 -16
  69. package/components/surface/phi-surface-tone.d.ts +13 -0
  70. package/components/surface/phi-surface-tone.js +21 -0
  71. package/components/tables/client/phi-table-binding.d.ts +1 -0
  72. package/components/tables/client/phi-table-binding.js +22 -3
  73. package/components/trees/client/phi-tree-binding.d.ts +1 -0
  74. package/components/trees/client/phi-tree-binding.js +11 -2
  75. package/components/widgets/client/bullet-list-entries-editor.js +7 -1
  76. package/components/widgets/client/html-editor.js +1 -1
  77. package/components/widgets/client/shared/phi-collection-provider.js +4 -3
  78. package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
  79. package/components/widgets/client/shared/phi-collection-view-binding.js +16 -2
  80. package/components/widgets/client/shared/phi-command-buttons.js +6 -2
  81. package/components/widgets/client/shared/use-page-reference-options.d.ts +17 -0
  82. package/components/widgets/client/shared/use-page-reference-options.js +57 -0
  83. package/components/widgets/config/background.d.ts +52 -1
  84. package/components/widgets/config/background.js +85 -4
  85. package/components/widgets/config/button-variant.d.ts +22 -4
  86. package/components/widgets/config/button-variant.js +24 -5
  87. package/components/widgets/config/common-action-field.d.ts +1 -1
  88. package/components/widgets/config/parser-primitives.js +4 -2
  89. package/components/widgets/config/theme-gradient.d.ts +11 -0
  90. package/components/widgets/config/theme-gradient.js +12 -0
  91. package/components/widgets/label-sets/background.js +4 -0
  92. package/components/widgets/label-sets/geometry.js +2 -0
  93. package/components/widgets/label-sets/inspector.js +4 -0
  94. package/components/widgets/label-types/background.d.ts +2 -0
  95. package/components/widgets/label-types/background.js +2 -0
  96. package/components/widgets/label-types/common-controls.js +2 -2
  97. package/components/widgets/label-types/geometry.d.ts +1 -0
  98. package/components/widgets/label-types/geometry.js +1 -0
  99. package/components/widgets/label-types/inspector.d.ts +4 -0
  100. package/components/widgets/label-types/inspector.js +2 -0
  101. package/components/widgets/shared/bullet-list-vocabulary.d.ts +10 -0
  102. package/components/widgets/shared/bullet-list-vocabulary.js +5 -2
  103. package/components/widgets/shared/card-body-client.d.ts +16 -3
  104. package/components/widgets/shared/card-body-client.js +79 -8
  105. package/components/widgets/shared/card-vocabulary.d.ts +12 -2
  106. package/components/widgets/shared/card-vocabulary.js +7 -0
  107. package/components/widgets/shared/collection-source-failure.d.ts +26 -0
  108. package/components/widgets/shared/collection-source-failure.js +42 -0
  109. package/components/widgets/shared/markdown-body-client.js +39 -10
  110. package/components/widgets/shared/markdown-render.js +16 -3
  111. package/components/widgets/shared/widget-failure-client.d.ts +10 -0
  112. package/components/widgets/shared/widget-failure-client.js +20 -0
  113. package/components/widgets/shared/widget-failure.d.ts +31 -0
  114. package/components/widgets/shared/widget-failure.js +20 -0
  115. package/components/widgets/shared/widget-failure.server.d.ts +9 -0
  116. package/components/widgets/shared/widget-failure.server.js +12 -0
  117. package/gateway/dashboard-card-memo.d.ts +3 -0
  118. package/gateway/dashboard-card-memo.js +25 -0
  119. package/helpers/cms-container-chrome.js +6 -1
  120. package/helpers/cms-region-keys.d.ts +1 -1
  121. package/helpers/layout-style.d.ts +8 -4
  122. package/helpers/layout-style.js +3 -2
  123. package/helpers/locale.d.ts +8 -0
  124. package/helpers/locale.js +18 -0
  125. package/helpers/mode-paint.d.ts +4 -0
  126. package/helpers/mode-paint.js +47 -0
  127. package/helpers/shell-region-style.js +2 -1
  128. package/helpers/surface-style.d.ts +12 -1
  129. package/helpers/surface-style.js +60 -12
  130. package/module-dashboard-cards.d.ts +2 -1
  131. package/module-dashboard-cards.js +2 -1
  132. package/module-records.d.ts +7 -0
  133. package/module-records.js +6 -0
  134. package/package.json +1 -1
  135. package/plugins/runtime-modules/area-definitions.d.ts +0 -42
  136. package/plugins/runtime-modules/area-definitions.js +3 -8
  137. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +21 -2
  138. package/plugins/runtime-modules/builder/clients/inspector-surface-labels.js +1 -0
  139. package/plugins/runtime-modules/builder/clients/layout-scaffold-overlays.js +10 -5
  140. package/plugins/runtime-modules/builder/clients/region-inspector.js +47 -2
  141. package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +1 -1
  142. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +7 -4
  143. package/plugins/runtime-modules/builder/controller/page-controller.js +7 -0
  144. package/plugins/runtime-modules/builder/edit-scaffold-drawer.js +3 -2
  145. package/plugins/runtime-modules/builder/persistence.d.ts +3 -0
  146. package/plugins/runtime-modules/builder/persistence.js +9 -1
  147. package/plugins/runtime-modules/builder/render-root-node-scaffold.js +25 -15
  148. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +4 -0
  149. package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +15 -4
  150. package/plugins/runtime-modules/client-authoring-module.d.ts +8 -1
  151. package/plugins/runtime-modules/client-authoring-module.js +13 -3
  152. package/plugins/runtime-modules/core/content-entries/record-source.server.d.ts +3 -1
  153. package/plugins/runtime-modules/core/content-entries/record-source.server.js +7 -4
  154. package/plugins/runtime-modules/core/widgets/brand/client.d.ts +12 -3
  155. package/plugins/runtime-modules/core/widgets/brand/client.js +3 -11
  156. package/plugins/runtime-modules/core/widgets/brand/home.d.ts +15 -0
  157. package/plugins/runtime-modules/core/widgets/brand/home.js +18 -0
  158. package/plugins/runtime-modules/core/widgets/brand/plugin.js +3 -2
  159. package/plugins/runtime-modules/core/widgets/brand/server.d.ts +2 -2
  160. package/plugins/runtime-modules/core/widgets/brand/server.js +2 -2
  161. package/plugins/runtime-modules/core/widgets/button/client.js +2 -2
  162. package/plugins/runtime-modules/core/widgets/button/config.d.ts +40 -4
  163. package/plugins/runtime-modules/core/widgets/button/config.js +12 -0
  164. package/plugins/runtime-modules/core/widgets/card/config.d.ts +100 -1
  165. package/plugins/runtime-modules/core/widgets/card/config.js +57 -3
  166. package/plugins/runtime-modules/core/widgets/card/editor.js +21 -4
  167. package/plugins/runtime-modules/core/widgets/card/server.js +5 -0
  168. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +4 -1
  169. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -3
  170. package/plugins/runtime-modules/core/widgets/collection-view/authoring.js +1 -1
  171. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +3 -0
  172. package/plugins/runtime-modules/core/widgets/collection-view/client.js +47 -11
  173. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +4 -1
  174. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
  175. package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +3 -2
  176. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +6 -1
  177. package/plugins/runtime-modules/core/widgets/collection-view/server.js +21 -3
  178. package/plugins/runtime-modules/core/widgets/description/client.js +3 -3
  179. package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -0
  180. package/plugins/runtime-modules/core/widgets/description/editor.js +3 -2
  181. package/plugins/runtime-modules/core/widgets/description/server.js +3 -2
  182. package/plugins/runtime-modules/core/widgets/entry-detail/plugin.js +1 -1
  183. package/plugins/runtime-modules/core/widgets/entry-detail/server.d.ts +3 -1
  184. package/plugins/runtime-modules/core/widgets/entry-detail/server.js +5 -2
  185. package/plugins/runtime-modules/core/widgets/entry-header/plugin.js +1 -1
  186. package/plugins/runtime-modules/core/widgets/entry-header/server.d.ts +3 -1
  187. package/plugins/runtime-modules/core/widgets/entry-header/server.js +5 -2
  188. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -0
  189. package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -1
  190. package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +6 -3
  191. package/plugins/runtime-modules/core/widgets/entry-list/server.js +13 -6
  192. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -0
  193. package/plugins/runtime-modules/core/widgets/gallery/plugin.js +1 -1
  194. package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -3
  195. package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -6
  196. package/plugins/runtime-modules/core/widgets/header-navigation/client.js +2 -2
  197. package/plugins/runtime-modules/core/widgets/html/client.js +1 -1
  198. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +320 -2
  199. package/plugins/runtime-modules/core/widgets/markdown/config.js +18 -4
  200. package/plugins/runtime-modules/core/widgets/markdown/editor.js +9 -1
  201. package/plugins/runtime-modules/core/widgets/markdown-toc/client.js +6 -1
  202. package/plugins/runtime-modules/core/widgets/markdown-toc/config.d.ts +14 -0
  203. package/plugins/runtime-modules/core/widgets/markdown-toc/config.js +14 -2
  204. package/plugins/runtime-modules/core/widgets/quick-links/authoring.js +7 -2
  205. package/plugins/runtime-modules/core/widgets/quick-links/client.js +2 -2
  206. package/plugins/runtime-modules/core/widgets/quick-links/items.d.ts +0 -2
  207. package/plugins/runtime-modules/core/widgets/quick-links/items.js +0 -15
  208. package/plugins/runtime-modules/core/widgets/record/client.d.ts +4 -1
  209. package/plugins/runtime-modules/core/widgets/record/client.js +8 -3
  210. package/plugins/runtime-modules/core/widgets/record/plugin.js +3 -2
  211. package/plugins/runtime-modules/core/widgets/record/server.d.ts +3 -1
  212. package/plugins/runtime-modules/core/widgets/record/server.js +2 -2
  213. package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -0
  214. package/plugins/runtime-modules/core/widgets/segmented/client.js +1 -1
  215. package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +21 -1
  216. package/plugins/runtime-modules/core/widgets/segmented/config.js +11 -1
  217. package/plugins/runtime-modules/core/widgets/sidebar-navigation/authoring.js +1 -1
  218. package/plugins/runtime-modules/core/widgets/sidebar-navigation/client.js +1 -1
  219. package/plugins/runtime-modules/core/widgets/simple-text/client.js +8 -3
  220. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
  221. package/plugins/runtime-modules/core/widgets/simple-text/editor.js +2 -2
  222. package/plugins/runtime-modules/core/widgets/switch/client.js +1 -1
  223. package/plugins/runtime-modules/core/widgets/switch/config.d.ts +19 -0
  224. package/plugins/runtime-modules/core/widgets/switch/config.js +11 -0
  225. package/plugins/runtime-modules/core/widgets/table/authoring.js +1 -1
  226. package/plugins/runtime-modules/core/widgets/table/client.d.ts +4 -1
  227. package/plugins/runtime-modules/core/widgets/table/client.js +16 -3
  228. package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -0
  229. package/plugins/runtime-modules/core/widgets/table/plugin.js +3 -2
  230. package/plugins/runtime-modules/core/widgets/table/server.d.ts +3 -1
  231. package/plugins/runtime-modules/core/widgets/table/server.js +2 -2
  232. package/plugins/runtime-modules/core/widgets/table/static-resource-editor.js +2 -1
  233. package/plugins/runtime-modules/core/widgets/timeline/authoring.js +1 -1
  234. package/plugins/runtime-modules/core/widgets/timeline/client.d.ts +1 -3
  235. package/plugins/runtime-modules/core/widgets/timeline/client.js +14 -4
  236. package/plugins/runtime-modules/core/widgets/tree/authoring.js +1 -1
  237. package/plugins/runtime-modules/core/widgets/tree/client.d.ts +4 -1
  238. package/plugins/runtime-modules/core/widgets/tree/client.js +13 -2
  239. package/plugins/runtime-modules/core/widgets/tree/plugin.js +3 -2
  240. package/plugins/runtime-modules/core/widgets/tree/server.d.ts +3 -1
  241. package/plugins/runtime-modules/core/widgets/tree/server.js +2 -2
  242. package/plugins/runtime-modules/dashboard/card-rows.d.ts +3 -1
  243. package/plugins/runtime-modules/dashboard/card-rows.js +30 -2
  244. package/plugins/runtime-modules/dashboard/clients/dashboard-card-view.js +29 -7
  245. package/plugins/runtime-modules/dashboard/trees/phi-default-builder-dashboard-page-tree.js +5 -40
  246. package/plugins/runtime-modules/theme/presets.d.ts +9 -1
  247. package/plugins/runtime-modules/theme/tour.d.ts +9 -1
  248. package/plugins/runtime-modules/theme/tour.js +10 -1
  249. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +157 -22
  250. package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +5 -9
  251. package/runtime-data-provider-client.d.ts +2 -0
  252. package/runtime-data-provider-client.js +7 -0
  253. package/server-helpers/cms-link-targets.js +6 -0
  254. package/styles/controls.css +74 -7
  255. package/styles/gradients.css +101 -0
  256. package/styles/layout.css +45 -2
  257. package/styles/root.css +18 -0
  258. package/styles/shell.css +137 -0
  259. package/theme/phi-antd-token-resolver.js +20 -1
  260. package/theme/phi-button-shadow.d.ts +6 -0
  261. package/theme/phi-theme-gradients.d.ts +96 -0
  262. package/theme/phi-theme-gradients.js +245 -0
  263. package/theme/phi-theme-presets.d.ts +3 -0
  264. package/theme/phi-theme-presets.js +3 -0
  265. package/theme/phi-theme-tokens.d.ts +6 -2
  266. package/theme/phi-theme-tokens.js +15 -0
  267. package/theme/phi-theme.d.ts +5 -0
  268. package/theme/phi-theme.js +21 -0
  269. package/theme/phi-tokens.d.ts +16 -15
  270. package/theme/phi-tokens.js +16 -15
  271. package/types/cms-plugins.d.ts +2 -0
  272. package/types/cms-presets.d.ts +7 -0
  273. package/types/core-widget-placements.d.ts +3 -0
  274. package/types/dashboard-cards.d.ts +39 -4
  275. package/types/dashboard-cards.js +6 -0
  276. package/types/layout-style.d.ts +9 -8
  277. package/types/layout-style.js +9 -8
  278. package/types/site-theme.d.ts +10 -2
  279. package/types/surface.d.ts +4 -0
  280. package/types/surface.js +4 -0
  281. package/types.d.ts +1 -1
  282. package/types.js +1 -1
@@ -0,0 +1,42 @@
1
+ /*
2
+ * What a Collection binding that does not hold says, in one wording wherever it is found out: by the
3
+ * live binding against the providers the Area mounted, and by the Builder against the descriptors the
4
+ * Area's Modules declare. An author who reads one in the Builder finds the same line in the log of the
5
+ * live page.
6
+ */
7
+ export const PhiCollectionSourceFailureText = {
8
+ notConfigured: () => "Collection data provider is not configured.",
9
+ providerUnavailable: (providerKey) => `Collection provider "${providerKey}" is not available from the active runtime modules.`,
10
+ resourceUnavailable: (resourceKey, providerKey) => `Collection resource "${resourceKey}" is not available from provider "${providerKey}".`,
11
+ rendererUnavailable: (rendererKey) => `Item renderer "${rendererKey}" is not available from the active runtime modules.`,
12
+ };
13
+ /**
14
+ * Why a Collection View cannot draw, as far as that is known without asking the source anything.
15
+ *
16
+ * This is what the Builder can say: it never reads the data, so a read that would fail is not its to
17
+ * find out, but a binding to a provider no active Module declares, a resource that provider does not
18
+ * have, or an item renderer nobody offers is plain from the declarations alone.
19
+ *
20
+ * `itemRendererKeys` is the set of renderers the Area's Modules declare, or null where the caller does
21
+ * not have it -- and then a renderer the configuration names is not judged at all rather than judged
22
+ * against nothing. The renderer a resource ships with is never judged: it belongs to the provider just
23
+ * found active.
24
+ */
25
+ export function readPhiCollectionViewDeclaredFailure({ source, itemRendererKey, dataProviderDescriptorsByKey, itemRendererKeys, }) {
26
+ if (!source) {
27
+ return PhiCollectionSourceFailureText.notConfigured();
28
+ }
29
+ const descriptor = dataProviderDescriptorsByKey.get(source.providerKey);
30
+ if (!descriptor || descriptor.kind !== "collection") {
31
+ return PhiCollectionSourceFailureText.providerUnavailable(source.providerKey);
32
+ }
33
+ const resource = descriptor.resources.find((entry) => entry.resourceKey === source.resourceKey);
34
+ if (!resource) {
35
+ return PhiCollectionSourceFailureText.resourceUnavailable(source.resourceKey, source.providerKey);
36
+ }
37
+ if (itemRendererKey && itemRendererKey !== resource.itemRendererKey && itemRendererKeys &&
38
+ !itemRendererKeys.has(itemRendererKey)) {
39
+ return PhiCollectionSourceFailureText.rendererUnavailable(itemRendererKey);
40
+ }
41
+ return null;
42
+ }
@@ -68,9 +68,16 @@ function renderInlineNodes(inlines) {
68
68
  }
69
69
  });
70
70
  }
71
- function renderBlocks(blocks, token, paragraphBlockStyle, headingBlockStyle, lists) {
71
+ function renderBlocks(blocks, token, paragraphStyle, headingStyle, lists, atStart = false) {
72
72
  return blocks.map((block, index) => {
73
73
  const key = `${block.kind}-${index}`;
74
+ /*
75
+ * The first block of a text, or of a quote, keeps no space before it: the space before a block
76
+ * parts it from the block above, and there is none -- the Widget's own edge stands there.
77
+ */
78
+ const leading = atStart && index === 0;
79
+ const paragraphBlockStyle = leading ? { ...paragraphStyle, marginBlockStart: 0 } : paragraphStyle;
80
+ const headingBlockStyle = leading ? { ...headingStyle, paddingBlockStart: 0 } : headingStyle;
74
81
  switch (block.kind) {
75
82
  case "heading":
76
83
  return (_jsx(PhiTypographyControl, { presentation: "title", id: block.id, level: block.level, style: headingBlockStyle, children: renderInlineNodes(block.inlines) }, key));
@@ -81,19 +88,31 @@ function renderBlocks(blocks, token, paragraphBlockStyle, headingBlockStyle, lis
81
88
  margin: 0,
82
89
  paddingInlineStart: PHI_SPACE.md,
83
90
  borderInlineStart: `3px solid ${token.colorBorderSecondary}`,
84
- }, children: _jsx("div", { style: { display: "grid", gap: 0 }, children: renderBlocks(block.children, token, paragraphBlockStyle, headingBlockStyle, lists) }) }, key));
91
+ }, children: _jsx("div", { style: { display: "grid", gap: 0 }, children: renderBlocks(block.children, token, paragraphStyle, headingStyle, lists, true) }) }, key));
85
92
  case "list":
86
93
  /*
87
94
  * The house's list, set by the Widget's list settings. A `1.` list counts whatever its level's
88
95
  * marker says: the numbers are the text's, not a look. A list inside an entry is one level down.
89
96
  */
90
- return (_jsx(PhiBulletListControl, { listStyle: lists.style, depth: lists.depth, ordered: block.ordered, start: block.start, items: block.items.map((itemBlocks) => ({
91
- content: (_jsx("div", { style: { display: "grid", gap: PHI_SPACE.xs, minWidth: 0 }, children: renderBlocks(itemBlocks, token, paragraphBlockStyle, headingBlockStyle, { ...lists, depth: lists.depth + 1 }) })),
97
+ return (_jsx(PhiBulletListControl, { listStyle: lists.style, depth: lists.depth, ordered: block.ordered, start: block.start,
98
+ /*
99
+ * The list stands among the text's blocks as a paragraph does: the entries draw close, but the
100
+ * block after the last one keeps the text's spacing. A list inside an entry gets the entry's
101
+ * zeroed spacing, so it sits in its entry's grid.
102
+ */
103
+ blockSpacing: {
104
+ marginBlockStart: paragraphBlockStyle.marginBlockStart,
105
+ marginBlockEnd: paragraphBlockStyle.marginBlockEnd,
106
+ }, items: block.items.map((itemBlocks) => ({
107
+ content: (_jsx("div", { style: { display: "grid", gap: PHI_SPACE.xs, minWidth: 0 }, children: renderBlocks(itemBlocks, token, { ...paragraphStyle, marginBlockStart: 0, marginBlockEnd: 0 }, headingStyle, { ...lists, depth: lists.depth + 1 }) })),
92
108
  })) }, key));
93
109
  case "code":
94
110
  return (_jsx("pre", { "data-phi-code-language": block.language ?? undefined, style: {
95
111
  margin: 0,
96
- padding: PHI_SPACE.md,
112
+ // A code block stands among the text's blocks as a paragraph does, with the text's spacing.
113
+ marginBlockStart: paragraphBlockStyle.marginBlockStart,
114
+ marginBlockEnd: paragraphBlockStyle.marginBlockEnd,
115
+ padding: PHI_SPACE.base,
97
116
  overflowX: "auto",
98
117
  borderRadius: token.borderRadiusSM,
99
118
  background: token.colorFillQuaternary,
@@ -157,15 +176,25 @@ export function PhiMarkdownWidgetClient({ config }) {
157
176
  marginBlockStart: resolvePhiSpacingScaleValue(config?.textBlockSpacingBefore ?? "none"),
158
177
  marginBlockEnd: resolvePhiSpacingScaleValue(config?.textBlockSpacingAfter ?? "sm"),
159
178
  };
179
+ /*
180
+ * The space before a heading is padding, not margin, so it adds to the space after the block above
181
+ * however the text is laid out: in the grid margins never collapse, in the flow that pictures need
182
+ * they would, and the same setting would part a heading from its paragraph by less there.
183
+ */
160
184
  const headingBlockStyle = {
161
185
  margin: 0,
162
- marginBlockStart: resolvePhiSpacingScaleValue(config?.headingBlockSpacingBefore ?? "none"),
186
+ paddingBlockStart: resolvePhiSpacingScaleValue(config?.headingBlockSpacingBefore ?? "sm"),
163
187
  marginBlockEnd: resolvePhiSpacingScaleValue(config?.headingBlockSpacingAfter ?? "sm"),
164
188
  };
165
- return (_jsx("div", { className: config?.imageFloat ? `phi-markdown-body phi-markdown-body--float-${config.imageFloat}` : undefined, style: config?.imageFloat
166
- ? { display: "flow-root", width: "100%", textAlign: config.textAlign, containerType: "inline-size" }
167
- : { display: "grid", gap: 0, width: "100%", textAlign: config?.textAlign }, children: renderBlocks(blocks, token, paragraphBlockStyle, headingBlockStyle, {
189
+ return (_jsx("div", { className: config?.imageFloat
190
+ ? `phi-markdown-text phi-markdown-body phi-markdown-body--float-${config.imageFloat}`
191
+ : "phi-markdown-text",
192
+ // The text's line height for everything in it, lists included: a list entry otherwise takes the
193
+ // browser's `normal`, and its marker centres on a line shorter than the one its words stand on.
194
+ style: config?.imageFloat
195
+ ? { display: "flow-root", width: "100%", textAlign: config.textAlign, containerType: "inline-size", lineHeight: token.lineHeight }
196
+ : { display: "grid", gap: 0, width: "100%", textAlign: config?.textAlign, lineHeight: token.lineHeight }, children: renderBlocks(blocks, token, paragraphBlockStyle, headingBlockStyle, {
168
197
  style: resolvePhiBulletListStyle(config?.list),
169
198
  depth: 1,
170
- }) }));
199
+ }, true) }));
171
200
  }
@@ -77,11 +77,24 @@ function resolveExternalDocumentUrl(value, sourceUrl) {
77
77
  return null;
78
78
  }
79
79
  }
80
- function projectExternalMarkdownNodes(nodes, sourceUrl) {
80
+ /*
81
+ * The address a reader is sent to for the document the text was fetched from. GitHub serves a file's
82
+ * bytes on one host and its page on another; the bytes are what the Widget reads and what a picture
83
+ * needs, but a link in the text means the page -- a neighbouring document opened as raw text in a new
84
+ * tab is the source, not the document. Any other host is its own page.
85
+ */
86
+ function readExternalDocumentPageUrl(sourceUrl) {
87
+ const githubRawMatch = sourceUrl.match(/^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)\/(.+)$/u);
88
+ if (!githubRawMatch)
89
+ return sourceUrl;
90
+ const [, owner, repo, ref, path] = githubRawMatch;
91
+ return `https://github.com/${owner}/${repo}/blob/${ref}/${path}`;
92
+ }
93
+ function projectExternalMarkdownNodes(nodes, sourceUrl, pageUrl = readExternalDocumentPageUrl(sourceUrl)) {
81
94
  return (nodes ?? []).flatMap((node) => {
82
- const children = projectExternalMarkdownNodes(node.children, sourceUrl);
95
+ const children = projectExternalMarkdownNodes(node.children, sourceUrl, pageUrl);
83
96
  if (node.type === "link") {
84
- const url = resolveExternalDocumentUrl(node.url ?? "", sourceUrl);
97
+ const url = resolveExternalDocumentUrl(node.url ?? "", pageUrl);
85
98
  return url ? [{ ...node, url, children }] : children;
86
99
  }
87
100
  if (node.type === "image") {
@@ -0,0 +1,10 @@
1
+ import { type PhiWidgetFailureProps } from "./widget-failure";
2
+ /**
3
+ * A Widget's data or configuration failure, found in the browser -- a Provider the Area does not offer,
4
+ * a read that failed after hydration.
5
+ *
6
+ * The warning is written from an effect, once for each distinct failure while the Widget stays mounted:
7
+ * a Client re-renders for reasons that have nothing to do with the failure, and a line per render would
8
+ * bury the one that matters. See `PhiWidgetFailureProps` for what counts and who sees it.
9
+ */
10
+ export declare function PhiWidgetFailure(props: PhiWidgetFailureProps): import("react").JSX.Element | null;
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { useEffect, useEffectEvent } from "react";
3
+ import { logPhiWidgetFailure, renderPhiWidgetFailureNotice } from "./widget-failure";
4
+ /**
5
+ * A Widget's data or configuration failure, found in the browser -- a Provider the Area does not offer,
6
+ * a read that failed after hydration.
7
+ *
8
+ * The warning is written from an effect, once for each distinct failure while the Widget stays mounted:
9
+ * a Client re-renders for reasons that have nothing to do with the failure, and a line per render would
10
+ * bury the one that matters. See `PhiWidgetFailureProps` for what counts and who sees it.
11
+ */
12
+ export function PhiWidgetFailure(props) {
13
+ const { renderMode, widgetType, widgetId, title, description } = props;
14
+ // `error` is read, not watched: it is a new object whenever the same failure is raised again.
15
+ const log = useEffectEvent(() => logPhiWidgetFailure(props));
16
+ useEffect(() => {
17
+ log();
18
+ }, [description, renderMode, title, widgetId, widgetType]);
19
+ return renderPhiWidgetFailureNotice(props);
20
+ }
@@ -0,0 +1,31 @@
1
+ import type { PhiCmsInstanceId } from "../../../types/cms-instance-id";
2
+ import type { PhiRenderableBlockRenderMode } from "../../../types/renderable-block";
3
+ /**
4
+ * A Widget that cannot show what it was placed to show, because its data or its configuration failed:
5
+ * the Provider it is bound to is not offered, the binding does not hold, the record cannot be read, the
6
+ * renderer it names is gone, the read itself failed.
7
+ *
8
+ * Said to the person who can do something about it, as the renderer says an unrenderable block
9
+ * (`renderCmsDiagnostic`). In the Builder that is the author, and the card stands in the Widget's own
10
+ * place with the cause. On a live page -- a revision preview is one -- it is nobody: a visitor cannot
11
+ * rebind a Provider, and a heading over an error, or over an empty frame, reads as a broken Site or as
12
+ * one that published nothing. So the Widget is absent and the rest of the page stands. The warning is
13
+ * written either way, which is where an operator finds it.
14
+ *
15
+ * What a visitor is meant to read -- a form's own answer, an empty state, a refusal addressed to them --
16
+ * is content, not a failure, and does not come here.
17
+ */
18
+ export type PhiWidgetFailureProps = {
19
+ renderMode: PhiRenderableBlockRenderMode;
20
+ /** The Widget type, as the log names it; the card does not, the author already knows what they placed. */
21
+ widgetType: string;
22
+ widgetId?: PhiCmsInstanceId | null;
23
+ title: string;
24
+ description?: string | null;
25
+ /** What was thrown, for the log only; the card says `title` and `description`. */
26
+ error?: unknown;
27
+ };
28
+ export declare const PHI_WIDGET_FAILURE_LOG_EVENT = "cms.widget.unavailable";
29
+ export declare function logPhiWidgetFailure({ renderMode, widgetType, widgetId, title, description, error, }: PhiWidgetFailureProps): void;
30
+ /** The card itself, or nothing on a live page. Both variants draw through this, so they cannot drift. */
31
+ export declare function renderPhiWidgetFailureNotice({ renderMode, widgetType, widgetId, title, description, }: PhiWidgetFailureProps): import("react").JSX.Element | null;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { logRuntimeEvent } from "../../../net/log";
3
+ import { PhiAlertControl } from "../../controls/phi-alert-control";
4
+ export const PHI_WIDGET_FAILURE_LOG_EVENT = "cms.widget.unavailable";
5
+ export function logPhiWidgetFailure({ renderMode, widgetType, widgetId, title, description, error, }) {
6
+ logRuntimeEvent("warn", PHI_WIDGET_FAILURE_LOG_EVENT, {
7
+ message: `Widget "${widgetType}" is unavailable: ${title}${description ? ` ${description}` : ""}`,
8
+ targetType: "widget",
9
+ targetId: widgetId == null ? null : String(widgetId),
10
+ error,
11
+ meta: { widgetType, title, description: description ?? null, renderMode },
12
+ });
13
+ }
14
+ /** The card itself, or nothing on a live page. Both variants draw through this, so they cannot drift. */
15
+ export function renderPhiWidgetFailureNotice({ renderMode, widgetType, widgetId, title, description, }) {
16
+ if (renderMode === "live") {
17
+ return null;
18
+ }
19
+ return (_jsx("div", { "data-phi-widget-failure": widgetType, "data-phi-widget-failure-id": widgetId == null ? undefined : String(widgetId), children: _jsx(PhiAlertControl, { level: "error", showIcon: true, title: title, description: description ?? undefined }) }));
20
+ }
@@ -0,0 +1,9 @@
1
+ import "server-only";
2
+ import { type PhiWidgetFailureProps } from "./widget-failure";
3
+ /**
4
+ * A Widget's data or configuration failure, decided while the page is drawn on the server.
5
+ *
6
+ * The warning is written here, during the render, because this render happens once per request and on
7
+ * the machine whose log an operator reads. See `PhiWidgetFailureProps` for what counts and who sees it.
8
+ */
9
+ export declare function PhiWidgetFailureServer(props: PhiWidgetFailureProps): import("react").JSX.Element | null;
@@ -0,0 +1,12 @@
1
+ import "server-only";
2
+ import { logPhiWidgetFailure, renderPhiWidgetFailureNotice } from "./widget-failure";
3
+ /**
4
+ * A Widget's data or configuration failure, decided while the page is drawn on the server.
5
+ *
6
+ * The warning is written here, during the render, because this render happens once per request and on
7
+ * the machine whose log an operator reads. See `PhiWidgetFailureProps` for what counts and who sees it.
8
+ */
9
+ export function PhiWidgetFailureServer(props) {
10
+ logPhiWidgetFailure(props);
11
+ return renderPhiWidgetFailureNotice(props);
12
+ }
@@ -0,0 +1,3 @@
1
+ import "server-only";
2
+ import type { PhiDashboardCardContext } from "../types/dashboard-cards";
3
+ export declare function definePhiDashboardCardRead<TResult>(load: (context: PhiDashboardCardContext) => Promise<TResult>): (context: PhiDashboardCardContext) => Promise<TResult>;
@@ -0,0 +1,25 @@
1
+ import "server-only";
2
+ /*
3
+ * A read that several cards of one Dashboard ask for, done once for that Dashboard.
4
+ *
5
+ * The cards of a list request are resolved side by side in a Route Handler, which is outside a render,
6
+ * so `definePhiRequestMemo` (React's request scope) loads every time there. What they do share is the
7
+ * card context: the route resolves it once and hands the same object to every card it resolves. Keying
8
+ * by that object is the request scope a card has -- four cards reading one Add-on route make one call,
9
+ * and a card refreshed on its own gets a fresh context and so a fresh read. Nothing outlives the
10
+ * context, so nothing goes stale.
11
+ *
12
+ * `load` must answer from the context alone; anything else a card wants to vary belongs in its own call.
13
+ * A rejected load stays rejected for that context, so every card sharing the read reports the same error.
14
+ */
15
+ export function definePhiDashboardCardRead(load) {
16
+ const reads = new WeakMap();
17
+ return (context) => {
18
+ let result = reads.get(context);
19
+ if (!result) {
20
+ result = load(context);
21
+ reads.set(context, result);
22
+ }
23
+ return result;
24
+ };
25
+ }
@@ -9,7 +9,12 @@ import { resolvePhiSurfaceStyle } from "./surface-style";
9
9
  * would show through as the default after all.
10
10
  */
11
11
  export function resolvePhiCmsContainerSurface(config) {
12
- const resolved = resolvePhiSurfaceStyle(config.surface, { groundLayer: false });
12
+ /*
13
+ * An Overlay draws no tone -- neither the class nor the scope -- so it does not paint a tone's ground
14
+ * either: without the class the ground would be the page's, laid over the Overlay's own.
15
+ */
16
+ const surface = config.surface?.tone ? { ...config.surface, tone: undefined } : config.surface;
17
+ const resolved = resolvePhiSurfaceStyle(surface, { groundLayer: false });
13
18
  const background = config.surface?.background
14
19
  ? normalizePhiBackgroundWidgetConfig(config.surface.background)
15
20
  : null;
@@ -33,5 +33,5 @@ export declare function resolvePhiCmsRegionOwnership(regionKey: string | null |
33
33
  * know is not a placement anybody chose -- refusing it would hide Widgets over a typo.
34
34
  */
35
35
  export declare function phiCmsRegionAcceptsWidget(regionKey: string | null | undefined, required: PhiCmsRegionOwnership | null | undefined): boolean;
36
- export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 10 | 40 | 12 | 50 | 11 | 20 | 21 | 25 | 30 | 39 | 41;
36
+ export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 11 | 10 | 40 | 12 | 50 | 20 | 21 | 25 | 30 | 39 | 41;
37
37
  export declare function resolvePhiCmsRegionKey(regionType: number | null | undefined): "content" | "header_top" | "header_main" | "header_bottom" | "sider_left" | "sider_right" | "hero" | "footer_top" | "footer_main" | "footer_bottom" | "drawer_right" | undefined;
@@ -8,13 +8,17 @@ import { type PhiGlassLayoutEffectId, type PhiShadow } from "../types/layout-sty
8
8
  * window that is dirty rather than glass that is lighter.
9
9
  */
10
10
  export declare const PHI_GLASS_LAYOUT_EFFECT_DEFINITIONS: {
11
+ readonly clear: {
12
+ readonly filter: "blur(14px) saturate(1.6) brightness(1.08)";
13
+ readonly strengthPercent: 22;
14
+ };
11
15
  readonly glass: {
12
- readonly filter: "blur(24px) saturate(1.2)";
13
- readonly strengthPercent: 36;
16
+ readonly filter: "blur(28px) saturate(1.3)";
17
+ readonly strengthPercent: 34;
14
18
  };
15
19
  readonly haze: {
16
- readonly filter: "blur(10px) saturate(1.1)";
17
- readonly strengthPercent: 60;
20
+ readonly filter: "blur(48px) saturate(1.2)";
21
+ readonly strengthPercent: 48;
18
22
  };
19
23
  };
20
24
  export declare const PHI_SHADOW_DEFINITIONS: {
@@ -8,8 +8,9 @@ import {} from "../types/layout-style";
8
8
  * window that is dirty rather than glass that is lighter.
9
9
  */
10
10
  export const PHI_GLASS_LAYOUT_EFFECT_DEFINITIONS = {
11
- glass: { filter: "blur(24px) saturate(1.2)", strengthPercent: 36 },
12
- haze: { filter: "blur(10px) saturate(1.1)", strengthPercent: 60 },
11
+ clear: { filter: "blur(14px) saturate(1.6) brightness(1.08)", strengthPercent: 22 },
12
+ glass: { filter: "blur(28px) saturate(1.3)", strengthPercent: 34 },
13
+ haze: { filter: "blur(48px) saturate(1.2)", strengthPercent: 48 },
13
14
  };
14
15
  function resolvePhiGlassBackground(background, strengthPercent) {
15
16
  const base = typeof background === "string" && background.trim()
@@ -31,6 +31,14 @@ export declare function isPhiLocaleReadableAsSource(locale: string, source: stri
31
31
  export declare function resolvePhiTranslationLocale(input: string | null | undefined): string;
32
32
  export declare function normalizeLocale(input: string | null | undefined, options?: NormalizeLocaleOptions): SiteLocale;
33
33
  export declare function localizePath(locale: SiteLocale | string, targetPath: string): string;
34
+ /**
35
+ * A Public path in the language being read, unless it already names one.
36
+ *
37
+ * A path stored without a locale (`/home`) gets `locale` in front, as `/` does; one whose first segment
38
+ * is one of the Site's locales (`/de/home`) and an external URL stay as they are. The locales are needed
39
+ * to tell a locale segment from a page, which `matchPhiLocalePrefixSegment` does.
40
+ */
41
+ export declare function localizePathUnlessLocalized(locale: SiteLocale | string, targetPath: string, availableLocales: readonly string[]): string;
34
42
  /**
35
43
  * The path for a staff Area, which carries no locale prefix.
36
44
  *
package/helpers/locale.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PHI_CMS_AREA_KEYS } from "../constants/cms-areas";
2
+ import { isPhiExternalHref } from "./external-href";
2
3
  export { PHI_CANONICAL_SOURCE_LOCALE } from "@phis/contracts/locale";
3
4
  import { PHI_CANONICAL_SOURCE_LOCALE } from "@phis/contracts/locale";
4
5
  export const SUPPORTED_CMS_AREAS = PHI_CMS_AREA_KEYS;
@@ -117,6 +118,23 @@ function prefixPath(prefix, targetPath) {
117
118
  export function localizePath(locale, targetPath) {
118
119
  return prefixPath(locale, targetPath);
119
120
  }
121
+ /**
122
+ * A Public path in the language being read, unless it already names one.
123
+ *
124
+ * A path stored without a locale (`/home`) gets `locale` in front, as `/` does; one whose first segment
125
+ * is one of the Site's locales (`/de/home`) and an external URL stay as they are. The locales are needed
126
+ * to tell a locale segment from a page, which `matchPhiLocalePrefixSegment` does.
127
+ */
128
+ export function localizePathUnlessLocalized(locale, targetPath, availableLocales) {
129
+ if (isPhiExternalHref(targetPath)) {
130
+ return targetPath;
131
+ }
132
+ const firstSegment = targetPath.split("/").filter(Boolean)[0];
133
+ if (firstSegment && matchPhiLocalePrefixSegment(firstSegment, { availableLocales })) {
134
+ return targetPath;
135
+ }
136
+ return localizePath(locale, targetPath);
137
+ }
120
138
  /**
121
139
  * The path for a staff Area, which carries no locale prefix.
122
140
  *
@@ -0,0 +1,4 @@
1
+ import type { CSSProperties } from "react";
2
+ /** One value per mode, as one CSS value the page's mode picks from. */
3
+ export declare function resolvePhiModeValue(light: string, dark: string): string;
4
+ export declare function composePhiModePaint(light: CSSProperties, dark: CSSProperties): CSSProperties;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A paint that differs between the page's light and dark mode, as one inline style.
3
+ *
4
+ * A Surface may state a ground per mode (`PhiSurface.backgroundDark`). The server does not know which
5
+ * mode a visitor sees, and the mode switch only turns `data-phi-theme-mode` on the Root Layout without
6
+ * rendering the page again, so the choice has to be made by CSS. Each property that differs is written
7
+ * as two gated values: `styles/root.css` sets one gate empty and the other to the guaranteed-invalid
8
+ * value, so `var(--phi-mode-light-gate, DARK) var(--phi-mode-dark-gate, LIGHT)` reads as `LIGHT` in light
9
+ * mode and `DARK` in dark mode. A fallback may hold commas, so a gradient or a list of layers passes.
10
+ *
11
+ * Where only one mode states a property, the other takes the property's neutral value, so the light
12
+ * picture does not stay behind a dark ground that brings none.
13
+ */
14
+ const PHI_MODE_LIGHT_GATE = "--phi-mode-light-gate";
15
+ const PHI_MODE_DARK_GATE = "--phi-mode-dark-gate";
16
+ const PHI_MODE_PAINT_NEUTRAL = {
17
+ backgroundColor: "transparent",
18
+ backgroundImage: "none",
19
+ backgroundSize: "auto",
20
+ backgroundPosition: "0% 0%",
21
+ backgroundRepeat: "repeat",
22
+ backgroundAttachment: "scroll",
23
+ backdropFilter: "none",
24
+ WebkitBackdropFilter: "none",
25
+ boxShadow: "none",
26
+ filter: "none",
27
+ };
28
+ /** One value per mode, as one CSS value the page's mode picks from. */
29
+ export function resolvePhiModeValue(light, dark) {
30
+ return light === dark ? light : `var(${PHI_MODE_LIGHT_GATE}, ${dark}) var(${PHI_MODE_DARK_GATE}, ${light})`;
31
+ }
32
+ export function composePhiModePaint(light, dark) {
33
+ const style = {};
34
+ const keys = new Set([...Object.keys(light), ...Object.keys(dark)]);
35
+ for (const key of keys) {
36
+ const neutral = PHI_MODE_PAINT_NEUTRAL[key];
37
+ const lightValue = light[key] ?? neutral;
38
+ const darkValue = dark[key] ?? neutral;
39
+ if (lightValue == null || darkValue == null) {
40
+ // A property with no neutral value that only one mode states stays as that mode states it.
41
+ style[key] = lightValue ?? darkValue;
42
+ continue;
43
+ }
44
+ style[key] = resolvePhiModeValue(String(lightValue), String(darkValue));
45
+ }
46
+ return style;
47
+ }
@@ -209,7 +209,8 @@ export function resolvePhiShellRegionGroundStyle(ground) {
209
209
  export function resolvePhiShellSiderWidth(shellTheme) {
210
210
  return (resolvePhiShellMetric(shellTheme, "width", { family: "sider", region: "left" }) ??
211
211
  resolvePhiShellMetric(shellTheme, "width", { family: "sider", region: "right" }) ??
212
- 200);
212
+ // The scale's sider width, which the Builder's defaults and the page grid already use.
213
+ PHI_LAYOUT.sidebarWidth);
213
214
  }
214
215
  export function resolvePhiShellSiderCollapsedWidth(shellTheme) {
215
216
  return (resolvePhiShellMetric(shellTheme, "collapsedWidth", { family: "sider", region: "left" }) ??
@@ -50,6 +50,14 @@ export type PhiSurfaceStyleOptions = {
50
50
  */
51
51
  groundLayer?: boolean;
52
52
  };
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)";
55
+ /**
56
+ * Whether a Surface takes its tone's ground (`PHI_SURFACE_TONE_GROUND`): it asks for a mode of its own and
57
+ * its Background paints nothing. A stated ground wins, and the Theme's Overlay (`base.kind: "theme"`) is
58
+ * one. The one rule for every box with a Surface -- this resolver's and the Region shell's.
59
+ */
60
+ export declare function phiSurfaceTakesToneGround(tone: PhiSurface["tone"] | null | undefined, paintsGround: boolean): boolean;
53
61
  /**
54
62
  * A Surface as CSS, in one place for every box that has one.
55
63
  *
@@ -59,5 +67,8 @@ export type PhiSurfaceStyleOptions = {
59
67
  * (a pane's) combined with the configured one.
60
68
  */
61
69
  export declare function resolvePhiSurfaceStyle(surface: PhiSurface | null | undefined, options?: PhiSurfaceStyleOptions): PhiResolvedSurface;
62
- /** Whether a Surface draws anything a reader could see: a ground, a line, or depth. */
70
+ /**
71
+ * Whether a Surface draws anything a reader could see: a ground (its own, or its tone's), a line, or
72
+ * depth.
73
+ */
63
74
  export declare function phiSurfaceDrawsChrome(surface: PhiSurface | null | undefined): boolean;
@@ -1,8 +1,19 @@
1
- import { normalizePhiBackgroundWidgetConfig, phiBackgroundWidgetConfigPaintsGround, resolvePhiBackgroundGroundFilter, resolvePhiBackgroundMotion, resolvePhiBackgroundMotionHostStyle, resolvePhiBackgroundWidgetStyle, } from "../components/widgets/config/background";
1
+ import { PHI_BACKGROUND_CONTAINER_GROUND, normalizePhiBackgroundWidgetConfig, phiBackgroundWidgetConfigPaintsGround, resolvePhiBackgroundGroundFilter, resolvePhiBackgroundMotion, resolvePhiBackgroundMotionHostStyle, resolvePhiBackgroundWidgetStyle, } from "../components/widgets/config/background";
2
2
  import { resolvePhiCmsBorderSource } from "../types/cms-border-source";
3
3
  import { resolvePhiSurfaceToneClassName } from "../types/surface";
4
4
  import { resolvePhiSourcedBorderStyle } from "./border-widget-style";
5
+ import { composePhiModePaint, resolvePhiModeValue } from "./mode-paint";
5
6
  import { combinePhiBoxShadows, resolvePhiShadow } from "./layout-style";
7
+ /** The ground a toned Surface paints where it states none: the container ground of the tone's mode. */
8
+ export const PHI_SURFACE_TONE_GROUND = PHI_BACKGROUND_CONTAINER_GROUND;
9
+ /**
10
+ * Whether a Surface takes its tone's ground (`PHI_SURFACE_TONE_GROUND`): it asks for a mode of its own and
11
+ * its Background paints nothing. A stated ground wins, and the Theme's Overlay (`base.kind: "theme"`) is
12
+ * one. The one rule for every box with a Surface -- this resolver's and the Region shell's.
13
+ */
14
+ export function phiSurfaceTakesToneGround(tone, paintsGround) {
15
+ return tone != null && tone !== "inherit" && !paintsGround;
16
+ }
6
17
  const PHI_SURFACE_EMPTY = { style: {}, ground: null, paintsGround: false };
7
18
  function resolvePhiSurfaceCorners(fallback, configured) {
8
19
  const corner = (value) => value ?? fallback ?? undefined;
@@ -27,23 +38,54 @@ export function resolvePhiSurfaceStyle(surface, options = {}) {
27
38
  return PHI_SURFACE_EMPTY;
28
39
  }
29
40
  const background = surface.background ? normalizePhiBackgroundWidgetConfig(surface.background) : null;
30
- const paintsGround = phiBackgroundWidgetConfigPaintsGround(background);
31
- const groundFilter = background ? resolvePhiBackgroundGroundFilter(background) : null;
32
41
  const motion = background ? resolvePhiBackgroundMotion(background) : null;
42
+ /*
43
+ * The ground in dark mode, where the Surface states one. A moving picture is drawn by the motion layer
44
+ * from one Background and keeps it in both modes.
45
+ */
46
+ const backgroundDark = surface.backgroundDark && motion == null
47
+ ? normalizePhiBackgroundWidgetConfig(surface.backgroundDark)
48
+ : null;
49
+ const modes = backgroundDark ? [background, backgroundDark] : [background];
50
+ const paintsGround = modes.some((entry) => phiBackgroundWidgetConfigPaintsGround(entry));
51
+ const groundFilters = modes.map((entry) => (entry ? resolvePhiBackgroundGroundFilter(entry) : null));
52
+ /*
53
+ * The Theme's Overlay never goes on a layer: it is a window onto one viewport-sized painting, so there
54
+ * is nothing to move or zoom, and its pane has to frost the page behind the box rather than the box.
55
+ */
33
56
  const needsGroundLayer = options.groundLayer !== false
34
57
  && paintsGround
35
- && (groundFilter != null || motion != null || options.forceGroundLayer === true);
36
- const paint = background ? resolvePhiBackgroundWidgetStyle(background) : {};
37
- const hostPaint = needsGroundLayer
38
- ? (background ? resolvePhiBackgroundMotionHostStyle(background) : {})
39
- : paint;
40
- const ground = needsGroundLayer && background
58
+ && modes.some((entry) => entry != null && entry.base.kind !== "theme")
59
+ && (groundFilters.some((filter) => filter != null) || motion != null || options.forceGroundLayer === true);
60
+ const paintOf = (entry) => (entry ? resolvePhiBackgroundWidgetStyle(entry) : {});
61
+ const hostPaintOf = (entry) => (needsGroundLayer
62
+ ? (entry ? resolvePhiBackgroundMotionHostStyle(entry) : {})
63
+ : paintOf(entry));
64
+ const layerPaintOf = (entry) => (entry
65
+ ? resolvePhiBackgroundWidgetStyle({ ...entry, filter: null, motion: null })
66
+ : {});
67
+ const paint = paintOf(background);
68
+ const hostPaint = backgroundDark
69
+ ? composePhiModePaint(hostPaintOf(background), hostPaintOf(backgroundDark))
70
+ : hostPaintOf(background);
71
+ const groundFilter = backgroundDark && groundFilters[0] !== groundFilters[1]
72
+ ? resolvePhiModeValue(groundFilters[0] ?? "none", groundFilters[1] ?? "none")
73
+ : groundFilters[0];
74
+ const ground = needsGroundLayer && (background || backgroundDark)
41
75
  ? {
42
- paint: resolvePhiBackgroundWidgetStyle({ ...background, filter: null, motion: null }),
43
- filter: groundFilter,
76
+ paint: backgroundDark
77
+ ? composePhiModePaint(layerPaintOf(background), layerPaintOf(backgroundDark))
78
+ : layerPaintOf(background),
79
+ filter: groundFilter ?? null,
44
80
  motion: motion ? background : null,
45
81
  }
46
82
  : null;
83
+ /*
84
+ * A tone turns the ground as well (LAYOUTING.md "Surface tone"): content in another mode on the page's
85
+ * ground would be light words on a light page. Where the Background paints nothing, the box takes the
86
+ * mode's own container ground, which resolves under the tone's class it carries. A stated ground wins.
87
+ */
88
+ const toneGround = phiSurfaceTakesToneGround(surface.tone, paintsGround);
47
89
  const borderSource = resolvePhiCmsBorderSource(surface.borderSource, surface.border);
48
90
  const edge = resolvePhiSourcedBorderStyle(borderSource, surface.border);
49
91
  const { border: line, ...configuredCorners } = edge;
@@ -51,6 +93,7 @@ export function resolvePhiSurfaceStyle(surface, options = {}) {
51
93
  return {
52
94
  style: {
53
95
  ...hostPaint,
96
+ ...(toneGround ? { backgroundColor: PHI_SURFACE_TONE_GROUND } : {}),
54
97
  ...(line == null ? {} : { border: line }),
55
98
  ...resolvePhiSurfaceCorners(options.cornerFallback, configuredCorners),
56
99
  ...(boxShadow == null ? {} : { boxShadow }),
@@ -63,12 +106,17 @@ export function resolvePhiSurfaceStyle(surface, options = {}) {
63
106
  ...(surface.tone ? { className: resolvePhiSurfaceToneClassName(surface.tone) } : {}),
64
107
  };
65
108
  }
66
- /** Whether a Surface draws anything a reader could see: a ground, a line, or depth. */
109
+ /**
110
+ * Whether a Surface draws anything a reader could see: a ground (its own, or its tone's), a line, or
111
+ * depth.
112
+ */
67
113
  export function phiSurfaceDrawsChrome(surface) {
68
114
  if (!surface) {
69
115
  return false;
70
116
  }
71
117
  return phiBackgroundWidgetConfigPaintsGround(surface.background ?? null)
118
+ || phiBackgroundWidgetConfigPaintsGround(surface.backgroundDark ?? null)
119
+ || (surface.tone != null && surface.tone !== "inherit")
72
120
  || resolvePhiCmsBorderSource(surface.borderSource, surface.border) !== "none"
73
121
  || (surface.shadow != null && surface.shadow !== "none");
74
122
  }
@@ -11,5 +11,6 @@
11
11
  * headers itself, which is a copy of a protocol that is this package's to change. See DASHBOARD.md.
12
12
  */
13
13
  import "server-only";
14
- export { createPhiDashboardCardId, isPhiDashboardCardId, type PhiDashboardCardContext, type PhiDashboardCardDescriptor, type PhiDashboardCardForm, type PhiDashboardCardId, type PhiDashboardCardPayload, type PhiDashboardCardProvider, } from "./types/dashboard-cards";
14
+ export { createPhiDashboardCardId, isPhiDashboardCardId, PHI_DASHBOARD_CARD_SERIES_LIMIT, type PhiDashboardCardContext, type PhiDashboardCardDescriptor, type PhiDashboardCardForm, type PhiDashboardCardId, type PhiDashboardCardPayload, type PhiDashboardCardProvider, type PhiDashboardCardSeries, type PhiDashboardCardSeriesPoint, } from "./types/dashboard-cards";
15
15
  export { fetchPhiSiteApi, type PhiSiteApiRequest } from "./gateway/site-api-request";
16
+ export { definePhiDashboardCardRead } from "./gateway/dashboard-card-memo";
@@ -11,5 +11,6 @@
11
11
  * headers itself, which is a copy of a protocol that is this package's to change. See DASHBOARD.md.
12
12
  */
13
13
  import "server-only";
14
- export { createPhiDashboardCardId, isPhiDashboardCardId, } from "./types/dashboard-cards";
14
+ export { createPhiDashboardCardId, isPhiDashboardCardId, PHI_DASHBOARD_CARD_SERIES_LIMIT, } from "./types/dashboard-cards";
15
15
  export { fetchPhiSiteApi } from "./gateway/site-api-request";
16
+ export { definePhiDashboardCardRead } from "./gateway/dashboard-card-memo";