@phis/ui 0.4.5 → 0.4.7

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 (145) hide show
  1. package/components/cms/phi-cms-root-layout.js +1 -1
  2. package/components/controls/phi-button-control.d.ts +3 -1
  3. package/components/controls/phi-button-control.js +2 -2
  4. package/components/controls/phi-collapse-control.d.ts +6 -2
  5. package/components/controls/phi-collapse-control.js +2 -2
  6. package/components/controls/phi-dialog-control.d.ts +11 -5
  7. package/components/controls/phi-dialog-control.js +19 -13
  8. package/components/controls/phi-menu-control-vocabulary.d.ts +7 -0
  9. package/components/controls/phi-menu-control-vocabulary.js +10 -0
  10. package/components/controls/phi-menu-control.d.ts +4 -1
  11. package/components/controls/phi-menu-control.js +6 -1
  12. package/components/controls/phi-text-control.d.ts +6 -1
  13. package/components/controls/phi-text-control.js +2 -1
  14. package/components/layouts/clients/phi-split-card-layout-client.js +13 -5
  15. package/components/layouts/clients/phi-three-column-layout-client.js +9 -3
  16. package/components/layouts/split-card-geometry.js +6 -2
  17. package/components/media/aspect-ratios.d.ts +2 -2
  18. package/components/menus/phi-account-menu.js +3 -1
  19. package/components/navigation/phi-link.js +7 -2
  20. package/components/navigation/use-phi-protected-mail.d.ts +11 -0
  21. package/components/navigation/use-phi-protected-mail.js +29 -0
  22. package/components/regions/clients/cms-region-container-client.js +5 -1
  23. package/components/regions/phi-cms-region-shell.d.ts +1 -0
  24. package/components/regions/phi-cms-region-shell.js +11 -0
  25. package/components/regions/presets/phi-area-shell-preset-nodes.d.ts +5 -0
  26. package/components/regions/presets/phi-area-shell-preset-nodes.js +19 -3
  27. package/components/root/phi-config-provider.js +16 -0
  28. package/components/shell/phi-cms-shell.d.ts +3 -1
  29. package/components/shell/phi-cms-shell.js +7 -3
  30. package/components/shell/phi-nav-link.js +7 -2
  31. package/components/shell/phi-shell-sider-drawer.d.ts +17 -0
  32. package/components/shell/phi-shell-sider-drawer.js +88 -0
  33. package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -0
  34. package/components/widgets/helpers/internal-reference-resolver.server.js +4 -1
  35. package/components/widgets/label-sets/inspector.js +2 -0
  36. package/components/widgets/label-sets/search-results.d.ts +4 -0
  37. package/components/widgets/label-sets/search-results.js +35 -0
  38. package/components/widgets/label-types/inspector.d.ts +2 -0
  39. package/components/widgets/label-types/inspector.js +1 -0
  40. package/components/widgets/label-types/search-results.d.ts +15 -0
  41. package/components/widgets/label-types/search-results.js +10 -0
  42. package/components/widgets/server/navigation-request.js +13 -1
  43. package/components/widgets/shared/card-body-client.d.ts +2 -0
  44. package/components/widgets/shared/card-body-client.js +8 -7
  45. package/components/widgets/shared/card-vocabulary.d.ts +36 -0
  46. package/components/widgets/shared/card-vocabulary.js +52 -0
  47. package/components/widgets/shared/markdown-body-client.d.ts +29 -0
  48. package/components/widgets/shared/markdown-body-client.js +60 -5
  49. package/components/widgets/shared/markdown-image-vocabulary.d.ts +31 -0
  50. package/components/widgets/shared/markdown-image-vocabulary.js +68 -0
  51. package/components/widgets/shared/markdown-render.d.ts +5 -0
  52. package/components/widgets/shared/markdown-render.js +123 -8
  53. package/components/widgets/shared/markdown-sections.d.ts +40 -0
  54. package/components/widgets/shared/markdown-sections.js +111 -0
  55. package/constants/cms-widget-types.d.ts +2 -0
  56. package/constants/cms-widget-types.js +4 -0
  57. package/gateway/site-area.d.ts +10 -7
  58. package/gateway/site-area.js +13 -11
  59. package/gateway/site-config.js +7 -1
  60. package/gateway/site-read-marker-listeners.d.ts +24 -0
  61. package/gateway/site-read-marker-listeners.js +22 -0
  62. package/gateway/site-search.d.ts +37 -0
  63. package/gateway/site-search.js +116 -0
  64. package/helpers/external-href.js +1 -1
  65. package/helpers/protected-mail.d.ts +16 -0
  66. package/helpers/protected-mail.js +81 -0
  67. package/next/areas/app.js +5 -1
  68. package/next/areas/public.js +5 -1
  69. package/next/seo-routes.js +2 -2
  70. package/package.json +2 -2
  71. package/plugins/runtime-modules/app/presets.js +23 -0
  72. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +2 -1
  73. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +3 -2
  74. package/plugins/runtime-modules/builder/clients/region-inspector.js +20 -1
  75. package/plugins/runtime-modules/client-manifests/common.js +8 -0
  76. package/plugins/runtime-modules/core/authoring-widgets.js +4 -0
  77. package/plugins/runtime-modules/core/widgets/card/config.d.ts +8 -1
  78. package/plugins/runtime-modules/core/widgets/card/config.js +22 -1
  79. package/plugins/runtime-modules/core/widgets/card/editor.js +9 -1
  80. package/plugins/runtime-modules/core/widgets/card/plugin.js +18 -0
  81. package/plugins/runtime-modules/core/widgets/card/server.js +9 -1
  82. package/plugins/runtime-modules/core/widgets/description/plugin.js +10 -0
  83. package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +2 -1
  84. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +3 -3
  85. package/plugins/runtime-modules/core/widgets/header-navigation/client.d.ts +6 -1
  86. package/plugins/runtime-modules/core/widgets/header-navigation/client.js +40 -13
  87. package/plugins/runtime-modules/core/widgets/header-navigation/config.d.ts +26 -1
  88. package/plugins/runtime-modules/core/widgets/header-navigation/config.js +27 -0
  89. package/plugins/runtime-modules/core/widgets/header-navigation/plugin.js +1 -1
  90. package/plugins/runtime-modules/core/widgets/header-navigation/server.d.ts +2 -2
  91. package/plugins/runtime-modules/core/widgets/header-navigation/server.js +3 -1
  92. package/plugins/runtime-modules/core/widgets/html/plugin.js +16 -1
  93. package/plugins/runtime-modules/core/widgets/html/server.d.ts +6 -0
  94. package/plugins/runtime-modules/core/widgets/html/server.js +12 -4
  95. package/plugins/runtime-modules/core/widgets/image/client.js +11 -7
  96. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -0
  97. package/plugins/runtime-modules/core/widgets/markdown/config.js +46 -1
  98. package/plugins/runtime-modules/core/widgets/markdown/plugin.js +16 -0
  99. package/plugins/runtime-modules/core/widgets/markdown/server.js +22 -8
  100. package/plugins/runtime-modules/core/widgets/search-box/authoring.d.ts +6 -0
  101. package/plugins/runtime-modules/core/widgets/search-box/authoring.js +10 -0
  102. package/plugins/runtime-modules/core/widgets/search-box/client.d.ts +21 -0
  103. package/plugins/runtime-modules/core/widgets/search-box/client.js +17 -0
  104. package/plugins/runtime-modules/core/widgets/search-box/config.d.ts +63 -0
  105. package/plugins/runtime-modules/core/widgets/search-box/config.js +48 -0
  106. package/plugins/runtime-modules/core/widgets/search-box/plugin.d.ts +3 -0
  107. package/plugins/runtime-modules/core/widgets/search-box/plugin.js +11 -0
  108. package/plugins/runtime-modules/core/widgets/search-box/server.d.ts +21 -0
  109. package/plugins/runtime-modules/core/widgets/search-box/server.js +48 -0
  110. package/plugins/runtime-modules/core/widgets/search-results/authoring.d.ts +6 -0
  111. package/plugins/runtime-modules/core/widgets/search-results/authoring.js +10 -0
  112. package/plugins/runtime-modules/core/widgets/search-results/client.d.ts +34 -0
  113. package/plugins/runtime-modules/core/widgets/search-results/client.js +32 -0
  114. package/plugins/runtime-modules/core/widgets/search-results/config.d.ts +41 -0
  115. package/plugins/runtime-modules/core/widgets/search-results/config.js +39 -0
  116. package/plugins/runtime-modules/core/widgets/search-results/plugin.d.ts +3 -0
  117. package/plugins/runtime-modules/core/widgets/search-results/plugin.js +10 -0
  118. package/plugins/runtime-modules/core/widgets/search-results/server.d.ts +20 -0
  119. package/plugins/runtime-modules/core/widgets/search-results/server.js +73 -0
  120. package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +11 -0
  121. package/plugins/runtime-modules/core/widgets/simple-text/server.js +11 -1
  122. package/plugins/runtime-modules/core/widgets.js +17 -0
  123. package/plugins/runtime-modules/public/presets.d.ts +16 -0
  124. package/plugins/runtime-modules/public/presets.js +22 -0
  125. package/plugins/runtime-modules/public-base-page-references.d.ts +1 -0
  126. package/plugins/runtime-modules/public-base-page-references.js +1 -0
  127. package/plugins/runtime-modules/search-page-references.d.ts +20 -0
  128. package/plugins/runtime-modules/search-page-references.js +35 -0
  129. package/plugins/runtime-modules/search-page-tree.d.ts +14 -0
  130. package/plugins/runtime-modules/search-page-tree.js +63 -0
  131. package/server-helpers/search-index.d.ts +28 -0
  132. package/server-helpers/search-index.js +299 -0
  133. package/server-helpers/search-text.d.ts +40 -0
  134. package/server-helpers/search-text.js +152 -0
  135. package/server-helpers.d.ts +1 -0
  136. package/server-helpers.js +1 -0
  137. package/styles/controls.css +108 -10
  138. package/styles/layout.css +35 -0
  139. package/styles/shell.css +142 -0
  140. package/theme/phi-tokens.d.ts +6 -0
  141. package/theme/phi-tokens.js +6 -0
  142. package/theme.d.ts +1 -0
  143. package/theme.js +6 -0
  144. package/types/cms-plugins.d.ts +20 -2
  145. package/types/core-widget-placements.d.ts +5 -0
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import "../../styles/shell.css";
3
+ import { PhiShellSiderDrawer } from "./phi-shell-sider-drawer";
3
4
  /**
4
5
  * One continuous pane per Chrome family (SHELL.md "Root Background and Shell Backdrop Layers").
5
6
  *
@@ -44,7 +45,7 @@ function PhiShellChromePane({ family, stickyTop, }) {
44
45
  ? { ...PHI_SHELL_CHROME_PANE_PAINT, boxShadow }
45
46
  : { ...PHI_SHELL_CHROME_PANE_PAINT, boxShadow, position: "sticky", top: stickyTop } }));
46
47
  }
47
- export function PhiCmsShell({ content, headerTop, headerMain, headerBottom, hero, siderLeft, siderRight, siderLeftFullHeight = false, footerTop, footerMain, footerBottom, drawer, headerPaneStickyTop, headerTopRoom, headerBandRoom, }) {
48
+ export function PhiCmsShell({ content, headerTop, headerMain, headerBottom, hero, siderLeft, siderRight, siderLeftFullHeight = false, siderLeftMobileDrawer = false, footerTop, footerMain, footerBottom, drawer, headerPaneStickyTop, headerTopRoom, headerBandRoom, }) {
48
49
  const roomStyle = headerTopRoom || headerBandRoom
49
50
  ? { ...headerTopRoom, ...headerBandRoom }
50
51
  : undefined;
@@ -61,8 +62,11 @@ export function PhiCmsShell({ content, headerTop, headerMain, headerBottom, hero
61
62
  */
