@phis/ui 0.4.7 → 0.4.10
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/components/cms/phi-cms-runtime-registry.d.ts +2 -1
- package/components/cms/phi-cms-runtime-registry.js +1 -1
- package/components/controls/phi-color-control.js +2 -1
- package/components/controls/phi-drawer-control-adapter.js +2 -3
- package/components/controls/phi-drawer-control.js +3 -3
- package/components/controls/phi-dropdown-control.js +2 -1
- package/components/controls/phi-float-button-control.js +3 -3
- package/components/controls/phi-modal-control-adapter.js +2 -2
- package/components/controls/phi-modal-control.js +3 -3
- package/components/controls/phi-ribbon-wrap-control.js +2 -1
- package/components/controls/phi-zoom-image-overlay.js +11 -5
- package/components/forms/content-entry-forms.js +1 -5
- package/components/forms/form-descriptor-runtime-client.js +2 -1
- package/components/forms/form-descriptor-text.d.ts +17 -0
- package/components/forms/form-descriptor-text.js +14 -0
- package/components/forms/runtime-form-controller-plugin.d.ts +0 -115
- package/components/forms/runtime-form-controller-plugin.js +1 -1
- package/components/forms/upload-form-control.d.ts +0 -7
- package/components/forms/upload-form-control.js +1 -1
- package/components/layouts/clients/phi-collapsible-layout-client.js +2 -1
- package/components/layouts/clients/phi-sequence-slot-editor.js +2 -1
- package/components/layouts/clients/phi-split-card-half.js +2 -1
- package/components/layouts/phi-base-layout.js +2 -1
- package/components/layouts/phi-layout-surface-box.js +2 -1
- package/components/media/phi-media-picker-server.js +3 -11
- package/components/navigation/use-phi-protected-mail.js +1 -9
- package/components/regions/presets/clients/sider-context.js +4 -2
- package/components/root/phi-config-provider.js +2 -1
- package/components/root/phi-dayjs-locale.d.ts +4 -1
- package/components/root/phi-dayjs-locale.js +2 -2
- package/components/root/phi-intl-locale.d.ts +7 -1
- package/components/root/phi-intl-locale.js +20 -15
- package/components/root/phi-root-layout.js +2 -1
- package/components/runtime/core-runtime-controller-plugin.d.ts +0 -84
- package/components/runtime/core-runtime-controller-plugin.js +1 -1
- package/components/runtime/runtime-signal-bus.js +39 -4
- package/components/state/use-phi-hydrated.d.ts +6 -0
- package/components/state/use-phi-hydrated.js +11 -0
- package/components/widgets/client/shared/phi-rendered-value.js +4 -3
- package/components/widgets/config/parser-primitives.d.ts +5 -0
- package/components/widgets/config/parser-primitives.js +11 -0
- package/components/widgets/label-sets/runtime-options.d.ts +1 -1
- package/components/widgets/server/builder-chrome.js +2 -6
- package/components/widgets/server/search.js +2 -6
- package/gateway/dashboard-cards-route.js +5 -7
- package/gateway/navigation-target-route.js +7 -9
- package/gateway/page-references-route.js +6 -8
- package/gateway/site-config.js +3 -0
- package/gateway/site-proxy.js +13 -2
- package/helpers/class-names.d.ts +7 -0
- package/helpers/class-names.js +10 -0
- package/helpers/cms-navigation-catalog.js +4 -2
- package/helpers/cms-page-catalog.js +35 -6
- package/helpers/cms-region-keys.d.ts +0 -1
- package/helpers/cms-region-keys.js +1 -1
- package/helpers/format-date-time.d.ts +14 -3
- package/helpers/format-date-time.js +27 -11
- package/helpers/region-page-scope.d.ts +1 -3
- package/helpers/region-page-scope.js +0 -4
- package/helpers/translation-format.d.ts +6 -0
- package/helpers/translation-format.js +15 -8
- package/package.json +2 -2
- package/plugins/runtime/phi-slot-child-frame-view.js +2 -1
- package/plugins/runtime/phi-slot-child-viewport-effects-observer.js +1 -1
- package/plugins/runtime-modules/admin/forms.js +1 -1
- package/plugins/runtime-modules/admin/trees/phi-default-admin-settings-page-tree.js +2 -5
- package/plugins/runtime-modules/app/forms.js +1 -1
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +2 -6
- package/plugins/runtime-modules/asset/metadata-form.js +2 -6
- package/plugins/runtime-modules/asset/settings-forms.js +1 -1
- package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +2 -5
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -6
- package/plugins/runtime-modules/asset/widgets/area-upload/server.js +2 -6
- package/plugins/runtime-modules/asset/widgets/image-inspector/authoring.js +1 -3
- package/plugins/runtime-modules/asset/widgets/image-inspector/server.js +2 -6
- package/plugins/runtime-modules/asset/widgets.js +5 -7
- package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
- package/plugins/runtime-modules/auth/ids.d.ts +7 -7
- package/plugins/runtime-modules/auth/ids.js +7 -7
- package/plugins/runtime-modules/auth/trees/phi-auth-area-overlay-tree.server.js +2 -6
- package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +2 -5
- package/plugins/runtime-modules/auth/widgets.d.ts +1 -2
- package/plugins/runtime-modules/auth/widgets.js +5 -7
- package/plugins/runtime-modules/avatar/overlay-tree.server.js +2 -6
- package/plugins/runtime-modules/avatar/widgets/account-avatar/server.js +2 -6
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/server.js +2 -6
- package/plugins/runtime-modules/avatar/widgets.js +3 -5
- package/plugins/runtime-modules/builder/clients/pages-workspace.d.ts +2 -3
- package/plugins/runtime-modules/builder/clients/pages-workspace.js +5 -18
- package/plugins/runtime-modules/builder/controller/draft-command-controller.js +1 -0
- package/plugins/runtime-modules/builder/controller/page-controller.js +1 -1
- package/plugins/runtime-modules/builder/controller/server-definition.js +3 -11
- package/plugins/runtime-modules/builder/controller/workspace-controller.js +2 -6
- package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +2 -8
- package/plugins/runtime-modules/builder/developer-workspace-store.js +24 -44
- package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +0 -5
- package/plugins/runtime-modules/builder/edit-scaffold-drawer.js +2 -1
- package/plugins/runtime-modules/builder/inspector-section-widget.js +6 -31
- package/plugins/runtime-modules/builder/navigation-persistence.js +12 -3
- package/plugins/runtime-modules/builder/page-meta-form.js +4 -12
- package/plugins/runtime-modules/builder/page-presets.server.d.ts +0 -1
- package/plugins/runtime-modules/builder/page-presets.server.js +0 -24
- package/plugins/runtime-modules/builder/pages-workspace.js +6 -16
- package/plugins/runtime-modules/builder/persistence.d.ts +6 -4
- package/plugins/runtime-modules/builder/persistence.js +6 -7
- package/plugins/runtime-modules/builder/shells-workspace.js +3 -11
- package/plugins/runtime-modules/builder/signal-wiring-form.js +3 -7
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +2 -6
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -26
- package/plugins/runtime-modules/builder/trees/phi-default-builder-settings-page-tree.js +2 -6
- package/plugins/runtime-modules/builder/widgets/developer-builder-pages-header/plugin.js +2 -6
- package/plugins/runtime-modules/builder/widgets/inspector-header/plugin.js +2 -6
- package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +3 -2
- package/plugins/runtime-modules/builder/widgets/structure-region/plugin.js +1 -6
- package/plugins/runtime-modules/builder/widgets.js +10 -12
- package/plugins/runtime-modules/contracts.d.ts +15 -1
- package/plugins/runtime-modules/contracts.js +10 -0
- package/plugins/runtime-modules/core/messaging/forms.js +1 -1
- package/plugins/runtime-modules/core/widgets/description/server.js +12 -9
- package/plugins/runtime-modules/core/widgets/dimension/plugin.js +2 -6
- package/plugins/runtime-modules/core/widgets/draft-status/plugin.js +2 -6
- package/plugins/runtime-modules/core/widgets/entry-list/config.js +2 -9
- package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +1 -1
- package/plugins/runtime-modules/core/widgets/form-preview/client.js +2 -15
- package/plugins/runtime-modules/core/widgets/gallery/server.js +2 -6
- package/plugins/runtime-modules/core/widgets/image/server.js +2 -6
- package/plugins/runtime-modules/core/widgets/length/plugin.js +2 -6
- package/plugins/runtime-modules/core/widgets/markdown-toc/plugin.js +2 -6
- package/plugins/runtime-modules/core/widgets/page-title/server.js +2 -6
- package/plugins/runtime-modules/core/widgets/pagination/config.js +4 -8
- package/plugins/runtime-modules/core/widgets/search-results/config.js +2 -8
- package/plugins/runtime-modules/core/widgets/sidebar-navigation/server.d.ts +2 -2
- package/plugins/runtime-modules/core/widgets/sidebar-navigation/server.js +8 -13
- package/plugins/runtime-modules/core/widgets/theme-mode-switch/server.js +2 -6
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +16 -31
- package/plugins/runtime-modules/core/widgets/timeline/client.js +9 -4
- package/plugins/runtime-modules/core/widgets/tour-button/server.js +2 -6
- package/plugins/runtime-modules/core/widgets.js +59 -61
- package/plugins/runtime-modules/dashboard/clients/dashboard-card-view.js +7 -5
- package/plugins/runtime-modules/dashboard/trees/phi-default-admin-dashboard-page-tree.js +2 -6
- package/plugins/runtime-modules/dashboard/trees/phi-default-area-dashboard-page-tree.js +2 -6
- package/plugins/runtime-modules/dashboard/trees/phi-default-builder-dashboard-page-tree.js +2 -6
- package/plugins/runtime-modules/descriptor-compiler.js +6 -6
- package/plugins/runtime-modules/groups/controller/client.d.ts +0 -56
- package/plugins/runtime-modules/groups/controller/client.js +1 -1
- package/plugins/runtime-modules/groups/forms.js +1 -5
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -6
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -6
- package/plugins/runtime-modules/localization/forms.js +2 -6
- package/plugins/runtime-modules/localization/services/options.js +19 -9
- package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +3 -11
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -11
- package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +3 -11
- package/plugins/runtime-modules/revisions/forms.js +1 -1
- package/plugins/runtime-modules/revisions/services/table.js +6 -2
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
- package/plugins/runtime-modules/theme/controller/server-definition.js +2 -6
- package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +2 -6
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +17 -21
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.d.ts +0 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +0 -8
- package/plugins/runtime-modules/theme/widgets.js +6 -8
- package/plugins/runtime-modules/threads/controller/client.d.ts +0 -78
- package/plugins/runtime-modules/threads/controller/client.js +1 -1
- package/plugins/runtime-modules/threads/forms.js +1 -1
- package/plugins/runtime-modules/threads/ids.d.ts +0 -1
- package/plugins/runtime-modules/threads/ids.js +0 -2
- package/plugins/runtime-modules/user-management/controller/client.d.ts +0 -73
- package/plugins/runtime-modules/user-management/controller/client.js +1 -1
- package/plugins/runtime-modules/user-management/forms.js +1 -5
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +2 -6
- package/plugins/runtime-modules/video/widgets.js +2 -4
- package/server-helpers/cms-request.d.ts +19 -0
- package/server-helpers/cms-request.js +26 -8
- package/server-helpers/cms-root.js +6 -8
- package/server-helpers/public-login-route.js +6 -8
- package/server-helpers/runtime.js +1 -0
- package/server-helpers/search-index.js +58 -27
- package/types/length.js +8 -3
- package/types/site-config.d.ts +6 -0
- package/types/widget-runtime.d.ts +2 -0
- package/types.d.ts +5 -3
- package/types.js +3 -0
|
@@ -122,7 +122,7 @@ function resolvePhiDayjsLocale(locale) {
|
|
|
122
122
|
* Both sit in this one Client reference because the root layout is under every route, and each Client
|
|
123
123
|
* reference it reaches is paid for by every page (`validate-area-client-reach.mjs`).
|
|
124
124
|
*/
|
|
125
|
-
export function PhiDayjsLocale({ locale, intlLocale, children, }) {
|
|
125
|
+
export function PhiDayjsLocale({ locale, intlLocale, timeZone, renderedAt, children, }) {
|
|
126
126
|
useEffect(() => {
|
|
127
127
|
let active = true;
|
|
128
128
|
async function applyLocale() {
|
|
@@ -141,5 +141,5 @@ export function PhiDayjsLocale({ locale, intlLocale, children, }) {
|
|
|
141
141
|
active = false;
|
|
142
142
|
};
|
|
143
143
|
}, [locale]);
|
|
144
|
-
return _jsx(PhiIntlLocaleProvider, { locale: intlLocale, children: children });
|
|
144
|
+
return (_jsx(PhiIntlLocaleProvider, { locale: intlLocale, timeZone: timeZone, renderedAt: renderedAt, children: children }));
|
|
145
145
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
export declare function PhiIntlLocaleProvider({ locale, children }: {
|
|
2
|
+
export declare function PhiIntlLocaleProvider({ locale, timeZone, renderedAt, children, }: {
|
|
3
3
|
locale: string;
|
|
4
|
+
timeZone: string;
|
|
5
|
+
renderedAt: number;
|
|
4
6
|
children: ReactNode;
|
|
5
7
|
}): import("react").JSX.Element;
|
|
6
8
|
export declare function usePhiIntlLocale(): string;
|
|
9
|
+
/** The Site's time zone, for every date and time a Client component formats. */
|
|
10
|
+
export declare function usePhiIntlTimeZone(): string;
|
|
11
|
+
/** The moment the server rendered this page, for relative times that have to hydrate unchanged. */
|
|
12
|
+
export declare function usePhiIntlRenderedAt(): number;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext } from "react";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* `/de/...` would show English dates in a German page, and the server's render would show a third. The
|
|
9
|
-
* Root Layout sets it once from the resolved locale, the same value `<html lang>` carries.
|
|
10
|
-
*/
|
|
11
|
-
const PhiIntlLocaleContext = createContext(null);
|
|
12
|
-
export function PhiIntlLocaleProvider({ locale, children }) {
|
|
13
|
-
return _jsx(PhiIntlLocaleContext.Provider, { value: locale, children: children });
|
|
3
|
+
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
const PhiIntlContext = createContext(null);
|
|
5
|
+
export function PhiIntlLocaleProvider({ locale, timeZone, renderedAt, children, }) {
|
|
6
|
+
const value = useMemo(() => ({ locale, timeZone, renderedAt }), [locale, renderedAt, timeZone]);
|
|
7
|
+
return _jsx(PhiIntlContext.Provider, { value: value, children: children });
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
9
|
+
function usePhiIntl() {
|
|
10
|
+
const value = useContext(PhiIntlContext);
|
|
11
|
+
if (!value) {
|
|
18
12
|
throw new Error("usePhiIntlLocale needs a PhiIntlLocaleProvider above it; the Root Layout sets one.");
|
|
19
13
|
}
|
|
20
|
-
return
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
export function usePhiIntlLocale() {
|
|
17
|
+
return usePhiIntl().locale;
|
|
18
|
+
}
|
|
19
|
+
/** The Site's time zone, for every date and time a Client component formats. */
|
|
20
|
+
export function usePhiIntlTimeZone() {
|
|
21
|
+
return usePhiIntl().timeZone;
|
|
22
|
+
}
|
|
23
|
+
/** The moment the server rendered this page, for relative times that have to hydrate unchanged. */
|
|
24
|
+
export function usePhiIntlRenderedAt() {
|
|
25
|
+
return usePhiIntl().renderedAt;
|
|
21
26
|
}
|
|
@@ -18,6 +18,7 @@ import "../../styles/gradients.css";
|
|
|
18
18
|
import { getResolvedSiteConfig } from "../../gateway/site-config";
|
|
19
19
|
import { loadPhiAntdLocale } from "../../helpers/antd-locale";
|
|
20
20
|
import { PhiDayjsLocale } from "./phi-dayjs-locale";
|
|
21
|
+
import { readPhiRenderMoment } from "../../helpers/format-date-time";
|
|
21
22
|
import { PhiRootLiveThemeProvider } from "./phi-root-live-theme-provider";
|
|
22
23
|
import { resolvePhiRootThemeState } from "./phi-root-theme-resolver";
|
|
23
24
|
import { PhiSignalRuntimePartitionProvider } from "../runtime/runtime-signal-partition";
|
|
@@ -120,5 +121,5 @@ export async function PhiRootLayout({ children, apiBaseUrl, internalToken, siteK
|
|
|
120
121
|
});
|
|
121
122
|
return (_jsxs(_Fragment, { children: [assetFonts.css ? (_jsx("style", { href: `phi-site-fonts:${site.key}`, precedence: "default", dangerouslySetInnerHTML: { __html: assetFonts.css } })) : null, _jsx(AntdRegistry, { children: _jsx(PhiSignalRuntimePartitionProvider, { id: `site:${site.key}`, kind: "site", context: { siteKey: site.key }, children: _jsx(PhiRootLiveThemeProvider, { siteKey: site.key, siteName: site.name, siteTheme: siteTheme, locale: antdLocale, initialMode: resolvedThemeMode, themeModePreference: themeModePreference, initialLocale: resolvedLocale?.locale ?? site.defaultLocale, availableLocales: site.availableLocales.map((option) => option.code), fonts: themeFonts, themeState: themeState, fontFamilies: fontCatalogue.entries.map(({ family, cssVariable }) => ({ family, cssVariable })), presets: themePresets, rootClassName: fontCatalogue.className, rootStyle: headingFontFamily
|
|
122
123
|
? { ...publishedRootTheme.style, [PHI_THEME_HEADING_FONT_VARIABLE]: headingFontFamily }
|
|
123
|
-
: publishedRootTheme.style, children: _jsxs("div", { "data-phi-app-ground": "true", children: [_jsx(PhiCoreRuntimeApplicationAdapter, { labels: sessionLabels }), _jsx(PhiDayjsLocale, { locale: resolvedLocale?.locale ?? resolvedLocale?.intlLocale, intlLocale: resolvedLocale?.intlLocale ?? site.defaultLocale, children: children })] }) }) }) })] }));
|
|
124
|
+
: publishedRootTheme.style, children: _jsxs("div", { "data-phi-app-ground": "true", children: [_jsx(PhiCoreRuntimeApplicationAdapter, { labels: sessionLabels }), _jsx(PhiDayjsLocale, { locale: resolvedLocale?.locale ?? resolvedLocale?.intlLocale, intlLocale: resolvedLocale?.intlLocale ?? site.defaultLocale, timeZone: site.timeZone, renderedAt: readPhiRenderMoment(), children: children })] }) }) }) })] }));
|
|
124
125
|
}
|
|
@@ -1,85 +1 @@
|
|
|
1
|
-
import { type PhiCoreRuntimeControllerConfig } from "./core-runtime-controller-definition";
|
|
2
|
-
export declare const PHI_CORE_RUNTIME_CONTROLLER_PLUGIN: {
|
|
3
|
-
renderController: () => null;
|
|
4
|
-
kind: "controller";
|
|
5
|
-
pluginKey: string;
|
|
6
|
-
key: string;
|
|
7
|
-
title: string;
|
|
8
|
-
description: string;
|
|
9
|
-
iconFamily: string;
|
|
10
|
-
allowedMountScopes: "site"[];
|
|
11
|
-
runtimeSignals: {
|
|
12
|
-
emits: ({
|
|
13
|
-
id: string;
|
|
14
|
-
action: "change";
|
|
15
|
-
valueType: "json";
|
|
16
|
-
valueSchema: `${string}/signals/${string}`;
|
|
17
|
-
} | {
|
|
18
|
-
id: string;
|
|
19
|
-
action: "change";
|
|
20
|
-
valueType: "string";
|
|
21
|
-
valueSchema?: undefined;
|
|
22
|
-
} | {
|
|
23
|
-
id: string;
|
|
24
|
-
action: "change";
|
|
25
|
-
valueType: "boolean";
|
|
26
|
-
valueSchema?: undefined;
|
|
27
|
-
} | {
|
|
28
|
-
id: string;
|
|
29
|
-
action: "clear";
|
|
30
|
-
valueType: "none";
|
|
31
|
-
valueSchema?: undefined;
|
|
32
|
-
} | {
|
|
33
|
-
id: string;
|
|
34
|
-
action: "change";
|
|
35
|
-
valueType: "image";
|
|
36
|
-
valueSchema?: undefined;
|
|
37
|
-
})[];
|
|
38
|
-
listens: ({
|
|
39
|
-
id: string;
|
|
40
|
-
channel: string;
|
|
41
|
-
action: "change";
|
|
42
|
-
valueType: "string";
|
|
43
|
-
valueSchema?: undefined;
|
|
44
|
-
} | {
|
|
45
|
-
id: string;
|
|
46
|
-
channel: string;
|
|
47
|
-
action: "clear";
|
|
48
|
-
valueType: "none";
|
|
49
|
-
valueSchema?: undefined;
|
|
50
|
-
} | {
|
|
51
|
-
id: string;
|
|
52
|
-
channel: string;
|
|
53
|
-
action: "change";
|
|
54
|
-
valueType: "image";
|
|
55
|
-
valueSchema?: undefined;
|
|
56
|
-
} | {
|
|
57
|
-
id: string;
|
|
58
|
-
channel: string;
|
|
59
|
-
action: "change";
|
|
60
|
-
valueType: "json";
|
|
61
|
-
valueSchema: `${string}/signals/${string}`;
|
|
62
|
-
} | {
|
|
63
|
-
id: string;
|
|
64
|
-
channel: string;
|
|
65
|
-
action: "change";
|
|
66
|
-
valueType: "boolean";
|
|
67
|
-
valueSchema?: undefined;
|
|
68
|
-
} | {
|
|
69
|
-
id: string;
|
|
70
|
-
channel: string;
|
|
71
|
-
action: "activate";
|
|
72
|
-
valueType: "json";
|
|
73
|
-
valueSchema: `${string}/signals/${string}`;
|
|
74
|
-
} | {
|
|
75
|
-
id: string;
|
|
76
|
-
channel: string;
|
|
77
|
-
action: "activate";
|
|
78
|
-
valueType: "none";
|
|
79
|
-
valueSchema?: undefined;
|
|
80
|
-
})[];
|
|
81
|
-
};
|
|
82
|
-
defaultConfig: {};
|
|
83
|
-
parseConfig: () => PhiCoreRuntimeControllerConfig;
|
|
84
|
-
};
|
|
85
1
|
export declare const PhiCoreRuntimeControllerClient: (props: import("../../types").PhiRuntimeModuleControllerClientProps) => import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createPhiRuntimeControllerClient } from "./runtime-controller-client-factory";
|
|
3
3
|
import { PHI_CORE_RUNTIME_CONTROLLER_DEFINITION, } from "./core-runtime-controller-definition";
|
|
4
|
-
|
|
4
|
+
const PHI_CORE_RUNTIME_CONTROLLER_PLUGIN = {
|
|
5
5
|
...PHI_CORE_RUNTIME_CONTROLLER_DEFINITION,
|
|
6
6
|
renderController: () => null,
|
|
7
7
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback, useEffect, useEffectEvent, } from "react";
|
|
2
|
+
import { useCallback, useEffect, useEffectEvent, useMemo, } from "react";
|
|
3
3
|
import { readPhiSignalValueSchema } from "../../types/signals";
|
|
4
4
|
import { matchesPhiSignalRuntimeContext, resolvePhiSignalDeliverability, resolvePhiSignalReceiverScope, resolvePhiSignalDeliveryPartition, } from "./runtime-signal-registry";
|
|
5
5
|
import { usePhiSignalRuntimePartition, } from "./runtime-signal-partition";
|
|
@@ -371,15 +371,50 @@ export function usePhiSignalDispatcher() {
|
|
|
371
371
|
emitPhiSignal(partition, signal);
|
|
372
372
|
}, [partition]);
|
|
373
373
|
}
|
|
374
|
+
function listKey(list) {
|
|
375
|
+
return list ? list.map(String).join("\u0001") : "";
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* A filter's content as one string, so that an effect can depend on what a filter says rather than on
|
|
379
|
+
* which object says it.
|
|
380
|
+
*
|
|
381
|
+
* Callers write the filter as a literal -- `{ scopes: ["page"], channels: [...], receiver }` -- and a
|
|
382
|
+
* literal is a new object every render. Keyed on the object, the subscription below was torn down and
|
|
383
|
+
* made again on every render of every Controller, and each re-subscription with a receiver flushed the
|
|
384
|
+
* partition's pending signals once more. Equality by content, decided here once, lets a caller write
|
|
385
|
+
* what it means.
|
|
386
|
+
*/
|
|
387
|
+
function filterKey(filter) {
|
|
388
|
+
if (filter === null)
|
|
389
|
+
return "null";
|
|
390
|
+
if (filter === undefined)
|
|
391
|
+
return "";
|
|
392
|
+
const context = filter.context;
|
|
393
|
+
return [
|
|
394
|
+
listKey(filter.scopes), listKey(filter.channels), listKey(filter.actions), listKey(filter.valueSchemas),
|
|
395
|
+
filter.receiver === undefined ? "" : String(filter.receiver),
|
|
396
|
+
context ? [context.siteKey, context.area, context.pageKey, context.regionKey, context.slotKey].map(String).join("\u0001") : "",
|
|
397
|
+
].join("\u0002");
|
|
398
|
+
}
|
|
399
|
+
function receiverKey(receiver) {
|
|
400
|
+
if (receiver == null)
|
|
401
|
+
return receiver === null ? "null" : "";
|
|
402
|
+
return Array.isArray(receiver) ? `[${listKey(receiver)}]` : String(receiver);
|
|
403
|
+
}
|
|
374
404
|
export function usePhiSignalListener(handler, filter, readyReceiver) {
|
|
375
405
|
const partition = usePhiSignalRuntimePartition();
|
|
376
406
|
const handleSignal = useEffectEvent((signal) => {
|
|
377
407
|
handler(signal);
|
|
378
408
|
});
|
|
409
|
+
const filterContent = filterKey(filter);
|
|
410
|
+
const receiverContent = receiverKey(readyReceiver);
|
|
411
|
+
// The same filter in a new object is the same subscription (filterKey above); the keys stand for them.
|
|
412
|
+
const stableFilter = useMemo(() => filter, [filterContent]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
413
|
+
const stableReceiver = useMemo(() => readyReceiver, [receiverContent]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
379
414
|
useEffect(() => {
|
|
380
|
-
if (
|
|
415
|
+
if (stableFilter === null) {
|
|
381
416
|
return undefined;
|
|
382
417
|
}
|
|
383
|
-
return subscribePhiSignals(partition, handleSignal,
|
|
384
|
-
}, [
|
|
418
|
+
return subscribePhiSignals(partition, handleSignal, stableFilter, stableReceiver);
|
|
419
|
+
}, [stableFilter, partition, stableReceiver]);
|
|
385
420
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this render runs in a hydrated browser: false on the server and during hydration -- the HTML a
|
|
3
|
+
* crawler reads -- and true in the render that follows. Seven Controls each kept a copy of this with a
|
|
4
|
+
* `subscribe` that never fires; one hook, so a lazily mounted shell and a protected mail agree on when.
|
|
5
|
+
*/
|
|
6
|
+
export declare function usePhiHydrated(): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
const subscribeNever = () => () => { };
|
|
4
|
+
/**
|
|
5
|
+
* Whether this render runs in a hydrated browser: false on the server and during hydration -- the HTML a
|
|
6
|
+
* crawler reads -- and true in the render that follows. Seven Controls each kept a copy of this with a
|
|
7
|
+
* `subscribe` that never fires; one hook, so a lazily mounted shell and a protected mail agree on when.
|
|
8
|
+
*/
|
|
9
|
+
export function usePhiHydrated() {
|
|
10
|
+
return useSyncExternalStore(subscribeNever, () => true, () => false);
|
|
11
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { formatPhiDate, formatPhiDateTime } from "../../../../helpers/format-date-time";
|
|
4
|
-
import { usePhiIntlLocale } from "../../../root/phi-intl-locale";
|
|
4
|
+
import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../root/phi-intl-locale";
|
|
5
5
|
import { PhiFlexControl } from "../../../controls/phi-flex-control";
|
|
6
6
|
import { PhiTagControl } from "../../../controls/phi-tag-control";
|
|
7
7
|
import { PhiTypographyControl } from "../../../controls/phi-typography-control";
|
|
@@ -33,10 +33,11 @@ function normalizePhiRenderedText(value) {
|
|
|
33
33
|
function resolveTagColor(color) {
|
|
34
34
|
return typeof color === "object" ? color.value : color;
|
|
35
35
|
}
|
|
36
|
-
/** A component rather than a call, because the page's locale
|
|
36
|
+
/** A component rather than a call, because the page's locale and the Site's zone are read from context. */
|
|
37
37
|
function PhiRenderedDate({ value, withTime }) {
|
|
38
38
|
const locale = usePhiIntlLocale();
|
|
39
|
-
|
|
39
|
+
const timeZone = usePhiIntlTimeZone();
|
|
40
|
+
return withTime ? formatPhiDateTime(value, locale, timeZone) : formatPhiDate(value, locale, timeZone);
|
|
40
41
|
}
|
|
41
42
|
export function renderPhiValueContent(value, definition, presentation = "cell") {
|
|
42
43
|
if (value == null || value === "")
|
|
@@ -9,3 +9,8 @@ export declare function readNumberList(value: unknown): number[] | undefined;
|
|
|
9
9
|
export declare function readCssSize(value: unknown): string | number | undefined;
|
|
10
10
|
export declare function readRenderableBlockConfig(config: Record<string, unknown>): PhiRenderableBlockBase;
|
|
11
11
|
export declare function readNavItems(value: unknown): PhiNavItem[] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* A positive whole number from a config, `fallback` where there is none or it is not positive, and no
|
|
14
|
+
* more than `max` where one is named. The list Widgets each parsed their page size this way.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readClampedPositiveInteger(value: unknown, fallback: number, max?: number): number;
|
|
@@ -126,3 +126,14 @@ export function readNavItems(value) {
|
|
|
126
126
|
.filter((item) => item !== null);
|
|
127
127
|
return items.length > 0 ? items : undefined;
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* A positive whole number from a config, `fallback` where there is none or it is not positive, and no
|
|
131
|
+
* more than `max` where one is named. The list Widgets each parsed their page size this way.
|
|
132
|
+
*/
|
|
133
|
+
export function readClampedPositiveInteger(value, fallback, max) {
|
|
134
|
+
const parsed = readInteger(value);
|
|
135
|
+
if (parsed == null || parsed <= 0) {
|
|
136
|
+
return fallback;
|
|
137
|
+
}
|
|
138
|
+
return max == null ? parsed : Math.min(parsed, max);
|
|
139
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PhiBlockRuntime } from "../../../types";
|
|
2
2
|
import type { PhiGlobalTranslatorOptions } from "../../../gateway/tr";
|
|
3
|
-
export declare function buildPhiWidgetLabelTranslatorOptions(runtime: Pick<PhiBlockRuntime, "locale"
|
|
3
|
+
export declare function buildPhiWidgetLabelTranslatorOptions(runtime: Pick<PhiBlockRuntime, "locale">): PhiGlobalTranslatorOptions;
|
|
@@ -2,13 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { getPhiBuilderChromeWidgetLabels } from "../label-sets/builder-chrome";
|
|
3
3
|
import { PhiRuntimeRenderClientType } from "../../../constants/runtime-render-client-types";
|
|
4
4
|
import { PhiRuntimeModuleRenderClientHost } from "../../runtime/runtime-module-render-client-manifest";
|
|
5
|
-
import {
|
|
5
|
+
import { buildPhiWidgetLabelTranslatorOptions } from "../label-sets/runtime-options";
|
|
6
6
|
async function getLabels(runtime) {
|
|
7
|
-
return getPhiBuilderChromeWidgetLabels(
|
|
8
|
-
apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
|
|
9
|
-
internalToken: readPhiServerApiCredentials().internalToken,
|
|
10
|
-
locale: runtime.locale.current,
|
|
11
|
-
});
|
|
7
|
+
return getPhiBuilderChromeWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
|
|
12
8
|
}
|
|
13
9
|
export async function PhiBuilderModeSwitchWidget({ runtime, disabled, }) {
|
|
14
10
|
const labels = await getLabels(runtime);
|
|
@@ -2,13 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { getPhiSearchWidgetLabels } from "../label-sets/search";
|
|
3
3
|
import { PhiRuntimeRenderClientType } from "../../../constants/runtime-render-client-types";
|
|
4
4
|
import { PhiRuntimeModuleRenderClientHost } from "../../runtime/runtime-module-render-client-manifest";
|
|
5
|
-
import {
|
|
5
|
+
import { buildPhiWidgetLabelTranslatorOptions } from "../label-sets/runtime-options";
|
|
6
6
|
async function loadPhiSearchWidgetLabels(runtime) {
|
|
7
|
-
return getPhiSearchWidgetLabels(
|
|
8
|
-
apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
|
|
9
|
-
internalToken: readPhiServerApiCredentials().internalToken,
|
|
10
|
-
locale: runtime.locale.current,
|
|
11
|
-
});
|
|
7
|
+
return getPhiSearchWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
|
|
12
8
|
}
|
|
13
9
|
export async function PhiSearchWidgetServer({ runtime, config, query, defaultQuery, disabled, onQueryChange, onQuerySubmit, }) {
|
|
14
10
|
const labels = await loadPhiSearchWidgetLabels(runtime);
|
|
@@ -3,9 +3,8 @@ import "server-only";
|
|
|
3
3
|
import { isPhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../constants/cms-areas";
|
|
4
4
|
import { canPhiViewerAccess } from "../types/access";
|
|
5
5
|
import { localizeAreaPath } from "../helpers/locale";
|
|
6
|
-
import { readPhiAreaLandingSelection, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
|
|
7
6
|
import { compilePhiCmsActiveRouteTable, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
8
|
-
import {
|
|
7
|
+
import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
|
|
9
8
|
import { getPhiExactSiteArea } from "../server-helpers/cms";
|
|
10
9
|
import { resolveCmsRootRoute } from "../server-helpers/cms-route";
|
|
11
10
|
import { buildPhiBlockRuntime, loadPhiSiteRequestContext, } from "../server-helpers/runtime";
|
|
@@ -63,13 +62,12 @@ async function resolveDashboardCardScope({ bridge, area, locale, path, cookieHea
|
|
|
63
62
|
presetKey: shellBinding.descriptor.presetKey,
|
|
64
63
|
},
|
|
65
64
|
});
|
|
66
|
-
const activeModuleIds
|
|
67
|
-
|
|
65
|
+
const { activeModuleIds, routeTable } = resolvePhiAreaRouteScope({
|
|
66
|
+
runtimeModuleCatalog: bridge.runtimeModuleCatalog,
|
|
68
67
|
catalog,
|
|
69
68
|
area,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
landingSelection: readPhiAreaLandingSelection(areaPreset?.preset.preset.config),
|
|
69
|
+
preset: areaPreset?.preset ?? null,
|
|
70
|
+
serverCapabilities: requestContext.serverCapabilities,
|
|
73
71
|
});
|
|
74
72
|
const cardContext = {
|
|
75
73
|
apiBaseUrl,
|
|
@@ -2,9 +2,8 @@ import { jsonResponse, readPhiInternalRequestPath, splitPhiRequestPath } from ".
|
|
|
2
2
|
import "server-only";
|
|
3
3
|
import { isPhiCmsAreaKey, } from "../constants/cms-areas";
|
|
4
4
|
import { canPhiViewerAccess } from "../types/access";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { resolveActivePresetModuleKeys } from "../server-helpers/cms-request";
|
|
5
|
+
import { normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
6
|
+
import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
|
|
8
7
|
import { resolvePhiCmsLookup } from "../server-helpers/cms-lookup";
|
|
9
8
|
import { getPhiCmsPage, getPhiExactSiteArea } from "../server-helpers/cms";
|
|
10
9
|
import { resolveCmsRootRoute } from "../server-helpers/cms-route";
|
|
@@ -93,15 +92,14 @@ export function buildPhiNavigationTargetRouteHandler({ loadAreaBridge, }) {
|
|
|
93
92
|
cookieHeader,
|
|
94
93
|
sourcePreset,
|
|
95
94
|
});
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const routeTable = compilePhiCmsActiveRouteTable({
|
|
95
|
+
const { routeTable } = resolvePhiAreaRouteScope({
|
|
96
|
+
runtimeModuleCatalog: bridge.runtimeModuleCatalog,
|
|
99
97
|
catalog,
|
|
100
98
|
area,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
landingSelection: readPhiAreaLandingSelection(areaPreset?.preset.preset.config),
|
|
99
|
+
preset: areaPreset?.preset ?? null,
|
|
100
|
+
serverCapabilities: requestContext.serverCapabilities,
|
|
104
101
|
});
|
|
102
|
+
const storagePath = resolveAreaStoragePath(resolvedRoute.cmsPath, area);
|
|
105
103
|
const routeBinding = storagePath
|
|
106
104
|
? resolvePhiCmsRoutePreset(routeTable, storagePath)
|
|
107
105
|
: null;
|
|
@@ -2,12 +2,11 @@ import { jsonResponse } from "./route-handler-helpers";
|
|
|
2
2
|
import "server-only";
|
|
3
3
|
import { isPhiBuilderAreaKey, isPhiCmsAreaKey } from "../constants/cms-areas";
|
|
4
4
|
import { canPhiViewerAccess, PHI_VIEWER_ACCESS_CONTENT_EDITING, PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING } from "../types/access";
|
|
5
|
-
import { readPhiAreaLandingSelection, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
|
|
6
5
|
import { resolvePhiBuilderActivePageCatalog } from "../helpers/cms-page-catalog";
|
|
7
|
-
import {
|
|
6
|
+
import { resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
8
7
|
import { buildPhiAreaActivePresetPages } from "../helpers/cms-preset-page-tree";
|
|
9
8
|
import { buildPhiBuilderPageReferenceTree } from "../helpers/page-reference-tree";
|
|
10
|
-
import {
|
|
9
|
+
import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
|
|
11
10
|
import { getPhiExactSiteArea } from "../server-helpers/cms";
|
|
12
11
|
import { loadPhiSiteRequestContext } from "../server-helpers/runtime";
|
|
13
12
|
import { getSiteCmsPageCatalog } from "./site-page";
|
|
@@ -59,13 +58,12 @@ export function buildPhiPageReferencesRouteHandler({ loadAreaBridge, }) {
|
|
|
59
58
|
},
|
|
60
59
|
})
|
|
61
60
|
: null;
|
|
62
|
-
const
|
|
63
|
-
|
|
61
|
+
const { routeTable } = resolvePhiAreaRouteScope({
|
|
62
|
+
runtimeModuleCatalog: bridge.runtimeModuleCatalog,
|
|
64
63
|
catalog,
|
|
65
64
|
area,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
landingSelection: readPhiAreaLandingSelection(areaPreset?.preset.preset.config),
|
|
65
|
+
preset: areaPreset?.preset ?? null,
|
|
66
|
+
serverCapabilities: requestContext.serverCapabilities,
|
|
69
67
|
});
|
|
70
68
|
const persistedPages = await getSiteCmsPageCatalog({
|
|
71
69
|
apiBaseUrl: runtime.apiBaseUrl,
|
package/gateway/site-config.js
CHANGED
|
@@ -58,6 +58,9 @@ async function fetchSiteConfig({ apiBaseUrl, internalToken, siteKey }, cacheKey)
|
|
|
58
58
|
if (!payload.site.translationMarkers) {
|
|
59
59
|
throw new Error("Missing translation markers in site config payload.");
|
|
60
60
|
}
|
|
61
|
+
if (typeof payload.site.timeZone !== "string" || !payload.site.timeZone.trim()) {
|
|
62
|
+
throw new Error("Missing time zone in site config payload.");
|
|
63
|
+
}
|
|
61
64
|
// Every fresh answer, cached or not afterwards, is where this process learns a translation changed.
|
|
62
65
|
syncPhiTranslationChangeMarkers({
|
|
63
66
|
siteKey,
|
package/gateway/site-proxy.js
CHANGED
|
@@ -59,10 +59,21 @@ async function buildLocallyAnsweredHandlers(answered, { upstreamBaseUrl, timeout
|
|
|
59
59
|
const { buildPhiNavigationTargetRouteHandler } = await import("./navigation-target-route");
|
|
60
60
|
return { GET: buildPhiNavigationTargetRouteHandler({ loadAreaBridge }) };
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Writes that are one person's own and change nothing the read cache holds. The cache keeps the Site's
|
|
64
|
+
* config, Navigation overlays, capabilities and Area doors -- what a publish changes. A Dashboard card
|
|
65
|
+
* dismissed, a message written, an avatar changed are a person's business, and emptying the Site's
|
|
66
|
+
* cache for each of them left it cold for everybody as soon as a few people were signed in.
|
|
67
|
+
*/
|
|
68
|
+
const PERSONAL_WRITE_SEGMENTS = new Set(["user-state", "threads", "account"]);
|
|
69
|
+
function isPersonalWrite(path) {
|
|
70
|
+
return path?.[0] !== undefined && PERSONAL_WRITE_SEGMENTS.has(path[0]);
|
|
71
|
+
}
|
|
62
72
|
/**
|
|
63
73
|
* A write Core accepted may have changed what this Site process keeps in its read cache. Which writes do
|
|
64
74
|
* is not worth listing: config and Navigation carry the theme draft, settings, logo revision and Page
|
|
65
|
-
* paths, and a list would fall behind the next endpoint. Every accepted write clears it
|
|
75
|
+
* paths, and a list would fall behind the next endpoint. Every accepted write clears it, except the
|
|
76
|
+
* personal ones named above, which cannot have.
|
|
66
77
|
*
|
|
67
78
|
* Translations are not cleared here. The next Site config read carries their change markers, and
|
|
68
79
|
* helpers/translation-cache.ts empties only a store whose marker moved.
|
|
@@ -70,7 +81,7 @@ async function buildLocallyAnsweredHandlers(answered, { upstreamBaseUrl, timeout
|
|
|
70
81
|
function clearingReadCacheOnWrite(handler) {
|
|
71
82
|
return async (request, context) => {
|
|
72
83
|
const response = await handler(request, context);
|
|
73
|
-
if (response.ok) {
|
|
84
|
+
if (response.ok && !isPersonalWrite((await context.params).path)) {
|
|
74
85
|
clearPhiSiteReadCache();
|
|
75
86
|
}
|
|
76
87
|
return response;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The class names that are there, joined by a space; undefined where none is.
|
|
3
|
+
*
|
|
4
|
+
* `[a, b].filter(Boolean).join(" ")` stood in sixteen files, half of them with `|| undefined` after it
|
|
5
|
+
* and half without, so some elements carried `class=""` and some did not. One helper, one answer.
|
|
6
|
+
*/
|
|
7
|
+
export declare function joinPhiClassNames(...parts: readonly (string | false | null | undefined)[]): string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The class names that are there, joined by a space; undefined where none is.
|
|
3
|
+
*
|
|
4
|
+
* `[a, b].filter(Boolean).join(" ")` stood in sixteen files, half of them with `|| undefined` after it
|
|
5
|
+
* and half without, so some elements carried `class=""` and some did not. One helper, one answer.
|
|
6
|
+
*/
|
|
7
|
+
export function joinPhiClassNames(...parts) {
|
|
8
|
+
const joined = parts.filter((part) => typeof part === "string" && part.length > 0).join(" ");
|
|
9
|
+
return joined.length > 0 ? joined : undefined;
|
|
10
|
+
}
|
|
@@ -164,7 +164,8 @@ export function resolvePhiBuilderNavigationPageTargets(area, items, pagesForArea
|
|
|
164
164
|
byArea.set(targetArea, index);
|
|
165
165
|
return index;
|
|
166
166
|
};
|
|
167
|
-
|
|
167
|
+
// One index per Area for the whole tree: the recursion below shares it rather than building its own.
|
|
168
|
+
const resolve = (list) => list.map((item) => {
|
|
168
169
|
const targetArea = item.targetArea ?? area;
|
|
169
170
|
const page = item.targetReference ? pageIndex(targetArea).get(item.targetReference) : null;
|
|
170
171
|
return {
|
|
@@ -175,7 +176,8 @@ export function resolvePhiBuilderNavigationPageTargets(area, items, pagesForArea
|
|
|
175
176
|
: null,
|
|
176
177
|
targetDeleted: page == null || page.tombstoned === true,
|
|
177
178
|
} : {}),
|
|
178
|
-
children:
|
|
179
|
+
children: resolve(item.children),
|
|
179
180
|
};
|
|
180
181
|
});
|
|
182
|
+
return resolve(items);
|
|
181
183
|
}
|
|
@@ -18,6 +18,35 @@ function findPagePathSegments(pages, targetKey, prefix = []) {
|
|
|
18
18
|
}
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Every node's path, indexed by key, once per catalog array.
|
|
23
|
+
*
|
|
24
|
+
* The catalog's own walkers asked `findPhiPageNodePath` for every node they visited, each call a walk
|
|
25
|
+
* of the whole tree with a copy of the array: the Builder's page list, its storage paths and its
|
|
26
|
+
* navigation targets were quadratic in the number of Pages. The index is held on the array it was
|
|
27
|
+
* built from, so a catalog that is handed around is walked once.
|
|
28
|
+
*/
|
|
29
|
+
const pageNodePathIndex = new WeakMap();
|
|
30
|
+
function readPhiPageNodePath(pages, targetKey) {
|
|
31
|
+
let index = pageNodePathIndex.get(pages);
|
|
32
|
+
if (!index) {
|
|
33
|
+
index = new Map();
|
|
34
|
+
const collect = (nodes, prefix) => {
|
|
35
|
+
for (const node of nodes) {
|
|
36
|
+
const path = [...prefix, node];
|
|
37
|
+
if (!index.has(node.key)) {
|
|
38
|
+
index.set(node.key, path);
|
|
39
|
+
}
|
|
40
|
+
if (node.children) {
|
|
41
|
+
collect(node.children, path);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
collect(pages, []);
|
|
46
|
+
pageNodePathIndex.set(pages, index);
|
|
47
|
+
}
|
|
48
|
+
return index.get(targetKey) ?? null;
|
|
49
|
+
}
|
|
21
50
|
export function findPhiPageNodePath(pages, targetKey, prefix = []) {
|
|
22
51
|
for (const page of pages) {
|
|
23
52
|
const currentPath = [...prefix, page];
|
|
@@ -69,7 +98,7 @@ function findFirstPhiBuilderPageNodeKey(pages) {
|
|
|
69
98
|
}
|
|
70
99
|
export function resolvePhiBuilderActivePageKey(requestedPageKey, pages) {
|
|
71
100
|
const normalizedPageKey = requestedPageKey?.trim() ?? "";
|
|
72
|
-
if (normalizedPageKey &&
|
|
101
|
+
if (normalizedPageKey && readPhiPageNodePath(pages, normalizedPageKey)) {
|
|
73
102
|
return normalizedPageKey;
|
|
74
103
|
}
|
|
75
104
|
/*
|
|
@@ -79,10 +108,10 @@ export function resolvePhiBuilderActivePageKey(requestedPageKey, pages) {
|
|
|
79
108
|
return findFirstPhiBuilderPageNodeKey(pages);
|
|
80
109
|
}
|
|
81
110
|
export function resolvePhiBuilderPagePresetSource(pageKey, pages) {
|
|
82
|
-
return
|
|
111
|
+
return readPhiPageNodePath(pages, pageKey)?.at(-1)?.sourcePreset ?? null;
|
|
83
112
|
}
|
|
84
113
|
export function resolvePhiBuilderPageDefaultFlags(pageKey, pages) {
|
|
85
|
-
return
|
|
114
|
+
return readPhiPageNodePath(pages, pageKey)?.at(-1)?.defaultPageFlags ?? 0;
|
|
86
115
|
}
|
|
87
116
|
export function normalizePhiBuilderCmsCatalogPath(value) {
|
|
88
117
|
const trimmed = value.trim();
|
|
@@ -114,7 +143,7 @@ function collectPresetStoragePaths(area, pages) {
|
|
|
114
143
|
return storagePaths;
|
|
115
144
|
}
|
|
116
145
|
export function resolvePhiBuilderCmsStoragePathForCatalog(area, pageKey, pages) {
|
|
117
|
-
const node =
|
|
146
|
+
const node = readPhiPageNodePath(pages, pageKey)?.at(-1);
|
|
118
147
|
if (!node) {
|
|
119
148
|
throw new Error(`Page "${area}:${pageKey}" is not present in the active Builder Page catalog.`);
|
|
120
149
|
}
|
|
@@ -133,13 +162,13 @@ export function resolvePhiBuilderCmsStoragePathForCatalog(area, pageKey, pages)
|
|
|
133
162
|
* than a fault. Asking the throwing function that question took the Page Select down with it.
|
|
134
163
|
*/
|
|
135
164
|
export function findPhiBuilderCatalogPathForCatalog(area, pageKey, pages) {
|
|
136
|
-
return
|
|
165
|
+
return readPhiPageNodePath(pages, pageKey)
|
|
137
166
|
? resolvePhiBuilderCatalogPathForCatalog(area, pageKey, pages)
|
|
138
167
|
: null;
|
|
139
168
|
}
|
|
140
169
|
/** Where the Builder shows a Page, which is what its picker offers and its path signal carries. */
|
|
141
170
|
export function resolvePhiBuilderCatalogPathForCatalog(area, pageKey, pages) {
|
|
142
|
-
const node =
|
|
171
|
+
const node = readPhiPageNodePath(pages, pageKey)?.at(-1);
|
|
143
172
|
if (node?.catalogPath) {
|
|
144
173
|
return normalizePhiBuilderCmsCatalogPath(node.catalogPath);
|
|
145
174
|
}
|
|
@@ -24,7 +24,6 @@ export declare function isPhiCmsPageOwnedRegion(regionKey: string): regionKey is
|
|
|
24
24
|
* can stand: navigation that rebuilds itself on every step is navigation that flickers.
|
|
25
25
|
*/
|
|
26
26
|
export type PhiCmsRegionOwnership = "shell" | "page";
|
|
27
|
-
export declare function resolvePhiCmsRegionOwnership(regionKey: string | null | undefined): PhiCmsRegionOwnership | undefined;
|
|
28
27
|
/**
|
|
29
28
|
* Whether a Widget asking for one kind of Region may stand in this one.
|
|
30
29
|
*
|