@phis/ui 0.5.1 → 0.5.2

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.
@@ -18,8 +18,11 @@ export declare function buildPhiBasePageColumnFrame({ page, regionId, columnId,
18
18
  regionId: number;
19
19
  columnId: PhiCmsInstanceId;
20
20
  label: string;
21
- /** Where the column stops, a `PHI_LAYOUT` measure: `readingMax` for prose, `contentMaxWide` for a page. */
22
- maxWidth: number;
21
+ /**
22
+ * Where the column stops: a `PHI_LAYOUT` measure such as `readingMax` for prose, or `PHI_PAGE.max` for a
23
+ * Page as wide as the Theme lets one get.
24
+ */
25
+ maxWidth: number | string;
23
26
  }): {
24
27
  regions: import("../../../types").PhiCmsRegionNode[];
25
28
  layoutNodes: import("../../../types").PhiCmsLayoutNode[];
@@ -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): 21 | 10 | 40 | 12 | 50 | 11 | 20 | 25 | 30 | 39 | 41;
35
+ export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 10 | 40 | 12 | 50 | 11 | 20 | 21 | 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -5,7 +5,6 @@ import { getPhiBuilderNavigationDefaultScopeKey, createPhiBuilderNavigationPageL
5
5
  import { PhiHeaderNavigationWidgetClient } from "./client";
6
6
  import { PHI_HEADER_NAVIGATION_WIDGET_DEFINITION, } from "./config";
7
7
  import { mapPhiBuilderNavigationItemsToNavItems } from "../../../../../components/widgets/builder/navigation-items";
8
- import { resolvePhiRenderableBlockGeometry } from "../../../../../types/renderable-block-geometry";
9
8
  function PhiHeaderNavigationWidgetEditor({ runtime, config, canvas, }) {
10
9
  if (!canvas.catalogHydrated) {
11
10
  return null;
@@ -16,9 +15,9 @@ function PhiHeaderNavigationWidgetEditor({ runtime, config, canvas, }) {
16
15
  if (!navigation) {
17
16
  return null;
18
17
  }
19
- return (_jsx(PhiHeaderNavigationWidgetClient, { runtime: { site: runtime.site, locale: runtime.locale, area: currentCmsArea }, items: mapPhiBuilderNavigationItemsToNavItems(resolvePhiBuilderNavigationPageTargets(currentCmsArea, navigation.items, createPhiBuilderNavigationPageLookup(canvas.pageCatalogForArea))), menuTheme: runtime.site.theme?.mode === "dark" ? "dark" : "light", height: config.height, align: config.align, interactive: false }));
18
+ return (_jsx(PhiHeaderNavigationWidgetClient, { runtime: { site: runtime.site, locale: runtime.locale, area: currentCmsArea }, items: mapPhiBuilderNavigationItemsToNavItems(resolvePhiBuilderNavigationPageTargets(currentCmsArea, navigation.items, createPhiBuilderNavigationPageLookup(canvas.pageCatalogForArea))), menuTheme: runtime.site.theme?.mode === "dark" ? "dark" : "light", align: config.align, interactive: false }));
20
19
  }
21
20
  export const PHI_HEADER_NAVIGATION_WIDGET_BUILDER_PLUGIN = {
22
21
  ...PHI_HEADER_NAVIGATION_WIDGET_DEFINITION,
23
- renderEditor: ({ runtime, regionConfig, config, authoring }) => authoring ? (_jsx(PhiHeaderNavigationWidgetEditor, { runtime: runtime, config: { ...config, height: resolvePhiRenderableBlockGeometry(regionConfig).block.size?.css }, canvas: authoring.canvas })) : null,
22
+ renderEditor: ({ runtime, config, authoring }) => authoring ? (_jsx(PhiHeaderNavigationWidgetEditor, { runtime: runtime, config: config, canvas: authoring.canvas })) : null,
24
23
  };
@@ -1,4 +1,3 @@
1
- import type { CSSProperties } from "react";
2
1
  import type { PhiMenuSelectionStyle } from "../../../../../components/controls/phi-menu-control-vocabulary";
3
2
  import type { PhiClientBlockBaseProps, PhiBlockRuntime, PhiNoLabels } from "../../../../../types";
4
3
  import { type PhiMenuTheme, type PhiNavItem } from "../../../../../components/shell/shell-types";
@@ -7,11 +6,10 @@ export type PhiHeaderNavigationWidgetClientProps = PhiClientBlockBaseProps<PhiNo
7
6
  runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area">;
8
7
  items: PhiNavItem[];
9
8
  menuTheme?: PhiMenuTheme;
10
- height?: CSSProperties["height"];
11
9
  align?: "left" | "center";
12
10
  selectionStyle?: PhiMenuSelectionStyle;
13
11
  /** Below 768px: the entries behind a menu button (the default), or the row as on a wider screen. */
14
12
  phoneMenu?: PhiHeaderNavigationPhoneMenu;
15
13
  interactive?: boolean;
16
14
  };
17
- export declare function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align, selectionStyle, phoneMenu, interactive, }: PhiHeaderNavigationWidgetClientProps): import("react").JSX.Element | null;
15
+ export declare function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, align, selectionStyle, phoneMenu, interactive, }: PhiHeaderNavigationWidgetClientProps): import("react").JSX.Element | null;
@@ -10,13 +10,12 @@ import { usePhiPathname } from "../../../../../components/runtime/use-phi-pathna
10
10
  import { PhiButtonControl } from "../../../../../components/controls/phi-button-control";
