@phis/ui 0.4.4 → 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 (183) 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-background-control.d.ts +6 -1
  6. package/components/controls/phi-background-control.js +12 -4
  7. package/components/controls/phi-button-control.d.ts +13 -1
  8. package/components/controls/phi-button-control.js +21 -3
  9. package/components/controls/phi-dropdown-control.js +2 -2
  10. package/components/controls/phi-media-asset-tile-control.js +10 -10
  11. package/components/controls/phi-progress-control.d.ts +10 -2
  12. package/components/controls/phi-progress-control.js +6 -2
  13. package/components/controls/phi-ribbon-control.d.ts +4 -1
  14. package/components/controls/phi-ribbon-control.js +5 -3
  15. package/components/controls/phi-ribbon-wrap-control.d.ts +7 -1
  16. package/components/controls/phi-ribbon-wrap-control.js +8 -2
  17. package/components/controls/phi-segmented-control.d.ts +4 -1
  18. package/components/controls/phi-segmented-control.js +13 -2
  19. package/components/controls/phi-surface-control.d.ts +2 -0
  20. package/components/controls/phi-surface-control.js +16 -1
  21. package/components/controls/phi-switch-control.d.ts +4 -1
  22. package/components/controls/phi-switch-control.js +8 -2
  23. package/components/controls/phi-tag-control.d.ts +4 -1
  24. package/components/controls/phi-tag-control.js +11 -3
  25. package/components/layouts/phi-layout-view-model.js +10 -1
  26. package/components/regions/clients/cms-region-container-client.js +11 -1
  27. package/components/regions/phi-cms-region-container.js +5 -1
  28. package/components/regions/phi-cms-region-shell.d.ts +10 -0
  29. package/components/regions/phi-cms-region-shell.js +53 -7
  30. package/components/root/phi-root-layout.d.ts +1 -0
  31. package/components/root/phi-root-layout.js +1 -0
  32. package/components/root/phi-root-theme-resolver.js +12 -1
  33. package/components/root/phi-shell-chrome-overlay.d.ts +6 -0
  34. package/components/root/phi-shell-chrome-overlay.js +7 -1
  35. package/components/runtime/runtime-module-context.d.ts +12 -1
  36. package/components/runtime/runtime-module-context.js +6 -1
  37. package/components/shell/phi-cms-shell.d.ts +7 -1
  38. package/components/shell/phi-cms-shell.js +4 -2
  39. package/components/shell/use-phi-shell-header-bands.d.ts +5 -0
  40. package/components/shell/use-phi-shell-header-bands.js +64 -0
  41. package/components/shell/use-phi-shell-sticky-bottom.d.ts +18 -0
  42. package/components/shell/use-phi-shell-sticky-bottom.js +54 -0
  43. package/components/tables/client/phi-table-binding.d.ts +1 -0
  44. package/components/tables/client/phi-table-binding.js +22 -3
  45. package/components/trees/client/phi-tree-binding.d.ts +1 -0
  46. package/components/trees/client/phi-tree-binding.js +11 -2
  47. package/components/widgets/client/shared/phi-collection-provider.js +4 -3
  48. package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
  49. package/components/widgets/client/shared/phi-collection-view-binding.js +16 -2
  50. package/components/widgets/client/shared/phi-command-buttons.js +6 -2
  51. package/components/widgets/config/background.d.ts +20 -0
  52. package/components/widgets/config/background.js +44 -2
  53. package/components/widgets/config/button-variant.d.ts +22 -4
  54. package/components/widgets/config/button-variant.js +24 -5
  55. package/components/widgets/config/common-action-field.d.ts +1 -1
  56. package/components/widgets/config/parser-primitives.js +4 -2
  57. package/components/widgets/config/theme-gradient.d.ts +11 -0
  58. package/components/widgets/config/theme-gradient.js +12 -0
  59. package/components/widgets/label-sets/background.js +2 -0
  60. package/components/widgets/label-sets/geometry.js +2 -0
  61. package/components/widgets/label-sets/inspector.js +4 -0
  62. package/components/widgets/label-types/background.d.ts +1 -0
  63. package/components/widgets/label-types/background.js +1 -0
  64. package/components/widgets/label-types/common-controls.js +2 -2
  65. package/components/widgets/label-types/geometry.d.ts +1 -0
  66. package/components/widgets/label-types/geometry.js +1 -0
  67. package/components/widgets/label-types/inspector.d.ts +4 -0
  68. package/components/widgets/label-types/inspector.js +2 -0
  69. package/components/widgets/shared/card-body-client.d.ts +11 -0
  70. package/components/widgets/shared/card-body-client.js +32 -4
  71. package/components/widgets/shared/collection-source-failure.d.ts +26 -0
  72. package/components/widgets/shared/collection-source-failure.js +42 -0
  73. package/components/widgets/shared/markdown-render.js +16 -3
  74. package/components/widgets/shared/widget-failure-client.d.ts +10 -0
  75. package/components/widgets/shared/widget-failure-client.js +20 -0
  76. package/components/widgets/shared/widget-failure.d.ts +31 -0
  77. package/components/widgets/shared/widget-failure.js +20 -0
  78. package/components/widgets/shared/widget-failure.server.d.ts +9 -0
  79. package/components/widgets/shared/widget-failure.server.js +12 -0
  80. package/gateway/dashboard-card-memo.d.ts +3 -0
  81. package/gateway/dashboard-card-memo.js +25 -0
  82. package/helpers/cms-region-keys.d.ts +1 -1
  83. package/helpers/layout-style.d.ts +8 -4
  84. package/helpers/layout-style.js +3 -2
  85. package/helpers/mode-paint.d.ts +4 -0
  86. package/helpers/mode-paint.js +47 -0
  87. package/helpers/surface-style.js +33 -11
  88. package/module-dashboard-cards.d.ts +1 -0
  89. package/module-dashboard-cards.js +1 -0
  90. package/module-records.d.ts +7 -0
  91. package/module-records.js +6 -0
  92. package/package.json +1 -1
  93. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +1 -1
  94. package/plugins/runtime-modules/builder/clients/inspector-surface-labels.js +1 -0
  95. package/plugins/runtime-modules/builder/clients/region-inspector.js +47 -2
  96. package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +1 -1
  97. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +7 -4
  98. package/plugins/runtime-modules/builder/controller/page-controller.js +7 -0
  99. package/plugins/runtime-modules/builder/persistence.d.ts +3 -0
  100. package/plugins/runtime-modules/builder/persistence.js +9 -1
  101. package/plugins/runtime-modules/core/content-entries/record-source.server.d.ts +3 -1
  102. package/plugins/runtime-modules/core/content-entries/record-source.server.js +7 -4
  103. package/plugins/runtime-modules/core/widgets/button/client.js +2 -2
  104. package/plugins/runtime-modules/core/widgets/button/config.d.ts +40 -4
  105. package/plugins/runtime-modules/core/widgets/button/config.js +12 -0
  106. package/plugins/runtime-modules/core/widgets/card/config.d.ts +94 -0
  107. package/plugins/runtime-modules/core/widgets/card/config.js +38 -0
  108. package/plugins/runtime-modules/core/widgets/card/editor.js +8 -1
  109. package/plugins/runtime-modules/core/widgets/card/server.js +4 -0
  110. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +4 -1
  111. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -3
  112. package/plugins/runtime-modules/core/widgets/collection-view/authoring.js +1 -1
  113. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +3 -0
  114. package/plugins/runtime-modules/core/widgets/collection-view/client.js +47 -11
  115. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +4 -1
  116. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
  117. package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +3 -2
  118. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +6 -1
  119. package/plugins/runtime-modules/core/widgets/collection-view/server.js +21 -3
  120. package/plugins/runtime-modules/core/widgets/entry-detail/plugin.js +1 -1
  121. package/plugins/runtime-modules/core/widgets/entry-detail/server.d.ts +3 -1
  122. package/plugins/runtime-modules/core/widgets/entry-detail/server.js +5 -2
  123. package/plugins/runtime-modules/core/widgets/entry-header/plugin.js +1 -1
  124. package/plugins/runtime-modules/core/widgets/entry-header/server.d.ts +3 -1
  125. package/plugins/runtime-modules/core/widgets/entry-header/server.js +5 -2
  126. package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -1
  127. package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +6 -3
  128. package/plugins/runtime-modules/core/widgets/entry-list/server.js +13 -6
  129. package/plugins/runtime-modules/core/widgets/gallery/plugin.js +1 -1
  130. package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -3
  131. package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -6
  132. package/plugins/runtime-modules/core/widgets/record/client.d.ts +4 -1
  133. package/plugins/runtime-modules/core/widgets/record/client.js +8 -3
  134. package/plugins/runtime-modules/core/widgets/record/plugin.js +3 -2
  135. package/plugins/runtime-modules/core/widgets/record/server.d.ts +3 -1
  136. package/plugins/runtime-modules/core/widgets/record/server.js +2 -2
  137. package/plugins/runtime-modules/core/widgets/segmented/client.js +1 -1
  138. package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +21 -1
  139. package/plugins/runtime-modules/core/widgets/segmented/config.js +11 -1
  140. package/plugins/runtime-modules/core/widgets/switch/client.js +1 -1
  141. package/plugins/runtime-modules/core/widgets/switch/config.d.ts +19 -0
  142. package/plugins/runtime-modules/core/widgets/switch/config.js +11 -0
  143. package/plugins/runtime-modules/core/widgets/table/authoring.js +1 -1
  144. package/plugins/runtime-modules/core/widgets/table/client.d.ts +4 -1
  145. package/plugins/runtime-modules/core/widgets/table/client.js +16 -3
  146. package/plugins/runtime-modules/core/widgets/table/plugin.js +3 -2
  147. package/plugins/runtime-modules/core/widgets/table/server.d.ts +3 -1
  148. package/plugins/runtime-modules/core/widgets/table/server.js +2 -2
  149. package/plugins/runtime-modules/core/widgets/table/static-resource-editor.js +2 -1
  150. package/plugins/runtime-modules/core/widgets/timeline/authoring.js +1 -1
  151. package/plugins/runtime-modules/core/widgets/timeline/client.d.ts +1 -3
  152. package/plugins/runtime-modules/core/widgets/timeline/client.js +14 -4
  153. package/plugins/runtime-modules/core/widgets/tree/authoring.js +1 -1
  154. package/plugins/runtime-modules/core/widgets/tree/client.d.ts +4 -1
  155. package/plugins/runtime-modules/core/widgets/tree/client.js +13 -2
  156. package/plugins/runtime-modules/core/widgets/tree/plugin.js +3 -2
  157. package/plugins/runtime-modules/core/widgets/tree/server.d.ts +3 -1
  158. package/plugins/runtime-modules/core/widgets/tree/server.js +2 -2
  159. package/plugins/runtime-modules/theme/presets.d.ts +9 -1
  160. package/plugins/runtime-modules/theme/tour.d.ts +9 -1
  161. package/plugins/runtime-modules/theme/tour.js +10 -1
  162. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +138 -7
  163. package/runtime-data-provider-client.d.ts +2 -0
  164. package/runtime-data-provider-client.js +7 -0
  165. package/styles/controls.css +10 -5
  166. package/styles/gradients.css +101 -0
  167. package/styles/root.css +18 -0
  168. package/styles/shell.css +64 -0
  169. package/theme/phi-button-shadow.d.ts +6 -0
  170. package/theme/phi-theme-gradients.d.ts +96 -0
  171. package/theme/phi-theme-gradients.js +245 -0
  172. package/theme/phi-theme-presets.d.ts +3 -0
  173. package/theme/phi-theme-presets.js +3 -0
  174. package/theme/phi-theme-tokens.d.ts +5 -1
  175. package/theme/phi-theme-tokens.js +14 -0
  176. package/types/cms-presets.d.ts +7 -0
  177. package/types/core-widget-placements.d.ts +3 -0
  178. package/types/layout-style.d.ts +9 -8
  179. package/types/layout-style.js +9 -8
  180. package/types/surface.d.ts +4 -0
  181. package/types/surface.js +4 -0
  182. package/types.d.ts +1 -1
  183. package/types.js +1 -1
