@phis/ui 0.4.4 → 0.4.5
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 +30 -1
- 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 +13 -1
- package/components/controls/phi-button-control.js +21 -3
- package/components/controls/phi-dropdown-control.js +2 -2
- package/components/controls/phi-media-asset-tile-control.js +10 -10
- 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/phi-layout-view-model.js +10 -1
- package/components/regions/clients/cms-region-container-client.js +11 -1
- package/components/regions/phi-cms-region-container.js +5 -1
- package/components/regions/phi-cms-region-shell.d.ts +10 -0
- package/components/regions/phi-cms-region-shell.js +53 -7
- 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 +7 -1
- package/components/shell/phi-cms-shell.js +4 -2
- 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/label-sets/background.js +2 -0
- package/components/widgets/label-sets/geometry.js +2 -0
- package/components/widgets/label-sets/inspector.js +4 -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 +4 -0
- package/components/widgets/label-types/inspector.js +2 -0
- package/components/widgets/shared/card-body-client.d.ts +11 -0
- package/components/widgets/shared/card-body-client.js +32 -4
- 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-render.js +16 -3
- 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/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/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 +1 -1
- 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 +47 -2
- 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 +94 -0
- package/plugins/runtime-modules/core/widgets/card/config.js +38 -0
- package/plugins/runtime-modules/core/widgets/card/editor.js +8 -1
- package/plugins/runtime-modules/core/widgets/card/server.js +4 -0
- 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/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/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/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 +10 -5
- package/styles/gradients.css +101 -0
- package/styles/root.css +18 -0
- package/styles/shell.css +64 -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/types/cms-presets.d.ts +7 -0
- package/types/core-widget-placements.d.ts +3 -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,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;
|
|
@@ -74,6 +79,8 @@ export type PhiCardWidgetClientConfig = {
|
|
|
74
79
|
badgeColor?: string;
|
|
75
80
|
/** How the badge is drawn; absent, `none`. */
|
|
76
81
|
badgeStyle?: PhiCardBadgeStyle;
|
|
82
|
+
/** A Theme gradient slot the badge is filled with, over `badgeColor`. */
|
|
83
|
+
badgeGradient?: PhiThemeGradientKey;
|
|
77
84
|
/** Which price a `plan` shows until a `billingPeriod` signal says otherwise. Absent is `monthly`. */
|
|
78
85
|
billingPeriod?: PhiCardBillingPeriod;
|
|
79
86
|
hoverEffect?: PhiCardHoverEffect;
|
|
@@ -87,6 +94,10 @@ export type PhiCardWidgetAction = {
|
|
|
87
94
|
icon?: string;
|
|
88
95
|
/** The button's name where it shows only its icon. */
|
|
89
96
|
ariaLabel?: string;
|
|
97
|
+
/** How it stands out; absent, primary on a highlighted card and normal otherwise. */
|
|
98
|
+
variant?: PhiButtonVariant;
|
|
99
|
+
/** The Theme gradient slot a `gradient` button is filled with. */
|
|
100
|
+
gradient?: PhiThemeGradientKey;
|
|
90
101
|
};
|
|
91
102
|
export type PhiCardWidgetClientProps = PhiClientBlockBaseProps<PhiCardWidgetClientLabels, PhiCardWidgetClientConfig> & {
|
|
92
103
|
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";
|
|
@@ -19,6 +21,25 @@ import { usePhiControlSignalController } from "../client/shared/phi-control-sign
|
|
|
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
23
|
import { 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
|
|
@@ -267,7 +288,12 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
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,
|
|
@@ -317,13 +343,15 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
317
343
|
const footAction = body === "plan" && action != null;
|
|
318
344
|
const actionButton = action ? (_jsx("div", { className: "phi-card__action",
|
|
319
345
|
/* 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, {
|
|
346
|
+
style: footAction ? { marginTop: "auto", alignSelf: textAlign === "center" ? "center" : textAlign === "end" ? "flex-end" : "flex-start" } : undefined, children: _jsx(PhiButtonControl, { ...(action.variant
|
|
347
|
+
? resolvePhiButtonVariantPresentation(action.variant, action.gradient)
|
|
348
|
+
: { 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
349
|
/*
|
|
322
350
|
* The band in the card's top end corner, floating (`PhiRibbonControl`): the words below it start where
|
|
323
351
|
* they start in a card without one, so plans side by side keep their headings on one line.
|
|
324
352
|
*/
|
|
325
353
|
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
|
|
354
|
+
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
355
|
? {
|
|
328
356
|
fullText: labels.badge,
|
|
329
357
|
...(href
|
|
@@ -351,5 +379,5 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
351
379
|
* A ribbon hangs over the card's edge, which the card -- clipping for its picture and its zoom -- cannot
|
|
352
380
|
* give a child of its own; it wraps the card instead (`PhiRibbonWrapControl`). An editor writes in it.
|
|
353
381
|
*/
|
|
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;
|
|
382
|
+
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
383
|
}
|
|
@@ -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
|
+
}
|
|
@@ -77,11 +77,24 @@ function resolveExternalDocumentUrl(value, sourceUrl) {
|
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
/*
|
|
81
|
+
* The address a reader is sent to for the document the text was fetched from. GitHub serves a file's
|
|
82
|
+
* bytes on one host and its page on another; the bytes are what the Widget reads and what a picture
|
|
83
|
+
* needs, but a link in the text means the page -- a neighbouring document opened as raw text in a new
|
|
84
|
+
* tab is the source, not the document. Any other host is its own page.
|
|
85
|
+
*/
|
|
86
|
+
function readExternalDocumentPageUrl(sourceUrl) {
|
|
87
|
+
const githubRawMatch = sourceUrl.match(/^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)\/(.+)$/u);
|
|
88
|
+
if (!githubRawMatch)
|
|
89
|
+
return sourceUrl;
|
|
90
|
+
const [, owner, repo, ref, path] = githubRawMatch;
|
|
91
|
+
return `https://github.com/${owner}/${repo}/blob/${ref}/${path}`;
|
|
92
|
+
}
|
|
93
|
+
function projectExternalMarkdownNodes(nodes, sourceUrl, pageUrl = readExternalDocumentPageUrl(sourceUrl)) {
|
|
81
94
|
return (nodes ?? []).flatMap((node) => {
|
|
82
|
-
const children = projectExternalMarkdownNodes(node.children, sourceUrl);
|
|
95
|
+
const children = projectExternalMarkdownNodes(node.children, sourceUrl, pageUrl);
|
|
83
96
|
if (node.type === "link") {
|
|
84
|
-
const url = resolveExternalDocumentUrl(node.url ?? "",
|
|
97
|
+
const url = resolveExternalDocumentUrl(node.url ?? "", pageUrl);
|
|
85
98
|
return url ? [{ ...node, url, children }] : children;
|
|
86
99
|
}
|
|
87
100
|
if (node.type === "image") {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PhiWidgetFailureProps } from "./widget-failure";
|
|
2
|
+
/**
|
|
3
|
+
* A Widget's data or configuration failure, found in the browser -- a Provider the Area does not offer,
|
|
4
|
+
* a read that failed after hydration.
|
|
5
|
+
*
|
|
6
|
+
* The warning is written from an effect, once for each distinct failure while the Widget stays mounted:
|
|
7
|
+
* a Client re-renders for reasons that have nothing to do with the failure, and a line per render would
|
|
8
|
+
* bury the one that matters. See `PhiWidgetFailureProps` for what counts and who sees it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function PhiWidgetFailure(props: PhiWidgetFailureProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useEffectEvent } from "react";
|
|
3
|
+
import { logPhiWidgetFailure, renderPhiWidgetFailureNotice } from "./widget-failure";
|
|
4
|
+
/**
|
|
5
|
+
* A Widget's data or configuration failure, found in the browser -- a Provider the Area does not offer,
|
|
6
|
+
* a read that failed after hydration.
|
|
7
|
+
*
|
|
8
|
+
* The warning is written from an effect, once for each distinct failure while the Widget stays mounted:
|
|
9
|
+
* a Client re-renders for reasons that have nothing to do with the failure, and a line per render would
|
|
10
|
+
* bury the one that matters. See `PhiWidgetFailureProps` for what counts and who sees it.
|
|
11
|
+
*/
|
|
12
|
+
export function PhiWidgetFailure(props) {
|
|
13
|
+
const { renderMode, widgetType, widgetId, title, description } = props;
|
|
14
|
+
// `error` is read, not watched: it is a new object whenever the same failure is raised again.
|
|
15
|
+
const log = useEffectEvent(() => logPhiWidgetFailure(props));
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
log();
|
|
18
|
+
}, [description, renderMode, title, widgetId, widgetType]);
|
|
19
|
+
return renderPhiWidgetFailureNotice(props);
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PhiCmsInstanceId } from "../../../types/cms-instance-id";
|
|
2
|
+
import type { PhiRenderableBlockRenderMode } from "../../../types/renderable-block";
|
|
3
|
+
/**
|
|
4
|
+
* A Widget that cannot show what it was placed to show, because its data or its configuration failed:
|
|
5
|
+
* the Provider it is bound to is not offered, the binding does not hold, the record cannot be read, the
|
|
6
|
+
* renderer it names is gone, the read itself failed.
|
|
7
|
+
*
|
|
8
|
+
* Said to the person who can do something about it, as the renderer says an unrenderable block
|
|
9
|
+
* (`renderCmsDiagnostic`). In the Builder that is the author, and the card stands in the Widget's own
|
|
10
|
+
* place with the cause. On a live page -- a revision preview is one -- it is nobody: a visitor cannot
|
|
11
|
+
* rebind a Provider, and a heading over an error, or over an empty frame, reads as a broken Site or as
|
|
12
|
+
* one that published nothing. So the Widget is absent and the rest of the page stands. The warning is
|
|
13
|
+
* written either way, which is where an operator finds it.
|
|
14
|
+
*
|
|
15
|
+
* What a visitor is meant to read -- a form's own answer, an empty state, a refusal addressed to them --
|
|
16
|
+
* is content, not a failure, and does not come here.
|
|
17
|
+
*/
|
|
18
|
+
export type PhiWidgetFailureProps = {
|
|
19
|
+
renderMode: PhiRenderableBlockRenderMode;
|
|
20
|
+
/** The Widget type, as the log names it; the card does not, the author already knows what they placed. */
|
|
21
|
+
widgetType: string;
|
|
22
|
+
widgetId?: PhiCmsInstanceId | null;
|
|
23
|
+
title: string;
|
|
24
|
+
description?: string | null;
|
|
25
|
+
/** What was thrown, for the log only; the card says `title` and `description`. */
|
|
26
|
+
error?: unknown;
|
|
27
|
+
};
|
|
28
|
+
export declare const PHI_WIDGET_FAILURE_LOG_EVENT = "cms.widget.unavailable";
|
|
29
|
+
export declare function logPhiWidgetFailure({ renderMode, widgetType, widgetId, title, description, error, }: PhiWidgetFailureProps): void;
|
|
30
|
+
/** The card itself, or nothing on a live page. Both variants draw through this, so they cannot drift. */
|
|
31
|
+
export declare function renderPhiWidgetFailureNotice({ renderMode, widgetType, widgetId, title, description, }: PhiWidgetFailureProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { logRuntimeEvent } from "../../../net/log";
|
|
3
|
+
import { PhiAlertControl } from "../../controls/phi-alert-control";
|
|
4
|
+
export const PHI_WIDGET_FAILURE_LOG_EVENT = "cms.widget.unavailable";
|
|
5
|
+
export function logPhiWidgetFailure({ renderMode, widgetType, widgetId, title, description, error, }) {
|
|
6
|
+
logRuntimeEvent("warn", PHI_WIDGET_FAILURE_LOG_EVENT, {
|
|
7
|
+
message: `Widget "${widgetType}" is unavailable: ${title}${description ? ` ${description}` : ""}`,
|
|
8
|
+
targetType: "widget",
|
|
9
|
+
targetId: widgetId == null ? null : String(widgetId),
|
|
10
|
+
error,
|
|
11
|
+
meta: { widgetType, title, description: description ?? null, renderMode },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/** The card itself, or nothing on a live page. Both variants draw through this, so they cannot drift. */
|
|
15
|
+
export function renderPhiWidgetFailureNotice({ renderMode, widgetType, widgetId, title, description, }) {
|
|
16
|
+
if (renderMode === "live") {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return (_jsx("div", { "data-phi-widget-failure": widgetType, "data-phi-widget-failure-id": widgetId == null ? undefined : String(widgetId), children: _jsx(PhiAlertControl, { level: "error", showIcon: true, title: title, description: description ?? undefined }) }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type PhiWidgetFailureProps } from "./widget-failure";
|
|
3
|
+
/**
|
|
4
|
+
* A Widget's data or configuration failure, decided while the page is drawn on the server.
|
|
5
|
+
*
|
|
6
|
+
* The warning is written here, during the render, because this render happens once per request and on
|
|
7
|
+
* the machine whose log an operator reads. See `PhiWidgetFailureProps` for what counts and who sees it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function PhiWidgetFailureServer(props: PhiWidgetFailureProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { logPhiWidgetFailure, renderPhiWidgetFailureNotice } from "./widget-failure";
|
|
3
|
+
/**
|
|
4
|
+
* A Widget's data or configuration failure, decided while the page is drawn on the server.
|
|
5
|
+
*
|
|
6
|
+
* The warning is written here, during the render, because this render happens once per request and on
|
|
7
|
+
* the machine whose log an operator reads. See `PhiWidgetFailureProps` for what counts and who sees it.
|
|
8
|
+
*/
|
|
9
|
+
export function PhiWidgetFailureServer(props) {
|
|
10
|
+
logPhiWidgetFailure(props);
|
|
11
|
+
return renderPhiWidgetFailureNotice(props);
|
|
12
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { PhiDashboardCardContext } from "../types/dashboard-cards";
|
|
3
|
+
export declare function definePhiDashboardCardRead<TResult>(load: (context: PhiDashboardCardContext) => Promise<TResult>): (context: PhiDashboardCardContext) => Promise<TResult>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
/*
|
|
3
|
+
* A read that several cards of one Dashboard ask for, done once for that Dashboard.
|
|
4
|
+
*
|
|
5
|
+
* The cards of a list request are resolved side by side in a Route Handler, which is outside a render,
|
|
6
|
+
* so `definePhiRequestMemo` (React's request scope) loads every time there. What they do share is the
|
|
7
|
+
* card context: the route resolves it once and hands the same object to every card it resolves. Keying
|
|
8
|
+
* by that object is the request scope a card has -- four cards reading one Add-on route make one call,
|
|
9
|
+
* and a card refreshed on its own gets a fresh context and so a fresh read. Nothing outlives the
|
|
10
|
+
* context, so nothing goes stale.
|
|
11
|
+
*
|
|
12
|
+
* `load` must answer from the context alone; anything else a card wants to vary belongs in its own call.
|
|
13
|
+
* A rejected load stays rejected for that context, so every card sharing the read reports the same error.
|
|
14
|
+
*/
|
|
15
|
+
export function definePhiDashboardCardRead(load) {
|
|
16
|
+
const reads = new WeakMap();
|
|
17
|
+
return (context) => {
|
|
18
|
+
let result = reads.get(context);
|
|
19
|
+
if (!result) {
|
|
20
|
+
result = load(context);
|
|
21
|
+
reads.set(context, result);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -33,5 +33,5 @@ export declare function resolvePhiCmsRegionOwnership(regionKey: string | null |
|
|
|
33
33
|
* know is not a placement anybody chose -- refusing it would hide Widgets over a typo.
|
|
34
34
|
*/
|
|
35
35
|
export declare function phiCmsRegionAcceptsWidget(regionKey: string | null | undefined, required: PhiCmsRegionOwnership | null | undefined): boolean;
|
|
36
|
-
export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 10 | 40 | 12 | 50 |
|
|
36
|
+
export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 11 | 10 | 40 | 12 | 50 | 20 | 21 | 25 | 30 | 39 | 41;
|
|
37
37
|
export declare function resolvePhiCmsRegionKey(regionType: number | null | undefined): "content" | "header_top" | "header_main" | "header_bottom" | "sider_left" | "sider_right" | "hero" | "footer_top" | "footer_main" | "footer_bottom" | "drawer_right" | undefined;
|
|
@@ -8,13 +8,17 @@ import { type PhiGlassLayoutEffectId, type PhiShadow } from "../types/layout-sty
|
|
|
8
8
|
* window that is dirty rather than glass that is lighter.
|
|
9
9
|
*/
|
|
10
10
|
export declare const PHI_GLASS_LAYOUT_EFFECT_DEFINITIONS: {
|
|
11
|
+
readonly clear: {
|
|
12
|
+
readonly filter: "blur(14px) saturate(1.6) brightness(1.08)";
|
|
13
|
+
readonly strengthPercent: 22;
|
|
14
|
+
};
|
|
11
15
|
readonly glass: {
|
|
12
|
-
readonly filter: "blur(
|
|
13
|
-
readonly strengthPercent:
|
|
16
|
+
readonly filter: "blur(28px) saturate(1.3)";
|
|
17
|
+
readonly strengthPercent: 34;
|
|
14
18
|
};
|
|
15
19
|
readonly haze: {
|
|
16
|
-
readonly filter: "blur(
|
|
17
|
-
readonly strengthPercent:
|
|
20
|
+
readonly filter: "blur(48px) saturate(1.2)";
|
|
21
|
+
readonly strengthPercent: 48;
|
|
18
22
|
};
|
|
19
23
|
};
|
|
20
24
|
export declare const PHI_SHADOW_DEFINITIONS: {
|
package/helpers/layout-style.js
CHANGED
|
@@ -8,8 +8,9 @@ import {} from "../types/layout-style";
|
|
|
8
8
|
* window that is dirty rather than glass that is lighter.
|
|
9
9
|
*/
|
|
10
10
|
export const PHI_GLASS_LAYOUT_EFFECT_DEFINITIONS = {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
clear: { filter: "blur(14px) saturate(1.6) brightness(1.08)", strengthPercent: 22 },
|
|
12
|
+
glass: { filter: "blur(28px) saturate(1.3)", strengthPercent: 34 },
|
|
13
|
+
haze: { filter: "blur(48px) saturate(1.2)", strengthPercent: 48 },
|
|
13
14
|
};
|
|
14
15
|
function resolvePhiGlassBackground(background, strengthPercent) {
|
|
15
16
|
const base = typeof background === "string" && background.trim()
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
/** One value per mode, as one CSS value the page's mode picks from. */
|
|
3
|
+
export declare function resolvePhiModeValue(light: string, dark: string): string;
|
|
4
|
+
export declare function composePhiModePaint(light: CSSProperties, dark: CSSProperties): CSSProperties;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A paint that differs between the page's light and dark mode, as one inline style.
|
|
3
|
+
*
|
|
4
|
+
* A Surface may state a ground per mode (`PhiSurface.backgroundDark`). The server does not know which
|
|
5
|
+
* mode a visitor sees, and the mode switch only turns `data-phi-theme-mode` on the Root Layout without
|
|
6
|
+
* rendering the page again, so the choice has to be made by CSS. Each property that differs is written
|
|
7
|
+
* as two gated values: `styles/root.css` sets one gate empty and the other to the guaranteed-invalid
|
|
8
|
+
* value, so `var(--phi-mode-light-gate, DARK) var(--phi-mode-dark-gate, LIGHT)` reads as `LIGHT` in light
|
|
9
|
+
* mode and `DARK` in dark mode. A fallback may hold commas, so a gradient or a list of layers passes.
|
|
10
|
+
*
|
|
11
|
+
* Where only one mode states a property, the other takes the property's neutral value, so the light
|
|
12
|
+
* picture does not stay behind a dark ground that brings none.
|
|
13
|
+
*/
|
|
14
|
+
const PHI_MODE_LIGHT_GATE = "--phi-mode-light-gate";
|
|
15
|
+
const PHI_MODE_DARK_GATE = "--phi-mode-dark-gate";
|
|
16
|
+
const PHI_MODE_PAINT_NEUTRAL = {
|
|
17
|
+
backgroundColor: "transparent",
|
|
18
|
+
backgroundImage: "none",
|
|
19
|
+
backgroundSize: "auto",
|
|
20
|
+
backgroundPosition: "0% 0%",
|
|
21
|
+
backgroundRepeat: "repeat",
|
|
22
|
+
backgroundAttachment: "scroll",
|
|
23
|
+
backdropFilter: "none",
|
|
24
|
+
WebkitBackdropFilter: "none",
|
|
25
|
+
boxShadow: "none",
|
|
26
|
+
filter: "none",
|
|
27
|
+
};
|
|
28
|
+
/** One value per mode, as one CSS value the page's mode picks from. */
|
|
29
|
+
export function resolvePhiModeValue(light, dark) {
|
|
30
|
+
return light === dark ? light : `var(${PHI_MODE_LIGHT_GATE}, ${dark}) var(${PHI_MODE_DARK_GATE}, ${light})`;
|
|
31
|
+
}
|
|
32
|
+
export function composePhiModePaint(light, dark) {
|
|
33
|
+
const style = {};
|
|
34
|
+
const keys = new Set([...Object.keys(light), ...Object.keys(dark)]);
|
|
35
|
+
for (const key of keys) {
|
|
36
|
+
const neutral = PHI_MODE_PAINT_NEUTRAL[key];
|
|
37
|
+
const lightValue = light[key] ?? neutral;
|
|
38
|
+
const darkValue = dark[key] ?? neutral;
|
|
39
|
+
if (lightValue == null || darkValue == null) {
|
|
40
|
+
// A property with no neutral value that only one mode states stays as that mode states it.
|
|
41
|
+
style[key] = lightValue ?? darkValue;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
style[key] = resolvePhiModeValue(String(lightValue), String(darkValue));
|
|
45
|
+
}
|
|
46
|
+
return style;
|
|
47
|
+
}
|
package/helpers/surface-style.js
CHANGED
|
@@ -2,6 +2,7 @@ import { PHI_BACKGROUND_CONTAINER_GROUND, normalizePhiBackgroundWidgetConfig, ph
|
|
|
2
2
|
import { resolvePhiCmsBorderSource } from "../types/cms-border-source";
|
|
3
3
|
import { resolvePhiSurfaceToneClassName } from "../types/surface";
|
|
4
4
|
import { resolvePhiSourcedBorderStyle } from "./border-widget-style";
|
|
5
|
+
import { composePhiModePaint, resolvePhiModeValue } from "./mode-paint";
|
|
5
6
|
import { combinePhiBoxShadows, resolvePhiShadow } from "./layout-style";
|
|
6
7
|
/** The ground a toned Surface paints where it states none: the container ground of the tone's mode. */
|
|
7
8
|
export const PHI_SURFACE_TONE_GROUND = PHI_BACKGROUND_CONTAINER_GROUND;
|
|
@@ -37,25 +38,45 @@ export function resolvePhiSurfaceStyle(surface, options = {}) {
|
|
|
37
38
|
return PHI_SURFACE_EMPTY;
|
|
38
39
|
}
|
|
39
40
|
const background = surface.background ? normalizePhiBackgroundWidgetConfig(surface.background) : null;
|
|
40
|
-
const paintsGround = phiBackgroundWidgetConfigPaintsGround(background);
|
|
41
|
-
const groundFilter = background ? resolvePhiBackgroundGroundFilter(background) : null;
|
|
42
41
|
const motion = background ? resolvePhiBackgroundMotion(background) : null;
|
|
42
|
+
/*
|
|
43
|
+
* The ground in dark mode, where the Surface states one. A moving picture is drawn by the motion layer
|
|
44
|
+
* from one Background and keeps it in both modes.
|
|
45
|
+
*/
|
|
46
|
+
const backgroundDark = surface.backgroundDark && motion == null
|
|
47
|
+
? normalizePhiBackgroundWidgetConfig(surface.backgroundDark)
|
|
48
|
+
: null;
|
|
49
|
+
const modes = backgroundDark ? [background, backgroundDark] : [background];
|
|
50
|
+
const paintsGround = modes.some((entry) => phiBackgroundWidgetConfigPaintsGround(entry));
|
|
51
|
+
const groundFilters = modes.map((entry) => (entry ? resolvePhiBackgroundGroundFilter(entry) : null));
|
|
43
52
|
/*
|
|
44
53
|
* The Theme's Overlay never goes on a layer: it is a window onto one viewport-sized painting, so there
|
|
45
54
|
* is nothing to move or zoom, and its pane has to frost the page behind the box rather than the box.
|
|
46
55
|
*/
|
|
47
56
|
const needsGroundLayer = options.groundLayer !== false
|
|
48
57
|
&& paintsGround
|
|
49
|
-
&&
|
|
50
|
-
&& (
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
? (
|
|
54
|
-
:
|
|
55
|
-
const
|
|
58
|
+
&& modes.some((entry) => entry != null && entry.base.kind !== "theme")
|
|
59
|
+
&& (groundFilters.some((filter) => filter != null) || motion != null || options.forceGroundLayer === true);
|
|
60
|
+
const paintOf = (entry) => (entry ? resolvePhiBackgroundWidgetStyle(entry) : {});
|
|
61
|
+
const hostPaintOf = (entry) => (needsGroundLayer
|
|
62
|
+
? (entry ? resolvePhiBackgroundMotionHostStyle(entry) : {})
|
|
63
|
+
: paintOf(entry));
|
|
64
|
+
const layerPaintOf = (entry) => (entry
|
|
65
|
+
? resolvePhiBackgroundWidgetStyle({ ...entry, filter: null, motion: null })
|
|
66
|
+
: {});
|
|
67
|
+
const paint = paintOf(background);
|
|
68
|
+
const hostPaint = backgroundDark
|
|
69
|
+
? composePhiModePaint(hostPaintOf(background), hostPaintOf(backgroundDark))
|
|
70
|
+
: hostPaintOf(background);
|
|
71
|
+
const groundFilter = backgroundDark && groundFilters[0] !== groundFilters[1]
|
|
72
|
+
? resolvePhiModeValue(groundFilters[0] ?? "none", groundFilters[1] ?? "none")
|
|
73
|
+
: groundFilters[0];
|
|
74
|
+
const ground = needsGroundLayer && (background || backgroundDark)
|
|
56
75
|
? {
|
|
57
|
-
paint:
|
|
58
|
-
|
|
76
|
+
paint: backgroundDark
|
|
77
|
+
? composePhiModePaint(layerPaintOf(background), layerPaintOf(backgroundDark))
|
|
78
|
+
: layerPaintOf(background),
|
|
79
|
+
filter: groundFilter ?? null,
|
|
59
80
|
motion: motion ? background : null,
|
|
60
81
|
}
|
|
61
82
|
: null;
|
|
@@ -94,6 +115,7 @@ export function phiSurfaceDrawsChrome(surface) {
|
|
|
94
115
|
return false;
|
|
95
116
|
}
|
|
96
117
|
return phiBackgroundWidgetConfigPaintsGround(surface.background ?? null)
|
|
118
|
+
|| phiBackgroundWidgetConfigPaintsGround(surface.backgroundDark ?? null)
|
|
97
119
|
|| (surface.tone != null && surface.tone !== "inherit")
|
|
98
120
|
|| resolvePhiCmsBorderSource(surface.borderSource, surface.border) !== "none"
|
|
99
121
|
|| (surface.shadow != null && surface.shadow !== "none");
|
|
@@ -13,3 +13,4 @@
|
|
|
13
13
|
import "server-only";
|
|
14
14
|
export { createPhiDashboardCardId, isPhiDashboardCardId, PHI_DASHBOARD_CARD_SERIES_LIMIT, type PhiDashboardCardContext, type PhiDashboardCardDescriptor, type PhiDashboardCardForm, type PhiDashboardCardId, type PhiDashboardCardPayload, type PhiDashboardCardProvider, type PhiDashboardCardSeries, type PhiDashboardCardSeriesPoint, } from "./types/dashboard-cards";
|
|
15
15
|
export { fetchPhiSiteApi, type PhiSiteApiRequest } from "./gateway/site-api-request";
|
|
16
|
+
export { definePhiDashboardCardRead } from "./gateway/dashboard-card-memo";
|
|
@@ -13,3 +13,4 @@
|
|
|
13
13
|
import "server-only";
|
|
14
14
|
export { createPhiDashboardCardId, isPhiDashboardCardId, PHI_DASHBOARD_CARD_SERIES_LIMIT, } from "./types/dashboard-cards";
|
|
15
15
|
export { fetchPhiSiteApi } from "./gateway/site-api-request";
|
|
16
|
+
export { definePhiDashboardCardRead } from "./gateway/dashboard-card-memo";
|
package/module-records.d.ts
CHANGED
|
@@ -7,8 +7,15 @@
|
|
|
7
7
|
* types say what it is asked with, `fetchPhiSiteApi` asks Core with the credentials the context carries,
|
|
8
8
|
* and `resolvePhiRecordSource` is how one of the package's Server Widgets reads the record its binding
|
|
9
9
|
* names -- once per request, however many Widgets are bound to it.
|
|
10
|
+
*
|
|
11
|
+
* `PhiWidgetFailureServer` is what such a Widget renders when that read, or its binding, fails: the error
|
|
12
|
+
* card in the Builder, nothing on a live page, and the `cms.widget.unavailable` warning either way. It is
|
|
13
|
+
* here rather than in a shared barrel because it is Server-only; its browser twin, `PhiWidgetFailure`, is
|
|
14
|
+
* in `@phis/ui/runtime/data-provider-client`.
|
|
10
15
|
*/
|
|
11
16
|
import "server-only";
|
|
12
17
|
export type { PhiRuntimeModuleRecordProviderServerDefinition, PhiRuntimeRecordProviderContext, PhiRuntimeRecordProviderResolver, } from "./types/record-provider";
|
|
13
18
|
export { resolvePhiRecordSource, type PhiRecordSourceResult } from "./server-helpers/record-source";
|
|
14
19
|
export { fetchPhiSiteApi, type PhiSiteApiRequest } from "./gateway/site-api-request";
|
|
20
|
+
export { PhiWidgetFailureServer } from "./components/widgets/shared/widget-failure.server";
|
|
21
|
+
export type { PhiWidgetFailureProps } from "./components/widgets/shared/widget-failure";
|
package/module-records.js
CHANGED
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
* types say what it is asked with, `fetchPhiSiteApi` asks Core with the credentials the context carries,
|
|
8
8
|
* and `resolvePhiRecordSource` is how one of the package's Server Widgets reads the record its binding
|
|
9
9
|
* names -- once per request, however many Widgets are bound to it.
|
|
10
|
+
*
|
|
11
|
+
* `PhiWidgetFailureServer` is what such a Widget renders when that read, or its binding, fails: the error
|
|
12
|
+
* card in the Builder, nothing on a live page, and the `cms.widget.unavailable` warning either way. It is
|
|
13
|
+
* here rather than in a shared barrel because it is Server-only; its browser twin, `PhiWidgetFailure`, is
|
|
14
|
+
* in `@phis/ui/runtime/data-provider-client`.
|
|
10
15
|
*/
|
|
11
16
|
import "server-only";
|
|
12
17
|
export { resolvePhiRecordSource } from "./server-helpers/record-source";
|
|
13
18
|
export { fetchPhiSiteApi } from "./gateway/site-api-request";
|
|
19
|
+
export { PhiWidgetFailureServer } from "./components/widgets/shared/widget-failure.server";
|
package/package.json
CHANGED
|
@@ -719,7 +719,7 @@ function renderPhiInspectorConfigFieldBody({ field, value, defaultValue, config,
|
|
|
719
719
|
if (field.type === "surface") {
|
|
720
720
|
return renderPhiInspectorConfigFieldBlock(field, _jsx(PhiSurfaceControl, { disabled: disabled || !onChange, value: value === null ? null : readPhiSurface(value) ?? readPhiSurface(defaultValue), tone: field.tone !== false,
|
|
721
721
|
// A box inside a Widget has no layer of its own to blur.
|
|
722
|
-
backgroundFilters: ["glass", "haze"], backgroundLabels: backgroundLabels, borderLabels: borderLabels, colorPickerLabels: colorPickerLabels, renderMediaPicker: renderMediaPicker, onChange: (nextValue) => onChange?.({ [field.key]: nextValue }) }));
|
|
722
|
+
backgroundFilters: ["glass", "haze", "clear"], backgroundLabels: backgroundLabels, borderLabels: borderLabels, colorPickerLabels: colorPickerLabels, renderMediaPicker: renderMediaPicker, onChange: (nextValue) => onChange?.({ [field.key]: nextValue }) }));
|
|
723
723
|
}
|
|
724
724
|
if (field.type === "icon") {
|
|
725
725
|
const iconValue = typeof value === "string"
|