@phis/ui 0.4.16 → 0.4.17

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 (104) hide show
  1. package/components/controls/phi-table-control.js +15 -0
  2. package/components/forms/compound-form-controls.js +2 -1
  3. package/components/widgets/label-sets/observability-logs.d.ts +2 -0
  4. package/components/widgets/label-sets/observability-logs.js +4 -0
  5. package/components/widgets/label-sets/search.js +2 -0
  6. package/components/widgets/label-types/search.d.ts +2 -0
  7. package/components/widgets/label-types/search.js +1 -0
  8. package/constants/cms-widget-types.js +3 -2
  9. package/helpers/site-runtime.js +3 -0
  10. package/net/log.d.ts +1 -0
  11. package/net/log.js +19 -1
  12. package/net/phi-next-proxy.js +9 -1
  13. package/package.json +1 -1
  14. package/plugins/runtime-modules/app/presets.js +0 -23
  15. package/plugins/runtime-modules/area-contributions/app.d.ts +1 -1
  16. package/plugins/runtime-modules/area-contributions/app.js +2 -0
  17. package/plugins/runtime-modules/area-contributions/public.d.ts +1 -1
  18. package/plugins/runtime-modules/area-contributions/public.js +2 -0
  19. package/plugins/runtime-modules/area-module-defaults.js +21 -2
  20. package/plugins/runtime-modules/client-authoring-providers/app.d.ts +1 -1
  21. package/plugins/runtime-modules/client-authoring-providers/app.js +6 -0
  22. package/plugins/runtime-modules/client-authoring-providers/public.d.ts +1 -1
  23. package/plugins/runtime-modules/client-authoring-providers/public.js +6 -0
  24. package/plugins/runtime-modules/client-manifests/common.js +2 -2
  25. package/plugins/runtime-modules/core/authoring-widgets.js +0 -4
  26. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +1 -1
  27. package/plugins/runtime-modules/core/widgets/markdown-toc/client.js +1 -1
  28. package/plugins/runtime-modules/core/widgets/table/client.js +7 -5
  29. package/plugins/runtime-modules/core/widgets/table/config.js +8 -1
  30. package/plugins/runtime-modules/core/widgets/tree/client.js +1 -1
  31. package/plugins/runtime-modules/core/widgets.js +0 -17
  32. package/plugins/runtime-modules/groups/trees/group-tables.d.ts +44 -0
  33. package/plugins/runtime-modules/groups/trees/group-tables.js +150 -0
  34. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +28 -136
  35. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +9 -106
  36. package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +17 -5
  37. package/plugins/runtime-modules/observability/data-providers.d.ts +9 -0
  38. package/plugins/runtime-modules/observability/data-providers.js +5 -0
  39. package/plugins/runtime-modules/observability/definition.d.ts +9 -0
  40. package/plugins/runtime-modules/observability/module.d.ts +9 -0
  41. package/plugins/runtime-modules/observability/services/table.js +4 -0
  42. package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +13 -0
  43. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +21 -0
  44. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
  45. package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
  46. package/plugins/runtime-modules/public/presets.d.ts +0 -16
  47. package/plugins/runtime-modules/public/presets.js +0 -22
  48. package/plugins/runtime-modules/public-base-page-references.d.ts +0 -1
  49. package/plugins/runtime-modules/public-base-page-references.js +0 -1
  50. package/plugins/runtime-modules/search/authoring-widgets.d.ts +2 -0
  51. package/plugins/runtime-modules/search/authoring-widgets.js +8 -0
  52. package/plugins/runtime-modules/search/authoring.d.ts +1 -0
  53. package/plugins/runtime-modules/search/authoring.js +8 -0
  54. package/plugins/runtime-modules/search/definition.d.ts +21 -0
  55. package/plugins/runtime-modules/search/definition.js +23 -0
  56. package/plugins/runtime-modules/search/ids.d.ts +6 -0
  57. package/plugins/runtime-modules/search/ids.js +7 -0
  58. package/plugins/runtime-modules/search/module.d.ts +10 -0
  59. package/plugins/runtime-modules/search/module.js +4 -0
  60. package/plugins/runtime-modules/search/page-references.d.ts +8 -0
  61. package/plugins/runtime-modules/search/page-references.js +17 -0
  62. package/plugins/runtime-modules/{search-page-tree.d.ts → search/page-tree.d.ts} +1 -1
  63. package/plugins/runtime-modules/{search-page-tree.js → search/page-tree.js} +9 -7
  64. package/plugins/runtime-modules/search/presets.d.ts +12 -0
  65. package/plugins/runtime-modules/search/presets.js +33 -0
  66. package/plugins/runtime-modules/search/server.d.ts +1 -0
  67. package/plugins/runtime-modules/search/server.js +16 -0
  68. package/plugins/runtime-modules/search/widgets/search-box/authoring.d.ts +8 -0
  69. package/plugins/runtime-modules/search/widgets/search-box/authoring.js +21 -0
  70. package/plugins/runtime-modules/search/widgets/search-box/client.d.ts +39 -0
  71. package/plugins/runtime-modules/search/widgets/search-box/client.js +114 -0
  72. package/plugins/runtime-modules/search/widgets/search-box/config.d.ts +96 -0
  73. package/plugins/runtime-modules/search/widgets/search-box/config.js +67 -0
  74. package/plugins/runtime-modules/{core → search}/widgets/search-box/plugin.js +1 -4
  75. package/plugins/runtime-modules/search/widgets/search-box/server.d.ts +15 -0
  76. package/plugins/runtime-modules/{core → search}/widgets/search-box/server.js +13 -14
  77. package/plugins/runtime-modules/{core → search}/widgets/search-results/config.d.ts +0 -1
  78. package/plugins/runtime-modules/{core → search}/widgets/search-results/config.js +0 -1
  79. package/plugins/runtime-modules/{core → search}/widgets/search-results/plugin.js +1 -3
  80. package/plugins/runtime-modules/{core → search}/widgets/search-results/server.d.ts +1 -2
  81. package/plugins/runtime-modules/{core → search}/widgets/search-results/server.js +2 -2
  82. package/plugins/runtime-modules/search/widgets.d.ts +2 -0
  83. package/plugins/runtime-modules/search/widgets.js +20 -0
  84. package/server-helpers/search-index.js +9 -0
  85. package/styles/shell.css +137 -0
  86. package/theme/phi-theme-tokens.d.ts +1 -1
  87. package/theme/phi-theme-tokens.js +2 -0
  88. package/types/table-widget.d.ts +10 -1
  89. package/types/table-widget.js +1 -0
  90. package/plugins/runtime-modules/core/widgets/search-box/authoring.d.ts +0 -6
  91. package/plugins/runtime-modules/core/widgets/search-box/authoring.js +0 -10
  92. package/plugins/runtime-modules/core/widgets/search-box/client.d.ts +0 -21
  93. package/plugins/runtime-modules/core/widgets/search-box/client.js +0 -17
  94. package/plugins/runtime-modules/core/widgets/search-box/config.d.ts +0 -63
  95. package/plugins/runtime-modules/core/widgets/search-box/config.js +0 -48
  96. package/plugins/runtime-modules/core/widgets/search-box/server.d.ts +0 -21
  97. package/plugins/runtime-modules/search-page-references.d.ts +0 -20
  98. package/plugins/runtime-modules/search-page-references.js +0 -35
  99. /package/plugins/runtime-modules/{core → search}/widgets/search-box/plugin.d.ts +0 -0
  100. /package/plugins/runtime-modules/{core → search}/widgets/search-results/authoring.d.ts +0 -0
  101. /package/plugins/runtime-modules/{core → search}/widgets/search-results/authoring.js +0 -0
  102. /package/plugins/runtime-modules/{core → search}/widgets/search-results/client.d.ts +0 -0
  103. /package/plugins/runtime-modules/{core → search}/widgets/search-results/client.js +0 -0
  104. /package/plugins/runtime-modules/{core → search}/widgets/search-results/plugin.d.ts +0 -0
