@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
@@ -1,5 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PHI_COLOR, PHI_FONT_SIZE, PHI_SPACE } from "../../theme/antd-css-var-contract";
3
+ import { PHI_THEME_GRADIENT_CSS_VARS } from "../../theme/phi-theme-gradients";
4
+ import { PhiTruncatedHoverText } from "./phi-truncated-hover-text";
3
5
  /**
4
6
  * A band of words at the end edge of a box: "Popular", "New", "-20 %".
5
7
  *
@@ -13,10 +15,12 @@ import { PHI_COLOR, PHI_FONT_SIZE, PHI_SPACE } from "../../theme/antd-css-var-co
13
15
  * box's top inset it was too thin to read. In the corner it stands over the inset and a little into the
14
16
  * first line's end, which a long eyebrow in a narrow box can reach.
15
17
  *
16
- * It sits above what the box draws, the highlight's ring included, and takes no clicks, so a card that
17
- * is a link stays one under its band.
18
+ * It sits above what the box draws, the highlight's ring included. Without a hover text it takes no
19
+ * clicks, so a card that is a link stays one under its band; with one it has to take the pointer to be
20
+ * pointed at, and hands a click on through `onClick`.
18
21
  */
19
- export function PhiRibbonControl({ children, color, placement = "edge", style }) {
22
+ export function PhiRibbonControl({ children, color, gradient, placement = "edge", style, fullText, onClick }) {
23
+ const gradientVars = gradient ? PHI_THEME_GRADIENT_CSS_VARS[gradient] : null;
20
24
  const radius = "var(--phi-control-radius-sm)";
21
25
  const position = placement === "corner"
22
26
  ? {
@@ -31,23 +35,25 @@ export function PhiRibbonControl({ children, color, placement = "edge", style })
31
35
  borderStartStartRadius: radius,
32
36
  borderEndStartRadius: radius,
33
37
  };
34
- return (_jsx("span", { className: "phi-ribbon-control", style: {
38
+ const band = (_jsx("span", { className: "phi-ribbon-control", style: {
35
39
  position: "absolute",
36
40
  insetInlineEnd: 0,
37
41
  zIndex: 4,
38
42
  maxWidth: "70%",
39
43
  boxSizing: "border-box",
40
44
  paddingInline: PHI_SPACE.sm,
41
- background: color ?? PHI_COLOR.primary,
42
- color: PHI_COLOR.textLightSolid,
45
+ background: gradientVars ? `var(${gradientVars.paint})` : color ?? PHI_COLOR.primary,
46
+ color: gradientVars ? `var(${gradientVars.text})` : PHI_COLOR.textLightSolid,
43
47
  fontSize: PHI_FONT_SIZE.sm,
44
48
  fontWeight: 600,
45
49
  lineHeight: 2,
46
50
  whiteSpace: "nowrap",
47
51
  overflow: "hidden",
48
52
  textOverflow: "ellipsis",
49
- pointerEvents: "none",
53
+ pointerEvents: fullText ? "auto" : "none",
54
+ ...(fullText && onClick ? { cursor: "pointer" } : {}),
50
55
  ...position,
51
56
  ...style,
52
- }, children: children }));
57
+ }, ...(onClick ? { onClick } : {}), children: children }));
58
+ return fullText ? _jsx(PhiTruncatedHoverText, { title: fullText, children: band }) : band;
53
59
  }
@@ -0,0 +1,32 @@
1
+ import type { ReactNode } from "react";
2
+ import { type PhiThemeGradientKey } from "../../theme/phi-theme-gradients";
3
+ export type PhiRibbonWrapControlProps = {
4
+ /** The box the ribbon hangs on. */
5
+ children: ReactNode;
6
+ /** The ribbon's words. */
7
+ text: ReactNode;
8
+ /** The ribbon's ground; absent, the Theme's primary. The fold under it is a darker shade of it. */
9
+ color?: string;
10
+ /**
11
+ * A Theme gradient slot to fill the ribbon with. The fold under it keeps one colour -- `color`, else the
12
+ * Theme's primary -- because Ant Design draws it as a border, which takes a colour and no run.
13
+ */
14
+ gradient?: PhiThemeGradientKey;
15
+ /** Takes the pointer, for an editor that writes in the ribbon; otherwise clicks pass to the box. */
16
+ interactive?: boolean;
17
+ className?: string;
18
+ };
19
+ /**
20
+ * A ribbon that hangs over a box's end edge, with a fold behind it: Ant Design's `Badge.Ribbon`.
21
+ *
22
+ * The other band, `PhiRibbonControl`, stands inside the box and needs nothing from it. This one reaches
23
+ * past the box's edge, which a box that clips -- a card does, for its picture's corners and its zoom --
24
+ * cannot give a child of its own. So it wraps the box: the wrapper does not clip, the box keeps clipping
25
+ * what is its own, and the ribbon is the box's sibling. The wrapper is a column that passes the slot's
26
+ * width and height on to the box. Whatever stands around the wrapper must leave the overhang room: a
27
+ * Layout that clips at the box's edge cuts the ribbon off as it would any overhang.
28
+ *
29
+ * Imported from its own module, not from `antd`'s Badge: the Badge brings its scroll-number motion along,
30
+ * which a ribbon never uses.
31
+ */
32
+ export declare function PhiRibbonWrapControl({ children, text, color, gradient, interactive, className }: PhiRibbonWrapControlProps): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import Ribbon from "antd/es/badge/Ribbon";
4
+ import { PHI_THEME_GRADIENT_CSS_VARS } from "../../theme/phi-theme-gradients";
5
+ /**
6
+ * A ribbon that hangs over a box's end edge, with a fold behind it: Ant Design's `Badge.Ribbon`.
7
+ *
8
+ * The other band, `PhiRibbonControl`, stands inside the box and needs nothing from it. This one reaches
9
+ * past the box's edge, which a box that clips -- a card does, for its picture's corners and its zoom --
10
+ * cannot give a child of its own. So it wraps the box: the wrapper does not clip, the box keeps clipping
11
+ * what is its own, and the ribbon is the box's sibling. The wrapper is a column that passes the slot's
12
+ * width and height on to the box. Whatever stands around the wrapper must leave the overhang room: a
13
+ * Layout that clips at the box's edge cuts the ribbon off as it would any overhang.
14
+ *
15
+ * Imported from its own module, not from `antd`'s Badge: the Badge brings its scroll-number motion along,
16
+ * which a ribbon never uses.
17
+ */
18
+ export function PhiRibbonWrapControl({ children, text, color, gradient, interactive = false, className }) {
19
+ const gradientVars = gradient ? PHI_THEME_GRADIENT_CSS_VARS[gradient] : null;
20
+ const indicator = {
21
+ zIndex: 4,
22
+ ...(interactive ? {} : { pointerEvents: "none" }),
23
+ ...(gradientVars ? { background: `var(${gradientVars.paint})`, color: `var(${gradientVars.text})` } : {}),
24
+ };
25
+ /*
26
+ * An editor's field in the ribbon measures itself against the ribbon, which is as wide as its words:
27
+ * empty, both were nothing, and only the fold showed. Room for a word, as the inner band keeps it.
28
+ */
29
+ const content = interactive ? { display: "inline-block", minWidth: "6em" } : undefined;
30
+ return (_jsx(Ribbon, { text: text, ...(color ? { color } : {}), rootClassName: ["phi-ribbon-wrap-control", className].filter(Boolean).join(" "), styles: { indicator, ...(content ? { content } : {}) }, children: children }));
31
+ }
@@ -1,4 +1,5 @@
1
1
  import type { PhiControlSize } from "../../types/control";
2
+ import { type PhiThemeGradientKey } from "../../theme/phi-theme-gradients";
2
3
  import type { PhiControlOption } from "./phi-control-options";
3
4
  export type PhiSegmentedControlProps<TValue extends string | number = string> = {
4
5
  /**
@@ -12,8 +13,10 @@ export type PhiSegmentedControlProps<TValue extends string | number = string> =
12
13
  readOnly?: boolean;
13
14
  block?: boolean;
14
15
  size?: PhiControlSize;
16
+ /** A Theme gradient slot the selected segment is filled with; its words take the slot's text colour. */
17
+ gradient?: PhiThemeGradientKey;
15
18
  onFocus?: () => void;
16
19
  onBlur?: () => void;
17
20
  onChange?: (value: TValue) => void;
18
21
  };
19
- export declare function PhiSegmentedControl<TValue extends string | number = string>({ value, label, options, disabled, readOnly, block, size, onFocus, onBlur, onChange, }: PhiSegmentedControlProps<TValue>): import("react").JSX.Element;
22
+ export declare function PhiSegmentedControl<TValue extends string | number = string>({ value, label, options, disabled, readOnly, block, size, gradient, onFocus, onBlur, onChange, }: PhiSegmentedControlProps<TValue>): import("react").JSX.Element;
@@ -1,9 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Segmented } from "antd";
4
+ import { PHI_THEME_GRADIENT_CSS_VARS } from "../../theme/phi-theme-gradients";
4
5
  import { PhiLabeledControl, usePhiControlLabel } from "./phi-labeled-control";
