@phis/ui 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/controls/phi-text-control.d.ts +6 -1
- package/components/controls/phi-text-control.js +2 -1
- package/components/regions/presets/phi-area-shell-preset-nodes.d.ts +5 -0
- package/components/regions/presets/phi-area-shell-preset-nodes.js +17 -2
- package/components/widgets/label-sets/search-results.d.ts +4 -0
- package/components/widgets/label-sets/search-results.js +35 -0
- package/components/widgets/label-types/search-results.d.ts +15 -0
- package/components/widgets/label-types/search-results.js +10 -0
- package/constants/cms-widget-types.d.ts +2 -0
- package/constants/cms-widget-types.js +4 -0
- package/gateway/site-area.d.ts +10 -7
- package/gateway/site-area.js +13 -11
- package/gateway/site-config.js +7 -1
- package/gateway/site-read-marker-listeners.d.ts +24 -0
- package/gateway/site-read-marker-listeners.js +22 -0
- package/gateway/site-search.d.ts +37 -0
- package/gateway/site-search.js +116 -0
- package/next/areas/app.js +5 -1
- package/next/areas/public.js +5 -1
- package/next/seo-routes.js +2 -2
- package/package.json +2 -2
- package/plugins/runtime-modules/app/presets.js +23 -0
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +2 -1
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +3 -2
- package/plugins/runtime-modules/client-manifests/common.js +8 -0
- package/plugins/runtime-modules/core/authoring-widgets.js +4 -0
- package/plugins/runtime-modules/core/widgets/card/plugin.js +18 -0
- package/plugins/runtime-modules/core/widgets/description/plugin.js +10 -0
- package/plugins/runtime-modules/core/widgets/html/plugin.js +16 -1
- package/plugins/runtime-modules/core/widgets/html/server.d.ts +6 -0
- package/plugins/runtime-modules/core/widgets/html/server.js +12 -4
- package/plugins/runtime-modules/core/widgets/markdown/plugin.js +16 -0
- package/plugins/runtime-modules/core/widgets/search-box/authoring.d.ts +6 -0
- package/plugins/runtime-modules/core/widgets/search-box/authoring.js +10 -0
- package/plugins/runtime-modules/core/widgets/search-box/client.d.ts +21 -0
- package/plugins/runtime-modules/core/widgets/search-box/client.js +17 -0
- package/plugins/runtime-modules/core/widgets/search-box/config.d.ts +63 -0
- package/plugins/runtime-modules/core/widgets/search-box/config.js +48 -0
- package/plugins/runtime-modules/core/widgets/search-box/plugin.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/search-box/plugin.js +11 -0
- package/plugins/runtime-modules/core/widgets/search-box/server.d.ts +21 -0
- package/plugins/runtime-modules/core/widgets/search-box/server.js +48 -0
- package/plugins/runtime-modules/core/widgets/search-results/authoring.d.ts +6 -0
- package/plugins/runtime-modules/core/widgets/search-results/authoring.js +10 -0
- package/plugins/runtime-modules/core/widgets/search-results/client.d.ts +34 -0
- package/plugins/runtime-modules/core/widgets/search-results/client.js +32 -0
- package/plugins/runtime-modules/core/widgets/search-results/config.d.ts +41 -0
- package/plugins/runtime-modules/core/widgets/search-results/config.js +39 -0
- package/plugins/runtime-modules/core/widgets/search-results/plugin.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/search-results/plugin.js +10 -0
- package/plugins/runtime-modules/core/widgets/search-results/server.d.ts +20 -0
- package/plugins/runtime-modules/core/widgets/search-results/server.js +73 -0
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +11 -0
- package/plugins/runtime-modules/core/widgets.js +17 -0
- package/plugins/runtime-modules/public/presets.d.ts +16 -0
- package/plugins/runtime-modules/public/presets.js +22 -0
- package/plugins/runtime-modules/public-base-page-references.d.ts +1 -0
- package/plugins/runtime-modules/public-base-page-references.js +1 -0
- package/plugins/runtime-modules/search-page-references.d.ts +20 -0
- package/plugins/runtime-modules/search-page-references.js +35 -0
- package/plugins/runtime-modules/search-page-tree.d.ts +14 -0
- package/plugins/runtime-modules/search-page-tree.js +63 -0
- package/server-helpers/search-index.d.ts +28 -0
- package/server-helpers/search-index.js +299 -0
- package/server-helpers/search-text.d.ts +40 -0
- package/server-helpers/search-text.js +152 -0
- package/server-helpers.d.ts +1 -0
- package/server-helpers.js +1 -0
- package/types/cms-plugins.d.ts +20 -2
|
@@ -15,7 +15,7 @@ const SYNTHETIC_APP_WIDGET_IDS = createPhiPresetCmsInstanceIdMap({
|
|
|
15
15
|
domain: "area",
|
|
16
16
|
ownerModuleId: PHI_APP_RUNTIME_MODULE_ID,
|
|
17
17
|
presetKey: "app-area-preset",
|
|
18
|
-
}, ["widgetSiderLeftNav"]);
|
|
18
|
+
}, ["widgetSiderLeftNav", "widgetSiderLeftSearch"]);
|
|
19
19
|
/**
|
|
20
20
|
* The App's own left sider, laid over the Site shell rather than replacing it.
|
|
21
21
|
*
|
|
@@ -26,7 +26,8 @@ const SYNTHETIC_APP_WIDGET_IDS = createPhiPresetCmsInstanceIdMap({
|
|
|
26
26
|
*
|
|
27
27
|
* The sider is where the Area's navigation belongs, and the reason is in SETTINGS.md section 3: a
|
|
28
28
|
* shell Region outlives a move between Pages, while a Page-owned one is built again for each of them.
|
|
29
|
-
* Navigation placed in the latter rebuilds itself under the hand that just used it.
|
|
29
|
+
* Navigation placed in the latter rebuilds itself under the hand that just used it. The search box
|
|
30
|
+
* stands above it for the same reason (SEARCH.md): a member searches from wherever they are.
|
|
30
31
|
*/
|
|
31
32
|
export async function buildPhiDefaultAppAreaPresetTree({ page, runtime, }) {
|
|
32
33
|
const nodes = createPhiCmsPresetNodes(page);
|
|
@@ -255,6 +255,14 @@ export const PHI_COMMON_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST = createPhiRuntime
|
|
|
255
255
|
PhiCmsWidgetType.EntryList,
|
|
256
256
|
definePhiRuntimeModuleRenderClient(dynamic(() => import("../core/widgets/entry-list/client").then((module) => module.PhiEntryListWidgetClient))),
|
|
257
257
|
],
|
|
258
|
+
[
|
|
259
|
+
PhiCmsWidgetType.SearchBox,
|
|
260
|
+
definePhiRuntimeModuleRenderClient(dynamic(() => import("../core/widgets/search-box/client").then((module) => module.PhiSearchBoxWidgetClient))),
|
|
261
|
+
],
|
|
262
|
+
[
|
|
263
|
+
PhiCmsWidgetType.SearchResults,
|
|
264
|
+
definePhiRuntimeModuleRenderClient(dynamic(() => import("../core/widgets/search-results/client").then((module) => module.PhiSearchResultsWidgetClient))),
|
|
265
|
+
],
|
|
258
266
|
[
|
|
259
267
|
PhiCmsWidgetType.EntryDetail,
|
|
260
268
|
definePhiRuntimeModuleRenderClient(dynamic(() => import("../core/widgets/entry-detail/client").then((module) => module.PhiEntryDetailWidgetClient))),
|
|
@@ -45,6 +45,8 @@ import { PHI_GALLERY_WIDGET_DEFINITION } from "./widgets/gallery/config";
|
|
|
45
45
|
import { PHI_STEPS_WIDGET_DEFINITION } from "./widgets/steps/config";
|
|
46
46
|
import { PHI_TIMELINE_WIDGET_DEFINITION } from "./widgets/timeline/config";
|
|
47
47
|
import { PHI_ENTRY_LIST_WIDGET_DEFINITION } from "./widgets/entry-list/config";
|
|
48
|
+
import { PHI_SEARCH_BOX_WIDGET_DEFINITION } from "./widgets/search-box/config";
|
|
49
|
+
import { PHI_SEARCH_RESULTS_WIDGET_DEFINITION } from "./widgets/search-results/config";
|
|
48
50
|
import { PHI_ENTRY_DETAIL_WIDGET_DEFINITION } from "./widgets/entry-detail/config";
|
|
49
51
|
import { PHI_ENTRY_HEADER_WIDGET_DEFINITION } from "./widgets/entry-header/config";
|
|
50
52
|
import { PHI_THREAD_CONVERSATION_WIDGET_DEFINITION } from "./widgets/thread-conversation/config";
|
|
@@ -103,6 +105,8 @@ export default createPhiAuthoringWidgetModule([
|
|
|
103
105
|
definePhiAuthoringWidgetModuleLoader(PHI_GALLERY_WIDGET_DEFINITION, () => import("./widgets/gallery/authoring").then((module) => module.PHI_GALLERY_WIDGET_BUILDER_PLUGIN)),
|
|
104
106
|
definePhiAuthoringWidgetModuleLoader(PHI_STEPS_WIDGET_DEFINITION, () => import("./widgets/steps/authoring").then((module) => module.PHI_STEPS_WIDGET_BUILDER_PLUGIN)),
|
|
105
107
|
definePhiAuthoringWidgetModuleLoader(PHI_TIMELINE_WIDGET_DEFINITION, () => import("./widgets/timeline/authoring").then((module) => module.PHI_TIMELINE_WIDGET_BUILDER_PLUGIN)),
|
|
108
|
+
definePhiAuthoringWidgetModuleLoader(PHI_SEARCH_BOX_WIDGET_DEFINITION, () => import("./widgets/search-box/authoring").then((module) => module.PHI_SEARCH_BOX_WIDGET_BUILDER_PLUGIN)),
|
|
109
|
+
definePhiAuthoringWidgetModuleLoader(PHI_SEARCH_RESULTS_WIDGET_DEFINITION, () => import("./widgets/search-results/authoring").then((module) => module.PHI_SEARCH_RESULTS_WIDGET_BUILDER_PLUGIN)),
|
|
106
110
|
definePhiAuthoringWidgetModuleLoader(PHI_ENTRY_LIST_WIDGET_DEFINITION, () => import("./widgets/entry-list/authoring").then((module) => module.PHI_ENTRY_LIST_WIDGET_BUILDER_PLUGIN)),
|
|
107
111
|
definePhiAuthoringWidgetModuleLoader(PHI_ENTRY_DETAIL_WIDGET_DEFINITION, () => import("./widgets/entry-detail/authoring").then((module) => module.PHI_ENTRY_DETAIL_WIDGET_BUILDER_PLUGIN)),
|
|
108
112
|
definePhiAuthoringWidgetModuleLoader(PHI_ENTRY_HEADER_WIDGET_DEFINITION, () => import("./widgets/entry-header/authoring").then((module) => module.PHI_ENTRY_HEADER_WIDGET_BUILDER_PLUGIN)),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
3
|
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
|
+
import { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
|
|
4
5
|
import { PhiCardWidget } from "./server";
|
|
5
6
|
import { PHI_CARD_WIDGET_DEFINITION, PHI_CARD_WIDGET_PLUGIN_TYPE } from "./config";
|
|
6
7
|
function renderPhiCard({ widget, config, runtime, links }, preview) {
|
|
@@ -14,6 +15,23 @@ function renderPhiCard({ widget, config, runtime, links }, preview) {
|
|
|
14
15
|
}
|
|
15
16
|
export const PHI_CARD_WIDGET_PLUGIN = {
|
|
16
17
|
...PHI_CARD_WIDGET_DEFINITION,
|
|
18
|
+
/*
|
|
19
|
+
* The card's words as the render draws them (SEARCH.md): the texts it translates, translated the same
|
|
20
|
+
* way; the figure and the prices as written, which the render never translates either.
|
|
21
|
+
*/
|
|
22
|
+
searchText: async ({ widget, config, runtime }) => {
|
|
23
|
+
const plan = config.body === "plan";
|
|
24
|
+
const translated = await translatePhiSearchWidgetTexts(runtime, [
|
|
25
|
+
config.eyebrow,
|
|
26
|
+
config.title,
|
|
27
|
+
config.description,
|
|
28
|
+
config.meta,
|
|
29
|
+
config.badge,
|
|
30
|
+
config.actionEnabled ? config.actionLabel : undefined,
|
|
31
|
+
...(plan ? (config.features ?? []).map((entry) => entry.text) : []),
|
|
32
|
+
], { translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate) });
|
|
33
|
+
return [...translated, config.value ?? "", ...(plan ? [config.price ?? "", config.priceYearly ?? ""] : [])];
|
|
34
|
+
},
|
|
17
35
|
/*
|
|
18
36
|
* Not the passive renderers' preview: that one is inert, and an inert card answers no pointer, so its
|
|
19
37
|
* hover effect could not be seen where it is chosen. The card's own preview leads nowhere instead.
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
3
|
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
|
+
import { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
|
|
4
5
|
import { PhiDescriptionWidget } from "./server";
|
|
5
6
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
6
7
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
|
|
7
8
|
import { PHI_DESCRIPTION_WIDGET_DEFINITION, PHI_DESCRIPTION_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
8
9
|
export const PHI_DESCRIPTION_WIDGET_PLUGIN = {
|
|
9
10
|
...PHI_DESCRIPTION_WIDGET_DEFINITION,
|
|
11
|
+
// Every sentence the render draws, translated the way it translates them: a Preset's globally, an author's for the Site.
|
|
12
|
+
searchText: ({ widget, config, runtime }) => translatePhiSearchWidgetTexts(runtime, [
|
|
13
|
+
config.eyebrow,
|
|
14
|
+
config.title,
|
|
15
|
+
config.description,
|
|
16
|
+
config.asideTitle,
|
|
17
|
+
...(config.asideItems ?? []).map((item) => item.text),
|
|
18
|
+
config.footer,
|
|
19
|
+
], { translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate), textSource: config.textSource }),
|
|
10
20
|
render: ({ widget, config, runtime }) => (_jsx(PhiDescriptionWidget, { labels: {
|
|
11
21
|
eyebrow: config.eyebrow,
|
|
12
22
|
title: config.title,
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
3
|
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
|
+
import { readPhiHtmlSearchText } from "../../../../../server-helpers/search-text";
|
|
4
5
|
import { PHI_HTML_WIDGET_DEFINITION, PHI_HTML_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
5
|
-
import { PhiHtmlWidget } from "./server";
|
|
6
|
+
import { PhiHtmlWidget, resolvePhiHtmlWidgetTranslatedHtml } from "./server";
|
|
6
7
|
export const PHI_HTML_WIDGET_PLUGIN = {
|
|
7
8
|
...PHI_HTML_WIDGET_DEFINITION,
|
|
9
|
+
// The fragment the render draws, read without its tags (SEARCH.md); a source that cannot be read contributes nothing.
|
|
10
|
+
searchText: async ({ widget, config, runtime }) => {
|
|
11
|
+
try {
|
|
12
|
+
const html = await resolvePhiHtmlWidgetTranslatedHtml({
|
|
13
|
+
...config,
|
|
14
|
+
resolvedContent: widget.resolvedContent ?? null,
|
|
15
|
+
preferSource: hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
|
|
16
|
+
}, runtime);
|
|
17
|
+
return readPhiHtmlSearchText(html);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
},
|
|
8
23
|
render: ({ widget, config, runtime }) => {
|
|
9
24
|
const noTranslate = hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate);
|
|
10
25
|
return (_jsx(PhiHtmlWidget, { blockId: widget.id, config: {
|
|
@@ -14,4 +14,10 @@ export type PhiHtmlWidgetConfig = PhiHtmlWidgetClientConfig & PhiRenderableBlock
|
|
|
14
14
|
export type PhiHtmlWidgetProps = PhiServerBlockBaseProps<PhiHtmlWidgetLabels, PhiHtmlWidgetConfig> & {
|
|
15
15
|
blockId: PhiCmsInstanceId;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* The fragment as the reader gets it: read from its source, its references resolved, sanitised and
|
|
19
|
+
* translated for the render's language. Empty where the Widget has nothing to show. The render draws it;
|
|
20
|
+
* the search index reads its words (SEARCH.md).
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolvePhiHtmlWidgetTranslatedHtml(config: PhiHtmlWidgetConfig | undefined, runtime: PhiHtmlWidgetProps["runtime"]): Promise<string>;
|
|
17
23
|
export declare function PhiHtmlWidget({ blockId, config, runtime, }: PhiHtmlWidgetProps): Promise<import("react").JSX.Element | null>;
|
|
@@ -19,7 +19,12 @@ const loadRemoteHtml = cache(async function loadRemoteHtml(resolvedUrl, revalida
|
|
|
19
19
|
throw new Error(`Failed to load HTML from ${resolvedUrl}: ${response.status}`);
|
|
20
20
|
return response.text();
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The fragment as the reader gets it: read from its source, its references resolved, sanitised and
|
|
24
|
+
* translated for the render's language. Empty where the Widget has nothing to show. The render draws it;
|
|
25
|
+
* the search index reads its words (SEARCH.md).
|
|
26
|
+
*/
|
|
27
|
+
export async function resolvePhiHtmlWidgetTranslatedHtml(config, runtime) {
|
|
23
28
|
const sourceMode = config?.sourceMode ?? (config?.sourceUrl?.trim() ? "url" : "inline");
|
|
24
29
|
const sourceUrl = config?.sourceUrl?.trim() ?? "";
|
|
25
30
|
/*
|
|
@@ -48,11 +53,14 @@ export async function PhiHtmlWidget({ blockId, config, runtime, }) {
|
|
|
48
53
|
}))
|
|
49
54
|
: "";
|
|
50
55
|
if (!sourceHtml) {
|
|
51
|
-
return
|
|
56
|
+
return "";
|
|
52
57
|
}
|
|
53
|
-
|
|
58
|
+
return (sourceMode !== "url" && config?.resolvedContent != null) || config?.preferSource === true
|
|
54
59
|
? sourceHtml
|
|
55
|
-
:
|
|
60
|
+
: translateSemanticHtml(sourceHtml, sourceMode === "url" ? config?.sourceLocale?.trim() : undefined, runtime.locale.current);
|
|
61
|
+
}
|
|
62
|
+
export async function PhiHtmlWidget({ blockId, config, runtime, }) {
|
|
63
|
+
const translatedHtml = await resolvePhiHtmlWidgetTranslatedHtml(config, runtime);
|
|
56
64
|
if (!translatedHtml) {
|
|
57
65
|
return null;
|
|
58
66
|
}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PhiWidgetInertPreview } from "../../../../../components/widgets/built-in/widget-preview";
|
|
3
|
+
import { resolveMarkdownRenderData } from "../../../../../components/widgets/shared/markdown-render";
|
|
3
4
|
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
4
5
|
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
6
|
+
import { readPhiMarkdownSearchText } from "../../../../../server-helpers/search-text";
|
|
5
7
|
import { PhiMarkdownWidget } from "./server";
|
|
6
8
|
import { PHI_MARKDOWN_WIDGET_DEFINITION, PHI_MARKDOWN_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
7
9
|
export const PHI_MARKDOWN_WIDGET_PLUGIN = {
|
|
8
10
|
...PHI_MARKDOWN_WIDGET_DEFINITION,
|
|
11
|
+
/*
|
|
12
|
+
* The document as the render would draw it -- inline, from its record, or fetched from its address --
|
|
13
|
+
* translated for the index's language, read back as lines (SEARCH.md). A source that cannot be read
|
|
14
|
+
* contributes nothing rather than failing the Page: the render shows the error in its place.
|
|
15
|
+
*/
|
|
16
|
+
searchText: async ({ widget, config, runtime }) => {
|
|
17
|
+
const data = await resolveMarkdownRenderData({
|
|
18
|
+
...config,
|
|
19
|
+
widgetId: widget.id,
|
|
20
|
+
resolvedContent: widget.resolvedContent ?? null,
|
|
21
|
+
translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
|
|
22
|
+
}, runtime);
|
|
23
|
+
return "error" in data ? [] : readPhiMarkdownSearchText(data.blocks);
|
|
24
|
+
},
|
|
9
25
|
render: ({ widget, config, runtime }) => (_jsx(PhiMarkdownWidget, { config: {
|
|
10
26
|
...config,
|
|
11
27
|
widgetId: widget.id,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PhiSearchBoxWidgetConfig } from "./config";
|
|
2
|
+
/**
|
|
3
|
+
* What the Builder says about a box that is a form the browser submits: where it leads, not a field to
|
|
4
|
+
* type into on the canvas -- a submit there would leave the Builder for the results Page.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PHI_SEARCH_BOX_WIDGET_BUILDER_PLUGIN: import("../../../../../types").PhiCmsBuilderWidgetPlugin<PhiSearchBoxWidgetConfig>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createPhiCmsBuilderWidgetPlugin } from "../../../../../plugins/factories/widget-builder-plugin";
|
|
4
|
+
import { PhiWidgetEditorPlaceholder } from "../../../../../components/widgets/builder/widget-editor-placeholder";
|
|
5
|
+
import { PHI_SEARCH_BOX_WIDGET_DEFINITION } from "./config";
|
|
6
|
+
/**
|
|
7
|
+
* What the Builder says about a box that is a form the browser submits: where it leads, not a field to
|
|
8
|
+
* type into on the canvas -- a submit there would leave the Builder for the results Page.
|
|
9
|
+
*/
|
|
10
|
+
export const PHI_SEARCH_BOX_WIDGET_BUILDER_PLUGIN = createPhiCmsBuilderWidgetPlugin(PHI_SEARCH_BOX_WIDGET_DEFINITION, ({ widget, config }) => (_jsx(PhiWidgetEditorPlaceholder, { widget: widget, pluginTitle: PHI_SEARCH_BOX_WIDGET_DEFINITION.title, summary: _jsxs(_Fragment, { children: ["A search field that sends what a visitor types to ", config?.linkTarget ? "the chosen results page" : "this Area's search page", config?.placeholder ? _jsxs(_Fragment, { children: ["; it reads \u201C", config.placeholder, "\u201D while empty"] }) : null, "."] }) })));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PhiSearchWidgetLabels } from "../../../../../components/widgets/label-types/search";
|
|
2
|
+
import type { PhiClientBlockBaseProps } from "../../../../../types";
|
|
3
|
+
import type { PhiControlSize } from "../../../../../types/control";
|
|
4
|
+
export type PhiSearchBoxWidgetClientConfig = {
|
|
5
|
+
/** The results Page, as the form's address. */
|
|
6
|
+
action: string;
|
|
7
|
+
placeholder: string;
|
|
8
|
+
size?: PhiControlSize;
|
|
9
|
+
/** The query the page is answering, so the box shows what was searched for. */
|
|
10
|
+
initialQuery: string;
|
|
11
|
+
};
|
|
12
|
+
export type PhiSearchBoxWidgetClientProps = PhiClientBlockBaseProps<PhiSearchWidgetLabels, PhiSearchBoxWidgetClientConfig>;
|
|
13
|
+
/**
|
|
14
|
+
* A `GET` form around one search field (SEARCH.md).
|
|
15
|
+
*
|
|
16
|
+
* The browser submits it: Enter, or the keyboard's search key, sends `?q=` to the results Page without
|
|
17
|
+
* a script, and a static Public page needs none. The field is the house's text Control with the form's
|
|
18
|
+
* field name, so it clears, labels and sizes like every other field, and the form is a landmark a screen
|
|
19
|
+
* reader lists.
|
|
20
|
+
*/
|
|
21
|
+
export declare function PhiSearchBoxWidgetClient({ labels, config }: PhiSearchBoxWidgetClientProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { PHI_SEARCH_QUERY_PARAM } from "@phis/contracts/search";
|
|
5
|
+
import { PhiTextControl } from "../../../../../components/controls/phi-text-control";
|
|
6
|
+
/**
|
|
7
|
+
* A `GET` form around one search field (SEARCH.md).
|
|
8
|
+
*
|
|
9
|
+
* The browser submits it: Enter, or the keyboard's search key, sends `?q=` to the results Page without
|
|
10
|
+
* a script, and a static Public page needs none. The field is the house's text Control with the form's
|
|
11
|
+
* field name, so it clears, labels and sizes like every other field, and the form is a landmark a screen
|
|
12
|
+
* reader lists.
|
|
13
|
+
*/
|
|
14
|
+
export function PhiSearchBoxWidgetClient({ labels, config }) {
|
|
15
|
+
const [draft, setDraft] = useState(config?.initialQuery ?? "");
|
|
16
|
+
return (_jsx("form", { method: "get", action: config?.action, role: "search", "aria-label": labels.title, style: { width: "100%" }, children: _jsx(PhiTextControl, { name: PHI_SEARCH_QUERY_PARAM, inputType: "search", ariaLabel: labels.ariaLabel, placeholder: config?.placeholder || labels.placeholder, clearLabel: labels.clearLabel, size: config?.size, value: draft, onChange: (value) => setDraft(value ?? ""), onClear: () => setDraft(""), style: { width: "100%" } }) }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PhiControlSize } from "../../../../../types/control";
|
|
2
|
+
import { type PhiLinkTarget } from "../../../../../types/references";
|
|
3
|
+
import { type PhiCmsWidgetConfigBase } from "../../../../../components/widgets/config/parser-primitives";
|
|
4
|
+
/**
|
|
5
|
+
* The box a visitor types a search into (SEARCH.md).
|
|
6
|
+
*
|
|
7
|
+
* It is a form the browser submits: `GET` to the results Page, the query in the URL. So it works before
|
|
8
|
+
* anything hydrated and in a static render, where no script has run yet; and the results Page reads the
|
|
9
|
+
* same URL whether it was reached from here, from a bookmark or from a link somebody pasted.
|
|
10
|
+
*/
|
|
11
|
+
export type PhiSearchBoxWidgetConfig = PhiCmsWidgetConfigBase & {
|
|
12
|
+
/** What the empty box says; empty for the label set's word. The author's text, translated. */
|
|
13
|
+
placeholder: string;
|
|
14
|
+
/**
|
|
15
|
+
* Where the query goes: a results Page, as a reference (REFERENCES.md). Absent, the Area's own search
|
|
16
|
+
* Page -- the App's in App, the Public one everywhere else -- so a box dropped into a Page works
|
|
17
|
+
* without being told where.
|
|
18
|
+
*/
|
|
19
|
+
linkTarget?: PhiLinkTarget;
|
|
20
|
+
/** The field's size; `size` is the block's own geometry and cannot be this. */
|
|
21
|
+
controlSize?: PhiControlSize;
|
|
22
|
+
};
|
|
23
|
+
declare function normalizePhiSearchBoxWidgetConfig(raw: Record<string, unknown>): PhiSearchBoxWidgetConfig;
|
|
24
|
+
export declare const PHI_SEARCH_BOX_WIDGET_DEFINITION: {
|
|
25
|
+
kind: "widget";
|
|
26
|
+
pluginKey: string;
|
|
27
|
+
typeKey: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
category: "navigation";
|
|
31
|
+
tags: string[];
|
|
32
|
+
translatesOwnText: true;
|
|
33
|
+
icon: string;
|
|
34
|
+
slotSizePolicy: "fill-inline";
|
|
35
|
+
fields: ({
|
|
36
|
+
key: string;
|
|
37
|
+
type: "string";
|
|
38
|
+
label: string;
|
|
39
|
+
description: string;
|
|
40
|
+
heading?: undefined;
|
|
41
|
+
options?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
key: string;
|
|
44
|
+
type: "link-target";
|
|
45
|
+
heading: string;
|
|
46
|
+
label: string;
|
|
47
|
+
description: string;
|
|
48
|
+
options?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
key: string;
|
|
51
|
+
type: "choice";
|
|
52
|
+
label: string;
|
|
53
|
+
options: {
|
|
54
|
+
value: string;
|
|
55
|
+
label: string;
|
|
56
|
+
}[];
|
|
57
|
+
description?: undefined;
|
|
58
|
+
heading?: undefined;
|
|
59
|
+
})[];
|
|
60
|
+
defaultConfig: PhiSearchBoxWidgetConfig;
|
|
61
|
+
parseConfig: typeof normalizePhiSearchBoxWidgetConfig;
|
|
62
|
+
};
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
|
|
2
|
+
import { readPhiLinkTarget } from "../../../../../types/references";
|
|
3
|
+
import { readRenderableBlockConfig, readString, } from "../../../../../components/widgets/config/parser-primitives";
|
|
4
|
+
const PHI_SEARCH_BOX_SIZES = ["small", "medium", "large"];
|
|
5
|
+
function normalizePhiSearchBoxWidgetConfig(raw) {
|
|
6
|
+
return {
|
|
7
|
+
...readRenderableBlockConfig(raw),
|
|
8
|
+
placeholder: readString(raw.placeholder)?.trim() ?? "",
|
|
9
|
+
linkTarget: readPhiLinkTarget(raw.linkTarget) ?? undefined,
|
|
10
|
+
controlSize: PHI_SEARCH_BOX_SIZES.includes(raw.controlSize)
|
|
11
|
+
? raw.controlSize
|
|
12
|
+
: undefined,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export const PHI_SEARCH_BOX_WIDGET_DEFINITION = {
|
|
16
|
+
kind: "widget",
|
|
17
|
+
pluginKey: resolvePhiCmsWidgetPluginKey("search-box"),
|
|
18
|
+
typeKey: "search-box",
|
|
19
|
+
title: "Search Box",
|
|
20
|
+
description: "A box that sends what a visitor types to the Site's search results page.",
|
|
21
|
+
category: "navigation",
|
|
22
|
+
tags: ["search", "find", "navigation"],
|
|
23
|
+
translatesOwnText: true,
|
|
24
|
+
icon: "antd:search",
|
|
25
|
+
slotSizePolicy: "fill-inline",
|
|
26
|
+
fields: [
|
|
27
|
+
{ key: "placeholder", type: "string", label: "Placeholder", description: "Empty shows \"Search\"." },
|
|
28
|
+
{
|
|
29
|
+
key: "linkTarget",
|
|
30
|
+
type: "link-target",
|
|
31
|
+
heading: "Results",
|
|
32
|
+
label: "Results page",
|
|
33
|
+
description: "Where the query is answered. Empty is this Area's own search page.",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: "controlSize",
|
|
37
|
+
type: "choice",
|
|
38
|
+
label: "Size",
|
|
39
|
+
options: [
|
|
40
|
+
{ value: "small", label: "Small" },
|
|
41
|
+
{ value: "medium", label: "Medium" },
|
|
42
|
+
{ value: "large", label: "Large" },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
defaultConfig: normalizePhiSearchBoxWidgetConfig({}),
|
|
47
|
+
parseConfig: normalizePhiSearchBoxWidgetConfig,
|
|
48
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
+
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
|
+
import { definePhiPassiveWidgetRenderers } from "../../../../../plugins/factories/widget-renderers";
|
|
5
|
+
import { PHI_SEARCH_BOX_WIDGET_DEFINITION } from "./config";
|
|
6
|
+
import { PhiSearchBoxWidget } from "./server";
|
|
7
|
+
export const PHI_SEARCH_BOX_WIDGET_PLUGIN = {
|
|
8
|
+
...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}`))),
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PhiNoLabels, PhiServerBlockBaseProps } from "../../../../../types";
|
|
2
|
+
import type { PhiResolvedLinkTargets } from "../../../../../types/references";
|
|
3
|
+
import type { PhiSearchBoxWidgetConfig } from "./config";
|
|
4
|
+
export type PhiSearchBoxWidgetProps = PhiServerBlockBaseProps<PhiNoLabels, PhiSearchBoxWidgetConfig> & {
|
|
5
|
+
/** The page's resolved link targets, where the author chose a results Page. */
|
|
6
|
+
links?: PhiResolvedLinkTargets | null;
|
|
7
|
+
/** Whether the placeholder is translated: the node's `NoTranslate` flag, read by the plugin. */
|
|
8
|
+
translate?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The search box, resolved on the server: where the form goes, what the box says, what it already holds.
|
|
12
|
+
*
|
|
13
|
+
* The results Page is a reference, resolved as every link is -- through the page's targets where the
|
|
14
|
+
* author picked one, or alone where the box takes the Area's own Page. An Area whose search Page does not
|
|
15
|
+
* resolve -- a Module switched off, a Page unpublished -- draws no box at all rather than one that
|
|
16
|
+
* leads to "not found".
|
|
17
|
+
*
|
|
18
|
+
* On the results Page itself the box shows the query it is answering, read from the same URL parameter
|
|
19
|
+
* the results Widget reads.
|
|
20
|
+
*/
|
|
21
|
+
export declare function PhiSearchBoxWidget({ config, runtime, links, translate }: PhiSearchBoxWidgetProps): Promise<import("react").JSX.Element | null>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PHI_SEARCH_QUERY_PARAM } from "@phis/contracts/search";
|
|
3
|
+
import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
|
|
4
|
+
import { getPhiSearchWidgetLabels } from "../../../../../components/widgets/label-sets/search";
|
|
5
|
+
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
6
|
+
import { resolvePhiLinkHref } from "../../../../../helpers/link-target";
|
|
7
|
+
import { resolvePhiLinkTargetReferences } from "../../../../../server-helpers/cms-link-targets";
|
|
8
|
+
import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
|
|
9
|
+
import { trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
10
|
+
import { resolvePhiSearchPageLinkTarget } from "../../../search-page-references";
|
|
11
|
+
/**
|
|
12
|
+
* The search box, resolved on the server: where the form goes, what the box says, what it already holds.
|
|
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".
|
|
18
|
+
*
|
|
19
|
+
* On the results Page itself the box shows the query it is answering, read from the same URL parameter
|
|
20
|
+
* the results Widget reads.
|
|
21
|
+
*/
|
|
22
|
+
export async function PhiSearchBoxWidget({ config, runtime, links, translate = true }) {
|
|
23
|
+
const rt = phiRuntime(runtime);
|
|
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;
|
|
31
|
+
const href = resolvePhiLinkHref(target, resolved);
|
|
32
|
+
if (!href) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const [labels, [placeholder]] = await Promise.all([
|
|
36
|
+
getPhiSearchWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale }),
|
|
37
|
+
config?.placeholder && translate ? trBulkForLocale(locale, [config.placeholder]) : [config?.placeholder ?? ""],
|
|
38
|
+
]);
|
|
39
|
+
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.SearchBox, componentProps: {
|
|
40
|
+
labels,
|
|
41
|
+
config: {
|
|
42
|
+
action: href.href,
|
|
43
|
+
placeholder: placeholder || labels.placeholder,
|
|
44
|
+
...(config?.controlSize ? { size: config.controlSize } : {}),
|
|
45
|
+
initialQuery: runtime.request?.searchParams?.[PHI_SEARCH_QUERY_PARAM] ?? "",
|
|
46
|
+
},
|
|
47
|
+
} }));
|
|
48
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PhiSearchResultsWidgetConfig } from "./config";
|
|
2
|
+
/**
|
|
3
|
+
* What the Builder says about a list it cannot show: the hits are whatever a visitor's query matches at
|
|
4
|
+
* the moment they ask, and the canvas has no query.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PHI_SEARCH_RESULTS_WIDGET_BUILDER_PLUGIN: import("../../../../../types").PhiCmsBuilderWidgetPlugin<PhiSearchResultsWidgetConfig>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createPhiCmsBuilderWidgetPlugin } from "../../../../../plugins/factories/widget-builder-plugin";
|
|
4
|
+
import { PhiWidgetEditorPlaceholder } from "../../../../../components/widgets/builder/widget-editor-placeholder";
|
|
5
|
+
import { PHI_SEARCH_RESULTS_WIDGET_DEFINITION } from "./config";
|
|
6
|
+
/**
|
|
7
|
+
* What the Builder says about a list it cannot show: the hits are whatever a visitor's query matches at
|
|
8
|
+
* the moment they ask, and the canvas has no query.
|
|
9
|
+
*/
|
|
10
|
+
export const PHI_SEARCH_RESULTS_WIDGET_BUILDER_PLUGIN = createPhiCmsBuilderWidgetPlugin(PHI_SEARCH_RESULTS_WIDGET_DEFINITION, ({ widget, config }) => (_jsx(PhiWidgetEditorPlaceholder, { widget: widget, pluginTitle: PHI_SEARCH_RESULTS_WIDGET_DEFINITION.title, summary: _jsxs(_Fragment, { children: ["Up to ", config?.limit ?? 20, " pages matching the search in the page's address, best first, read from the Site's search index when a visitor arrives."] }) })));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PhiSearchSnippetSegment } from "@phis/contracts/search";
|
|
2
|
+
import type { PhiSearchResultsWidgetLabels } from "../../../../../components/widgets/label-types/search-results";
|
|
3
|
+
import type { PhiCmsAreaKey } from "../../../../../constants/cms-areas";
|
|
4
|
+
import type { PhiClientBlockBaseProps } from "../../../../../types";
|
|
5
|
+
export type PhiSearchResultsWidgetHit = {
|
|
6
|
+
/** The Page's address as a visitor's link is written: locale and Area in front. */
|
|
7
|
+
href: string;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
snippet: PhiSearchSnippetSegment[];
|
|
11
|
+
area: PhiCmsAreaKey;
|
|
12
|
+
};
|
|
13
|
+
export type PhiSearchResultsWidgetClientConfig = {
|
|
14
|
+
/** The author's heading; absent, the label set's, which names the query. */
|
|
15
|
+
title?: string;
|
|
16
|
+
minLength: number;
|
|
17
|
+
} & ({
|
|
18
|
+
state: "idle";
|
|
19
|
+
} | {
|
|
20
|
+
state: "short";
|
|
21
|
+
query: string;
|
|
22
|
+
} | {
|
|
23
|
+
state: "results";
|
|
24
|
+
query: string;
|
|
25
|
+
total: number;
|
|
26
|
+
hits: PhiSearchResultsWidgetHit[];
|
|
27
|
+
});
|
|
28
|
+
export type PhiSearchResultsWidgetClientProps = PhiClientBlockBaseProps<PhiSearchResultsWidgetLabels, PhiSearchResultsWidgetClientConfig>;
|
|
29
|
+
/**
|
|
30
|
+
* The hits as a list a reader scans: the Page's title as the link, its description, and the passage the
|
|
31
|
+
* query was found in with the words marked. The heading says what was searched for and how many Pages
|
|
32
|
+
* answered, so a reader who arrived by a pasted link knows what they are looking at.
|
|
33
|
+
*/
|
|
34
|
+
export declare function PhiSearchResultsWidgetClient({ labels, config }: PhiSearchResultsWidgetClientProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { PhiEmptyControl } from "../../../../../components/controls/phi-empty-control";
|
|
4
|
+
import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
|
|
5
|
+
import { PhiLink } from "../../../../../components/navigation/phi-link";
|
|
6
|
+
import { formatPhiTranslation } from "../../../../../helpers/translation-format";
|
|
7
|
+
import { PHI_SPACE } from "../../../../../theme/antd-css-var-contract";
|
|
8
|
+
function PhiSearchSnippet({ segments }) {
|
|
9
|
+
if (segments.length === 0)
|
|
10
|
+
return null;
|
|
11
|
+
return (_jsx(PhiTypographyControl, { presentation: "paragraph", style: { marginBottom: 0 }, children: segments.map((segment, index) => (segment.match
|
|
12
|
+
? _jsx(PhiTypographyControl, { mark: true, children: segment.text }, index)
|
|
13
|
+
: _jsx("span", { children: segment.text }, index))) }));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The hits as a list a reader scans: the Page's title as the link, its description, and the passage the
|
|
17
|
+
* query was found in with the words marked. The heading says what was searched for and how many Pages
|
|
18
|
+
* answered, so a reader who arrived by a pasted link knows what they are looking at.
|
|
19
|
+
*/
|
|
20
|
+
export function PhiSearchResultsWidgetClient({ labels, config }) {
|
|
21
|
+
if (!config)
|
|
22
|
+
return null;
|
|
23
|
+
if (config.state === "idle") {
|
|
24
|
+
return _jsx(PhiTypographyControl, { type: "secondary", children: labels.idle });
|
|
25
|
+
}
|
|
26
|
+
if (config.state === "short") {
|
|
27
|
+
return (_jsx(PhiTypographyControl, { type: "secondary", children: formatPhiTranslation(labels.short, [String(config.minLength)]) }));
|
|
28
|
+
}
|
|
29
|
+
const heading = config.title ?? formatPhiTranslation(labels.heading, [config.query]);
|
|
30
|
+
const count = config.total === 1 ? labels.countOne : formatPhiTranslation(labels.count, [String(config.total)]);
|
|
31
|
+
return (_jsxs("section", { "aria-label": labels.region, style: { display: "flex", flexDirection: "column", gap: PHI_SPACE.sm }, children: [_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: PHI_SPACE.xxs }, children: [_jsx(PhiTypographyControl, { presentation: "title", level: 2, style: { marginTop: 0, marginBottom: 0 }, children: heading }), config.hits.length > 0 ? _jsx(PhiTypographyControl, { type: "secondary", children: count }) : null] }), config.hits.length === 0 ? (_jsx(PhiEmptyControl, { description: formatPhiTranslation(labels.empty, [config.query]) })) : (_jsx("ol", { style: { listStyle: "none", margin: 0, padding: 0, display: "flex", flexDirection: "column", gap: PHI_SPACE.base }, children: config.hits.map((hit) => (_jsxs("li", { style: { display: "flex", flexDirection: "column", gap: PHI_SPACE.xxs }, children: [_jsx(PhiTypographyControl, { presentation: "title", level: 3, style: { marginTop: 0, marginBottom: 0 }, children: _jsx(PhiLink, { href: hit.href, children: hit.title }) }), _jsx(PhiTypographyControl, { type: "secondary", style: { fontSize: "0.85em" }, children: hit.href }), hit.description ? (_jsx(PhiTypographyControl, { presentation: "paragraph", style: { marginBottom: 0 }, children: hit.description })) : null, _jsx(PhiSearchSnippet, { segments: hit.snippet })] }, hit.href))) }))] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type PhiCmsWidgetConfigBase } from "../../../../../components/widgets/config/parser-primitives";
|
|
2
|
+
/**
|
|
3
|
+
* The Pages matching the query in the page's URL (SEARCH.md), read from Core while the page is drawn.
|
|
4
|
+
*
|
|
5
|
+
* It searches where it stands: on a Public Page the Public Area, on an App Page the App and Public
|
|
6
|
+
* Areas -- nobody reaches the App without signing in, and a member who did may search both. The query
|
|
7
|
+
* comes from the URL alone, so the page is never static and a pasted link answers like a typed search.
|
|
8
|
+
*/
|
|
9
|
+
export type PhiSearchResultsWidgetConfig = PhiCmsWidgetConfigBase & {
|
|
10
|
+
/** How many hits at most; a ceiling the Site sets once, not a parameter a visitor raises. */
|
|
11
|
+
limit: number;
|
|
12
|
+
/** A heading over the hits in the author's words; empty for the label set's, which names the query. */
|
|
13
|
+
title: string;
|
|
14
|
+
};
|
|
15
|
+
declare function normalizePhiSearchResultsWidgetConfig(raw: Record<string, unknown>): PhiSearchResultsWidgetConfig;
|
|
16
|
+
export declare const PHI_SEARCH_RESULTS_WIDGET_DEFINITION: {
|
|
17
|
+
kind: "widget";
|
|
18
|
+
pluginKey: string;
|
|
19
|
+
typeKey: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
category: "content";
|
|
23
|
+
tags: string[];
|
|
24
|
+
translatesOwnText: true;
|
|
25
|
+
icon: string;
|
|
26
|
+
slotSizePolicy: "fill-inline";
|
|
27
|
+
fields: ({
|
|
28
|
+
key: string;
|
|
29
|
+
type: "number";
|
|
30
|
+
label: string;
|
|
31
|
+
description: string;
|
|
32
|
+
} | {
|
|
33
|
+
key: string;
|
|
34
|
+
type: "string";
|
|
35
|
+
label: string;
|
|
36
|
+
description: string;
|
|
37
|
+
})[];
|
|
38
|
+
defaultConfig: PhiSearchResultsWidgetConfig;
|
|
39
|
+
parseConfig: typeof normalizePhiSearchResultsWidgetConfig;
|
|
40
|
+
};
|
|
41
|
+
export {};
|