62
63
  const hasHeader = Boolean(headerTop || headerMain || headerBottom);
63
64
  const hasFooter = Boolean(footerTop || footerMain || footerBottom);
65
+ // The Client is mounted only where a Sider asks for it: every other Shell stays without one.
66
+ const siderDrawer = siderLeftMobileDrawer && siderLeft ? _jsx(PhiShellSiderDrawer, {}) : null;
67
+ const siderDrawerAttribute = siderDrawer ? "sider_left" : undefined;
64
68
  if (hasLeftFullHeightSidebar) {
65
- return (_jsxs("div", { className: "shell-sider-full", "data-phi-shell-layout": "cms", "data-phi-shell-variant": shellVariant, "data-phi-shell-chrome-panes": "true", style: roomStyle, children: [hasHeader ? _jsx(PhiShellChromePane, { family: "header", stickyTop: headerPaneStickyTop }) : null, _jsx(PhiShellChromePane, { family: "sider" }), siderRight ? _jsx(PhiShellChromePane, { family: "sider-right" }) : null, hasFooter ? _jsx(PhiShellChromePane, { family: "footer" }) : null, siderLeft, headerTop, headerMain, headerBottom, hero, _jsx("main", { className: "content phi-shell-content-main", children: content }), siderRight, footerTop, footerMain, footerBottom, drawer] }));
69
+ return (_jsxs("div", { className: "shell-sider-full", "data-phi-shell-layout": "cms", "data-phi-shell-variant": shellVariant, "data-phi-shell-chrome-panes": "true", "data-phi-shell-sider-drawer": siderDrawerAttribute, style: roomStyle, children: [siderDrawer, hasHeader ? _jsx(PhiShellChromePane, { family: "header", stickyTop: headerPaneStickyTop }) : null, _jsx(PhiShellChromePane, { family: "sider" }), siderRight ? _jsx(PhiShellChromePane, { family: "sider-right" }) : null, hasFooter ? _jsx(PhiShellChromePane, { family: "footer" }) : null, siderLeft, headerTop, headerMain, headerBottom, hero, _jsx("main", { className: "content phi-shell-content-main", children: content }), siderRight, footerTop, footerMain, footerBottom, drawer] }));
66
70
  }