@@ -0,0 +1,245 @@
1
+ /**
2
+ * The Theme's gradients: three named slots, like the ten custom colours, that a control can take its
3
+ * ground from instead of from one colour.
4
+ *
5
+ * A gradient belongs to a mode for the reason a mode seed does: the ground that reads as a brand on a
6
+ * light page -- a deep burgundy run -- is a hole in a dark one, where the same brand reads as gold. So a
7
+ * palette states each slot per mode (`modes[mode].gradients`), and a slot it leaves out is derived from
8
+ * the mode's own colours, which is what lets every Theme offer all three without anybody drawing them.
9
+ *
10
+ * They reach the page as Ant Design tokens -- `phiGradient1` and its `phiGradient1Text` -- and Ant Design
11
+ * writes every token as a custom property under the Theme's class (`--ant-phi-gradient-1`). That is the
12
+ * whole transport: the root writes both modes, a Surface tone writes its own mode on its box, and the
13
+ * Theme workspace's preview writes the draft's, so a control that reads the property is in the right mode
14
+ * wherever it stands without asking which one that is.
15
+ */
16
+ export const PHI_THEME_GRADIENT_KEYS = ["gradient1", "gradient2", "gradient3"];
17
+ export const PHI_THEME_GRADIENT_TEXT_TONES = ["light", "dark"];
18
+ function isPhiThemeGradientKey(value) {
19
+ return typeof value === "string" && PHI_THEME_GRADIENT_KEYS.includes(value);
20
+ }
21
+ /** A slot as a value a control or a widget config may store; anything else reads as no gradient. */
22
+ export function readPhiThemeGradientKey(value) {
23
+ return isPhiThemeGradientKey(value) ? value : undefined;
24
+ }
25
+ function isGradientDirection(value) {
26
+ return typeof value === "string"
27
+ && (["to right", "to left", "to bottom", "to top"].includes(value) || /^-?\d+(\.\d+)?deg$/.test(value));
28
+ }
29
+ /** The text tone a stored slot states, with or without a run of its own. */
30
+ export function readPhiThemeGradientTextTone(value) {
31
+ const text = value && typeof value === "object" ? value.text : undefined;
32
+ return PHI_THEME_GRADIENT_TEXT_TONES.find((tone) => tone === text);
33
+ }
34
+ /** A stored gradient, read strictly: two stops at least, each a colour and a place on the run. */
35
+ export function readPhiThemeGradient(value) {
36
+ if (!value || typeof value !== "object")
37
+ return null;
38
+ const raw = value;
39
+ if (!isGradientDirection(raw.direction) || !Array.isArray(raw.stops))
40
+ return null;
41
+ const stops = raw.stops.flatMap((stop) => {
42
+ if (!stop || typeof stop !== "object")
43
+ return [];
44
+ const { color, percent } = stop;
45
+ return typeof color === "string" && color.trim() && typeof percent === "number" && Number.isFinite(percent)
46
+ ? [{ color: color.trim(), percent: Math.min(100, Math.max(0, percent)) }]
47
+ : [];
48
+ });
49
+ if (stops.length < 2)
50
+ return null;
51
+ const text = PHI_THEME_GRADIENT_TEXT_TONES.find((tone) => tone === raw.text);
52
+ return { direction: raw.direction, stops, ...(text ? { text } : {}) };
53
+ }
54
+ function serializePhiThemeGradientCss(gradient) {
55
+ return `linear-gradient(${gradient.direction}, ${gradient.stops.map((stop) => `${stop.color} ${stop.percent}%`).join(", ")})`;
56
+ }
57
+ /*
58
+ * The custom properties, named the way Ant Design names a token's (`token2CSSVar`): `phiGradient1Text`
59
+ * becomes `--ant-phi-gradient-1-text`. Stated once so CSS and controls never spell them differently.
60
+ */
61
+ const PHI_THEME_GRADIENT_TOKEN_NAMES = {
62
+ gradient1: { paint: "phiGradient1", text: "phiGradient1Text" },
63
+ gradient2: { paint: "phiGradient2", text: "phiGradient2Text" },
64
+ gradient3: { paint: "phiGradient3", text: "phiGradient3Text" },
65
+ };
66
+ export const PHI_THEME_GRADIENT_CSS_VARS = {
67
+ gradient1: { paint: "--ant-phi-gradient-1", text: "--ant-phi-gradient-1-text" },
68
+ gradient2: { paint: "--ant-phi-gradient-2", text: "--ant-phi-gradient-2-text" },
69
+ gradient3: { paint: "--ant-phi-gradient-3", text: "--ant-phi-gradient-3-text" },
70
+ };
71
+ /*
72
+ * The primary Buttons' run when the Theme gives them one, with the filter each pressed state lays over
73
+ * it; `none` in all three otherwise, so the rules in `styles/gradients.css` change nothing on a Theme
74
+ * that never asked for a gradient. The states are filters rather than a second picture: Ant Design
75
+ * transitions every property of a Button, and a picture swapped on hover crossfades badly -- it
76
+ * flickered as the pointer left -- where a filter eases.
77
+ */
78
+ const PHI_PRIMARY_BUTTON_GRADIENT_TOKENS = {
79
+ paint: "phiPrimaryButtonGradient",
80
+ hover: "phiPrimaryButtonGradientHover",
81
+ active: "phiPrimaryButtonGradientActive",
82
+ text: "phiPrimaryButtonGradientText",
83
+ };
84
+ /** A run a little lighter under the pointer, a little darker while it is pressed. */
85
+ export const PHI_GRADIENT_HOVER_FILTER = "brightness(1.18) saturate(1.15)";
86
+ const PHI_GRADIENT_ACTIVE_FILTER = "brightness(0.88)";
87
+ /* Enough of CSS colour for what a palette states: hex in its four lengths and `rgb()`/`rgba()`. */
88
+ function parseColor(value) {
89
+ const text = value.trim().toLowerCase();
90
+ const hex = /^#([0-9a-f]{3,8})$/.exec(text)?.[1];
91
+ if (hex) {
92
+ const full = hex.length <= 4 ? [...hex].map((digit) => digit + digit).join("") : hex;
93
+ return {
94
+ r: Number.parseInt(full.slice(0, 2), 16),
95
+ g: Number.parseInt(full.slice(2, 4), 16),
96
+ b: Number.parseInt(full.slice(4, 6), 16),
97
+ a: full.length >= 8 ? Number.parseInt(full.slice(6, 8), 16) / 255 : 1,
98
+ };
99
+ }
100
+ const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+)(%?))?/.exec(text);
101
+ if (!rgb)
102
+ return null;
103
+ const alpha = rgb[4] == null ? 1 : Number(rgb[4]) / (rgb[5] ? 100 : 1);
104
+ return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]), a: Math.min(1, Math.max(0, alpha)) };
105
+ }
106
+ /** A translucent text colour as it lands on its ground: the near-black `0.88` text is not black. */
107
+ function composite(top, ground) {
108
+ const mix = (front, back) => front * top.a + back * (1 - top.a);
109
+ return { r: mix(top.r, ground.r), g: mix(top.g, ground.g), b: mix(top.b, ground.b) };
110
+ }
111
+ /* What `filter: brightness(n)` does to a colour: each channel scaled and clipped. */
112
+ function brighten(colour, factor) {
113
+ const scale = (channel) => Math.min(255, channel * factor);
114
+ return { r: scale(colour.r), g: scale(colour.g), b: scale(colour.b) };
115
+ }
116
+ function relativeLuminance({ r, g, b }) {
117
+ const channel = (value) => {
118
+ const c = value / 255;
119
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
120
+ };
121
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
122
+ }
123
+ function contrastOf(first, second) {
124
+ const [light, dark] = [relativeLuminance(first), relativeLuminance(second)].sort((x, y) => y - x);
125
+ return (light + 0.05) / (dark + 0.05);
126
+ }
127
+ /** How much lighter a gradient Control is under the pointer (`styles/gradients.css`). */
128
+ const PHI_GRADIENT_HOVER_BRIGHTNESS = 1.18;
129
+ const PHI_GRADIENT_LIGHT_TEXT = "#ffffff";
130
+ const PHI_GRADIENT_DARK_TEXT = "rgba(0, 0, 0, 0.88)";
131
+ /** The two text colours of one mode's resolved tokens (`PhiThemeGradientInks`). */
132
+ export function resolvePhiThemeGradientInks(token) {
133
+ const light = tokenColor(token, "colorTextLightSolid", PHI_GRADIENT_LIGHT_TEXT);
134
+ const candidates = [tokenColor(token, "colorText", PHI_GRADIENT_DARK_TEXT), tokenColor(token, "colorBgBase", PHI_GRADIENT_DARK_TEXT)];
135
+ const darkness = (colour) => {
136
+ const parsed = parseColor(colour);
137
+ return parsed ? relativeLuminance(composite(parsed, { r: 255, g: 255, b: 255 })) : Number.POSITIVE_INFINITY;
138
+ };
139
+ const dark = candidates.reduce((darkest, next) => (darkness(next) < darkness(darkest) ? next : darkest));
140
+ return { light, dark: Number.isFinite(darkness(dark)) ? dark : PHI_GRADIENT_DARK_TEXT };
141
+ }
142
+ /**
143
+ * Where a text colour reads worst on the run. Text crosses the whole run, so the stop it reads worst on
144
+ * decides -- at rest and under the pointer, where the hover filter lightens run and words alike. A
145
+ * translucent text colour is laid on each stop first. `null` where a colour is not one this can read
146
+ * (`hsl()`, a variable): the Theme workspace then says nothing rather than something wrong.
147
+ */
148
+ export function resolvePhiThemeGradientContrast(gradient, text) {
149
+ const words = parseColor(text);
150
+ if (!words)
151
+ return null;
152
+ let worst = null;
153
+ for (const [stopIndex, stop] of gradient.stops.entries()) {
154
+ const ground = parseColor(stop.color);
155
+ if (!ground)
156
+ return null;
157
+ for (const hover of [false, true]) {
158
+ const factor = hover ? PHI_GRADIENT_HOVER_BRIGHTNESS : 1;
159
+ const lit = brighten(ground, factor);
160
+ const ratio = contrastOf(lit, brighten(composite(words, ground), factor));
161
+ if (worst == null || ratio < worst.ratio - 1e-9) {
162
+ worst = { ratio, stopIndex, color: stop.color, hover };
163
+ }
164
+ }
165
+ }
166
+ return worst;
167
+ }
168
+ /** The weakest contrast a text colour has anywhere on the run, at rest or under the pointer. */
169
+ export function resolvePhiThemeGradientWorstContrast(gradient, text) {
170
+ return resolvePhiThemeGradientContrast(gradient, text)?.ratio ?? null;
171
+ }
172
+ /** Which of the two text colours reads better where the run reads worst for it. */
173
+ export function resolvePhiThemeGradientAutoTextTone(gradient, inks) {
174
+ const light = resolvePhiThemeGradientWorstContrast(gradient, inks.light) ?? 0;
175
+ const dark = resolvePhiThemeGradientWorstContrast(gradient, inks.dark) ?? 0;
176
+ return light >= dark ? "light" : "dark";
177
+ }
178
+ function tokenColor(token, key, fallback) {
179
+ const value = token[key];
180
+ return typeof value === "string" && value.trim() ? value : fallback;
181
+ }
182
+ /**
183
+ * The three slots a mode offers when its palette states none: runs within the mode's own colours, so they
184
+ * belong to whichever brand the Theme carries. The primary's hover into its pressed shade first -- the
185
+ * brand --, the warning colour second because a palette's accent sits there, then the info colour into
186
+ * the primary, a run for the chrome. Three cover what a site asks of a run; a fourth was the third
187
+ * turned round.
188
+ */
189
+ function buildPhiThemeDefaultGradients(token) {
190
+ const primary = tokenColor(token, "colorPrimary", "#1677ff");
191
+ const primaryHover = tokenColor(token, "colorPrimaryHover", primary);
192
+ const primaryActive = tokenColor(token, "colorPrimaryActive", primary);
193
+ const warning = tokenColor(token, "colorWarning", "#faad14");
194
+ const warningHover = tokenColor(token, "colorWarningHover", warning);
195
+ const warningActive = tokenColor(token, "colorWarningActive", warning);
196
+ const info = tokenColor(token, "colorInfo", primary);
197
+ return {
198
+ gradient1: { direction: "135deg", stops: [{ color: primaryHover, percent: 0 }, { color: primaryActive, percent: 100 }] },
199
+ gradient2: { direction: "135deg", stops: [{ color: warningHover, percent: 0 }, { color: warningActive, percent: 100 }] },
200
+ gradient3: { direction: "135deg", stops: [{ color: info, percent: 0 }, { color: primary, percent: 100 }] },
201
+ };
202
+ }
203
+ /** Every slot of one mode: what the palette states, the derived run where it states nothing. */
204
+ export function resolvePhiThemeGradients(stated, token) {
205
+ const defaults = buildPhiThemeDefaultGradients(token);
206
+ return Object.fromEntries(PHI_THEME_GRADIENT_KEYS.map((key) => {
207
+ const own = readPhiThemeGradient(stated?.[key]);
208
+ const text = readPhiThemeGradientTextTone(stated?.[key]);
209
+ return [key, own ?? (text ? { ...defaults[key], text } : defaults[key])];
210
+ }));
211
+ }
212
+ /** The text colour on a run: the tone it states, else the one that reads better. */
213
+ export function resolvePhiThemeGradientText(gradient, inks) {
214
+ return inks[gradient.text ?? resolvePhiThemeGradientAutoTextTone(gradient, inks)];
215
+ }
216
+ /**
217
+ * The tokens one mode's gradients become, and the primary Buttons' run when the Theme asks for one.
218
+ *
219
+ * Laid over the resolved alias tokens rather than fed to the algorithm: they are not seeds, nothing
220
+ * derives from them, and they are read back only as the custom properties Ant Design writes for them.
221
+ */
222
+ export function buildPhiThemeGradientTokens({ gradients, token, primaryButtonGradient, }) {
223
+ const resolved = resolvePhiThemeGradients(gradients, token);
224
+ const inks = resolvePhiThemeGradientInks(token);
225
+ const tokens = {};
226
+ for (const key of PHI_THEME_GRADIENT_KEYS) {
227
+ const names = PHI_THEME_GRADIENT_TOKEN_NAMES[key];
228
+ tokens[names.paint] = serializePhiThemeGradientCss(resolved[key]);
229
+ tokens[names.text] = resolvePhiThemeGradientText(resolved[key], inks);
230
+ }
231
+ if (primaryButtonGradient && isPhiThemeGradientKey(primaryButtonGradient)) {
232
+ const paint = tokens[PHI_THEME_GRADIENT_TOKEN_NAMES[primaryButtonGradient].paint];
233
+ tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.paint] = paint;
234
+ tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.hover] = PHI_GRADIENT_HOVER_FILTER;
235
+ tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.active] = PHI_GRADIENT_ACTIVE_FILTER;
236
+ // Only stated with a run under it: absent, the rule falls back to Ant Design's own primary text.
237
+ tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.text] = tokens[PHI_THEME_GRADIENT_TOKEN_NAMES[primaryButtonGradient].text];
238
+ }
239
+ else {
240
+ tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.paint] = "none";
241
+ tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.hover] = "none";
242
+ tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.active] = "none";
243
+ }
244
+ return tokens;
245
+ }
@@ -1,3 +1,4 @@
1
+ import type { PhiThemeGradientPalette } from "./phi-theme-gradients";
1
2
  export type PhiThemeMode = "light" | "dark";
