@phis/ui 0.4.5 → 0.4.6

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 (78) 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/layouts/clients/phi-split-card-layout-client.js +13 -5
  13. package/components/layouts/clients/phi-three-column-layout-client.js +9 -3
  14. package/components/layouts/split-card-geometry.js +6 -2
  15. package/components/media/aspect-ratios.d.ts +2 -2
  16. package/components/menus/phi-account-menu.js +3 -1
  17. package/components/navigation/phi-link.js +7 -2
  18. package/components/navigation/use-phi-protected-mail.d.ts +11 -0
  19. package/components/navigation/use-phi-protected-mail.js +29 -0
  20. package/components/regions/clients/cms-region-container-client.js +5 -1
  21. package/components/regions/phi-cms-region-shell.d.ts +1 -0
  22. package/components/regions/phi-cms-region-shell.js +11 -0
  23. package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
  24. package/components/root/phi-config-provider.js +16 -0
  25. package/components/shell/phi-cms-shell.d.ts +3 -1
  26. package/components/shell/phi-cms-shell.js +7 -3
  27. package/components/shell/phi-nav-link.js +7 -2
  28. package/components/shell/phi-shell-sider-drawer.d.ts +17 -0
  29. package/components/shell/phi-shell-sider-drawer.js +88 -0
  30. package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -0
  31. package/components/widgets/helpers/internal-reference-resolver.server.js +4 -1
  32. package/components/widgets/label-sets/inspector.js +2 -0
  33. package/components/widgets/label-types/inspector.d.ts +2 -0
  34. package/components/widgets/label-types/inspector.js +1 -0
  35. package/components/widgets/server/navigation-request.js +13 -1
  36. package/components/widgets/shared/card-body-client.d.ts +2 -0
  37. package/components/widgets/shared/card-body-client.js +8 -7
  38. package/components/widgets/shared/card-vocabulary.d.ts +36 -0
  39. package/components/widgets/shared/card-vocabulary.js +52 -0
  40. package/components/widgets/shared/markdown-body-client.d.ts +29 -0
  41. package/components/widgets/shared/markdown-body-client.js +60 -5
  42. package/components/widgets/shared/markdown-image-vocabulary.d.ts +31 -0
  43. package/components/widgets/shared/markdown-image-vocabulary.js +68 -0
  44. package/components/widgets/shared/markdown-render.d.ts +5 -0
  45. package/components/widgets/shared/markdown-render.js +123 -8
  46. package/components/widgets/shared/markdown-sections.d.ts +40 -0
  47. package/components/widgets/shared/markdown-sections.js +111 -0
  48. package/helpers/external-href.js +1 -1
  49. package/helpers/protected-mail.d.ts +16 -0
  50. package/helpers/protected-mail.js +81 -0
  51. package/package.json +2 -2
  52. package/plugins/runtime-modules/builder/clients/region-inspector.js +20 -1
  53. package/plugins/runtime-modules/core/widgets/card/config.d.ts +8 -1
  54. package/plugins/runtime-modules/core/widgets/card/config.js +22 -1
  55. package/plugins/runtime-modules/core/widgets/card/editor.js +9 -1
  56. package/plugins/runtime-modules/core/widgets/card/server.js +9 -1
  57. package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +2 -1
  58. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +3 -3
  59. package/plugins/runtime-modules/core/widgets/header-navigation/client.d.ts +6 -1
  60. package/plugins/runtime-modules/core/widgets/header-navigation/client.js +40 -13
  61. package/plugins/runtime-modules/core/widgets/header-navigation/config.d.ts +26 -1
  62. package/plugins/runtime-modules/core/widgets/header-navigation/config.js +27 -0
  63. package/plugins/runtime-modules/core/widgets/header-navigation/plugin.js +1 -1
  64. package/plugins/runtime-modules/core/widgets/header-navigation/server.d.ts +2 -2
  65. package/plugins/runtime-modules/core/widgets/header-navigation/server.js +3 -1
  66. package/plugins/runtime-modules/core/widgets/image/client.js +11 -7
  67. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -0
  68. package/plugins/runtime-modules/core/widgets/markdown/config.js +46 -1
  69. package/plugins/runtime-modules/core/widgets/markdown/server.js +22 -8
  70. package/plugins/runtime-modules/core/widgets/simple-text/server.js +11 -1
  71. package/styles/controls.css +108 -10
  72. package/styles/layout.css +35 -0
  73. package/styles/shell.css +142 -0
  74. package/theme/phi-tokens.d.ts +6 -0
  75. package/theme/phi-tokens.js +6 -0
  76. package/theme.d.ts +1 -0
  77. package/theme.js +6 -0
  78. package/types/core-widget-placements.d.ts +5 -0