67
- return (_jsxs("div", { className: siderLeft ? "shell-sider-embedded" : "shell-sider-embedded shell-sider-embedded--no-sider", "data-phi-shell-layout": "cms", "data-phi-shell-variant": shellVariant, "data-phi-shell-chrome-panes": "true", style: roomStyle, children: [headerTop || headerMain ? _jsx(PhiShellChromePane, { family: "header", stickyTop: headerPaneStickyTop }) : null, headerBottom ? _jsx(PhiShellChromePane, { family: "header-bottom" }) : null, siderLeft ? _jsx(PhiShellChromePane, { family: "sider" }) : null, siderRight ? _jsx(PhiShellChromePane, { family: "sider-right" }) : null, hasFooter ? _jsx(PhiShellChromePane, { family: "footer" }) : null, headerTop, headerMain, headerBottom, hero, siderLeft, _jsx("main", { className: "content phi-shell-content-main", children: content }), siderRight, footerTop, footerMain, footerBottom, drawer] }));
71
+ return (_jsxs("div", { className: siderLeft ? "shell-sider-embedded" : "shell-sider-embedded shell-sider-embedded--no-sider", "data-phi-shell-layout": "cms", "data-phi-shell-variant": shellVariant, "data-phi-shell-chrome-panes": "true", "data-phi-shell-sider-drawer": siderDrawerAttribute, style: roomStyle, children: [siderDrawer, headerTop || headerMain ? _jsx(PhiShellChromePane, { family: "header", stickyTop: headerPaneStickyTop }) : null, headerBottom ? _jsx(PhiShellChromePane, { family: "header-bottom" }) : null, siderLeft ? _jsx(PhiShellChromePane, { family: "sider" }) : null, siderRight ? _jsx(PhiShellChromePane, { family: "sider-right" }) : null, hasFooter ? _jsx(PhiShellChromePane, { family: "footer" }) : null, headerTop, headerMain, headerBottom, hero, siderLeft, _jsx("main", { className: "content phi-shell-content-main", children: content }), siderRight, footerTop, footerMain, footerBottom, drawer] }));
68
72
  }
@@ -1,10 +1,15 @@
1
+ "use client";
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import Link from "next/link";
3
4
  import { isPhiExternalHref } from "../../helpers/external-href";