2
3
  export type PhiThemeCustomColorKey = "custom1" | "custom2" | "custom3" | "custom4" | "custom5" | "custom6" | "custom7" | "custom8" | "custom9" | "custom10";
3
4
  export type PhiThemeCustomColorPalette = Record<PhiThemeCustomColorKey, string>;
@@ -14,6 +15,8 @@ export type PhiThemePaletteMode = {
14
15
  seed?: Record<string, string>;
15
16
  overrides?: Record<string, string>;
16
17
  customColors?: Partial<PhiThemeCustomColorPalette>;
18
+ /** The mode's gradient slots (theme/phi-theme-gradients.ts); a slot left out is derived. */
19
+ gradients?: PhiThemeGradientPalette;
17
20
  };
18
21
  /**
19
22
  * A palette: the colour of a Theme, in the one shape a Module ships it in and a Site owns it in.
@@ -107,6 +107,9 @@ function mergePhiThemePaletteModes(base, own) {
107
107
  ...(base?.customColors || own?.customColors
108
108
  ? { customColors: { ...(base?.customColors ?? {}), ...(own?.customColors ?? {}) } }
109
109
  : {}),
110
+ ...(base?.gradients || own?.gradients
111
+ ? { gradients: { ...(base?.gradients ?? {}), ...(own?.gradients ?? {}) } }
112
+ : {}),
110
113
  };
111
114
  }
112
115
  /**
@@ -34,8 +34,12 @@ export declare const PHI_THEME_TOKEN_KEYS: readonly ["colorBgContainer", "colorB
34
34
  * It is a separate list and not one more entry above, because `PhiThemeTokens` is cut from Ant
35
35
  * Design's type and a name Ant Design does not know cannot be cut from it. A Client Component that
36
36
  * needs one of these reads it as a CSS variable, the way a Server Component does.
37
+ *
38
+ * The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
39
+ * (theme/phi-theme-gradients.ts): tokens of this package's own, laid over the resolved ones so Ant
40
+ * Design writes them per mode and per Surface tone like every other.
37
41
  */