@@ -0,0 +1,114 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useRef, useState, } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import { PHI_SEARCH_QUERY_PARAM } from "@phis/contracts/search";
6
+ import { PhiButtonControl } from "../../../../../components/controls/phi-button-control";
7
+ import { PhiTextControl } from "../../../../../components/controls/phi-text-control";
8
+ import { PhiIcon } from "../../../../../components/shell/phi-icon";
9
+ import { usePhiHydrated } from "../../../../../components/state/use-phi-hydrated";
10
+ /** The Shell's phone, as `styles/shell.css` measures it: the render viewport below 768px. */
11
+ const PHI_SEARCH_BOX_PHONE_WIDTH = 768;
12
+ /**
13
+ * Whether the magnifier stands on a phone, measured where `styles/shell.css` measures it: the nearest
14
+ * `phi-render-viewport` container, which is the window less the sider live and the device frame in the
15
+ * Builder. Read once when the magnifier is pressed, which is the only moment it decides anything.
16
+ */
17
+ function readPhiSearchBoxOnPhone(element) {
18
+ for (let node = element.parentElement; node; node = node.parentElement) {
19
+ if (getComputedStyle(node).containerName.split(/\s+/).includes("phi-render-viewport")) {
20
+ return node.clientWidth < PHI_SEARCH_BOX_PHONE_WIDTH;
21
+ }
22
+ }
23
+ return window.innerWidth < PHI_SEARCH_BOX_PHONE_WIDTH;
24
+ }
25
+ /** Whether the reader asked for less motion: then there is no fold to wait for. */
26
+ function readPhiReducedMotion() {
27
+ return typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
28
+ }
29
+ /**
30
+ * A `GET` form around one search field (SEARCH.md), as the input or as a magnifier alone that opens into one (`icon-only`).
31
+ *
32
+ * The browser submits it: Enter, or the keyboard's search key, sends `?q=` to the results Page without
33
+ * a script, and a static Public page needs none. The field is the house's text Control with the form's
34
+ * field name, so it clears, labels and sizes like every other field, and the form is a landmark a screen
35
+ * reader lists.
36
+ *
37
+ * The magnifier is a link to the results Page until the page has hydrated, so it leads somewhere without
38
+ * a script too. After that it opens the field where it stands -- the field grows out of it -- or, on a
39
+ * phone, as a row over the whole band it stands in: a header on a phone has no room for a field beside
40
+ * the brand and the menu button, and one that wrapped would push the page down. Escape, the close mark,
41
+ * or leaving the field empty closes it again, the field folding back into the magnifier as it came.
42
+ *
43
+ * `auto` draws both the field and the magnifier and `styles/shell.css` shows one, the way the Header
44
+ * Navigation draws its row and its menu button: whether this is a phone is the Shell's width, known to
45
+ * CSS on the first paint.
46
+ */
47
+ export function PhiSearchBoxWidgetClient({ labels, config }) {
48
+ const [draft, setDraft] = useState(config?.initialQuery ?? "");
49
+ const [open, setOpen] = useState(null);
50
+ const hydrated = usePhiHydrated();
51
+ const rootRef = useRef(null);
52
+ const interactive = config?.interactive !== false;
53
+ const variant = config?.variant ?? "input";
54
+ const placeholder = config?.placeholder ?? "";
55
+ /*
56
+ * Closing plays the opening backwards: the field is marked `closing`, folds, and is removed when its
57
+ * animation ends (`finishClosing`). Without motion there is nothing to wait for.
58
+ */
59
+ const close = useCallback(() => {
60
+ if (readPhiReducedMotion()) {
61
+ setOpen(null);
62
+ return;
63
+ }
64
+ setOpen((current) => (current && !current.closing ? { ...current, closing: true } : current));
65
+ }, []);
66
+ const finishClosing = (event) => {
67
+ if (event.target === event.currentTarget && open?.closing)
68
+ setOpen(null);
69
+ };
70
+ /*
71
+ * The band the row covers is its containing block. A band that is already positioned -- a sticky
72
+ * header -- stays as it is; a static one is positioned while the row is open and given back after.
73
+ */
74
+ useEffect(() => {
75
+ if (open?.kind !== "row")
76
+ return undefined;
77
+ const { region } = open;
78
+ if (getComputedStyle(region).position !== "static")
79
+ return undefined;
80
+ const previous = region.style.position;
81
+ region.style.position = "relative";
82
+ return () => {
83
+ region.style.position = previous;
84
+ };
85
+ }, [open]);
86
+ const submit = (event) => {
87
+ if (!interactive || !config?.action)
88
+ event.preventDefault();
89
+ };
90
+ const onKeyDown = (event) => {
91
+ if (event.key === "Escape" && open && !open.closing) {
92
+ event.preventDefault();
93
+ close();
94
+ }
95
+ };
96
+ const form = ({ autoFocus = false, collapsible = false } = {}) => (_jsx("form", { method: "get", action: interactive ? config?.action : undefined, role: "search", "aria-label": labels.title, className: "phi-search-box__form", onSubmit: submit, children: _jsx(PhiTextControl, { name: PHI_SEARCH_QUERY_PARAM, inputType: "search", ariaLabel: labels.ariaLabel, placeholder: placeholder, clearLabel: labels.clearLabel, size: config?.size, value: draft, readOnly: !interactive, tabIndex: interactive ? undefined : -1, autoFocus: autoFocus, onChange: (value) => setDraft(value ?? ""), onClear: () => setDraft(""), onKeyDown: onKeyDown, onBlur: collapsible ? () => {
97
+ if (!draft.trim())
98
+ close();
99
+ } : undefined, style: { width: "100%" } }) }));
100
+ const pressMagnifier = () => {
101
+ const root = rootRef.current;
102
+ if (!root)
103
+ return;
104
+ // A header band only: a row over the content Region would cover the page, where the field has room.
105
+ const region = root.closest('[data-phi-region-key^="header_"]');
106
+ setOpen(region && readPhiSearchBoxOnPhone(root) ? { kind: "row", region } : { kind: "inline" });
107
+ };
108
+ const magnifier = open?.kind === "inline"
109
+ ? (_jsx("span", { className: open.closing ? "phi-search-box__expand phi-search-box__expand--closing" : "phi-search-box__expand", onAnimationEnd: finishClosing, children: form({ autoFocus: true, collapsible: true }) }))
110
+ : (_jsx("span", { className: "phi-search-box__magnifier", children: _jsx(PhiButtonControl, { type: "text", shape: "circle", ariaLabel: labels.title, ariaExpanded: open != null, icon: _jsx(PhiIcon, { name: "search", size: "inherit" }), size: config?.size, readOnly: !interactive, ...(interactive && !hydrated && config?.action ? { href: config.action } : { onClick: pressMagnifier }) }) }));
111
+ return (_jsxs("div", { ref: rootRef, className: `phi-search-box phi-search-box--${variant}`, children: [variant === "icon-only" ? null : _jsx("span", { className: "phi-search-box__field", children: form() }), variant === "input" ? null : magnifier, open?.kind === "row"
112
+ ? createPortal(_jsxs("div", { className: open.closing ? "phi-search-box__row phi-search-box__row--closing" : "phi-search-box__row", onAnimationEnd: finishClosing, children: [form({ autoFocus: true }), _jsx(PhiButtonControl, { type: "text", shape: "circle", ariaLabel: labels.closeLabel, icon: _jsx(PhiIcon, { name: "close", size: "inherit" }), onClick: close })] }), open.region)
113
+ : null] }));
114
+ }
@@ -0,0 +1,96 @@
1
+ import type { PhiControlSize } from "../../../../../types/control";
2
+ import { type PhiCmsWidgetConfigBase } from "../../../../../components/widgets/config/parser-primitives";
3
+ export declare const PHI_SEARCH_BOX_VARIANTS: readonly ["input", "icon-only", "auto"];
4
+ /**
5
+ * How the box stands where it is placed, named as the Account Widget names its forms: the field itself;
6
+ * a magnifier alone (`icon-only`) that opens into the field when it
7
+ * is pressed, for a header where a field would crowd the row; or `auto`, the field where the screen has
8
+ * room for it and the magnifier on a phone (below 768px of the render viewport, as the Shell's phone).
9
+ */
10
+ export type PhiSearchBoxVariant = (typeof PHI_SEARCH_BOX_VARIANTS)[number];
11
+ /**
12
+ * The box a visitor types a search into (SEARCH.md).
13
+ *
14
+ * It is a form the browser submits: `GET` to the Search Module's results Page of its Area -- always that
15
+ * Page, which always holds the results -- the query in the URL. So it works before
16
+ * anything hydrated and in a static render, where no script has run yet; and the results Page reads the
17
+ * same URL whether it was reached from here, from a bookmark or from a link somebody pasted.
18
+ */
19
+ export type PhiSearchBoxWidgetConfig = PhiCmsWidgetConfigBase & {
20
+ /**
21
+ * What the empty box says: the author's text, translated. Absent is "Search", which an author can
22
+ * change or clear; cleared, the box says nothing.
23
+ */
24
+ placeholder: string;
25
+ /** The field's size; `size` is the block's own geometry and cannot be this. */
26
+ controlSize?: PhiControlSize;
27
+ /** Absent is `input`, the box as it always was. */
28
+ variant?: PhiSearchBoxVariant;
29
+ };
30
+ declare function normalizePhiSearchBoxWidgetConfig(raw: Record<string, unknown>): PhiSearchBoxWidgetConfig;
31
+ export declare const PHI_SEARCH_BOX_WIDGET_DEFINITION: {
32
+ kind: "widget";
33
+ pluginKey: string;
34
+ typeKey: string;
35
+ title: string;
36
+ description: string;
37
+ category: "navigation";
38
+ tags: string[];
39
+ icon: string;
40
+ slotSizePolicy: "fill-inline";
41
+ fields: ({
42
+ key: string;
43
+ type: "string";
44
+ label: string;
45
+ emptyValue: "";
46
+ description: string;
47
+ options?: undefined;
48
+ } | {
49
+ key: string;
50
+ type: "choice";
51
+ label: string;
52
+ description: string;
53
+ options: {
54
+ value: string;
55
+ label: string;
56
+ }[];
57
+ emptyValue?: undefined;
58
+ } | {
59
+ key: string;
60
+ type: "choice";
61
+ label: string;
62
+ options: {
63
+ value: string;
64
+ label: string;
65
+ }[];
66
+ emptyValue?: undefined;
67
+ description?: undefined;
68
+ })[];
69
+ defaultConfig: {
70
+ variant: "input";
71
+ controlSize: "medium";
72
+ renderMode?: import("../../../../../types").PhiRenderableBlockRenderMode;
73
+ visibility?: import("../../../../../types").PhiRenderableBlockVisibility;
74
+ accessPolicy?: import("@phis/contracts/access").PhiViewerAccessPolicy;
75
+ viewportFlags?: import("../../../../../types").PhiViewportFlags;
76
+ enabled?: boolean;
77
+ debugMode?: boolean;
78
+ anchor?: import("../../../../../types").PhiRenderableBlockAnchor;
79
+ zIndex?: number;
80
+ opacity?: number;
81
+ surface?: import("../../../../../types/surface").PhiSurface;
82
+ className?: string;
83
+ size?: import("../../../../../types").PhiRenderableBlockResponsiveSize;
84
+ minSize?: import("../../../../../types").PhiRenderableBlockResponsiveSize;
85
+ maxSize?: import("../../../../../types").PhiRenderableBlockResponsiveSize;
86
+ collapsedSizeHint?: import("../../../../../types").PhiRenderableBlockSize;
87
+ effects?: import("../../../../../types").PhiRenderableBlockEffects;
88
+ /**
89
+ * What the empty box says: the author's text, translated. Absent is "Search", which an author can
90
+ * change or clear; cleared, the box says nothing.
91
+ */
92
+ placeholder: string;
93
+ };
94
+ parseConfig: typeof normalizePhiSearchBoxWidgetConfig;
95
+ };
96
+ export {};
@@ -0,0 +1,67 @@
1
+ import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
2
+ import { PHI_SEARCH_WIDGET_DEFAULT_LABELS } from "../../../../../components/widgets/label-types/search";
3
+ import { readRenderableBlockConfig, } from "../../../../../components/widgets/config/parser-primitives";
4
+ const PHI_SEARCH_BOX_SIZES = ["small", "medium", "large"];
5
+ export const PHI_SEARCH_BOX_VARIANTS = ["input", "icon-only", "auto"];
6
+ function normalizePhiSearchBoxWidgetConfig(raw) {
7
+ return {
8
+ ...readRenderableBlockConfig(raw),
9
+ placeholder: typeof raw.placeholder === "string"
10
+ ? raw.placeholder.trim()
11
+ : PHI_SEARCH_WIDGET_DEFAULT_LABELS.placeholder,
12
+ controlSize: PHI_SEARCH_BOX_SIZES.includes(raw.controlSize)
13
+ ? raw.controlSize
14
+ : undefined,
15
+ variant: PHI_SEARCH_BOX_VARIANTS.includes(raw.variant)
16
+ ? raw.variant
17
+ : undefined,
18
+ };
19
+ }
20
+ export const PHI_SEARCH_BOX_WIDGET_DEFINITION = {
21
+ kind: "widget",
22
+ pluginKey: resolvePhiCmsWidgetPluginKey("search-box"),
23
+ typeKey: "search-box",
24
+ title: "Search Box",
25
+ description: "A box that sends what a visitor types to the Site's search results page.",
26
+ category: "navigation",
27
+ tags: ["search", "find", "navigation"],
28
+ icon: "antd:search",
29
+ slotSizePolicy: "fill-inline",
30
+ fields: [
31
+ {
32
+ key: "placeholder",
33
+ type: "string",
34
+ label: "Placeholder",
35
+ // Cleared is kept as cleared: the box then says nothing, rather than "Search" again.
36
+ emptyValue: "",
37
+ description: "Translated. Empty shows nothing.",
38
+ },
39
+ {
40
+ key: "variant",
41
+ type: "choice",
42
+ label: "Variant",
43
+ description: "Icon only opens into the field when pressed. Auto is the input, and the icon on a phone.",
44
+ options: [
45
+ { value: "input", label: "Input" },
46
+ { value: "icon-only", label: "Icon only" },
47
+ { value: "auto", label: "Auto" },
48
+ ],
49
+ },
50
+ {
51
+ key: "controlSize",
52
+ type: "choice",
53
+ label: "Size",
54
+ options: [
55
+ { value: "small", label: "Small" },
56
+ { value: "medium", label: "Medium" },
57
+ { value: "large", label: "Large" },
58
+ ],
59
+ },
60
+ ],
61
+ /*
62
+ * What the Inspector shows chosen where a box states nothing, and what an absent value renders as: the
63
+ * input, at the house's medium size.
64
+ */
65
+ defaultConfig: { ...normalizePhiSearchBoxWidgetConfig({}), variant: "input", controlSize: "medium" },
66
+ parseConfig: normalizePhiSearchBoxWidgetConfig,
67
+ };
@@ -1,11 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { PhiCmsFlags } from "../../../../../constants/phi-cms";
3
- import { hasPhiFlag } from "../../../../../helpers/flags";
4
2
  import { definePhiPassiveWidgetRenderers } from "../../../../../plugins/factories/widget-renderers";