5
+ import { isPhiProtectedMail } from "../../helpers/protected-mail";
6
+ import { usePhiRevealedHref } from "../navigation/use-phi-protected-mail";
4
7
  export function PhiNavLink({ href, children, external, newTab, className, style, }) {
5
- const useAnchor = external ?? isPhiExternalHref(href);
8
+ // A protected address is never a route, whatever the caller says it is.
9
+ const useAnchor = isPhiProtectedMail(href) || (external ?? isPhiExternalHref(href));
10
+ const anchorHref = usePhiRevealedHref(href);
6
11
  if (useAnchor) {
7
- return (_jsx("a", { href: href, target: newTab ? "_blank" : undefined, rel: newTab ? "noreferrer noopener" : undefined, className: className, style: style, children: children }));
12
+ return (_jsx("a", { href: anchorHref, target: newTab ? "_blank" : undefined, rel: newTab ? "noreferrer noopener" : undefined, className: className, style: style, children: children }));
8
13
  }
9
14
  return (_jsx(Link, { href: href, className: className, style: style, children: children }));
10
15
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A `sider_left` with `MobileDrawer`, on a phone: the menu button that opens it, the mask behind it, and
3
+ * the rules that close it again (SHELL.md "The Sider on a phone").
4
+ *
5
+ * The Sider itself does not move. `styles/shell.css` takes it out of its column below 768px and stands it
6
+ * at the inline start, off screen until the Shell says `data-phi-sider-drawer-open`; this component only
7
+ * says so. The Region keeps rendering where it always renders -- statically or through its own client --
8
+ * so nothing it holds is mounted twice.
9
+ *
10
+ * **The Shell is a container**, and a container is the containing block of what is `position: fixed`
11
+ * inside it: the drawer's top is the Shell's, not the viewport's. So the page stops scrolling while the
12
+ * drawer is open, and the drawer is moved to where the viewport's top is on the Shell at that moment.
13
+ *
14
+ * The button goes into `header_main`, at its inline start; a Shell without one gets it at its own top.
15
+ * Opening needs JavaScript: without it the Sider stays off screen on a phone.
16
+ */
17
+ export declare function PhiShellSiderDrawer(): import("react").JSX.Element;
@@ -0,0 +1,88 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useLayoutEffect, useState } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import { usePhiPathname } from "../runtime/use-phi-pathname";
6
+ import { PhiButtonControl } from "../controls/phi-button-control";
7
+ import { PhiIcon } from "./phi-icon";
8
+ /** Where the drawer's top stands within the Shell, published on the Shell element (`styles/shell.css`). */
9
+ const PHI_SHELL_SIDER_DRAWER_TOP_PROPERTY = "--phi-shell-sider-drawer-top";
10
+ /**
11
+ * A `sider_left` with `MobileDrawer`, on a phone: the menu button that opens it, the mask behind it, and
12
+ * the rules that close it again (SHELL.md "The Sider on a phone").
13
+ *
14
+ * The Sider itself does not move. `styles/shell.css` takes it out of its column below 768px and stands it
15
+ * at the inline start, off screen until the Shell says `data-phi-sider-drawer-open`; this component only
16
+ * says so. The Region keeps rendering where it always renders -- statically or through its own client --
17
+ * so nothing it holds is mounted twice.
18
+ *
19
+ * **The Shell is a container**, and a container is the containing block of what is `position: fixed`
20
+ * inside it: the drawer's top is the Shell's, not the viewport's. So the page stops scrolling while the
21
+ * drawer is open, and the drawer is moved to where the viewport's top is on the Shell at that moment.
22
+ *
23
+ * The button goes into `header_main`, at its inline start; a Shell without one gets it at its own top.
24
+ * Opening needs JavaScript: without it the Sider stays off screen on a phone.
25
+ */
26
+ export function PhiShellSiderDrawer() {
27
+ const pathname = usePhiPathname();
28
+ const [shell, setShell] = useState(null);
29
+ /*
30
+ * The Page the drawer was opened on. Following a link to another Page closes it without an effect
31
+ * having to notice the navigation: on the new path it is simply not open.
32
+ */
33
+ const [openedOn, setOpenedOn] = useState(null);
34
+ const open = openedOn != null && openedOn === pathname;
35
+ const close = useCallback(() => setOpenedOn(null), []);
36
+ const anchorRef = useCallback((node) => {
37
+ setShell(node?.closest("[data-phi-shell-layout]") ?? null);
38
+ }, []);
39
+ const sider = shell?.querySelector('[data-phi-sider-mobile="drawer"]') ?? null;
40
+ const header = shell?.querySelector('[data-phi-region-key="header_main"]') ?? null;
41
+ useLayoutEffect(() => {
42
+ if (!shell)
43
+ return;
44
+ if (!open) {
45
+ shell.removeAttribute("data-phi-sider-drawer-open");
46
+ return;
47
+ }
48
+ const root = document.documentElement;
49
+ const previousOverflow = root.style.overflow;
50
+ root.style.overflow = "hidden";
51
+ shell.style.setProperty(PHI_SHELL_SIDER_DRAWER_TOP_PROPERTY, `${-shell.getBoundingClientRect().top}px`);
52
+ shell.setAttribute("data-phi-sider-drawer-open", "true");
53
+ return () => {
54
+ root.style.overflow = previousOverflow;
55
+ shell.removeAttribute("data-phi-sider-drawer-open");
56
+ shell.style.removeProperty(PHI_SHELL_SIDER_DRAWER_TOP_PROPERTY);
57
+ };
58
+ }, [open, shell]);
59
+ useEffect(() => {
60
+ if (!open || !sider)
61
+ return;
62
+ const onKeyDown = (event) => {
63
+ if (event.key === "Escape")
64
+ close();
65
+ };
66
+ // A link chosen in the drawer is where the reader is going; one to the Page they are on goes nowhere.
67
+ const onClick = (event) => {
68
+ if (event.target instanceof Element && event.target.closest("a[href]"))
69
+ close();
70
+ };
71
+ const previousTabIndex = sider.getAttribute("tabindex");
72
+ if (previousTabIndex == null)
73
+ sider.setAttribute("tabindex", "-1");
74
+ sider.focus({ preventScroll: true });
75
+ document.addEventListener("keydown", onKeyDown);
76
+ sider.addEventListener("click", onClick);
77
+ return () => {
78
+ document.removeEventListener("keydown", onKeyDown);
79
+ sider.removeEventListener("click", onClick);
80
+ if (previousTabIndex == null)
81
+ sider.removeAttribute("tabindex");
82
+ };
83
+ }, [close, open, sider]);
84
+ const button = (_jsx("span", { className: header ? "phi-shell-sider-drawer-button" : "phi-shell-sider-drawer-button phi-shell-sider-drawer-button--shell", children: _jsx(PhiButtonControl, { type: "text", ariaLabel: open ? "Close menu" : "Open menu", ariaExpanded: open, icon: _jsx(PhiIcon, { name: open ? "close" : "menu", size: "inherit" }), onClick: () => setOpenedOn(open ? null : pathname) }) }));
85
+ return (_jsxs(_Fragment, { children: [_jsx("span", { hidden: true, ref: anchorRef }), shell ? createPortal(button, header ?? shell) : null, shell && open
86
+ ? createPortal(_jsx("div", { "aria-hidden": true, className: "phi-shell-sider-drawer-mask", onClick: close }), shell)
87
+ : null] }));
88
+ }
@@ -28,4 +28,5 @@ export declare function resolvePhiWidgetInternalReferences(input: {
28
28
  }): Promise<{
29
29
  pagePaths: Map<PhiPageReference, string>;
30
30
  assetUrls: Map<number, string>;
31
+ assets: Map<number, import("../../../types").PhiPublicMediaAssetReference>;
31
32
  }>;