11
11
  import { PhiDialogControl } from "../../../../../components/controls/phi-dialog-control";
12
12
  import { PhiIcon } from "../../../../../components/shell/phi-icon";
13
- export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align = "left", selectionStyle = "auto", phoneMenu = "button", interactive = true, }) {
13
+ export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, align = "left", selectionStyle = "auto", phoneMenu = "button", interactive = true, }) {
14
14
  const { token } = usePhiConfig();
15
15
  const pathname = usePhiPathname();
16
16
  const availableLocales = runtime.site.availableLocales.map((option) => option.code);
17
17
  const selectedKeys = collectPhiSelectedNavKeys(pathname, items, availableLocales);
18
18
  const menuItems = mapPhiNavItems(runtime.locale.current, runtime.area, pathname, items, availableLocales, { interactive });
19
- const resolvedHeight = typeof height === "number" ? `${height}px` : (height ?? "100%");
20
19
  /*
21
20
  * The Page the Drawer was opened on: following an entry to another Page closes it without an effect
22
21
  * having to notice the navigation (the Shell's Sider drawer does the same).
@@ -75,12 +74,17 @@ export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, hei
75
74
  justifyContent: align === "center" ? "center" : "flex-start",
76
75
  }, children: _jsx(PhiMenuControl, { mode: "horizontal", menuTheme: menuTheme, selectionStyle: selectionStyle, selectedKeys: selectedKeys, items: menuItems, fontSize: token.fontSize, style: {
77
76
  display: "flex",
78
- alignItems: "center",
77
+ /*
78
+ * The row is as tall as the room its Layout gives it, not as tall as the Region: a Region's
79
+ * padding -- the gap a floating Header keeps above its bar -- is not the menu's. Each entry
80
+ * stretches to the row and centres its words (`styles/controls.css`, "Header Navigation"); the
81
+ * pill stands at the control height in the middle of it.
82
+ */
83
+ alignItems: "stretch",
79
84
  justifyContent: align === "center" ? "center" : "flex-start",
80
85
  minHeight: 0,
81
86
  flex: "1 1 auto",
82
87
  paddingInline: 0,
83
- height: resolvedHeight,
84
- lineHeight: resolvedHeight,
88
+ height: "100%",
85
89
  } }) })] }));
86
90
  }
@@ -1,4 +1,3 @@
1
- import type { CSSProperties } from "react";
2
1
  import { type PhiMenuSelectionStyle } from "../../../../../components/controls/phi-menu-control-vocabulary";