5
3
  import { PHI_SEARCH_BOX_WIDGET_DEFINITION } from "./config";
6
4
  import { PhiSearchBoxWidget } from "./server";
7
5
  export const PHI_SEARCH_BOX_WIDGET_PLUGIN = {
8
6
  ...PHI_SEARCH_BOX_WIDGET_DEFINITION,
9
- // `links` carries the author's results Page, resolved with every other target of the page.
10
- ...definePhiPassiveWidgetRenderers(({ widget, config, runtime, links }) => (_jsx(PhiSearchBoxWidget, { config: config, runtime: runtime, links: links, translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate) }, `widget-${widget.id}`))),
7
+ ...definePhiPassiveWidgetRenderers(({ widget, config, runtime }) => (_jsx(PhiSearchBoxWidget, { config: config, runtime: runtime }, `widget-${widget.id}`))),
11
8
  };
@@ -0,0 +1,15 @@
1
+ import type { PhiNoLabels, PhiServerBlockBaseProps } from "../../../../../types";
2
+ import type { PhiSearchBoxWidgetConfig } from "./config";
3
+ export type PhiSearchBoxWidgetProps = PhiServerBlockBaseProps<PhiNoLabels, PhiSearchBoxWidgetConfig>;
4
+ /**
5
+ * The search box, resolved on the server: where the form goes, what the box says, what it already holds.
6
+ *
7
+ * Where it goes is the Search Module's results Page of the Area it stands in, a reference resolved as
8
+ * every link is. A Page that does not resolve -- unpublished -- draws no box at all rather than one that
9
+ * leads to "not found". The placeholder is the author's words, always translated: a box whose prompt
10
+ * stays in one language on a Site that speaks several has nothing to gain from it.
11
+ *
12
+ * On the results Page itself the box shows the query it is answering, read from the same URL parameter
13
+ * the results Widget reads.
14
+ */
15
+ export declare function PhiSearchBoxWidget({ config, runtime }: PhiSearchBoxWidgetProps): Promise<import("react").JSX.Element | null>;
@@ -7,41 +7,40 @@ import { resolvePhiLinkHref } from "../../../../../helpers/link-target";
7
7
  import { resolvePhiLinkTargetReferences } from "../../../../../server-helpers/cms-link-targets";