@@ -69,5 +69,8 @@ export async function resolvePhiWidgetInternalReferences(input) {
69
69
  // renderable and must not be re-filtered here.
70
70
  const assetUrls = new Map([...projection.assets.values()]
71
71
  .flatMap((asset) => asset.deliveryUrl ? [[asset.id, asset.deliveryUrl]] : []));
72
- return { pagePaths, assetUrls };
72
+ /* The whole public projection as well, for a reader that draws the picture and not only links it. */
73
+ const assets = new Map([...projection.assets.values()]
74
+ .flatMap((asset) => asset.deliveryUrl ? [[asset.id, asset]] : []));
75
+ return { pagePaths, assetUrls, assets };
73
76
  }
@@ -32,6 +32,7 @@ const PHI_INSPECTOR_WIDGET_LABEL_SET = definePhiLabelSet({
32
32
  region_visibility_always: PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.regionVisibility.always,
33
33
  region_visibility_hover: PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.regionVisibility.hover,
34
34
  region_hero_overlap: PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.regionVisibility.heroOverlap,
35
+ region_sider_mobile_drawer: PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.regionVisibility.siderMobileDrawer,
35
36
  region_visibility_scroll_up: PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.regionVisibility.scrollUp,
36
37
  region_visibility_page_owned: definePhiMessageLabel(PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.regionVisibility.pageOwned),
37
38
  surface_style_title: PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.surfaceStyle.title,
@@ -112,6 +113,7 @@ export async function getPhiInspectorWidgetLabels(options) {
112
113
  scrollUp: labels.region_visibility_scroll_up,
113
114
  pageOwned: labels.region_visibility_page_owned,
114
115
  heroOverlap: labels.region_hero_overlap,
116
+ siderMobileDrawer: labels.region_sider_mobile_drawer,
115
117
  },
116
118
  surfaceStyle: {
117
119
  title: labels.surface_style_title,
@@ -0,0 +1,4 @@
1
+ import "server-only";
2
+ import { type PhiGlobalTranslatorOptions } from "../../../gateway/tr";
3
+ import { type PhiSearchResultsWidgetLabels } from "../label-types/search-results";
4
+ export declare function getPhiSearchResultsWidgetLabels(options: PhiGlobalTranslatorOptions): Promise<PhiSearchResultsWidgetLabels>;
@@ -0,0 +1,35 @@
1
+ import "server-only";
2
+ import { definePhiLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../gateway/label-set";
3
+ import { PHI_TR_CTX_WEB_UI_LABEL, } from "../../../gateway/tr";
4
+ import { PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS, } from "../label-types/search-results";
5
+ /**
6
+ * What the results Widget says around the hits (SEARCH.md). The hits' own words -- titles, snippets --
7
+ * are the Pages' and arrive from Core in the page's language already.
8
+ */
9
+ const PHI_SEARCH_RESULTS_WIDGET_LABEL_SET = definePhiLabelSet({
10
+ key: "widget:search-results",
11
+ ctx: PHI_TR_CTX_WEB_UI_LABEL,
12
+ labels: {
13
+ heading: PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.heading,
14
+ count: PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.count,
15
+ count_one: PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.countOne,
16
+ empty: definePhiMessageLabel(PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.empty),
17
+ short: definePhiMessageLabel(PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.short),
18
+ idle: definePhiMessageLabel(PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.idle),
19
+ unavailable: definePhiMessageLabel(PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.unavailable),
20
+ region: PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS.region,
21
+ },
22
+ });
23
+ export async function getPhiSearchResultsWidgetLabels(options) {
24
+ const labels = await getPhiLabelSet(options, PHI_SEARCH_RESULTS_WIDGET_LABEL_SET);
25
+ return {
26
+ heading: labels.heading,
27
+ count: labels.count,
28
+ countOne: labels.count_one,
29
+ empty: labels.empty,
30
+ short: labels.short,
31
+ idle: labels.idle,
32
+ unavailable: labels.unavailable,
33
+ region: labels.region,
34
+ };
35
+ }
@@ -74,6 +74,8 @@ export type PhiInspectorRegionVisibilityLabels = {
74
74
  pageOwned: string;
75
75
  /** How far the Page's `content` reaches up into its Hero (`PhiCmsRegionConfig.heroOverlap`). */
76
76
  heroOverlap: string;
77
+ /** `sider_left` opens as a drawer on a phone (`PhiCmsFlags.MobileDrawer`). */
78
+ siderMobileDrawer: string;
77
79
  };
78
80
  export type PhiInspectorLinkTargetLabels = {
79
81
  none: string;
@@ -31,6 +31,7 @@ export const PHI_INSPECTOR_WIDGET_DEFAULT_LABELS = {
31
31
  scrollUp: "When scrolling up",
32
32
  pageOwned: "This Region belongs to its Page and stands on that Page alone.",
33
33
  heroOverlap: "Reaches into the Hero",
34
+ siderMobileDrawer: "On a phone, opens from the menu button",
34
35
  },
35
36
  surfaceStyle: {
36
37
  title: "Style",
@@ -0,0 +1,15 @@
1
+ export type PhiSearchResultsWidgetLabels = {
2
+ /** `%1` is the query. */
3
+ heading: string;
4
+ /** `%1` is how many Pages matched in all. */
5
+ count: string;
6
+ countOne: string;
7
+ /** `%1` is the query. */
8
+ empty: string;
9
+ /** `%1` is how many characters a query needs. */
10
+ short: string;
11
+ idle: string;
12
+ unavailable: string;
13
+ region: string;
14
+ };
15
+ export declare const PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS: PhiSearchResultsWidgetLabels;
@@ -0,0 +1,10 @@
1
+ export const PHI_SEARCH_RESULTS_WIDGET_DEFAULT_LABELS = {
2
+ heading: "Results for “%1”",
3
+ count: "%1 pages",
4
+ countOne: "1 page",
5
+ empty: "Nothing found for “%1”.",
6
+ short: "Type at least %1 characters.",
7
+ idle: "Enter what you are looking for.",
8
+ unavailable: "The search is not available just now.",
9
+ region: "Search results",
10
+ };
@@ -5,6 +5,7 @@ import { isPhiCmsGatewayAuthError } from "../../../gateway/errors";
5
5
  import { fetchSiteNavigationOverlay } from "../../../gateway/site-nav";
6
6
  import { phiRuntime } from "../../../server-helpers/phi-runtime";
7
7
  import { resolvePhiCmsReviewParams } from "../../../server-helpers/cms-review";
8
+ import { protectPhiMailHref } from "../../../helpers/protected-mail";
8
9
  import { resolvePhiDescriptorNavigationItems, } from "../navigation-descriptor-resolver.server";
9
10
  function resolvePhiNavigationRevisionFromRuntime(runtime) {
10
11
  const rawNavRevision = runtime.request?.searchParams?.navRevision?.trim();
@@ -45,5 +46,16 @@ export async function resolvePhiNavigationItems(runtime, navKey) {
45
46
  if (navRevision != null && overlay == null) {
46
47
  return null;
47
48
  }
48
- return (await resolvePhiDescriptorNavigationItems(runtime, navKey, overlay)) ?? [];
49
+ return protectPhiNavMailHrefs((await resolvePhiDescriptorNavigationItems(runtime, navKey, overlay)) ?? []);
50
+ }
51
+ /*
52
+ * An entry that writes to somebody leaves here protected (`helpers/protected-mail.ts`): the items go to
53
+ * the client as props, and a `mailto:` in them stood in the page's payload for any crawler to read.
54
+ */
55
+ function protectPhiNavMailHrefs(items) {
56
+ return items.map((item) => ({
57
+ ...item,
58
+ ...(item.href ? { href: protectPhiMailHref(item.href) } : {}),
59
+ ...(item.children ? { children: protectPhiNavMailHrefs(item.children) } : {}),
60
+ }));
49
61
  }
@@ -55,6 +55,8 @@ export type PhiCardWidgetImage = {
55
55
  export type PhiCardWidgetClientConfig = {
56
56
  surface?: PhiSurface | null;
57
57
  image?: PhiCardWidgetImage | null;
58
+ /** The picture's box as CSS (`3 / 2`) where the card states one; absent, the variant's or the file's. */
59
+ mediaAspectRatio?: string | null;
58
60
  iconName?: string;
59
61
  iconPlacement?: PhiCardIconPlacement;
60
62
  /** The icon's colour and its ground; absent, the Theme's. */
@@ -20,7 +20,7 @@ import { resolvePhiSurfaceStyle } from "../../../helpers/surface-style";
20
20
  import { usePhiControlSignalController } from "../client/shared/phi-control-signals";
21
21
  import { PHI_COLOR, PHI_SPACE } from "../../../theme/antd-css-var-contract";
22
22
  import { PHI_THEME_HEADING_FONT_VARIABLE } from "../../../theme/phi-theme-typography";
23
- import { PHI_CARD_TEXT_SLOTS, readPhiCardBillingPeriod } from "./card-vocabulary";
23
+ import { PHI_CARD_IMAGE_SIZES, PHI_CARD_TEXT_SLOTS, readPhiCardBillingPeriod } from "./card-vocabulary";
24
24
  /**
25
25
  * The layer over a card's picture. A colour or a gradient is drawn as CSS, each colour mixed down to the
26
26
  * Overlay's opacity, so a Theme variable (`var(--ant-color-bg-container)`) resolves and the picture fades
@@ -282,9 +282,9 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
282
282
  const headingRow = iconPlacement === "inline" && iconName ? (_jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: justify, gap, ...slotWidth }, children: [iconMark(iconSize, inlineIconFrame), heading] })) : heading;
283
283
  const media = image ? (_jsxs("div", { className: "phi-card__media", style: {
284
284
  position: "relative",
285
- aspectRatio: metrics.mediaAspectRatio ?? resolveMediaAspectRatio(image.presentation),
285
+ aspectRatio: config?.mediaAspectRatio ?? metrics.mediaAspectRatio ?? resolveMediaAspectRatio(image.presentation),
286
286
  overflow: "hidden",
287
- }, children: [_jsx(PhiImageControl, { presentation: image.presentation, source: image.source, alt: image.alt, blurDataUrl: image.blurDataUrl, optimizable: image.optimizable, style: { width: "100%", height: "100%" }, imageStyle: {
287
+ }, children: [_jsx(PhiImageControl, { presentation: image.presentation, source: image.source, alt: image.alt, blurDataUrl: image.blurDataUrl, optimizable: image.optimizable, sizes: PHI_CARD_IMAGE_SIZES, style: { width: "100%", height: "100%" }, imageStyle: {
288
288
  width: "100%",
289
289
  height: "100%",
290
290
  ...(image.opacity == null || image.opacity >= 1 ? {} : { opacity: image.opacity }),
@@ -336,11 +336,12 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
336
336
  ...(highlight ? { "--phi-card-highlight-color": PHI_COLOR.primary } : {}),
337
337
  };
338
338
  /*
339
- * A plan's button stands at the card's foot: plans side by side in a row have lists of different
340
- * lengths, and their buttons belong on one line. The words keep their grid; the grid and the button
341
- * stand in a column that fills the card, and the button takes what is left above it.
339
+ * The button stands at the card's foot, whatever the body: cards side by side in a Grid row are one
340
+ * height, their words are not, and their buttons belong on one line. The words keep their grid; the
341
+ * grid and the button stand in a column that fills the card, and the button takes what is left above
342
+ * it. A card standing alone is as tall as its content, so there the foot is right under the words.
342
343
  */
343
- const footAction = body === "plan" && action != null;
344
+ const footAction = action != null;
344
345
  const actionButton = action ? (_jsx("div", { className: "phi-card__action",
345
346
  /* At the foot, it stands where the words' alignment puts it, as it does among them. */
346
347
  style: footAction ? { marginTop: "auto", alignSelf: textAlign === "center" ? "center" : textAlign === "end" ? "flex-end" : "flex-start" } : undefined, children: _jsx(PhiButtonControl, { ...(action.variant
@@ -70,6 +70,42 @@ export type PhiCardHoverEffect = (typeof PHI_CARD_HOVER_EFFECTS)[number];
70
70
  */
71
71
  export declare const PHI_CARD_VARIANTS: readonly ["default", "compact", "center"];
72
72
  export type PhiCardVariant = (typeof PHI_CARD_VARIANTS)[number];
73
+ /**
74
+ * How tall a card's picture stands, as a proportion of its width.
75
+ *
76
+ * `auto` is the proportion of the file the card shows. A Media picture that names no variant is shown as
77
+ * the Media library's Card variant (3:2, cropped around the picture's focal rectangle), so cards side by
78
+ * side stand at one height without anybody choosing one, and the browser gets a file sized for a card
79
+ * rather than the original. A picture that names a variant shows that variant and its proportion; one
80
+ * given by address, its own. `original` is the escape: the Media picture's original file, uncropped.
81
+ *
82
+ * `phi` is the golden rectangle, φ : 1 (`PHI_GOLDEN_RATIO`), between 3:2 and 16:9.
83
+ *
84
+ * A step crops whatever file the card shows into that box around the focal rectangle. 3:2 is the Card
85
+ * variant's own proportion, so it keeps taking that file; every other step shows the original, which the
86
+ * image optimiser scales to the card's width.
87
+ */
88
+ export declare const PHI_CARD_MEDIA_ASPECT_RATIOS: readonly ["auto", "original", "phi", "3:2", "4:3", "16:9", "2:1", "1:1"];
89
+ export type PhiCardMediaAspectRatio = (typeof PHI_CARD_MEDIA_ASPECT_RATIOS)[number];
90
+ /** A step as a number, width over height; `auto` and `original` have none -- the file decides. */
91
+ export declare function resolvePhiCardMediaAspectRatioValue(ratio: PhiCardMediaAspectRatio | undefined): number | null;
92
+ /** A step as CSS writes it (`3 / 2`); `auto` and `original` have none. */
93
+ export declare function resolvePhiCardMediaAspectRatioCss(ratio: PhiCardMediaAspectRatio | undefined): string | null;
94
+ /**
95
+ * Which variant of a Media picture the card shows: the one the card names, else the Card variant where the
96
+ * box is the Card variant's own proportion (`auto`, `3:2`), else the original.
97
+ */
98
+ export declare function resolvePhiCardImageVariantKey({ sourceKind, variantKey, mediaAspectRatio, }: {
99
+ sourceKind: string | undefined;
100
+ variantKey: number | null | undefined;
101
+ mediaAspectRatio: PhiCardMediaAspectRatio | undefined;
102
+ }): number | null;
103
+ /**
104
+ * How wide a card's picture is drawn, for the image optimiser: the window's width on a phone, where cards
105
+ * stand one under the other, and at most half of it beside another card. Without it the optimiser takes
106
+ * the file's own width -- a 1920 px original for a 350 px card.
107
+ */
108
+ export declare const PHI_CARD_IMAGE_SIZES = "(max-width: 768px) 100vw, 50vw";
73
109
  /**
74
110
  * The words a card shows, each in its own place; what an editor can put a field in, and what a signal can
75
111
  * write. `badge` is the band at the card's end edge, any body may carry one. The prices are figures like
@@ -2,6 +2,8 @@
2
2
  * The Card Widget's words, apart from its Client half: the Widget's definition is read on the server, and
3
3
  * a value imported from the Client file would make that file a client reference of every route.
4
4
  */
5
+ import { PhiImageAssetVariantKey } from "../../../constants/media";
6
+ import { PHI_GOLDEN_RATIO } from "../../../theme/phi-tokens";
5
7
  /**
6
8
  * Which of a plan card's two prices it shows. A plan states one, the other, or both; one that states
7
9
  * only the monthly price shows it under `yearly` as well, so a period switch on the page never leaves a
@@ -52,6 +54,56 @@ export const PHI_CARD_HOVER_EFFECTS = ["none", "lift", "zoom", "icon"];
52
54
  * not another branch in every size the card draws. `default` is what a card without one is.
53
55
  */
54
56
  export const PHI_CARD_VARIANTS = ["default", "compact", "center"];
57
+ /**
58
+ * How tall a card's picture stands, as a proportion of its width.
59
+ *
60
+ * `auto` is the proportion of the file the card shows. A Media picture that names no variant is shown as
61
+ * the Media library's Card variant (3:2, cropped around the picture's focal rectangle), so cards side by
62
+ * side stand at one height without anybody choosing one, and the browser gets a file sized for a card
63
+ * rather than the original. A picture that names a variant shows that variant and its proportion; one
64
+ * given by address, its own. `original` is the escape: the Media picture's original file, uncropped.
65
+ *
66
+ * `phi` is the golden rectangle, φ : 1 (`PHI_GOLDEN_RATIO`), between 3:2 and 16:9.
67
+ *
68
+ * A step crops whatever file the card shows into that box around the focal rectangle. 3:2 is the Card
69
+ * variant's own proportion, so it keeps taking that file; every other step shows the original, which the
70
+ * image optimiser scales to the card's width.
71
+ */
72
+ export const PHI_CARD_MEDIA_ASPECT_RATIOS = ["auto", "original", "phi", "3:2", "4:3", "16:9", "2:1", "1:1"];
73
+ /** A step as a number, width over height; `auto` and `original` have none -- the file decides. */
74
+ export function resolvePhiCardMediaAspectRatioValue(ratio) {
75
+ if (ratio == null || ratio === "auto" || ratio === "original")
76
+ return null;
77
+ if (ratio === "phi")
78
+ return PHI_GOLDEN_RATIO;
79
+ const [width, height] = ratio.split(":").map(Number);
80
+ return width / height;
81
+ }
82
+ /** A step as CSS writes it (`3 / 2`); `auto` and `original` have none. */
83
+ export function resolvePhiCardMediaAspectRatioCss(ratio) {
84
+ if (ratio == null || ratio === "auto" || ratio === "original")
85
+ return null;
86
+ return ratio === "phi" ? `${PHI_GOLDEN_RATIO.toFixed(6)} / 1` : ratio.replace(":", " / ");
87
+ }
88
+ /**
89
+ * Which variant of a Media picture the card shows: the one the card names, else the Card variant where the
90
+ * box is the Card variant's own proportion (`auto`, `3:2`), else the original.
91
+ */
92
+ export function resolvePhiCardImageVariantKey({ sourceKind, variantKey, mediaAspectRatio, }) {
93
+ if (sourceKind !== "asset")
94
+ return null;
95
+ if (variantKey != null)
96
+ return variantKey;
97
+ return mediaAspectRatio == null || mediaAspectRatio === "auto" || mediaAspectRatio === "3:2"
98
+ ? PhiImageAssetVariantKey.Card
99
+ : null;
100
+ }
101
+ /**
102
+ * How wide a card's picture is drawn, for the image optimiser: the window's width on a phone, where cards
103
+ * stand one under the other, and at most half of it beside another card. Without it the optimiser takes
104
+ * the file's own width -- a 1920 px original for a 350 px card.
105
+ */
106
+ export const PHI_CARD_IMAGE_SIZES = "(max-width: 768px) 100vw, 50vw";
55
107
  /**
56
108
  * The words a card shows, each in its own place; what an editor can put a field in, and what a signal can
57
109
  * write. `badge` is the band at the card's end edge, any body may carry one. The prices are figures like
@@ -3,10 +3,18 @@ import type { PhiCodeToken } from "./markdown-code-tokens";
3
3
  import type { PhiMarkdownImageFloat, PhiMarkdownTextAlign } from "../../../types/core-widget-placements";
4
4
  import { type PhiSpacingScaleKey } from "../config/spacing-options";
5
5
  import type { PhiMarkdownTocHeading } from "../../../types/markdown";
6
+ import { type PhiMarkdownFoldSections } from "./markdown-sections";
7
+ import type { PhiImagePresentation } from "../../media/image-presentation";
8
+ import { type PhiMarkdownFigureFloat } from "./markdown-image-vocabulary";
6
9
  import { type PhiBulletListStyle } from "./bullet-list-vocabulary";
7
10
  export type PhiMarkdownInline = {
8
11
  kind: "text";
9
12
  text: string;
13
+ }
14
+ /** An address in the text, protected (`helpers/protected-mail.ts`) and written in once mounted. */
15
+ | {
16
+ kind: "mail_text";
17
+ token: string;
10
18
  } | {
11
19
  kind: "strong";
12
20
  children: PhiMarkdownInline[];
@@ -33,6 +41,20 @@ export type PhiMarkdownInline = {
33
41
  kind: "break";
34
42
  };
35
43
  export type PhiMarkdownTableAlign = "left" | "center" | "right" | null;
44
+ /**
45
+ * A Media picture standing on its own in the text, resolved on the server (`markdown-render.ts`): which
46
+ * bytes and how they are framed, the box it stands in, and where it stands.
47
+ */
48
+ export type PhiMarkdownFigure = {
49
+ presentation: PhiImagePresentation;
50
+ alt: string;
51
+ title?: string;
52
+ blurDataUrl: string | null;
53
+ optimizable: boolean;
54
+ /** The box as CSS (`16 / 9`) where a step was chosen; `null` is the picture's own proportion. */
55
+ aspectRatio: string | null;
56
+ float: PhiMarkdownFigureFloat;
57
+ };
36
58
  export type PhiMarkdownBlock = {
37
59
  kind: "heading";
38
60
  id: string;
@@ -67,6 +89,9 @@ export type PhiMarkdownBlock = {
67
89
  align: PhiMarkdownTableAlign[];
68
90
  } | {
69
91
  kind: "divider";
92
+ } | {
93
+ kind: "image";
94
+ image: PhiMarkdownFigure;
70
95
  };
71
96
  export type PhiMarkdownWidgetClientProps = PhiClientBlockBaseProps<PhiNoLabels, {
72
97
  blocks: PhiMarkdownBlock[];
@@ -82,5 +107,9 @@ export type PhiMarkdownWidgetClientProps = PhiClientBlockBaseProps<PhiNoLabels,
82
107
  headingBlockSpacingAfter?: PhiSpacingScaleKey;
83
108
  /** How the text's lists are set (`bullet-list-vocabulary.ts`). */
84
109
  list?: PhiBulletListStyle;
110
+ /** Whether the text's `##` sections fold (`markdown-sections.ts`); absent, `none`. */
111
+ foldSections?: PhiMarkdownFoldSections;
112
+ /** How far the text's headings moved down, which moves the level that folds with them. */
113
+ headingOffset?: number;
85
114
  }>;
86
115
  export declare function PhiMarkdownWidgetClient({ config }: PhiMarkdownWidgetClientProps): import("react").JSX.Element | null;