@phis/ui 0.4.5 → 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.
Files changed (145) hide show
  1. package/components/cms/phi-cms-root-layout.js +1 -1
  2. package/components/controls/phi-button-control.d.ts +3 -1
  3. package/components/controls/phi-button-control.js +2 -2
  4. package/components/controls/phi-collapse-control.d.ts +6 -2
  5. package/components/controls/phi-collapse-control.js +2 -2
  6. package/components/controls/phi-dialog-control.d.ts +11 -5
  7. package/components/controls/phi-dialog-control.js +19 -13
  8. package/components/controls/phi-menu-control-vocabulary.d.ts +7 -0
  9. package/components/controls/phi-menu-control-vocabulary.js +10 -0
  10. package/components/controls/phi-menu-control.d.ts +4 -1
  11. package/components/controls/phi-menu-control.js +6 -1
  12. package/components/controls/phi-text-control.d.ts +6 -1
  13. package/components/controls/phi-text-control.js +2 -1
  14. package/components/layouts/clients/phi-split-card-layout-client.js +13 -5
  15. package/components/layouts/clients/phi-three-column-layout-client.js +9 -3
  16. package/components/layouts/split-card-geometry.js +6 -2
  17. package/components/media/aspect-ratios.d.ts +2 -2
  18. package/components/menus/phi-account-menu.js +3 -1
  19. package/components/navigation/phi-link.js +7 -2
  20. package/components/navigation/use-phi-protected-mail.d.ts +11 -0
  21. package/components/navigation/use-phi-protected-mail.js +29 -0
  22. package/components/regions/clients/cms-region-container-client.js +5 -1
  23. package/components/regions/phi-cms-region-shell.d.ts +1 -0
  24. package/components/regions/phi-cms-region-shell.js +11 -0
  25. package/components/regions/presets/phi-area-shell-preset-nodes.d.ts +5 -0
  26. package/components/regions/presets/phi-area-shell-preset-nodes.js +19 -3
  27. package/components/root/phi-config-provider.js +16 -0
  28. package/components/shell/phi-cms-shell.d.ts +3 -1
  29. package/components/shell/phi-cms-shell.js +7 -3
  30. package/components/shell/phi-nav-link.js +7 -2
  31. package/components/shell/phi-shell-sider-drawer.d.ts +17 -0
  32. package/components/shell/phi-shell-sider-drawer.js +88 -0
  33. package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -0
  34. package/components/widgets/helpers/internal-reference-resolver.server.js +4 -1
  35. package/components/widgets/label-sets/inspector.js +2 -0
  36. package/components/widgets/label-sets/search-results.d.ts +4 -0
  37. package/components/widgets/label-sets/search-results.js +35 -0
  38. package/components/widgets/label-types/inspector.d.ts +2 -0
  39. package/components/widgets/label-types/inspector.js +1 -0
  40. package/components/widgets/label-types/search-results.d.ts +15 -0
  41. package/components/widgets/label-types/search-results.js +10 -0
  42. package/components/widgets/server/navigation-request.js +13 -1
  43. package/components/widgets/shared/card-body-client.d.ts +2 -0
  44. package/components/widgets/shared/card-body-client.js +8 -7
  45. package/components/widgets/shared/card-vocabulary.d.ts +36 -0
  46. package/components/widgets/shared/card-vocabulary.js +52 -0
  47. package/components/widgets/shared/markdown-body-client.d.ts +29 -0
  48. package/components/widgets/shared/markdown-body-client.js +60 -5
  49. package/components/widgets/shared/markdown-image-vocabulary.d.ts +31 -0
  50. package/components/widgets/shared/markdown-image-vocabulary.js +68 -0
  51. package/components/widgets/shared/markdown-render.d.ts +5 -0
  52. package/components/widgets/shared/markdown-render.js +123 -8
  53. package/components/widgets/shared/markdown-sections.d.ts +40 -0
  54. package/components/widgets/shared/markdown-sections.js +111 -0
  55. package/constants/cms-widget-types.d.ts +2 -0
  56. package/constants/cms-widget-types.js +4 -0
  57. package/gateway/site-area.d.ts +10 -7
  58. package/gateway/site-area.js +13 -11
  59. package/gateway/site-config.js +7 -1
  60. package/gateway/site-read-marker-listeners.d.ts +24 -0
  61. package/gateway/site-read-marker-listeners.js +22 -0
  62. package/gateway/site-search.d.ts +37 -0
  63. package/gateway/site-search.js +116 -0
  64. package/helpers/external-href.js +1 -1
  65. package/helpers/protected-mail.d.ts +16 -0
  66. package/helpers/protected-mail.js +81 -0
  67. package/next/areas/app.js +5 -1
  68. package/next/areas/public.js +5 -1
  69. package/next/seo-routes.js +2 -2
  70. package/package.json +2 -2
  71. package/plugins/runtime-modules/app/presets.js +23 -0
  72. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +2 -1
  73. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +3 -2
  74. package/plugins/runtime-modules/builder/clients/region-inspector.js +20 -1
  75. package/plugins/runtime-modules/client-manifests/common.js +8 -0
  76. package/plugins/runtime-modules/core/authoring-widgets.js +4 -0
  77. package/plugins/runtime-modules/core/widgets/card/config.d.ts +8 -1
  78. package/plugins/runtime-modules/core/widgets/card/config.js +22 -1
  79. package/plugins/runtime-modules/core/widgets/card/editor.js +9 -1
  80. package/plugins/runtime-modules/core/widgets/card/plugin.js +18 -0
  81. package/plugins/runtime-modules/core/widgets/card/server.js +9 -1
  82. package/plugins/runtime-modules/core/widgets/description/plugin.js +10 -0
  83. package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +2 -1
  84. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +3 -3
  85. package/plugins/runtime-modules/core/widgets/header-navigation/client.d.ts +6 -1
  86. package/plugins/runtime-modules/core/widgets/header-navigation/client.js +40 -13
  87. package/plugins/runtime-modules/core/widgets/header-navigation/config.d.ts +26 -1
  88. package/plugins/runtime-modules/core/widgets/header-navigation/config.js +27 -0
  89. package/plugins/runtime-modules/core/widgets/header-navigation/plugin.js +1 -1
  90. package/plugins/runtime-modules/core/widgets/header-navigation/server.d.ts +2 -2
  91. package/plugins/runtime-modules/core/widgets/header-navigation/server.js +3 -1
  92. package/plugins/runtime-modules/core/widgets/html/plugin.js +16 -1
  93. package/plugins/runtime-modules/core/widgets/html/server.d.ts +6 -0
  94. package/plugins/runtime-modules/core/widgets/html/server.js +12 -4
  95. package/plugins/runtime-modules/core/widgets/image/client.js +11 -7
  96. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -0
  97. package/plugins/runtime-modules/core/widgets/markdown/config.js +46 -1
  98. package/plugins/runtime-modules/core/widgets/markdown/plugin.js +16 -0
  99. package/plugins/runtime-modules/core/widgets/markdown/server.js +22 -8
  100. package/plugins/runtime-modules/core/widgets/search-box/authoring.d.ts +6 -0
  101. package/plugins/runtime-modules/core/widgets/search-box/authoring.js +10 -0
  102. package/plugins/runtime-modules/core/widgets/search-box/client.d.ts +21 -0
  103. package/plugins/runtime-modules/core/widgets/search-box/client.js +17 -0
  104. package/plugins/runtime-modules/core/widgets/search-box/config.d.ts +63 -0
  105. package/plugins/runtime-modules/core/widgets/search-box/config.js +48 -0
  106. package/plugins/runtime-modules/core/widgets/search-box/plugin.d.ts +3 -0
  107. package/plugins/runtime-modules/core/widgets/search-box/plugin.js +11 -0
  108. package/plugins/runtime-modules/core/widgets/search-box/server.d.ts +21 -0
  109. package/plugins/runtime-modules/core/widgets/search-box/server.js +48 -0
  110. package/plugins/runtime-modules/core/widgets/search-results/authoring.d.ts +6 -0
  111. package/plugins/runtime-modules/core/widgets/search-results/authoring.js +10 -0
  112. package/plugins/runtime-modules/core/widgets/search-results/client.d.ts +34 -0
  113. package/plugins/runtime-modules/core/widgets/search-results/client.js +32 -0
  114. package/plugins/runtime-modules/core/widgets/search-results/config.d.ts +41 -0
  115. package/plugins/runtime-modules/core/widgets/search-results/config.js +39 -0
  116. package/plugins/runtime-modules/core/widgets/search-results/plugin.d.ts +3 -0
  117. package/plugins/runtime-modules/core/widgets/search-results/plugin.js +10 -0
  118. package/plugins/runtime-modules/core/widgets/search-results/server.d.ts +20 -0
  119. package/plugins/runtime-modules/core/widgets/search-results/server.js +73 -0
  120. package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +11 -0
  121. package/plugins/runtime-modules/core/widgets/simple-text/server.js +11 -1
  122. package/plugins/runtime-modules/core/widgets.js +17 -0
  123. package/plugins/runtime-modules/public/presets.d.ts +16 -0
  124. package/plugins/runtime-modules/public/presets.js +22 -0
  125. package/plugins/runtime-modules/public-base-page-references.d.ts +1 -0
  126. package/plugins/runtime-modules/public-base-page-references.js +1 -0
  127. package/plugins/runtime-modules/search-page-references.d.ts +20 -0
  128. package/plugins/runtime-modules/search-page-references.js +35 -0
  129. package/plugins/runtime-modules/search-page-tree.d.ts +14 -0
  130. package/plugins/runtime-modules/search-page-tree.js +63 -0
  131. package/server-helpers/search-index.d.ts +28 -0
  132. package/server-helpers/search-index.js +299 -0
  133. package/server-helpers/search-text.d.ts +40 -0
  134. package/server-helpers/search-text.js +152 -0
  135. package/server-helpers.d.ts +1 -0
  136. package/server-helpers.js +1 -0
  137. package/styles/controls.css +108 -10
  138. package/styles/layout.css +35 -0
  139. package/styles/shell.css +142 -0
  140. package/theme/phi-tokens.d.ts +6 -0
  141. package/theme/phi-tokens.js +6 -0
  142. package/theme.d.ts +1 -0
  143. package/theme.js +6 -0
  144. package/types/cms-plugins.d.ts +20 -2
  145. package/types/core-widget-placements.d.ts +5 -0
