@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
|
@@ -11,12 +11,12 @@ export const PHI_COMMON_CONTROL_DEFAULT_LABELS = {
|
|
|
11
11
|
meta: { label: "Meta", tooltip: "Meta", icon: "meta" },
|
|
12
12
|
new: { label: "New", tooltip: "New", icon: "new" },
|
|
13
13
|
pageMeta: { label: "Meta", tooltip: "Page meta", icon: "meta" },
|
|
14
|
-
publish: { label: "Publish", tooltip: "Publish", icon: "publish"
|
|
14
|
+
publish: { label: "Publish", tooltip: "Publish", icon: "publish" },
|
|
15
15
|
reload: { label: "Reload", tooltip: "Reload", icon: "reload" },
|
|
16
16
|
reset: { label: "Reset", tooltip: "Reset", icon: "reset", danger: true },
|
|
17
17
|
restore: { label: "Restore", tooltip: "Restore", icon: "restore" },
|
|
18
18
|
review: { label: "Review", tooltip: "Review", icon: "preview" },
|
|
19
|
-
save: { label: "Save", tooltip: "Save", icon: "save"
|
|
19
|
+
save: { label: "Save", tooltip: "Save", icon: "save" },
|
|
20
20
|
search: { label: "Search", tooltip: "Search", icon: "search" },
|
|
21
21
|
undo: { label: "Undo", tooltip: "Undo", icon: "undo" },
|
|
22
22
|
redo: { label: "Redo", tooltip: "Redo", icon: "redo" },
|
|
@@ -33,6 +33,8 @@ export type PhiInspectorWidgetLabels = {
|
|
|
33
33
|
light: string;
|
|
34
34
|
dark: string;
|
|
35
35
|
inverse: string;
|
|
36
|
+
/** The switch that gives a Surface a ground of its own in dark mode (`PhiSurface.backgroundDark`). */
|
|
37
|
+
backgroundPerMode: string;
|
|
36
38
|
};
|
|
37
39
|
/**
|
|
38
40
|
* A Grid's columns -- how many slots a row holds at each width, and where one slot stands -- and a
|
|
@@ -70,6 +72,10 @@ export type PhiInspectorRegionVisibilityLabels = {
|
|
|
70
72
|
hover: string;
|
|
71
73
|
scrollUp: string;
|
|
72
74
|
pageOwned: string;
|
|
75
|
+
/** How far the Page's `content` reaches up into its Hero (`PhiCmsRegionConfig.heroOverlap`). */
|
|
76
|
+
heroOverlap: string;
|
|
77
|
+
/** `sider_left` opens as a drawer on a phone (`PhiCmsFlags.MobileDrawer`). */
|
|
78
|
+
siderMobileDrawer: string;
|
|
73
79
|
};
|
|
74
80
|
export type PhiInspectorLinkTargetLabels = {
|
|
75
81
|
none: string;
|
|
@@ -30,6 +30,8 @@ export const PHI_INSPECTOR_WIDGET_DEFAULT_LABELS = {
|
|
|
30
30
|
hover: "At the top edge",
|
|
31
31
|
scrollUp: "When scrolling up",
|
|
32
32
|
pageOwned: "This Region belongs to its Page and stands on that Page alone.",
|
|
33
|
+
heroOverlap: "Reaches into the Hero",
|
|
34
|
+
siderMobileDrawer: "On a phone, opens from the menu button",
|
|
33
35
|
},
|
|
34
36
|
surfaceStyle: {
|
|
35
37
|
title: "Style",
|
|
@@ -44,6 +46,7 @@ export const PHI_INSPECTOR_WIDGET_DEFAULT_LABELS = {
|
|
|
44
46
|
light: "Light",
|
|
45
47
|
dark: "Dark",
|
|
46
48
|
inverse: "Inverse",
|
|
49
|
+
backgroundPerMode: "Own background in dark mode",
|
|
47
50
|
},
|
|
48
51
|
grid: {
|
|
49
52
|
columns: "Slots per row",
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import { type PhiBackgroundOverlay } from "../config/background";
|
|
3
|
+
import { type PhiButtonVariant } from "../config/button-variant";
|
|
4
|
+
import type { PhiThemeGradientKey } from "../../../theme/phi-theme-gradients";
|
|
2
5
|
import { type PhiImageControlSource } from "../../controls/phi-image-control";
|
|
3
6
|
import type { PhiImagePresentation } from "../../media/image-presentation";
|
|
4
7
|
import type { PhiClientBlockBaseProps } from "../../../types";
|
|
@@ -42,6 +45,8 @@ export type PhiCardWidgetImage = {
|
|
|
42
45
|
presentation: PhiImagePresentation;
|
|
43
46
|
/** 0 to 1; absent is the whole picture. */
|
|
44
47
|
opacity?: number;
|
|
48
|
+
/** A layer over the picture, under the card's marks (`PhiCmsCardWidgetConfig.imageOverlay`). */
|
|
49
|
+
overlay?: PhiBackgroundOverlay | null;
|
|
45
50
|
source: PhiImageControlSource;
|
|
46
51
|
alt: string;
|
|
47
52
|
blurDataUrl?: string | null;
|
|
@@ -50,6 +55,8 @@ export type PhiCardWidgetImage = {
|
|
|
50
55
|
export type PhiCardWidgetClientConfig = {
|
|
51
56
|
surface?: PhiSurface | null;
|
|
52
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;
|
|
53
60
|
iconName?: string;
|
|
54
61
|
iconPlacement?: PhiCardIconPlacement;
|
|
55
62
|
/** The icon's colour and its ground; absent, the Theme's. */
|
|
@@ -74,6 +81,8 @@ export type PhiCardWidgetClientConfig = {
|
|
|
74
81
|
badgeColor?: string;
|
|
75
82
|
/** How the badge is drawn; absent, `none`. */
|
|
76
83
|
badgeStyle?: PhiCardBadgeStyle;
|
|
84
|
+
/** A Theme gradient slot the badge is filled with, over `badgeColor`. */
|
|
85
|
+
badgeGradient?: PhiThemeGradientKey;
|
|
77
86
|
/** Which price a `plan` shows until a `billingPeriod` signal says otherwise. Absent is `monthly`. */
|
|
78
87
|
billingPeriod?: PhiCardBillingPeriod;
|
|
79
88
|
hoverEffect?: PhiCardHoverEffect;
|
|
@@ -87,6 +96,10 @@ export type PhiCardWidgetAction = {
|
|
|
87
96
|
icon?: string;
|
|
88
97
|
/** The button's name where it shows only its icon. */
|
|
89
98
|
ariaLabel?: string;
|
|
99
|
+
/** How it stands out; absent, primary on a highlighted card and normal otherwise. */
|
|
100
|
+
variant?: PhiButtonVariant;
|
|
101
|
+
/** The Theme gradient slot a `gradient` button is filled with. */
|
|
102
|
+
gradient?: PhiThemeGradientKey;
|
|
90
103
|
};
|
|
91
104
|
export type PhiCardWidgetClientProps = PhiClientBlockBaseProps<PhiCardWidgetClientLabels, PhiCardWidgetClientConfig> & {
|
|
92
105
|
binding?: PhiCardWidgetClientBinding;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { PhiButtonControl } from "../../controls/phi-button-control";
|
|
5
|
+
import { PHI_BACKGROUND_OVERLAY_DEFAULT_OPACITY, resolvePhiBackgroundWidgetStyle, } from "../config/background";
|
|
6
|
+
import { resolvePhiButtonVariantPresentation } from "../config/button-variant";
|
|
5
7
|
import { PhiFlexControl } from "../../controls/phi-flex-control";
|
|
6
8
|
import { PhiImageControl } from "../../controls/phi-image-control";
|
|
7
9
|
import { PhiRibbonControl } from "../../controls/phi-ribbon-control";
|
|
@@ -18,7 +20,26 @@ import { resolvePhiSurfaceStyle } from "../../../helpers/surface-style";
|
|
|
18
20
|
import { usePhiControlSignalController } from "../client/shared/phi-control-signals";
|
|
19
21
|
import { PHI_COLOR, PHI_SPACE } from "../../../theme/antd-css-var-contract";
|
|
20
22
|
import { PHI_THEME_HEADING_FONT_VARIABLE } from "../../../theme/phi-theme-typography";
|
|
21
|
-
import { PHI_CARD_TEXT_SLOTS, readPhiCardBillingPeriod } from "./card-vocabulary";
|
|
23
|
+
import { PHI_CARD_IMAGE_SIZES, PHI_CARD_TEXT_SLOTS, readPhiCardBillingPeriod } from "./card-vocabulary";
|
|
24
|
+
/**
|
|
25
|
+
* The layer over a card's picture. A colour or a gradient is drawn as CSS, each colour mixed down to the
|
|
26
|
+
* Overlay's opacity, so a Theme variable (`var(--ant-color-bg-container)`) resolves and the picture fades
|
|
27
|
+
* into the card's own ground in either mode; a Background draws the same Overlay into an SVG picture,
|
|
28
|
+
* where no variable reaches. A pattern or noise is drawn as a Background draws it.
|
|
29
|
+
*/
|
|
30
|
+
function resolvePhiCardImageOverlayStyle(overlay) {
|
|
31
|
+
if (overlay.kind !== "color") {
|
|
32
|
+
return resolvePhiBackgroundWidgetStyle({ base: { kind: "none" }, overlay });
|
|
33
|
+
}
|
|
34
|
+
const opacity = Math.round(Math.max(0, Math.min(1, overlay.opacity ?? PHI_BACKGROUND_OVERLAY_DEFAULT_OPACITY)) * 1000) / 10;
|
|
35
|
+
const mix = (color) => (color === "transparent" || opacity >= 100
|
|
36
|
+
? color
|
|
37
|
+
: `color-mix(in srgb, ${color} ${opacity}%, transparent)`);
|
|
38
|
+
const ink = overlay.ink ?? { kind: "color", color: "#000000" };
|
|
39
|
+
return ink.kind === "color"
|
|
40
|
+
? { backgroundColor: mix(ink.color) }
|
|
41
|
+
: { backgroundImage: `linear-gradient(${ink.direction}, ${ink.stops.map((stop) => `${mix(stop.color)} ${stop.percent}%`).join(", ")})` };
|
|
42
|
+
}
|
|
22
43
|
const PHI_CARD_SIGNAL_TEXT_SLOTS = new Set(PHI_CARD_TEXT_SLOTS);
|
|
23
44
|
/*
|
|
24
45
|
* What each variant sets, in one row per variant. A further variant -- a featured card -- is a row here
|
|
@@ -261,13 +282,18 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
261
282
|
const headingRow = iconPlacement === "inline" && iconName ? (_jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: justify, gap, ...slotWidth }, children: [iconMark(iconSize, inlineIconFrame), heading] })) : heading;
|
|
262
283
|
const media = image ? (_jsxs("div", { className: "phi-card__media", style: {
|
|
263
284
|
position: "relative",
|
|
264
|
-
aspectRatio: metrics.mediaAspectRatio ?? resolveMediaAspectRatio(image.presentation),
|
|
285
|
+
aspectRatio: config?.mediaAspectRatio ?? metrics.mediaAspectRatio ?? resolveMediaAspectRatio(image.presentation),
|
|
265
286
|
overflow: "hidden",
|
|
266
|
-
}, 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: {
|
|
267
288
|
width: "100%",
|
|
268
289
|
height: "100%",
|
|
269
290
|
...(image.opacity == null || image.opacity >= 1 ? {} : { opacity: image.opacity }),
|
|
270
|
-
} }),
|
|
291
|
+
} }), image.overlay ? (_jsx("span", { "aria-hidden": "true", className: "phi-card__media-overlay", style: {
|
|
292
|
+
...resolvePhiCardImageOverlayStyle(image.overlay),
|
|
293
|
+
position: "absolute",
|
|
294
|
+
inset: 0,
|
|
295
|
+
pointerEvents: "none",
|
|
296
|
+
} })) : null, iconAtTop && iconName ? (_jsx("span", { "aria-hidden": "true", className: "phi-card__icon", style: {
|
|
271
297
|
position: "absolute",
|
|
272
298
|
insetInlineStart: markSide === "start" ? inset : markSide === "end" ? undefined : "50%",
|
|
273
299
|
insetInlineEnd: markSide === "end" ? inset : undefined,
|
|
@@ -310,20 +336,23 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
310
336
|
...(highlight ? { "--phi-card-highlight-color": PHI_COLOR.primary } : {}),
|
|
311
337
|
};
|
|
312
338
|
/*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* stand in a column that fills the card, and the button takes what is left above
|
|
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.
|
|
316
343
|
*/
|
|
317
|
-
const footAction =
|
|
344
|
+
const footAction = action != null;
|
|
318
345
|
const actionButton = action ? (_jsx("div", { className: "phi-card__action",
|
|
319
346
|
/* At the foot, it stands where the words' alignment puts it, as it does among them. */
|
|
320
|
-
style: footAction ? { marginTop: "auto", alignSelf: textAlign === "center" ? "center" : textAlign === "end" ? "flex-end" : "flex-start" } : undefined, children: _jsx(PhiButtonControl, {
|
|
347
|
+
style: footAction ? { marginTop: "auto", alignSelf: textAlign === "center" ? "center" : textAlign === "end" ? "flex-end" : "flex-start" } : undefined, children: _jsx(PhiButtonControl, { ...(action.variant
|
|
348
|
+
? resolvePhiButtonVariantPresentation(action.variant, action.gradient)
|
|
349
|
+
: { type: highlight ? "primary" : "default" }), size: buttonSize, ...(action.href ? { href: action.href, newTab: action.newTab, external: action.external } : {}), label: labels.actionLabel || undefined, ...(labels.actionLabel ? {} : { ariaLabel: action.ariaLabel }), ...(action.icon ? { icon: _jsx(PhiIcon, { name: action.icon, size: "1em" }) } : {}), ...(activates ? { onClick: () => controlSignals.emitCapability("activate", null) } : {}) }) })) : null;
|
|
321
350
|
/*
|
|
322
351
|
* The band in the card's top end corner, floating (`PhiRibbonControl`): the words below it start where
|
|
323
352
|
* they start in a card without one, so plans side by side keep their headings on one line.
|
|
324
353
|
*/
|
|
325
354
|
const badgeStyle = config?.badgeStyle ?? "none";
|
|
326
|
-
const ribbon = badge != null && (badgeStyle === "corner" || badgeStyle === "tag") ? (_jsx(PhiRibbonControl, { color: config?.badgeColor, placement: badgeStyle === "tag" ? "edge" : "corner", ...(!renderText && labels.badge
|
|
355
|
+
const ribbon = badge != null && (badgeStyle === "corner" || badgeStyle === "tag") ? (_jsx(PhiRibbonControl, { color: config?.badgeColor, ...(config?.badgeGradient ? { gradient: config.badgeGradient } : {}), placement: badgeStyle === "tag" ? "edge" : "corner", ...(!renderText && labels.badge
|
|
327
356
|
? {
|
|
328
357
|
fullText: labels.badge,
|
|
329
358
|
...(href
|
|
@@ -351,5 +380,5 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
351
380
|
* A ribbon hangs over the card's edge, which the card -- clipping for its picture and its zoom -- cannot
|
|
352
381
|
* give a child of its own; it wraps the card instead (`PhiRibbonWrapControl`). An editor writes in it.
|
|
353
382
|
*/
|
|
354
|
-
return badge != null && badgeStyle === "ribbon" ? (_jsx(PhiRibbonWrapControl, { text: badge, ...(config?.badgeColor ? { color: config.badgeColor } : {}), interactive: renderText != null, className: hoverEffect === "lift" ? "phi-card-ribbon phi-card-ribbon--lift" : "phi-card-ribbon", children: card })) : card;
|
|
383
|
+
return badge != null && badgeStyle === "ribbon" ? (_jsx(PhiRibbonWrapControl, { text: badge, ...(config?.badgeColor ? { color: config.badgeColor } : {}), ...(config?.badgeGradient ? { gradient: config.badgeGradient } : {}), interactive: renderText != null, className: hoverEffect === "lift" ? "phi-card-ribbon phi-card-ribbon--lift" : "phi-card-ribbon", children: card })) : card;
|
|
355
384
|
}
|
|
@@ -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
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PhiRuntimeModuleDataProviderDescriptor } from "../../../types/cms-plugins";
|
|
2
|
+
import type { PhiProviderResourceSource, PhiRuntimeDataProviderKey } from "../../../types/runtime-data-provider";
|
|
3
|
+
export declare const PhiCollectionSourceFailureText: {
|
|
4
|
+
readonly notConfigured: () => string;
|
|
5
|
+
readonly providerUnavailable: (providerKey: string) => string;
|
|
6
|
+
readonly resourceUnavailable: (resourceKey: string, providerKey: string) => string;
|
|
7
|
+
readonly rendererUnavailable: (rendererKey: string) => string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Why a Collection View cannot draw, as far as that is known without asking the source anything.
|
|
11
|
+
*
|
|
12
|
+
* This is what the Builder can say: it never reads the data, so a read that would fail is not its to
|
|
13
|
+
* find out, but a binding to a provider no active Module declares, a resource that provider does not
|
|
14
|
+
* have, or an item renderer nobody offers is plain from the declarations alone.
|
|
15
|
+
*
|
|
16
|
+
* `itemRendererKeys` is the set of renderers the Area's Modules declare, or null where the caller does
|
|
17
|
+
* not have it -- and then a renderer the configuration names is not judged at all rather than judged
|
|
18
|
+
* against nothing. The renderer a resource ships with is never judged: it belongs to the provider just
|
|
19
|
+
* found active.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readPhiCollectionViewDeclaredFailure({ source, itemRendererKey, dataProviderDescriptorsByKey, itemRendererKeys, }: {
|
|
22
|
+
source: PhiProviderResourceSource | null | undefined;
|
|
23
|
+
itemRendererKey: string | null | undefined;
|
|
24
|
+
dataProviderDescriptorsByKey: ReadonlyMap<PhiRuntimeDataProviderKey, PhiRuntimeModuleDataProviderDescriptor>;
|
|
25
|
+
itemRendererKeys: ReadonlySet<string> | null;
|
|
26
|
+
}): string | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* What a Collection binding that does not hold says, in one wording wherever it is found out: by the
|
|
3
|
+
* live binding against the providers the Area mounted, and by the Builder against the descriptors the
|
|
4
|
+
* Area's Modules declare. An author who reads one in the Builder finds the same line in the log of the
|
|
5
|
+
* live page.
|
|
6
|
+
*/
|
|
7
|
+
export const PhiCollectionSourceFailureText = {
|
|
8
|
+
notConfigured: () => "Collection data provider is not configured.",
|
|
9
|
+
providerUnavailable: (providerKey) => `Collection provider "${providerKey}" is not available from the active runtime modules.`,
|
|
10
|
+
resourceUnavailable: (resourceKey, providerKey) => `Collection resource "${resourceKey}" is not available from provider "${providerKey}".`,
|
|
11
|
+
rendererUnavailable: (rendererKey) => `Item renderer "${rendererKey}" is not available from the active runtime modules.`,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Why a Collection View cannot draw, as far as that is known without asking the source anything.
|
|
15
|
+
*
|
|
16
|
+
* This is what the Builder can say: it never reads the data, so a read that would fail is not its to
|
|
17
|
+
* find out, but a binding to a provider no active Module declares, a resource that provider does not
|
|
18
|
+
* have, or an item renderer nobody offers is plain from the declarations alone.
|
|
19
|
+
*
|
|
20
|
+
* `itemRendererKeys` is the set of renderers the Area's Modules declare, or null where the caller does
|
|
21
|
+
* not have it -- and then a renderer the configuration names is not judged at all rather than judged
|
|
22
|
+
* against nothing. The renderer a resource ships with is never judged: it belongs to the provider just
|
|
23
|
+
* found active.
|
|
24
|
+
*/
|
|
25
|
+
export function readPhiCollectionViewDeclaredFailure({ source, itemRendererKey, dataProviderDescriptorsByKey, itemRendererKeys, }) {
|
|
26
|
+
if (!source) {
|
|
27
|
+
return PhiCollectionSourceFailureText.notConfigured();
|
|
28
|
+
}
|
|
29
|
+
const descriptor = dataProviderDescriptorsByKey.get(source.providerKey);
|
|
30
|
+
if (!descriptor || descriptor.kind !== "collection") {
|
|
31
|
+
return PhiCollectionSourceFailureText.providerUnavailable(source.providerKey);
|
|
32
|
+
}
|
|
33
|
+
const resource = descriptor.resources.find((entry) => entry.resourceKey === source.resourceKey);
|
|
34
|
+
if (!resource) {
|
|
35
|
+
return PhiCollectionSourceFailureText.resourceUnavailable(source.resourceKey, source.providerKey);
|
|
36
|
+
}
|
|
37
|
+
if (itemRendererKey && itemRendererKey !== resource.itemRendererKey && itemRendererKeys &&
|
|
38
|
+
!itemRendererKeys.has(itemRendererKey)) {
|
|
39
|
+
return PhiCollectionSourceFailureText.rendererUnavailable(itemRendererKey);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
@@ -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;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Fragment, useEffect, useMemo } from "react";
|
|
3
|
+
import { Fragment, useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { PhiProtectedMailText } from "../../navigation/use-phi-protected-mail";
|
|
4
5
|
import { PhiLink } from "../../navigation/phi-link";
|
|
5
6
|
import { PHI_SIGNAL_VALUE_SCHEMAS } from "../../../types/signals";
|
|
6
7
|
import { usePhiSignalEmitter } from "../../runtime/runtime-signal-identity";
|
|
@@ -11,6 +12,10 @@ import { PhiPlainTable } from "../../tables/phi-plain-table";
|
|
|
11
12
|
import { PhiTypographyControl } from "../../controls/phi-typography-control";
|
|
12
13
|
import { PhiDividerControl } from "../../controls/phi-divider-control";
|
|
13
14
|
import { PhiBulletListControl } from "../../controls/phi-bullet-list-control";
|
|
15
|
+
import { PhiImageControl } from "../../controls/phi-image-control";
|
|
16
|
+
import { PhiCollapseControl } from "../../controls/phi-collapse-control";
|
|
17
|
+
import { resolvePhiMarkdownFoldLevel, splitPhiMarkdownSegments, } from "./markdown-sections";
|
|
18
|
+
import { resolvePhiMarkdownFigureSizes } from "./markdown-image-vocabulary";
|
|
14
19
|
import { resolvePhiBulletListStyle, } from "./bullet-list-vocabulary";
|
|
15
20
|
/**
|
|
16
21
|
* The colour a kind of code is drawn in, from the Theme and from nowhere else.
|
|
@@ -51,6 +56,8 @@ function renderInlineNodes(inlines) {
|
|
|
51
56
|
switch (inline.kind) {
|
|
52
57
|
case "text":
|
|
53
58
|
return _jsx(Fragment, { children: inline.text }, key);
|
|
59
|
+
case "mail_text":
|
|
60
|
+
return _jsx(PhiProtectedMailText, { token: inline.token }, key);
|
|
54
61
|
case "strong":
|
|
55
62
|
return _jsx("strong", { children: renderInlineNodes(inline.children) }, key);
|
|
56
63
|
case "emphasis":
|
|
@@ -83,6 +90,8 @@ function renderBlocks(blocks, token, paragraphStyle, headingStyle, lists, atStar
|
|
|
83
90
|
return (_jsx(PhiTypographyControl, { presentation: "title", id: block.id, level: block.level, style: headingBlockStyle, children: renderInlineNodes(block.inlines) }, key));
|
|
84
91
|
case "paragraph":
|
|
85
92
|
return (_jsx(PhiTypographyControl, { presentation: "paragraph", style: paragraphBlockStyle, children: renderInlineNodes(block.inlines) }, key));
|
|
93
|
+
case "image":
|
|
94
|
+
return _jsx(PhiMarkdownFigureBlock, { figure: block.image }, key);
|
|
86
95
|
case "blockquote":
|
|
87
96
|
return (_jsx("blockquote", { style: {
|
|
88
97
|
margin: 0,
|
|
@@ -186,6 +195,7 @@ export function PhiMarkdownWidgetClient({ config }) {
|
|
|
186
195
|
paddingBlockStart: resolvePhiSpacingScaleValue(config?.headingBlockSpacingBefore ?? "sm"),
|
|
187
196
|
marginBlockEnd: resolvePhiSpacingScaleValue(config?.headingBlockSpacingAfter ?? "sm"),
|
|
188
197
|
};
|
|
198
|
+
const lists = { style: resolvePhiBulletListStyle(config?.list), depth: 1 };
|
|
189
199
|
return (_jsx("div", { className: config?.imageFloat
|
|
190
200
|
? `phi-markdown-text phi-markdown-body phi-markdown-body--float-${config.imageFloat}`
|
|
191
201
|
: "phi-markdown-text",
|
|
@@ -193,8 +203,53 @@ export function PhiMarkdownWidgetClient({ config }) {
|
|
|
193
203
|
// browser's `normal`, and its marker centres on a line shorter than the one its words stand on.
|
|
194
204
|
style: config?.imageFloat
|
|
195
205
|
? { display: "flow-root", width: "100%", textAlign: config.textAlign, containerType: "inline-size", lineHeight: token.lineHeight }
|
|
196
|
-
: { display: "grid", gap: 0, width: "100%", textAlign: config?.textAlign, lineHeight: token.lineHeight }, children:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
206
|
+
: { display: "grid", gap: 0, width: "100%", textAlign: config?.textAlign, lineHeight: token.lineHeight }, children: config?.foldSections && config.foldSections !== "none"
|
|
207
|
+
? splitPhiMarkdownSegments(blocks, resolvePhiMarkdownFoldLevel(config.headingOffset)).map((segment, index) => segment.kind === "text"
|
|
208
|
+
? _jsx(Fragment, { children: renderBlocks(segment.blocks, token, paragraphBlockStyle, headingBlockStyle, lists, index === 0) }, `text-${index}`)
|
|
209
|
+
: (_jsx(PhiMarkdownFoldedSections, { sections: segment.sections, accordion: config.foldSections === "accordion", renderBody: (sectionBlocks) => renderBlocks(sectionBlocks, token, paragraphBlockStyle, headingBlockStyle, lists, true) }, `sections-${index}`)))
|
|
210
|
+
: renderBlocks(blocks, token, paragraphBlockStyle, headingBlockStyle, lists, true) }));
|
|
211
|
+
}
|
|
212
|
+
/*
|
|
213
|
+
* The sections that fold: each heading is a header, what follows it the body. Every answer is drawn even
|
|
214
|
+
* while folded, so a search engine and the browser's own find read the whole text. A heading keeps its id,
|
|
215
|
+
* so the table of contents and a link to `#that-question` reach it -- and a link to it opens it, on arrival
|
|
216
|
+
* and whenever the address's fragment changes.
|
|
217
|
+
*/
|
|
218
|
+
function PhiMarkdownFoldedSections({ sections, accordion, renderBody, }) {
|
|
219
|
+
const [openKeys, setOpenKeys] = useState([]);
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
const openFromAddress = () => {
|
|
222
|
+
const id = decodeURIComponent(window.location.hash.slice(1));
|
|
223
|
+
if (!id)
|
|
224
|
+
return;
|
|
225
|
+
const section = sections.find((entry) => entry.heading.id === id || entry.blocks.some((block) => block.kind === "heading" && block.id === id));
|
|
226
|
+
if (!section)
|
|
227
|
+
return;
|
|
228
|
+
setOpenKeys((current) => accordion ? [section.heading.id] : [...new Set([...current, section.heading.id])]);
|
|
229
|
+
window.requestAnimationFrame(() => document.getElementById(id)?.scrollIntoView({ block: "start" }));
|
|
230
|
+
};
|
|
231
|
+
openFromAddress();
|
|
232
|
+
window.addEventListener("hashchange", openFromAddress);
|
|
233
|
+
return () => window.removeEventListener("hashchange", openFromAddress);
|
|
234
|
+
}, [accordion, sections]);
|
|
235
|
+
return (_jsx("div", { className: "phi-markdown-folds", children: _jsx(PhiCollapseControl, { sections: sections.map((section) => ({
|
|
236
|
+
key: section.heading.id,
|
|
237
|
+
label: (_jsx(PhiTypographyControl, { presentation: "title", id: section.heading.id, level: section.heading.level, style: { margin: 0 }, children: renderInlineNodes(section.heading.inlines) })),
|
|
238
|
+
children: renderBody(section.blocks),
|
|
239
|
+
forceRender: true,
|
|
240
|
+
})), openKeys: openKeys, onOpenKeysChange: setOpenKeys, accordion: accordion,
|
|
241
|
+
// A question is answered wherever its row is clicked, not only on its words.
|
|
242
|
+
collapsible: "row", ghost: true, expandIconPlacement: "end",
|
|
243
|
+
// Flush with the text around them: a question starts where a paragraph starts.
|
|
244
|
+
headerPadding: `${PHI_SPACE.sm} 0`, bodyPadding: `0 0 ${PHI_SPACE.sm}` }) }));
|
|
245
|
+
}
|
|
246
|
+
/*
|
|
247
|
+
* A picture standing on its own: a figure, so it is a block between the paragraphs and never a box inside
|
|
248
|
+
* one. The box is reserved from the start -- the chosen proportion, else the picture's own -- so the text
|
|
249
|
+
* does not jump when the bytes arrive, and its corners are the Theme's surface step (`styles/controls.css`).
|
|
250
|
+
*/
|
|
251
|
+
function PhiMarkdownFigureBlock({ figure }) {
|
|
252
|
+
const { presentation } = figure;
|
|
253
|
+
const ownRatio = presentation.width && presentation.height ? `${presentation.width} / ${presentation.height}` : undefined;
|
|
254
|
+
return (_jsx("figure", { className: `phi-markdown-figure phi-markdown-figure--float-${figure.float}`, children: _jsx("div", { className: "phi-markdown-figure__frame", style: { aspectRatio: figure.aspectRatio ?? ownRatio }, children: _jsx(PhiImageControl, { presentation: presentation, source: "asset", alt: figure.alt, title: figure.title, blurDataUrl: figure.blurDataUrl, optimizable: figure.optimizable, sizes: resolvePhiMarkdownFigureSizes(figure.float), style: { width: "100%", height: "100%" }, imageStyle: { width: "100%", height: "100%" } }) }) }));
|
|
200
255
|
}
|