8
8
  import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
9
9
  import { trBulkForLocale } from "../../../../../server-helpers/translate";
10
- import { resolvePhiSearchPageLinkTarget } from "../../../search-page-references";
10
+ import { resolvePhiSearchPageLinkTarget } from "../../page-references";
11
11
  /**
12
12
  * The search box, resolved on the server: where the form goes, what the box says, what it already holds.
13
13
  *
14
- * The results Page is a reference, resolved as every link is -- through the page's targets where the
15
- * author picked one, or alone where the box takes the Area's own Page. An Area whose search Page does not
16
- * resolve -- a Module switched off, a Page unpublished -- draws no box at all rather than one that
17
- * leads to "not found".
14
+ * Where it goes is the Search Module's results Page of the Area it stands in, a reference resolved as
15
+ * every link is. A Page that does not resolve -- unpublished -- draws no box at all rather than one that
16
+ * leads to "not found". The placeholder is the author's words, always translated: a box whose prompt
17
+ * stays in one language on a Site that speaks several has nothing to gain from it.
18
18
  *
19
19
  * On the results Page itself the box shows the query it is answering, read from the same URL parameter
20
20
  * the results Widget reads.
21
21
  */
22
- export async function PhiSearchBoxWidget({ config, runtime, links, translate = true }) {
22
+ export async function PhiSearchBoxWidget({ config, runtime }) {
23
23
  const rt = phiRuntime(runtime);
24
24
  const locale = runtime.locale.current;
25
- const target = config?.linkTarget ?? resolvePhiSearchPageLinkTarget(runtime.area);
26
- const resolved = config?.linkTarget
27
- ? links ?? null
28
- : target.kind === "page"
29
- ? await resolvePhiLinkTargetReferences(new Map([["linkTarget", { reference: target.reference, area: target.area ?? null }]]), runtime)
30
- : null;
25
+ const target = resolvePhiSearchPageLinkTarget(runtime.area);
26
+ const resolved = target.kind === "page"
27
+ ? await resolvePhiLinkTargetReferences(new Map([["linkTarget", { reference: target.reference, area: target.area ?? null }]]), runtime)
28
+ : null;
31
29
  const href = resolvePhiLinkHref(target, resolved);
32
30
  if (!href) {
33
31
  return null;
34
32
  }
35
33
  const [labels, [placeholder]] = await Promise.all([
36
34
  getPhiSearchWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale }),
37
- config?.placeholder && translate ? trBulkForLocale(locale, [config.placeholder]) : [config?.placeholder ?? ""],
35
+ config?.placeholder ? trBulkForLocale(locale, [config.placeholder]) : [""],
38
36
  ]);