38
- export declare const PHI_THEME_OWN_TOKEN_KEYS: readonly ["paddingXXL"];
42
+ export declare const PHI_THEME_OWN_TOKEN_KEYS: readonly ["paddingXXL", "phiGradient1", "phiGradient1Text", "phiGradient2", "phiGradient2Text", "phiGradient3", "phiGradient3Text", "phiPrimaryButtonGradient", "phiPrimaryButtonGradientHover", "phiPrimaryButtonGradientActive", "phiPrimaryButtonGradientText"];
39
43
  export type PhiThemeTokenKey = (typeof PHI_THEME_TOKEN_KEYS)[number];
40
44
  /**
41
45
  * The resolved Theme, in the names above and their Ant Design value types.
@@ -162,9 +162,23 @@ export const PHI_THEME_TOKEN_KEYS = [
162
162
  * It is a separate list and not one more entry above, because `PhiThemeTokens` is cut from Ant
163
163
  * Design's type and a name Ant Design does not know cannot be cut from it. A Client Component that
164
164
  * needs one of these reads it as a CSS variable, the way a Server Component does.
165
+ *
166
+ * The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
167
+ * (theme/phi-theme-gradients.ts): tokens of this package's own, laid over the resolved ones so Ant
168
+ * Design writes them per mode and per Surface tone like every other.
165
169
  */
