@phis/ui 0.5.4 → 0.5.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/components/cms/phi-cms-layout-renderer.js +17 -7
- package/components/controls/phi-anchor-nav-control.js +18 -1
- package/components/layouts/clients/phi-flex-layout-client.js +17 -2
- package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
- package/components/layouts/clients/phi-layout-anchored-overlay.js +2 -0
- package/components/regions/presets/content-entry-editor-page-tree.js +2 -0
- package/components/regions/presets/content-entry-public-page-trees.js +2 -0
- package/components/widgets/builder/stack-tabs.d.ts +2 -1
- package/components/widgets/builder/stack-tabs.js +18 -2
- package/components/widgets/config/choice-shared.d.ts +0 -48
- package/components/widgets/config/choice-shared.js +0 -1
- package/components/widgets/config/stack-tabs.js +4 -3
- package/components/widgets/shared/card-body-client.d.ts +6 -2
- package/components/widgets/shared/card-body-client.js +27 -20
- package/components/widgets/shared/card-vocabulary.d.ts +7 -0
- package/components/widgets/shared/card-vocabulary.js +6 -0
- package/components/widgets/shared/markdown-body-client.js +7 -2
- package/constants/module-identity.d.ts +8 -0
- package/constants/module-identity.js +13 -0
- package/gateway/server-module-media.d.ts +12 -0
- package/gateway/server-module-media.js +83 -0
- package/helpers/cms-navigation-catalog.js +4 -1
- package/helpers/cms-page-catalog.d.ts +7 -0
- package/helpers/cms-preset-page-tree.js +16 -1
- package/helpers/config-text-fields.d.ts +49 -0
- package/helpers/config-text-fields.js +122 -0
- package/helpers/module-media-check.d.ts +23 -0
- package/helpers/module-media-check.js +32 -0
- package/helpers/module-media.d.ts +7 -0
- package/helpers/module-media.js +15 -0
- package/helpers/preset-text-source-check.d.ts +22 -0
- package/helpers/preset-text-source-check.js +45 -0
- package/helpers/route-address-check.d.ts +35 -0
- package/helpers/route-address-check.js +28 -0
- package/helpers/text-source.d.ts +14 -5
- package/helpers/text-source.js +16 -3
- package/module-page-check.d.ts +3 -0
- package/module-page-check.js +3 -0
- package/package.json +1 -1
- package/plugins/runtime/phi-slot-child-frame-view.js +1 -1
- package/plugins/runtime/slot-size-policy.d.ts +8 -2
- package/plugins/runtime/slot-size-policy.js +51 -16
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +2 -0
- package/plugins/runtime-modules/builder/area-shell-presets.server.js +2 -0
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
- package/plugins/runtime-modules/builder/navigation-folder-drop.js +2 -1
- package/plugins/runtime-modules/builder/options-providers.js +7 -1
- package/plugins/runtime-modules/builder/page-presets.server.js +2 -0
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -0
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +11 -0
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +9 -2
- package/plugins/runtime-modules/core/widgets/button/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/button/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/button/plugin.js +6 -25
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +24 -2
- package/plugins/runtime-modules/core/widgets/card/config.js +35 -3
- package/plugins/runtime-modules/core/widgets/card/editor.js +2 -0
- package/plugins/runtime-modules/core/widgets/card/plugin.js +8 -10
- package/plugins/runtime-modules/core/widgets/card/server.d.ts +1 -2
- package/plugins/runtime-modules/core/widgets/card/server.js +18 -28
- package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +7 -1
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +1 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.js +3 -3
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/image/server.js +5 -9
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/markdown-toc/server.js +3 -5
- package/plugins/runtime-modules/core/widgets/quick-links/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/quick-links/server.d.ts +2 -5
- package/plugins/runtime-modules/core/widgets/quick-links/server.js +2 -6
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/result/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/result/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/result/server.d.ts +2 -3
- package/plugins/runtime-modules/core/widgets/result/server.js +11 -33
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/slider/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/slider/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/config.js +0 -2
- package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +3 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/server.js +5 -13
- package/plugins/runtime-modules/core/widgets/spacer/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/spacer/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/steps/config.d.ts +7 -2
- package/plugins/runtime-modules/core/widgets/steps/config.js +1 -2
- package/plugins/runtime-modules/core/widgets/steps/plugin.js +6 -30
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/table/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/timeline/config.d.ts +8 -1
- package/plugins/runtime-modules/core/widgets/timeline/config.js +1 -2
- package/plugins/runtime-modules/core/widgets/timeline/plugin.js +6 -37
- package/plugins/runtime-modules/descriptor-compiler.d.ts +23 -3
- package/plugins/runtime-modules/descriptor-compiler.js +107 -12
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -0
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -0
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -0
- package/plugins/runtime-modules/page-preset-overlays.d.ts +18 -0
- package/plugins/runtime-modules/page-preset-overlays.js +70 -0
- package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +1 -0
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -0
- package/plugins/runtime-modules/search/widgets/search-box/server.js +3 -5
- package/plugins/runtime-modules/search/widgets/search-results/server.js +3 -5
- package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +4 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +2 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +2 -0
- package/server-helpers/cms-area.js +9 -1
- package/server-helpers/cms-request.js +49 -14
- package/server-helpers/cms-root.js +2 -0
- package/server-helpers/cms-widget-texts.d.ts +14 -0
- package/server-helpers/cms-widget-texts.js +117 -0
- package/server-helpers/module-folder-targets.d.ts +7 -0
- package/server-helpers/module-folder-targets.js +15 -0
- package/server-helpers/search-index.js +12 -3
- package/styles/root.css +6 -2
- package/types/cms-module-descriptors.d.ts +24 -0
- package/types/cms-plugins.d.ts +30 -5
- package/types/core-widget-placements.d.ts +5 -0
- package/types/module-media.d.ts +31 -0
- package/types/module-media.js +11 -0
- package/types/slot-size-policy.d.ts +19 -2
- package/types.d.ts +1 -0
|
@@ -58,6 +58,14 @@ export function createPhiLayoutOwnTextTranslator(plugin, node, runtime) {
|
|
|
58
58
|
return texts.map((text, index) => (text.trim() ? translated[index]?.trim() || text : text));
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The tree with its Widgets' words in the reader's language (`server-helpers/cms-widget-texts.ts`),
|
|
63
|
+
* imported lazily as the passes beside it are.
|
|
64
|
+
*/
|
|
65
|
+
async function translatePhiCmsTreeWidgetTexts(tree, registry, runtime) {
|
|
66
|
+
const { translatePhiCmsTreeWidgetTexts: translate } = await import("../../server-helpers/cms-widget-texts");
|
|
67
|
+
return translate(tree, registry, runtime);
|
|
68
|
+
}
|
|
61
69
|
/** Lazily imported for the reason above: the pass is `server-only`, the helpers beside it are not. */
|
|
62
70
|
async function resolvePhiCmsTreeLinkTargets(...args) {
|
|
63
71
|
const { resolvePhiCmsTreeLinkTargets: resolve } = await import("../../server-helpers/cms-link-targets");
|
|
@@ -268,16 +276,17 @@ function buildLayoutTree(tree, blockDefaultsByType) {
|
|
|
268
276
|
});
|
|
269
277
|
}
|
|
270
278
|
export async function preparePhiCmsOverlayRenderContext({ tree, runtime, registry, signalScope, }) {
|
|
271
|
-
const [featureResolution, links] = await Promise.all([
|
|
279
|
+
const [featureResolution, links, translatedTree] = await Promise.all([
|
|
272
280
|
resolvePhiCmsTreeFeatures(tree, registry, runtime),
|
|
273
281
|
resolvePhiCmsTreeLinkTargets(tree, runtime),
|
|
282
|
+
translatePhiCmsTreeWidgetTexts(tree, registry, runtime),
|
|
274
283
|
]);
|
|
275
284
|
return {
|
|
276
|
-
tree,
|
|
285
|
+
tree: translatedTree,
|
|
277
286
|
runtime,
|
|
278
287
|
registry,
|
|
279
288
|
signalScope,
|
|
280
|
-
createNode: buildLayoutNodeResolver(
|
|
289
|
+
createNode: buildLayoutNodeResolver(translatedTree, registry.widgetBlockDefaultsByType),
|
|
281
290
|
// From the whole tree, not the Overlay alone: a block is a participant when anything in the tree
|
|
282
291
|
// addresses it, and that is the same answer whether the zones render with the page or on demand.
|
|
283
292
|
signalParticipants: resolvePhiTreeSignalParticipants(tree),
|
|
@@ -739,14 +748,15 @@ function renderLayoutNode(node, context) {
|
|
|
739
748
|
return (_jsxs("div", { "data-phi-cms-orphaned-layout": node.widgetType, style: { display: "flex", flexDirection: "column", gap: 21, width: "100%", minWidth: 0 }, children: [diagnostic, orphanedChildren] }));
|
|
740
749
|
}
|
|
741
750
|
export async function PhiCmsLayoutRenderer({ tree, runtime, regionClassName, regionTypes, stackGap = 21, registry, }) {
|
|
742
|
-
const
|
|
751
|
+
const viewerTree = filterPhiCmsRenderableTreeForViewer({
|
|
743
752
|
tree,
|
|
744
753
|
viewer: runtime.viewer,
|
|
745
754
|
registry,
|
|
746
755
|
});
|
|
747
|
-
const [{ features, failures: featureFailures }, links] = await Promise.all([
|
|
748
|
-
resolvePhiCmsTreeFeatures(
|
|
749
|
-
resolvePhiCmsTreeLinkTargets(
|
|
756
|
+
const [{ features, failures: featureFailures }, links, filteredTree] = await Promise.all([
|
|
757
|
+
resolvePhiCmsTreeFeatures(viewerTree, registry, runtime),
|
|
758
|
+
resolvePhiCmsTreeLinkTargets(viewerTree, runtime),
|
|
759
|
+
translatePhiCmsTreeWidgetTexts(viewerTree, registry, runtime),
|
|
750
760
|
]);
|
|
751
761
|
const signalParticipants = resolvePhiTreeSignalParticipants(filteredTree);
|
|
752
762
|
const allowedRegionTypes = regionTypes ? new Set(regionTypes) : null;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { Anchor } from "antd";
|
|
4
|
+
/**
|
|
5
|
+
* Tells the page about a jump the way a link to `#id` would.
|
|
6
|
+
*
|
|
7
|
+
* Ant Design scrolls to the place itself and writes the address with `history.pushState`, which fires no
|
|
8
|
+
* `hashchange` -- so whatever opens on its fragment (a folded section, `markdown-body-client.tsx`) never
|
|
9
|
+
* heard of the jump and the reader landed on a closed question. Sent once the address is written, after
|
|
10
|
+
* the click. It is not the browser's event (`isTrusted` is false): a listener reads that the scroll is
|
|
11
|
+
* this Control's and leaves it alone.
|
|
12
|
+
*/
|
|
13
|
+
function announcePhiInPageJump(oldURL) {
|
|
14
|
+
queueMicrotask(() => {
|
|
15
|
+
const newURL = window.location.href;
|
|
16
|
+
if (newURL !== oldURL) {
|
|
17
|
+
window.dispatchEvent(new HashChangeEvent("hashchange", { oldURL, newURL }));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
4
21
|
/**
|
|
5
22
|
* Links to places on the same page, with the one currently in view marked.
|
|
6
23
|
*
|
|
@@ -8,7 +25,7 @@ import { Anchor } from "antd";
|
|
|
8
25
|
* page, the shape a table of contents takes. It stays where it is drawn and never pins itself.
|
|
9
26
|
*/
|
|
10
27
|
export function PhiAnchorNavControl({ items, offsetTop = 0, style }) {
|
|
11
|
-
return (_jsx(Anchor, { affix: false, offsetTop: offsetTop, items: [...items], className: "phi-anchor-nav-control",
|
|
28
|
+
return (_jsx(Anchor, { affix: false, offsetTop: offsetTop, items: [...items], onClick: () => announcePhiInPageJump(window.location.href), className: "phi-anchor-nav-control",
|
|
12
29
|
// As wide as its slot and no wider: Ant Design sizes the list to its longest title, which in a
|
|
13
30
|
// narrow sider ran past the edge. Within the slot a long title ends in an ellipsis, Ant Design's own.
|
|
14
31
|
style: { maxWidth: "100%", minWidth: 0, ...style } }));
|
|
@@ -96,6 +96,21 @@ export function PhiFlexLayout({ slots, ...layoutProps }) {
|
|
|
96
96
|
function isRenderableSlotChild(child) {
|
|
97
97
|
return child !== null && child !== undefined && child !== false;
|
|
98
98
|
}
|
|
99
|
+
/*
|
|
100
|
+
* Whether a content child takes the rest of the main axis. A child does when it states `rest` and still
|
|
101
|
+
* fills that axis (a stated size makes the axis `fixed`). Where any does, the others that fill the main
|
|
102
|
+
* axis keep their content size on it, so the rest is shared among those that took it and nobody else.
|
|
103
|
+
*/
|
|
104
|
+
const mainAxisHasRestTaker = slots.some((child, index) => {
|
|
105
|
+
if (!isRenderableSlotChild(child) || isFlexSeparatorChild(child)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if ((resolvedSlotStates[index] ?? "expanded") !== "expanded") {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const sizing = resolvePhiLayoutSlotChildSizing(child);
|
|
112
|
+
return sizing.takesRest && (resolvedVertical ? sizing.stretchesBlock : sizing.stretchesInline);
|
|
113
|
+
});
|
|
99
114
|
const renderSlotChild = (child, index) => {
|
|
100
115
|
if (isFlexSeparatorChild(child)) {
|
|
101
116
|
return child;
|
|
@@ -122,7 +137,7 @@ export function PhiFlexLayout({ slots, ...layoutProps }) {
|
|
|
122
137
|
}
|
|
123
138
|
: {};
|
|
124
139
|
if (resolvedVertical) {
|
|
125
|
-
const shouldFillMainAxis = slotSizing.stretchesBlock;
|
|
140
|
+
const shouldFillMainAxis = slotSizing.stretchesBlock && (!mainAxisHasRestTaker || slotSizing.takesRest);
|
|
126
141
|
const shouldFillCrossAxis = slotSizing.stretchesInline;
|
|
127
142
|
return (_jsx("div", { className: phiLayoutSlotClassName(isAuthoringRender), "data-phi-layout-has-content": phiLayoutSlotContentMarker(isAuthoringRender, true), style: {
|
|
128
143
|
flexGrow: shouldFillMainAxis ? 1 : 0,
|
|
@@ -166,7 +181,7 @@ export function PhiFlexLayout({ slots, ...layoutProps }) {
|
|
|
166
181
|
}),
|
|
167
182
|
}, children: child }, `content-${index}`));
|
|
168
183
|
}
|
|
169
|
-
const shouldFillMainAxis = slotSizing.stretchesInline;
|
|
184
|
+
const shouldFillMainAxis = slotSizing.stretchesInline && (!mainAxisHasRestTaker || slotSizing.takesRest);
|
|
170
185
|
const shouldFillCrossAxis = slotSizing.stretchesBlock;
|
|
171
186
|
const minMainSize = slotSizing.minInlineSize;
|
|
172
187
|
const maxMainSize = slotSizing.maxInlineSize;
|
|
@@ -17,6 +17,8 @@ export type PhiLayoutSlotChildSizing = {
|
|
|
17
17
|
*/
|
|
18
18
|
stretchesInline: boolean;
|
|
19
19
|
stretchesBlock: boolean;
|
|
20
|
+
/** The child states `rest`; a Flex Layout also asks whether it still fills its main axis. */
|
|
21
|
+
takesRest: boolean;
|
|
20
22
|
minInlineSize: CSSProperties["minWidth"];
|
|
21
23
|
minBlockSize: CSSProperties["minHeight"];
|
|
22
24
|
maxInlineSize: CSSProperties["maxWidth"];
|
|
@@ -22,6 +22,7 @@ export function resolvePhiLayoutSlotChildSizing(child) {
|
|
|
22
22
|
hasExplicitHeight: slotSizing.explicitBlockSize,
|
|
23
23
|
stretchesInline: slotSizing.policy.inline === "fill",
|
|
24
24
|
stretchesBlock: slotSizing.policy.block === "fill",
|
|
25
|
+
takesRest: slotSizing.policy.takesRest === true,
|
|
25
26
|
minInlineSize: slotSizing.minInlineSize,
|
|
26
27
|
minBlockSize: slotSizing.minBlockSize,
|
|
27
28
|
maxInlineSize: slotSizing.maxInlineSize,
|
|
@@ -90,6 +91,7 @@ export function PhiLayoutAnchoredOverlay({ anchor, slotRole, positionMode = "abs
|
|
|
90
91
|
}, ...buildPhiSlotChildDataAttributes({
|
|
91
92
|
inline: slotSizing.fillInline ? "fill" : "intrinsic",
|
|
92
93
|
block: slotSizing.fillBlock ? "fill" : "intrinsic",
|
|
94
|
+
...(slotSizing.takesRest ? { takesRest: true } : {}),
|
|
93
95
|
}, {
|
|
94
96
|
explicitInlineSize: slotSizing.hasExplicitWidth,
|
|
95
97
|
explicitBlockSize: slotSizing.hasExplicitHeight,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, } from "../../../constants/cms-layout-types";
|
|
2
3
|
import { PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS } from "../../../constants/core-data-provider-keys";
|
|
3
4
|
import { canPhiViewerAccess, PHI_VIEWER_ACCESS_PUBLISHING } from "../../../types/access";
|
|
@@ -182,6 +183,7 @@ function buildEntryDialogNodes(nodes, input) {
|
|
|
182
183
|
label: `${input.routePrefix} ${input.key} commands`,
|
|
183
184
|
config: {
|
|
184
185
|
key: `${prefix}-commands`,
|
|
186
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
185
187
|
...PHI_DIALOG_COMMANDS_CONFIG,
|
|
186
188
|
/*
|
|
187
189
|
* The two buttons as one group, the way every other overlay footer states it: they are the two
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../helpers/text-source";
|
|
1
2
|
import "server-only";
|
|
2
3
|
import { notFound } from "next/navigation";
|
|
3
4
|
import { createPhiPresetCmsInstanceIdMap } from "../../../types/cms-instance-id";
|
|
@@ -129,6 +130,7 @@ export async function buildPhiContentEntryDetailPageTree({ page, runtime, params
|
|
|
129
130
|
config: {
|
|
130
131
|
kind,
|
|
131
132
|
source: "related",
|
|
133
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
132
134
|
relatedTo: entry,
|
|
133
135
|
presentation: related.presentation,
|
|
134
136
|
...listPartsFor(related.presentation),
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { PhiCmsBuilderWidgetPlugin } from "../../../types";
|
|
1
2
|
import { type PhiCmsTabBarWidgetConfig } from "../config/stack-tabs";
|
|
2
|
-
export declare const PHI_TAB_BAR_WIDGET_BUILDER_PLUGIN:
|
|
3
|
+
export declare const PHI_TAB_BAR_WIDGET_BUILDER_PLUGIN: PhiCmsBuilderWidgetPlugin<PhiCmsTabBarWidgetConfig>;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createPhiCmsBuilderWidgetPlugin } from "../../../plugins/factories/widget-builder-plugin";
|
|
4
3
|
import { PHI_TAB_BAR_WIDGET_DEFINITION, } from "../config/stack-tabs";
|
|
5
4
|
import { PhiTabBarWidgetClient } from "../client/stack-tabs";
|
|
6
|
-
|
|
5
|
+
import { PhiStaticOptionsToolButton } from "./phi-static-options-picker";
|
|
6
|
+
export const PHI_TAB_BAR_WIDGET_BUILDER_PLUGIN = {
|
|
7
|
+
...PHI_TAB_BAR_WIDGET_DEFINITION,
|
|
8
|
+
renderEditor: ({ config }) => _jsx(PhiTabBarWidgetClient, { config: config }),
|
|
9
|
+
/*
|
|
10
|
+
* Static options only where they are what is drawn: not while a provider answers for them, and not
|
|
11
|
+
* while the tabs are the followed Stack's slots.
|
|
12
|
+
*/
|
|
13
|
+
renderEditorTools: ({ config, authoring }) => authoring?.updateConfig && !config.optionsProvider && config.valueMode !== "stack-slot-index" ? (_jsx(PhiStaticOptionsToolButton, { options: config.options, onApply: (options) => {
|
|
14
|
+
const selectedValue = config.value?.trim();
|
|
15
|
+
authoring.updateConfig?.({
|
|
16
|
+
options,
|
|
17
|
+
...(!selectedValue || options.some((option) => option.value === selectedValue)
|
|
18
|
+
? {}
|
|
19
|
+
: { value: options[0]?.value }),
|
|
20
|
+
});
|
|
21
|
+
} })) : null,
|
|
22
|
+
};
|
|
@@ -64,54 +64,6 @@ export declare function buildPhiChoiceControlOptionFields(editorPlacement?: "ins
|
|
|
64
64
|
emptyLabel?: undefined;
|
|
65
65
|
itemFields?: undefined;
|
|
66
66
|
})[];
|
|
67
|
-
export declare const PHI_CHOICE_CONTROL_OPTION_FIELDS: ({
|
|
68
|
-
key: string;
|
|
69
|
-
type: "collection";
|
|
70
|
-
label: string;
|
|
71
|
-
editorPlacement: "inspector" | "toolbar";
|
|
72
|
-
itemKeyField: string;
|
|
73
|
-
itemLabelField: string;
|
|
74
|
-
defaultItem: {
|
|
75
|
-
value: string;
|
|
76
|
-
label: string;
|
|
77
|
-
};
|
|
78
|
-
addLabel: string;
|
|
79
|
-
emptyLabel: string;
|
|
80
|
-
itemFields: ({
|
|
81
|
-
key: string;
|
|
82
|
-
type: "icon";
|
|
83
|
-
label: string;
|
|
84
|
-
required?: undefined;
|
|
85
|
-
} | {
|
|
86
|
-
key: string;
|
|
87
|
-
type: "string";
|
|
88
|
-
label: string;
|
|
89
|
-
required: true;
|
|
90
|
-
} | {
|
|
91
|
-
key: string;
|
|
92
|
-
type: "string";
|
|
93
|
-
label: string;
|
|
94
|
-
required?: undefined;
|
|
95
|
-
} | {
|
|
96
|
-
key: string;
|
|
97
|
-
type: "boolean";
|
|
98
|
-
label: string;
|
|
99
|
-
required?: undefined;
|
|
100
|
-
})[];
|
|
101
|
-
providerKind?: undefined;
|
|
102
|
-
} | {
|
|
103
|
-
key: string;
|
|
104
|
-
type: "data-provider";
|
|
105
|
-
providerKind: "options";
|
|
106
|
-
label: string;
|
|
107
|
-
editorPlacement?: undefined;
|
|
108
|
-
itemKeyField?: undefined;
|
|
109
|
-
itemLabelField?: undefined;
|
|
110
|
-
defaultItem?: undefined;
|
|
111
|
-
addLabel?: undefined;
|
|
112
|
-
emptyLabel?: undefined;
|
|
113
|
-
itemFields?: undefined;
|
|
114
|
-
})[];
|
|
115
67
|
export declare function parsePhiChoiceOptionsConfig(config: Record<string, unknown>): PhiChoiceOptionsConfig;
|
|
116
68
|
export declare const PHI_CHOICE_CONTROL_CONFIG_FIELDS: ({
|
|
117
69
|
key: string;
|
|
@@ -26,7 +26,6 @@ export function buildPhiChoiceControlOptionFields(editorPlacement = "inspector")
|
|
|
26
26
|
label: "Options Source",
|
|
27
27
|
}];
|
|
28
28
|
}
|
|
29
|
-
export const PHI_CHOICE_CONTROL_OPTION_FIELDS = buildPhiChoiceControlOptionFields();
|
|
30
29
|
export function parsePhiChoiceOptionsConfig(config) {
|
|
31
30
|
const reader = createPhiConfigReader(config);
|
|
32
31
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createPhiConfigReader } from "./strict-config-reader";
|
|
2
|
-
import {
|
|
2
|
+
import { buildPhiChoiceControlOptionFields, PHI_CHOICE_CONTROL_CONFIG_FIELDS, PHI_CHOICE_CONTROL_VALUE_MODE_FIELD, parsePhiStackChoiceControlConfig, } from "./choice-shared";
|
|
3
3
|
import { createPhiCmsWidgetDefinition } from "./helpers";
|
|
4
4
|
import { PHI_SELECT_CONTROL_SIGNALS } from "../signals/control-signal-capabilities";
|
|
5
5
|
function parsePhiCmsTabBarWidgetConfig(config) {
|
|
@@ -14,7 +14,7 @@ export const PHI_TAB_BAR_WIDGET_DEFINITION = createPhiCmsWidgetDefinition({
|
|
|
14
14
|
description: "Reusable tab control that emits runtime state signals and can optionally control stack slots.",
|
|
15
15
|
category: "navigation",
|
|
16
16
|
iconFamily: "basic",
|
|
17
|
-
slotSizePolicy: "fill-block",
|
|
17
|
+
slotSizePolicy: { configField: "placement", byValue: { left: "fill-block", right: "fill-block" }, otherwise: "fill-inline" },
|
|
18
18
|
runtimeSignals: {
|
|
19
19
|
...PHI_SELECT_CONTROL_SIGNALS,
|
|
20
20
|
},
|
|
@@ -39,7 +39,8 @@ export const PHI_TAB_BAR_WIDGET_DEFINITION = createPhiCmsWidgetDefinition({
|
|
|
39
39
|
{ value: "right", label: "Right" },
|
|
40
40
|
],
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
/* Edited in the scaffold's dialog, as every choice Widget's static options are. */
|
|
43
|
+
...buildPhiChoiceControlOptionFields("toolbar"),
|
|
43
44
|
...PHI_CHOICE_CONTROL_CONFIG_FIELDS,
|
|
44
45
|
],
|
|
45
46
|
parseConfig: parsePhiCmsTabBarWidgetConfig,
|
|
@@ -7,8 +7,8 @@ import type { PhiImagePresentation } from "../../media/image-presentation";
|
|
|
7
7
|
import type { PhiClientBlockBaseProps } from "../../../types";
|
|
8
8
|
import type { PhiSurface } from "../../../types/surface";
|
|
9
9
|
import type { PhiSignalRouteSet } from "../../../types/signals";
|
|
10
|
-
import type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody } from "./card-vocabulary";
|
|
11
|
-
export type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody, } from "./card-vocabulary";
|
|
10
|
+
import type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardIconSize, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody } from "./card-vocabulary";
|
|
11
|
+
export type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardIconSize, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody, } from "./card-vocabulary";
|
|
12
12
|
export type PhiCardWidgetClientLabels = {
|
|
13
13
|
eyebrow?: string;
|
|
14
14
|
/**
|
|
@@ -62,6 +62,10 @@ export type PhiCardWidgetClientConfig = {
|
|
|
62
62
|
/** The icon's colour and its ground; absent, the Theme's. */
|
|
63
63
|
iconColor?: string;
|
|
64
64
|
iconBackground?: string;
|
|
65
|
+
/** How large the icon is drawn; absent is `default`. */
|
|
66
|
+
iconSize?: PhiCardIconSize;
|
|
67
|
+
/** `false` draws the icon without its ground; absent is framed, as a card always drew it. */
|
|
68
|
+
iconFramed?: boolean;
|
|
65
69
|
textAlign?: PhiCardTextAlign;
|
|
66
70
|
headingLevel?: PhiCardHeadingLevel;
|
|
67
71
|
/** Where the whole card leads, already resolved to an address. */
|
|
@@ -56,8 +56,7 @@ const PHI_CARD_VARIANT_METRICS = {
|
|
|
56
56
|
h4: { fontSize: token.fontSizeHeading4, lineHeight: token.lineHeightHeading4 },
|
|
57
57
|
},
|
|
58
58
|
descriptionSize: token.fontSizeLG,
|
|
59
|
-
|
|
60
|
-
topIconSize: 40,
|
|
59
|
+
iconSizes: { default: { inline: 24, top: 40 }, large: { inline: 40, top: 64 }, xlarge: { inline: 64, top: 96 } },
|
|
61
60
|
buttonSize: "medium",
|
|
62
61
|
}),
|
|
63
62
|
compact: (token) => ({
|
|
@@ -69,8 +68,7 @@ const PHI_CARD_VARIANT_METRICS = {
|
|
|
69
68
|
h4: { fontSize: token.fontSizeHeading5, lineHeight: token.lineHeightHeading5 },
|
|
70
69
|
},
|
|
71
70
|
descriptionSize: token.fontSize,
|
|
72
|
-
|
|
73
|
-
topIconSize: 32,
|
|
71
|
+
iconSizes: { default: { inline: 20, top: 32 }, large: { inline: 24, top: 40 }, xlarge: { inline: 40, top: 64 } },
|
|
74
72
|
buttonSize: "small",
|
|
75
73
|
// A strip rather than a poster, so the words stay the larger part of a compact card.
|
|
76
74
|
mediaAspectRatio: "2 / 1",
|
|
@@ -145,9 +143,11 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
145
143
|
const variant = config?.variant ?? "default";
|
|
146
144
|
const body = config?.body ?? "text";
|
|
147
145
|
const metrics = (PHI_CARD_VARIANT_METRICS[variant] ?? PHI_CARD_VARIANT_METRICS.default)(token);
|
|
148
|
-
const { inset, gap, headingType, descriptionSize,
|
|
146
|
+
const { inset, gap, headingType, descriptionSize, buttonSize } = metrics;
|
|
149
147
|
const textAlign = metrics.arrangement?.textAlign ?? config?.textAlign ?? "start";
|
|
150
148
|
const headingLevel = config?.headingLevel ?? "h3";
|
|
149
|
+
const { inline: iconSize, top: topIconSize } = metrics.iconSizes[config?.iconSize ?? "default"];
|
|
150
|
+
const iconFramed = config?.iconFramed !== false;
|
|
151
151
|
const iconPlacement = metrics.arrangement?.iconPlacement ?? config?.iconPlacement ?? "inline";
|
|
152
152
|
const highlight = overrides.highlight ?? config?.highlight === true;
|
|
153
153
|
const href = config?.href;
|
|
@@ -202,13 +202,17 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
202
202
|
/*
|
|
203
203
|
* The icon's colours as custom properties, which `.phi-card__icon` paints (`styles/layout.css`): the
|
|
204
204
|
* `icon` hover effect turns them round, and a colour stated inline could not be turned by a rule.
|
|
205
|
+
* An icon without its ground takes no part in that: it has no ground to turn the colours onto, so it
|
|
206
|
+
* carries no `phi-card__icon` class and states its colour directly, which no hover rule reaches.
|
|
205
207
|
*/
|
|
206
|
-
const iconColours = (color, background) => (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
const iconColours = (color, background) => (iconFramed
|
|
209
|
+
? {
|
|
210
|
+
"--phi-card-icon-color": color,
|
|
211
|
+
"--phi-card-icon-background": background,
|
|
212
|
+
/* The mark's colour once the `icon` effect turns them round: a ground it can be read on. */
|
|
213
|
+
"--phi-card-icon-hover-color": config?.iconBackground ?? PHI_COLOR.bgContainer,
|
|
214
|
+
}
|
|
215
|
+
: { color });
|
|
212
216
|
/*
|
|
213
217
|
* The corner of the icon's ground: the Theme's Control shape at the large size, scaled from a large
|
|
214
218
|
* Control's height to the ground's side. So `square` draws a square, `pill` a circle -- half the large
|
|
@@ -217,15 +221,16 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
217
221
|
*/
|
|
218
222
|
const iconCorner = (side) => `calc(var(--phi-control-radius-lg, ${token.borderRadiusLG}px) * ${side / token.controlHeightLG})`;
|
|
219
223
|
/* The framed box an icon before the title stands in. */
|
|
220
|
-
const inlineIconFrame = iconSize + 16;
|
|
221
|
-
const
|
|
224
|
+
const inlineIconFrame = iconFramed ? iconSize + 16 : iconSize;
|
|
225
|
+
const topIconFrame = iconFramed ? topIconSize + 24 : topIconSize;
|
|
226
|
+
const iconMark = (size, framed) => iconName ? (_jsx("span", { "aria-hidden": "true", className: iconFramed ? "phi-card__icon" : undefined, style: {
|
|
222
227
|
display: "inline-flex",
|
|
223
228
|
flex: "none",
|
|
224
229
|
alignItems: "center",
|
|
225
230
|
justifyContent: "center",
|
|
226
231
|
width: framed,
|
|
227
232
|
height: framed,
|
|
228
|
-
borderRadius: iconCorner(framed),
|
|
233
|
+
...(iconFramed ? { borderRadius: iconCorner(framed) } : {}),
|
|
229
234
|
...iconColours(config?.iconColor ?? (highlight ? PHI_COLOR.primary : PHI_COLOR.textSecondary), config?.iconBackground ?? PHI_COLOR.fillQuaternary),
|
|
230
235
|
}, children: _jsx(PhiIcon, { name: iconName, size: size }) })) : null;
|
|
231
236
|
/*
|
|
@@ -285,6 +290,8 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
285
290
|
position: "relative",
|
|
286
291
|
aspectRatio: config?.mediaAspectRatio ?? metrics.mediaAspectRatio ?? resolveMediaAspectRatio(image.presentation),
|
|
287
292
|
overflow: "hidden",
|
|
293
|
+
// The icon stands in the picture's middle: a picture shorter than its box would clip it.
|
|
294
|
+
...(iconAtTop && iconName ? { minHeight: topIconFrame } : {}),
|
|
288
295
|
}, children: [_jsx(PhiImageControl, { presentation: image.presentation, source: image.source, alt: image.alt, blurDataUrl: image.blurDataUrl, optimizable: image.optimizable, sizes: PHI_CARD_IMAGE_SIZES, style: { width: "100%", height: "100%" }, imageStyle: {
|
|
289
296
|
width: "100%",
|
|
290
297
|
height: "100%",
|
|
@@ -294,7 +301,7 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
294
301
|
position: "absolute",
|
|
295
302
|
inset: 0,
|
|
296
303
|
pointerEvents: "none",
|
|
297
|
-
} })) : null, iconAtTop && iconName ? (_jsx("span", { "aria-hidden": "true", className: "phi-card__icon", style: {
|
|
304
|
+
} })) : null, iconAtTop && iconName ? (_jsx("span", { "aria-hidden": "true", className: iconFramed ? "phi-card__icon" : undefined, style: {
|
|
298
305
|
position: "absolute",
|
|
299
306
|
insetInlineStart: markSide === "start" ? inset : markSide === "end" ? undefined : "50%",
|
|
300
307
|
insetInlineEnd: markSide === "end" ? inset : undefined,
|
|
@@ -303,12 +310,12 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
303
310
|
display: "inline-flex",
|
|
304
311
|
alignItems: "center",
|
|
305
312
|
justifyContent: "center",
|
|
306
|
-
width:
|
|
307
|
-
height:
|
|
308
|
-
borderRadius: iconCorner(
|
|
313
|
+
width: topIconFrame,
|
|
314
|
+
height: topIconFrame,
|
|
315
|
+
...(iconFramed ? { borderRadius: iconCorner(topIconFrame) } : {}),
|
|
309
316
|
// A ground of its own, so the mark reads on a bright picture and on a dark one alike.
|
|
310
317
|
...iconColours(config?.iconColor ?? (highlight ? PHI_COLOR.primary : PHI_COLOR.text), config?.iconBackground ?? `color-mix(in srgb, ${PHI_COLOR.bgContainer} 88%, transparent)`),
|
|
311
|
-
boxShadow: token.boxShadowTertiary,
|
|
318
|
+
...(iconFramed ? { boxShadow: token.boxShadowTertiary } : {}),
|
|
312
319
|
}, children: _jsx(PhiIcon, { name: iconName, size: topIconSize }) })) : null, eyebrowOnMedia && eyebrow != null ? (_jsx(PhiTypographyControl, { type: "secondary", style: {
|
|
313
320
|
...eyebrowType,
|
|
314
321
|
position: "absolute",
|
|
@@ -363,7 +370,7 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
|
|
|
363
370
|
: {}),
|
|
364
371
|
}
|
|
365
372
|
: {}), ...(renderText ? { style: { pointerEvents: "auto", minWidth: "6em" } } : {}), children: badge })) : null;
|
|
366
|
-
const words = (_jsxs("div", { style: { display: "grid", gap, padding: footAction ? 0 : inset, justifyItems }, children: [iconAtTop && iconName && !image ? (_jsx("div", { style: { justifySelf: markSide === "center" ? "center" : markSide === "end" ? "end" : "start" }, children: iconMark(topIconSize,
|
|
373
|
+
const words = (_jsxs("div", { style: { display: "grid", gap, padding: footAction ? 0 : inset, justifyItems }, children: [iconAtTop && iconName && !image ? (_jsx("div", { style: { justifySelf: markSide === "center" ? "center" : markSide === "end" ? "end" : "start" }, children: iconMark(topIconSize, topIconFrame) })) : null, eyebrow != null && !eyebrowOnMedia && !labels.eyebrowEnd ? (_jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: highlight ? PHI_COLOR.primary : PHI_COLOR.textTertiary, ...slotWidth }, children: eyebrow })) : null, labels.eyebrowEnd && !eyebrowOnMedia ? (_jsxs(PhiFlexControl, { justify: "space-between", align: "baseline", wrap: true, gap: PHI_SPACE.xs, style: { justifySelf: "stretch", minWidth: 0 }, children: [_jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: highlight ? PHI_COLOR.primary : PHI_COLOR.textTertiary }, children: eyebrow ?? "" }), _jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: PHI_COLOR.textTertiary }, children: labels.eyebrowEnd })] })) : null, headingRow, body === "stat" ? figure : null, body === "series" ? (_jsxs(_Fragment, { children: [labels.value || binding?.error || binding?.loading === true || overrides.loading === true ? figure : null, list != null && !binding?.error && binding?.loading !== true && overrides.loading !== true ? (_jsx("div", { style: { justifySelf: "stretch", minWidth: 0 }, children: list })) : null] })) : null, body === "list" && list != null ? (_jsx("div", { style: { justifySelf: "stretch", minWidth: 0 }, children: list })) : null, description != null ? (_jsx(PhiTypographyControl, { presentation: "paragraph", style: {
|
|
367
374
|
marginBottom: 0,
|
|
368
375
|
color: PHI_COLOR.textSecondary,
|
|
369
376
|
fontSize: descriptionSize,
|
|
@@ -53,6 +53,13 @@ export type PhiCardBadgeStyle = (typeof PHI_CARD_BADGE_STYLES)[number];
|
|
|
53
53
|
*/
|
|
54
54
|
export declare const PHI_CARD_ICON_PLACEMENTS: readonly ["inline", "top", "top-center", "top-end"];
|
|
55
55
|
export type PhiCardIconPlacement = (typeof PHI_CARD_ICON_PLACEMENTS)[number];
|
|
56
|
+
/**
|
|
57
|
+
* How large the icon is drawn: fixed steps, no pixel entry, so every card of a Site stands on the same few
|
|
58
|
+
* sizes and the variant's table (`PHI_CARD_VARIANT_METRICS`) decides what each step is for its placement.
|
|
59
|
+
* Absent is `default`, which is what a card drew before the steps existed.
|
|
60
|
+
*/
|
|
61
|
+
export declare const PHI_CARD_ICON_SIZES: readonly ["default", "large", "xlarge"];
|
|
62
|
+
export type PhiCardIconSize = (typeof PHI_CARD_ICON_SIZES)[number];
|
|
56
63
|
/**
|
|
57
64
|
* How a card that leads somewhere answers the pointer; a card without a link has none. A list, so a
|
|
58
65
|
* further effect is an entry and a rule in `styles/layout.css`, not another flag. `lift` raises the card, `zoom` enlarges its picture, `icon`
|
|
@@ -39,6 +39,12 @@ export const PHI_CARD_BADGE_STYLES = ["none", "corner", "tag", "ribbon"];
|
|
|
39
39
|
* picture. Logical like the text alignment: `top` is the left in a left-to-right page.
|
|
40
40
|
*/
|
|
41
41
|
export const PHI_CARD_ICON_PLACEMENTS = ["inline", "top", "top-center", "top-end"];
|
|
42
|
+
/**
|
|
43
|
+
* How large the icon is drawn: fixed steps, no pixel entry, so every card of a Site stands on the same few
|
|
44
|
+
* sizes and the variant's table (`PHI_CARD_VARIANT_METRICS`) decides what each step is for its placement.
|
|
45
|
+
* Absent is `default`, which is what a card drew before the steps existed.
|
|
46
|
+
*/
|
|
47
|
+
export const PHI_CARD_ICON_SIZES = ["default", "large", "xlarge"];
|
|
42
48
|
/**
|
|
43
49
|
* How a card that leads somewhere answers the pointer; a card without a link has none. A list, so a
|
|
44
50
|
* further effect is an entry and a rule in `styles/layout.css`, not another flag. `lift` raises the card, `zoom` enlarges its picture, `icon`
|
|
@@ -230,12 +230,14 @@ export function PhiMarkdownWidgetClient({ config, labels }) {
|
|
|
230
230
|
* The sections that fold: each heading is a header, what follows it the body. Every answer is drawn even
|
|
231
231
|
* while folded, so a search engine and the browser's own find read the whole text. A heading keeps its id,
|
|
232
232
|
* so the table of contents and a link to `#that-question` reach it -- and a link to it opens it, on arrival
|
|
233
|
-
* and whenever the address's fragment changes.
|
|
233
|
+
* and whenever the address's fragment changes. The table of contents announces its jumps as a fragment
|
|
234
|
+
* change of its own (`phi-anchor-nav-control.tsx`) and scrolls there itself, with the Header's offset;
|
|
235
|
+
* only on arrival and on the browser's own change is the heading scrolled to here.
|
|
234
236
|
*/
|
|
235
237
|
function PhiMarkdownFoldedSections({ sections, accordion, renderBody, }) {
|
|
236
238
|
const [openKeys, setOpenKeys] = useState([]);
|
|
237
239
|
useEffect(() => {
|
|
238
|
-
const openFromAddress = () => {
|
|
240
|
+
const openFromAddress = (event) => {
|
|
239
241
|
const id = decodeURIComponent(window.location.hash.slice(1));
|
|
240
242
|
if (!id)
|
|
241
243
|
return;
|
|
@@ -243,6 +245,9 @@ function PhiMarkdownFoldedSections({ sections, accordion, renderBody, }) {
|
|
|
243
245
|
if (!section)
|
|
244
246
|
return;
|
|
245
247
|
setOpenKeys((current) => accordion ? [section.heading.id] : [...new Set([...current, section.heading.id])]);
|
|
248
|
+
// A change the page sent itself comes with its own scroll (the table of contents').
|
|
249
|
+
if (event && !event.isTrusted)
|
|
250
|
+
return;
|
|
246
251
|
window.requestAnimationFrame(() => document.getElementById(id)?.scrollIntoView({ block: "start" }));
|
|
247
252
|
};
|
|
248
253
|
openFromAddress();
|
|
@@ -65,3 +65,11 @@ export declare function parsePhiModuleIconName(value: unknown): {
|
|
|
65
65
|
moduleId: `${string}/${string}`;
|
|
66
66
|
name: string;
|
|
67
67
|
} | null;
|
|
68
|
+
/**
|
|
69
|
+
* The npm package a runtime module id belongs to: its first two path segments
|
|
70
|
+
* (`@phis/phisys/modules/site` -> `@phis/phisys`).
|
|
71
|
+
*
|
|
72
|
+
* What is declared per package -- the pictures of `phis.media` -- is looked up by this name, so a Module
|
|
73
|
+
* reaches its own package's names and nobody else's. Throws on an id that is not a runtime module id.
|
|
74
|
+
*/
|
|
75
|
+
export declare function readPhiRuntimeModulePackageName(moduleId: string): string;
|
|
@@ -127,3 +127,16 @@ export function parsePhiModuleIconName(value) {
|
|
|
127
127
|
const name = reference.slice(cut + 1);
|
|
128
128
|
return isPhiRuntimeModuleId(moduleId) && isPhiModuleIconName(name) ? { moduleId, name } : null;
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* The npm package a runtime module id belongs to: its first two path segments
|
|
132
|
+
* (`@phis/phisys/modules/site` -> `@phis/phisys`).
|
|
133
|
+
*
|
|
134
|
+
* What is declared per package -- the pictures of `phis.media` -- is looked up by this name, so a Module
|
|
135
|
+
* reaches its own package's names and nobody else's. Throws on an id that is not a runtime module id.
|
|
136
|
+
*/
|
|
137
|
+
export function readPhiRuntimeModulePackageName(moduleId) {
|
|
138
|
+
if (!isPhiRuntimeModuleId(moduleId)) {
|
|
139
|
+
throw new Error(`Invalid Phi runtime module id: ${moduleId}.`);
|
|
140
|
+
}
|
|
141
|
+
return moduleId.split("/", 2).join("/");
|
|
142
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type PhiModuleMediaLoader, type PhiModuleMediaMapping } from "../types/module-media";
|
|
3
|
+
export declare function parsePhiModuleMediaMapping(value: unknown): PhiModuleMediaMapping;
|
|
4
|
+
/** Re-arms the once-per-process log; for tests. */
|
|
5
|
+
export declare function resetPhiModuleMediaUnavailableLog(): void;
|
|
6
|
+
export declare function getPhiModuleMediaMapping(options: {
|
|
7
|
+
apiBaseUrl: string;
|
|
8
|
+
internalToken: string;
|
|
9
|
+
siteKey: string;
|
|
10
|
+
}): Promise<PhiModuleMediaMapping>;
|
|
11
|
+
/** The loader a server caller hands to the descriptor compiler for this Site. */
|
|
12
|
+
export declare function createPhiModuleMediaLoader(siteKey: string): PhiModuleMediaLoader;
|