@phis/ui 0.4.18 → 0.4.20

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.
Files changed (32) hide show
  1. package/components/cms/phi-cms-root-layout.js +3 -1
  2. package/components/controls/phi-icon-picker-control.js +12 -2
  3. package/components/controls/phi-table-control.js +2 -0
  4. package/components/shell/phi-icon.d.ts +2 -1
  5. package/components/shell/phi-icon.js +4 -0
  6. package/components/shell/phi-module-icons.d.ts +19 -0
  7. package/components/shell/phi-module-icons.js +36 -0
  8. package/constants/module-identity.d.ts +26 -0
  9. package/constants/module-identity.js +44 -0
  10. package/helpers/module-icons.d.ts +28 -0
  11. package/helpers/module-icons.js +112 -0
  12. package/module.d.ts +7 -0
  13. package/module.js +6 -0
  14. package/package.json +1 -1
  15. package/plugins/runtime-modules/accounting/module.d.ts +1 -1
  16. package/plugins/runtime-modules/admin/module.d.ts +1 -1
  17. package/plugins/runtime-modules/app/module.d.ts +1 -1
  18. package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +13 -2
  19. package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +5 -1
  20. package/plugins/runtime-modules/builder/controller/workspace-controller.js +21 -1
  21. package/plugins/runtime-modules/builder/module-authoring-catalog.d.ts +3 -0
  22. package/plugins/runtime-modules/builder/module-authoring-catalog.server.js +2 -0
  23. package/plugins/runtime-modules/builder/plugin-meta-store.d.ts +3 -0
  24. package/plugins/runtime-modules/builder/plugin-meta-store.js +1 -0
  25. package/plugins/runtime-modules/contracts.js +10 -0
  26. package/plugins/runtime-modules/core/widgets/card/config.d.ts +1 -1
  27. package/plugins/runtime-modules/editor/module.d.ts +1 -1
  28. package/plugins/runtime-modules/public/module.d.ts +1 -1
  29. package/styles/controls.css +6 -1
  30. package/types/cms-plugins.d.ts +10 -0
  31. package/types/module-icons.d.ts +56 -0
  32. package/types/module-icons.js +10 -0
@@ -19,6 +19,8 @@ import { resolvePhiUnauthenticatedLoginHref, } from "../../server-helpers/public
19
19
  import { isPhiCmsGatewayAuthError } from "../../gateway/errors";
20
20
  import { PhiRuntimeControllerServerHost } from "../runtime/runtime-controller-server-host";
21
21
  import { PhiRuntimeModuleProvider } from "../runtime/runtime-module-context";
22
+ import { PhiModuleIconsProvider } from "../shell/phi-module-icons";
23
+ import { collectPhiModuleIconSets } from "../../helpers/module-icons";
22
24
  import { PhiRuntimeModuleDataProviderHost } from "../runtime/runtime-module-data-provider-host";
23
25
  import { PhiSignalRuntimePartitionProvider } from "../runtime/runtime-signal-partition";
24
26
  import { resolvePhiCmsDescriptorCatalog } from "../../plugins/runtime-modules/descriptor-compiler";
@@ -167,7 +169,7 @@ export async function PhiCmsAreaBoundary({ root, cmsBridge, children, path, page
167
169
  ...runtimeModuleScope.moduleSet.calendarAdapterDescriptorsByKey.values(),
168
170
  ], videoProviderDescriptors: [
169
171
  ...runtimeModuleScope.moduleSet.videoProviderDescriptorsByKey.values(),
170
- ], children: _jsxs(PhiRuntimeModuleDataProviderHost, { providerKeys: [...scope.runtimeRegistry.dataProviderDescriptorsByKey.keys()], children: [areaControllers.registeredControllerSettings && areaControllers.registeredControllerSettings.length > 0 ? (_jsx(PhiRuntimeControllerServerHost, { controllers: areaControllers.registeredControllerSettings, runtime: runtime, registry: areaControllers.controllerDefinitionsByType, controllerModuleIdsByType: runtimeModuleScope.moduleSet.ownerModuleIdByControllerType, runtimeModuleCatalog: scope.runtimeRegistry.runtimeModuleCatalog, serverCapabilities: scope.runtimeRegistry.serverCapabilities })) : null, children, filteredLayoutTree ? (_jsx(PhiCmsOverlayRenderer, { tree: filteredLayoutTree, runtime: runtime, registry: scope.runtimeRegistry, signalScope: "area", deferredOrigin: { area: runtime.area, root, path: path ?? pagePath ?? null } })) : null] }) }) }));
172
+ ], children: _jsx(PhiModuleIconsProvider, { sets: collectPhiModuleIconSets(runtimeModuleScope.moduleSet.moduleDefinitionsById.values()), children: _jsxs(PhiRuntimeModuleDataProviderHost, { providerKeys: [...scope.runtimeRegistry.dataProviderDescriptorsByKey.keys()], children: [areaControllers.registeredControllerSettings && areaControllers.registeredControllerSettings.length > 0 ? (_jsx(PhiRuntimeControllerServerHost, { controllers: areaControllers.registeredControllerSettings, runtime: runtime, registry: areaControllers.controllerDefinitionsByType, controllerModuleIdsByType: runtimeModuleScope.moduleSet.ownerModuleIdByControllerType, runtimeModuleCatalog: scope.runtimeRegistry.runtimeModuleCatalog, serverCapabilities: scope.runtimeRegistry.serverCapabilities })) : null, children, filteredLayoutTree ? (_jsx(PhiCmsOverlayRenderer, { tree: filteredLayoutTree, runtime: runtime, registry: scope.runtimeRegistry, signalScope: "area", deferredOrigin: { area: runtime.area, root, path: path ?? pagePath ?? null } })) : null] }) }) }) }));
171
173
  }
172
174
  /**
173
175
  * The Area-owned Regions around a Page, or nothing but the grid they share.
@@ -1,9 +1,11 @@
1
1
  "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { stopPhiOverlayEvent } from "../../helpers/overlay-events";
4
4
  import { useEffect, useMemo, useRef, useState } from "react";
5
5
  import { Flex, Typography } from "antd";
6
6
  import { PhiIcon } from "../shell/phi-icon";
7
+ import { usePhiModuleIconSets } from "../shell/phi-module-icons";
8
+ import { createPhiModuleIconName } from "../../constants/module-identity";
7
9
  import { usePhiConfig } from "../root/phi-config-provider";
8
10
  import { PHI_ICON_PICKER_CONTROL_DEFAULT_LABELS, } from "../widgets/label-types/icon-picker";
9
11
  import { PhiAlertControl } from "./phi-alert-control";
@@ -116,6 +118,11 @@ function parseIconValue(value) {
116
118
  }
117
119
  export function PhiIconPickerControl({ value, onChange, buttonAriaLabel, buttonIcon, buttonLabel, buttonType = "text", buttonSize = "small", buttonBlock = false, disabled = false, buttonStyle, placement = "bottom", getPopupContainer, rootClassName, onOpenChange, onCommit, onDiscard, labels = PHI_ICON_PICKER_CONTROL_DEFAULT_LABELS, }) {
118
120
  const { token } = usePhiConfig();
121
+ /*
122
+ * The icons the active Modules register, one group per Module under its title. Which Modules those are
123
+ * is the provider's answer: the Area's own live, the target Area's in the Builder.
124
+ */
125
+ const moduleIconSets = usePhiModuleIconSets();
119
126
  const parsedCurrentIcon = parseIconValue(value);