3
2
  import { type PhiCmsWidgetConfigBase } from "../../../../../components/widgets/config/parser-primitives";
4
3
  export type PhiCmsHeaderNavigationWidgetConfig = PhiCmsWidgetConfigBase & {
@@ -14,9 +13,7 @@ export type PhiCmsHeaderNavigationWidgetConfig = PhiCmsWidgetConfigBase & {
14
13
  };
15
14
  export type PhiHeaderNavigationPhoneMenu = "button" | "row";
16
15
  declare function parsePhiCmsHeaderNavigationWidgetConfig(config: Record<string, unknown>): PhiCmsHeaderNavigationWidgetConfig;
17
- export type PhiHeaderNavigationWidgetRenderableConfig = Pick<PhiCmsHeaderNavigationWidgetConfig, "align" | "selectionStyle" | "phoneMenu"> & {
18
- height?: CSSProperties["height"];
19
- };
16
+ export type PhiHeaderNavigationWidgetRenderableConfig = Pick<PhiCmsHeaderNavigationWidgetConfig, "align" | "selectionStyle" | "phoneMenu">;
20
17
  export declare const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION: {
21
18
  kind: "widget";
22
19
  pluginKey: string;
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PHI_HEADER_NAVIGATION_WIDGET_DEFINITION, PHI_HEADER_NAVIGATION_WIDGET_PLUGIN_TYPE, } from "./config";
3
3
  import { PhiHeaderNavigationWidget } from "./server";
4
- import { resolvePhiRenderableBlockGeometry } from "../../../../../types/renderable-block-geometry";
5
4
  export const PHI_HEADER_NAVIGATION_WIDGET_PLUGIN = {
6
5
  ...PHI_HEADER_NAVIGATION_WIDGET_DEFINITION,
7
- render: ({ widget, runtime, regionConfig, config }) => (_jsx(PhiHeaderNavigationWidget, { runtime: runtime, navKey: config.navKey ?? `${runtime.area}:header`, height: resolvePhiRenderableBlockGeometry(regionConfig).block.size?.css, align: config.align, selectionStyle: config.selectionStyle, phoneMenu: config.phoneMenu, interactive: true }, `widget-${widget.id}`)),
8
- renderPreview: ({ widget, runtime, regionConfig, config }) => (_jsx(PhiHeaderNavigationWidget, { runtime: runtime, navKey: config.navKey ?? `${runtime.area}:header`, height: resolvePhiRenderableBlockGeometry(regionConfig).block.size?.css, align: config.align, interactive: false }, `widget-${widget.id}`)),
6
+ render: ({ widget, runtime, config }) => (_jsx(PhiHeaderNavigationWidget, { runtime: runtime, navKey: config.navKey ?? `${runtime.area}:header`, align: config.align, selectionStyle: config.selectionStyle, phoneMenu: config.phoneMenu, interactive: true }, `widget-${widget.id}`)),
7
+ renderPreview: ({ widget, runtime, config }) => (_jsx(PhiHeaderNavigationWidget, { runtime: runtime, navKey: config.navKey ?? `${runtime.area}:header`, align: config.align, interactive: false }, `widget-${widget.id}`)),
9
8
  };
10
9
  export { PHI_HEADER_NAVIGATION_WIDGET_PLUGIN_TYPE };
@@ -1,7 +1,7 @@
1
1
  import type { PhiBlockRuntime } from "../../../../../types";
2
2
  import type { PhiHeaderNavigationWidgetClientProps } from "./client";
3
- export type PhiHeaderNavigationWidgetProps = Pick<PhiHeaderNavigationWidgetClientProps, "menuTheme" | "height" | "align" | "selectionStyle" | "phoneMenu" | "interactive"> & {
3
+ export type PhiHeaderNavigationWidgetProps = Pick<PhiHeaderNavigationWidgetClientProps, "menuTheme" | "align" | "selectionStyle" | "phoneMenu" | "interactive"> & {
4
4
  runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area" | "viewer" | "request">;
5
5
  navKey?: string;
6
6
  };
7
- export declare function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, align, selectionStyle, phoneMenu, interactive, }: PhiHeaderNavigationWidgetProps): Promise<import("react").JSX.Element | null>;
7
+ export declare function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, align, selectionStyle, phoneMenu, interactive, }: PhiHeaderNavigationWidgetProps): Promise<import("react").JSX.Element | null>;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
3
3
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
4
4
  import { resolvePhiNavigationItems } from "../../../../../components/widgets/server/navigation-request";