@@ -11,7 +11,8 @@ function inlineText(inlines) {
11
11
  return inline.text;
12
12
  if (inline.kind === "break")
13
13
  return " ";
14
- if (inline.kind === "image")
14
+ // A teaser is plain text, so a protected address (`helpers/protected-mail.ts`) is left out of it.
15
+ if (inline.kind === "image" || inline.kind === "mail_text")
15
16
  return "";
16
17
  return inlineText(inline.children);
17
18
  }).join("");
@@ -338,8 +338,8 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
338
338
  type: "choice";
339
339
  label: string;
340
340
  options: {
341
- value: "16:9" | "3:2" | "4:3" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
342
- label: "16:9" | "3:2" | "4:3" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
341
+ value: "3:2" | "4:3" | "16:9" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
342
+ label: "3:2" | "4:3" | "16:9" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
343
343
  }[];
344
344
  visibleWhen: {
345
345
  field: string;
@@ -362,7 +362,7 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
362
362
  params: {};
363
363
  };
364
364
  preview: false;
365
- aspectRatio: "16:9" | "3:2" | "4:3" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
365
+ aspectRatio: "3:2" | "4:3" | "16:9" | "1:1" | "3:4" | "2:3" | "9:16" | "21:9";
366
366
  fit: "cover";
367
367
  };
368
368
  parseConfig: typeof parsePhiCmsGalleryWidgetConfig;
@@ -1,12 +1,17 @@
1
1
  import type { CSSProperties } from "react";
2
+ import type { PhiMenuSelectionStyle } from "../../../../../components/controls/phi-menu-control-vocabulary";
2
3
  import type { PhiClientBlockBaseProps, PhiBlockRuntime, PhiNoLabels } from "../../../../../types";
3
4
  import { type PhiMenuTheme, type PhiNavItem } from "../../../../../components/shell/shell-types";
5
+ import type { PhiHeaderNavigationPhoneMenu } from "./config";
4
6
  export type PhiHeaderNavigationWidgetClientProps = PhiClientBlockBaseProps<PhiNoLabels, Record<string, never>, Pick<PhiBlockRuntime, "site" | "locale" | "area">> & {
5
7
  runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area">;
6
8
  items: PhiNavItem[];
7
9
  menuTheme?: PhiMenuTheme;
8
10
  height?: CSSProperties["height"];
9
11
  align?: "left" | "center";
12
+ selectionStyle?: PhiMenuSelectionStyle;
13
+ /** Below 768px: the entries behind a menu button (the default), or the row as on a wider screen. */
14
+ phoneMenu?: PhiHeaderNavigationPhoneMenu;
10
15
  interactive?: boolean;
11
16
  };
12
- export declare function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align, interactive, }: PhiHeaderNavigationWidgetClientProps): import("react").JSX.Element | null;
17
+ export declare function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align, selectionStyle, phoneMenu, interactive, }: PhiHeaderNavigationWidgetClientProps): import("react").JSX.Element | null;
@@ -1,18 +1,34 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useState } from "react";
3
4
  import { collectPhiSelectedNavKeys } from "../../../../../helpers/nav-selection";
4
5
  import { PhiMenuControl } from "../../../../../components/controls/phi-menu-control";
5
6
  import { usePhiConfig } from "../../../../../components/root/phi-config-provider";
6
7
  import { mapPhiNavItems } from "../../../../../components/shell/menu-items";
7
8
  import {} from "../../../../../components/shell/shell-types";
8
9
  import { usePhiPathname } from "../../../../../components/runtime/use-phi-pathname";