5
- export function PhiSegmentedControl({ value, label, options, disabled, readOnly, block, size, onFocus, onBlur, onChange, }) {
6
+ export function PhiSegmentedControl({ value, label, options, disabled, readOnly, block, size, gradient, onFocus, onBlur, onChange, }) {
6
7
  const { labelId, labelledBy } = usePhiControlLabel(label);
8
+ const gradientVars = gradient ? PHI_THEME_GRADIENT_CSS_VARS[gradient] : null;
7
9
  const control = (_jsx(Segmented, { "aria-labelledby": labelledBy, block: block, value: value, disabled: disabled || readOnly || !onChange, options: options.map((option) => ({
8
10
  value: option.value,
9
11
  label: option.label,
@@ -15,6 +17,15 @@ export function PhiSegmentedControl({ value, label, options, disabled, readOnly,
15
17
  */
16
18
  title: "",
17
19
  tooltip: option.description || undefined,
18
- })), size: size, onChange: (nextValue) => onChange?.(nextValue), onFocus: onFocus, onBlur: onBlur, style: { minWidth: 0, width: block ? "100%" : undefined } }));
20
+ })), size: size, onChange: (nextValue) => onChange?.(nextValue), onFocus: onFocus, onBlur: onBlur, className: gradientVars ? "phi-segmented-gradient" : undefined, style: {
21
+ minWidth: 0,
22
+ width: block ? "100%" : undefined,
23
+ ...(gradientVars
24
+ ? {
25
+ "--phi-control-gradient": `var(${gradientVars.paint})`,
26
+ "--phi-control-gradient-text": `var(${gradientVars.text})`,
27
+ }
28
+ : {}),
29
+ } }));
19
30
  return _jsx(PhiLabeledControl, { label: label, labelId: labelId, fill: block, children: control });
20
31
  }
@@ -60,6 +60,9 @@ function groupPhiSelectOptions(resolved) {
60
60
  }
