@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
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Scrambles `value` -- a whole `mailto:` href or a bare address -- into a `phi-mail:` string. */
|
|
2
|
+
export declare function encodePhiProtectedMail(value: string): string;
|
|
3
|
+
export declare function isPhiProtectedMail(value: string | null | undefined): value is string;
|
|
4
|
+
/** The value `encodePhiProtectedMail` was given, or `null` for anything it did not write. */
|
|
5
|
+
export declare function decodePhiProtectedMail(value: string): string | null;
|
|
6
|
+
/** A `mailto:` href protected; every other href as it is. */
|
|
7
|
+
export declare function protectPhiMailHref<T extends string | null | undefined>(href: T): T | string;
|
|
8
|
+
export type PhiMailTextSegment = {
|
|
9
|
+
kind: "text";
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "mail";
|
|
13
|
+
token: string;
|
|
14
|
+
};
|
|
15
|
+
/** A text cut where it names an address, each address protected; one text segment when it names none. */
|
|
16
|
+
export declare function splitPhiMailAddresses(text: string): PhiMailTextSegment[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An e-mail address kept out of the page's source, for crawlers that harvest them.
|
|
3
|
+
*
|
|
4
|
+
* A crawler reads the HTML and the React payload beside it and runs no script; a reader's browser runs
|
|
5
|
+
* one. So the server writes an address as `phi-mail:` and a scrambled hex string, and the client turns it
|
|
6
|
+
* back into the address after the page has mounted (`components/navigation/use-phi-protected-mail.ts`).
|
|
7
|
+
* It is obfuscation, not secrecy: anybody who runs the page sees the address, which is the point.
|
|
8
|
+
*
|
|
9
|
+
* **Only where a page is delivered.** A stored config keeps `mailto:` as the operator wrote it -- the
|
|
10
|
+
* Builder shows the field it edits -- and the server renderer protects it on the way out. A value that
|
|
11
|
+
* only ever reaches the client as data, a table's rows, is beyond this: the rows are in the payload.
|
|
12
|
+
*
|
|
13
|
+
* The key is derived from the address, not drawn at random, so the server and a client render of the same
|
|
14
|
+
* value write the same string and hydration agrees.
|
|
15
|
+
*/
|
|
16
|
+
const PHI_PROTECTED_MAIL_PREFIX = "phi-mail:";
|
|
17
|
+
const PHI_MAIL_ADDRESS_PATTERN = /[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/gu;
|
|
18
|
+
function derivePhiMailKey(value) {
|
|
19
|
+
let hash = 0x811c9dc5;
|
|
20
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
21
|
+
hash = Math.imul(hash ^ value.charCodeAt(index), 0x01000193) >>> 0;
|
|
22
|
+
}
|
|
23
|
+
return (hash % 255) + 1;
|
|
24
|
+
}
|
|
25
|
+
function toHex(byte) {
|
|
26
|
+
return byte.toString(16).padStart(2, "0");
|
|
27
|
+
}
|
|
28
|
+
/** Scrambles `value` -- a whole `mailto:` href or a bare address -- into a `phi-mail:` string. */
|
|
29
|
+
export function encodePhiProtectedMail(value) {
|
|
30
|
+
const key = derivePhiMailKey(value);
|
|
31
|
+
const bytes = new TextEncoder().encode(value);
|
|
32
|
+
let hex = toHex(key);
|
|
33
|
+
bytes.forEach((byte, index) => {
|
|
34
|
+
hex += toHex(byte ^ ((key + index * 31) & 0xff));
|
|
35
|
+
});
|
|
36
|
+
return `${PHI_PROTECTED_MAIL_PREFIX}${hex}`;
|
|
37
|
+
}
|
|
38
|
+
export function isPhiProtectedMail(value) {
|
|
39
|
+
return typeof value === "string" && value.startsWith(PHI_PROTECTED_MAIL_PREFIX);
|
|
40
|
+
}
|
|
41
|
+
/** The value `encodePhiProtectedMail` was given, or `null` for anything it did not write. */
|
|
42
|
+
export function decodePhiProtectedMail(value) {
|
|
43
|
+
if (!isPhiProtectedMail(value))
|
|
44
|
+
return null;
|
|
45
|
+
const hex = value.slice(PHI_PROTECTED_MAIL_PREFIX.length);
|
|
46
|
+
if (hex.length < 2 || hex.length % 2 !== 0 || !/^[0-9a-f]+$/u.test(hex))
|
|
47
|
+
return null;
|
|
48
|
+
const key = Number.parseInt(hex.slice(0, 2), 16);
|
|
49
|
+
const bytes = new Uint8Array((hex.length - 2) / 2);
|
|
50
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
51
|
+
const byte = Number.parseInt(hex.slice(2 + index * 2, 4 + index * 2), 16);
|
|
52
|
+
bytes[index] = byte ^ ((key + index * 31) & 0xff);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** A `mailto:` href protected; every other href as it is. */
|
|
62
|
+
export function protectPhiMailHref(href) {
|
|
63
|
+
if (typeof href !== "string")
|
|
64
|
+
return href;
|
|
65
|
+
return /^mailto:/iu.test(href.trim()) ? encodePhiProtectedMail(href.trim()) : href;
|
|
66
|
+
}
|
|
67
|
+
/** A text cut where it names an address, each address protected; one text segment when it names none. */
|
|
68
|
+
export function splitPhiMailAddresses(text) {
|
|
69
|
+
const segments = [];
|
|
70
|
+
let cursor = 0;
|
|
71
|
+
for (const match of text.matchAll(PHI_MAIL_ADDRESS_PATTERN)) {
|
|
72
|
+
const start = match.index ?? 0;
|
|
73
|
+
if (start > cursor)
|
|
74
|
+
segments.push({ kind: "text", text: text.slice(cursor, start) });
|
|
75
|
+
segments.push({ kind: "mail", token: encodePhiProtectedMail(match[0]) });
|
|
76
|
+
cursor = start + match[0].length;
|
|
77
|
+
}
|
|
78
|
+
if (cursor < text.length || segments.length === 0)
|
|
79
|
+
segments.push({ kind: "text", text: text.slice(cursor) });
|
|
80
|
+
return segments;
|
|
81
|
+
}
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phis/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
"@lexical/rich-text": "0.50.0",
|
|
504
504
|
"@lexical/selection": "0.50.0",
|
|
505
505
|
"@lexical/utils": "0.50.0",
|
|
506
|
-
"@phis/contracts": "^0.7.
|
|
506
|
+
"@phis/contracts": "^0.7.2",
|
|
507
507
|
"dayjs": "^1.11.23",
|
|
508
508
|
"dom-serializer": "^2.0.0",
|
|
509
509
|
"htmlparser2": "^10.1.0",
|
|
@@ -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"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { PhiSurfaceControl } from "../../../../components/controls/phi-surface-control";
|
|
4
4
|
import { PhiGeometryControl } from "../../../../components/controls/phi-geometry-control";
|
|
5
5
|
import { PhiViewportVisibilityControl } from "../../../../components/controls/phi-viewport-visibility-control";
|
|
@@ -10,6 +10,9 @@ import { normalizePhiPaddingWidgetConfig, } from "../../../../types/cms-config";
|
|
|
10
10
|
import { PhiTypographyControl } from "../../../../components/controls/phi-typography-control";
|
|
11
11
|
import { PHI_INSPECTOR_WIDGET_DEFAULT_LABELS } from "../../../../components/widgets/label-types/inspector";
|
|
12
12
|
import { PhiRegionVisibilityFields } from "./region-visibility-fields";
|
|
13
|
+
import { renderPhiInspectorConfigField } from "./inspector-config-field";
|
|
14
|
+
import { hasPhiFlag, readPhiFlags } from "../../../../helpers/flags";
|
|
15
|
+
import { PhiCmsFlags } from "../../../../constants/phi-cms";
|
|
13
16
|
const PHI_GAP_SM = "var(--ant-padding-sm)";
|
|
14
17
|
const REGION_PADDING_KEYS = [
|
|
15
18
|
"padding",
|
|
@@ -33,6 +36,18 @@ function patchRegionConfigPadding(regionConfig, padding) {
|
|
|
33
36
|
export function PhiDeveloperBuilderRegionInspectorWidgetClient({ section, builderMode = "editor", selectedStructureNodeKind = null, selectedRegionKey = null, currentDraft = null, onDraftChange, geometryLabels, backgroundLabels, borderLabels, colorPickerLabels, paddingLabels, surfaceLabels, visibilityLabels = PHI_INSPECTOR_WIDGET_DEFAULT_LABELS.regionVisibility, renderMediaPicker, }) {
|
|
34
37
|
const isPreviewMode = builderMode === "preview";
|
|
35
38
|
const effectiveDraft = currentDraft ?? (selectedRegionKey ? getDefaultRegionDraft(selectedRegionKey) : null);
|
|
39
|
+
/*
|
|
40
|
+
* Which edge the selected Region can stick to, if any. The Header bands and the Siders stick at the top;
|
|
41
|
+
* `footer_bottom` sticks at the bottom (`phiCmsRegionFooterSticks`); every other Region ignores the flag,
|
|
42
|
+
* so it is not offered there.
|
|
43
|
+
*/
|
|
44
|
+
const stickyEdge = selectedRegionKey == null
|
|
45
|
+
? null
|
|
46
|
+
: selectedRegionKey === "footer_bottom"
|
|
47
|
+
? "bottom"
|
|
48
|
+
: selectedRegionKey.startsWith("header_") || selectedRegionKey.startsWith("sider_")
|
|
49
|
+
? "top"
|
|
50
|
+
: null;
|
|
36
51
|
function updateDraft(patch) {
|
|
37
52
|
if (!selectedRegionKey || !effectiveDraft || !onDraftChange) {
|
|
38
53
|
return;
|
|
@@ -43,12 +58,61 @@ export function PhiDeveloperBuilderRegionInspectorWidgetClient({ section, builde
|
|
|
43
58
|
{
|
|
44
59
|
key: "geometry",
|
|
45
60
|
title: "Geometry",
|
|
46
|
-
children: (
|
|
61
|
+
children: (_jsxs("div", { style: { display: "grid", gap: PHI_GAP_SM, width: "100%" }, children: [_jsx(PhiGeometryControl, { mode: "control", disabled: isPreviewMode, showViewport: false, showSticky: stickyEdge !== null, showOffsetTop: stickyEdge === "top", value: effectiveDraft, onChange: (geometry) => updateDraft(geometry), labels: geometryLabels }), stickyEdge === "bottom" ? renderPhiInspectorConfigField({
|
|
62
|
+
field: { key: "offsetBottom", type: "length", label: geometryLabels?.fields.offsetBottom ?? "Offset bottom", min: 0 },
|
|
63
|
+
value: effectiveDraft.regionConfig?.offsetBottom,
|
|
64
|
+
defaultValue: undefined,
|
|
65
|
+
config: effectiveDraft.regionConfig ?? {},
|
|
66
|
+
disabled: isPreviewMode || !onDraftChange || !effectiveDraft.sticky,
|
|
67
|
+
onChange: (patch) => {
|
|
68
|
+
const next = { ...(effectiveDraft.regionConfig ?? {}) };
|
|
69
|
+
if (patch.offsetBottom == null || patch.offsetBottom === 0) {
|
|
70
|
+
delete next.offsetBottom;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
next.offsetBottom = patch.offsetBottom;
|
|
74
|
+
}
|
|
75
|
+
updateDraft({ regionConfig: next });
|
|
76
|
+
},
|
|
77
|
+
}) : null, selectedRegionKey === "content" ? renderPhiInspectorConfigField({
|
|
78
|
+
field: { key: "heroOverlap", type: "length", label: visibilityLabels.heroOverlap, min: 0 },
|
|
79
|
+
value: effectiveDraft.regionConfig?.heroOverlap,
|
|
80
|
+
defaultValue: undefined,
|
|
81
|
+
config: effectiveDraft.regionConfig ?? {},
|
|
82
|
+
disabled: isPreviewMode || !onDraftChange,
|
|
83
|
+
onChange: (patch) => {
|
|
84
|
+
const next = { ...(effectiveDraft.regionConfig ?? {}) };
|
|
85
|
+
if (patch.heroOverlap == null || patch.heroOverlap === 0) {
|
|
86
|
+
delete next.heroOverlap;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
next.heroOverlap = patch.heroOverlap;
|
|
90
|
+
}
|
|
91
|
+
updateDraft({ regionConfig: next });
|
|
92
|
+
},
|
|
93
|
+
}) : null] })),
|
|
47
94
|
},
|
|
48
95
|
{
|
|
49
96
|
key: "viewport",
|
|
50
97
|
title: geometryLabels?.fields.viewport ?? "Viewport",
|
|
51
|
-
children: (_jsx(PhiViewportVisibilityControl, { disabled: isPreviewMode || !onDraftChange, value: effectiveDraft.viewportFlags, labels: geometryLabels?.viewport, onChange: (viewportFlags) => updateDraft({ viewportFlags }) })
|
|
98
|
+
children: (_jsxs("div", { style: { display: "grid", gap: PHI_GAP_SM, width: "100%" }, children: [_jsx(PhiViewportVisibilityControl, { disabled: isPreviewMode || !onDraftChange, value: effectiveDraft.viewportFlags, labels: geometryLabels?.viewport, onChange: (viewportFlags) => updateDraft({ viewportFlags }) }), selectedRegionKey === "sider_left" ? renderPhiInspectorConfigField({
|
|
99
|
+
field: { key: "mobileDrawer", type: "boolean", label: visibilityLabels.siderMobileDrawer },
|
|
100
|
+
value: hasPhiFlag(readPhiFlags(effectiveDraft.regionConfig?.flags), PhiCmsFlags.MobileDrawer),
|
|
101
|
+
defaultValue: false,
|
|
102
|
+
config: effectiveDraft.regionConfig ?? {},
|
|
103
|
+
disabled: isPreviewMode || !onDraftChange,
|
|
104
|
+
onChange: (patch) => {
|
|
105
|
+
const flags = readPhiFlags(effectiveDraft.regionConfig?.flags);
|
|
106
|
+
updateDraft({
|
|
107
|
+
regionConfig: {
|
|
108
|
+
...(effectiveDraft.regionConfig ?? {}),
|
|
109
|
+
flags: patch.mobileDrawer === true
|
|
110
|
+
? flags | PhiCmsFlags.MobileDrawer
|
|
111
|
+
: flags & ~PhiCmsFlags.MobileDrawer,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
}) : null] })),
|
|
52
116
|
},
|
|
53
117
|
{
|
|
54
118
|
key: "visibility",
|
|
@@ -44,5 +44,5 @@ export function PhiBuilderRuntimeModuleAuthoringBoundary({ targetArea, catalog,
|
|
|
44
44
|
targetArea,
|
|
45
45
|
videoProviderDescriptors,
|
|
46
46
|
]);
|
|
47
|
-
return (_jsx(PhiRuntimeModuleProvider, { moduleIds: moduleIds, widgetTypes: widgetDefinitions.map((definition) => definition.type), layoutTypes: layoutTypes, widgetDefinitions: widgetDefinitions, dataProviderDescriptors: dataProviderDescriptors, calendarAdapterDescriptors: calendarAdapterDescriptors, videoProviderDescriptors: videoProviderDescriptors, children: _jsx(PhiRuntimeModuleAuthoringDataProviderHost, { providerKeys: authoringDataProviderKeys, children: _jsx(PhiRuntimeModuleDataProviderClientHost, { providerKeys: pickerDataProviderKeys, mode: "live", children: _jsx(PhiRuntimeModuleAuthoringClientHost, { moduleIds: moduleIds, children: children }) }) }) }));
|
|
47
|
+
return (_jsx(PhiRuntimeModuleProvider, { moduleIds: moduleIds, widgetTypes: widgetDefinitions.map((definition) => definition.type), layoutTypes: layoutTypes, widgetDefinitions: widgetDefinitions, dataProviderDescriptors: dataProviderDescriptors, calendarAdapterDescriptors: calendarAdapterDescriptors, videoProviderDescriptors: videoProviderDescriptors, collectionItemRendererDescriptors: collectionItemRendererDescriptors, children: _jsx(PhiRuntimeModuleAuthoringDataProviderHost, { providerKeys: authoringDataProviderKeys, children: _jsx(PhiRuntimeModuleDataProviderClientHost, { providerKeys: pickerDataProviderKeys, mode: "live", children: _jsx(PhiRuntimeModuleAuthoringClientHost, { moduleIds: moduleIds, children: children }) }) }) }));
|
|
48
48
|
}
|
|
@@ -269,9 +269,10 @@ export function usePhiBuilderDraftCommandController({ effectiveArea, effectiveNa
|
|
|
269
269
|
pageKey: effectivePageKey,
|
|
270
270
|
};
|
|
271
271
|
/*
|
|
272
|
-
* A preview is of the saved draft or
|
|
273
|
-
* the
|
|
274
|
-
*
|
|
272
|
+
* A preview is of the saved draft, or -- when nothing is saved -- of what is published, which is then
|
|
273
|
+
* what the page is. A read that failed is the command's error rather than the live page: the author
|
|
274
|
+
* would take what is published for a draft that may exist. What the preview leaves out is said
|
|
275
|
+
* before it opens, and which of the two it shows.
|
|
275
276
|
*/
|
|
276
277
|
const result = await previewPhiDeveloperBuilderDraft(state, workspaceKind, {
|
|
277
278
|
pathname,
|
|
@@ -280,7 +281,9 @@ export function usePhiBuilderDraftCommandController({ effectiveArea, effectiveNa
|
|
|
280
281
|
if (hasUnsavedChanges) {
|
|
281
282
|
showMessage({
|
|
282
283
|
level: "warning",
|
|
283
|
-
content:
|
|
284
|
+
content: result.revisionId == null
|
|
285
|
+
? "Nothing is saved yet, so the preview shows the published page. Save to include your changes."
|
|
286
|
+
: "The preview shows the last saved draft. Save to include your latest changes.",
|
|
284
287
|
});
|
|
285
288
|
}
|
|
286
289
|
window.open(result.previewHref, "_blank", "noopener,noreferrer");
|
|
@@ -13,6 +13,7 @@ import { collectPhiDeveloperBuilderPageKeys, collectPhiDeveloperBuilderPageStora
|
|
|
13
13
|
import { createPhiDeveloperBuilderInitialPageDrafts, createPhiDeveloperBuilderPageDraft, PhiBuilderPageExistsError, } from "../persistence";
|
|
14
14
|
import { describePhiBuilderPageAddressConflict, findPhiBuilderSitePageAddressConflict, } from "../page-address-rule";
|
|
15
15
|
import { PHI_BUILDER_AREA_SEARCH_PARAM, PHI_BUILDER_PAGE_SEARCH_PARAM, } from "../../../../helpers/cms-scope-search-params";
|
|
16
|
+
import { PHI_BUILDER_PREVIEW_SEARCH_PARAM } from "../preview-transport";
|
|
16
17
|
import { mergePhiDeveloperRegionDrafts, openPhiBuilderPage, setPhiBuilderPageMetaDraft, startPhiBuilderNewPageDrafts, getPhiDeveloperBuilderStateSnapshot, } from "../developer-workspace-store";
|
|
17
18
|
import { getPhiBuilderRegionDraftKey } from "../region-keys";
|
|
18
19
|
import { capturePhiBuilderWorkspaceHistoryState, createPhiBuilderHistoryContext, phiBuilderHistory, } from "../history";
|
|
@@ -67,6 +68,12 @@ export function usePhiBuilderPageController({ emitCapability, effectiveArea, eff
|
|
|
67
68
|
const nextSearchParams = new URLSearchParams(searchParams.toString());
|
|
68
69
|
nextSearchParams.set(PHI_BUILDER_AREA_SEARCH_PARAM, effectiveArea);
|
|
69
70
|
nextSearchParams.set(PHI_BUILDER_PAGE_SEARCH_PARAM, pageKey);
|
|
71
|
+
/*
|
|
72
|
+
* Another Page opens in the Editor. The preview was of the Page that was open -- its snapshot holds
|
|
73
|
+
* that Page's drafts -- so carrying it over would show the new Page in a mode it was never put in,
|
|
74
|
+
* from a snapshot that is not its own.
|
|
75
|
+
*/
|
|
76
|
+
nextSearchParams.delete(PHI_BUILDER_PREVIEW_SEARCH_PARAM);
|
|
70
77
|
router.replace(`${pathname}?${nextSearchParams.toString()}`, { scroll: false });
|
|
71
78
|
}
|
|
72
79
|
}
|
|
@@ -813,8 +813,16 @@ export async function previewPhiDeveloperBuilderDraft(state, workspaceKind, opti
|
|
|
813
813
|
}
|
|
814
814
|
: { path: resolvePhiBuilderCmsStoragePath(area, pageKey, pages) }),
|
|
815
815
|
});
|
|
816
|
+
/*
|
|
817
|
+
* No saved draft is not a failure: what the preview has to show is then what is published, so it
|
|
818
|
+
* opens the live page. A read that failed still throws -- that is not knowing, which is different
|
|
819
|
+
* from there being nothing.
|
|
820
|
+
*/
|
|
816
821
|
if (!draft || !Number.isInteger(draft.revisionId) || draft.revisionId <= 0) {
|
|
817
|
-
|
|
822
|
+
return {
|
|
823
|
+
revisionId: null,
|
|
824
|
+
previewHref: buildPhiBuilderLiveHref(area, pageKey, pages, workspaceKind),
|
|
825
|
+
};
|
|
818
826
|
}
|
|
819
827
|
return {
|
|
820
828
|
revisionId: draft.revisionId,
|
|
@@ -6,7 +6,8 @@ import type { PhiRuntimeDataProviderBinding } from "../../../../types/runtime-da
|
|
|
6
6
|
/**
|
|
7
7
|
* The entry an entry Widget is bound to, as the three of them draw it: the record, none by that address,
|
|
8
8
|
* or none to be had. A record of another shape -- a binding to some other Module's Provider -- is no entry,
|
|
9
|
-
* and is said as unavailable rather than drawn as an empty one.
|
|
9
|
+
* and is said as unavailable rather than drawn as an empty one. An unavailable one says why, which is
|
|
10
|
+
* what the author reads in the Builder and the operator in the log.
|
|
10
11
|
*/
|
|
11
12
|
export declare function readPhiBoundContentEntry(input: {
|
|
12
13
|
registry: Pick<PhiCmsRuntimeRenderRegistry, "recordProviderLoadersByKey"> | undefined;
|
|
@@ -19,4 +20,5 @@ export declare function readPhiBoundContentEntry(input: {
|
|
|
19
20
|
status: "missing";
|
|
20
21
|
} | {
|
|
21
22
|
status: "unavailable";
|
|
23
|
+
reason: string;
|
|
22
24
|
}>;
|
|
@@ -4,16 +4,19 @@ import { readPhiContentEntryRecord } from "../../../../types/content-entries";
|
|
|
4
4
|
/**
|
|
5
5
|
* The entry an entry Widget is bound to, as the three of them draw it: the record, none by that address,
|
|
6
6
|
* or none to be had. A record of another shape -- a binding to some other Module's Provider -- is no entry,
|
|
7
|
-
* and is said as unavailable rather than drawn as an empty one.
|
|
7
|
+
* and is said as unavailable rather than drawn as an empty one. An unavailable one says why, which is
|
|
8
|
+
* what the author reads in the Builder and the operator in the log.
|
|
8
9
|
*/
|
|
9
10
|
export async function readPhiBoundContentEntry(input) {
|
|
10
11
|
if (!input.registry) {
|
|
11
|
-
return { status: "unavailable" };
|
|
12
|
+
return { status: "unavailable", reason: "No record providers are available outside a page render." };
|
|
12
13
|
}
|
|
13
14
|
const result = await resolvePhiRecordSource({ ...input, registry: input.registry });
|
|
14
15
|
if (result.status !== "ok") {
|
|
15
|
-
return result
|
|
16
|
+
return result;
|
|
16
17
|
}
|
|
17
18
|
const record = readPhiContentEntryRecord(result.record);
|
|
18
|
-
return record
|
|
19
|
+
return record
|
|
20
|
+
? { status: "ok", record }
|
|
21
|
+
: { status: "unavailable", reason: `The record bound from "${input.binding.providerKey}" is not a content entry.` };
|
|
19
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { resolvePhiButtonVariantPresentation } from "../../../../../components/widgets/config/button-variant";
|
|
4
4
|
import { usePhiControlSignalController } from "../../../../../components/widgets/client/shared/phi-control-signals";
|
|
5
5
|
import { usePhiControlBadgeController } from "../../../../../components/widgets/client/shared/phi-control-badge";
|
|
6
6
|
import { resolvePhiButtonIcon } from "../../../../../components/widgets/client/shared/phi-button-icons";
|
|
@@ -57,7 +57,7 @@ export function PhiButtonWidget({ config, labels, link, disabled, signalsEnabled
|
|
|
57
57
|
const tooltip = config?.tooltip;
|
|
58
58
|
return (_jsx(PhiButtonControl, { label: label, ...(label ? {} : { ariaLabel: tooltip ?? action?.label }), ...(link && !config?.signalRoutes?.emits?.length
|
|
59
59
|
? { href: link.href, newTab: link.newTab, external: link.external }
|
|
60
|
-
: {}), tooltip: tooltip,
|
|
60
|
+
: {}), tooltip: tooltip, ...resolvePhiButtonVariantPresentation(action ? action.variant : config?.variant, config?.gradient), danger: action ? action.danger === true : config?.danger === true, disabled: resolvedDisabled, size: config?.controlSize, icon: icon, onClick: publish, badge: {
|
|
61
61
|
enabled: badge.enabled,
|
|
62
62
|
value: badge.visible ? badge.value : 0,
|
|
63
63
|
color: badge.color,
|