9
- export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align = "left", interactive = true, }) {
10
+ import { PhiButtonControl } from "../../../../../components/controls/phi-button-control";
11
+ import { PhiDialogControl } from "../../../../../components/controls/phi-dialog-control";
12
+ import { PhiIcon } from "../../../../../components/shell/phi-icon";
13
+ export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, height, align = "left", selectionStyle = "auto", phoneMenu = "button", interactive = true, }) {
10
14
  const { token } = usePhiConfig();
11
15
  const pathname = usePhiPathname();
12
16
  const availableLocales = runtime.site.availableLocales.map((option) => option.code);
13
17
  const selectedKeys = collectPhiSelectedNavKeys(pathname, items, availableLocales);
14
18
  const menuItems = mapPhiNavItems(runtime.locale.current, runtime.area, pathname, items, availableLocales, { interactive });
15
19
  const resolvedHeight = typeof height === "number" ? `${height}px` : (height ?? "100%");
20
+ /*
21
+ * The Page the Drawer was opened on: following an entry to another Page closes it without an effect
22
+ * having to notice the navigation (the Shell's Sider drawer does the same).
23
+ */
24
+ const [openedOn, setOpenedOn] = useState(null);
25
+ const drawerOpen = openedOn != null && openedOn === pathname;
26
+ const closeDrawer = useCallback(() => setOpenedOn(null), []);
27
+ // An entry chosen in the Drawer is where the reader is going, the Page they are on included.
28
+ const closeOnLink = useCallback((event) => {
29
+ if (event.target instanceof Element && event.target.closest("a[href]"))
30
+ closeDrawer();
31
+ }, [closeDrawer]);
16
32
  if (menuItems.length === 0) {
17
33
  return null;
18
34
  }
@@ -37,7 +53,12 @@ export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, hei
37
53
  textDecoration: "none",
38
54
  }, children: item.label }, item.key))) }));
39
55
  }