61
61
  export function PhiSelectControl({ id, value, label, description, ariaLabel, placeholder, disabled, readOnly, presentation = "select", allowCustom, allowClear, options, size, variant, popupMatchSelectWidth = false, getPopupContainer, popupRootClassName, popupZIndex, style, onFocus, onBlur, onOpenChange, onSearch, filterOptionsLocally = true, onChange, }) {
62
62
  const { labelId, labelledBy } = usePhiControlLabel(label, ariaLabel);
63
+ // A compact field opens a compact list: its options write small, as the field does (controls.css).
64
+ const popupClassName = [popupRootClassName, size === "small" ? "phi-select-popup--sm" : null]
65
+ .filter(Boolean).join(" ") || undefined;
63
66
  const resolvedOptions = groupPhiSelectOptions(separatePhiSelectOptions(options.map((option) => ({
64
67
  value: option.value,
65
68
  // rc-select synthesizes native HTML title attributes from primitive labels.
@@ -74,7 +77,7 @@ export function PhiSelectControl({ id, value, label, description, ariaLabel, pla
74
77
  (value === undefined || typeof value === "string") &&
75
78
  options.every((option) => typeof option.value === "string");
76
79
  if (canUseTextEntry) {
77
- const control = (_jsx(AutoComplete, { "aria-label": ariaLabel, "aria-labelledby": labelledBy, value: value, placeholder: placeholder, disabled: controlDisabled, allowClear: allowClear, options: resolvedOptions, optionRender: (resolvedOption) => isPhiSelectSeparatorEntry(resolvedOption.data) ? renderPhiSelectSeparator() : (_jsx(PhiControlOptionContent, { option: resolvedOption.data.option, presentation: "dropdown" })), size: size, variant: variant, popupMatchSelectWidth: popupMatchSelectWidth, getPopupContainer: getPopupContainer, classNames: popupRootClassName ? { popup: { root: popupRootClassName } } : undefined, styles: popupZIndex == null ? undefined : { popup: { root: { zIndex: popupZIndex } } }, filterOption: !filterOptionsLocally
80
+ const control = (_jsx(AutoComplete, { "aria-label": ariaLabel, "aria-labelledby": labelledBy, value: value, placeholder: placeholder, disabled: controlDisabled, allowClear: allowClear, options: resolvedOptions, optionRender: (resolvedOption) => isPhiSelectSeparatorEntry(resolvedOption.data) ? renderPhiSelectSeparator() : (_jsx(PhiControlOptionContent, { option: resolvedOption.data.option, presentation: "dropdown" })), size: size, variant: variant, popupMatchSelectWidth: popupMatchSelectWidth, getPopupContainer: getPopupContainer, classNames: popupClassName ? { popup: { root: popupClassName } } : undefined, styles: popupZIndex == null ? undefined : { popup: { root: { zIndex: popupZIndex } } }, filterOption: !filterOptionsLocally
78
81
  ? false
79
82
  : (inputValue, option) => {
80
83
  // A group heading has no search label of its own; antd filters the options inside it.
@@ -90,6 +93,6 @@ export function PhiSelectControl({ id, value, label, description, ariaLabel, pla
90
93
  return selected
91
94
  ? _jsx(PhiControlOptionContent, { option: selected, presentation: "selection" })
92
95
  : selectedOption.label;
93
- }, size: size, variant: variant, popupMatchSelectWidth: popupMatchSelectWidth, getPopupContainer: getPopupContainer, classNames: popupRootClassName ? { popup: { root: popupRootClassName } } : undefined, styles: popupZIndex == null ? undefined : { popup: { root: { zIndex: popupZIndex } } }, showSearch: true, optionFilterProp: ["searchLabel", "value"], filterOption: filterOptionsLocally ? undefined : false, onSearch: onSearch, onFocus: onFocus, onBlur: onBlur, onOpenChange: onOpenChange, onChange: onChange, style: style }));
96
+ }, size: size, variant: variant, popupMatchSelectWidth: popupMatchSelectWidth, getPopupContainer: getPopupContainer, classNames: popupClassName ? { popup: { root: popupClassName } } : undefined, styles: popupZIndex == null ? undefined : { popup: { root: { zIndex: popupZIndex } } }, showSearch: true, optionFilterProp: ["searchLabel", "value"], filterOption: filterOptionsLocally ? undefined : false, onSearch: onSearch, onFocus: onFocus, onBlur: onBlur, onOpenChange: onOpenChange, onChange: onChange, style: style }));
94
97
  return _jsx(PhiLabeledControl, { label: label, labelId: labelId, description: description, fill: style?.width === "100%", children: control });
95
98
  }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Figures over time: a line per series across the width it is given.
3
+ *
4
+ * Drawn as SVG by hand rather than through a chart library. What a card asks of it is a shape -- rising,
5
+ * falling, a spike last Tuesday -- and its latest figure, not axes to read values off; a library would
6
+ * bring a second rendering model and a dependency to every Site for that. No hooks and no Ant Design, so
7
+ * a server render draws it as well as a client one.
8
+ *
9
+ * The drawing is stretched to its box (`preserveAspectRatio="none"`) with strokes that do not stretch
10
+ * with it, so the chart takes its container's width at any size. The last point of each series is the
11
+ * emphasized one, drawn over the SVG rather than in it: a circle in a stretched drawing would be an ellipse.
12
+ *
13
+ * Every colour is the Theme's variable (`PHI_COLOR`), never a resolved value, so a Surface `tone` reaches
14
+ * the lines. The first series is the Theme's primary, with an area under it; the second and third are the
15
+ * text colours, the third dashed, so two lines differ in more than hue.
16
+ *
17
+ * The scale starts at zero for figures that are never negative, which counts are: a line that starts at
18
+ * its own minimum turns a day with one more visitor into a cliff.
19
+ */
20
+ export type PhiSeriesChartControlSeries = {
21
+ label: string;
22
+ /** One value per key, in the keys' order. */
23
+ values: readonly number[];
24
+ };
25
+ export type PhiSeriesChartControlProps = {
26
+ /** What each point is called, already in words -- its day -- oldest first. */
27
+ keys: readonly string[];
28
+ series: readonly PhiSeriesChartControlSeries[];
29
+ /** A word for what is counted, already translated; said after each latest figure. */
30
+ unit?: string;
31
+ /** The page's locale, for the figures in the spoken label. */
32
+ locale: string;
33
+ /** What the chart is of, said before its latest figures. */
34
+ title?: string;
35
+ /** The drawing's height in pixels; its width is the container's. */
36
+ height?: number;
37
+ };
38
+ /** Where each series' points stand in the drawing's own coordinates. */
39
+ export declare function computePhiSeriesChartGeometry(series: readonly PhiSeriesChartControlSeries[], pointCount: number): {
40
+ baseline: number;
41
+ top: number;
42
+ series: {
43
+ x: number;
44
+ y: number;
45
+ value: number;
46
+ }[][];
47
+ };
48
+ export declare function PhiSeriesChartControl({ keys, series, unit, locale, title, height, }: PhiSeriesChartControlProps): import("react").JSX.Element;
@@ -0,0 +1,82 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { PHI_COLOR, PHI_FONT_SIZE, PHI_SPACE } from "../../theme/antd-css-var-contract";
3
+ const VIEW_WIDTH = 100;
4
+ const VIEW_HEIGHT = 100;
5
+ /* Room above the highest point and below the baseline, so the emphasized dot is not clipped. */
6
+ const VIEW_INSET = 8;
7
+ const SERIES_STROKES = [
8
+ { color: PHI_COLOR.primary },
9
+ { color: PHI_COLOR.textSecondary },
10
+ { color: PHI_COLOR.textTertiary, dash: "4 3" },
11
+ ];
12
+ function strokeOf(index) {
13
+ return SERIES_STROKES[index % SERIES_STROKES.length];
14
+ }
15
+ function finite(values) {
16
+ return values.filter((value) => Number.isFinite(value));
17
+ }
18
+ /** Where each series' points stand in the drawing's own coordinates. */
19
+ export function computePhiSeriesChartGeometry(series, pointCount) {
20
+ const all = series.flatMap((entry) => finite(entry.values.slice(0, pointCount)));
21
+ const low = Math.min(0, ...all);
22
+ const high = Math.max(0, ...all);
23
+ const range = high - low || 1;
24
+ const xOf = (index) => (pointCount <= 1 ? VIEW_WIDTH / 2 : (index / (pointCount - 1)) * VIEW_WIDTH);
25
+ const yOf = (value) => VIEW_INSET + (1 - (value - low) / range) * (VIEW_HEIGHT - 2 * VIEW_INSET);
26
+ return {
27
+ baseline: yOf(Math.max(low, 0)),
28
+ top: yOf(high),
29
+ series: series.map((entry) => entry.values.slice(0, pointCount).flatMap((value, index) => Number.isFinite(value) ? [{ x: xOf(index), y: yOf(value), value }] : [])),
30
+ };
31
+ }
32
+ function round(value) {
33
+ return Math.round(value * 100) / 100;
34
+ }
35
+ function linePath(points) {
36
+ return points.map((point, index) => `${index === 0 ? "M" : "L"}${round(point.x)} ${round(point.y)}`).join(" ");
37
+ }
38
+ export function PhiSeriesChartControl({ keys, series, unit, locale, title, height = 64, }) {
39
+ const pointCount = keys.length;
40
+ const geometry = computePhiSeriesChartGeometry(series, pointCount);
41
+ const numbers = new Intl.NumberFormat(locale);
42
+ const lastKey = keys[pointCount - 1];
43
+ const latest = series.flatMap((entry) => {
44
+ const value = entry.values[pointCount - 1];
45
+ return value !== undefined && Number.isFinite(value)
46
+ ? [`${entry.label} ${numbers.format(value)}${unit ? ` ${unit}` : ""}`]
47
+ : [];
48
+ });
49
+ /* What a reader who cannot see the lines is told: what it is, the latest day, each series' figure on it. */
50
+ const spoken = [title, lastKey && latest.length > 0 ? `${lastKey}: ${latest.join(", ")}` : null]
51
+ .filter(Boolean)
52
+ .join(" -- ");
53
+ const first = geometry.series[0] ?? [];
54
+ const area = first.length > 1
55
+ ? `${linePath(first)} L${round(first[first.length - 1].x)} ${round(geometry.baseline)} L${round(first[0].x)} ${round(geometry.baseline)} Z`
56
+ : null;
57
+ return (_jsxs("figure", { style: { margin: 0, display: "grid", gap: PHI_SPACE.xxs, minWidth: 0 }, "data-phi-series-chart": "", children: [_jsxs("div", { style: { position: "relative", height, minWidth: 0 }, children: [_jsxs("svg", { role: "img", "aria-label": spoken || undefined, viewBox: `0 0 ${VIEW_WIDTH} ${VIEW_HEIGHT}`, preserveAspectRatio: "none", width: "100%", height: height, style: { display: "block", overflow: "visible" }, children: [spoken ? _jsx("title", { children: spoken }) : null, _jsx("line", { x1: 0, x2: VIEW_WIDTH, y1: round(geometry.top), y2: round(geometry.top), vectorEffect: "non-scaling-stroke", strokeWidth: 1, strokeDasharray: "2 3", style: { stroke: PHI_COLOR.split } }), _jsx("line", { x1: 0, x2: VIEW_WIDTH, y1: round(geometry.baseline), y2: round(geometry.baseline), vectorEffect: "non-scaling-stroke", strokeWidth: 1, style: { stroke: PHI_COLOR.border } }), area ? (_jsx("path", { d: area, style: { fill: `color-mix(in srgb, ${PHI_COLOR.primary} 14%, transparent)`, stroke: "none" } })) : null, geometry.series.map((points, index) => points.length > 1 ? (_jsx("path", { d: linePath(points), fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: index === 0 ? 2 : 1.5, strokeLinejoin: "round", strokeLinecap: "round", ...(strokeOf(index).dash ? { strokeDasharray: strokeOf(index).dash } : {}), style: { stroke: strokeOf(index).color } }, index)) : null)] }), geometry.series.map((points, index) => {
58
+ /* The latest day's point, where the series has a figure for that day. */
59
+ const last = points[points.length - 1];
60
+ return last && Number.isFinite(series[index].values[pointCount - 1]) ? (_jsx("span", { "aria-hidden": "true", "data-phi-series-chart-last": "", style: {
61
+ position: "absolute",
62
+ left: `${round((last.x / VIEW_WIDTH) * 100)}%`,
63
+ top: `${round((last.y / VIEW_HEIGHT) * 100)}%`,
64
+ width: 8,
65
+ height: 8,
66
+ borderRadius: "50%",
67
+ transform: "translate(-50%, -50%)",
68
+ background: strokeOf(index).color,
69
+ boxShadow: `0 0 0 2px ${PHI_COLOR.bgContainer}`,
70
+ } }, index)) : null;
71
+ })] }), series.length > 1 || pointCount > 1 ? (_jsxs("figcaption", { "aria-hidden": "true", style: {
72
+ display: "grid",
73
+ gap: PHI_SPACE.xxs,
74
+ fontSize: PHI_FONT_SIZE.sm,
75
+ color: PHI_COLOR.textTertiary,
76
+ minWidth: 0,
77
+ }, children: [pointCount > 1 ? (_jsxs("span", { style: { display: "flex", justifyContent: "space-between", columnGap: PHI_SPACE.sm, minWidth: 0 }, children: [_jsx("span", { children: keys[0] }), _jsx("span", { children: lastKey })] })) : null, series.length > 1 ? (_jsx("span", { style: { display: "flex", flexWrap: "wrap", columnGap: PHI_SPACE.sm, minWidth: 0 }, children: series.map((entry, index) => (_jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: PHI_SPACE.xxs }, children: [_jsx("span", { style: {
78
+ display: "inline-block",
79
+ width: 10,
80
+ borderTop: `2px ${strokeOf(index).dash ? "dashed" : "solid"} ${strokeOf(index).color}`,
81
+ } }), entry.label] }, index))) })) : null] })) : null] }));
82
+ }
@@ -15,6 +15,8 @@ export type PhiSurfaceControlLabels = {
15
15
  shadow: string;
16
16
  tone: string;
17
17
  tones: Record<PhiSurfaceTone, string>;
18
+ /** The switch for a ground of its own in dark mode; the two grounds are then named by `tones`. */
19
+ backgroundPerMode?: string;
18
20
  };
19
21
  export type PhiSurfaceControlProps = {
20
22
  value?: PhiSurface | null;
@@ -5,6 +5,7 @@ import { PhiBackgroundControl } from "./phi-background-control";
5
5
  import { PhiBorderControl } from "./phi-border-control";
6
6
  import { PhiFlexControl } from "./phi-flex-control";
7
7
  import { PhiSegmentedControl } from "./phi-segmented-control";
8
+ import { PhiSwitchControl } from "./phi-switch-control";
8
9
  import { PhiShadowControl } from "./phi-shadow-control";
9
10
  import { PhiDividerControl } from "./phi-divider-control";
10
11
  import { PHI_CMS_BORDER_SOURCES, resolvePhiCmsBorderSource, } from "../../types/cms-border-source";
@@ -23,6 +24,7 @@ const PHI_SURFACE_CONTROL_DEFAULT_LABELS = {
23
24
  dark: "Dark",
24
25
  inverse: "Inverse",
25
26
  },
27
+ backgroundPerMode: "Own background in dark mode",
26
28
  };
27
29
  /** Read only where the Border labels have not arrived; the words themselves live in their label set. */
28
30
  const PHI_BORDER_SOURCE_FALLBACK_LABELS = {
@@ -71,6 +73,10 @@ export function PhiSurfaceControl({ value, onChange, disabled = false, labels =
71
73
  * next selected node) drops it, one this Control wrote keeps it.
72
74
  */
73
75
  const [customChosen, setCustomChosen] = useState(false);
76
+ /* Which of the two grounds is open, where the Surface has one per mode. */
77
+ const [backgroundMode, setBackgroundMode] = useState("light");
78
+ const perMode = current.backgroundDark != null;
79
+ const editedMode = perMode ? backgroundMode : "light";
74
80
  const [seenValue, setSeenValue] = useState(value);
75
81
  const [writtenValue, setWrittenValue] = useState(undefined);
76
82
  if (seenValue !== value) {
@@ -102,7 +108,16 @@ export function PhiSurfaceControl({ value, onChange, disabled = false, labels =
102
108
  { value: "none", label: labels.styles.none },
103
109
  ...PHI_SURFACE_PRESET_IDS.map((id) => ({ value: id, label: labels.styles[id] })),
104
110
  { value: "custom", label: labels.styles.custom },
105
- ], block: true, disabled: isDisabled, onChange: chooseStyle })] }), tone ? (_jsxs(PhiFlexControl, { vertical: true, gap: "small", style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiDividerControl, { titlePlacement: "start", style: { marginBlock: 0 }, children: labels.tone }), _jsx(PhiSegmentedControl, { value: current.tone ?? "inherit", options: PHI_SURFACE_TONES.map((entry) => ({ value: entry, label: labels.tones[entry] })), block: true, disabled: isDisabled, onChange: (next) => patch({ tone: next === "inherit" ? undefined : next }) })] })) : null, style === "custom" ? (_jsxs(_Fragment, { children: [_jsxs(PhiFlexControl, { vertical: true, gap: "small", style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiDividerControl, { titlePlacement: "start", style: { marginBlock: 0 }, children: labels.background }), _jsx(PhiBackgroundControl, { mode: "control", disabled: isDisabled, value: current.background ?? null, onChange: (background) => patch({ background }), labels: backgroundLabels, colorPickerLabels: colorPickerLabels, colorPickerPlacement: colorPickerPlacement, filters: backgroundFilters, renderMediaPicker: renderMediaPicker })] }), _jsxs(PhiFlexControl, { vertical: true, gap: "small", style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiDividerControl, { titlePlacement: "start", style: { marginBlock: 0 }, children: labels.border }), _jsx(PhiSegmentedControl, { value: borderSource, options: PHI_CMS_BORDER_SOURCES.map((source) => ({
111
+ ], block: true, disabled: isDisabled, onChange: chooseStyle })] }), tone ? (_jsxs(PhiFlexControl, { vertical: true, gap: "small", style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiDividerControl, { titlePlacement: "start", style: { marginBlock: 0 }, children: labels.tone }), _jsx(PhiSegmentedControl, { value: current.tone ?? "inherit", options: PHI_SURFACE_TONES.map((entry) => ({ value: entry, label: labels.tones[entry] })), block: true, disabled: isDisabled, onChange: (next) => patch({ tone: next === "inherit" ? undefined : next }) })] })) : null, style === "custom" ? (_jsxs(_Fragment, { children: [_jsxs(PhiFlexControl, { vertical: true, gap: "small", style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiDividerControl, { titlePlacement: "start", style: { marginBlock: 0 }, children: labels.background }), _jsx(PhiSwitchControl, { label: labels.backgroundPerMode ?? PHI_SURFACE_CONTROL_DEFAULT_LABELS.backgroundPerMode, checked: perMode, disabled: isDisabled, onChange: (checked) => {
112
+ // Switched on, the dark ground starts as a copy of the light one, to be changed from there.
113
+ setBackgroundMode(checked ? "dark" : "light");
114
+ patch({ backgroundDark: checked ? (current.background ?? { base: { kind: "none" } }) : undefined });
115
+ } }), perMode ? (_jsx(PhiSegmentedControl, { value: editedMode, options: [
116
+ { value: "light", label: labels.tones.light },
117
+ { value: "dark", label: labels.tones.dark },
118
+ ], block: true, disabled: isDisabled, onChange: setBackgroundMode })) : null, _jsx(PhiBackgroundControl, { mode: "control", disabled: isDisabled, value: (editedMode === "dark" ? current.backgroundDark : current.background) ?? null, onChange: (next) => patch(editedMode === "dark"
119
+ ? { backgroundDark: next ?? { base: { kind: "none" } } }
120
+ : { background: next }), labels: backgroundLabels, colorPickerLabels: colorPickerLabels, colorPickerPlacement: colorPickerPlacement, filters: backgroundFilters, renderMediaPicker: renderMediaPicker }, editedMode)] }), _jsxs(PhiFlexControl, { vertical: true, gap: "small", style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiDividerControl, { titlePlacement: "start", style: { marginBlock: 0 }, children: labels.border }), _jsx(PhiSegmentedControl, { value: borderSource, options: PHI_CMS_BORDER_SOURCES.map((source) => ({
106
121
  value: source,
107
122
  label: borderLabels?.sources?.[source] ?? PHI_BORDER_SOURCE_FALLBACK_LABELS[source],
108
123
  })), block: true, disabled: isDisabled, onChange: (nextSource) => patch({ borderSource: nextSource }) }), borderSource === "custom" ? (_jsx(PhiBorderControl, { mode: "control", disabled: isDisabled, value: current.border ?? null, onChange: (border) => patch({ border, borderSource: "custom" }), labels: borderLabels, colorPickerLabels: colorPickerLabels, colorPickerPlacement: colorPickerPlacement })) : null] }), _jsxs(PhiFlexControl, { vertical: true, gap: "small", style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiDividerControl, { titlePlacement: "start", style: { marginBlock: 0 }, children: labels.shadow }), _jsx(PhiShadowControl, { mode: "control", disabled: isDisabled, value: current.shadow ?? null, onChange: (shadow) => patch({ shadow }) })] })] })) : null] }));
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { PhiControlSize } from "../../types/control";
3
+ import { type PhiThemeGradientKey } from "../../theme/phi-theme-gradients";
3
4
  export type PhiSwitchControlProps = {
4
5
  /** The DOM id of the input, so a `<label for>` outside the control can name it. */
5
6
  id?: string;
@@ -13,6 +14,8 @@ export type PhiSwitchControlProps = {
13
14
  /** What the switch reads while off. */
14
15
  uncheckedLabel?: ReactNode;
15
16
  size?: Exclude<PhiControlSize, "large">;
17
+ /** A Theme gradient slot the switch is filled with while on, instead of the primary colour. */
18
+ gradient?: PhiThemeGradientKey;
16
19
  onChange?: (checked: boolean) => void;
17
20
  };
18
- export declare function PhiSwitchControl({ id, checked, label, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, onChange, }: PhiSwitchControlProps): import("react").JSX.Element;
21
+ export declare function PhiSwitchControl({ id, checked, label, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, gradient, onChange, }: PhiSwitchControlProps): import("react").JSX.Element;
@@ -1,8 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Switch } from "antd";
4
+ import { PHI_THEME_GRADIENT_CSS_VARS } from "../../theme/phi-theme-gradients";
4
5
  import { PhiLabeledControl, usePhiControlLabel } from "./phi-labeled-control";