5
- export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, align, selectionStyle, phoneMenu, interactive = true, }) {
5
+ export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, align, selectionStyle, phoneMenu, interactive = true, }) {
6
6
  const items = await resolvePhiNavigationItems(runtime, navKey?.trim() || `${runtime.area}:header`);
7
7
  if (items == null) {
8
8
  return null;
@@ -11,7 +11,6 @@ export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, he
11
11
  runtime: { site: runtime.site, locale: runtime.locale, area: runtime.area },
12
12
  items,
13
13
  menuTheme,
14
- height,
15
14
  align,
16
15
  selectionStyle,
17
16
  phoneMenu,
@@ -21,7 +21,8 @@ import { PHI_THEME_HEADING_FONT_VARIABLE, readPhiThemeHeadingFont, resolvePhiThe
21
21
  import { resolvePhiThemeRuntimePayload } from "../../../../../theme/phi-theme-runtime";
22
22
  import { resolvePhiAntdAliasTokens } from "../../../../../theme/phi-antd-token-resolver";
23
23
  import { buildPhiThemeStructuralTokens } from "../../../../../theme/phi-theme";
24
- import { PHI_CONTROL_HEIGHTS, PHI_PADDING, PHI_RADII, } from "../../../../../theme/phi-tokens";
24
+ import { PHI_CONTROL_HEIGHTS, PHI_LAYOUT, PHI_PADDING, PHI_RADII, } from "../../../../../theme/phi-tokens";
25
+ import { PHI_CONTAINER_BREAKPOINT_REGION } from "../../../../../theme/phi-container-breakpoints";
25
26
  import { PHI_COLOR_PICKER_NEUTRAL_PRESETS, PHI_COLOR_PICKER_PRESETS } from "../../../../../components/widgets/config/color-picker-presets";
26
27
  import { PHI_SPACING_TOKEN_KEYS } from "../../../../../components/widgets/config/spacing-options";
27
28
  import { PhiColorFieldControl } from "../../../../../components/controls/phi-color-field-control";
@@ -83,6 +84,7 @@ const BRAND_THEME_STYLE_SECTION_KEYS = [
83
84
  "fontFamily",
84
85
  "fontSize",
85
86
  "wireframe",
87
+ "pageWidth",
86
88
  ];
87
89
  /*
88
90
  * The shadow under each kind of Button (theme/phi-button-shadow.ts). "Theme" is no step at all -- the
@@ -1300,6 +1302,7 @@ export function PhiBuilderBrandStyleControlsWidgetClient({ runtime, config, }) {
1300
1302
  /** One row per size step: a label and the preset picker; Border Radius and Control Height share it. */
1301
1303
  const renderPresetSizeRows = (items, options) => (_jsx(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: items.map((item) => (_jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: item.label }), _jsx(PhiPresetSizeControl, { value: item.value, fallbackKey: item.fallbackPreset, options: options, onChange: (value) => updateToken({ [item.key]: value }) })] }, item.key))) }));
1302
1304
  const wireframe = readEffectiveTokenBoolean(styleTokenInput, "wireframe", true);
1305
+ const pageMax = readEffectiveTokenNumber(styleTokenInput, "phiPageMax", PHI_LAYOUT.pageMax);
1303
1306
  const baseFontSize = readEffectiveTokenNumber(styleTokenInput, "fontSize", 12);