39
37
  return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.SearchBox, componentProps: {
40
38
  labels,
41
39
  config: {
42
40
  action: href.href,
43
- placeholder: placeholder || labels.placeholder,
41
+ placeholder,
44
42
  ...(config?.controlSize ? { size: config.controlSize } : {}),
43
+ ...(config?.variant ? { variant: config.variant } : {}),
45
44
  initialQuery: runtime.request?.searchParams?.[PHI_SEARCH_QUERY_PARAM] ?? "",
46
45
  },
47
46
  } }));
@@ -21,7 +21,6 @@ export declare const PHI_SEARCH_RESULTS_WIDGET_DEFINITION: {
21
21
  description: string;
22
22
  category: "content";
23
23
  tags: string[];
24
- translatesOwnText: true;
25
24
  icon: string;
26
25
  slotSizePolicy: "fill-inline";
27
26
  fields: ({
@@ -16,7 +16,6 @@ export const PHI_SEARCH_RESULTS_WIDGET_DEFINITION = {
16
16
  description: "The Site's pages matching the search in the page's address, best first.",
17
17
  category: "content",
18
18
  tags: ["search", "results", "find"],
19
- translatesOwnText: true,
20
19
  icon: "antd:search",
21
20
  slotSizePolicy: "fill-inline",
22
21
  fields: [
@@ -1,10 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { PhiCmsFlags } from "../../../../../constants/phi-cms";
3
- import { hasPhiFlag } from "../../../../../helpers/flags";
4
2
  import { definePhiPassiveWidgetRenderers } from "../../../../../plugins/factories/widget-renderers";
5
3
  import { PHI_SEARCH_RESULTS_WIDGET_DEFINITION } from "./config";
6
4
  import { PhiSearchResultsWidget } from "./server";
7
5
  export const PHI_SEARCH_RESULTS_WIDGET_PLUGIN = {
8
6
  ...PHI_SEARCH_RESULTS_WIDGET_DEFINITION,
9
- ...definePhiPassiveWidgetRenderers(({ widget, config, runtime }) => (_jsx(PhiSearchResultsWidget, { config: config, runtime: runtime, translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate), widgetId: widget.id }, `widget-${widget.id}`))),
7
+ ...definePhiPassiveWidgetRenderers(({ widget, config, runtime }) => (_jsx(PhiSearchResultsWidget, { config: config, runtime: runtime, widgetId: widget.id }, `widget-${widget.id}`))),
10
8
  };
@@ -2,7 +2,6 @@ import type { PhiNoLabels, PhiServerBlockBaseProps } from "../../../../../types"
2
2
  import type { PhiCmsInstanceId } from "../../../../../types/cms-instance-id";
3
3
  import type { PhiSearchResultsWidgetConfig } from "./config";
4
4
  export type PhiSearchResultsWidgetProps = PhiServerBlockBaseProps<PhiNoLabels, PhiSearchResultsWidgetConfig> & {
5
- translate?: boolean;
6
5
  widgetId?: PhiCmsInstanceId | null;
7
6
  };
8
7
  /**
@@ -17,4 +16,4 @@ export type PhiSearchResultsWidgetProps = PhiServerBlockBaseProps<PhiNoLabels, P
17
16
  * A failed read is `PhiWidgetFailureServer`: an empty list would tell the visitor the Site has nothing on
18
17
  * the subject, which is not what happened.
19
18
  */
20
- export declare function PhiSearchResultsWidget({ config, runtime, translate, widgetId }: PhiSearchResultsWidgetProps): Promise<import("react").JSX.Element>;
19
+ export declare function PhiSearchResultsWidget({ config, runtime, widgetId }: PhiSearchResultsWidgetProps): Promise<import("react").JSX.Element>;
@@ -29,13 +29,13 @@ function readHitArea(areaMask) {
29
29
  * A failed read is `PhiWidgetFailureServer`: an empty list would tell the visitor the Site has nothing on
30
30
  * the subject, which is not what happened.
31
31
  */
32
- export async function PhiSearchResultsWidget({ config, runtime, translate = true, widgetId }) {
32
+ export async function PhiSearchResultsWidget({ config, runtime, widgetId }) {
33
33
  const rt = phiRuntime(runtime);
34
34
  const locale = runtime.locale.current;
35
35
  const renderMode = readPhiRuntimeTreeRenderMode(config ?? {});
36
36
  const [labels, [title]] = await Promise.all([
37
37
  getPhiSearchResultsWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale }),
38
- config?.title && translate ? trBulkForLocale(locale, [config.title]) : [config?.title ?? ""],
38
+ config?.title ? trBulkForLocale(locale, [config.title]) : [""],
39
39
  ]);
40
40
  const raw = runtime.request?.searchParams?.[PHI_SEARCH_QUERY_PARAM];
41
41
  const query = readPhiSearchQuery(raw);
@@ -0,0 +1,2 @@
1
+ import type { PhiRuntimeModuleWidgetDefinition } from "../contracts";
2
+ export declare const PHI_SEARCH_RUNTIME_MODULE_WIDGETS: readonly PhiRuntimeModuleWidgetDefinition[];
@@ -0,0 +1,20 @@
1
+ import { PHI_SEARCH_RUNTIME_MODULE_ID } from "./ids";
2
+ import { PHI_SEARCH_BOX_WIDGET_DEFINITION } from "./widgets/search-box/config";
3
+ import { PHI_SEARCH_RESULTS_WIDGET_DEFINITION } from "./widgets/search-results/config";
4
+ import { definePhiFirstPartyWidget } from "../contracts";
5
+ export const PHI_SEARCH_RUNTIME_MODULE_WIDGETS = [
6
+ definePhiFirstPartyWidget({
7
+ definition: PHI_SEARCH_BOX_WIDGET_DEFINITION,
8
+ ownerModuleId: PHI_SEARCH_RUNTIME_MODULE_ID,
9
+ renderPolicies: { runtime: "custom", preview: "custom", authoring: "custom" },
10
+ loadRuntime: () => import("./widgets/search-box/plugin").then((module) => module.PHI_SEARCH_BOX_WIDGET_PLUGIN),
11
+ loadPreview: () => import("./widgets/search-box/plugin").then((module) => module.PHI_SEARCH_BOX_WIDGET_PLUGIN),
12
+ }),
13
+ definePhiFirstPartyWidget({
14
+ definition: PHI_SEARCH_RESULTS_WIDGET_DEFINITION,
15
+ ownerModuleId: PHI_SEARCH_RUNTIME_MODULE_ID,
16
+ renderPolicies: { runtime: "custom", preview: "custom", authoring: "custom" },
17
+ loadRuntime: () => import("./widgets/search-results/plugin").then((module) => module.PHI_SEARCH_RESULTS_WIDGET_PLUGIN),
18
+ loadPreview: () => import("./widgets/search-results/plugin").then((module) => module.PHI_SEARCH_RESULTS_WIDGET_PLUGIN),
19
+ }),
20
+ ];
@@ -1,5 +1,7 @@
1
1
  import "server-only";
2
2
  import { createHash } from "node:crypto";
3
+ import { PHI_SHARED_PACKAGE_NAME } from "../constants/package";
4
+ import { createPhiRuntimeModuleId } from "../constants/module-identity";
3
5
  import { PHI_SEARCH_MAX_DOCUMENTS } from "@phis/contracts/search";
4
6
  import { resolvePhiCmsPageRedirect } from "../components/cms/phi-cms-page-redirect";
5
7
  import { getSiteAreaWithPublishedPages } from "../gateway/site-area";
@@ -35,6 +37,11 @@ import { joinPhiSearchText } from "./search-text";
35
37
  * during a run queues one more.
36
38
  */
37
39
  const PHI_SEARCH_INDEX_AREAS = ["public", "app"];
40
+ /*
41
+ * The first-party Search Module, named by id as data (MODULES.md, "The dependency rule"): an Area is
42
+ * indexed only where it is switched on, since only there is anything placed that reads the index.
43
+ */
44
+ const PHI_SEARCH_RUNTIME_MODULE_ID = createPhiRuntimeModuleId(PHI_SHARED_PACKAGE_NAME, "search");
38
45
  /** How many Pages are resolved at once; each is a page lookup against the server. */
39
46
  const PHI_SEARCH_INDEX_RESOLVE_CONCURRENCY = 4;
40
47
  /** How long after the marker moved the run starts, so a burst of publishes is one run. */
@@ -181,6 +188,8 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
181
188
  preset: areaPreset?.preset ?? null,
182
189
  serverCapabilities: anonymous.serverCapabilities,
183
190
  });
191
+ if (!activeModuleIds.has(PHI_SEARCH_RUNTIME_MODULE_ID))
192
+ return;
184
193
  const candidates = collectPhiSitemapCandidates({
185
194
  moduleRoutes: [...routeTable.exactByPath].map(([path, descriptor]) => [path, descriptor]),
186
195
  publishedPages,
package/styles/shell.css CHANGED
@@ -795,3 +795,140 @@
795
795
  transition: none !important;
796
796
  }
797
797
  }
798
+
799
+ /*
800
+ * The Search Box (SEARCH.md): the input, a magnifier alone that opens into one (`icon-only`), or `auto` -- both drawn, and the
801
+ * Shell's phone decides which shows, as it does for the Header Navigation's menu button above.
802
+ */
803
+ .phi-search-box {
804
+ display: flex;
805
+ align-items: center;
806
+ justify-content: flex-end;
807
+ min-width: 0;
808
+ }
809
+
810
+ .phi-search-box__field,
811
+ .phi-search-box__form {
812
+ display: block;
813
+ flex: 1 1 auto;
814
+ min-width: 0;
815
+ }
816
+
817
+ .phi-search-box--input,
818
+ .phi-search-box--auto {
819
+ width: 100%;
820
+ }
821
+
822
+ .phi-search-box__magnifier {
823
+ display: inline-flex;
824
+ align-items: center;
825
+ }
826
+
827
+ .phi-search-box--auto > .phi-search-box__magnifier,
828
+ .phi-search-box--auto > .phi-search-box__expand {
829
+ display: none;
830
+ }
831
+
832
+ /*
833
+ * The magnifier keeps its own width. The Widget fills its slot's inline size as a field does; a magnifier
834
+ * that filled it would push the Widgets beside it away, so the innermost slot around it hugs it instead.
835
+ */
836
+ .phi-slot-child:has(.phi-search-box--icon-only):not(:has(.phi-slot-child)) {
837
+ width: auto !important;
838
+ flex: 0 0 auto !important;
839
+ min-width: var(--ant-control-height) !important;
840
+ }
841
+
842
+ /* Opened where it stands: the field grows out of the magnifier. */
843
+ .phi-search-box__expand {
844
+ display: block;
845
+ width: 15rem;
846
+ max-width: 100%;
847
+ animation: phi-search-box-expand 180ms ease-out;
848
+ }
849
+
850
+ @keyframes phi-search-box-expand {
851
+ from {
852
+ width: var(--ant-control-height);
853
+ opacity: 0.4;
854
+ }
855
+ }
856
+
857
+ /* Closing plays it backwards, back into the magnifier; the field is removed when it ends. */
858
+ .phi-search-box__expand--closing {
859
+ animation: phi-search-box-collapse 180ms ease-in forwards;
860
+ pointer-events: none;
861
+ }
862
+
863
+ @keyframes phi-search-box-collapse {
864
+ to {
865
+ width: var(--ant-control-height);
866
+ opacity: 0.4;
867
+ }
868
+ }
869
+
870
+ /*
871
+ * Opened on a phone: a row over the whole band, the field and its close mark, on the page's own ground
872
+ * so the band's widgets do not show through it, light or dark.
873
+ */
874
+ .phi-search-box__row {
875
+ position: absolute;
876
+ inset: 0;
877
+ z-index: 60;
878
+ display: flex;
879
+ align-items: center;
880
+ gap: var(--ant-padding-xs, 8px);
881
+ padding-inline: var(--ant-padding, 16px);
882
+ background: var(--ant-color-bg-container);
883
+ animation: phi-search-box-row 160ms ease-out;
884
+ }
885
+
886
+ @keyframes phi-search-box-row {
887
+ from {
888
+ opacity: 0;
889
+ }
890
+ }
891
+
892
+ .phi-search-box__row--closing {
893
+ animation: phi-search-box-row-out 160ms ease-in forwards;
894
+ pointer-events: none;
895
+ }
896
+
897
+ @keyframes phi-search-box-row-out {
898
+ to {
899
+ opacity: 0;
900
+ }
901
+ }
902
+
903
+ @container phi-render-viewport (width < 768px) {
904
+ .phi-search-box--auto {
905
+ width: auto;
906
+ }
907
+
908
+ .phi-search-box--auto > .phi-search-box__field {
909
+ display: none;
910
+ }
911
+
912
+ .phi-search-box--auto > .phi-search-box__magnifier {
913
+ display: inline-flex;
914
+ }
915
+
916
+ .phi-search-box--auto > .phi-search-box__expand {
917
+ display: block;
918
+ }
919
+
920
+ .phi-slot-child:has(.phi-search-box--auto):not(:has(.phi-slot-child)) {
921
+ width: auto !important;
922
+ flex: 0 0 auto !important;
923
+ min-width: var(--ant-control-height) !important;
924
+ }
925
+ }
926
+
927
+ @media (prefers-reduced-motion: reduce) {
928
+ .phi-search-box__expand,
929
+ .phi-search-box__expand--closing,
930
+ .phi-search-box__row,
931
+ .phi-search-box__row--closing {
932
+ animation: none;
933
+ }
934
+ }
@@ -22,7 +22,7 @@ import type { PhiThemePalette } from "./phi-theme-presets";
22
22
  * Who may still speak Ant Design directly is a separate question, and `scripts/validate-control-boundaries.mjs`
23
23
  * answers it: the alias resolver, the root adapter, the two font helpers and this file.
24
24
  */
25
- export declare const PHI_THEME_TOKEN_KEYS: readonly ["colorBgContainer", "colorBgElevated", "colorBgMask", "colorBgSpotlight", "colorBorder", "colorBorderSecondary", "colorSplit", "colorFillAlter", "colorFill", "colorBgLayout", "colorFillQuaternary", "colorFillSecondary", "colorFillTertiary", "colorText", "colorTextBase", "colorTextHeading", "colorTextSecondary", "colorTextTertiary", "colorTextQuaternary", "colorTextDescription", "colorTextDisabled", "colorTextLabel", "colorTextPlaceholder", "colorTextLightSolid", "colorPrimary", "colorPrimaryBg", "colorPrimaryBgHover", "colorPrimaryBorder", "colorPrimaryBorderHover", "colorPrimaryHover", "colorPrimaryActive", "colorPrimaryText", "colorPrimaryTextHover", "colorPrimaryTextActive", "colorInfo", "colorInfoBg", "colorInfoBgHover", "colorInfoBorder", "colorInfoBorderHover", "colorInfoText", "colorInfoTextHover", "colorSuccess", "colorSuccessBg", "colorSuccessBgHover", "colorSuccessBorder", "colorSuccessBorderHover", "colorSuccessText", "colorWarning", "colorWarningBg", "colorWarningBgHover", "colorWarningBorder", "colorWarningBorderHover", "colorWarningText", "colorError", "colorErrorBg", "colorErrorText", "colorErrorTextHover", "colorErrorTextActive", "colorLink", "colorLinkHover", "colorLinkActive", "padding", "paddingXXS", "paddingXS", "paddingSM", "paddingMD", "paddingLG", "paddingXL", "margin", "marginXXS", "marginXS", "marginSM", "marginMD", "marginLG", "marginXL", "marginXXL", "sizeXS", "sizeSM", "sizeMD", "sizeLG", "borderRadius", "borderRadiusXS", "borderRadiusSM", "borderRadiusLG", "borderRadiusOuter", "lineWidth", "lineType", "boxShadow", "boxShadowSecondary", "boxShadowTertiary", "controlHeight", "controlHeightXS", "controlHeightSM", "controlHeightLG", "fontFamily", "fontFamilyCode", "fontSize", "fontSizeSM", "fontSizeLG", "fontSizeXL", "fontSizeHeading1", "fontSizeHeading2", "fontSizeHeading3", "fontSizeHeading4", "fontSizeHeading5", "fontWeightStrong", "lineHeight", "lineHeightSM", "lineHeightLG", "lineHeightHeading1", "lineHeightHeading2", "lineHeightHeading3", "lineHeightHeading4", "lineHeightHeading5", "motionDurationMid", "motionDurationSlow", "motionEaseInOut", "motionEaseOut"];
25
+ export declare const PHI_THEME_TOKEN_KEYS: readonly ["colorBgContainer", "colorBgElevated", "colorBgMask", "colorBgSpotlight", "colorBorder", "colorBorderSecondary", "colorSplit", "colorFillAlter", "colorFill", "colorBgLayout", "colorFillQuaternary", "colorFillSecondary", "colorFillTertiary", "colorText", "colorTextBase", "colorTextHeading", "colorTextSecondary", "colorTextTertiary", "colorTextQuaternary", "colorTextDescription", "colorTextDisabled", "colorTextLabel", "colorTextPlaceholder", "colorTextLightSolid", "colorPrimary", "colorPrimaryBg", "colorPrimaryBgHover", "colorPrimaryBorder", "colorPrimaryBorderHover", "colorPrimaryHover", "colorPrimaryActive", "colorPrimaryText", "colorPrimaryTextHover", "colorPrimaryTextActive", "colorInfo", "colorInfoBg", "colorInfoBgHover", "colorInfoBorder", "colorInfoBorderHover", "colorInfoText", "colorInfoTextHover", "colorSuccess", "colorSuccessBg", "colorSuccessBgHover", "colorSuccessBorder", "colorSuccessBorderHover", "colorSuccessText", "colorWarning", "colorWarningBg", "colorWarningBgHover", "colorWarningBorder", "colorWarningBorderHover", "colorWarningText", "colorError", "colorErrorBg", "colorErrorText", "colorErrorTextHover", "colorErrorTextActive", "colorLink", "colorLinkHover", "colorLinkActive", "padding", "paddingXXS", "paddingXS", "paddingSM", "paddingMD", "paddingLG", "paddingXL", "margin", "marginXXS", "marginXS", "marginSM", "marginMD", "marginLG", "marginXL", "marginXXL", "sizeXS", "sizeSM", "sizeMD", "sizeLG", "borderRadius", "borderRadiusXS", "borderRadiusSM", "borderRadiusLG", "borderRadiusOuter", "lineWidth", "lineWidthBold", "lineType", "boxShadow", "boxShadowSecondary", "boxShadowTertiary", "controlHeight", "controlHeightXS", "controlHeightSM", "controlHeightLG", "fontFamily", "fontFamilyCode", "fontSize", "fontSizeSM", "fontSizeLG", "fontSizeXL", "fontSizeHeading1", "fontSizeHeading2", "fontSizeHeading3", "fontSizeHeading4", "fontSizeHeading5", "fontWeightStrong", "lineHeight", "lineHeightSM", "lineHeightLG", "lineHeightHeading1", "lineHeightHeading2", "lineHeightHeading3", "lineHeightHeading4", "lineHeightHeading5", "motionDurationMid", "motionDurationSlow", "motionEaseInOut", "motionEaseOut"];
26
26
  /**
27
27
  * The names this house adds to Ant Design's set.
28
28
  *