166
170
  export const PHI_THEME_OWN_TOKEN_KEYS = [
167
171
  "paddingXXL",
172
+ "phiGradient1",
173
+ "phiGradient1Text",
174
+ "phiGradient2",
175
+ "phiGradient2Text",
176
+ "phiGradient3",
177
+ "phiGradient3Text",
178
+ "phiPrimaryButtonGradient",
179
+ "phiPrimaryButtonGradientHover",
180
+ "phiPrimaryButtonGradientActive",
181
+ "phiPrimaryButtonGradientText",
168
182
  ];
169
183
  /**
170
184
  * The colours a palette seeds, shared by both modes.
@@ -37,11 +37,18 @@ export type PhiCmsRegionConfig = Record<string, unknown> & PhiCmsContainerChrome
37
37
  fontSize?: CSSProperties["fontSize"];
38
38
  lineHeight?: CSSProperties["lineHeight"];
39
39
  offsetTop?: PhiCssLength;
40
+ /** The air below a `Sticky` `footer_bottom` when it sticks to the viewport's bottom; nobody else reads it. */
41
+ offsetBottom?: PhiCssLength;
40
42
  zIndex?: number;
41
43
  /** Which of the Area's Pages show this Shell Region (`helpers/region-page-scope.ts`). */
42
44
  pageScope?: PhiCmsRegionPageScope;