@@ -1,4 +1,6 @@
1
1
  import type { PhiMarkdownImageFloat, PhiMarkdownTextAlign } from "../../../../../types/core-widget-placements";
2
+ import { type PhiMarkdownFoldSections } from "../../../../../components/widgets/shared/markdown-sections";
3
+ import { type PhiMarkdownImageAspectRatio } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
2
4
  import { type PhiSpacingScaleKey } from "../../../../../components/widgets/config/spacing-options";
3
5
  import type { PhiCmsResolvedContent } from "../../../../../types/cms";
4
6
  import { type PhiBulletListStyle } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
@@ -15,6 +17,18 @@ export type PhiCmsMarkdownWidgetConfig = PhiCmsWidgetConfigBase & {
15
17
  textAlign?: PhiMarkdownTextAlign;
16
18
  /** Pictures stand at this edge and the text flows past them; absent, a picture is a line of its own. */
17
19
  imageFloat?: PhiMarkdownImageFloat;
20
+ /**
21
+ * How tall every Media picture standing on its own in the text is (`markdown-image-vocabulary.ts`);
22
+ * absent is `auto`, the picture's own proportion. A picture's own address may say otherwise.
23
+ */
24
+ imageAspectRatio?: PhiMarkdownImageAspectRatio;
25
+ /**
26
+ * Whether every `##` section folds under its heading -- each on its own or one at a time
27
+ * (`markdown-sections.ts`) -- the way a page of questions and answers reads; absent, `none`.
28
+ */
29
+ foldSections?: PhiMarkdownFoldSections;
30
+ /** With folding sections: state them as schema.org `FAQPage` data for search engines. */
31
+ faqStructuredData?: boolean;
18
32
  textBlockSpacingBefore?: PhiSpacingScaleKey;
19
33
  textBlockSpacingAfter?: PhiSpacingScaleKey;
20
34
  headingBlockSpacingBefore?: PhiSpacingScaleKey;
@@ -41,6 +55,8 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
41
55
  slotSizePolicy: "fill-inline";
42
56
  defaultConfig: {
43
57
  revalidateSeconds: number;
58
+ imageAspectRatio: "auto";
59
+ foldSections: "none";
44
60
  textAlign: "start";
45
61
  textBlockSpacingBefore: "none";
46
62
  textBlockSpacingAfter: "sm";
@@ -1,8 +1,10 @@
1
1
  import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
2
+ import { readPhiMarkdownFoldSections, } from "../../../../../components/widgets/shared/markdown-sections";
3
+ import { readPhiMarkdownImageAspectRatio, } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
2
4
  import { PHI_SPACING_SCALE_KEYS } from "../../../../../components/widgets/config/spacing-options";
3
5
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
4
6
  import { buildPhiBulletListFields, PHI_BULLET_LIST_DEFAULT_STYLE, readPhiBulletListStyle, } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
5
- import { readNumber, readRenderableBlockConfig, readString, } from "../../../../../components/widgets/config/parser-primitives";
7
+ import { readNumber, readRenderableBlockConfig, readBoolean, readString, } from "../../../../../components/widgets/config/parser-primitives";
6
8
  const PHI_MARKDOWN_TEXT_ALIGN_OPTIONS = [
7
9
  { value: "start", label: "Start" },
8
10
  { value: "center", label: "Center" },
@@ -49,6 +51,9 @@ export function parsePhiCmsMarkdownWidgetConfig(config) {
49
51
  revalidateSeconds: readNumber(config.revalidateSeconds),
50
52
  textAlign: readMarkdownTextAlign(config.textAlign),
51
53
  imageFloat: readMarkdownImageFloat(config.imageFloat),
54
+ imageAspectRatio: readPhiMarkdownImageAspectRatio(config.imageAspectRatio),
55
+ foldSections: readPhiMarkdownFoldSections(config.foldSections),
56
+ faqStructuredData: readBoolean(config.faqStructuredData),
52
57
  textBlockSpacingBefore: readMarkdownSpacingKey(config.textBlockSpacingBefore),
53
58
  textBlockSpacingAfter: readMarkdownSpacingKey(config.textBlockSpacingAfter),
54
59
  headingBlockSpacingBefore: readMarkdownSpacingKey(config.headingBlockSpacingBefore),
@@ -78,6 +83,8 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
78
83
  slotSizePolicy: "fill-inline",
79
84
  defaultConfig: {
80
85
  revalidateSeconds: 14400,
86
+ imageAspectRatio: "auto",
87
+ foldSections: "none",
81
88
  textAlign: "start",
82
89
  textBlockSpacingBefore: "none",
83
90
  textBlockSpacingAfter: "sm",
@@ -126,6 +133,26 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
126
133
  label: "Align",
127
134
  options: PHI_MARKDOWN_TEXT_ALIGN_OPTIONS,
128
135
  },
136
+ /*
137
+ * A page of questions and answers: every `##` folds under its heading. Each on its own, or one open at
138
+ * a time; a link to a question opens it. With it, the questions can be stated for search engines.
139
+ */
140
+ {
141
+ key: "foldSections",
142
+ type: "choice",
143
+ label: "Fold Sections",
144
+ options: [
145
+ { value: "none", label: "None" },
146
+ { value: "independent", label: "Each on its own" },
147
+ { value: "accordion", label: "One at a time" },
148
+ ],
149
+ },
150
+ {
151
+ key: "faqStructuredData",
152
+ type: "boolean",
153
+ label: "FAQ for search engines",
154
+ visibleWhen: { field: "foldSections", notEquals: "none" },
155
+ },
129
156
  {
130
157
  key: "imageFloat",
131
158
  type: "choice",
@@ -134,6 +161,24 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
134
161
  emptyOption: { value: "none", label: "None" },
135
162
  options: PHI_MARKDOWN_IMAGE_FLOAT_OPTIONS,
136
163
  },
164
+ /*
165
+ * Every picture standing on its own takes this box; one that needs another says so in its own address
166
+ * (`phis:asset/12?ratio=16:9`, and `float=start|end|none` beside it). Automatic is the picture's own.
167
+ */
168
+ {
169
+ key: "imageAspectRatio",
170
+ type: "choice",
171
+ label: "Image Proportion",
172
+ options: [
173
+ { value: "auto", label: "Automatic" },
174
+ { value: "phi", label: "φ (golden)" },
175
+ { value: "3:2", label: "3:2" },
176
+ { value: "4:3", label: "4:3" },
177
+ { value: "16:9", label: "16:9" },
178
+ { value: "2:1", label: "2:1" },
179
+ { value: "1:1", label: "1:1" },
180
+ ],
181
+ },
137
182
  {
138
183
  key: "textBlockSpacingBefore",
139
184
  type: "choice",
@@ -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,
@@ -1,7 +1,8 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
3
3
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
4
4
  import { resolveMarkdownRenderData } from "../../../../../components/widgets/shared/markdown-render";
5
+ import { buildPhiMarkdownFaqStructuredData, resolvePhiMarkdownFoldLevel } from "../../../../../components/widgets/shared/markdown-sections";
5
6
  export async function PhiMarkdownWidget({ config, runtime, }) {
6
7
  const renderData = await resolveMarkdownRenderData(config, runtime);
7
8
  if ("error" in renderData) {
@@ -10,11 +11,24 @@ export async function PhiMarkdownWidget({ config, runtime, }) {
10
11
  if (renderData.blocks.length === 0) {
11
12
  return null;
12
13
  }
13
- return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Markdown, componentProps: {
14
- config: {
15
- ...config,
16
- blocks: renderData.blocks,
17
- headings: renderData.headings,
18
- },
19
- } }));
14
+ /*
15
+ * The source stays on the server. The client draws `blocks`; the text they were made from -- inline or
16
+ * out of a Content record -- went to the page's payload as well, every address in it in the clear while
17
+ * the blocks protected them (`helpers/protected-mail.ts`).
18
+ */
19
+ const { markdown: _markdown, resolvedContent: _resolvedContent, ...presentation } = config ?? {};
20
+ /*
21
+ * The folding sections as questions and answers, written into the page for search engines: data, never
22
+ * run, and its `<` escaped so no answer can close the element it stands in.
23
+ */
24
+ const faq = config?.faqStructuredData && config.foldSections && config.foldSections !== "none"
25
+ ? buildPhiMarkdownFaqStructuredData(renderData.blocks, resolvePhiMarkdownFoldLevel(config.headingOffset))
26
+ : null;
27
+ return (_jsxs(_Fragment, { children: [faq ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(faq).replace(/</gu, "\\u003c") } })) : null, _jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Markdown, componentProps: {
28
+ config: {
29
+ ...presentation,
30
+ blocks: renderData.blocks,
31
+ headings: renderData.headings,
32
+ },
33
+ } })] }));
20
34
  }