1304
1307
  function updateToken(tokenPatch) {
1305
1308
  publishDraft(mergeThemeToken(state.draft, tokenPatch));
@@ -1409,6 +1412,16 @@ export function PhiBuilderBrandStyleControlsWidgetClient({ runtime, config, }) {
1409
1412
  label: _jsx(PhiTypographyControl, { strong: true, children: "Wireframe" }),
1410
1413
  children: (_jsxs(PhiFlexControl, { align: "center", justify: "space-between", gap: clientToken.paddingSM, wrap: "wrap", children: [_jsx(PhiTypographyControl, { type: "secondary", children: "Dividing lines in dialogs and popovers, outlined steps and radios" }), _jsx(PhiSwitchControl, { checked: wireframe, checkedLabel: "On", uncheckedLabel: "Off", onChange: (checked) => updateToken({ wireframe: checked }) })] })),
1411
1414
  },
1415
+ {
1416
+ /*
1417
+ * How wide a Page may get (`PHI_PAGE.max`). Never below the width from which a Region counts
1418
+ * as wide: a narrower Page could never be wide, and the Theme refuses one when it is saved.
1419
+ * Emptied, the Theme says nothing and the house default stands.
1420
+ */
1421
+ key: "pageWidth",
1422
+ label: _jsx(PhiTypographyControl, { strong: true, children: "Page Width" }),
1423
+ children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: [_jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: "Maximum" }), _jsx(PhiNumberControl, { prefix: "px", value: pageMax, step: 1, min: PHI_CONTAINER_BREAKPOINT_REGION, onChange: (next) => updateToken({ phiPageMax: next == null ? undefined : next }) })] }), _jsxs(PhiTypographyControl, { type: "secondary", children: ["How wide a Page gets on a wide screen. At least ", PHI_CONTAINER_BREAKPOINT_REGION, "px, the width from which a Region counts as wide."] })] })),
1424
+ },
1412
1425
  ] }) })] }));
1413
1426
  }