43
45
  /** How `header_top` comes into view (`helpers/region-page-scope.ts`); every other Region ignores it. */
44
46
  reveal?: PhiCmsRegionReveal;
47
+ /**
48
+ * How far the Page's `content` reaches up into its Hero, the Hero's picture running on under it (SHELL.md
49
+ * "Content reaching into the Hero"). Read on `content` alone, and only where the Page has a Hero.
50
+ */
51
+ heroOverlap?: PhiCssLength;
45
52
  };
46
53
  /**
47
54
  * Which Pages a Shell Region stands on (SHELL.md "Region visibility per Page").
@@ -14,6 +14,7 @@ import type { PhiViewerAccessPolicy } from "./access";
14
14
  import type { PhiWidgetFontFamilyKey, PhiWidgetFontSizeKey } from "./site-theme";
15
15
  import type { PhiTableQuery, PhiTableWidgetConfig, PhiTableWidgetFeatures, PhiTableWidgetPresentation } from "./table-widget";
16
16
  import type { PhiButtonVariant } from "../components/widgets/config/button-variant";
17
+ import type { PhiThemeGradientKey } from "../theme/phi-theme-gradients";
17
18
  import type { PhiTextTone } from "../components/widgets/config/text-tone";
18
19
  import type { PhiCommonControlActionKey } from "../components/widgets/label-types/common-controls";
19
20
  import type { PhiMaskConfig } from "../components/widgets/config/mask";
@@ -97,6 +98,8 @@ export type PhiButtonWidgetPlacement = PhiWidgetPlacementBase & PhiControlPlacem
97
98
  icon?: string;
98
99
  value?: string;
99
100
  variant?: PhiButtonVariant;
101
+ /** The Theme gradient slot a `gradient` Button is filled with; absent, the first. */
102
+ gradient?: PhiThemeGradientKey;
100
103
  linkTarget?: PhiLinkTarget;
