@phis/ui 0.4.15 → 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 (120) hide show
  1. package/components/cms/phi-cms-layout-renderer.js +2 -1
  2. package/components/controls/phi-table-control.js +15 -0
  3. package/components/forms/compound-form-controls.js +2 -1
  4. package/components/regions/clients/cms-region-container-client.d.ts +3 -1
  5. package/components/regions/clients/cms-region-container-client.js +2 -1
  6. package/components/regions/phi-cms-region-container.d.ts +3 -1
  7. package/components/regions/phi-cms-region-container.js +3 -2
  8. package/components/regions/phi-cms-region-shell.d.ts +16 -1
  9. package/components/regions/phi-cms-region-shell.js +39 -10
  10. package/components/regions/phi-cms-region-static.d.ts +3 -1
  11. package/components/regions/phi-cms-region-static.js +2 -1
  12. package/components/widgets/label-sets/observability-logs.d.ts +2 -0
  13. package/components/widgets/label-sets/observability-logs.js +4 -0
  14. package/components/widgets/label-sets/search.js +2 -0
  15. package/components/widgets/label-types/search.d.ts +2 -0
  16. package/components/widgets/label-types/search.js +1 -0
  17. package/constants/cms-widget-types.js +3 -2
  18. package/helpers/renderable-block-defaults.js +1 -0
  19. package/helpers/renderable-block-serialization.js +7 -1
  20. package/helpers/site-runtime.js +3 -0
  21. package/net/log.d.ts +1 -0
  22. package/net/log.js +19 -1
  23. package/net/phi-next-proxy.js +9 -1
  24. package/package.json +2 -2
  25. package/plugins/runtime/phi-slot-child-viewport-effects-observer.js +13 -0
  26. package/plugins/runtime-modules/app/presets.js +0 -23
  27. package/plugins/runtime-modules/area-contributions/app.d.ts +1 -1
  28. package/plugins/runtime-modules/area-contributions/app.js +2 -0
  29. package/plugins/runtime-modules/area-contributions/public.d.ts +1 -1
  30. package/plugins/runtime-modules/area-contributions/public.js +2 -0
  31. package/plugins/runtime-modules/area-module-defaults.js +21 -2
  32. package/plugins/runtime-modules/builder/page-meta-form.js +11 -0
  33. package/plugins/runtime-modules/client-authoring-providers/app.d.ts +1 -1
  34. package/plugins/runtime-modules/client-authoring-providers/app.js +6 -0
  35. package/plugins/runtime-modules/client-authoring-providers/public.d.ts +1 -1
  36. package/plugins/runtime-modules/client-authoring-providers/public.js +6 -0
  37. package/plugins/runtime-modules/client-manifests/common.js +2 -2
  38. package/plugins/runtime-modules/core/authoring-widgets.js +0 -4
  39. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +1 -1
  40. package/plugins/runtime-modules/core/widgets/markdown-toc/client.js +1 -1
  41. package/plugins/runtime-modules/core/widgets/table/client.js +7 -5
  42. package/plugins/runtime-modules/core/widgets/table/config.js +8 -1
  43. package/plugins/runtime-modules/core/widgets/tree/client.js +1 -1
  44. package/plugins/runtime-modules/core/widgets.js +0 -17
  45. package/plugins/runtime-modules/groups/trees/group-tables.d.ts +44 -0
  46. package/plugins/runtime-modules/groups/trees/group-tables.js +150 -0
  47. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +28 -136
  48. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +9 -106
  49. package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +17 -5
  50. package/plugins/runtime-modules/observability/data-providers.d.ts +9 -0
  51. package/plugins/runtime-modules/observability/data-providers.js +5 -0
  52. package/plugins/runtime-modules/observability/definition.d.ts +9 -0
  53. package/plugins/runtime-modules/observability/module.d.ts +9 -0
  54. package/plugins/runtime-modules/observability/services/table.js +4 -0
  55. package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +13 -0
  56. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +21 -0
  57. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
  58. package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
  59. package/plugins/runtime-modules/public/presets.d.ts +0 -16
  60. package/plugins/runtime-modules/public/presets.js +0 -22
  61. package/plugins/runtime-modules/public-base-page-references.d.ts +0 -1
  62. package/plugins/runtime-modules/public-base-page-references.js +0 -1
  63. package/plugins/runtime-modules/search/authoring-widgets.d.ts +2 -0
  64. package/plugins/runtime-modules/search/authoring-widgets.js +8 -0
  65. package/plugins/runtime-modules/search/authoring.d.ts +1 -0
  66. package/plugins/runtime-modules/search/authoring.js +8 -0
  67. package/plugins/runtime-modules/search/definition.d.ts +21 -0
  68. package/plugins/runtime-modules/search/definition.js +23 -0
  69. package/plugins/runtime-modules/search/ids.d.ts +6 -0
  70. package/plugins/runtime-modules/search/ids.js +7 -0
  71. package/plugins/runtime-modules/search/module.d.ts +10 -0
  72. package/plugins/runtime-modules/search/module.js +4 -0
  73. package/plugins/runtime-modules/search/page-references.d.ts +8 -0
  74. package/plugins/runtime-modules/search/page-references.js +17 -0
  75. package/plugins/runtime-modules/{search-page-tree.d.ts → search/page-tree.d.ts} +1 -1
  76. package/plugins/runtime-modules/{search-page-tree.js → search/page-tree.js} +9 -7
  77. package/plugins/runtime-modules/search/presets.d.ts +12 -0
  78. package/plugins/runtime-modules/search/presets.js +33 -0
  79. package/plugins/runtime-modules/search/server.d.ts +1 -0
  80. package/plugins/runtime-modules/search/server.js +16 -0
  81. package/plugins/runtime-modules/search/widgets/search-box/authoring.d.ts +8 -0
  82. package/plugins/runtime-modules/search/widgets/search-box/authoring.js +21 -0
  83. package/plugins/runtime-modules/search/widgets/search-box/client.d.ts +39 -0
  84. package/plugins/runtime-modules/search/widgets/search-box/client.js +114 -0
  85. package/plugins/runtime-modules/search/widgets/search-box/config.d.ts +96 -0
  86. package/plugins/runtime-modules/search/widgets/search-box/config.js +67 -0
  87. package/plugins/runtime-modules/{core → search}/widgets/search-box/plugin.js +1 -4
  88. package/plugins/runtime-modules/search/widgets/search-box/server.d.ts +15 -0
  89. package/plugins/runtime-modules/{core → search}/widgets/search-box/server.js +13 -14
  90. package/plugins/runtime-modules/{core → search}/widgets/search-results/config.d.ts +0 -1
  91. package/plugins/runtime-modules/{core → search}/widgets/search-results/config.js +0 -1
  92. package/plugins/runtime-modules/{core → search}/widgets/search-results/plugin.js +1 -3
  93. package/plugins/runtime-modules/{core → search}/widgets/search-results/server.d.ts +1 -2
  94. package/plugins/runtime-modules/{core → search}/widgets/search-results/server.js +2 -2
  95. package/plugins/runtime-modules/search/widgets.d.ts +2 -0
  96. package/plugins/runtime-modules/search/widgets.js +20 -0
  97. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +15 -1
  98. package/server-helpers/search-index.js +9 -0
  99. package/styles/root.css +2 -0
  100. package/styles/shell.css +178 -18
  101. package/theme/phi-theme-tokens.d.ts +1 -1
  102. package/theme/phi-theme-tokens.js +2 -0
  103. package/types/renderable-block.d.ts +5 -0
  104. package/types/table-widget.d.ts +10 -1
  105. package/types/table-widget.js +1 -0
  106. package/plugins/runtime-modules/core/widgets/search-box/authoring.d.ts +0 -6
  107. package/plugins/runtime-modules/core/widgets/search-box/authoring.js +0 -10
  108. package/plugins/runtime-modules/core/widgets/search-box/client.d.ts +0 -21
  109. package/plugins/runtime-modules/core/widgets/search-box/client.js +0 -17
  110. package/plugins/runtime-modules/core/widgets/search-box/config.d.ts +0 -63
  111. package/plugins/runtime-modules/core/widgets/search-box/config.js +0 -48
  112. package/plugins/runtime-modules/core/widgets/search-box/server.d.ts +0 -21
  113. package/plugins/runtime-modules/search-page-references.d.ts +0 -20
  114. package/plugins/runtime-modules/search-page-references.js +0 -35
  115. /package/plugins/runtime-modules/{core → search}/widgets/search-box/plugin.d.ts +0 -0
  116. /package/plugins/runtime-modules/{core → search}/widgets/search-results/authoring.d.ts +0 -0
  117. /package/plugins/runtime-modules/{core → search}/widgets/search-results/authoring.js +0 -0
  118. /package/plugins/runtime-modules/{core → search}/widgets/search-results/client.d.ts +0 -0
  119. /package/plugins/runtime-modules/{core → search}/widgets/search-results/client.js +0 -0
  120. /package/plugins/runtime-modules/{core → search}/widgets/search-results/plugin.d.ts +0 -0