@@ -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,3 @@
1
+ import type { PhiCmsServerWidgetPlugin } from "../../../../../types";
2
+ import { type PhiSearchBoxWidgetConfig } from "./config";
3
+ export declare const PHI_SEARCH_BOX_WIDGET_PLUGIN: PhiCmsServerWidgetPlugin<PhiSearchBoxWidgetConfig>;
@@ -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 {};
@@ -0,0 +1,39 @@
1
+ import { PHI_SEARCH_DEFAULT_LIMIT, PHI_SEARCH_MAX_LIMIT } from "@phis/contracts/search";
2
+ import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
3
+ import { readInteger, readRenderableBlockConfig, readString, } from "../../../../../components/widgets/config/parser-primitives";
4
+ function readLimit(value) {
5
+ const limit = readInteger(value);
6
+ if (!limit || limit <= 0)
7
+ return PHI_SEARCH_DEFAULT_LIMIT;
8
+ return Math.min(limit, PHI_SEARCH_MAX_LIMIT);
9
+ }
10
+ function normalizePhiSearchResultsWidgetConfig(raw) {
11
+ return {
12
+ ...readRenderableBlockConfig(raw),
13
+ limit: readLimit(raw.limit),
14
+ title: readString(raw.title)?.trim() ?? "",
15
+ };
16
+ }
17
+ export const PHI_SEARCH_RESULTS_WIDGET_DEFINITION = {
18
+ kind: "widget",
19
+ pluginKey: resolvePhiCmsWidgetPluginKey("search-results"),
20
+ typeKey: "search-results",
21
+ title: "Search Results",
22
+ description: "The Site's pages matching the search in the page's address, best first.",
23
+ category: "content",
24
+ tags: ["search", "results", "find"],
25
+ translatesOwnText: true,
26
+ icon: "antd:search",
27
+ slotSizePolicy: "fill-inline",
28
+ fields: [
29
+ {
30
+ key: "limit",
31
+ type: "number",
32
+ label: "Hits",
33
+ description: `How many at most. ${PHI_SEARCH_DEFAULT_LIMIT} by default, ${PHI_SEARCH_MAX_LIMIT} at the very most.`,
34
+ },
35
+ { key: "title", type: "string", label: "Heading", description: "Empty names the query." },
36
+ ],
37
+ defaultConfig: normalizePhiSearchResultsWidgetConfig({}),
38
+ parseConfig: normalizePhiSearchResultsWidgetConfig,
39
+ };
@@ -0,0 +1,3 @@
1
+ import type { PhiCmsServerWidgetPlugin } from "../../../../../types";
2
+ import { type PhiSearchResultsWidgetConfig } from "./config";
3
+ export declare const PHI_SEARCH_RESULTS_WIDGET_PLUGIN: PhiCmsServerWidgetPlugin<PhiSearchResultsWidgetConfig>;