120
127
  const picker = usePhiImmediatePicker({
121
128
  value: value ?? null,
@@ -286,7 +293,10 @@ export function PhiIconPickerControl({ value, onChange, buttonAriaLabel, buttonI
286
293
  }, options: [
287
294
  { label: labels.modes.standard, value: "standard" },
288
295
  { label: labels.modes.iconify, value: "iconify" },
289
- ] }), mode === "standard" ? (_jsx("div", { style: ICON_BUTTON_GRID_STYLE, children: STANDARD_ICON_CHOICES.map((entry) => (_jsx(PhiButtonControl, { type: picker.value === entry.value ? "primary" : "default", size: "small", disabled: disabled, ariaLabel: entry.label, tooltip: entry.value, icon: _jsx(PhiIcon, { name: entry.value, size: 16 }), onClick: () => applyIcon(entry.value), style: { width: "100%", height: 36, padding: 0 } }, entry.value))) })) : (_jsxs(Flex, { vertical: true, gap: token.paddingXS, children: [_jsx(PhiSegmentedControl, { block: true, size: "small", value: iconifySet, disabled: disabled, onChange: (nextSet) => {
296
+ ] }), mode === "standard" ? (_jsxs(Flex, { vertical: true, gap: token.paddingXS, children: [_jsx("div", { style: ICON_BUTTON_GRID_STYLE, children: STANDARD_ICON_CHOICES.map((entry) => (_jsx(PhiButtonControl, { type: picker.value === entry.value ? "primary" : "default", size: "small", disabled: disabled, ariaLabel: entry.label, tooltip: entry.value, icon: _jsx(PhiIcon, { name: entry.value, size: 16 }), onClick: () => applyIcon(entry.value), style: { width: "100%", height: 36, padding: 0 } }, entry.value))) }), moduleIconSets.map((set) => (_jsxs(Flex, { vertical: true, gap: 4, children: [_jsx(Typography.Text, { type: "secondary", children: set.title }), _jsx("div", { style: ICON_BUTTON_GRID_STYLE, children: set.icons.map((icon) => {
297
+ const entryValue = createPhiModuleIconName(set.moduleId, icon.name);
298
+ return (_jsx(PhiButtonControl, { type: picker.value === entryValue ? "primary" : "default", size: "small", disabled: disabled, ariaLabel: icon.label, tooltip: entryValue, icon: _jsx(PhiIcon, { name: entryValue, size: 16 }), onClick: () => applyIcon(entryValue), style: { width: "100%", height: 36, padding: 0 } }, entryValue));
299
+ }) })] }, set.moduleId)))] })) : (_jsxs(Flex, { vertical: true, gap: token.paddingXS, children: [_jsx(PhiSegmentedControl, { block: true, size: "small", value: iconifySet, disabled: disabled, onChange: (nextSet) => {
290
300
  if (disabled) {
291
301
  return;
292
302
  }
@@ -1029,6 +1029,8 @@ export function PhiTableControl({ rows, rowIdentityPath, columns, columnOrder, s
1029
1029
  "phi-table-control",
1030
1030
  hasClosingBlock ? "phi-table-control--closing-block" : null,
1031
1031
  stickyHeader && showHeader !== false ? "phi-table-control--sticky-header" : null,
1032
+ // No rows, nothing measured: the sticky header's fixed layout would have no widths to fix.
1033
+ !loading && dataSource.length === 0 ? "phi-table-control--empty" : null,
1032
1034
  ]
1033
1035
  .filter(Boolean)
1034
1036
  .join(" "), style: { "--phi-table-striped-row-background": token.colorFillAlter }, rowKey: (row) => loading
@@ -1,7 +1,8 @@
1
1
  import { type PhiAntdIconPresentation } from "./phi-antd-icon";
2
2
  /**
3
3
  * `style`, `className`, `title`, `ariaLabel` and `twoToneColor` reach the Ant Design icons, which is
4
- * where the house draws its interface icons; a motif, Iconify or asset icon takes its size only.
4
+ * where the house draws its interface icons, and all but `twoToneColor` a Module's own icon
5
+ * (`module:<runtime module id>/<name>`); a motif, Iconify or asset icon takes its size only.
5
6
  */
6
7
  type PhiIconProps = {
7
8
  name?: string;
@@ -1,7 +1,9 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { lazy, Suspense, useEffect, useState, } from "react";
4
+ import { PHI_MODULE_ICON_NAMESPACE } from "../../constants/module-identity";
4
5
  import { PHI_ANTD_ICON_NAMES, PhiAntdIcon } from "./phi-antd-icon";
6
+ import { PhiModuleIcon } from "./phi-module-icons";
5
7
  let iconifyComponentLoader = null;
6
8
  function loadIconifyComponent() {
7
9
  if (!iconifyComponentLoader) {
@@ -83,6 +85,8 @@ export function PhiIcon({ name, size = 16, ...presentation }) {
83
85
  return builderIcon;
84
86
  }
85
87
  switch (namespace) {
88
+ case PHI_MODULE_ICON_NAMESPACE:
89
+ return _jsx(PhiModuleIcon, { name: name, size: resolvedSize, ...presentation });
86
90
  case "antd":
87
91
  return renderAntdIcon(value, resolvedSize, presentation);
88
92
  case "iconify":
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from "react";
2
+ import type { PhiModuleIconSet } from "../../types/module-icons";
3
+ import { type PhiAntdIconPresentation } from "./phi-antd-icon";
4
+ /**
5
+ * The icons `PhiIcon` resolves a `module:` name against below this point. A nested provider replaces the
6
+ * outer one rather than adding to it: the Builder's canvas holds the target Area's Modules, not its own.
7
+ */
8
+ export declare function PhiModuleIconsProvider({ sets, flagUnavailable, children, }: {
9
+ sets: readonly PhiModuleIconSet[];
10
+ /** Draw a marked placeholder for a `module:` name that does not resolve, instead of nothing. */
11
+ flagUnavailable?: boolean;
12
+ children: ReactNode;
13
+ }): import("react").JSX.Element;
14
+ /** The active Modules' icon sets, for a picker that offers them. */
15
+ export declare function usePhiModuleIconSets(): readonly PhiModuleIconSet[];
16
+ export declare function PhiModuleIcon({ name, size, style, className, title, ariaLabel, }: {
17
+ name: string;
18
+ size: number | string;
19
+ } & PhiAntdIconPresentation): import("react").JSX.Element | null;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import { indexPhiModuleIconSets, resolvePhiModuleIcon, } from "../../helpers/module-icons";
5
+ import { PhiAntdIcon } from "./phi-antd-icon";
6
+ const EMPTY_MODULE_ICONS = {
7
+ sets: [],
8
+ index: new Map(),
9
+ flagUnavailable: false,
10
+ };
11
+ const PhiModuleIconsContext = createContext(EMPTY_MODULE_ICONS);
12
+ /**
13
+ * The icons `PhiIcon` resolves a `module:` name against below this point. A nested provider replaces the
14
+ * outer one rather than adding to it: the Builder's canvas holds the target Area's Modules, not its own.
15
+ */
16
+ export function PhiModuleIconsProvider({ sets, flagUnavailable = false, children, }) {
17
+ const state = useMemo(() => ({ sets, index: indexPhiModuleIconSets(sets), flagUnavailable }), [flagUnavailable, sets]);
18
+ return _jsx(PhiModuleIconsContext.Provider, { value: state, children: children });
19
+ }
20
+ /** The active Modules' icon sets, for a picker that offers them. */
21
+ export function usePhiModuleIconSets() {
22
+ return useContext(PhiModuleIconsContext).sets;
23
+ }
24
+ export function PhiModuleIcon({ name, size, style, className, title, ariaLabel, }) {
25
+ const { index, flagUnavailable } = useContext(PhiModuleIconsContext);
26
+ const icon = resolvePhiModuleIcon(index, name);
27
+ if (!icon) {
28
+ /*
29
+ * In the Builder the name stays visible as the mark's title: the Module is not active in the target
30
+ * Area, or does not register that name. Live, a missing icon is nothing, as an unknown `antd:` is.
31
+ */
32
+ return flagUnavailable ? (_jsx(PhiAntdIcon, { icon: "WarningOutlined", size: size, title: name, className: className ? `phi-module-icon-unavailable ${className}` : "phi-module-icon-unavailable", style: { color: "var(--ant-color-warning)", ...style } })) : null;
33
+ }
34
+ const { drawing } = icon;
35
+ return (_jsx("span", { role: "img", "aria-label": ariaLabel ?? icon.name, title: title, className: className ? `anticon ${className}` : "anticon", style: size === "1em" ? style : { fontSize: size, ...style }, children: _jsx("svg", { viewBox: drawing.viewBox, width: "1em", height: "1em", fill: "currentColor", "aria-hidden": "true", focusable: "false", children: drawing.paths.map((path, index) => (_jsx("path", { d: path, fillRule: drawing.fillRule }, index))) }) }));
36
+ }
@@ -39,3 +39,29 @@ export declare function createPhiModuleIdentifier<TNamespace extends string>(mod
39
39
  * grammar that is widened on the writing side alone turns stored data into rejected data.
40
40
  */
41
41
  export declare function isPhiModuleScopedIdentifier(namespace: string, value: unknown, leafShape?: PhiModuleLeafShape): boolean;
42
+ /**
43
+ * The `PhiIcon` namespace of the icons a Module registers in its definition (`icons`).
44
+ *
45
+ * ```text
46
+ * module:<runtime module id>/<icon name> module:@phis/dev/modules/site/product
47
+ * ```
48
+ *
49
+ * `PhiIcon` splits a name at its first `:`, and a runtime module id holds no `:` but does hold `/` and
50
+ * `@`, so the icon name is what follows the *last* `/`. An icon name is one lower-case kebab segment,
51
+ * which is what keeps that cut unambiguous: it never holds a `/` of its own.
52
+ */
53
+ export declare const PHI_MODULE_ICON_NAMESPACE = "module";
54
+ /** Whether `value` can be the name of an icon a Module registers: one lower-case kebab segment. */
55
+ export declare function isPhiModuleIconName(value: unknown): value is string;
56
+ /** The `PhiIcon` name of icon `name` of Module `moduleId`. Throws on a part the grammar refuses. */
57
+ export declare function createPhiModuleIconName(moduleId: string, name: string): `module:${string}/${string}`;
58
+ /**
59
+ * The Module and the icon a `module:` icon name names, or null when it is not one.
60
+ *
61
+ * The reader for what `createPhiModuleIconName` writes, kept beside it for the reason
62
+ * `isPhiModuleScopedIdentifier` is.
63
+ */
64
+ export declare function parsePhiModuleIconName(value: unknown): {
65
+ moduleId: `${string}/${string}`;
66
+ name: string;
67
+ } | null;
@@ -83,3 +83,47 @@ export function isPhiModuleScopedIdentifier(namespace, value, leafShape = "segme
83
83
  const owner = value.slice(0, marker);
84
84
  return isPhiRuntimeModuleId(owner) || isPhiNpmPackageName(owner);
85
85
  }
86
+ /**
87
+ * The `PhiIcon` namespace of the icons a Module registers in its definition (`icons`).
88
+ *
89
+ * ```text
90
+ * module:<runtime module id>/<icon name> module:@phis/dev/modules/site/product
91
+ * ```
92
+ *
93
+ * `PhiIcon` splits a name at its first `:`, and a runtime module id holds no `:` but does hold `/` and
94
+ * `@`, so the icon name is what follows the *last* `/`. An icon name is one lower-case kebab segment,
95
+ * which is what keeps that cut unambiguous: it never holds a `/` of its own.
96
+ */
97
+ export const PHI_MODULE_ICON_NAMESPACE = "module";
98
+ const MODULE_ICON_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
99
+ /** Whether `value` can be the name of an icon a Module registers: one lower-case kebab segment. */
100
+ export function isPhiModuleIconName(value) {
101
+ return typeof value === "string" && MODULE_ICON_NAME_PATTERN.test(value);
102
+ }
103
+ /** The `PhiIcon` name of icon `name` of Module `moduleId`. Throws on a part the grammar refuses. */
104
+ export function createPhiModuleIconName(moduleId, name) {
105
+ if (!isPhiRuntimeModuleId(moduleId) || !isPhiModuleIconName(name)) {
106
+ throw new Error(`Invalid Module icon name parts: ${moduleId} / ${name}.`);
107
+ }
108
+ return `${PHI_MODULE_ICON_NAMESPACE}:${moduleId}/${name}`;
109
+ }
110
+ /**
111
+ * The Module and the icon a `module:` icon name names, or null when it is not one.
112
+ *
113
+ * The reader for what `createPhiModuleIconName` writes, kept beside it for the reason
114
+ * `isPhiModuleScopedIdentifier` is.
115
+ */
116
+ export function parsePhiModuleIconName(value) {
117
+ const prefix = `${PHI_MODULE_ICON_NAMESPACE}:`;
118
+ if (typeof value !== "string" || !value.startsWith(prefix)) {
119
+ return null;
120
+ }
121
+ const reference = value.slice(prefix.length);
122
+ const cut = reference.lastIndexOf("/");
123
+ if (cut < 0) {
124
+ return null;
125
+ }
126
+ const moduleId = reference.slice(0, cut);
127
+ const name = reference.slice(cut + 1);
128
+ return isPhiRuntimeModuleId(moduleId) && isPhiModuleIconName(name) ? { moduleId, name } : null;
129
+ }
@@ -0,0 +1,28 @@
1
+ import type { PhiModuleIcon, PhiModuleIconInput, PhiModuleIconSet } from "../types/module-icons";
2
+ /** What is wrong with a Module's icons, as sentences; empty when nothing is. */
3
+ export declare function collectPhiModuleIconErrors(icons: readonly PhiModuleIcon[]): string[];
4
+ /**
5
+ * A Module's icons, for the `icons` of its definition.
6
+ *
7
+ * A drawing is the Module's own (`viewBox` and path data) or an `@ant-design/icons-svg` definition,
8
+ * which is read into one here -- so a package that wants an Ant Design icon the core registry lacks
9
+ * registers it with one import. A name used twice, a name outside the grammar, or a drawing that is not
10
+ * one is refused here, where the package is written.
11
+ */
12
+ export declare function definePhiModuleIcons(icons: readonly PhiModuleIconInput[]): readonly PhiModuleIcon[];
13
+ /** The icon sets of the given Module definitions, one per Module that registers any. */
14
+ export declare function collectPhiModuleIconSets(definitions: Iterable<{
15
+ moduleId: `${string}/${string}`;
16
+ title: string;
17
+ icons?: readonly PhiModuleIcon[];
18
+ }>): PhiModuleIconSet[];
19
+ export type PhiModuleIconIndex = ReadonlyMap<string, ReadonlyMap<string, PhiModuleIcon>>;
20
+ /** The icon sets keyed by Module and name, for the lookups `resolvePhiModuleIcon` makes. */
21
+ export declare function indexPhiModuleIconSets(sets: readonly PhiModuleIconSet[]): PhiModuleIconIndex;
22
+ /**
23
+ * The icon a `module:` name stands for among the Modules an Area holds, or null.
24
+ *
25
+ * Null for a name that is not a `module:` name, for a Module that is not among them -- not installed,
26
+ * or not active in this Area -- and for a name that Module does not register.
27
+ */
28
+ export declare function resolvePhiModuleIcon(index: PhiModuleIconIndex, iconName: string): PhiModuleIcon | null;
@@ -0,0 +1,112 @@
1
+ import { isPhiModuleIconName, parsePhiModuleIconName } from "../constants/module-identity";
2
+ /*
3
+ * The icons a Module registers (`icons` on its definition), how they are checked, and how a name is
4
+ * resolved against the ones an Area holds. Pure: the definition, the catalog check, the Server that
5
+ * hands the active Modules' icons to an Area and the Client that draws them all read the same code.
6
+ */
7
+ function isSvgDefinition(drawing) {
8
+ return "icon" in drawing;
9
+ }
10
+ /*
11
+ * An Ant Design definition is an `<svg>` whose children are `<path>`s -- every outlined and filled icon
12
+ * the package has that a Module would want. Anything else in it (a `<defs>`, a group, a style) is a
13
+ * drawing this reader does not know how to keep, and saying so beats drawing part of it.
14
+ */
15
+ function readSvgDefinitionDrawing(definition) {
16
+ const root = definition.icon;
17
+ if (typeof root === "function") {
18
+ throw new Error(`Ant Design icon "${definition.name}" (${definition.theme}) is two-tone, a function of two colours; `
19
+ + "a Module icon is one drawing in currentColor.");
20
+ }
21
+ const viewBox = root.attrs.viewBox;
22
+ if (root.tag !== "svg" || !viewBox) {
23
+ throw new Error(`Ant Design icon "${definition.name}" is not an <svg> with a viewBox.`);
24
+ }
25
+ const paths = (root.children ?? []).map((child) => {
26
+ if (child.tag !== "path" || !child.attrs.d || child.children?.length) {
27
+ throw new Error(`Ant Design icon "${definition.name}" holds a <${child.tag}>; only <path> children are read.`);
28
+ }
29
+ return child.attrs.d;
30
+ });
31
+ const fillRule = root.attrs["fill-rule"];
32
+ return {
33
+ viewBox,
34
+ paths,
35
+ ...(fillRule === "evenodd" || fillRule === "nonzero" ? { fillRule } : {}),
36
+ };
37
+ }
38
+ /** What is wrong with a Module's icons, as sentences; empty when nothing is. */
39
+ export function collectPhiModuleIconErrors(icons) {
40
+ const errors = [];
41
+ const seen = new Set();
42
+ for (const icon of icons) {
43
+ if (!isPhiModuleIconName(icon.name)) {
44
+ errors.push(`Module icon name "${icon.name}" is not one lower-case kebab segment.`);
45
+ }
46
+ if (seen.has(icon.name)) {
47
+ errors.push(`Module icon "${icon.name}" is registered twice.`);
48
+ }
49
+ seen.add(icon.name);
50
+ if (!icon.label?.trim()) {
51
+ errors.push(`Module icon "${icon.name}" has no label.`);
52
+ }
53
+ const { drawing } = icon;
54
+ if (!drawing || typeof drawing.viewBox !== "string" || !drawing.viewBox.trim()) {
55
+ errors.push(`Module icon "${icon.name}" has no viewBox.`);
56
+ }
57
+ if (!drawing
58
+ || !Array.isArray(drawing.paths)
59
+ || drawing.paths.length === 0
60
+ || drawing.paths.some((path) => typeof path !== "string" || !path.trim())) {
61
+ errors.push(`Module icon "${icon.name}" has no path data.`);
62
+ }
63
+ }
64
+ return errors;
65
+ }
66
+ /**
67
+ * A Module's icons, for the `icons` of its definition.
68
+ *
69
+ * A drawing is the Module's own (`viewBox` and path data) or an `@ant-design/icons-svg` definition,
70
+ * which is read into one here -- so a package that wants an Ant Design icon the core registry lacks
71
+ * registers it with one import. A name used twice, a name outside the grammar, or a drawing that is not
72
+ * one is refused here, where the package is written.
73
+ */
74
+ export function definePhiModuleIcons(icons) {
75
+ const defined = icons.map((icon) => ({
76
+ name: icon.name,
77
+ label: icon.label,
78
+ drawing: isSvgDefinition(icon.drawing) ? readSvgDefinitionDrawing(icon.drawing) : icon.drawing,
79
+ }));
80
+ const errors = collectPhiModuleIconErrors(defined);
81
+ if (errors.length > 0) {
82
+ throw new Error(errors.join(" "));
83
+ }
84
+ return defined;
85
+ }
86
+ /** The icon sets of the given Module definitions, one per Module that registers any. */
87
+ export function collectPhiModuleIconSets(definitions) {
88
+ const sets = [];
89
+ for (const definition of definitions) {
90
+ if (definition.icons && definition.icons.length > 0) {
91
+ sets.push({ moduleId: definition.moduleId, title: definition.title, icons: definition.icons });
92
+ }
93
+ }
94
+ return sets;
95
+ }
96
+ /** The icon sets keyed by Module and name, for the lookups `resolvePhiModuleIcon` makes. */
97
+ export function indexPhiModuleIconSets(sets) {
98
+ return new Map(sets.map((set) => [set.moduleId, new Map(set.icons.map((icon) => [icon.name, icon]))]));
99
+ }
100
+ /**
101
+ * The icon a `module:` name stands for among the Modules an Area holds, or null.
102
+ *
103
+ * Null for a name that is not a `module:` name, for a Module that is not among them -- not installed,
104
+ * or not active in this Area -- and for a name that Module does not register.
105
+ */
106
+ export function resolvePhiModuleIcon(index, iconName) {
107
+ const parsed = parsePhiModuleIconName(iconName);
108
+ if (!parsed) {
109
+ return null;
110
+ }
111
+ return index.get(parsed.moduleId)?.get(parsed.name) ?? null;
112
+ }
package/module.d.ts CHANGED
@@ -52,6 +52,13 @@ export type { PhiRuntimeModuleServerAreaContribution };
52
52
  */
53
53
  export type PhiModuleDefinitions = readonly PhiModuleDefinition[];
54
54
  export declare function definePhiModuleDefinitions(definitions: PhiModuleDefinitions): PhiModuleDefinitions;
55
+ /**
56
+ * The icons a Module registers, for the `icons` of its definition (THIRD_PARTY_MODULES.md, "8d. Icons a
57
+ * Module brings"). Pure data and pure checks, so the root door stays importable by every boundary.
58
+ * Name one with `createPhiModuleIconName` from `@phis/ui/constants`.
59
+ */
60
+ export { definePhiModuleIcons } from "./helpers/module-icons";
61
+ export type { PhiModuleIcon, PhiModuleIconDrawing, PhiModuleIconInput, PhiModuleIconSvgDefinition, } from "./types/module-icons";
55
62
  /**
56
63
  * The Controller descriptor a definition carries, for a package whose Module has a Controller.
57
64
  *
package/module.js CHANGED
@@ -22,6 +22,12 @@ export function definePhiModuleDefinitions(definitions) {
22
22
  }
23
23
  return definitions;
24
24
  }
25
+ /**
26
+ * The icons a Module registers, for the `icons` of its definition (THIRD_PARTY_MODULES.md, "8d. Icons a
27
+ * Module brings"). Pure data and pure checks, so the root door stays importable by every boundary.
28
+ * Name one with `createPhiModuleIconName` from `@phis/ui/constants`.
29
+ */
30
+ export { definePhiModuleIcons } from "./helpers/module-icons";
25
31
  /**
26
32
  * The Controller descriptor a definition carries, for a package whose Module has a Controller.
27
33
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -5,9 +5,9 @@
5
5
  */
6
6
  export declare const PHI_ACCOUNTING_RUNTIME_MODULE: {
7
7
  icon: string;
8
+ moduleId: "@phis/ui/modules/accounting";
8
9
  category: "foundation";
9
10
  description: string;
10
- moduleId: "@phis/ui/modules/accounting";
11
11
  serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
12
12
  kind: "module";
13
13
  eligibleAreas: readonly ["public" | "app" | "admin" | "builder" | "editor" | "accounting"];
@@ -4,9 +4,9 @@
4
4
  * Controller; a Module's own goes into that Module's Controller, mounted on demand.
5
5
  */
6
6
  export declare const PHI_ADMIN_RUNTIME_MODULE: {
7
+ moduleId: "@phis/ui/modules/admin";
7
8
  category: "foundation";
8
9
  description: string;
9
- moduleId: "@phis/ui/modules/admin";
10
10
  serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
11
11
  formProviders: {
12
12
  handlers: {
@@ -5,9 +5,9 @@
5
5
  */
6
6
  export declare const PHI_APP_RUNTIME_MODULE: {
7
7
  icon: string;
8
+ moduleId: "@phis/ui/modules/app";
8
9
  category: "foundation";
9
10
  description: string;
10
- moduleId: "@phis/ui/modules/app";
11
11
  serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
12
12
  formProviders: {
13
13
  handlers: ({
@@ -16,6 +16,7 @@ import { PhiDeveloperBuilderRegionInspectorWidgetClient } from "./region-inspect
16
16
  import { PhiDeveloperBuilderLayoutInspectorWidgetClient } from "./layout-inspector";
17
17
  import { PhiDeveloperBuilderWidgetInspectorWidgetClient } from "./widget-inspector";
18
18
  import { readPhiSurface } from "../../../../types/surface";
19
+ import { PhiModuleIconsProvider } from "../../../../components/shell/phi-module-icons";
19
20
  import { normalizePhiPaddingWidgetConfig } from "../../../../types/cms-config";
20
21
  import { usePhiBuilderModuleMetas, } from "../plugin-meta-store";
21
22
  import { findPhiBuilderLayoutNodeById, findPhiBuilderWidgetNodeByIdInLayouts, } from "../node-finders";
@@ -89,6 +90,7 @@ function usePhiBuilderInspectorSectionState(signalRoutes) {
89
90
  const activeDataProviderDescriptors = activeModuleMetas.dataProviders;
90
91
  const activeCalendarAdapterDescriptors = activeModuleMetas.calendarAdapters;
91
92
  const activeVideoProviderDescriptors = activeModuleMetas.videoProviders;
93
+ const activeModuleIcons = activeModuleMetas.icons;
92
94
  /*
93
95
  * Every Inspector section runs this hook, so what it works out per render is worked out fifteen
94
96
  * times. The lookups and the two tree searches are kept until the drafts or the selection move; the
@@ -174,17 +176,26 @@ function usePhiBuilderInspectorSectionState(signalRoutes) {
174
176
  selectedStructurePlugin,
175
177
  selectedWidgetNode,
176
178
  widgetReferenceOptions,
179
+ activeModuleIcons,
177
180
  };
178
181
  }
182
+ /*
183
+ * The Inspector sits in the Builder's own chrome, outside the canvas, so the icons it holds would be the
184
+ * Builder Area's. An icon field is about the target Area: its picker offers that Area's Module icons and
185
+ * a `module:` value whose Module is not active there is flagged, as it is in the canvas.
186
+ */
187
+ function PhiBuilderInspectorModuleIcons({ sets, children, }) {
188
+ return _jsx(PhiModuleIconsProvider, { sets: sets, flagUnavailable: true, children: children });
189
+ }
179
190
  export function PhiBuilderRegionInspectorSectionWidgetClient({ section, signalRoutes, visibilityLabels, geometryLabels, paddingLabels, backgroundLabels, borderLabels, surfaceLabels, colorPickerLabels, }) {
180
191
  const state = usePhiBuilderInspectorSectionState(signalRoutes);
181
192
  return _jsx(PhiDeveloperBuilderRegionInspectorWidgetClient, { surfaceLabels: surfaceLabels, visibilityLabels: visibilityLabels, section: section, builderMode: state.builderMode, selectedStructureNodeKey: state.nodeKey, selectedStructureNodeKind: state.nodeKind, selectedRegionKey: state.selectedRegionKey, selectedRootRegionKey: state.selectedRootRegionKey, currentDraft: state.currentRegionDraft, onDraftChange: (patch) => state.emitInspectorControllerAction({ kind: "patchSelectedRegionDraft", patch }), geometryLabels: geometryLabels, backgroundLabels: backgroundLabels, borderLabels: borderLabels, colorPickerLabels: colorPickerLabels, paddingLabels: paddingLabels, renderMediaPicker: state.renderBackgroundMediaPicker });
182
193
  }
183
194
  export function PhiBuilderLayoutInspectorSectionWidgetClient({ section, signalRoutes, signalsLabels, paddingLabels, backgroundLabels, borderLabels, surfaceLabels, gridLabels, fieldLabels, colorPickerLabels, iconPickerLabels, }) {
184
195
  const state = usePhiBuilderInspectorSectionState(signalRoutes);
185
- return _jsx(PhiDeveloperBuilderLayoutInspectorWidgetClient, { surfaceLabels: surfaceLabels, gridLabels: gridLabels, fieldLabels: fieldLabels, section: section, builderMode: state.builderMode, selectedStructureNodeKind: state.nodeKind, selectedStructureNodeTitle: state.selectedStructureNodeTitle, selectedStructurePlugin: state.selectedStructurePlugin?.kind !== "widget" ? state.selectedStructurePlugin : null, selectedStructureDefaultConfig: resolvePhiBuilderPluginDefaultConfig(state.selectedStructurePlugin) ?? null, currentDraft: state.selectedStructureDraft, signalRouteScope: state.selectedSignalRouteScope, selectedLayoutAnchor: state.selectedLayoutAnchor, onLayoutAnchorChange: (selectedLayoutAnchor) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutAnchor", selectedLayoutAnchor }), onPaddingChange: (padding) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutPadding", padding }), onSurfaceChange: (surface) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutSurface", surface }), onConfigPatch: (patch) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutConfig", patch }), onTranslateChange: (translate) => state.emitInspectorControllerAction({ kind: "setSelectedLayoutTranslate", translate }), borderLabels: borderLabels, paddingLabels: paddingLabels, backgroundLabels: backgroundLabels, signalsLabels: signalsLabels, colorPickerLabels: colorPickerLabels, iconPickerLabels: iconPickerLabels, dataProviderDescriptors: state.activeDataProviderDescriptors, calendarAdapterDescriptors: state.activeCalendarAdapterDescriptors, videoProviderDescriptors: state.activeVideoProviderDescriptors, renderMediaPicker: state.renderBackgroundMediaPicker });
196
+ return _jsx(PhiBuilderInspectorModuleIcons, { sets: state.activeModuleIcons, children: _jsx(PhiDeveloperBuilderLayoutInspectorWidgetClient, { surfaceLabels: surfaceLabels, gridLabels: gridLabels, fieldLabels: fieldLabels, section: section, builderMode: state.builderMode, selectedStructureNodeKind: state.nodeKind, selectedStructureNodeTitle: state.selectedStructureNodeTitle, selectedStructurePlugin: state.selectedStructurePlugin?.kind !== "widget" ? state.selectedStructurePlugin : null, selectedStructureDefaultConfig: resolvePhiBuilderPluginDefaultConfig(state.selectedStructurePlugin) ?? null, currentDraft: state.selectedStructureDraft, signalRouteScope: state.selectedSignalRouteScope, selectedLayoutAnchor: state.selectedLayoutAnchor, onLayoutAnchorChange: (selectedLayoutAnchor) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutAnchor", selectedLayoutAnchor }), onPaddingChange: (padding) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutPadding", padding }), onSurfaceChange: (surface) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutSurface", surface }), onConfigPatch: (patch) => state.emitInspectorControllerAction({ kind: "patchSelectedLayoutConfig", patch }), onTranslateChange: (translate) => state.emitInspectorControllerAction({ kind: "setSelectedLayoutTranslate", translate }), borderLabels: borderLabels, paddingLabels: paddingLabels, backgroundLabels: backgroundLabels, signalsLabels: signalsLabels, colorPickerLabels: colorPickerLabels, iconPickerLabels: iconPickerLabels, dataProviderDescriptors: state.activeDataProviderDescriptors, calendarAdapterDescriptors: state.activeCalendarAdapterDescriptors, videoProviderDescriptors: state.activeVideoProviderDescriptors, renderMediaPicker: state.renderBackgroundMediaPicker }) });
186
197
  }
187
198
  export function PhiBuilderWidgetInspectorSectionWidgetClient({ section, signalRoutes, geometryLabels, surfaceLabels, backgroundLabels, borderLabels, signalsLabels, fieldLabels, colorPickerLabels, iconPickerLabels, }) {
188
199
  const state = usePhiBuilderInspectorSectionState(signalRoutes);
189
- return _jsx(PhiDeveloperBuilderWidgetInspectorWidgetClient, { surfaceLabels: surfaceLabels, fieldLabels: fieldLabels, backgroundLabels: backgroundLabels, borderLabels: borderLabels, renderMediaPicker: state.renderBackgroundMediaPicker, onSurfaceChange: (surface) => state.emitInspectorControllerAction({ kind: "patchSelectedWidgetSurface", surface }), section: section, builderMode: state.builderMode, selectedStructureNodeKey: state.nodeKey, selectedStructureNodeKind: state.nodeKind, selectedStructureNodeTitle: state.selectedStructureNodeTitle, selectedStructureWidgetMeta: state.selectedStructurePlugin?.kind === "widget" ? state.selectedStructurePlugin : null, currentDraft: state.selectedWidgetNode, widgetReferenceOptions: state.widgetReferenceOptions, signalRouteScope: state.selectedSignalRouteScope, onConfigChange: (nextConfig) => state.emitInspectorControllerAction({ kind: "patchSelectedWidgetConfig", patch: nextConfig }), geometryLabels: geometryLabels, signalsLabels: signalsLabels, colorPickerLabels: colorPickerLabels, iconPickerLabels: iconPickerLabels, dataProviderDescriptors: state.activeDataProviderDescriptors, calendarAdapterDescriptors: state.activeCalendarAdapterDescriptors, videoProviderDescriptors: state.activeVideoProviderDescriptors, onGeometryChange: (geometry) => state.emitInspectorControllerAction({ kind: "patchSelectedWidgetGeometry", geometry }), onTranslateChange: (translate) => state.emitInspectorControllerAction({ kind: "setSelectedWidgetTranslate", translate }) });
200
+ return _jsx(PhiBuilderInspectorModuleIcons, { sets: state.activeModuleIcons, children: _jsx(PhiDeveloperBuilderWidgetInspectorWidgetClient, { surfaceLabels: surfaceLabels, fieldLabels: fieldLabels, backgroundLabels: backgroundLabels, borderLabels: borderLabels, renderMediaPicker: state.renderBackgroundMediaPicker, onSurfaceChange: (surface) => state.emitInspectorControllerAction({ kind: "patchSelectedWidgetSurface", surface }), section: section, builderMode: state.builderMode, selectedStructureNodeKey: state.nodeKey, selectedStructureNodeKind: state.nodeKind, selectedStructureNodeTitle: state.selectedStructureNodeTitle, selectedStructureWidgetMeta: state.selectedStructurePlugin?.kind === "widget" ? state.selectedStructurePlugin : null, currentDraft: state.selectedWidgetNode, widgetReferenceOptions: state.widgetReferenceOptions, signalRouteScope: state.selectedSignalRouteScope, onConfigChange: (nextConfig) => state.emitInspectorControllerAction({ kind: "patchSelectedWidgetConfig", patch: nextConfig }), geometryLabels: geometryLabels, signalsLabels: signalsLabels, colorPickerLabels: colorPickerLabels, iconPickerLabels: iconPickerLabels, dataProviderDescriptors: state.activeDataProviderDescriptors, calendarAdapterDescriptors: state.activeCalendarAdapterDescriptors, videoProviderDescriptors: state.activeVideoProviderDescriptors, onGeometryChange: (geometry) => state.emitInspectorControllerAction({ kind: "patchSelectedWidgetGeometry", geometry }), onTranslateChange: (translate) => state.emitInspectorControllerAction({ kind: "setSelectedWidgetTranslate", translate }) }) });
190
201
  }
@@ -7,6 +7,7 @@ import { PhiRuntimeModuleDataProviderClientHost } from "../../../../components/r
7
7
  import { PhiRuntimeModuleProvider } from "../../../../components/runtime/runtime-module-context";
8
8
  import { setPhiBuilderModuleMetas } from "../plugin-meta-store";
9
9
  import { usePhiDeveloperBuilderStateValue } from "../developer-workspace-store";
10
+ import { PhiModuleIconsProvider } from "../../../../components/shell/phi-module-icons";
10
11
  export function PhiBuilderRuntimeModuleAuthoringBoundary({ targetArea, catalog, pickerDataProviderKeys, children, }) {
11
12
  const selectedModuleIds = usePhiDeveloperBuilderStateValue((state) => state.runtimeModuleIdsByArea[targetArea]);
12
13
  const activeEntries = useMemo(() => {
@@ -25,6 +26,7 @@ export function PhiBuilderRuntimeModuleAuthoringBoundary({ targetArea, catalog,
25
26
  const calendarAdapterDescriptors = useMemo(() => activeEntries.flatMap((entry) => entry.calendarAdapterDescriptors), [activeEntries]);
26
27
  const videoProviderDescriptors = useMemo(() => activeEntries.flatMap((entry) => entry.videoProviderDescriptors), [activeEntries]);
27
28
  const formOptions = useMemo(() => activeEntries.flatMap((entry) => entry.formOptions), [activeEntries]);
29
+ const iconSets = useMemo(() => activeEntries.flatMap((entry) => entry.iconSet ? [entry.iconSet] : []), [activeEntries]);
28
30
  const authoringDataProviderKeys = useMemo(() => activeEntries.flatMap((entry) => entry.authoringDataProviderKeys), [activeEntries]);
29
31
  useEffect(() => {
30
32
  setPhiBuilderModuleMetas(targetArea, {
@@ -34,15 +36,17 @@ export function PhiBuilderRuntimeModuleAuthoringBoundary({ targetArea, catalog,
34
36
  calendarAdapters: calendarAdapterDescriptors,
35
37
  videoProviders: videoProviderDescriptors,
36
38
  forms: formOptions,
39
+ icons: iconSets,
37
40
  });
38
41
  }, [
39
42
  calendarAdapterDescriptors,
40
43
  collectionItemRendererDescriptors,
41
44
  dataProviderDescriptors,
42
45
  formOptions,
46
+ iconSets,
43
47
  plugins,
44
48
  targetArea,
45
49
  videoProviderDescriptors,
46
50
  ]);
47
- return (_jsx(PhiRuntimeModuleProvider, { moduleIds: moduleIds, widgetTypes: widgetDefinitions.map((definition) => definition.type), layoutTypes: layoutTypes, widgetDefinitions: widgetDefinitions, dataProviderDescriptors: dataProviderDescriptors, calendarAdapterDescriptors: calendarAdapterDescriptors, videoProviderDescriptors: videoProviderDescriptors, collectionItemRendererDescriptors: collectionItemRendererDescriptors, children: _jsx(PhiRuntimeModuleAuthoringDataProviderHost, { providerKeys: authoringDataProviderKeys, children: _jsx(PhiRuntimeModuleDataProviderClientHost, { providerKeys: pickerDataProviderKeys, mode: "live", children: _jsx(PhiRuntimeModuleAuthoringClientHost, { moduleIds: moduleIds, children: children }) }) }) }));
51
+ return (_jsx(PhiRuntimeModuleProvider, { moduleIds: moduleIds, widgetTypes: widgetDefinitions.map((definition) => definition.type), layoutTypes: layoutTypes, widgetDefinitions: widgetDefinitions, dataProviderDescriptors: dataProviderDescriptors, calendarAdapterDescriptors: calendarAdapterDescriptors, videoProviderDescriptors: videoProviderDescriptors, collectionItemRendererDescriptors: collectionItemRendererDescriptors, children: _jsx(PhiRuntimeModuleAuthoringDataProviderHost, { providerKeys: authoringDataProviderKeys, children: _jsx(PhiRuntimeModuleDataProviderClientHost, { providerKeys: pickerDataProviderKeys, mode: "live", children: _jsx(PhiRuntimeModuleAuthoringClientHost, { moduleIds: moduleIds, children: _jsx(PhiModuleIconsProvider, { sets: iconSets, flagUnavailable: true, children: children }) }) }) }) }));
48
52
  }
@@ -527,17 +527,37 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
527
527
  * The Pages workspace derives which Pages are visible from which Modules are active, so an unsaved
528
528
  * Module change has to reach it even though the change itself is made and persisted from elsewhere --
529
529
  * the URL is what carries it across that gap.
530
+ *
531
+ * It writes last, on top of an address that already names its Area and Page. The address is also
532
+ * written by the effect that settles the Area and Page below, and both built their next address from
533
+ * the same old one, so each dropped what the other had set; and before the Area's Modules had loaded
534
+ * this one wrote an empty list. Every write is a server render of the canvas -- five per open, some of
535
+ * them aborted, one of them a Shell with no Modules -- and when the last one died the canvas stayed
536
+ * "Rendering" with its Regions empty. So it waits for the Modules and for the Area and Page to be in
537
+ * the address, and adds the Modules to that.
530
538
  */
531
539
  useEffect(() => {
532
540
  if (typeof pathname !== "string" ||
533
541
  (builderWorkspaceKey !== "shells" && builderWorkspaceKey !== "pages") ||
542
+ state.runtimeModuleIdsByArea == null ||
543
+ scopeAreaFromSearch == null ||
544
+ scopePageFromSearch == null ||
534
545
  searchParams.get(PHI_BUILDER_RUNTIME_MODULES_SEARCH_PARAM) === selectedRuntimeModuleIdsSearchValue) {
535
546
  return;
536
547
  }
537
548
  const nextSearchParams = new URLSearchParams(searchParams.toString());
538
549
  nextSearchParams.set(PHI_BUILDER_RUNTIME_MODULES_SEARCH_PARAM, selectedRuntimeModuleIdsSearchValue);
539
550
  router.replace(`${pathname}?${nextSearchParams.toString()}`, { scroll: false });
540
- }, [builderWorkspaceKey, pathname, router, searchParams, selectedRuntimeModuleIdsSearchValue]);
551
+ }, [
552
+ builderWorkspaceKey,
553
+ pathname,
554
+ router,
555
+ scopeAreaFromSearch,
556
+ scopePageFromSearch,
557
+ searchParams,
558
+ selectedRuntimeModuleIdsSearchValue,
559
+ state.runtimeModuleIdsByArea,
560
+ ]);
541
561
  useEffect(() => {
542
562
  if (builderWorkspaceKey !== "shells") {
543
563
  return;
@@ -5,6 +5,7 @@ import type { PhiCollectionItemRendererDescriptor } from "../../../types/collect
5
5
  import type { PhiRuntimeDataProviderKey } from "../../../types/runtime-data-provider";
6
6
  import type { PhiControlOption } from "../../../components/controls/phi-control-options";
7
7
  import type { PhiBuilderPluginMeta } from "../../../types/builder";
8
+ import type { PhiModuleIconSet } from "../../../types/module-icons";
8
9
  export type PhiBuilderModuleAuthoringCatalogEntry = {
9
10
  moduleId: PhiRuntimeModuleId;
10
11
  /** The language the Module's own texts are written in; `en` for every Module of ours. */
@@ -19,4 +20,6 @@ export type PhiBuilderModuleAuthoringCatalogEntry = {
19
20
  videoProviderDescriptors: readonly PhiVideoProviderDescriptor[];
20
21
  formOptions: readonly PhiControlOption[];
21
22
  authoringDataProviderKeys: readonly PhiRuntimeDataProviderKey[];
23
+ /** The icons the Module registers, for the canvas and the icon picker; null when it registers none. */
24
+ iconSet: PhiModuleIconSet | null;
22
25
  };
@@ -3,6 +3,7 @@ import { canPhiViewerAccessOwnedPolicy } from "../../../types/access";
3
3
  import { buildPhiRuntimeModuleLayoutType, buildPhiRuntimeModuleWidgetType, } from "../../../plugins/runtime-modules/contracts";
4
4
  import { buildPhiBuilderLayoutPluginMetas, buildPhiBuilderPluginMeta, } from "./plugin-metas";
5
5
  import { resolvePhiRuntimeModuleSourceLocale } from "../../../types/runtime-module-locale";
6
+ import { collectPhiModuleIconSets } from "../../../helpers/module-icons";
6
7
  export function buildPhiBuilderModuleAuthoringCatalog({ catalog, area, activeModuleIds, viewer, }) {
7
8
  const areaDefinition = catalog.areaDefinitions.find((definition) => definition.area === area);
8
9
  if (!areaDefinition) {
@@ -54,6 +55,7 @@ export function buildPhiBuilderModuleAuthoringCatalog({ catalog, area, activeMod
54
55
  authoringDataProviderKeys: (entry.definition.dataProviders ?? [])
55
56
  .filter((descriptor) => descriptor.authoringMode !== "none")
56
57
  .map((descriptor) => descriptor.key),
58
+ iconSet: collectPhiModuleIconSets([entry.definition])[0] ?? null,
57
59
  }];
58
60
  });
59
61
  }
@@ -4,6 +4,7 @@ import type { PhiCollectionItemRendererDescriptor } from "../../../types/collect
4
4
  import type { PhiCalendarAdapterDescriptor } from "../../../types/calendar";
5
5
  import type { PhiVideoProviderDescriptor } from "../../../types/video";
6
6
  import type { PhiControlOption } from "../../../components/controls/phi-control-options";
7
+ import type { PhiModuleIconSet } from "../../../types/module-icons";
7
8
  type PhiBuilderModuleMetaState = {
8
9
  plugins: readonly PhiBuilderPluginMeta[];
9
10
  dataProviders: readonly PhiRuntimeModuleDataProviderDescriptor[];
@@ -11,6 +12,8 @@ type PhiBuilderModuleMetaState = {
11
12
  calendarAdapters: readonly PhiCalendarAdapterDescriptor[];
12
13
  videoProviders: readonly PhiVideoProviderDescriptor[];
13
14
  forms: readonly PhiControlOption[];
15
+ /** The target Area's active Modules' icons, which the Inspector's icon picker offers. */
16
+ icons: readonly PhiModuleIconSet[];
14
17
  };
15
18
  export declare function usePhiBuilderModuleMetas(area: string): PhiBuilderModuleMetaState;
16
19
  export declare function getPhiBuilderModuleMetasSnapshot(area: string): PhiBuilderModuleMetaState;
@@ -7,6 +7,7 @@ const builderPluginMetaStore = createPhiPluginStateStore("@phis/ui/builder-plugi
7
7
  calendarAdapters: [],
8
8
  videoProviders: [],
9
9
  forms: [],
10
+ icons: [],
10
11
  }));
11
12
  export function usePhiBuilderModuleMetas(area) {
12
13
  return builderPluginMetaStore.useStore(area);
@@ -8,6 +8,7 @@ import { PHI_MODULE_MARKER, isPhiRuntimeModuleId } from "../../constants/module-
8
8
  import { isPhiCmsPluginCategory } from "../../constants/cms-plugin-categories";
9
9
  import { assertPhiSignalPluginMetaContract, isPhiSignalValueSchema } from "../../types/signals";
10
10
  import { isPhiNamespacedRuntimeKey } from "../../types/runtime-data-provider";
11
+ import { collectPhiModuleIconErrors } from "../../helpers/module-icons";
11
12
  import { isPhiViewerAccessPolicyProviderOwned, } from "../../types/access";
12
13
  import { isPhiOwnedRuntimeModuleId, isPhiRuntimeModuleSourceLocale, resolvePhiRuntimeModuleSourceLocale, } from "../../types/runtime-module-locale";
13
14
  /*
@@ -367,6 +368,14 @@ function assertPhiRuntimeModuleMetadata(definition) {
367
368
  throw new Error(`${definition.moduleId}: Phi-owned Modules must use English canonical copy.`);
368
369
  }
369
370
  assertPhiCollectionItemRenderers(definition);
371
+ /*
372
+ * `definePhiModuleIcons` refuses the same where a package writes its icons; a definition that was not
373
+ * written through it is refused here, before a name it holds twice can resolve to either drawing.
374
+ */
375
+ const iconErrors = collectPhiModuleIconErrors(definition.icons ?? []);
376
+ if (iconErrors.length > 0) {
377
+ throw new Error(`${definition.moduleId}: ${iconErrors.join(" ")}`);
378
+ }
370
379
  if (definition.authUiProvider) {
371
380
  if (!isPhiNamespacedRuntimeKey(definition.authUiProvider.providerKey)) {
372
381
  throw new Error(`${definition.moduleId}: Auth UI provider key must be namespaced.`);
@@ -682,6 +691,7 @@ export function createPhiRuntimeModuleCatalog(entries, areaDefinitions) {
682
691
  (entry.dashboardCards ? 1 : 0) +
683
692
  (definition.dataProviders?.length ?? 0) + (definition.calendarAdapters?.length ?? 0) +
684
693
  (definition.videoProviders?.length ?? 0) + (definition.collectionItemRenderers?.length ?? 0) +
694
+ (definition.icons?.length ?? 0) +
685
695
  Object.values(definition.formProviders ?? {}).reduce((count, providers) => count + (providers?.length ?? 0), 0);
686
696
  if (definition.kind === "module" && contributionCount === 0 && !hasController) {
687
697
  throw new Error(`Controllerless runtime module "${definition.moduleId}" must contribute at least one owned artifact.`);
@@ -48,7 +48,7 @@ export type PhiCmsCardWidgetConfig = PhiCmsWidgetConfigBase & PhiCardImageSource
48
48
  /** The tag of the heading; how large it is drawn is the variant's business. */
49
49
  headingLevel?: PhiCardHeadingLevel;
50
50
  textAlign?: PhiCardTextAlign;
51
- /** An icon name, as the icon picker writes it (`antd:*`, `iconify:*`, `asset:*`). */
51
+ /** An icon name, as the icon picker writes it (`antd:*`, `module:*`, `iconify:*`, `asset:*`). */
52
52
  icon?: string;
53
53
  iconPlacement?: PhiCardIconPlacement;
54
54
  /** The icon's colour and the ground it stands on; absent, the Theme's. */
@@ -4,9 +4,9 @@
4
4
  * Controller; a Module's own goes into that Module's Controller, mounted on demand.
5
5
  */
6
6
  export declare const PHI_EDITOR_RUNTIME_MODULE: {
7
+ moduleId: "@phis/ui/modules/editor";
7
8
  category: "foundation";
8
9
  description: string;
9
- moduleId: "@phis/ui/modules/editor";
10
10
  serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
11
11
  dataProviders: {
12
12
  key: `${string}/${string}`;
@@ -5,9 +5,9 @@
5
5
  */
6
6
  export declare const PHI_PUBLIC_RUNTIME_MODULE: {
7
7
  icon: string;
8
+ moduleId: "@phis/ui/modules/public";
8
9
  category: "foundation";
9
10
  description: string;
10
- moduleId: "@phis/ui/modules/public";
11
11
  serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
12
12
  formProviders: {
13
13
  handlers: readonly [{
@@ -566,8 +566,13 @@ h5.phi-typography, .phi-typography h5 {
566
566
  * to its title and a `fill` column took the rest, out of line with the rows under it. Fixed layout makes
567
567
  * the `<colgroup>` the header's widths. The body keeps the configured `layout.mode`; Ant Design writes
568
568
  * that inline on both tables, so the header's is stated over it.
569
+ *
570
+ * Not while the table is empty. With no rows Ant Design has measured nothing and leaves the header's
571
+ * `<colgroup>` without widths, so fixed layout took them from the header cells instead: every `content`
572
+ * column got its 1% -- a dozen pixels, its title cut to one letter -- and the `fill` column the rest.
573
+ * Without rows there is nothing to line up with, and `auto` gives each title its own width.
569
574
  */
570
- .phi-table-control.phi-table-control--sticky-header [class~="ant-table-sticky-holder"] > table {
575
+ .phi-table-control.phi-table-control--sticky-header:not(.phi-table-control--empty) [class~="ant-table-sticky-holder"] > table {
571
576
  table-layout: fixed !important;
572
577
  }
573
578
 
@@ -885,6 +885,16 @@ export type PhiRuntimeModuleDefinition = {
885
885
  * reach the browser as props and the placeholder reads them there.
886
886
  */
887
887
  videoProviders?: readonly import("./video").PhiVideoProviderDescriptor[];
888
+ /**
889
+ * Icons this Module brings, for its own presets and for Widget configs on Sites that activate it.
890
+ *
891
+ * Plain drawings in `currentColor` the Module bundles itself (`definePhiModuleIcons`), named
892
+ * `module:<moduleId>/<name>` (`createPhiModuleIconName`). Data like `videoProviders`: the active
893
+ * Modules' icons reach the browser as props of the Area and of the Builder canvas, and a name whose
894
+ * Module is not active there draws nothing. Not `icon`, which is the Module's own mark in the Modules
895
+ * list and stays a name every Area resolves.
896
+ */
897
+ icons?: readonly import("./module-icons").PhiModuleIcon[];
888
898
  formProviders?: PhiRuntimeModuleFormProviderDescriptors;
889
899
  authUiProvider?: {
890
900
  providerKey: `${string}/${string}`;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Icons a Module registers for itself, so its presets and Widget configs can name them.
3
+ *
4
+ * Plain data, because that is all an icon is: a drawing the Module bundles in its own source, filled
5
+ * with `currentColor` so it follows the Theme. The definition carries it (`icons`), the resolved Module
6
+ * set hands the active Modules' icons to the Area as props, and `PhiIcon` draws one by its name,
7
+ * `module:<runtime module id>/<icon name>` (`createPhiModuleIconName`). Nothing is fetched, and an icon
8
+ * of a Module that is not active where it is drawn is not there.
9
+ */
10
+ /** One outline drawing: a view box and the path data drawn in it, filled with `currentColor`. */
11
+ export type PhiModuleIconDrawing = {
12
+ viewBox: string;
13
+ /** Every path is filled; several paths draw one mark. */
14
+ paths: readonly string[];
15
+ /** Ant Design draws some outlines with `evenodd`; the SVG default is `nonzero`. */
16
+ fillRule?: "nonzero" | "evenodd";
17
+ };
18
+ /** An icon as the definition carries it. */
19
+ export type PhiModuleIcon = {
20
+ /** One lower-case kebab segment, unique within the Module (`isPhiModuleIconName`). */
21
+ name: string;
22
+ /** What the Builder's icon picker shows beside it, in the Module's source locale. */
23
+ label: string;
24
+ drawing: PhiModuleIconDrawing;
25
+ };
26
+ /**
27
+ * An Ant Design icon definition as `@ant-design/icons-svg` ships it -- the same data, under a structure
28
+ * of its own. Typed here by shape so that neither this package nor a Module has to import that
29
+ * package's types to hand one over. Only an outline or filled definition is a drawing; a two-tone one is
30
+ * a function of two colours, and is refused.
31
+ */
32
+ export type PhiModuleIconSvgDefinition = {
33
+ name: string;
34
+ theme: string;
35
+ icon: PhiModuleIconSvgNode | ((primaryColor: string, secondaryColor: string) => PhiModuleIconSvgNode);
36
+ };
37
+ export type PhiModuleIconSvgNode = {
38
+ tag: string;
39
+ attrs: {
40
+ readonly [key: string]: string;
41
+ };
42
+ children?: readonly PhiModuleIconSvgNode[];
43
+ };
44
+ /** An icon as a Module writes it into `definePhiModuleIcons`: its own drawing, or an Ant Design one. */
45
+ export type PhiModuleIconInput = {
46
+ name: string;
47
+ label: string;
48
+ drawing: PhiModuleIconDrawing | PhiModuleIconSvgDefinition;
49
+ };
50
+ /** One active Module's icons, as an Area or the Builder receives them. */
51
+ export type PhiModuleIconSet = {
52
+ moduleId: `${string}/${string}`;
53
+ /** The Module's title, which the icon picker groups the icons under. */
54
+ title: string;
55
+ icons: readonly PhiModuleIcon[];
56
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Icons a Module registers for itself, so its presets and Widget configs can name them.
3
+ *
4
+ * Plain data, because that is all an icon is: a drawing the Module bundles in its own source, filled
5
+ * with `currentColor` so it follows the Theme. The definition carries it (`icons`), the resolved Module
6
+ * set hands the active Modules' icons to the Area as props, and `PhiIcon` draws one by its name,
7
+ * `module:<runtime module id>/<icon name>` (`createPhiModuleIconName`). Nothing is fetched, and an icon
8
+ * of a Module that is not active where it is drawn is not there.
9
+ */
10
+ export {};