@@ -101,28 +101,6 @@ export const PHI_PUBLIC_RUNTIME_MODULE_ROUTES = [
101
101
  loadTree: ({ page }) => import("./trees/phi-default-pub-terms-page-tree")
102
102
  .then((module) => module.buildPhiDefaultPubTermsPageTree({ page })),
103
103
  },
104
- /*
105
- * Where a search goes (SEARCH.md): the box on any Page sends its query here, and the results Widget
106
- * reads it from the address. Core's, because the box is Core's and a box without a Page to answer it is
107
- * a field that leads nowhere. No menu entry -- nobody browses to a results Page -- and `NoIndex`, so
108
- * neither a crawler nor the Site's own index lists a Page whose words are whatever was last searched.
109
- */
110
- {
111
- ownerModuleId: PHI_PUBLIC_RUNTIME_MODULE_ID,
112
- presetKey: PHI_PUBLIC_BASE_PAGE_PRESET_KEYS.search,
113
- presetVersion: 1,
114
- area: "public",
115
- title: "Search",
116
- path: "/search",
117
- navigation: [],
118
- defaultPageFlags: PhiCmsFlags.NoIndex,
119
- loadTree: ({ page }) => import("../search-page-tree")
120
- .then((module) => module.buildPhiDefaultSearchPageTree({
121
- page,
122
- ownerModuleId: PHI_PUBLIC_RUNTIME_MODULE_ID,
123
- presetKey: PHI_PUBLIC_BASE_PAGE_PRESET_KEYS.search,
124
- })),
125
- },
126
104
  ];