5
- export function PhiSwitchControl({ id, checked, label, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, onChange, }) {
6
+ export function PhiSwitchControl({ id, checked, label, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, gradient, onChange, }) {
6
7
  const { labelId, labelledBy } = usePhiControlLabel(label);
7
- return (_jsx(PhiLabeledControl, { label: label, labelId: labelId, children: _jsx(Switch, { id: id, "aria-labelledby": labelledBy, checked: checked, disabled: disabled || readOnly || !onChange, loading: loading, checkedChildren: checkedLabel, unCheckedChildren: uncheckedLabel, size: size, onChange: onChange }) }));
8
+ return (_jsx(PhiLabeledControl, { label: label, labelId: labelId, children: _jsx(Switch, { id: id, "aria-labelledby": labelledBy, checked: checked, disabled: disabled || readOnly || !onChange, loading: loading, checkedChildren: checkedLabel, unCheckedChildren: uncheckedLabel, size: size, onChange: onChange, ...(gradient
9
+ ? {
10
+ className: "phi-switch-gradient",
11
+ style: { "--phi-control-gradient": `var(${PHI_THEME_GRADIENT_CSS_VARS[gradient].paint})` },
12
+ }
13
+ : {}) }) }));
8
14
  }
@@ -1,7 +1,10 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
+ import { type PhiThemeGradientKey } from "../../theme/phi-theme-gradients";
2
3
  export type PhiTagControlProps = {
3
4
  children: ReactNode;
4
5
  color?: string;
6
+ /** A Theme gradient slot to fill the tag with; it then draws solid, in the slot's text colour. */
7
+ gradient?: PhiThemeGradientKey;
5
8
  variant?: "filled" | "outlined" | "solid";
6
9
  /**
7
10
  * Offers the remove affordance Ant Design draws inside the capsule.
@@ -23,4 +26,4 @@ export type PhiTagControlProps = {
23
26
  onClose?: () => void;
24
27
  style?: CSSProperties;
25
28
  };
26
- export declare function PhiTagControl({ children, color, variant, closable, onClose, style, }: PhiTagControlProps): import("react").JSX.Element;
29
+ export declare function PhiTagControl({ children, color, gradient, variant, closable, onClose, style, }: PhiTagControlProps): import("react").JSX.Element;
@@ -1,9 +1,17 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Tag } from "antd";
4
- export function PhiTagControl({ children, color, variant = "outlined", closable, onClose, style, }) {
5
- return (_jsx(Tag, { color: color, variant: variant, closeIcon: closable || undefined, onClose: onClose ? (event) => {
4
+ import { PHI_THEME_GRADIENT_CSS_VARS } from "../../theme/phi-theme-gradients";
5
+ export function PhiTagControl({ children, color, gradient, variant = "outlined", closable, onClose, style, }) {
6
+ const gradientVars = gradient ? PHI_THEME_GRADIENT_CSS_VARS[gradient] : null;
7
+ return (_jsx(Tag, { color: gradientVars ? undefined : color, variant: gradientVars ? "solid" : variant, closeIcon: closable || undefined, onClose: onClose ? (event) => {
6
8
  event.preventDefault();
7
9
  onClose();
8
- } : undefined, style: { marginInlineEnd: 0, ...style }, children: children }));
10
+ } : undefined, style: {
11
+ marginInlineEnd: 0,
12
+ ...(gradientVars
13
+ ? { background: `var(${gradientVars.paint})`, color: `var(${gradientVars.text})`, borderColor: "transparent" }
14
+ : {}),
15
+ ...style,
16
+ }, children: children }));
9
17
  }
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Input } from "antd";
3
+ import { Input, theme } from "antd";
4
4
  import { PhiLabeledControl, usePhiControlLabel } from "./phi-labeled-control";
5
5
  import { PhiIcon } from "../shell/phi-icon";
6
6
  function resolveTextInputKind(inputType) {
@@ -22,12 +22,63 @@ function resolveTextInputKind(inputType) {
22
22
  return { type: "text", inputMode: "text" };
23
23
  }
24
24
  }
25
+ /*
26
+ * The first line of a text area, where its clear button belongs.
27
+ *
28
+ * Ant Design hangs the button absolutely from the box's top at `paddingXS`, which is the middle of the
29
+ * first line only for a text area at its own padding. A field restyled to stand in its text -- no
30
+ * padding, the text's own type, as the inline editors are -- had the cross half a line below its line.
31
+ * Where the field states its own top padding, the button is given one line of the field from there,
32
+ * with the cross in its middle: `1lh` in the field's type. A field at Ant Design's padding keeps
33
+ * Ant Design's place.
34
+ */
35
+ function readBlockStartPadding(style) {
36
+ const value = style?.paddingBlockStart ?? style?.paddingTop ?? style?.paddingBlock ?? style?.padding;
37
+ if (value == null)
38
+ return null;
39
+ if (typeof value === "number")
40
+ return `${value}px`;
41
+ // The first value of a shorthand, read past the spaces inside a `calc()`.
42
+ const text = String(value).trim();
43
+ let depth = 0;
44
+ for (let index = 0; index < text.length; index += 1) {
45
+ const character = text[index];
46
+ if (character === "(")
47
+ depth += 1;
48
+ else if (character === ")")
49
+ depth -= 1;
50
+ else if (depth === 0 && /\s/u.test(character ?? ""))
51
+ return text.slice(0, index);
52
+ }
53
+ return text || null;
54
+ }
55
+ function resolveTextAreaClearStyle(style, inputStyle) {
56
+ const fieldPadding = readBlockStartPadding(inputStyle);
57
+ if (fieldPadding == null)
58
+ return null;
59
+ const boxPadding = readBlockStartPadding(style) ?? "0px";
60
+ const type = inputStyle?.font != null
61
+ ? { font: inputStyle.font }
62
+ : {
63
+ fontSize: inputStyle?.fontSize ?? "inherit",
64
+ lineHeight: inputStyle?.lineHeight ?? "inherit",
65
+ fontFamily: inputStyle?.fontFamily ?? "inherit",
66
+ };
67
+ return {
68
+ ...type,
69
+ insetBlockStart: `calc(${boxPadding} + ${fieldPadding})`,
70
+ height: "1lh",
71
+ display: "flex",
72
+ alignItems: "center",
73
+ };
74
+ }
25
75
  export function PhiTextControl({ id, value, label, description, inputType = "text", presentation = "input", disabled = false, readOnly = false, allowClear = true, clearLabel, placeholder, ariaLabel, prefix, autoFocus, autoComplete, minLength, maxLength, rows, cols, autoSize, tabIndex, size, variant, inputRef, textareaRef, onChange, onPressEnter, onKeyDown, onFocus, onBlur, onClear, style, inputStyle, }) {
26
76
  const { labelId, labelledBy } = usePhiControlLabel(label, ariaLabel);
27
77
  const resolvedKind = resolveTextInputKind(inputType);
78
+ const { token } = theme.useToken();
28
79
  const stableAllowClear = {
29
80
  disabled: !allowClear,
30
- clearIcon: (_jsx(PhiIcon, { name: "close", size: "inherit", ariaLabel: clearLabel })),
81
+ clearIcon: (_jsx(PhiIcon, { name: "close", size: token.fontSizeIcon, ariaLabel: clearLabel })),
31
82
  };
32
83
  const commonProps = {
33
84
  ref: inputRef,
@@ -56,7 +107,10 @@ export function PhiTextControl({ id, value, label, description, inputType = "tex
56
107
  }
57
108
  let control;
58
109
  if (presentation === "textarea") {
59
- control = (_jsx(Input.TextArea, { ...commonProps, styles: inputStyle ? { textarea: inputStyle } : undefined, ref: textareaRef, allowClear: stableAllowClear, onClear: onClear, autoSize: autoSize, rows: rows, cols: cols, onPressEnter: onPressEnter }));
110
+ control = (_jsx(Input.TextArea, { ...commonProps, styles: {
111
+ ...(inputStyle ? { textarea: inputStyle } : {}),
112
+ ...(allowClear ? { clear: resolveTextAreaClearStyle(style, inputStyle) ?? undefined } : {}),
113
+ }, ref: textareaRef, allowClear: stableAllowClear, onClear: onClear, autoSize: autoSize, rows: rows, cols: cols, onPressEnter: onPressEnter }));
60
114
  }
61
115
  else if (presentation === "password") {
62
116
  control = (_jsx(Input.Password, { ...commonProps, styles: inputStyle ? { input: inputStyle } : undefined, allowClear: stableAllowClear, onClear: onClear, prefix: prefix, onPressEnter: onPressEnter }));
@@ -102,7 +102,7 @@ function PhiTreeNodeTitle({ node, presentation, editing, actions, controlSize, o
102
102
  beforeNodeIdentity: dropMode === "before" ? node.identity : null,
103
103
  afterNodeIdentity: dropMode === "after" ? node.identity : null,
104
104
  });
105
- }, children: [iconEditable ? (_jsx(PhiIconPickerControl, { value: typeof icon === "string" ? icon : null, buttonSize: controlSize, buttonType: "text", onChange: (value) => void onCommitField?.(node.identity, iconFieldKey, value) })) : presentation.showIcon !== false && typeof icon === "string" ? _jsx(PhiIcon, { name: icon }) : null, _jsxs("div", { style: { display: "grid", flex: 1, minWidth: 0 }, children: [titleEditable ? (_jsx(PhiTextControl, { value: draftTitle, size: controlSize, variant: presentation.node.titleEditor?.variant ?? "underlined", onChange: (value) => setDraftTitle(value ?? ""), onPressEnter: commitTitle, onBlur: commitTitle })) : _jsx("span", { children: title }), description != null && description !== "" ? (_jsx(Typography.Text, { type: "secondary", ellipsis: true, children: String(description) })) : null] }), actions.length ? (_jsx(Flex, { align: "center", gap: 2, onClick: (event) => event.stopPropagation(), children: actions.map((action) => (_jsx(PhiTreeActionButton, { action: action.execution === "link" && action.hrefPath
105
+ }, children: [iconEditable ? (_jsx(PhiIconPickerControl, { value: typeof icon === "string" ? icon : null, buttonSize: controlSize, buttonType: "text", onChange: (value) => void onCommitField?.(node.identity, iconFieldKey, value) })) : presentation.showIcon !== false && typeof icon === "string" ? _jsx(PhiIcon, { name: icon }) : null, _jsxs("div", { style: { display: "grid", flex: 1, minWidth: 0 }, children: [titleEditable ? (_jsx(PhiTextControl, { value: draftTitle, size: controlSize, variant: presentation.node.titleEditor?.variant ?? "underlined", onChange: (value) => setDraftTitle(value ?? ""), onPressEnter: commitTitle, onBlur: commitTitle })) : _jsx("span", { children: title }), description != null && description !== "" ? (_jsx(Typography.Text, { type: "secondary", ellipsis: true, style: { fontSize: "inherit" }, children: String(description) })) : null] }), actions.length ? (_jsx(Flex, { align: "center", gap: 2, onClick: (event) => event.stopPropagation(), children: actions.map((action) => (_jsx(PhiTreeActionButton, { action: action.execution === "link" && action.hrefPath
106
106
  ? { ...action, href: String(readPath(node.record, action.hrefPath) ?? "") }
107
107
  : action, size: controlSize, onActivate: () => onAction?.(action, node.identity) }, action.key))) })) : null] }));
108
108
  }
@@ -0,0 +1,15 @@
1
+ import { type ReactElement, type ReactNode, type Ref } from "react";
2
+ /**
3
+ * A hover text that says what an ellipsis cut off, and only then.
4
+ *
5
+ * Around one element that cuts its own text short (`text-overflow: ellipsis`): pointed at, the element is
6
+ * measured, and the whole text shows in the house tooltip when it did not fit. An element whose text fits
7
+ * shows nothing -- a tooltip repeating the words that stand right there is noise. The child is the element
8
+ * itself, not a component, so the measuring reaches the box that cuts.
9
+ */
10
+ export declare function PhiTruncatedHoverText({ title, children, }: {
11
+ title: ReactNode;
12
+ children: ReactElement<{
13
+ ref?: Ref<HTMLElement>;
14
+ }>;
15
+ }): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { cloneElement, lazy, Suspense, useState } from "react";
4
+ /* The same Tooltip `PhiHoverText` loads, and loaded the same way: only where one is drawn. */
5
+ const PhiLazyTooltip = lazy(() => import("antd/es/tooltip"));
6
+ /** Whether an element shows less than its text: cut off at its end by an ellipsis, or by its height. */
7
+ function isPhiElementTruncated(element) {
8
+ return element != null
9
+ && (element.scrollWidth > element.clientWidth + 1 || element.scrollHeight > element.clientHeight + 1);
10
+ }
11
+ /**
12
+ * A hover text that says what an ellipsis cut off, and only then.
13
+ *
14
+ * Around one element that cuts its own text short (`text-overflow: ellipsis`): pointed at, the element is
15
+ * measured, and the whole text shows in the house tooltip when it did not fit. An element whose text fits
16
+ * shows nothing -- a tooltip repeating the words that stand right there is noise. The child is the element
17
+ * itself, not a component, so the measuring reaches the box that cuts.
18
+ */
19
+ export function PhiTruncatedHoverText({ title, children, }) {
20
+ // A callback ref held as state: the element is read when it is pointed at, never while rendering.
21
+ const [element, setElement] = useState(null);
22
+ const [open, setOpen] = useState(false);
23
+ const target = cloneElement(children, { ref: setElement });
24
+ return (_jsx(Suspense, { fallback: children, children: _jsx(PhiLazyTooltip, { title: title, open: open, onOpenChange: (next) => setOpen(next && isPhiElementTruncated(element)), children: target }) }));
25
+ }
@@ -1,4 +1,4 @@
1
- import { type ComponentType } from "react";
1
+ import type { ComponentType } from "react";
2
2
  import type { PhiFormFieldProviderProps } from "./form-provider-registry";
3
3
  /**
4
4
  * The `link-target` field: one link, to a Page of an Area or to an address elsewhere (`FORMS.md`).