@phis/ui 0.4.17 → 0.4.18

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 CHANGED
@@ -73,7 +73,7 @@ The root export (`@phis/ui`) is not an integration surface; import from the grou
73
73
  | --- | --- |
74
74
  | Next.js Site | `next/config` (`withPhiNextConfig` for the Site's `next.config`), `next/area-route`, `next/areas/<area>`, `next/areas/<area>-client`, `next/root-route`, `next/root-error-page`, `next/global-error`, `next/site-bridge`, `next/site-proxy`, `next/proxy-runtime`, `next/route-handlers`, `next/seo-routes`, `next/overlay-zones`, `next/overlay-zones-client`, `next/cache-handler`, `next/runtime-module-client-boundary` |
75
75
  | CMS rendering | `cms`, `cms/root-layout`, `cms/root-page`, `cms/root-slot-page`, `cms/error-page`, `cms/request`, `cms/plugins`, `cms/plugins/<area>` |
76
- | Module packages | `module`, `module/client`, `module/authoring-client`, `module/labels`, `module/dashboard-cards`, `module/records`, `module/projection`, `module/projection/client`, `module/projection/authoring-client`, `module/site-modules`, `module/site-modules-client` |
76
+ | Module packages | `module`, `module/client`, `module/authoring-client`, `module/labels`, `module/dashboard-cards`, `module/records`, `module/references`, `module/projection`, `module/projection/client`, `module/projection/authoring-client`, `module/site-modules`, `module/site-modules-client` |
77
77
  | Runtime Clients | `runtime`, `runtime/controller-client`, `runtime/render-client`, `runtime/signal-client`, `runtime/data-provider-client`, `runtime/authoring-client`, `runtime/authoring-manifest-client`, `runtime/calendar-adapter-client`, `runtime/user-state-client`, `runtime/client-manifests/<area>` |
78
78
  | UI | `widgets`, `core-widgets`, `widget-config`, `controls`, `controls/config`, `controls/date-time`, `layouts`, `shells`, `root`, `navigation`, `forms`, `forms/client`, `media`, `references`, `state`, `theme` |
79
79
  | Builder | `builder-api-route` |
@@ -6,6 +6,14 @@ export type PhiCmsRenderErrorBoundaryProps = {
6
6
  blockId?: PhiCmsInstanceId | null;
7
7
  typeKey?: string | null;
8
8
  moduleId?: PhiCmsRenderIssue["moduleId"];
9
+ /**
10
+ * Where the diagnostic of a failed render is drawn, for a host that frames its nodes.
11
+ *
12
+ * The Builder draws every node in a scaffold that selects and removes it, and that scaffold is part
13
+ * of what failed. Handed the diagnostic, the host frames it again, so a node that throws can still
14
+ * be taken out of the tree it broke.
15
+ */
16
+ renderDiagnostic?: (diagnostic: ReactNode) => ReactNode;
9
17
  children: ReactNode;
10
18
  };
11
19
  type PhiCmsRenderErrorBoundaryState = {
@@ -20,7 +20,7 @@ export class PhiCmsRenderErrorBoundary extends Component {
20
20
  }
21
21
  render() {
22
22
  if (this.state.error) {
23
- return _jsx(PhiCmsRenderDiagnostic, { issue: {
23
+ const diagnostic = _jsx(PhiCmsRenderDiagnostic, { issue: {
24
24
  code: resolvePhiRenderFailureCode(this.state.error),
25
25
  kind: this.props.kind,
26
26
  type: this.props.typeKey ?? "unknown",
@@ -28,6 +28,7 @@ export class PhiCmsRenderErrorBoundary extends Component {
28
28
  moduleId: this.props.moduleId,
29
29
  detail: this.state.error.message,
30
30
  } });
31
+ return this.props.renderDiagnostic ? this.props.renderDiagnostic(diagnostic) : diagnostic;
31
32
  }
32
33
  return this.props.children;
33
34
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * What a Module package needs to resolve a Page target it chose while rendering, and nothing else
3
+ * (REFERENCES.md, "Resolving a target a Widget chose itself").
4
+ *
5
+ * A render's targets are resolved once, before anything draws, from what the stored configs name; a
6
+ * Widget is handed the answers as `links`. A target the Widget decides on while it renders is not among
7
+ * them -- the Search Box leading to the results Page of the Area it stands in, a shop's Basket leading to
8
+ * the cart of that Area -- because no config says it. This is the resolver the render itself uses, for
9
+ * exactly those: one round trip for the targets handed to it, answered per Area as every link is.
10
+ *
11
+ * Narrow for the reason `@phis/ui/module/labels` is: a package outside this one reads it from the Server
12
+ * half every route of the Site imports, and the `server-helpers` barrel would bring `cms-root` and
13
+ * `next/headers` along. The first-party Modules import `server-helpers/cms-link-targets` by its path.
14
+ *
15
+ * Turning an answer into an address is `resolvePhiLinkHref` from `@phis/ui/references`, as for `links`.
16
+ */
17
+ import "server-only";
18
+ export { resolvePhiLinkTargetReferences } from "./server-helpers/cms-link-targets";
19
+ export type { PhiLinkTargetReference } from "./helpers/link-target";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What a Module package needs to resolve a Page target it chose while rendering, and nothing else
3
+ * (REFERENCES.md, "Resolving a target a Widget chose itself").
4
+ *
5
+ * A render's targets are resolved once, before anything draws, from what the stored configs name; a
6
+ * Widget is handed the answers as `links`. A target the Widget decides on while it renders is not among
7
+ * them -- the Search Box leading to the results Page of the Area it stands in, a shop's Basket leading to
8
+ * the cart of that Area -- because no config says it. This is the resolver the render itself uses, for
9
+ * exactly those: one round trip for the targets handed to it, answered per Area as every link is.
10
+ *
11
+ * Narrow for the reason `@phis/ui/module/labels` is: a package outside this one reads it from the Server
12
+ * half every route of the Site imports, and the `server-helpers` barrel would bring `cms-root` and
13
+ * `next/headers` along. The first-party Modules import `server-helpers/cms-link-targets` by its path.
14
+ *
15
+ * Turning an answer into an address is `resolvePhiLinkHref` from `@phis/ui/references`, as for `links`.
16
+ */
17
+ import "server-only";
18
+ export { resolvePhiLinkTargetReferences } from "./server-helpers/cms-link-targets";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.4.17",
3
+ "version": "0.4.18",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -282,6 +282,11 @@
282
282
  "import": "./module-records.js",
283
283
  "default": "./module-records.js"
284
284
  },
285
+ "./module/references": {
286
+ "types": "./module-references.d.ts",
287
+ "import": "./module-references.js",
288
+ "default": "./module-references.js"
289
+ },
285
290
  "./module/projection": {
286
291
  "types": "./module-projection.d.ts",
287
292
  "import": "./module-projection.js",
@@ -61,86 +61,74 @@ function renderPhiLayoutInsertControl(control, resolveDropTarget, parentLayoutNo
61
61
  function renderPhiLayoutTitleControl(control) {
62
62
  return (_jsx(PhiInlineTextEditor, { autoFocus: true, variant: "underlined", value: control.value, onChange: control.onChange, onCommit: control.onCommit, onCancel: control.onCancel, collapsibleTitleControl: true, ariaLabel: control.ariaLabel, style: control.style }));
63
63
  }
64
- function PhiAuthoringWidgetLoader({ widget, config, slotSizePolicy, demandControllerContext, children, }) {
64
+ function PhiAuthoringWidgetLoader({ widget, config, slotSizePolicy, demandControllerContext, renderUnavailable, children, }) {
65
65
  const type = widget.widgetType;
66
66
  const blockId = widget.id;
67
67
  const activeModules = usePhiRuntimeModuleState();
68
68
  const definition = activeModules.widgetDefinitionsByType.get(type);
69
69
  const authoringModule = usePhiRuntimeModuleAuthoringRegistration(definition?.ownerModuleId);
70
+ const frameUnavailable = (diagnostic) => renderUnavailable ? renderUnavailable(diagnostic) : diagnostic;
71
+ const unavailable = (issue) => frameUnavailable(_jsx(PhiCmsRenderDiagnostic, { issue: { kind: "widget", type, blockId, ...issue } }));
70
72
  if (!definition) {
71
73
  const moduleIsInactive = !activeModules.widgetTypes.has(type);
72
- return _jsx(PhiCmsRenderDiagnostic, { issue: {
73
- code: moduleIsInactive ? "missing-module" : "missing-renderer",
74
- kind: "widget",
75
- type,
76
- blockId,
77
- detail: moduleIsInactive
78
- ? "No active Canvas module provides this widget type."
79
- : "Active widget metadata is unavailable in the Canvas runtime context.",
80
- } });
74
+ return unavailable({
75
+ code: moduleIsInactive ? "missing-module" : "missing-renderer",
76
+ detail: moduleIsInactive
77
+ ? "No active Canvas module provides this widget type."
78
+ : "Active widget metadata is unavailable in the Canvas runtime context.",
79
+ });
81
80
  }
82
81
  if (!activeModules.moduleIds.has(definition.ownerModuleId) ||
83
82
  !activeModules.widgetTypes.has(type)) {
84
- return _jsx(PhiCmsRenderDiagnostic, { issue: {
85
- code: "missing-module",
86
- kind: "widget",
87
- type,
88
- blockId,
89
- moduleId: definition.ownerModuleId,
90
- detail: "Widget owner module is not active in the current Canvas sandbox.",
91
- } });
83
+ return unavailable({
84
+ code: "missing-module",
85
+ moduleId: definition.ownerModuleId,
86
+ detail: "Widget owner module is not active in the current Canvas sandbox.",
87
+ });
92
88
  }
93
89
  if (!authoringModule) {
94
- return _jsx(PhiCmsRenderDiagnostic, { issue: {
95
- code: "missing-renderer",
96
- kind: "widget",
97
- type,
98
- blockId,
99
- moduleId: definition.ownerModuleId,
100
- detail: "Widget owner module does not provide its declared AuthoringClient.",
101
- } });
90
+ return unavailable({
91
+ code: "missing-renderer",
92
+ moduleId: definition.ownerModuleId,
93
+ detail: "Widget owner module does not provide its declared AuthoringClient.",
94
+ });
102
95
  }
103
96
  const WidgetModule = authoringModule.WidgetModule;
104
- return (_jsx(PhiCmsRenderErrorBoundary, { kind: "widget", blockId: blockId, typeKey: type, moduleId: definition.ownerModuleId, children: _jsx(Suspense, { fallback: (_jsx(PhiSlotChildFrame, { kind: "widget", slotSizePolicy: slotSizePolicy ?? definition.slotSizePolicy, surfacePolicy: definition.surface, blockId: null, config: config, disableEffects: true, runtimeSignalEmissionsEnabled: false, className: "phi-widget-authoring-loading", children: _jsx(PhiWidgetPreviewFallback, { widget: widget, pluginTitle: definition.title }) })), children: _jsx(WidgetModule, { type: type, children: (plugin) => plugin
97
+ return (_jsx(PhiCmsRenderErrorBoundary, { kind: "widget", blockId: blockId, typeKey: type, moduleId: definition.ownerModuleId, renderDiagnostic: renderUnavailable, children: _jsx(Suspense, { fallback: (_jsx(PhiSlotChildFrame, { kind: "widget", slotSizePolicy: slotSizePolicy ?? definition.slotSizePolicy, surfacePolicy: definition.surface, blockId: null, config: config, disableEffects: true, runtimeSignalEmissionsEnabled: false, className: "phi-widget-authoring-loading", children: _jsx(PhiWidgetPreviewFallback, { widget: widget, pluginTitle: definition.title }) })), children: _jsx(WidgetModule, { type: type, children: (plugin) => plugin
105
98
  ? demandControllerContext && plugin.requiredRuntimeControllers
106
99
  ? (_jsx(PhiBuilderDemandControllerRegistration, { area: demandControllerContext.area, ownerKey: demandControllerContext.ownerKey, ownerMountScope: demandControllerContext.ownerMountScope, pageKey: demandControllerContext.pageKey, widget: widget, tree: demandControllerContext.tree, plugin: plugin, children: children(plugin, definition) }))
107
100
  : children(plugin, definition)
108
- : _jsx(PhiCmsRenderDiagnostic, { issue: {
109
- code: "missing-renderer",
110
- kind: "widget",
111
- type,
112
- blockId,
113
- moduleId: definition.ownerModuleId,
114
- detail: "Widget is not registered in its owner module's authoring catalog.",
115
- } }) }) }) }));
101
+ : unavailable({
102
+ code: "missing-renderer",
103
+ moduleId: definition.ownerModuleId,
104
+ detail: "Widget is not registered in its owner module's authoring catalog.",
105
+ }) }) }) }));
116
106
  }
117
- function PhiAuthoringLayoutLoader({ type, kind, blockId, children, }) {
107
+ function PhiAuthoringLayoutLoader({ type, kind, blockId, renderUnavailable, children, }) {
118
108
  const activeModules = usePhiRuntimeModuleState();
119
109
  const layoutType = resolvePhiAuthoringLayoutType(type);
120
110
  const resolveLayoutDefinition = usePhiAuthoringLayoutDefinitionResolver();
121
111
  const definition = resolveLayoutDefinition(layoutType);
112
+ const unavailable = (issue) => {
113
+ const diagnostic = _jsx(PhiCmsRenderDiagnostic, { issue: { kind, type, blockId, ...issue } });
114
+ return renderUnavailable ? renderUnavailable(diagnostic) : diagnostic;
115
+ };
122
116
  if (!definition) {
123
- return _jsx(PhiCmsRenderDiagnostic, { issue: {
124
- code: "missing-renderer",
125
- kind,
126
- type,
127
- blockId,
128
- detail: "Layout does not provide a client authoring loader.",
129
- } });
117
+ return unavailable({
118
+ code: "missing-renderer",
119
+ detail: "Layout does not provide a client authoring loader.",
120
+ });
130
121
  }
131
122
  if (!activeModules.moduleIds.has(definition.ownerModuleId) ||
132
123
  !activeModules.layoutTypes.has(layoutType)) {
133
- return _jsx(PhiCmsRenderDiagnostic, { issue: {
134
- code: "missing-module",
135
- kind,
136
- type,
137
- blockId,
138
- moduleId: definition.ownerModuleId,
139
- detail: "Layout owner module is not active in the current Canvas sandbox.",
140
- } });
124
+ return unavailable({
125
+ code: "missing-module",
126
+ moduleId: definition.ownerModuleId,
127
+ detail: "Layout owner module is not active in the current Canvas sandbox.",
128
+ });
141
129
  }
142
130
  const LazyAuthoringLayout = definition.component;
143
- return (_jsx(PhiCmsRenderErrorBoundary, { kind: kind, blockId: blockId, typeKey: type, moduleId: definition.ownerModuleId, children: _jsx(Suspense, { fallback: null, children: _jsx(LazyAuthoringLayout, { children: (plugin) => children(plugin, definition, activeModules.widgetDefinitionsByType, resolveLayoutDefinition) }) }) }));
131
+ return (_jsx(PhiCmsRenderErrorBoundary, { kind: kind, blockId: blockId, typeKey: type, moduleId: definition.ownerModuleId, renderDiagnostic: renderUnavailable, children: _jsx(Suspense, { fallback: null, children: _jsx(LazyAuthoringLayout, { children: (plugin) => children(plugin, definition, activeModules.widgetDefinitionsByType, resolveLayoutDefinition) }) }) }));
144
132
  }
145
133
  function resolveRootNodeEditSlotAnchor(rootNode) {
146
134
  return rootNode.editSlotAnchor ?? undefined;
@@ -636,7 +624,7 @@ function resolvePhiRootNodeRenderedBody(rootNode, renderMode, plugin, definition
636
624
  const renderWidgetNode = (widget) => {
637
625
  const renderableBlockConfig = mergeRenderableBlockDefaults(widget.config);
638
626
  const widgetViewportFlags = intersectPhiInheritedViewportFlags(resolvedViewportFlags, widget.config.viewportFlags);
639
- return (_jsx(PhiAuthoringWidgetLoader, { widget: widget, config: { ...renderableBlockConfig, renderMode: "editor" }, slotSizePolicy: widgetDefinitionsByType.get(widget.widgetType)?.slotSizePolicy, demandControllerContext: demandControllerContext, children: (plugin, definition) => {
627
+ return (_jsx(PhiAuthoringWidgetLoader, { widget: widget, config: { ...renderableBlockConfig, renderMode: "editor" }, slotSizePolicy: widgetDefinitionsByType.get(widget.widgetType)?.slotSizePolicy, demandControllerContext: demandControllerContext, renderUnavailable: renderMode === "editor" && onDeleteWidgetNode ? (diagnostic) => (_jsx(PhiWidgetEffectsPreviewFrame, { kind: "widget", blockId: widget.id, regionKey: regionKey, config: { renderMode: "editor" }, title: widget.label ?? widget.widgetType, onSelect: () => undefined, tools: (_jsx(PhiLayoutDeleteButtonOverlay, { ariaLabel: `Delete ${widget.label ?? widget.widgetType}`, top: -10, bottom: "auto", transform: "translateY(-50%)", zIndex: 40, nodeKind: "widget", onDelete: () => onDeleteWidgetNode({ ...widget }) })), style: { position: "relative", zIndex: 30 }, children: diagnostic }, `widget-${widget.id}`)) : undefined, children: (plugin, definition) => {
640
628
  const resolvedConfig = plugin.parseConfig(widget.config ?? {});
641
629
  const widgetTypeTitle = plugin.title ?? widget.widgetType;
642
630
  const widgetTitle = widget.label ?? widgetTypeTitle;
@@ -870,7 +858,19 @@ export function renderPhiRootNodeScaffold(rootNode, onOpenInsert, onOpenInspecto
870
858
  renderInsertPicker: options?.renderInsertPicker,
871
859
  }) }));
872
860
  };
873
- const scaffold = (_jsx(PhiAuthoringLayoutLoader, { type: normalizedRootNode.typeKey, kind: "layout", blockId: normalizedRootNode.id ?? -1, children: (plugin, definition, widgetDefinitionsByType, resolveLayoutDefinition) => {
861
+ /*
862
+ * A Layout that cannot be drawn, framed like one that can: the drawer takes the click, so it stops at
863
+ * this Layout instead of selecting its parent, and its only tool removes it. Removing a Layout takes
864
+ * what is in it along, as it does from a Layout that draws.
865
+ */
866
+ const renderUnavailableRoot = typeof onDeleteRootNode === "function" && normalizedRootNode.id != null
867
+ ? (diagnostic) => (_jsx(PhiEditScaffoldDrawer, { className: "phi-builder-root-scaffold", kind: "layout", nodeId: normalizedRootNode.id, regionKey: regionKey, title: rootTitle, scaffoldLabel: formatLayoutScaffoldLabel(normalizedRootNode.typeKey, normalizedRootNode.kind, null, normalizedRootNode.title), onClick: () => undefined, chrome: (_jsx(PhiLayoutDeleteButtonOverlay, { ariaLabel: `Delete ${rootTitle}`, nodeKind: "layout", onDelete: () => onDeleteRootNode({
868
+ nodeId: normalizedRootNode.id ?? null,
869
+ nodeKey: normalizedRootNode.typeKey,
870
+ nodeKind: normalizedRootNode.kind,
871
+ }) })), children: diagnostic }))
872
+ : undefined;
873
+ const scaffold = (_jsx(PhiAuthoringLayoutLoader, { type: normalizedRootNode.typeKey, kind: "layout", blockId: normalizedRootNode.id ?? -1, renderUnavailable: renderUnavailableRoot, children: (plugin, definition, widgetDefinitionsByType, resolveLayoutDefinition) => {
874
874
  const rendered = resolvePhiRootNodeRenderedBody(normalizedRootNode, "editor", plugin, definition, widgetDefinitionsByType, regionKey, renderChildLayoutNodeWith(resolveLayoutDefinition), onDeleteRootNode
875
875
  ? (widget) => onDeleteRootNode({
876
876
  nodeId: widget.id,
package/styles/shell.css CHANGED
@@ -784,6 +784,11 @@
784
784
  position: absolute !important;
785
785
  width: 1px !important;
786
786
  height: 1px !important;
787
+ /* The pill's own `min-width` outweighs the width above; left standing, it kept the box 56px wide and
788
+ pushed it past the screen's edge, so every page scrolled sideways by a few pixels. */
789
+ min-width: 0 !important;
790
+ padding: 0 !important;
791
+ border: 0 !important;
787
792
  overflow: hidden !important;
788
793
  clip-path: inset(50%) !important;
789
794
  white-space: nowrap !important;