127
105
  /**
128
106
  * The Public form pages, in their own list because they appear only where Forms are allowed. The
@@ -17,7 +17,6 @@ export declare const PHI_PUBLIC_BASE_PAGE_PRESET_KEYS: {
17
17
  readonly terms: "public-terms-page";
18
18
  readonly contact: "public-contact-page";
19
19
  readonly unsubscribe: "public-unsubscribe-page";
20
- readonly search: "public-search-page";
21
20
  };
22
21
  /**
23
22
  * Ready-made references to the Pages every Site has, for a Module that links to one.
@@ -19,7 +19,6 @@ export const PHI_PUBLIC_BASE_PAGE_PRESET_KEYS = {
19
19
  terms: "public-terms-page",
20
20
  contact: "public-contact-page",
21
21
  unsubscribe: "public-unsubscribe-page",
22
- search: "public-search-page",
23
22
  };
24
23
  // Named by id, as data, for the same reason: `public/ids` would bind the door to the Module folder.
25
24
  const PHI_PUBLIC_RUNTIME_MODULE_ID = createPhiRuntimeModuleId(PHI_SHARED_PACKAGE_NAME, "public");
@@ -0,0 +1,2 @@
1
+ declare const _default: import("react").ComponentType<import("../client-authoring-widget-module").PhiAuthoringWidgetModuleProps>;
2
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use client";
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 { createPhiAuthoringWidgetModule, definePhiAuthoringWidgetModuleLoader, } from "../client-authoring-widget-module";
5
+ export default createPhiAuthoringWidgetModule([
6
+ definePhiAuthoringWidgetModuleLoader(PHI_SEARCH_BOX_WIDGET_DEFINITION, () => import("./widgets/search-box/authoring").then((module) => module.PHI_SEARCH_BOX_WIDGET_BUILDER_PLUGIN)),
7
+ definePhiAuthoringWidgetModuleLoader(PHI_SEARCH_RESULTS_WIDGET_DEFINITION, () => import("./widgets/search-results/authoring").then((module) => module.PHI_SEARCH_RESULTS_WIDGET_BUILDER_PLUGIN)),
8
+ ]);
@@ -0,0 +1 @@
1
+ export declare const PhiSearchRuntimeModuleAuthoringClient: import("react").ComponentType<import("../contracts").PhiRuntimeModuleAuthoringClientProps>;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import WidgetModule from "./authoring-widgets";
3
+ import { createPhiRuntimeModuleAuthoringClient } from "../client-authoring-module";
4
+ import { PHI_SEARCH_RUNTIME_MODULE_ID } from "./ids";
5
+ export const PhiSearchRuntimeModuleAuthoringClient = createPhiRuntimeModuleAuthoringClient({
6
+ moduleId: PHI_SEARCH_RUNTIME_MODULE_ID,
7
+ WidgetModule,
8
+ });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The Site's own search (SEARCH.md): the box, the results, and the Page the box leads to, in each Area
3
+ * whose Pages are indexed.
4
+ *
5
+ * A Module rather than Core, because the box is only worth placing where something answers it, and what
6
+ * answers it is the Module's own results Page -- never a Page somebody picked that may hold no results.
7
+ * Switched off, the box goes with the Page and the indexer leaves the Area alone; a package that brings a
8
+ * search of its own brings its own box, Page and results the same way, over the same Core endpoints.
9
+ *
10
+ * Public and App: the Areas whose Pages the index holds. The operator's Areas are not searched.
11
+ */
12
+ export declare const PHI_SEARCH_RUNTIME_MODULE_DEFINITION: {
13
+ moduleId: "@phis/ui/modules/search";
14
+ kind: "module";
15
+ eligibleAreas: readonly ["public", "app"];
16
+ serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
17
+ title: string;
18
+ description: string;
19
+ category: "content";
20
+ icon: string;
21
+ };
@@ -0,0 +1,23 @@
1
+ import { PHI_CORE_SERVER_BINDING } from "../../../types/server-capabilities";
2
+ import { PHI_SEARCH_RUNTIME_MODULE_ID } from "./ids";
3
+ /**
4
+ * The Site's own search (SEARCH.md): the box, the results, and the Page the box leads to, in each Area
5
+ * whose Pages are indexed.
6
+ *
7
+ * A Module rather than Core, because the box is only worth placing where something answers it, and what
8
+ * answers it is the Module's own results Page -- never a Page somebody picked that may hold no results.
9
+ * Switched off, the box goes with the Page and the indexer leaves the Area alone; a package that brings a
10
+ * search of its own brings its own box, Page and results the same way, over the same Core endpoints.
11
+ *
12
+ * Public and App: the Areas whose Pages the index holds. The operator's Areas are not searched.
13
+ */
14
+ export const PHI_SEARCH_RUNTIME_MODULE_DEFINITION = {
15
+ moduleId: PHI_SEARCH_RUNTIME_MODULE_ID,
16
+ kind: "module",
17
+ eligibleAreas: ["public", "app"],
18
+ serverBinding: PHI_CORE_SERVER_BINDING,
19
+ title: "Search",
20
+ description: "A search over the Site's own Pages: a box, a results Page, and the index behind them.",
21
+ category: "content",
22
+ icon: "antd:search",
23
+ };
@@ -0,0 +1,6 @@
1
+ export declare const PHI_SEARCH_RUNTIME_MODULE_ID: "@phis/ui/modules/search";
2
+ /** The results Page each Area the Module serves brings, under the Module's own name (SEARCH.md). */
3
+ export declare const PHI_SEARCH_PAGE_PRESET_KEYS: {
4
+ readonly public: "public-search-page";
5
+ readonly app: "app-search-page";
6
+ };
@@ -0,0 +1,7 @@
1
+ import { PHI_SHARED_PACKAGE_NAME } from "../../../types/signals";
2
+ export const PHI_SEARCH_RUNTIME_MODULE_ID = `${PHI_SHARED_PACKAGE_NAME}/modules/search`;
3
+ /** The results Page each Area the Module serves brings, under the Module's own name (SEARCH.md). */
4
+ export const PHI_SEARCH_PAGE_PRESET_KEYS = {
5
+ public: "public-search-page",
6
+ app: "app-search-page",
7
+ };
@@ -0,0 +1,10 @@
1
+ export declare const PHI_SEARCH_RUNTIME_MODULE: {
2
+ moduleId: "@phis/ui/modules/search";
3
+ kind: "module";
4
+ eligibleAreas: readonly ["public", "app"];
5
+ serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
6
+ title: string;
7
+ description: string;
8
+ category: "content";
9
+ icon: string;
10
+ };
@@ -0,0 +1,4 @@
1
+ import { PHI_SEARCH_RUNTIME_MODULE_DEFINITION } from "./definition";
2
+ export const PHI_SEARCH_RUNTIME_MODULE = {
3
+ ...PHI_SEARCH_RUNTIME_MODULE_DEFINITION,
4
+ };
@@ -0,0 +1,8 @@
1
+ import type { PhiCmsAreaKey } from "../../../constants/cms-areas";
2
+ import { type PhiLinkTarget } from "../../../types/references";
3
+ /**
4
+ * Where a Search Box sends its query when its author chose no Page: this Module's results Page of the
5
+ * Area it stands in -- the App's in App, the Public one in Public (SEARCH.md). The Module serves no other
6
+ * Area; a box rendered for one all the same leads to the Public Page, resolved in Public.
7
+ */
8
+ export declare function resolvePhiSearchPageLinkTarget(area: PhiCmsAreaKey): PhiLinkTarget;
@@ -0,0 +1,17 @@
1
+ import { createPhiPageReference } from "../../../types/references";
2
+ import { PHI_SEARCH_PAGE_PRESET_KEYS, PHI_SEARCH_RUNTIME_MODULE_ID } from "./ids";
3
+ /**
4
+ * Where a Search Box sends its query when its author chose no Page: this Module's results Page of the
5
+ * Area it stands in -- the App's in App, the Public one in Public (SEARCH.md). The Module serves no other
6
+ * Area; a box rendered for one all the same leads to the Public Page, resolved in Public.
7
+ */
8
+ export function resolvePhiSearchPageLinkTarget(area) {
9
+ const reference = createPhiPageReference({
10
+ kind: "module",
11
+ ownerModuleId: PHI_SEARCH_RUNTIME_MODULE_ID,
12
+ presetKey: area === "app" ? PHI_SEARCH_PAGE_PRESET_KEYS.app : PHI_SEARCH_PAGE_PRESET_KEYS.public,
13
+ });
14
+ if (area === "app" || area === "public")
15
+ return { kind: "page", reference };
16
+ return { kind: "page", reference, area: "public" };
17
+ }
@@ -1,4 +1,4 @@
1
- import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../../types/cms";
1
+ import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../../../types/cms";
2
2
  /**
3
3
  * The results Page every indexed Area brings (SEARCH.md): the box, so a reader can search again without
4
4
  * going back, and under it the results, which read the query from the page's address.
@@ -1,9 +1,10 @@
1
- import { buildPhiBasePageContentScaffold, PHI_BASE_PAGE_LAYOUT_NODE_ID, } from "../../components/regions/presets/phi-base-page-layout";
2
- import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../constants/cms-layout-types";
3
- import { PhiCmsPageType } from "../../constants/phi-cms";
4
- import { createPhiCmsPresetNodes } from "../../helpers/cms-preset-nodes";
5
- import { PHI_SPACE } from "../../theme/antd-css-var-contract";
6
- import { createPhiPresetCmsInstanceIdMap } from "../../types/cms-instance-id";
1
+ import { buildPhiBasePageContentScaffold, PHI_BASE_PAGE_LAYOUT_NODE_ID, } from "../../../components/regions/presets/phi-base-page-layout";
2
+ import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../constants/cms-layout-types";
3
+ import { PhiCmsPageType } from "../../../constants/phi-cms";
4
+ import { createPhiCmsPresetNodes } from "../../../helpers/cms-preset-nodes";
5
+ import { PHI_SPACE } from "../../../theme/antd-css-var-contract";
6
+ import { PHI_LAYOUT } from "../../../theme/phi-tokens";
7
+ import { createPhiPresetCmsInstanceIdMap } from "../../../types/cms-instance-id";
7
8
  /** Synthetic Region id; negative, and unique among the base Presets. */