101
104
  danger?: boolean;
102
105
  };
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * The Background filters that are a pane rather than a treatment of the paint itself.
3
3
  *
4
- * `glass` and `haze` are the same thing at two strengths: a sheet that frosts what shows through it.
5
- * `glass` is the frosted pane, `haze` the barely clouded one -- both a smaller radius and more of the
6
- * ground let through, because moving only one of the two reads as a dirty window rather than as
7
- * lighter glass. Everything that used to test for `glass` asks this instead, so a further strength
8
- * would be a table entry and not another branch.
4
+ * `clear`, `glass` and `haze` are the same thing at three strengths: a sheet that frosts what shows
5
+ * through it, light, medium and strong. The frost and the share of the ground's colour rise together,
6
+ * because moving only one of the two reads as a dirty window rather than as another strength of glass.
7
+ * `clear` lifts and saturates what it shows so it still reads as glass with little tint. Everything
8
+ * that used to test for `glass` asks this instead, so a further strength is a table entry and not
9
+ * another branch.
9
10
  */
10
- export declare const PHI_GLASS_LAYOUT_EFFECT_IDS: readonly ["glass", "haze"];
11
+ export declare const PHI_GLASS_LAYOUT_EFFECT_IDS: readonly ["glass", "haze", "clear"];
11
12
  export type PhiGlassLayoutEffectId = (typeof PHI_GLASS_LAYOUT_EFFECT_IDS)[number];
12
13
  export declare function isPhiGlassLayoutEffectId(value: unknown): value is PhiGlassLayoutEffectId;
13
14
  export declare const PHI_SHADOW_IDS: readonly ["none", "soft", "strong"];
@@ -22,11 +23,11 @@ export declare function readPhiShadow(value: unknown): PhiShadow | undefined;
22
23
  /**
23
24
  * What a Background does to the light that reaches it, beside what it paints.
24
25
  *
25
- * `glass` and `haze` are panes: they frost what shows THROUGH the surface, so they act on the backdrop and
26
+ * `glass`, `haze` and `clear` are panes: they frost what shows THROUGH the surface, so they act on the backdrop and
26
27
  * on a ground thinned enough to let it through. `blur` softens the Background's own paint -- the picture,
27
28
  * the gradient, the pattern -- and nothing in front of it: the content a surface carries is never filtered.
28
29
  * Darkening is not a filter; a colour Overlay at an opacity does it, and lets the colour be chosen.
29
30
  */
30
- export declare const PHI_BACKGROUND_FILTERS: readonly ["glass", "haze", "blur"];
31
+ export declare const PHI_BACKGROUND_FILTERS: readonly ["glass", "haze", "clear", "blur"];
31
32
  export type PhiBackgroundFilter = (typeof PHI_BACKGROUND_FILTERS)[number];
32
33
  export declare function isPhiBackgroundFilter(value: unknown): value is PhiBackgroundFilter;
@@ -2,13 +2,14 @@ import { isPhiRecord } from "../helpers/is-record";
2
2
  /**
3
3
  * The Background filters that are a pane rather than a treatment of the paint itself.
4
4
  *
5
- * `glass` and `haze` are the same thing at two strengths: a sheet that frosts what shows through it.
6
- * `glass` is the frosted pane, `haze` the barely clouded one -- both a smaller radius and more of the
7
- * ground let through, because moving only one of the two reads as a dirty window rather than as
8
- * lighter glass. Everything that used to test for `glass` asks this instead, so a further strength
9
- * would be a table entry and not another branch.
5
+ * `clear`, `glass` and `haze` are the same thing at three strengths: a sheet that frosts what shows
6
+ * through it, light, medium and strong. The frost and the share of the ground's colour rise together,
7
+ * because moving only one of the two reads as a dirty window rather than as another strength of glass.
8
+ * `clear` lifts and saturates what it shows so it still reads as glass with little tint. Everything
9
+ * that used to test for `glass` asks this instead, so a further strength is a table entry and not
10
+ * another branch.
10
11
  */
