@phis/ui 0.4.12 → 0.4.14

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.
@@ -63,7 +63,8 @@ function resolveStoredSolidColor(color) {
63
63
  }
64
64
  export function PhiBackgroundControl({ value, config, disabled = false, mode = "control", labels = PHI_BACKGROUND_WIDGET_DEFAULT_LABELS, colorPickerLabels = PHI_COLOR_PICKER_DEFAULT_LABELS, colorPickerPlacement, motionModes = PHI_BACKGROUND_MOTION_MODES, filters = PHI_BACKGROUND_FILTERS, imageSourceKinds = PHI_BACKGROUND_IMAGE_SOURCE_KINDS, baseKinds = PHI_BACKGROUND_BASE_KINDS, overlay: overlayOffered = true, renderMediaPicker, editTransaction, onChange, }) {
65
65
  const { token } = theme.useToken();
66
- const colorPickerPresets = usePhiColorControlPresets({ labels: colorPickerLabels });
66
+ // A Theme swatch stores its role, so a ground picked from the Theme follows it and the mode.
67
+ const colorPickerPresets = usePhiColorControlPresets({ labels: colorPickerLabels, storeThemeRoles: true });
67
68
  const currentValue = useMemo(() => normalizePhiBackgroundWidgetConfig(value ?? config ?? null), [value, config]);
68
69
  const isDisabled = disabled || !onChange;
69
70
  const colorPickerTransaction = {
@@ -13,4 +13,4 @@ export type PhiBorderControlProps = {
13
13
  colorPickerPlacement?: PhiPickerPlacement;
14
14
  onChange?: (value: PhiCmsBorderWidgetConfig) => void;
15
15
  };
16
- export declare function PhiBorderControl({ value, config, disabled, mode, labels, colorPickerPlacement, onChange, }: PhiBorderControlProps): import("react").JSX.Element;
16
+ export declare function PhiBorderControl({ value, config, disabled, mode, labels, colorPickerLabels, colorPickerPlacement, onChange, }: PhiBorderControlProps): import("react").JSX.Element;
@@ -7,6 +7,7 @@ import { PHI_BORDER_WIDGET_DEFAULT_LABELS, } from "../widgets/label-types/border
7
7
  import { ConfigPreviewShell } from "./config-preview-shell";
8
8
  import { PhiBoundRadiusControl } from "./phi-bound-radius-control";
9
9
  import { PhiColorControl } from "./phi-color-control";
10
+ import { usePhiColorControlPresets } from "./use-phi-color-control-presets";
10
11
  import { PhiCompactGroupControl } from "./phi-compact-group-control";
11
12
  const BORDER_STYLE_OPTIONS = [
12
13
  { value: "solid", label: "Solid" },
@@ -32,8 +33,10 @@ function resolveDisplayBorderColor(color, primaryColor) {
32
33
  }
33
34
  return color;
34
35
  }
35
- export function PhiBorderControl({ value, config, disabled = false, mode = "control", labels = PHI_BORDER_WIDGET_DEFAULT_LABELS, colorPickerPlacement, onChange, }) {
36
+ export function PhiBorderControl({ value, config, disabled = false, mode = "control", labels = PHI_BORDER_WIDGET_DEFAULT_LABELS, colorPickerLabels, colorPickerPlacement, onChange, }) {
36
37
  const { token } = theme.useToken();
38
+ // The Theme's swatches, each storing its role, so a line picked from the Theme follows it and the mode.
39
+ const colorPickerPresets = usePhiColorControlPresets({ labels: colorPickerLabels, storeThemeRoles: true });
37
40
  const currentValue = mergePhiBorderWidgetConfig(config, value);
38
41
  const isDisabled = disabled || !onChange || mode === "preview";
39
42
  const resolvedValue = resolveCurrentValue(currentValue, token.colorPrimary);
@@ -69,7 +72,7 @@ export function PhiBorderControl({ value, config, disabled = false, mode = "cont
69
72
  emit({
70
73
  borderStyle,
71
74
  });
72
- }, style: { width: "58%" } })] }), _jsx(Typography.Text, { children: labels.fields.color }), _jsx(PhiColorControl, { value: displayBorderColor, disabled: isDisabled, mode: "single", placement: colorPickerPlacement, onChange: (resolvedCss) => {
75
+ }, style: { width: "58%" } })] }), _jsx(Typography.Text, { children: labels.fields.color }), _jsx(PhiColorControl, { value: displayBorderColor, disabled: isDisabled, mode: "single", placement: colorPickerPlacement, presets: colorPickerPresets, onChange: (resolvedCss) => {
73
76
  if (resolvedCss == null)
74
77
  return;
75
78
  emit({
@@ -7,6 +7,11 @@ export type PhiColorPickerPreset = {
7
7
  label: string;
8
8
  colors: readonly string[];
9
9
  colorLabels?: readonly string[];
10
+ /**
11
+ * What a swatch stores, where that is not its colour: the Theme role it shows (`PHI_COLOR.primaryBg`,
12
+ * `PHI_COLOR.custom3`). A role follows the Theme and the mode; the colour it showed would stay as it was.
13
+ */
14
+ colorReferences?: readonly string[];
10
15
  defaultOpen?: boolean;
11
16
  };
12
17
  export type PhiColorPickerPresets = readonly PhiColorPickerPreset[];
@@ -7,6 +7,27 @@ import { PhiSelectControl } from "./phi-select-control";
7
7
  import { usePhiImmediatePicker } from "./use-phi-immediate-picker";
8
8
  import { readPhiCssLinearGradient } from "../../helpers/css-linear-gradient";
9
9
  import { joinPhiClassNames } from "../../helpers/class-names";
10
+ /** Every role a set of presets names, with the colour it shows now. */
11
+ function collectPhiColorReferences(presets) {
12
+ const references = new Map();
13
+ for (const preset of presets) {
14
+ preset.colorReferences?.forEach((reference, index) => {
15
+ const color = preset.colors[index];
16
+ if (reference && color)
17
+ references.set(reference, color);
18
+ });
19
+ }
20
+ return references;
21
+ }
22
+ /**
23
+ * A value as the picker can show it: every role in it replaced by the colour it shows now. The value
24
+ * itself keeps the role; only the swatch and the panel need a colour they can parse.
25
+ */
26
+ function resolvePhiColorReferences(value, references) {
27
+ if (!value || references.size === 0 || !value.includes("var("))
28
+ return value;
29
+ return value.replace(/var\(--[a-z0-9-]+\)/giu, (reference) => references.get(reference) ?? reference);
30
+ }
10
31
  const PHI_COLOR_PICKER_CONTENT_WIDTH = 234;
11
32
  /*
12
33
  * A gradient the picker may edit is one a Background can hold: read by the Background's own reader, so
@@ -54,7 +75,9 @@ export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabl
54
75
  const selectedPalette = presets.find((preset) => preset.key === paletteKey) ?? presets[0];
55
76
  const selectedPaletteKey = selectedPalette?.key;
56
77
  const selectedPaletteLabel = selectedPalette?.label ?? selectedPaletteKey;
57
- const selectedCssValue = picker.value ?? defaultValue;
78
+ const references = useMemo(() => collectPhiColorReferences(presets), [presets]);
79
+ const storedValue = picker.value ?? defaultValue;
80
+ const selectedCssValue = resolvePhiColorReferences(storedValue, references) ?? defaultValue;
58
81
  /*
59
82
  * A single colour names itself, a gradient cannot.
60
83
  *
@@ -70,7 +93,7 @@ export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabl
70
93
  colors: [...preset.colors],
71
94
  defaultOpen: preset.defaultOpen,
72
95
  }));
73
- return (_jsx(ColorPicker, { mode: resolveAntdMode(mode), value: resolveAntdColorValue(picker.value, defaultValue), open: picker.open, disabled: disabled, allowClear: allowClear, trigger: trigger, placement: placement === "auto" ? undefined : placement, size: size, showText: resolvedShowText, presets: antdPresets, getPopupContainer: getPopupContainer, classNames: { popup: { root: joinPhiClassNames("phi-color-widget-popup", popupClassName) } }, styles: {
96
+ return (_jsx(ColorPicker, { mode: resolveAntdMode(mode), value: resolveAntdColorValue(resolvePhiColorReferences(picker.value, references), defaultValue), open: picker.open, disabled: disabled, allowClear: allowClear, trigger: trigger, placement: placement === "auto" ? undefined : placement, size: size, showText: resolvedShowText, presets: antdPresets, getPopupContainer: getPopupContainer, classNames: { popup: { root: joinPhiClassNames("phi-color-widget-popup", popupClassName) } }, styles: {
74
97
  root: {
75
98
  display: "inline-flex",
76
99
  alignItems: "center",
@@ -96,10 +119,11 @@ export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabl
96
119
  justifyContent: "space-between",
97
120
  rowGap: token.paddingXXS,
98
121
  }, children: selectedPalette.colors.map((presetColor, index) => {
99
- const selected = presetColor === selectedCssValue;
122
+ const reference = selectedPalette.colorReferences?.[index];
123
+ const selected = reference ? reference === storedValue : presetColor === selectedCssValue;
100
124
  const swatchLabel = selectedPalette.colorLabels?.[index]
101
125
  ?? `${selectedPaletteLabel} ${index + 1}`;
102
- return (_jsx(PhiLabeledControl, { description: `${swatchLabel}: ${presetColor}`, children: _jsx("button", { type: "button", "aria-label": `${swatchLabel}: ${presetColor}`, "aria-pressed": selected, disabled: disabled, onClick: () => picker.changeValue(presetColor), style: {
126
+ return (_jsx(PhiLabeledControl, { description: `${swatchLabel}: ${presetColor}`, children: _jsx("button", { type: "button", "aria-label": `${swatchLabel}: ${presetColor}`, "aria-pressed": selected, disabled: disabled, onClick: () => picker.changeValue(reference ?? presetColor), style: {
103
127
  width: 22,
104
128
  height: 22,
105
129
  padding: 0,
@@ -29,6 +29,8 @@ export type PhiColorFieldControlProps = {
29
29
  onDiscard?: (originalValue: string | null) => void;
30
30
  onClear?: () => void;
31
31
  customColors?: ReadonlyArray<PhiColorControlCustomColor>;
32
+ /** A Theme swatch stores its role instead of its colour (`usePhiColorControlPresets`). */
33
+ storeThemeRoles?: boolean;
32
34
  labels?: PhiColorPickerLabels;
33
35
  onChange?: (value: string, tokenKey?: string) => void;
34
36
  onValueChange?: (value: string | null, tokenKey?: string) => void;
@@ -40,4 +42,4 @@ export type PhiColorFieldControlProps = {
40
42
  * authoring tool buttons. The Color Widget is the Core Module's placement of it, which adds its config
41
43
  * and its signals.
42
44
  */
43
- export declare function PhiColorFieldControl({ label, value, defaultValue: fixedDefaultValue, defaultToken, tokenKey, disabled, mode, showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, labels, onChange, onValueChange, }: PhiColorFieldControlProps): import("react").JSX.Element;
45
+ export declare function PhiColorFieldControl({ label, value, defaultValue: fixedDefaultValue, defaultToken, tokenKey, disabled, mode, showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, storeThemeRoles, labels, onChange, onValueChange, }: PhiColorFieldControlProps): import("react").JSX.Element;
@@ -15,12 +15,12 @@ import { PhiTypographyControl } from "./phi-typography-control";
15
15
  * authoring tool buttons. The Color Widget is the Core Module's placement of it, which adds its config
16
16
  * and its signals.
17
17
  */
18
- export function PhiColorFieldControl({ label, value, defaultValue: fixedDefaultValue = "#1677ff", defaultToken, tokenKey, disabled = false, mode = "single", showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, labels = PHI_COLOR_PICKER_DEFAULT_LABELS, onChange, onValueChange, }) {
18
+ export function PhiColorFieldControl({ label, value, defaultValue: fixedDefaultValue = "#1677ff", defaultToken, tokenKey, disabled = false, mode = "single", showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, storeThemeRoles = false, labels = PHI_COLOR_PICKER_DEFAULT_LABELS, onChange, onValueChange, }) {
19
19
  const { token } = usePhiConfig();
20
20
  const tokenValue = defaultToken ? token[defaultToken] : undefined;
21
21
  const defaultValue = typeof tokenValue === "string" ? tokenValue : fixedDefaultValue;
22
22
  const resolvedValue = value?.trim() || defaultValue;
23
- const pickerPresets = usePhiColorControlPresets({ labels, customColors, presets });
23
+ const pickerPresets = usePhiColorControlPresets({ labels, customColors, presets, storeThemeRoles });
24
24
  function publish(nextValue) {
25
25
  if (nextValue == null) {
26
26
  onValueChange?.(null, tokenKey);
@@ -5,8 +5,18 @@ export type PhiColorControlCustomColor = {
5
5
  label: string;
6
6
  value: string;
7
7
  };
8
- export declare function usePhiColorControlPresets({ labels, customColors, presets, }?: {
8
+ /**
9
+ * The colour picker's swatches: the Theme's custom colours, its primary and text ladders, then the fixed
10
+ * palettes.
11
+ *
12
+ * With `storeThemeRoles`, a Theme swatch stores the role it shows (`PHI_COLOR.custom3`,
13
+ * `PHI_COLOR.primaryBg`) rather than its colour, so what an author picks follows the Theme and the mode.
14
+ * Every field that styles content wants that. The Theme workspace does not: it is where those colours are
15
+ * set, and a palette that named its own roles would point at itself.
16
+ */
17
+ export declare function usePhiColorControlPresets({ labels, customColors, presets, storeThemeRoles, }?: {
9
18
  labels?: PhiColorPickerLabels;
10
19
  customColors?: readonly PhiColorControlCustomColor[];
11
20
  presets?: PhiColorPickerPresets;
21
+ storeThemeRoles?: boolean;
12
22
  }): PhiColorPickerPresets;
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { PHI_COLOR } from "../../theme/antd-css-var-contract";
2
3
  import { PHI_THEME_CUSTOM_COLOR_KEYS } from "../../theme/phi-theme-presets";
3
4
  import { createPhiColorPickerPresets } from "../widgets/config/color-picker-presets";
4
5
  import { PHI_COLOR_PICKER_DEFAULT_LABELS, } from "../widgets/label-types/color-picker";
@@ -27,7 +28,20 @@ const PHI_TEXT_COLOR_TOKEN_KEYS = [
27
28
  "colorTextPlaceholder",
28
29
  "colorTextDisabled",
29
30
  ];
30
- export function usePhiColorControlPresets({ labels = PHI_COLOR_PICKER_DEFAULT_LABELS, customColors, presets, } = {}) {
31
+ /** A Theme colour token's role, the custom property Ant Design writes for it: `colorPrimaryBg` → `var(--ant-color-primary-bg)`. */
32
+ function resolvePhiColorTokenReference(tokenKey) {
33
+ return `var(--ant-${tokenKey.replace(/[A-Z]/gu, (letter) => `-${letter.toLowerCase()}`)})`;
34
+ }
35
+ /**
36
+ * The colour picker's swatches: the Theme's custom colours, its primary and text ladders, then the fixed
37
+ * palettes.
38
+ *
39
+ * With `storeThemeRoles`, a Theme swatch stores the role it shows (`PHI_COLOR.custom3`,
40
+ * `PHI_COLOR.primaryBg`) rather than its colour, so what an author picks follows the Theme and the mode.
41
+ * Every field that styles content wants that. The Theme workspace does not: it is where those colours are
42
+ * set, and a palette that named its own roles would point at itself.
43
+ */
44
+ export function usePhiColorControlPresets({ labels = PHI_COLOR_PICKER_DEFAULT_LABELS, customColors, presets, storeThemeRoles = false, } = {}) {
31
45
  const { customColors: publishedThemePalette, token } = usePhiConfig();
32
46
  const resolvedCustomColors = customColors ?? PHI_THEME_CUSTOM_COLOR_KEYS.map((key, index) => ({
33
47
  key,
@@ -43,6 +57,9 @@ export function usePhiColorControlPresets({ labels = PHI_COLOR_PICKER_DEFAULT_LA
43
57
  label: labels.custom,
44
58
  colors: resolvedCustomColors.map((color) => color.value),
45
59
  colorLabels: resolvedCustomColors.map((color) => color.label),
60
+ ...(storeThemeRoles && !customColors
61
+ ? { colorReferences: PHI_THEME_CUSTOM_COLOR_KEYS.map((key) => PHI_COLOR[key]) }
62
+ : {}),
46
63
  defaultOpen: true,
47
64
  }]
48
65
  : []),
@@ -51,12 +68,14 @@ export function usePhiColorControlPresets({ labels = PHI_COLOR_PICKER_DEFAULT_LA
51
68
  label: labels.colors.primary,
52
69
  colors: PHI_PRIMARY_COLOR_TOKEN_KEYS.map((key) => token[key]),
53
70
  colorLabels: [...PHI_PRIMARY_COLOR_TOKEN_KEYS],
71
+ ...(storeThemeRoles ? { colorReferences: PHI_PRIMARY_COLOR_TOKEN_KEYS.map(resolvePhiColorTokenReference) } : {}),
54
72
  },
55
73
  {
56
74
  key: "phi-text",
57
75
  label: labels.colors.text,
58
76
  colors: PHI_TEXT_COLOR_TOKEN_KEYS.map((key) => token[key]),
59
77
  colorLabels: [...PHI_TEXT_COLOR_TOKEN_KEYS],
78
+ ...(storeThemeRoles ? { colorReferences: PHI_TEXT_COLOR_TOKEN_KEYS.map(resolvePhiColorTokenReference) } : {}),
60
79
  },
61
80
  ...resolvedPresets.map((preset) => ({
62
81
  ...preset,
@@ -6,6 +6,7 @@ import { mergePhiThemePalettes, PHI_THEME_PALETTE_MODE_SEED_KEYS, resolvePhiThem
6
6
  import { assertPhiThemeVocabulary } from "../../theme/phi-theme-tokens";
7
7
  import { applyPhiButtonShadowComponentTokens } from "../../theme/phi-button-shadow";
8
8
  import { buildPhiThemeGradientTokens, readPhiThemeGradientKey } from "../../theme/phi-theme-gradients";
9
+ import { buildPhiThemeCustomColorTokens } from "../../theme/phi-theme-palette";
9
10
  import { applyPhiControlShapeComponentTokens, applyPhiSurfaceShapeComponentTokens, resolvePhiControlShape, } from "../../theme/phi-control-shape";
10
11
  const PHI_DEFAULT_DARK_NAV_BACKGROUND = "#001529";
11
12
  function mergeComponentThemes(defaults, overrides) {
@@ -85,10 +86,13 @@ export function resolvePhiRootTheme({ siteTheme, mode, fonts, presets, }) {
85
86
  * this mode's class like every other token (theme/phi-theme-gradients.ts). Derived from the resolved
86
87
  * colours, so a slot the palette leaves out follows the brand.
87
88
  */
89
+ const mergedPalette = mergePhiThemePalettes(themePreset.palette, siteTheme?.palette);
88
90
  const token = {
89
91
  ...effectiveThemeTokens,
92
+ // The custom colours ride the same way, so a config names one by its role (`PHI_COLOR.custom1`).
93
+ ...buildPhiThemeCustomColorTokens(mergedPalette, mode),
90
94
  ...buildPhiThemeGradientTokens({
91
- gradients: mergePhiThemePalettes(themePreset.palette, siteTheme?.palette).modes?.[mode]?.gradients,
95
+ gradients: mergedPalette.modes?.[mode]?.gradients,
92
96
  token: effectiveThemeTokens,
93
97
  primaryButtonGradient: readPhiThemeGradientKey(siteTheme?.buttons?.primaryGradient),
94
98
  }),
@@ -59,7 +59,7 @@ export function PhiWidgetColorToolButton({ value, ariaLabel, onChange, }) {
59
59
  const labels = usePhiAuthoringToolsLabels();
60
60
  const currentColor = typeof value === "string" && value.trim().length > 0 ? value : undefined;
61
61
  const popup = usePhiWidgetScaffoldPopup();
62
- return (_jsx(PhiColorFieldControl, { value: currentColor, defaultValue: currentColor ?? "#1677ff", allowClear: true, getPopupContainer: popup.getPopupContainer, popupClassName: popup.rootClassName, onOpenChange: popup.setOpen, renderPanel: (panel) => (_jsx("div", { onClick: stopPhiOverlayEvent, onMouseDown: preserveEditorSelectionMouseEvent, onPointerDown: stopPhiOverlayEvent, onKeyDown: stopPhiOverlayEvent, children: panel })), onChange: (css) => {
62
+ return (_jsx(PhiColorFieldControl, { value: currentColor, defaultValue: currentColor ?? "#1677ff", allowClear: true, storeThemeRoles: true, getPopupContainer: popup.getPopupContainer, popupClassName: popup.rootClassName, onOpenChange: popup.setOpen, renderPanel: (panel) => (_jsx("div", { onClick: stopPhiOverlayEvent, onMouseDown: preserveEditorSelectionMouseEvent, onPointerDown: stopPhiOverlayEvent, onKeyDown: stopPhiOverlayEvent, children: panel })), onChange: (css) => {
63
63
  onChange(css);
64
64
  }, onClear: () => {
65
65
  onChange(null);
@@ -32,5 +32,5 @@ export type PhiCmsRegionOwnership = "shell" | "page";
32
32
  * know is not a placement anybody chose -- refusing it would hide Widgets over a typo.
33
33
  */
34
34
  export declare function phiCmsRegionAcceptsWidget(regionKey: string | null | undefined, required: PhiCmsRegionOwnership | null | undefined): boolean;
35
- export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 11 | 10 | 40 | 12 | 50 | 20 | 21 | 25 | 30 | 39 | 41;
35
+ export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 21 | 10 | 40 | 12 | 50 | 11 | 20 | 25 | 30 | 39 | 41;
36
36
  export declare function resolvePhiCmsRegionKey(regionType: number | null | undefined): "content" | "header_top" | "header_main" | "header_bottom" | "sider_left" | "sider_right" | "hero" | "footer_top" | "footer_main" | "footer_bottom" | "drawer_right" | undefined;
@@ -0,0 +1,17 @@
1
+ import type { PhiResolvedCmsPageTree } from "../types/cms";
2
+ /**
3
+ * The Page rule as a check (THIRD_PARTY_MODULES.md, "6b. Laying out a Page").
4
+ *
5
+ * For presets -- what a package or Core writes in code, by hand or by an agent. A package runs it over the
6
+ * trees its route presets build, in its own verify step, and treats a finding as an error. It is never run
7
+ * on what an author saves in the Builder: there the scale is what the Inspector offers, and a value off it
8
+ * is the author's to choose.
9
+ *
10
+ * It reads the stated config only and resolves nothing: a distance is a step of `PHI_SPACE` or nothing.
11
+ */
12
+ export type PhiPageLayoutFinding = {
13
+ /** The node's label, or its id where it has none. */
14
+ node: string;
15
+ message: string;
16
+ };
17
+ export declare function checkPhiPagePresetLayout(tree: PhiResolvedCmsPageTree): PhiPageLayoutFinding[];
@@ -0,0 +1,121 @@
1
+ import { PhiCmsRegionType } from "../constants/phi-cms";
2
+ import { PHI_SPACE } from "../theme/antd-css-var-contract";
3
+ import { readPhiSurface } from "../types/surface";
4
+ const SPACING_KEYS = ["padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "gap"];
5
+ const PADDING_KEYS = SPACING_KEYS.filter((key) => key !== "gap");
6
+ /** The steps a preset may use for any distance; above them is the author's emphasis. */
7
+ const PRESET_STEPS = ["xxs", "xs", "sm", "base", "md"];
8
+ const EMPHASIS_STEPS = ["lg", "xl", "xxl"];
9
+ /** Layouts that bring a padding of their own by default (LAYOUTING.md): stated, or they keep it. */
10
+ const DEFAULT_PADDED_LAYOUTS = new Set(["grid", "masonry", "three-column"]);
11
+ function stepOf(value) {
12
+ if (value === 0 || value === "0")
13
+ return "none";
14
+ for (const [step, reference] of Object.entries(PHI_SPACE)) {
15
+ if (value === reference)
16
+ return step;
17
+ }
18
+ return null;
19
+ }
20
+ function typeKeyOf(node) {
21
+ return node.widgetType.split("/").at(-1) ?? node.widgetType;
22
+ }
23
+ function nameOf(node) {
24
+ return node.label?.trim() || String(node.id);
25
+ }
26
+ function hasPadding(config) {
27
+ return PADDING_KEYS.some((key) => {
28
+ const step = stepOf(config[key]);
29
+ return config[key] != null && step !== "none";
30
+ });
31
+ }
32
+ export function checkPhiPagePresetLayout(tree) {
33
+ const findings = [];
34
+ const contentRegion = tree.regions.find((region) => region.regionType === PhiCmsRegionType.Content);
35
+ const heroRegion = tree.regions.find((region) => region.regionType === PhiCmsRegionType.Hero);
36
+ const regionConfig = (contentRegion?.config ?? {});
37
+ const heroOverlap = heroRegion ? regionConfig.heroOverlap : undefined;
38
+ if (contentRegion) {
39
+ const edge = stepOf(regionConfig.padding);
40
+ if (edge !== "md") {
41
+ findings.push({
42
+ node: `region ${contentRegion.id}`,
43
+ message: "The content Region is the Page's edge and states `padding: PHI_SPACE.md`.",
44
+ });
45
+ }
46
+ if (heroOverlap != null && stepOf(heroOverlap) == null) {
47
+ findings.push({ node: `region ${contentRegion.id}`, message: "`heroOverlap` is a step of `PHI_SPACE`." });
48
+ }
49
+ }
50
+ const byId = new Map(tree.layoutNodes.map((node) => [node.id, node]));
51
+ const childrenOf = (id) => tree.layoutNodes.filter((node) => node.parentLayoutNodeId === id);
52
+ // The Page column: the content Region's root Layout holds one vertical Flex.
53
+ const contentRoot = contentRegion ? byId.get(contentRegion.rootLayoutNodeId) : undefined;
54
+ if (contentRoot) {
55
+ const column = typeKeyOf(contentRoot) === "content" ? childrenOf(contentRoot.id)[0] : contentRoot;
56
+ if (!column || typeKeyOf(column) !== "flex-vertical") {
57
+ findings.push({
58
+ node: nameOf(contentRoot),
59
+ message: "The Page column under the content Region is one `flex-vertical`.",
60
+ });
61
+ }
62
+ }
63
+ const heroRootId = heroRegion?.rootLayoutNodeId;
64
+ // A band under the Header keeps its sides on the small step without a Surface; nothing above or below.
65
+ const headerBottomRootId = tree.regions
66
+ .find((region) => region.regionType === PhiCmsRegionType.HeaderBottom)?.rootLayoutNodeId;
67
+ for (const node of tree.layoutNodes) {
68
+ const config = (node.config ?? {});
69
+ const typeKey = typeKeyOf(node);
70
+ const surface = readPhiSurface(config.surface);
71
+ for (const key of SPACING_KEYS) {
72
+ const value = config[key];
73
+ if (value == null)
74
+ continue;
75
+ const step = stepOf(value);
76
+ if (step == null) {
77
+ findings.push({
78
+ node: nameOf(node),
79
+ message: `\`${key}\` is \`${String(value)}\`; a preset names a step of \`PHI_SPACE\`, never a number, a string or \`clamp()\`.`,
80
+ });
81
+ continue;
82
+ }
83
+ if (EMPHASIS_STEPS.includes(step)) {
84
+ const heroBottom = node.id === heroRootId && key === "paddingBottom" && heroOverlap != null;
85
+ if (!heroBottom) {
86
+ findings.push({
87
+ node: nameOf(node),
88
+ message: `\`${key}\` is \`${step}\`. Above \`md\` is the author's emphasis; a preset stays at ${PRESET_STEPS.join(", ")} -- but a Hero's bottom beside \`heroOverlap\`.`,
89
+ });
90
+ }
91
+ }
92
+ }
93
+ if (node.id === headerBottomRootId) {
94
+ const sideSteps = ["paddingLeft", "paddingRight"].map((key) => stepOf(config[key]));
95
+ const blocks = ["paddingTop", "paddingBottom"].map((key) => stepOf(config[key]));
96
+ if (sideSteps.some((step) => step !== "sm") || blocks.some((step) => step != null && step !== "none")
97
+ || (config.padding != null && stepOf(config.padding) !== "none")) {
98
+ findings.push({
99
+ node: nameOf(node),
100
+ message: "A band under the Header states `padding: 0` and its sides `PHI_SPACE.sm`.",
101
+ });
102
+ }
103
+ continue;
104
+ }
105
+ if (!surface && typeKey !== "content") {
106
+ if (hasPadding(config)) {
107
+ findings.push({
108
+ node: nameOf(node),
109
+ message: "Has a padding but no Surface. A Layout without a Surface only arranges; padding belongs to an edge one can see.",
110
+ });
111
+ }
112
+ else if (DEFAULT_PADDED_LAYOUTS.has(typeKey) && config.padding == null) {
113
+ findings.push({
114
+ node: nameOf(node),
115
+ message: `States no padding, so the ${typeKey} keeps its default inset; without a Surface it states \`padding: 0\`.`,
116
+ });
117
+ }
118
+ }
119
+ }
120
+ return findings;
121
+ }
@@ -13,7 +13,8 @@
13
13
  * limit collects. Neither event needs to invalidate anything.
14
14
  *
15
15
  * What does change a stored value is a write to the translation store -- an edit, a delete, a changed
16
- * translation configuration. Entries do not expire for it. Core keeps a change marker per store, one
16
+ * translation configuration. Entries do not wait to expire for it (they leave after a day for another
17
+ * reason, `PHI_TRANSLATION_CACHE_MAX_AGE_MS`). Core keeps a change marker per store, one
17
18
  * global and one per Site, and hands both out with the Site config; `syncPhiTranslationChangeMarkers`
18
19
  * empties a store whose marker differs from the one this process saw last. The process that forwarded
19
20
  * an edit reads the Site config fresh on its next render (its proxy cleared the read cache), and every
@@ -32,6 +33,14 @@
32
33
  * passed through `tr` cannot grow the process without bound.
33
34
  */
34
35
  export declare const PHI_TRANSLATION_CACHE_MAX_ENTRIES = 5000;
36
+ /**
37
+ * How long an entry is kept: a day, and up to four hours more so that entries written together do not
38
+ * all leave in the same minute. Not for freshness -- the change markers see to that -- but so that a text
39
+ * this Site still shows is asked for again once a day. Core notes when a message was last read
40
+ * (phis-server TRANSLATIONS.md, "When a message was last read"), and a text served from here forever
41
+ * would look unread there.
42
+ */
43
+ export declare const PHI_TRANSLATION_CACHE_MAX_AGE_MS: number;
35
44
  export type PhiTranslationCacheKeyInput = {
36
45
  /** The Site the translation belongs to, or an empty string for a global one. */
37
46
  scope: string;
@@ -13,7 +13,8 @@
13
13
  * limit collects. Neither event needs to invalidate anything.
14
14
  *
15
15
  * What does change a stored value is a write to the translation store -- an edit, a delete, a changed
16
- * translation configuration. Entries do not expire for it. Core keeps a change marker per store, one
16
+ * translation configuration. Entries do not wait to expire for it (they leave after a day for another
17
+ * reason, `PHI_TRANSLATION_CACHE_MAX_AGE_MS`). Core keeps a change marker per store, one
17
18
  * global and one per Site, and hands both out with the Site config; `syncPhiTranslationChangeMarkers`
18
19
  * empties a store whose marker differs from the one this process saw last. The process that forwarded
19
20
  * an edit reads the Site config fresh on its next render (its proxy cleared the read cache), and every
@@ -32,11 +33,20 @@
32
33
  * passed through `tr` cannot grow the process without bound.
33
34
  */
34
35
  export const PHI_TRANSLATION_CACHE_MAX_ENTRIES = 5_000;
36
+ /**
37
+ * How long an entry is kept: a day, and up to four hours more so that entries written together do not
38
+ * all leave in the same minute. Not for freshness -- the change markers see to that -- but so that a text
39
+ * this Site still shows is asked for again once a day. Core notes when a message was last read
40
+ * (phis-server TRANSLATIONS.md, "When a message was last read"), and a text served from here forever
41
+ * would look unread there.
42
+ */
43
+ export const PHI_TRANSLATION_CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1000;
44
+ const PHI_TRANSLATION_CACHE_AGE_SPREAD_MS = 4 * 60 * 60 * 1000;
35
45
  /** ASCII unit separator: the one character a locale, a context, or a format will never contain. */
36
46
  const SEPARATOR = String.fromCharCode(31);
37
47
  // Named for its shape: a process that outlives a code change (a dev server's HMR) still holds the old
38
48
  // value under the old name, and must not hand it to code that expects this one.
39
- const TRANSLATION_CACHE_STORE_KEY = Symbol.for("phis-ui.translation-cache.entries-generation-markers");
49
+ const TRANSLATION_CACHE_STORE_KEY = Symbol.for("phis-ui.translation-cache.expiring-entries-generation-markers");
40
50
  const STATE = (() => {
41
51
  const holder = globalThis;
42
52
  holder[TRANSLATION_CACHE_STORE_KEY] ??= {
@@ -52,15 +62,19 @@ export function buildPhiTranslationCacheKey({ scope, sourceLocale, targetLocale,
52
62
  return [scope, sourceLocale, targetLocale, ctx, format, msg].join(SEPARATOR);
53
63
  }
54
64
  export function readPhiTranslationCache(key) {
55
- const value = TRANSLATION_CACHE.get(key);
56
- if (value == null) {
65
+ const entry = TRANSLATION_CACHE.get(key);
66
+ if (entry == null) {
67
+ return null;
68
+ }
69
+ if (entry.expiresAt <= Date.now()) {
70
+ TRANSLATION_CACHE.delete(key);
57
71
  return null;
58
72
  }
59
73
  // Re-inserting moves the entry to the end, so the size limit evicts what is least recently read
60
74
  // rather than what was written first -- a Navigation label read on every request outlives a one-off.
61
75
  TRANSLATION_CACHE.delete(key);
62
- TRANSLATION_CACHE.set(key, value);
63
- return value;
76
+ TRANSLATION_CACHE.set(key, entry);
77
+ return entry.value;
64
78
  }
65
79
  /** Taken before a request to Core, and handed back to `writePhiTranslationCache` with its answer. */
66
80
  export function readPhiTranslationCacheGeneration() {
@@ -75,7 +89,10 @@ export function writePhiTranslationCache(key, value, generation) {
75
89
  return;
76
90
  }
77
91
  TRANSLATION_CACHE.delete(key);
78
- TRANSLATION_CACHE.set(key, value);
92
+ TRANSLATION_CACHE.set(key, {
93
+ value,
94
+ expiresAt: Date.now() + PHI_TRANSLATION_CACHE_MAX_AGE_MS + Math.random() * PHI_TRANSLATION_CACHE_AGE_SPREAD_MS,
95
+ });
79
96
  while (TRANSLATION_CACHE.size > PHI_TRANSLATION_CACHE_MAX_ENTRIES) {
80
97
  const oldest = TRANSLATION_CACHE.keys().next();
81
98
  if (oldest.done) {
package/helpers.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from "./helpers/widget-dimension-plugin-fields";
10
10
  export * from "./helpers/translation-format";
11
11
  export { buildPhiCmsLayoutNode, buildPhiCmsWidgetNode, } from "./helpers/cms-node-factories";
12
12
  export * from "./helpers/cms-preset-nodes";
13
+ export { checkPhiPagePresetLayout, type PhiPageLayoutFinding } from "./helpers/page-layout-check";
13
14
  export * from "./helpers/cms-dialog";
14
15
  export { buildPhiSettingsPageShellTree, type PhiSettingsPageShellFormSection, type PhiSettingsPageShellOverlay, type PhiSettingsPageShellPanel, type PhiSettingsPageShellSection, type PhiSettingsPageShellWidgetSection, } from "./components/regions/presets/phi-settings-page-shell-tree";
15
16
  export * from "./helpers/format-date-time";
package/helpers.js CHANGED
@@ -10,6 +10,8 @@ export * from "./helpers/widget-dimension-plugin-fields";
10
10
  export * from "./helpers/translation-format";
11
11
  export { buildPhiCmsLayoutNode, buildPhiCmsWidgetNode, } from "./helpers/cms-node-factories";
12
12
  export * from "./helpers/cms-preset-nodes";
13
+ /* The Page rule as a check, for a package to run over the trees its presets build (THIRD_PARTY_MODULES.md 6b). */
14
+ export { checkPhiPagePresetLayout } from "./helpers/page-layout-check";
13
15
  export * from "./helpers/cms-dialog";
14
16
  /*
15
17
  * The one Settings page shell (SETTINGS.md section 4). Public because the contract holds for every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -714,7 +714,7 @@ function renderPhiInspectorConfigFieldBody({ field, value, defaultValue, config,
714
714
  return (_jsx(PhiInspectorCollectionFieldControl, { field: field, config: config, labels: fieldLabels, value: value, defaultValue: defaultValue, disabled: disabled || !onChange, widgetReferenceOptions: widgetReferenceOptions ?? [], paddingLabels: paddingLabels, backgroundLabels: backgroundLabels, borderLabels: borderLabels, renderMediaPicker: renderMediaPicker, colorPickerLabels: colorPickerLabels, iconPickerLabels: iconPickerLabels, dataProviderDescriptors: dataProviderDescriptors, calendarAdapterDescriptors: calendarAdapterDescriptors, videoProviderDescriptors: videoProviderDescriptors, onChange: onChange }, field.key));
715
715
  }
716
716
  if (field.type === "color") {
717
- return renderPhiInspectorConfigFieldControl(field, _jsx(PhiColorFieldControl, { value: value, defaultValue: defaultValue, ...(field.defaultToken ? { defaultToken: field.defaultToken } : {}), disabled: disabled || !onChange, mode: resolveInspectorColorMode(field.mode), placement: "left", labels: colorPickerLabels, onChange: (nextValue) => onChange?.({ [field.key]: nextValue || undefined }) }));
717
+ return renderPhiInspectorConfigFieldControl(field, _jsx(PhiColorFieldControl, { value: value, defaultValue: defaultValue, ...(field.defaultToken ? { defaultToken: field.defaultToken } : {}), disabled: disabled || !onChange, mode: resolveInspectorColorMode(field.mode), placement: "left", labels: colorPickerLabels, storeThemeRoles: true, onChange: (nextValue) => onChange?.({ [field.key]: nextValue || undefined }) }));
718
718
  }
719
719
  if (field.type === "surface") {
720
720
  return renderPhiInspectorConfigFieldBlock(field, _jsx(PhiSurfaceControl, { disabled: disabled || !onChange, value: value === null ? null : readPhiSurface(value) ?? readPhiSurface(defaultValue), tone: field.tone !== false,
@@ -10,7 +10,7 @@ import { PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../../types/signals";
10
10
  import { createPhiThemeControllerAddress } from "../../../../../plugins/runtime-modules/theme/controller/address";
11
11
  import { PHI_THEME_SIGNAL_CHANNELS } from "../../../../../plugins/runtime-modules/theme/controller/signals";
12
12
  import { PHI_THEME_CUSTOM_COLOR_KEYS, isPhiThemePaletteModeSeedKey, mergePhiThemePalettes, resolvePhiThemeColorTokens, } from "../../../../../theme/phi-theme-presets";
13
- import { buildPhiThemeCustomColorPalette, resolvePhiThemePaletteCustomColors } from "../../../../../theme/phi-theme-palette";
13
+ import { buildPhiThemeCustomColorPalette, buildPhiThemeCustomColorTokens, resolvePhiThemePaletteCustomColors, } from "../../../../../theme/phi-theme-palette";
14
14
  import { buildPhiThemeGradientTokens, PHI_THEME_GRADIENT_KEYS, readPhiThemeGradient, readPhiThemeGradientTextTone, readPhiThemeGradientKey, resolvePhiThemeGradients, resolvePhiThemeGradientText, resolvePhiThemeGradientContrast, resolvePhiThemeGradientAutoTextTone, resolvePhiThemeGradientInks, PHI_GRADIENT_HOVER_FILTER, } from "../../../../../theme/phi-theme-gradients";
15
15
  import { usePhiConfig } from "../../../../../components/root/phi-config-provider";
16
16
  import { usePhiThemeBlockCatalog } from "../../../../../components/root/phi-theme-block-catalog-provider";
@@ -534,11 +534,13 @@ function resolveBrandDraftAliasTokens(resolvedTheme, preset, mode, fonts = {}) {
534
534
  ...(fonts.body ? { fontFamily: fonts.body } : {}),
535
535
  ...(fonts.mono ? { fontFamilyCode: fonts.mono } : {}),
536
536
  });
537
- // The gradient slots and the primary Buttons' run, as the root lays them over its tokens.
537
+ // The custom colours, the gradient slots and the primary Buttons' run, as the root lays them over its tokens.
538
+ const mergedPalette = mergePhiThemePalettes(preset.palette, resolvedTheme.palette);
538
539
  return {
539
540
  ...aliasTokens,
541
+ ...buildPhiThemeCustomColorTokens(mergedPalette, mode),
540
542
  ...buildPhiThemeGradientTokens({
541
- gradients: mergePhiThemePalettes(preset.palette, resolvedTheme.palette).modes?.[mode]?.gradients,
543
+ gradients: mergedPalette.modes?.[mode]?.gradients,
542
544
  token: aliasTokens,
543
545
  primaryButtonGradient: readPhiThemeGradientKey(resolvedTheme.buttons?.primaryGradient),
544
546
  }),
@@ -5,15 +5,28 @@
5
5
  * `usePhiConfig().token` when they need the resolved value in JavaScript.
6
6
  */
7
7
  export declare const PHI_COLOR: {
8
- readonly primary: "var(--ant-color-primary)";
8
+ readonly primaryBg: "var(--ant-color-primary-bg)";
9
+ readonly primaryBgHover: "var(--ant-color-primary-bg-hover)";
10
+ readonly primaryBorder: "var(--ant-color-primary-border)";
11
+ readonly primaryBorderHover: "var(--ant-color-primary-border-hover)";
9
12
  readonly primaryHover: "var(--ant-color-primary-hover)";
13
+ readonly primary: "var(--ant-color-primary)";
10
14
  readonly primaryActive: "var(--ant-color-primary-active)";
15
+ readonly primaryTextHover: "var(--ant-color-primary-text-hover)";
16
+ readonly primaryText: "var(--ant-color-primary-text)";
17
+ readonly primaryTextActive: "var(--ant-color-primary-text-active)";
11
18
  readonly link: "var(--ant-color-link)";
12
19
  readonly linkHover: "var(--ant-color-link-hover)";
20
+ readonly textBase: "var(--ant-color-text-base)";
13
21
  readonly text: "var(--ant-color-text)";
14
22
  readonly textSecondary: "var(--ant-color-text-secondary)";
15
23
  readonly textTertiary: "var(--ant-color-text-tertiary)";
24
+ readonly textQuaternary: "var(--ant-color-text-quaternary)";
16
25
  readonly textHeading: "var(--ant-color-text-heading)";
26
+ readonly textLabel: "var(--ant-color-text-label)";
27
+ readonly textDescription: "var(--ant-color-text-description)";
28
+ readonly textPlaceholder: "var(--ant-color-text-placeholder)";
29
+ readonly textDisabled: "var(--ant-color-text-disabled)";
17
30
  readonly textLightSolid: "var(--ant-color-text-light-solid)";
18
31
  readonly bgContainer: "var(--ant-color-bg-container)";
19
32
  readonly bgLayout: "var(--ant-color-bg-layout)";
@@ -30,6 +43,16 @@ export declare const PHI_COLOR: {
30
43
  readonly error: "var(--ant-color-error)";
31
44
  readonly success: "var(--ant-color-success)";
32
45
  readonly warning: "var(--ant-color-warning)";
46
+ readonly custom1: "var(--ant-phi-custom-1)";
47
+ readonly custom2: "var(--ant-phi-custom-2)";
48
+ readonly custom3: "var(--ant-phi-custom-3)";
49
+ readonly custom4: "var(--ant-phi-custom-4)";
50
+ readonly custom5: "var(--ant-phi-custom-5)";
51
+ readonly custom6: "var(--ant-phi-custom-6)";
52
+ readonly custom7: "var(--ant-phi-custom-7)";
53
+ readonly custom8: "var(--ant-phi-custom-8)";
54
+ readonly custom9: "var(--ant-phi-custom-9)";
55
+ readonly custom10: "var(--ant-phi-custom-10)";
33
56
  };
34
57
  /**
35
58
  * Every distance a Phi surface states, inside a frame (`padding`) and between two things (`gap`), on the
@@ -5,15 +5,33 @@
5
5
  * `usePhiConfig().token` when they need the resolved value in JavaScript.
6
6
  */
7
7
  export const PHI_COLOR = {
8
- primary: "var(--ant-color-primary)",
8
+ /*
9
+ * The primary colour's ladder, as the Theme derives it per mode -- the same ten the colour picker offers
10
+ * as the Theme's primary swatches, so a colour picked there is stored as its role and follows the Theme.
11
+ */
12
+ primaryBg: "var(--ant-color-primary-bg)",
13
+ primaryBgHover: "var(--ant-color-primary-bg-hover)",
14
+ primaryBorder: "var(--ant-color-primary-border)",
15
+ primaryBorderHover: "var(--ant-color-primary-border-hover)",
9
16
  primaryHover: "var(--ant-color-primary-hover)",
17
+ primary: "var(--ant-color-primary)",
10
18
  primaryActive: "var(--ant-color-primary-active)",
19
+ primaryTextHover: "var(--ant-color-primary-text-hover)",
20
+ primaryText: "var(--ant-color-primary-text)",
21
+ primaryTextActive: "var(--ant-color-primary-text-active)",
11
22
  link: "var(--ant-color-link)",
12
23
  linkHover: "var(--ant-color-link-hover)",
24
+ /* The text ladder, likewise the picker's text swatches. */
25
+ textBase: "var(--ant-color-text-base)",
13
26
  text: "var(--ant-color-text)",
14
27
  textSecondary: "var(--ant-color-text-secondary)",
15
28
  textTertiary: "var(--ant-color-text-tertiary)",
29
+ textQuaternary: "var(--ant-color-text-quaternary)",
16
30
  textHeading: "var(--ant-color-text-heading)",
31
+ textLabel: "var(--ant-color-text-label)",
32
+ textDescription: "var(--ant-color-text-description)",
33
+ textPlaceholder: "var(--ant-color-text-placeholder)",
34
+ textDisabled: "var(--ant-color-text-disabled)",
17
35
  textLightSolid: "var(--ant-color-text-light-solid)",
18
36
  bgContainer: "var(--ant-color-bg-container)",
19
37
  bgLayout: "var(--ant-color-bg-layout)",
@@ -30,6 +48,20 @@ export const PHI_COLOR = {
30
48
  error: "var(--ant-color-error)",
31
49
  success: "var(--ant-color-success)",
32
50
  warning: "var(--ant-color-warning)",
51
+ /*
52
+ * The palette's ten custom colours, per mode, written by the Theme as tokens of its own
53
+ * (`phiCustom1` ... `phiCustom10`, theme/phi-theme-palette.ts).
54
+ */
55
+ custom1: "var(--ant-phi-custom-1)",
56
+ custom2: "var(--ant-phi-custom-2)",
57
+ custom3: "var(--ant-phi-custom-3)",
58
+ custom4: "var(--ant-phi-custom-4)",
59
+ custom5: "var(--ant-phi-custom-5)",
60
+ custom6: "var(--ant-phi-custom-6)",
61
+ custom7: "var(--ant-phi-custom-7)",
62
+ custom8: "var(--ant-phi-custom-8)",
63
+ custom9: "var(--ant-phi-custom-9)",
64
+ custom10: "var(--ant-phi-custom-10)",
33
65
  };
34
66
  /**
35
67
  * Every distance a Phi surface states, inside a frame (`padding`) and between two things (`gap`), on the
@@ -13,4 +13,10 @@ export declare function buildPhiThemeCustomColorPalette(seedColor: string): PhiT
13
13
  export declare function resolvePhiThemePaletteCustomColors(palette: PhiThemePalette | null | undefined, mode: PhiThemeMode): PhiThemeCustomColorPalette;
14
14
  /** The custom colours a Site renders: the palette it follows with the Site's own palette on top. */
15
15
  export declare function resolvePhiPublishedThemeCustomColors(siteTheme: PhiThemeCustomColorSource, mode: PhiThemeMode, presets: readonly PhiThemePresetPlugin[]): PhiThemeCustomColorPalette;
16
+ /**
17
+ * The custom colours of one mode as tokens of the Theme's own, laid over the resolved ones like the
18
+ * gradient slots, so Ant Design writes them per mode and per Surface tone (`--ant-phi-custom-1` ...) and a
19
+ * config can name one by its role (`PHI_COLOR.custom1`) instead of copying its value.
20
+ */
21
+ export declare function buildPhiThemeCustomColorTokens(palette: PhiThemePalette | null | undefined, mode: PhiThemeMode): Record<string, string>;
16
22
  export {};
@@ -30,3 +30,16 @@ export function resolvePhiPublishedThemeCustomColors(siteTheme, mode, presets) {
30
30
  const preset = resolvePhiThemePresetPlugin(presets, siteTheme.preset);
31
31
  return resolvePhiThemePaletteCustomColors(mergePhiThemePalettes(preset.palette, siteTheme.palette), mode);
32
32
  }
33
+ /** The token a custom colour rides as, and so the custom property Ant Design writes for it. */
34
+ function resolvePhiThemeCustomColorTokenName(key) {
35
+ return `phiCustom${key.slice("custom".length)}`;
36
+ }
37
+ /**
38
+ * The custom colours of one mode as tokens of the Theme's own, laid over the resolved ones like the
39
+ * gradient slots, so Ant Design writes them per mode and per Surface tone (`--ant-phi-custom-1` ...) and a
40
+ * config can name one by its role (`PHI_COLOR.custom1`) instead of copying its value.
41
+ */
42
+ export function buildPhiThemeCustomColorTokens(palette, mode) {
43
+ const colors = resolvePhiThemePaletteCustomColors(palette, mode);
44
+ return Object.fromEntries(PHI_THEME_CUSTOM_COLOR_KEYS.map((key) => [resolvePhiThemeCustomColorTokenName(key), colors[key]]));
45
+ }
@@ -37,9 +37,10 @@ export declare const PHI_THEME_TOKEN_KEYS: readonly ["colorBgContainer", "colorB
37
37
  *
38
38
  * The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
39
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.
40
+ * Design writes them per mode and per Surface tone like every other. The `phiCustom*` names are the
41
+ * palette's custom colours, laid over the same way (theme/phi-theme-palette.ts).
41
42
  */
42
- export declare const PHI_THEME_OWN_TOKEN_KEYS: readonly ["paddingXXL", "phiGradient1", "phiGradient1Text", "phiGradient2", "phiGradient2Text", "phiGradient3", "phiGradient3Text", "phiPrimaryButtonGradient", "phiPrimaryButtonGradientHover", "phiPrimaryButtonGradientActive", "phiPrimaryButtonGradientText"];
43
+ export declare const PHI_THEME_OWN_TOKEN_KEYS: readonly ["paddingXXL", "phiGradient1", "phiGradient1Text", "phiGradient2", "phiGradient2Text", "phiGradient3", "phiGradient3Text", "phiPrimaryButtonGradient", "phiPrimaryButtonGradientHover", "phiPrimaryButtonGradientActive", "phiPrimaryButtonGradientText", "phiCustom1", "phiCustom2", "phiCustom3", "phiCustom4", "phiCustom5", "phiCustom6", "phiCustom7", "phiCustom8", "phiCustom9", "phiCustom10"];
43
44
  export type PhiThemeTokenKey = (typeof PHI_THEME_TOKEN_KEYS)[number];
44
45
  /**
45
46
  * The resolved Theme, in the names above and their Ant Design value types.
@@ -165,7 +165,8 @@ export const PHI_THEME_TOKEN_KEYS = [
165
165
  *
166
166
  * The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
167
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.
168
+ * Design writes them per mode and per Surface tone like every other. The `phiCustom*` names are the
169
+ * palette's custom colours, laid over the same way (theme/phi-theme-palette.ts).
169
170
  */
170
171
  export const PHI_THEME_OWN_TOKEN_KEYS = [
171
172
  "paddingXXL",
@@ -179,6 +180,16 @@ export const PHI_THEME_OWN_TOKEN_KEYS = [
179
180
  "phiPrimaryButtonGradientHover",
180
181
  "phiPrimaryButtonGradientActive",
181
182
  "phiPrimaryButtonGradientText",
183
+ "phiCustom1",
184
+ "phiCustom2",
185
+ "phiCustom3",
186
+ "phiCustom4",
187
+ "phiCustom5",
188
+ "phiCustom6",
189
+ "phiCustom7",
190
+ "phiCustom8",
191
+ "phiCustom9",
192
+ "phiCustom10",
182
193
  ];
183
194
  /**
184
195
  * The colours a palette seeds, shared by both modes.