40
- return (_jsx("div", { style: {
56
+ return (_jsxs("div", {
57
+ /*
58
+ * Both forms are drawn and `styles/shell.css` shows one: whether this is a phone is the Shell's
59
+ * container width, which a Widget's own box cannot answer. The row is the wider screen's.
60
+ */
61
+ className: phoneMenu === "button" ? "phi-header-nav phi-header-nav--phone-button" : "phi-header-nav", style: {
41
62
  display: "flex",
42
63
  alignItems: "stretch",
43
64
  width: "100%",
@@ -46,14 +67,20 @@ export function PhiHeaderNavigationWidgetClient({ runtime, items, menuTheme, hei
46
67
  minHeight: 0,
47
68
  flex: 1,
48
69
  justifyContent: align === "center" ? "center" : "flex-start",
49
- }, children: _jsx(PhiMenuControl, { mode: "horizontal", menuTheme: menuTheme, selectedKeys: selectedKeys, items: menuItems, fontSize: token.fontSize, style: {
50
- display: "flex",
51
- alignItems: "center",
52
- justifyContent: align === "center" ? "center" : "flex-start",
53
- minHeight: 0,
54
- flex: "1 1 auto",
55
- paddingInline: 0,
56
- height: resolvedHeight,
57
- lineHeight: resolvedHeight,
58
- } }) }));
70
+ }, children: [phoneMenu === "button" ? (_jsxs("span", { className: "phi-header-nav__button", children: [_jsx(PhiButtonControl, { type: "text", ariaLabel: "Open navigation", ariaExpanded: drawerOpen, icon: _jsx(PhiIcon, { name: "menu", size: "inherit" }), onClick: () => setOpenedOn(pathname) }), _jsx(PhiDialogControl, { open: drawerOpen, presentation: "drawer", placement: "right", size: "min(20rem, 85vw)", onDismiss: closeDrawer, children: _jsx("nav", { "aria-label": "Navigation", onClickCapture: closeOnLink, children: _jsx(PhiMenuControl, { mode: "inline", menuTheme: menuTheme, selectionStyle: selectionStyle, selectedKeys: selectedKeys, items: menuItems, fontSize: token.fontSize, style: { borderInlineEnd: "none" } }) }) })] })) : null, _jsx("div", { className: "phi-header-nav__row", style: {
71
+ display: "flex",
72
+ alignItems: "stretch",
73
+ flex: "1 1 auto",
74
+ minWidth: 0,
75
+ justifyContent: align === "center" ? "center" : "flex-start",
76
+ }, children: _jsx(PhiMenuControl, { mode: "horizontal", menuTheme: menuTheme, selectionStyle: selectionStyle, selectedKeys: selectedKeys, items: menuItems, fontSize: token.fontSize, style: {
77
+ display: "flex",
78
+ alignItems: "center",
79
+ justifyContent: align === "center" ? "center" : "flex-start",
80
+ minHeight: 0,
81
+ flex: "1 1 auto",
82
+ paddingInline: 0,
83
+ height: resolvedHeight,
84
+ lineHeight: resolvedHeight,
85
+ } }) })] }));
59
86
  }
@@ -1,11 +1,20 @@
1
1
  import type { CSSProperties } from "react";
2
+ import { type PhiMenuSelectionStyle } from "../../../../../components/controls/phi-menu-control-vocabulary";
2
3
  import { type PhiCmsWidgetConfigBase } from "../../../../../components/widgets/config/parser-primitives";
3
4
  export type PhiCmsHeaderNavigationWidgetConfig = PhiCmsWidgetConfigBase & {
4
5
  navKey?: string;
5
6
  align?: "left" | "center";
7
+ /** How the current entry is marked (`PHI_MENU_SELECTION_STYLES`); absent is `auto`. */
8
+ selectionStyle?: PhiMenuSelectionStyle;
9
+ /**
10
+ * How the entries stand on a phone (below 768px): behind a menu button that opens them in a Drawer, the
11
+ * default, or in the row as on a wider screen, where what does not fit folds into "…".
12
+ */
13
+ phoneMenu?: PhiHeaderNavigationPhoneMenu;
6
14
  };
15
+ export type PhiHeaderNavigationPhoneMenu = "button" | "row";
7
16
  declare function parsePhiCmsHeaderNavigationWidgetConfig(config: Record<string, unknown>): PhiCmsHeaderNavigationWidgetConfig;
8
- export type PhiHeaderNavigationWidgetRenderableConfig = Pick<PhiCmsHeaderNavigationWidgetConfig, "align"> & {
17
+ export type PhiHeaderNavigationWidgetRenderableConfig = Pick<PhiCmsHeaderNavigationWidgetConfig, "align" | "selectionStyle" | "phoneMenu"> & {
9
18
  height?: CSSProperties["height"];
10
19
  };
11
20
  export declare const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION: {
@@ -17,6 +26,11 @@ export declare const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION: {
17
26
  category: "navigation";
18
27
  iconFamily: string;
19
28
  slotSizePolicy: "fill";
29
+ defaultConfig: {
30
+ align: "left";
31
+ selectionStyle: "auto";
32
+ phoneMenu: "button";
33
+ };
20
34
  fields: ({
21
35
  key: string;
22
36
  type: "choice";
@@ -46,6 +60,17 @@ export declare const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION: {
46
60
  presentation?: undefined;
47
61
  optionsProvider?: undefined;
48
62
  placeholder?: undefined;
63
+ } | {
64
+ key: string;
65
+ type: "choice";
66
+ label: string;
67
+ presentation: "segmented";
68
+ options: {
69
+ value: string;
70
+ label: string;
71
+ }[];
72
+ optionsProvider?: undefined;
73
+ placeholder?: undefined;
49
74
  })[];
50
75
  parseConfig: typeof parsePhiCmsHeaderNavigationWidgetConfig;
51
76
  };
@@ -1,12 +1,15 @@
1
1
  import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
2
2
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
3
3
  import { PHI_AUTHORING_OPTION_PROVIDER_KEYS } from "../../../../../constants/authoring-option-provider-keys";
4
+ import { PHI_MENU_SELECTION_STYLES, } from "../../../../../components/controls/phi-menu-control-vocabulary";
4
5
  import { readRenderableBlockConfig, readString, } from "../../../../../components/widgets/config/parser-primitives";
5
6
  function parsePhiCmsHeaderNavigationWidgetConfig(config) {
6
7
  return {
7
8
  ...readRenderableBlockConfig(config),
8
9
  navKey: readString(config.navKey),
9
10
  align: readString(config.align) === "center" ? "center" : "left",
11
+ selectionStyle: PHI_MENU_SELECTION_STYLES.find((style) => style === readString(config.selectionStyle)),
12
+ phoneMenu: readString(config.phoneMenu) === "row" ? "row" : "button",
10
13
  };
11
14
  }
12
15
  export const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION = {
@@ -18,6 +21,8 @@ export const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION = {
18
21
  category: "navigation",
19
22
  iconFamily: "navigation",
20
23
  slotSizePolicy: "fill",
24
+ /* What the Inspector shows chosen where a header states nothing, and what an absent value renders as. */
25
+ defaultConfig: { align: "left", selectionStyle: "auto", phoneMenu: "button" },
21
26
  fields: [
22
27
  {
23
28
  key: "navKey",
@@ -43,6 +48,28 @@ export const PHI_HEADER_NAVIGATION_WIDGET_DEFINITION = {
43
48
  { value: "center", label: "Center" },
44
49
  ],
45
50
  },
51
+ /* Automatic is a bar in light mode and a rounded ground in dark mode, where a bar is hard to see. */
52
+ {
53
+ key: "selectionStyle",
54
+ type: "choice",
55
+ label: "Current entry",
56
+ presentation: "segmented",
57
+ options: [
58
+ { value: "auto", label: "Automatic" },
59
+ { value: "underline", label: "Underline" },
60
+ { value: "pill", label: "Pill" },
61
+ ],
62
+ },
63
+ {
64
+ key: "phoneMenu",
65
+ type: "choice",
66
+ label: "On a phone",
67
+ presentation: "segmented",
68
+ options: [
69
+ { value: "button", label: "Menu button" },
70
+ { value: "row", label: "Row" },
71
+ ],
72
+ },
46
73
  ],
47
74
  parseConfig: parsePhiCmsHeaderNavigationWidgetConfig,
48
75
  };
@@ -4,7 +4,7 @@ import { PhiHeaderNavigationWidget } from "./server";
4
4
  import { resolvePhiRenderableBlockGeometry } from "../../../../../types/renderable-block-geometry";
5
5
  export const PHI_HEADER_NAVIGATION_WIDGET_PLUGIN = {
6
6
  ...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, interactive: true }, `widget-${widget.id}`)),
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
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}`)),
9
9
  };
10
10
  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" | "interactive"> & {
3
+ export type PhiHeaderNavigationWidgetProps = Pick<PhiHeaderNavigationWidgetClientProps, "menuTheme" | "height" | "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, interactive, }: PhiHeaderNavigationWidgetProps): Promise<import("react").JSX.Element | null>;
7
+ export declare function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, 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, interactive = true, }) {
5
+ export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, height, 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;
@@ -13,6 +13,8 @@ export async function PhiHeaderNavigationWidget({ runtime, navKey, menuTheme, he
13
13
  menuTheme,
14
14
  height,
15
15
  align,
16
+ selectionStyle,
17
+ phoneMenu,
16
18
  interactive,
17
19
  } }));
18
20
  }
@@ -8,6 +8,7 @@ import { PhiEmptyControl } from "../../../../../components/controls/phi-empty-co
8
8
  import { PhiImageControl } from "../../../../../components/controls/phi-image-control";
9
9
  import { PhiFlexControl } from "../../../../../components/controls/phi-flex-control";
10
10
  import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
11
+ import { PHI_LAYOUT_SURFACE_RADIUS } from "../../../../../components/layouts/phi-layout-contract";
11
12
  function formatImageSize(value) {
12
13
  if (typeof value === "number" && Number.isFinite(value)) {
13
14
  return `${value}px`;
@@ -68,11 +69,15 @@ export function PhiImageWidget({ labels, config, resolvedAsset, focalRect, autho
68
69
  const renderedWidth = formatImageSize(width);
69
70
  const renderedHeight = formatImageSize(height);
70
71
  const maskStyle = resolvePhiMaskStyle(config?.mask);
72
+ /*
73
+ * A picture is a surface: a corner the author left unstated is the Theme's surface step, as a Layout's
74
+ * and a Markdown picture's are (THEME.md "Control shape"); a corner the author stated keeps its value.
75
+ */
71
76
  const radiusStyle = {
72
- borderTopLeftRadius: config?.borderTopLeftRadius,
73
- borderTopRightRadius: config?.borderTopRightRadius,
74
- borderBottomLeftRadius: config?.borderBottomLeftRadius,
75
- borderBottomRightRadius: config?.borderBottomRightRadius,
77
+ borderTopLeftRadius: config?.borderTopLeftRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
78
+ borderTopRightRadius: config?.borderTopRightRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
79
+ borderBottomLeftRadius: config?.borderBottomLeftRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
80
+ borderBottomRightRadius: config?.borderBottomRightRadius ?? PHI_LAYOUT_SURFACE_RADIUS,
76
81
  };
77
82
  if (!renderUrl) {
78
83
  return (_jsxs(PhiFlexControl, { align: "center", justify: "center", vertical: true, gap: 6, style: {
@@ -90,8 +95,7 @@ export function PhiImageWidget({ labels, config, resolvedAsset, focalRect, autho
90
95
  return (_jsx(PhiImageControl, { presentation: presentation, source: sourceKind === "asset" ? "asset" : config?.trusted === true ? "trusted-url" : "url", alt: alt, title: title || undefined, width: width, height: height, blurDataUrl: resolvedAsset?.blurDataUrl, optimizable: optimizable, sizes: config?.sizes, preload: config?.preload === true && isPublicAsset, preview: (config?.previewMode ?? "none") === "lightbox", zoom: config?.previewMode === "native", style: {
91
96
  ...radiusStyle,
92
97
  ...maskStyle,
93
- overflow: presentation.simulatedCropStyle || Object.values(radiusStyle).some((value) => value != null)
94
- ? "hidden"
95
- : undefined,
98
+ // Every corner has a radius now, the Theme's at least, so the box always clips its picture.
99
+ overflow: "hidden",
96
100
  }, imageStyle: radiusStyle }));
97
101
  }
@@ -1,4 +1,6 @@
1
1
  import type { PhiMarkdownImageFloat, PhiMarkdownTextAlign } from "../../../../../types/core-widget-placements";
2
+ import { type PhiMarkdownFoldSections } from "../../../../../components/widgets/shared/markdown-sections";
3
+ import { type PhiMarkdownImageAspectRatio } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
2
4
  import { type PhiSpacingScaleKey } from "../../../../../components/widgets/config/spacing-options";
3
5
  import type { PhiCmsResolvedContent } from "../../../../../types/cms";
4
6
  import { type PhiBulletListStyle } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
@@ -15,6 +17,18 @@ export type PhiCmsMarkdownWidgetConfig = PhiCmsWidgetConfigBase & {
15
17
  textAlign?: PhiMarkdownTextAlign;
16
18
  /** Pictures stand at this edge and the text flows past them; absent, a picture is a line of its own. */
17
19
  imageFloat?: PhiMarkdownImageFloat;
20
+ /**
21
+ * How tall every Media picture standing on its own in the text is (`markdown-image-vocabulary.ts`);
22
+ * absent is `auto`, the picture's own proportion. A picture's own address may say otherwise.
23
+ */
24
+ imageAspectRatio?: PhiMarkdownImageAspectRatio;
25
+ /**
26
+ * Whether every `##` section folds under its heading -- each on its own or one at a time
27
+ * (`markdown-sections.ts`) -- the way a page of questions and answers reads; absent, `none`.
28
+ */
29
+ foldSections?: PhiMarkdownFoldSections;
30
+ /** With folding sections: state them as schema.org `FAQPage` data for search engines. */
31
+ faqStructuredData?: boolean;
18
32
  textBlockSpacingBefore?: PhiSpacingScaleKey;
19
33
  textBlockSpacingAfter?: PhiSpacingScaleKey;
20
34
  headingBlockSpacingBefore?: PhiSpacingScaleKey;
@@ -41,6 +55,8 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
41
55
  slotSizePolicy: "fill-inline";
42
56
  defaultConfig: {
43
57
  revalidateSeconds: number;
58
+ imageAspectRatio: "auto";
59
+ foldSections: "none";
44
60
  textAlign: "start";
45
61
  textBlockSpacingBefore: "none";
46
62
  textBlockSpacingAfter: "sm";
@@ -1,8 +1,10 @@
1
1
  import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
2
+ import { readPhiMarkdownFoldSections, } from "../../../../../components/widgets/shared/markdown-sections";
3
+ import { readPhiMarkdownImageAspectRatio, } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
2
4
  import { PHI_SPACING_SCALE_KEYS } from "../../../../../components/widgets/config/spacing-options";
3
5
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
4
6
  import { buildPhiBulletListFields, PHI_BULLET_LIST_DEFAULT_STYLE, readPhiBulletListStyle, } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
5
- import { readNumber, readRenderableBlockConfig, readString, } from "../../../../../components/widgets/config/parser-primitives";
7
+ import { readNumber, readRenderableBlockConfig, readBoolean, readString, } from "../../../../../components/widgets/config/parser-primitives";
6
8
  const PHI_MARKDOWN_TEXT_ALIGN_OPTIONS = [
7
9
  { value: "start", label: "Start" },
8
10
  { value: "center", label: "Center" },
@@ -49,6 +51,9 @@ export function parsePhiCmsMarkdownWidgetConfig(config) {
49
51
  revalidateSeconds: readNumber(config.revalidateSeconds),
50
52
  textAlign: readMarkdownTextAlign(config.textAlign),
51
53
  imageFloat: readMarkdownImageFloat(config.imageFloat),
54
+ imageAspectRatio: readPhiMarkdownImageAspectRatio(config.imageAspectRatio),
55
+ foldSections: readPhiMarkdownFoldSections(config.foldSections),
56
+ faqStructuredData: readBoolean(config.faqStructuredData),
52
57
  textBlockSpacingBefore: readMarkdownSpacingKey(config.textBlockSpacingBefore),
53
58
  textBlockSpacingAfter: readMarkdownSpacingKey(config.textBlockSpacingAfter),
54
59
  headingBlockSpacingBefore: readMarkdownSpacingKey(config.headingBlockSpacingBefore),
@@ -78,6 +83,8 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
78
83
  slotSizePolicy: "fill-inline",
79
84
  defaultConfig: {
80
85
  revalidateSeconds: 14400,
86
+ imageAspectRatio: "auto",
87
+ foldSections: "none",
81
88
  textAlign: "start",
82
89
  textBlockSpacingBefore: "none",
83
90
  textBlockSpacingAfter: "sm",
@@ -126,6 +133,26 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
126
133
  label: "Align",
127
134
  options: PHI_MARKDOWN_TEXT_ALIGN_OPTIONS,
128
135
  },
136
+ /*
137
+ * A page of questions and answers: every `##` folds under its heading. Each on its own, or one open at
138
+ * a time; a link to a question opens it. With it, the questions can be stated for search engines.
139
+ */
140
+ {
141
+ key: "foldSections",
142
+ type: "choice",
143
+ label: "Fold Sections",
144
+ options: [
145
+ { value: "none", label: "None" },
146
+ { value: "independent", label: "Each on its own" },
147
+ { value: "accordion", label: "One at a time" },
148
+ ],
149
+ },
150
+ {
151
+ key: "faqStructuredData",
152
+ type: "boolean",
153
+ label: "FAQ for search engines",
154
+ visibleWhen: { field: "foldSections", notEquals: "none" },
155
+ },
129
156
  {
130
157
  key: "imageFloat",
131
158
  type: "choice",
@@ -134,6 +161,24 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
134
161
  emptyOption: { value: "none", label: "None" },
135
162
  options: PHI_MARKDOWN_IMAGE_FLOAT_OPTIONS,
136
163
  },
164
+ /*
165
+ * Every picture standing on its own takes this box; one that needs another says so in its own address
166
+ * (`phis:asset/12?ratio=16:9`, and `float=start|end|none` beside it). Automatic is the picture's own.
167
+ */
168
+ {
169
+ key: "imageAspectRatio",
170
+ type: "choice",
171
+ label: "Image Proportion",
172
+ options: [
173
+ { value: "auto", label: "Automatic" },
174
+ { value: "phi", label: "φ (golden)" },
175
+ { value: "3:2", label: "3:2" },
176
+ { value: "4:3", label: "4:3" },
177
+ { value: "16:9", label: "16:9" },
178
+ { value: "2:1", label: "2:1" },
179
+ { value: "1:1", label: "1:1" },
180
+ ],
181
+ },
137
182
  {
138
183
  key: "textBlockSpacingBefore",
139
184
  type: "choice",
@@ -1,7 +1,8 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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 { resolveMarkdownRenderData } from "../../../../../components/widgets/shared/markdown-render";
5
+ import { buildPhiMarkdownFaqStructuredData, resolvePhiMarkdownFoldLevel } from "../../../../../components/widgets/shared/markdown-sections";
5
6
  export async function PhiMarkdownWidget({ config, runtime, }) {
6
7
  const renderData = await resolveMarkdownRenderData(config, runtime);
7
8
  if ("error" in renderData) {
@@ -10,11 +11,24 @@ export async function PhiMarkdownWidget({ config, runtime, }) {
10
11
  if (renderData.blocks.length === 0) {
11
12
  return null;
12
13
  }
13
- return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Markdown, componentProps: {
14
- config: {
15
- ...config,
16
- blocks: renderData.blocks,
17
- headings: renderData.headings,
18
- },
19
- } }));
14
+ /*
15
+ * The source stays on the server. The client draws `blocks`; the text they were made from -- inline or
16
+ * out of a Content record -- went to the page's payload as well, every address in it in the clear while
17
+ * the blocks protected them (`helpers/protected-mail.ts`).
18
+ */
19
+ const { markdown: _markdown, resolvedContent: _resolvedContent, ...presentation } = config ?? {};
20
+ /*
21
+ * The folding sections as questions and answers, written into the page for search engines: data, never
22
+ * run, and its `<` escaped so no answer can close the element it stands in.
23
+ */
24
+ const faq = config?.faqStructuredData && config.foldSections && config.foldSections !== "none"
25
+ ? buildPhiMarkdownFaqStructuredData(renderData.blocks, resolvePhiMarkdownFoldLevel(config.headingOffset))
26
+ : null;
27
+ return (_jsxs(_Fragment, { children: [faq ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(faq).replace(/</gu, "\\u003c") } })) : null, _jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Markdown, componentProps: {
28
+ config: {
29
+ ...presentation,
30
+ blocks: renderData.blocks,
31
+ headings: renderData.headings,
32
+ },
33
+ } })] }));
20
34
  }
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { trWidgetText } from "../../../../../server-helpers/translate";
3
3
  import { maskPhiTextPlaceholders, resolvePhiTextPlaceholders } from "../../../../../helpers/text-placeholders";
4
4
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
5
+ import { protectPhiMailHref } from "../../../../../helpers/protected-mail";
5
6
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
6
7
  export async function PhiSimpleTextWidget({ blockId, labels, config, translate, textSource, runtime, }) {
7
8
  const locale = runtime?.locale.current;
@@ -20,6 +21,15 @@ export async function PhiSimpleTextWidget({ blockId, labels, config, translate,
20
21
  return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.SimpleText, componentProps: {
21
22
  blockId,
22
23
  labels: { text },
23
- config: config,
24
+ config: protectPhiSimpleTextMailHref(config),
24
25
  } }));
25
26
  }
27
+ /*
28
+ * Live, a `mailto:` target leaves protected (`helpers/protected-mail.ts`). In the Builder the config is
29
+ * the operator's to edit and goes as it is.
30
+ */
31
+ function protectPhiSimpleTextMailHref(config) {
32
+ if (!config?.href || (config.renderMode != null && config.renderMode !== "live"))
33
+ return config;
34
+ return { ...config, href: protectPhiMailHref(config.href) };
35
+ }