11
- export const PHI_GLASS_LAYOUT_EFFECT_IDS = ["glass", "haze"];
12
+ export const PHI_GLASS_LAYOUT_EFFECT_IDS = ["glass", "haze", "clear"];
12
13
  export function isPhiGlassLayoutEffectId(value) {
13
14
  return typeof value === "string" && PHI_GLASS_LAYOUT_EFFECT_IDS.includes(value);
14
15
  }
@@ -32,12 +33,12 @@ export function readPhiShadow(value) {
32
33
  /**
33
34
  * What a Background does to the light that reaches it, beside what it paints.
34
35
  *
35
- * `glass` and `haze` are panes: they frost what shows THROUGH the surface, so they act on the backdrop and
36
+ * `glass`, `haze` and `clear` are panes: they frost what shows THROUGH the surface, so they act on the backdrop and
36
37
  * on a ground thinned enough to let it through. `blur` softens the Background's own paint -- the picture,
37
38
  * the gradient, the pattern -- and nothing in front of it: the content a surface carries is never filtered.
38
39
  * Darkening is not a filter; a colour Overlay at an opacity does it, and lets the colour be chosen.
39
40
  */
40
- export const PHI_BACKGROUND_FILTERS = ["glass", "haze", "blur"];
41
+ export const PHI_BACKGROUND_FILTERS = ["glass", "haze", "clear", "blur"];
41
42
  export function isPhiBackgroundFilter(value) {
42
43
  return typeof value === "string" && PHI_BACKGROUND_FILTERS.includes(value);
43
44
  }
@@ -20,6 +20,9 @@ export type PhiSurfaceTone = (typeof PHI_SURFACE_TONES)[number];
20
20
  * `effects`, which say how it arrives rather than what it is.
21
21
  *
22
22
  * - `background` carries its own Filter: a glass pane or a softened paint is something the ground does.
23
+ * - `backgroundDark` is the ground in dark mode, where the box wants another one than in light mode -- a
24
+ * Hero's dark picture for a dark page. Absent, `background` stands in both modes. The page's mode
25
+ * picks, in CSS (`helpers/mode-paint.ts`), so a mode switch needs no render.
23
26
  * - `borderSource` says where the line comes from. Only `custom` reads `border`, corners included; under
24
27
  * `theme` and `none` the corner is the Site's surface step, so a shape change is seen at once.
25
28
  * - `shadow` is depth.
@@ -29,6 +32,7 @@ export type PhiSurfaceTone = (typeof PHI_SURFACE_TONES)[number];
29
32
  */
30
33
  export type PhiSurface = {
31
34
  background?: PhiCmsBackgroundWidgetConfig | null;
35
+ backgroundDark?: PhiCmsBackgroundWidgetConfig | null;
32
36
  borderSource?: PhiCmsBorderSource;
33
37
  border?: PhiCmsBorderWidgetConfig | null;
34
38
  shadow?: PhiShadow | null;
package/types/surface.js CHANGED
@@ -38,6 +38,9 @@ export function readPhiSurface(value) {
38
38
  const background = isPhiRecord(raw.background)
39
39
  ? normalizePhiBackgroundWidgetConfig(raw.background)
40
40
  : null;
41
+ const backgroundDark = isPhiRecord(raw.backgroundDark)
42
+ ? normalizePhiBackgroundWidgetConfig(raw.backgroundDark)
43
+ : null;
41
44
  const borderSource = readPhiCmsBorderSource(raw.borderSource);
42
45
  const border = isPhiRecord(raw.border)
43
46
  ? readPhiCmsBorderWidgetConfig(raw.border) ?? null
@@ -46,6 +49,7 @@ export function readPhiSurface(value) {
46
49
  const tone = isPhiSurfaceTone(raw.tone) && raw.tone !== "inherit" ? raw.tone : undefined;
47
50
  const surface = {
48
51
  ...(background ? { background } : {}),
52
+ ...(backgroundDark ? { backgroundDark } : {}),
49
53
  ...(borderSource ? { borderSource } : {}),
50
54
  ...(border ? { border } : {}),
51
55
  ...(shadow ? { shadow } : {}),
package/types.d.ts CHANGED
@@ -22,7 +22,7 @@ export type { PhiAuthoringRenderPolicy, PhiCmsBuilderWidgetEditorInteraction, Ph
22
22
  export type * from "./types/cms-presets";
23
23
  export type * from "./types/slot-size-policy";
24
24
  export type * from "./types/runtime-data-provider";
25
- export { isPhiRuntimeDataProviderKey } from "./types/runtime-data-provider";
25
+ export { isPhiRuntimeDataProviderKey, readPhiRuntimeDataProviderBinding } from "./types/runtime-data-provider";
26
26
  export type * from "./types/table-widget";
27
27
  export type * from "./types/tree-widget";
28
28
  export type * from "./types/collection-provider";
package/types.js CHANGED
@@ -12,7 +12,7 @@ export * from "./types/spacing";
12
12
  export * from "./types/runtime-condition";
13
13
  export * from "./types/state-machine";
14
14
  export * from "./types/access";
15
- export { isPhiRuntimeDataProviderKey } from "./types/runtime-data-provider";
15
+ export { isPhiRuntimeDataProviderKey, readPhiRuntimeDataProviderBinding } from "./types/runtime-data-provider";
16
16
  export * from "./types/form-id";
17
17
  export { PhiTableProviderError, readPhiTableProviderError, readPhiTableQuery, } from "./types/table-widget";
18
18
  export { PhiTreeProviderError, readPhiTreeProviderError, readPhiTreeProviderQueryResult, readPhiTreeProviderMutationResult, validatePhiTreeWidgetBinding, } from "./types/tree-widget";