@phis/ui 0.4.4 → 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.
- package/README.md +9 -3
- package/cms/plugins.d.ts +1 -0
- package/cms/plugins.js +2 -0
- package/components/cms/phi-cms-root-layout.js +31 -2
- package/components/controls/phi-background-control.d.ts +6 -1
- package/components/controls/phi-background-control.js +12 -4
- package/components/controls/phi-button-control.d.ts +15 -1
- package/components/controls/phi-button-control.js +21 -3
- package/components/controls/phi-collapse-control.d.ts +6 -2
- package/components/controls/phi-collapse-control.js +2 -2
- package/components/controls/phi-dialog-control.d.ts +11 -5
- package/components/controls/phi-dialog-control.js +19 -13
- package/components/controls/phi-dropdown-control.js +2 -2
- package/components/controls/phi-media-asset-tile-control.js +10 -10
- package/components/controls/phi-menu-control-vocabulary.d.ts +7 -0
- package/components/controls/phi-menu-control-vocabulary.js +10 -0
- package/components/controls/phi-menu-control.d.ts +4 -1
- package/components/controls/phi-menu-control.js +6 -1
- package/components/controls/phi-progress-control.d.ts +10 -2
- package/components/controls/phi-progress-control.js +6 -2
- package/components/controls/phi-ribbon-control.d.ts +4 -1
- package/components/controls/phi-ribbon-control.js +5 -3
- package/components/controls/phi-ribbon-wrap-control.d.ts +7 -1
- package/components/controls/phi-ribbon-wrap-control.js +8 -2
- package/components/controls/phi-segmented-control.d.ts +4 -1
- package/components/controls/phi-segmented-control.js +13 -2
- package/components/controls/phi-surface-control.d.ts +2 -0
- package/components/controls/phi-surface-control.js +16 -1
- package/components/controls/phi-switch-control.d.ts +4 -1
- package/components/controls/phi-switch-control.js +8 -2
- package/components/controls/phi-tag-control.d.ts +4 -1
- package/components/controls/phi-tag-control.js +11 -3
- package/components/layouts/clients/phi-split-card-layout-client.js +13 -5
- package/components/layouts/clients/phi-three-column-layout-client.js +9 -3
- package/components/layouts/phi-layout-view-model.js +10 -1
- package/components/layouts/split-card-geometry.js +6 -2
- package/components/media/aspect-ratios.d.ts +2 -2
- package/components/menus/phi-account-menu.js +3 -1
- package/components/navigation/phi-link.js +7 -2
- package/components/navigation/use-phi-protected-mail.d.ts +11 -0
- package/components/navigation/use-phi-protected-mail.js +29 -0
- package/components/regions/clients/cms-region-container-client.js +16 -2
- package/components/regions/phi-cms-region-container.js +5 -1
- package/components/regions/phi-cms-region-shell.d.ts +11 -0
- package/components/regions/phi-cms-region-shell.js +64 -7
- package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
- package/components/root/phi-config-provider.js +16 -0
- package/components/root/phi-root-layout.d.ts +1 -0
- package/components/root/phi-root-layout.js +1 -0
- package/components/root/phi-root-theme-resolver.js +12 -1
- package/components/root/phi-shell-chrome-overlay.d.ts +6 -0
- package/components/root/phi-shell-chrome-overlay.js +7 -1
- package/components/runtime/runtime-module-context.d.ts +12 -1
- package/components/runtime/runtime-module-context.js +6 -1
- package/components/shell/phi-cms-shell.d.ts +9 -1
- package/components/shell/phi-cms-shell.js +10 -4
- package/components/shell/phi-nav-link.js +7 -2
- package/components/shell/phi-shell-sider-drawer.d.ts +17 -0
- package/components/shell/phi-shell-sider-drawer.js +88 -0
- package/components/shell/use-phi-shell-header-bands.d.ts +5 -0
- package/components/shell/use-phi-shell-header-bands.js +64 -0
- package/components/shell/use-phi-shell-sticky-bottom.d.ts +18 -0
- package/components/shell/use-phi-shell-sticky-bottom.js +54 -0
- package/components/tables/client/phi-table-binding.d.ts +1 -0
- package/components/tables/client/phi-table-binding.js +22 -3
- package/components/trees/client/phi-tree-binding.d.ts +1 -0
- package/components/trees/client/phi-tree-binding.js +11 -2
- package/components/widgets/client/shared/phi-collection-provider.js +4 -3
- package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
- package/components/widgets/client/shared/phi-collection-view-binding.js +16 -2
- package/components/widgets/client/shared/phi-command-buttons.js +6 -2
- package/components/widgets/config/background.d.ts +20 -0
- package/components/widgets/config/background.js +44 -2
- package/components/widgets/config/button-variant.d.ts +22 -4
- package/components/widgets/config/button-variant.js +24 -5
- package/components/widgets/config/common-action-field.d.ts +1 -1
- package/components/widgets/config/parser-primitives.js +4 -2
- package/components/widgets/config/theme-gradient.d.ts +11 -0
- package/components/widgets/config/theme-gradient.js +12 -0
- package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -0
- package/components/widgets/helpers/internal-reference-resolver.server.js +4 -1
- package/components/widgets/label-sets/background.js +2 -0
- package/components/widgets/label-sets/geometry.js +2 -0
- package/components/widgets/label-sets/inspector.js +6 -0
- package/components/widgets/label-types/background.d.ts +1 -0
- package/components/widgets/label-types/background.js +1 -0
- package/components/widgets/label-types/common-controls.js +2 -2
- package/components/widgets/label-types/geometry.d.ts +1 -0
- package/components/widgets/label-types/geometry.js +1 -0
- package/components/widgets/label-types/inspector.d.ts +6 -0
- package/components/widgets/label-types/inspector.js +3 -0
- package/components/widgets/server/navigation-request.js +13 -1
- package/components/widgets/shared/card-body-client.d.ts +13 -0
- package/components/widgets/shared/card-body-client.js +40 -11
- package/components/widgets/shared/card-vocabulary.d.ts +36 -0
- package/components/widgets/shared/card-vocabulary.js +52 -0
- package/components/widgets/shared/collection-source-failure.d.ts +26 -0
- package/components/widgets/shared/collection-source-failure.js +42 -0
- package/components/widgets/shared/markdown-body-client.d.ts +29 -0
- package/components/widgets/shared/markdown-body-client.js +60 -5
- package/components/widgets/shared/markdown-image-vocabulary.d.ts +31 -0
- package/components/widgets/shared/markdown-image-vocabulary.js +68 -0
- package/components/widgets/shared/markdown-render.d.ts +5 -0
- package/components/widgets/shared/markdown-render.js +139 -11
- package/components/widgets/shared/markdown-sections.d.ts +40 -0
- package/components/widgets/shared/markdown-sections.js +111 -0
- package/components/widgets/shared/widget-failure-client.d.ts +10 -0
- package/components/widgets/shared/widget-failure-client.js +20 -0
- package/components/widgets/shared/widget-failure.d.ts +31 -0
- package/components/widgets/shared/widget-failure.js +20 -0
- package/components/widgets/shared/widget-failure.server.d.ts +9 -0
- package/components/widgets/shared/widget-failure.server.js +12 -0
- package/gateway/dashboard-card-memo.d.ts +3 -0
- package/gateway/dashboard-card-memo.js +25 -0
- package/helpers/cms-region-keys.d.ts +1 -1
- package/helpers/external-href.js +1 -1
- package/helpers/layout-style.d.ts +8 -4
- package/helpers/layout-style.js +3 -2
- package/helpers/mode-paint.d.ts +4 -0
- package/helpers/mode-paint.js +47 -0
- package/helpers/protected-mail.d.ts +16 -0
- package/helpers/protected-mail.js +81 -0
- package/helpers/surface-style.js +33 -11
- package/module-dashboard-cards.d.ts +1 -0
- package/module-dashboard-cards.js +1 -0
- package/module-records.d.ts +7 -0
- package/module-records.js +6 -0
- package/package.json +2 -2
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-surface-labels.js +1 -0
- package/plugins/runtime-modules/builder/clients/region-inspector.js +67 -3
- package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +1 -1
- package/plugins/runtime-modules/builder/controller/draft-command-controller.js +7 -4
- package/plugins/runtime-modules/builder/controller/page-controller.js +7 -0
- package/plugins/runtime-modules/builder/persistence.d.ts +3 -0
- package/plugins/runtime-modules/builder/persistence.js +9 -1
- package/plugins/runtime-modules/core/content-entries/record-source.server.d.ts +3 -1
- package/plugins/runtime-modules/core/content-entries/record-source.server.js +7 -4
- package/plugins/runtime-modules/core/widgets/button/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/button/config.d.ts +40 -4
- package/plugins/runtime-modules/core/widgets/button/config.js +12 -0
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +102 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +60 -1
- package/plugins/runtime-modules/core/widgets/card/editor.js +17 -2
- package/plugins/runtime-modules/core/widgets/card/server.js +13 -1
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -3
- package/plugins/runtime-modules/core/widgets/collection-view/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +47 -11
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
- package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +6 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.js +21 -3
- package/plugins/runtime-modules/core/widgets/entry-detail/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-detail/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/entry-detail/server.js +5 -2
- package/plugins/runtime-modules/core/widgets/entry-header/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-header/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/entry-header/server.js +5 -2
- package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +6 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.js +13 -6
- package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +2 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/gallery/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -3
- package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -6
- package/plugins/runtime-modules/core/widgets/header-navigation/client.d.ts +6 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/client.js +40 -13
- package/plugins/runtime-modules/core/widgets/header-navigation/config.d.ts +26 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/config.js +27 -0
- package/plugins/runtime-modules/core/widgets/header-navigation/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/server.d.ts +2 -2
- package/plugins/runtime-modules/core/widgets/header-navigation/server.js +3 -1
- package/plugins/runtime-modules/core/widgets/image/client.js +11 -7
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.js +46 -1
- package/plugins/runtime-modules/core/widgets/markdown/server.js +22 -8
- package/plugins/runtime-modules/core/widgets/record/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/record/client.js +8 -3
- package/plugins/runtime-modules/core/widgets/record/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/record/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/record/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/segmented/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +21 -1
- package/plugins/runtime-modules/core/widgets/segmented/config.js +11 -1
- package/plugins/runtime-modules/core/widgets/simple-text/server.js +11 -1
- package/plugins/runtime-modules/core/widgets/switch/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/switch/config.d.ts +19 -0
- package/plugins/runtime-modules/core/widgets/switch/config.js +11 -0
- package/plugins/runtime-modules/core/widgets/table/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +16 -3
- package/plugins/runtime-modules/core/widgets/table/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/table/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/table/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/table/static-resource-editor.js +2 -1
- package/plugins/runtime-modules/core/widgets/timeline/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/timeline/client.d.ts +1 -3
- package/plugins/runtime-modules/core/widgets/timeline/client.js +14 -4
- package/plugins/runtime-modules/core/widgets/tree/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/tree/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/tree/client.js +13 -2
- package/plugins/runtime-modules/core/widgets/tree/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/tree/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/tree/server.js +2 -2
- package/plugins/runtime-modules/theme/presets.d.ts +9 -1
- package/plugins/runtime-modules/theme/tour.d.ts +9 -1
- package/plugins/runtime-modules/theme/tour.js +10 -1
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +138 -7
- package/runtime-data-provider-client.d.ts +2 -0
- package/runtime-data-provider-client.js +7 -0
- package/styles/controls.css +118 -15
- package/styles/gradients.css +101 -0
- package/styles/layout.css +35 -0
- package/styles/root.css +18 -0
- package/styles/shell.css +206 -0
- package/theme/phi-button-shadow.d.ts +6 -0
- package/theme/phi-theme-gradients.d.ts +96 -0
- package/theme/phi-theme-gradients.js +245 -0
- package/theme/phi-theme-presets.d.ts +3 -0
- package/theme/phi-theme-presets.js +3 -0
- package/theme/phi-theme-tokens.d.ts +5 -1
- package/theme/phi-theme-tokens.js +14 -0
- package/theme/phi-tokens.d.ts +6 -0
- package/theme/phi-tokens.js +6 -0
- package/theme.d.ts +1 -0
- package/theme.js +6 -0
- package/types/cms-presets.d.ts +7 -0
- package/types/core-widget-placements.d.ts +8 -0
- package/types/layout-style.d.ts +9 -8
- package/types/layout-style.js +9 -8
- package/types/surface.d.ts +4 -0
- package/types/surface.js +4 -0
- package/types.d.ts +1 -1
- package/types.js +1 -1
|
@@ -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
|
-
|
|
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 (
|
|
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: "
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
94
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type PhiRecordWidgetLabels } from "../../../../../components/widgets/label-types/record";
|
|
2
2
|
import type { PhiRecordWidgetConfig } from "../../../../../types/record-widget";
|
|
3
|
+
import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
|
|
3
4
|
export type PhiRecordWidgetClientProps = {
|
|
4
5
|
config: PhiRecordWidgetConfig;
|
|
5
6
|
labels?: PhiRecordWidgetLabels;
|
|
7
|
+
/** Where this draws, which decides who reads a failed read: the author, or only the log. */
|
|
8
|
+
renderMode: PhiRenderableBlockRenderMode;
|
|
6
9
|
};
|
|
7
|
-
export declare function PhiRecordWidgetClient({ config, labels, }: PhiRecordWidgetClientProps): import("react").JSX.Element;
|
|
10
|
+
export declare function PhiRecordWidgetClient({ config, labels, renderMode, }: PhiRecordWidgetClientProps): import("react").JSX.Element;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { readPhiDotPath } from "../../../../../helpers/dot-path";
|
|
5
|
-
import { PhiAlertControl } from "../../../../../components/controls/phi-alert-control";
|
|
6
5
|
import { PhiDescriptionListControl } from "../../../../../components/controls/phi-description-list-control";
|
|
7
6
|
import { PhiEmptyControl } from "../../../../../components/controls/phi-empty-control";
|
|
8
7
|
import { PhiSkeletonControl } from "../../../../../components/controls/phi-skeleton-control";
|
|
@@ -11,8 +10,10 @@ import { usePhiSignalIdentity } from "../../../../../components/runtime/runtime-
|
|
|
11
10
|
import { renderPhiValueContent } from "../../../../../components/widgets/client/shared/phi-rendered-value";
|
|
12
11
|
import { usePhiTableProvider } from "../../../../../components/widgets/client/shared/phi-table-provider";
|
|
13
12
|
import { PHI_RECORD_WIDGET_DEFAULT_LABELS, formatPhiRecordWidgetLabel, } from "../../../../../components/widgets/label-types/record";
|
|
13
|
+
import { PhiWidgetFailure } from "../../../../../components/widgets/shared/widget-failure-client";
|
|
14
|
+
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
14
15
|
import { readPhiTableActionSignalValue } from "../../../../../types/table-signal-values";
|
|
15
|
-
export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAULT_LABELS, }) {
|
|
16
|
+
export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAULT_LABELS, renderMode, }) {
|
|
16
17
|
/*
|
|
17
18
|
* Which record to show arrives as a signal, and is not read out of a store this Widget knows about.
|
|
18
19
|
*
|
|
@@ -122,8 +123,12 @@ export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAU
|
|
|
122
123
|
if (loading) {
|
|
123
124
|
return _jsx(PhiSkeletonControl, { lines: config.presentation.fields.length || 7, withTitle: true });
|
|
124
125
|
}
|
|
126
|
+
/*
|
|
127
|
+
* Every error here is the source's -- no binding, a resource that reads no single records, a read that
|
|
128
|
+
* failed -- and none of them is the reader's to fix, so it goes the way of every such failure.
|
|
129
|
+
*/
|
|
125
130
|
if (error) {
|
|
126
|
-
return _jsx(
|
|
131
|
+
return _jsx(PhiWidgetFailure, { renderMode: renderMode, widgetType: PhiCmsWidgetType.Record, title: error });
|
|
127
132
|
}
|
|
128
133
|
if (!record) {
|
|
129
134
|
return _jsx(PhiEmptyControl, { description: labels.empty });
|
|
@@ -2,16 +2,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { definePhiPassiveWidgetRenderers } from "../../../../../plugins/factories/widget-renderers";
|
|
3
3
|
import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
|
|
4
4
|
import { getPhiRecordWidgetLabels } from "../../../../../components/widgets/label-sets/record";
|
|
5
|
+
import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
|
|
5
6
|
import { PHI_RECORD_WIDGET_DEFINITION } from "./config";
|
|
6
7
|
import { PhiRecordWidget } from "./server";
|
|
7
|
-
async function PhiRecordWidgetPluginServer({ config, runtime, }) {
|
|
8
|
+
async function PhiRecordWidgetPluginServer({ widget, config, runtime, }) {
|
|
8
9
|
const rt = phiRuntime(runtime);
|
|
9
10
|
const labels = await getPhiRecordWidgetLabels({
|
|
10
11
|
apiBaseUrl: rt.apiBaseUrl,
|
|
11
12
|
internalToken: rt.internalToken,
|
|
12
13
|
locale: runtime.locale.current,
|
|
13
14
|
});
|
|
14
|
-
return _jsx(PhiRecordWidget, { config: config, labels: labels });
|
|
15
|
+
return _jsx(PhiRecordWidget, { config: config, labels: labels, renderMode: readPhiRuntimeTreeRenderMode(widget.config) });
|
|
15
16
|
}
|
|
16
17
|
export const PHI_RECORD_WIDGET_PLUGIN = {
|
|
17
18
|
...PHI_RECORD_WIDGET_DEFINITION,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { PhiRecordWidgetLabels } from "../../../../../components/widgets/label-types/record";
|
|
2
2
|
import type { PhiRecordWidgetConfig } from "../../../../../types/record-widget";
|
|
3
|
+
import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
|
|
3
4
|
export type PhiRecordWidgetProps = {
|
|
4
5
|
config: PhiRecordWidgetConfig;
|
|
5
6
|
labels: PhiRecordWidgetLabels;
|
|
7
|
+
renderMode: PhiRenderableBlockRenderMode;
|
|
6
8
|
};
|
|
7
|
-
export declare function PhiRecordWidget({ config, labels }: PhiRecordWidgetProps): import("react").JSX.Element;
|
|
9
|
+
export declare function PhiRecordWidget({ config, labels, renderMode }: PhiRecordWidgetProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
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
|
-
export function PhiRecordWidget({ config, labels }) {
|
|
5
|
-
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Record, componentProps: { config, labels } }));
|
|
4
|
+
export function PhiRecordWidget({ config, labels, renderMode }) {
|
|
5
|
+
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Record, componentProps: { config, labels, renderMode } }));
|
|
6
6
|
}
|
|
@@ -14,7 +14,7 @@ export function PhiSegmentedWidget({ config, signalsEnabled = true, mode = "prev
|
|
|
14
14
|
if (choice.options.length === 0 && emptyHint) {
|
|
15
15
|
return _jsx(PhiEmptyControl, { description: emptyHint });
|
|
16
16
|
}
|
|
17
|
-
return (_jsx(PhiSegmentedControl, { block: fill, label: config?.label, value: choice.value || undefined, disabled: choice.disabled, readOnly: choice.readOnly, size: config?.controlSize, options: choice.options, onChange: (resolvedValue) => {
|
|
17
|
+
return (_jsx(PhiSegmentedControl, { block: fill, label: config?.label, value: choice.value || undefined, disabled: choice.disabled, readOnly: choice.readOnly, size: config?.controlSize, ...(config?.gradient ? { gradient: config.gradient } : {}), options: choice.options, onChange: (resolvedValue) => {
|
|
18
18
|
onChange?.(resolvedValue);
|
|
19
19
|
choice.publish(resolvedValue);
|
|
20
20
|
}, onFocus: choice.emitFocus, onBlur: choice.emitBlur }));
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { type PhiThemeGradientKey } from "../../../../../theme/phi-theme-gradients";
|
|
1
2
|
import { type PhiStackChoiceControlConfig } from "../../../../../components/widgets/config/choice-shared";
|
|
2
|
-
export type PhiSegmentedWidgetConfig = PhiStackChoiceControlConfig
|
|
3
|
+
export type PhiSegmentedWidgetConfig = PhiStackChoiceControlConfig & {
|
|
4
|
+
/** A Theme gradient slot the selected segment is filled with; absent, Ant Design's selected ground. */
|
|
5
|
+
gradient?: PhiThemeGradientKey;
|
|
6
|
+
};
|
|
3
7
|
declare function parsePhiSegmentedWidgetConfig(config: Record<string, unknown>): PhiSegmentedWidgetConfig;
|
|
4
8
|
export declare const PHI_SEGMENTED_WIDGET_DEFINITION: {
|
|
5
9
|
kind: "widget";
|
|
@@ -111,6 +115,22 @@ export declare const PHI_SEGMENTED_WIDGET_DEFINITION: {
|
|
|
111
115
|
key: string;
|
|
112
116
|
type: "string";
|
|
113
117
|
label: string;
|
|
118
|
+
description?: undefined;
|
|
119
|
+
options?: undefined;
|
|
120
|
+
emptyOption?: undefined;
|
|
121
|
+
} | {
|
|
122
|
+
key: string;
|
|
123
|
+
type: "choice";
|
|
124
|
+
label: string;
|
|
125
|
+
description: string;
|
|
126
|
+
options: {
|
|
127
|
+
value: "gradient1" | "gradient2" | "gradient3";
|
|
128
|
+
label: string;
|
|
129
|
+
}[];
|
|
130
|
+
emptyOption: {
|
|
131
|
+
value: string;
|
|
132
|
+
label: string;
|
|
133
|
+
};
|
|
114
134
|
})[];
|
|
115
135
|
defaultConfig: {
|
|
116
136
|
key: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { readPhiThemeGradientKey } from "../../../../../theme/phi-theme-gradients";
|
|
2
|
+
import { PHI_THEME_GRADIENT_FIELD_OPTIONS } from "../../../../../components/widgets/config/theme-gradient";
|
|
1
3
|
import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
|
|
2
4
|
import { buildPhiChoiceControlOptionFields, PHI_CHOICE_CONTROL_CONFIG_FIELDS, PHI_CHOICE_CONTROL_VALUE_MODE_FIELD, parsePhiStackChoiceControlConfig, } from "../../../../../components/widgets/config/choice-shared";
|
|
3
5
|
import { PHI_SELECT_CONTROL_SIGNALS } from "../../../../../components/widgets/signals/control-signal-capabilities";
|
|
4
6
|
function parsePhiSegmentedWidgetConfig(config) {
|
|
5
|
-
return parsePhiStackChoiceControlConfig(config);
|
|
7
|
+
return { ...parsePhiStackChoiceControlConfig(config), gradient: readPhiThemeGradientKey(config.gradient) };
|
|
6
8
|
}
|
|
7
9
|
export const PHI_SEGMENTED_WIDGET_DEFINITION = {
|
|
8
10
|
kind: "widget",
|
|
@@ -22,6 +24,14 @@ export const PHI_SEGMENTED_WIDGET_DEFINITION = {
|
|
|
22
24
|
PHI_CHOICE_CONTROL_VALUE_MODE_FIELD,
|
|
23
25
|
...buildPhiChoiceControlOptionFields("toolbar"),
|
|
24
26
|
...PHI_CHOICE_CONTROL_CONFIG_FIELDS,
|
|
27
|
+
{
|
|
28
|
+
key: "gradient",
|
|
29
|
+
type: "choice",
|
|
30
|
+
label: "Gradient",
|
|
31
|
+
description: "Fills the selected segment with one of the Theme's gradients.",
|
|
32
|
+
options: [...PHI_THEME_GRADIENT_FIELD_OPTIONS],
|
|
33
|
+
emptyOption: { value: "", label: "None" },
|
|
34
|
+
},
|
|
25
35
|
],
|
|
26
36
|
defaultConfig: {
|
|
27
37
|
key: "segmented",
|
|
@@ -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
|
+
}
|
|
@@ -35,5 +35,5 @@ export function PhiSwitchWidget({ config, disabled, readOnly, checked: controlle
|
|
|
35
35
|
onChange?.(nextChecked);
|
|
36
36
|
controlSignals.emitChange(nextChecked);
|
|
37
37
|
}
|
|
38
|
-
return (_jsx(PhiSwitchControl, { checked: checked, disabled: resolvedDisabled, readOnly: controlSignals.readOnly, size: config?.controlSize, label: config?.label, checkedLabel: config?.checkedLabel, uncheckedLabel: config?.uncheckedLabel, onChange: publish }));
|
|
38
|
+
return (_jsx(PhiSwitchControl, { checked: checked, disabled: resolvedDisabled, readOnly: controlSignals.readOnly, size: config?.controlSize, label: config?.label, checkedLabel: config?.checkedLabel, uncheckedLabel: config?.uncheckedLabel, ...(config?.gradient ? { gradient: config.gradient } : {}), onChange: publish }));
|
|
39
39
|
}
|