8
9
  const SYNTHETIC_SEARCH_REGION_IDS = {
9
10
  regionContent: -260,
@@ -46,7 +47,8 @@ export async function buildPhiDefaultSearchPageTree({ page, ownerModuleId, prese
46
47
  slotIndex: PHI_CMS_DEFAULT_SLOT_INDEX,
47
48
  sortOrder: 0,
48
49
  label: "search page box",
49
- config: { controlSize: "large" },
50
+ // The field at the house's size, no wider than a form: a query is a few words, not a line of prose.
51
+ config: { controlSize: "medium", maxSize: { width: PHI_LAYOUT.contentMax } },
50
52
  }),
51
53
  nodes.widget({
52
54
  typeKey: "search-results",
@@ -0,0 +1,12 @@
1
+ import type { PhiCmsDescriptorBuildContext } from "../../../types/cms-module-descriptors";
2
+ export declare const PHI_SEARCH_RUNTIME_MODULE_ROUTES: {
3
+ ownerModuleId: "@phis/ui/modules/search";
4
+ presetKey: "public-search-page" | "app-search-page";
5
+ presetVersion: number;
6
+ area: "public" | "app";
7
+ title: string;
8
+ path: string;
9
+ navigation: never[];
10
+ defaultPageFlags: number;
11
+ loadTree: ({ page }: PhiCmsDescriptorBuildContext) => Promise<import("../../../types").PhiResolvedCmsPageTree>;
12
+ }[];
@@ -0,0 +1,33 @@
1
+ import { PhiCmsFlags } from "../../../constants/phi-cms";
2
+ import { PHI_SEARCH_PAGE_PRESET_KEYS, PHI_SEARCH_RUNTIME_MODULE_ID } from "./ids";
3
+ /**
4
+ * The results Pages (SEARCH.md), one per Area the Module serves, the same tree in both: the box and the
5
+ * results. Which Areas are searched is decided by where the results Widget stands -- on the App's Page
6
+ * the App and Public, on the Public one Public -- not written into the tree.
7
+ *
8
+ * No menu entry -- nobody browses to a results Page -- and `NoIndex`, so neither a crawler nor the Site's
9
+ * own index lists a Page whose words are whatever was last searched.
10
+ */
11
+ function defineSearchPageRoute(area) {
12
+ const presetKey = PHI_SEARCH_PAGE_PRESET_KEYS[area];
13
+ return {
14
+ ownerModuleId: PHI_SEARCH_RUNTIME_MODULE_ID,
15
+ presetKey,
16
+ presetVersion: 1,
17
+ area,
18
+ title: "Search",
19
+ path: "/search",
20
+ navigation: [],
21
+ defaultPageFlags: PhiCmsFlags.NoIndex,
22
+ loadTree: ({ page }) => import("./page-tree")
23
+ .then((module) => module.buildPhiDefaultSearchPageTree({
24
+ page,
25
+ ownerModuleId: PHI_SEARCH_RUNTIME_MODULE_ID,
26
+ presetKey,
27
+ })),
28
+ };
29
+ }
30
+ export const PHI_SEARCH_RUNTIME_MODULE_ROUTES = [
31
+ defineSearchPageRoute("public"),
32
+ defineSearchPageRoute("app"),
33
+ ];
@@ -0,0 +1 @@
1
+ export declare function createPhiSearchRuntimeModuleServerAreaContribution(): import("../area-contributions").PhiRuntimeModuleServerAreaContribution;
@@ -0,0 +1,16 @@
1
+ import { definePhiRuntimeModuleServerAreaContribution } from "../area-contributions";
2
+ import { PHI_SEARCH_RUNTIME_MODULE_DEFINITION } from "./definition";
3
+ import { PHI_SEARCH_RUNTIME_MODULE_ROUTES } from "./presets";
4
+ import { PHI_SEARCH_RUNTIME_MODULE_WIDGETS } from "./widgets";
5
+ export function createPhiSearchRuntimeModuleServerAreaContribution() {
6
+ return definePhiRuntimeModuleServerAreaContribution({
7
+ moduleId: PHI_SEARCH_RUNTIME_MODULE_DEFINITION.moduleId,
8
+ catalogEntry: {
9
+ definition: PHI_SEARCH_RUNTIME_MODULE_DEFINITION,
10
+ widgets: PHI_SEARCH_RUNTIME_MODULE_WIDGETS,
11
+ layouts: [],
12
+ routes: PHI_SEARCH_RUNTIME_MODULE_ROUTES,
13
+ load: () => import("./module").then((module) => module.PHI_SEARCH_RUNTIME_MODULE),
14
+ },
15
+ });
16
+ }
@@ -0,0 +1,8 @@
1
+ import type { PhiCmsBuilderWidgetPlugin } from "../../../../../types";
2
+ import { type PhiSearchBoxWidgetConfig } from "./config";
3
+ /**
4
+ * The box as a visitor sees it -- the field, or the magnifier -- in the size and words its author chose,
5
+ * but inert: a submit on the canvas would leave the Builder for the results Page, so the field takes no
6
+ * input and the magnifier does not open.
7
+ */
8
+ export declare const PHI_SEARCH_BOX_WIDGET_BUILDER_PLUGIN: PhiCmsBuilderWidgetPlugin<PhiSearchBoxWidgetConfig>;
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { PHI_SEARCH_WIDGET_DEFAULT_LABELS } from "../../../../../components/widgets/label-types/search";
4
+ import { PhiSearchBoxWidgetClient } from "./client";
5
+ import { PHI_SEARCH_BOX_WIDGET_DEFINITION } from "./config";
6
+ /**
7
+ * The box as a visitor sees it -- the field, or the magnifier -- in the size and words its author chose,
8
+ * but inert: a submit on the canvas would leave the Builder for the results Page, so the field takes no
9
+ * input and the magnifier does not open.
10
+ */
11
+ export const PHI_SEARCH_BOX_WIDGET_BUILDER_PLUGIN = {
12
+ ...PHI_SEARCH_BOX_WIDGET_DEFINITION,
13
+ renderEditor: ({ config }) => (_jsx(PhiSearchBoxWidgetClient, { labels: PHI_SEARCH_WIDGET_DEFAULT_LABELS, config: {
14
+ // The author's words as stored; the canvas does not translate them.
15
+ placeholder: config?.placeholder ?? "",
16
+ initialQuery: "",
17
+ interactive: false,
18
+ ...(config?.controlSize ? { size: config.controlSize } : {}),
19
+ ...(config?.variant ? { variant: config.variant } : {}),
20
+ } })),
21
+ };
@@ -0,0 +1,39 @@
1
+ import type { PhiSearchWidgetLabels } from "../../../../../components/widgets/label-types/search";
2
+ import type { PhiClientBlockBaseProps } from "../../../../../types";
3
+ import type { PhiControlSize } from "../../../../../types/control";
4
+ import type { PhiSearchBoxVariant } from "./config";
5
+ export type PhiSearchBoxWidgetClientConfig = {
6
+ /** The results Page, as the form's address. Absent on the Builder's canvas, where nothing submits. */
7
+ action?: string;
8
+ placeholder: string;
9
+ size?: PhiControlSize;
10
+ /** The query the page is answering, so the box shows what was searched for. */
11
+ initialQuery: string;
12
+ /** Absent is `input`. */
13
+ variant?: PhiSearchBoxVariant;
14
+ /**
15
+ * False on the Builder's canvas: the box is drawn as a visitor sees it, but a submit there would leave
16
+ * the Builder for the results Page, so the field takes no input and the magnifier does not open.
17
+ */
18
+ interactive?: boolean;
19
+ };
20
+ export type PhiSearchBoxWidgetClientProps = PhiClientBlockBaseProps<PhiSearchWidgetLabels, PhiSearchBoxWidgetClientConfig>;
21
+ /**
22
+ * A `GET` form around one search field (SEARCH.md), as the input or as a magnifier alone that opens into one (`icon-only`).
23
+ *
24
+ * The browser submits it: Enter, or the keyboard's search key, sends `?q=` to the results Page without
25
+ * a script, and a static Public page needs none. The field is the house's text Control with the form's
26
+ * field name, so it clears, labels and sizes like every other field, and the form is a landmark a screen
27
+ * reader lists.
28
+ *
29
+ * The magnifier is a link to the results Page until the page has hydrated, so it leads somewhere without
30
+ * a script too. After that it opens the field where it stands -- the field grows out of it -- or, on a
31
+ * phone, as a row over the whole band it stands in: a header on a phone has no room for a field beside
32
+ * the brand and the menu button, and one that wrapped would push the page down. Escape, the close mark,
33
+ * or leaving the field empty closes it again, the field folding back into the magnifier as it came.
34
+ *
35
+ * `auto` draws both the field and the magnifier and `styles/shell.css` shows one, the way the Header
36
+ * Navigation draws its row and its menu button: whether this is a phone is the Shell's width, known to
37
+ * CSS on the first paint.
38
+ */
39
+ export declare function PhiSearchBoxWidgetClient({ labels, config }: PhiSearchBoxWidgetClientProps): import("react").JSX.Element;
@@ -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 {};