1414
1427
  /**
@@ -293,6 +293,19 @@ h5.phi-typography, .phi-typography h5 {
293
293
  --ant-menu-icon-margin-inline-end: calc(var(--ant-control-height-sm) - var(--phi-menu-font-size));
294
294
  }
295
295
 
296
+ /*
297
+ * Header Navigation: the row is as tall as the room its Layout gives it (the Widget's `height: 100%`), and
298
+ * each entry stretches to the row and centres its words in it. Ant Design centres them with a line height
299
+ * as tall as the bar, which is a length, and the length the Widget used to hand it was the Region's height
300
+ * -- padding included, so the entries of a Header that keeps its floating gap as padding stood below the
301
+ * brand and the buttons beside them. The pill below still stands at the control height in the middle.
302
+ */
303
+ .phi-header-nav .ant-menu-horizontal > :is(.ant-menu-item, .ant-menu-submenu) {
304
+ display: flex;
305
+ align-items: center;
306
+ line-height: var(--ant-control-height);
307
+ }
308
+
296
309
  /*
297
310
  * A horizontal menu's mark for the current entry (`PhiMenuControl` `selectionStyle`).
298
311
  *
@@ -69,6 +69,15 @@ export declare const PHI_SPACE: {
69
69
  readonly xl: "var(--ant-padding-xl)";
70
70
  readonly xxl: "var(--ant-padding-xxl)";
71
71
  };
72
+ /**
73
+ * How wide a Page may get: the Theme's `phiPageMax` (theme/phi-tokens.ts, `PHI_LAYOUT.pageMax`).
74
+ *
75
+ * A Page states this reference and not the number, so the Theme's answer reaches every Page, an edited
76
+ * copy included -- a number written into a preset tree stays what it was the day the copy was made.
77
+ */
78
+ export declare const PHI_PAGE: {
79
+ readonly max: "var(--ant-phi-page-max)";
80
+ };
72
81
  export declare const PHI_RADIUS: {
73
82
  readonly xxs: "var(--ant-border-radius-xs)";
74
83
  readonly xs: "var(--ant-border-radius-sm)";
@@ -78,6 +78,15 @@ export const PHI_SPACE = {
78
78
  xl: "var(--ant-padding-xl)",
79
79
  xxl: "var(--ant-padding-xxl)",
80
80
  };
81
+ /**
82
+ * How wide a Page may get: the Theme's `phiPageMax` (theme/phi-tokens.ts, `PHI_LAYOUT.pageMax`).
83
+ *
84
+ * A Page states this reference and not the number, so the Theme's answer reaches every Page, an edited
85
+ * copy included -- a number written into a preset tree stays what it was the day the copy was made.
86
+ */
87
+ export const PHI_PAGE = {
88
+ max: "var(--ant-phi-page-max)",
89
+ };
81
90
  export const PHI_RADIUS = {
82
91
  xxs: "var(--ant-border-radius-xs)",
83
92
  xs: "var(--ant-border-radius-sm)",
@@ -31,5 +31,8 @@ export declare const PHI_CONTAINER_BREAKPOINT_COL3: PhiContainerBreakpoint;
31
31
  * a full-width Region rather than in a content column.
32
32
  */
33
33
  export declare const PHI_CONTAINER_BREAKPOINT_CONTENT: PhiContainerBreakpoint;
34
- /** The wide content maximum (`PHI_LAYOUT.contentMaxWide`): a Region running the width of the page. */
34
+ /**
35
+ * From here a Region counts as wide: one running the width of a Page. Not a Page's width -- that is the
36
+ * Theme's (`PHI_PAGE.max`), and a Theme may not state one below this.
37
+ */
35
38
  export declare const PHI_CONTAINER_BREAKPOINT_REGION: PhiContainerBreakpoint;
@@ -30,5 +30,8 @@ export const PHI_CONTAINER_BREAKPOINT_COL3 = 377;
30
30
  * a full-width Region rather than in a content column.
31
31
  */
32
32
  export const PHI_CONTAINER_BREAKPOINT_CONTENT = 610;
33
- /** The wide content maximum (`PHI_LAYOUT.contentMaxWide`): a Region running the width of the page. */
33
+ /**
34
+ * From here a Region counts as wide: one running the width of a Page. Not a Page's width -- that is the
35
+ * Theme's (`PHI_PAGE.max`), and a Theme may not state one below this.
36
+ */
34
37
  export const PHI_CONTAINER_BREAKPOINT_REGION = 987;
@@ -35,12 +35,15 @@ export declare const PHI_THEME_TOKEN_KEYS: readonly ["colorBgContainer", "colorB
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
37
  *
38
+ * `phiPageMax` is how wide a Page may get (theme/phi-tokens.ts, `PHI_LAYOUT.pageMax`); a Page reads it
39
+ * as `PHI_PAGE.max`.
40
+ *
38
41
  * The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
39
42
  * (theme/phi-theme-gradients.ts): tokens of this package's own, laid over the resolved ones so Ant
40
43
  * Design writes them per mode and per Surface tone like every other. The `phiCustom*` names are the
41
44
  * palette's custom colours, laid over the same way (theme/phi-theme-palette.ts).
42
45
  */
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"];
46
+ export declare const PHI_THEME_OWN_TOKEN_KEYS: readonly ["paddingXXL", "phiPageMax", "phiGradient1", "phiGradient1Text", "phiGradient2", "phiGradient2Text", "phiGradient3", "phiGradient3Text", "phiPrimaryButtonGradient", "phiPrimaryButtonGradientHover", "phiPrimaryButtonGradientActive", "phiPrimaryButtonGradientText", "phiCustom1", "phiCustom2", "phiCustom3", "phiCustom4", "phiCustom5", "phiCustom6", "phiCustom7", "phiCustom8", "phiCustom9", "phiCustom10"];
44
47
  export type PhiThemeTokenKey = (typeof PHI_THEME_TOKEN_KEYS)[number];
45
48
  /**
46
49
  * The resolved Theme, in the names above and their Ant Design value types.
@@ -1,3 +1,4 @@
1
+ import { PHI_CONTAINER_BREAKPOINT_REGION } from "./phi-container-breakpoints";
1
2
  /**
2
3
  * The token vocabulary of this house, stated once.
3
4
  *
@@ -165,6 +166,9 @@ export const PHI_THEME_TOKEN_KEYS = [
165
166
  * Design's type and a name Ant Design does not know cannot be cut from it. A Client Component that
166
167
  * needs one of these reads it as a CSS variable, the way a Server Component does.
167
168
  *
169
+ * `phiPageMax` is how wide a Page may get (theme/phi-tokens.ts, `PHI_LAYOUT.pageMax`); a Page reads it
170
+ * as `PHI_PAGE.max`.
171
+ *
168
172
  * The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
169
173
  * (theme/phi-theme-gradients.ts): tokens of this package's own, laid over the resolved ones so Ant
170
174
  * Design writes them per mode and per Surface tone like every other. The `phiCustom*` names are the
@@ -172,6 +176,7 @@ export const PHI_THEME_TOKEN_KEYS = [
172
176
  */
173
177
  export const PHI_THEME_OWN_TOKEN_KEYS = [
174
178
  "paddingXXL",
179
+ "phiPageMax",
175
180
  "phiGradient1",
176
181
  "phiGradient1Text",
177
182
  "phiGradient2",
@@ -252,7 +257,26 @@ export function assertPhiThemeVocabulary({ palette, styleToken, modeSeedKeys, so
252
257
  for (const [mode, modeConfig] of Object.entries(palette?.modes ?? {})) {
253
258
  violations.push(...readPhiThemeVocabularyViolations(modeConfig?.seed, modeSeedNames, source, `the ${mode} seed`), ...readPhiThemeVocabularyViolations(modeConfig?.overrides, PHI_THEME_TOKEN_NAMES, source, `the ${mode} override`));
254
259
  }
260
+ violations.push(...readPhiThemePageMaxViolations(styleToken, source));
255
261
  if (violations.length > 0) {
256
262
  throw new Error(violations.join(" "));
257
263
  }
258
264
  }
265
+ /**
266
+ * A Page's maximum is a number of pixels and at least the width from which a Region counts as wide.
267
+ *
268
+ * Narrower, no Page could ever be wide: a Grid of four columns or anything else that answers to the
269
+ * Region threshold would never draw its wide form, and nothing would say why.
270
+ */
271
+ function readPhiThemePageMaxViolations(styleToken, source) {
272
+ const value = styleToken?.phiPageMax;
273
+ if (value == null)
274
+ return [];
275
+ if (typeof value !== "number" || !Number.isFinite(value)) {
276
+ return [`${source}: the style token states phiPageMax as ${JSON.stringify(value)}, which is not a number of pixels.`];
277
+ }
278
+ if (value < PHI_CONTAINER_BREAKPOINT_REGION) {
279
+ return [`${source}: the style token states phiPageMax ${value}, narrower than ${PHI_CONTAINER_BREAKPOINT_REGION}, from which a Region counts as wide.`];
280
+ }
281
+ return [];
282
+ }
@@ -32,6 +32,8 @@ export type PhiThemeTokens = {
32
32
  paddingLG: number;
33
33
  paddingXL: number;
34
34
  paddingXXL: number;
35
+ /** How wide a Page may get (`PHI_LAYOUT.pageMax`), published as `--ant-phi-page-max`. */
36
+ phiPageMax: number;
35
37
  marginXXS: number;
36
38
  marginXS: number;
37
39
  marginSM: number;
@@ -17,6 +17,7 @@ function buildPhiThemeTokens(options = {}) {
17
17
  paddingLG: PHI_PADDING_VALUES.lg,
18
18
  paddingXL: PHI_PADDING_VALUES.xl,
19
19
  paddingXXL: PHI_PADDING_VALUES.xxl,
20
+ phiPageMax: PHI_LAYOUT.pageMax,
20
21
  // Ant Design's second family, on the same scale: its own components read it (phi-tokens.ts).
21
22
  marginXXS: PHI_PADDING_VALUES.xxs,
22
23
  marginXS: PHI_PADDING_VALUES.xs,
@@ -88,7 +88,7 @@ export declare const PHI_LAYOUT: {
88
88
  readonly numberControlMax: 144;
89
89
  readonly contentMaxNarrow: 377;
90
90
  readonly contentMax: 610;
91
- readonly contentMaxWide: 987;
91
+ readonly pageMax: 1220;
92
92
  readonly readingMax: 754;
93
93
  readonly heroHeight: 377;
94
94
  };
@@ -118,13 +118,24 @@ export const PHI_LAYOUT = {
118
118
  * `narrow` is a single column of Controls without a label beside them -- a sign-in, a confirmation.
119
119
  * `contentMax` is the one a labelled form wants: the 24-track grid puts labels left of their
120
120
  * Controls, and at 377 a label column of 8 tracks leaves the Control too little to show what is in
121
- * it. `wide` is for what is read across rather than filled in, such as a table.
121
+ * it.
122
122
  *
123
123
  * They are maxima and not widths. A block still fills its slot; these only say where it stops.
124
124
  */
125
125
  contentMaxNarrow: 377,
126
126
  contentMax: 610,
127
- contentMaxWide: 987,
127
+ /*
128
+ * How wide a Page is allowed to get: the column a catalogue, a landing or a Module's wide Page stands in.
129
+ *
130
+ * The Theme's to decide and not a constant: this is only the answer where a Theme says nothing, and a
131
+ * Page reads it as `PHI_PAGE.max`, the Theme's own variable, never as this number -- a Theme that
132
+ * widens its Pages then widens every one of them, an edited copy included.
133
+ *
134
+ * 987 + 233, off the sequence the way `readingMax` is. 987 itself is not a Page's width but the
135
+ * threshold from which a Region counts as wide (`PHI_CONTAINER_BREAKPOINT_REGION`), and a Page has to
136
+ * be able to get past it, which is why a Theme may not state less (`assertPhiThemeVocabulary`).
137
+ */
138
+ pageMax: 1220,
128
139
  /*
129
140
  * How wide a column of prose is allowed to get: an article, an entry and what stands around it.
130
141
  *
package/theme.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { isPhiThemePaletteModeSeedKey, mergePhiThemePalettes, PHI_THEME_CUSTOM_COLOR_KEYS, PHI_THEME_PALETTE_MODE_SEED_KEYS, type PhiThemeCustomColorKey, type PhiThemeCustomColorPalette, type PhiThemeMode, type PhiThemePalette, type PhiThemePaletteMode, type PhiThemePresetPlugin, } from "./theme/phi-theme-presets";
2
2
  export * from "./theme/phi-tokens";
3
- export { PHI_COLOR, PHI_RADIUS, PHI_SPACE } from "./theme/antd-css-var-contract";
3
+ export { PHI_COLOR, PHI_PAGE, PHI_RADIUS, PHI_SPACE } from "./theme/antd-css-var-contract";
4
4
  export { type PhiThemeBlockIdentity, type PhiThemeFontsBlock, type PhiThemeGroundBlock, type PhiThemePaletteBlock, type PhiThemeSetBlock, type PhiThemeStyleBlock, } from "./theme/phi-theme-blocks";
package/theme.js CHANGED
@@ -5,5 +5,5 @@ export * from "./theme/phi-tokens";
5
5
  * Each is a reference the Theme resolves per Site and per mode, never a value of its own, so a preset
6
6
  * that names one follows whatever Theme it lands in (THEME.md, "Phi scale").
7
7
  */
8
- export { PHI_COLOR, PHI_RADIUS, PHI_SPACE } from "./theme/antd-css-var-contract";
8
+ export { PHI_COLOR, PHI_PAGE, PHI_RADIUS, PHI_SPACE } from "./theme/antd-css-var-contract";
9
9
  export {} from "./theme/phi-theme-blocks";