@phis/ui 0.5.7 → 0.6.1

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 (116) hide show
  1. package/components/controls/phi-amount-list-control.d.ts +69 -0
  2. package/components/controls/phi-amount-list-control.js +15 -0
  3. package/components/controls/phi-button-control.js +16 -2
  4. package/components/controls/phi-form-control.d.ts +6 -0
  5. package/components/controls/phi-form-control.js +23 -7
  6. package/components/controls/phi-media-picker-control.d.ts +3 -1
  7. package/components/controls/phi-media-picker-control.js +2 -2
  8. package/components/forms/form-descriptor-runtime-client.d.ts +3 -1
  9. package/components/forms/form-descriptor-runtime-client.js +2 -2
  10. package/components/forms/form-field-provider-modules.d.ts +23 -0
  11. package/components/forms/form-field-provider-modules.js +28 -0
  12. package/components/forms/form-provider-contract.d.ts +7 -0
  13. package/components/forms/form-provider-contract.js +7 -0
  14. package/components/forms/lazy-form-field-control.d.ts +14 -0
  15. package/components/forms/lazy-form-field-control.js +35 -0
  16. package/components/forms/phi-form-widget.d.ts +3 -2
  17. package/components/forms/phi-form-widget.js +21 -3
  18. package/components/forms/shared-form-provider-registry.js +1 -33
  19. package/components/media/phi-area-upload-widget.js +6 -58
  20. package/components/media/phi-media-picker-binding.d.ts +16 -1
  21. package/components/media/phi-media-picker-binding.js +3 -2
  22. package/components/media/phi-media-upload.d.ts +12 -0
  23. package/components/media/phi-media-upload.js +22 -0
  24. package/components/media/phi-upload-drop-area.d.ts +22 -0
  25. package/components/media/phi-upload-drop-area.js +49 -0
  26. package/components/root/phi-root-layout.d.ts +1 -0
  27. package/components/root/phi-root-layout.js +1 -0
  28. package/components/widgets/helpers/semantic-html-translation.d.ts +4 -1
  29. package/components/widgets/helpers/semantic-html-translation.js +4 -2
  30. package/components/widgets/label-sets/admin-users.d.ts +9 -1
  31. package/components/widgets/label-sets/admin-users.js +14 -2
  32. package/components/widgets/label-sets/slot-upload.js +6 -3
  33. package/components/widgets/label-types/slot-upload.d.ts +7 -1
  34. package/components/widgets/label-types/slot-upload.js +2 -1
  35. package/components/widgets/shared/markdown-render.js +6 -6
  36. package/constants/media-library-provider-keys.d.ts +9 -0
  37. package/constants/media-library-provider-keys.js +9 -0
  38. package/constants/media.d.ts +2 -0
  39. package/constants/media.js +2 -0
  40. package/constants/runtime-module-ownership.js +2 -0
  41. package/controls.d.ts +4 -0
  42. package/controls.js +2 -0
  43. package/gateway/signet-route.d.ts +24 -0
  44. package/gateway/signet-route.js +107 -0
  45. package/gateway/site-proxy.js +14 -7
  46. package/helpers/phi-metadata.d.ts +8 -6
  47. package/helpers/phi-metadata.js +9 -2
  48. package/helpers/phi-signet-head.d.ts +26 -0
  49. package/helpers/phi-signet-head.js +53 -0
  50. package/helpers/phi-signet-paths.d.ts +16 -0
  51. package/helpers/phi-signet-paths.js +19 -0
  52. package/helpers/phi-signet.d.ts +40 -0
  53. package/helpers/phi-signet.js +70 -0
  54. package/net/phi-next-proxy.d.ts +10 -8
  55. package/net/phi-next-proxy.js +27 -84
  56. package/next/proxy-runtime.js +15 -0
  57. package/next/root-route.js +7 -4
  58. package/next/site-proxy.js +21 -0
  59. package/package.json +3 -3
  60. package/plugins/runtime-modules/area-definitions.d.ts +24 -3
  61. package/plugins/runtime-modules/area-definitions.js +11 -3
  62. package/plugins/runtime-modules/asset/definition.d.ts +44 -2
  63. package/plugins/runtime-modules/asset/definition.js +5 -2
  64. package/plugins/runtime-modules/asset/form-providers.d.ts +63 -0
  65. package/plugins/runtime-modules/asset/form-providers.js +54 -0
  66. package/plugins/runtime-modules/asset/form-ui-provider.js +13 -3
  67. package/plugins/runtime-modules/asset/media-asset-field.d.ts +20 -0
  68. package/plugins/runtime-modules/asset/media-asset-field.js +33 -0
  69. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +21 -0
  70. package/plugins/runtime-modules/asset/media-asset-form-control.js +74 -0
  71. package/plugins/runtime-modules/core/widgets/html/server.js +1 -1
  72. package/plugins/runtime-modules/core/widgets/slot-upload/client.js +28 -23
  73. package/plugins/runtime-modules/core/widgets/slot-upload/slot.d.ts +19 -0
  74. package/plugins/runtime-modules/core/widgets/slot-upload/slot.js +16 -0
  75. package/plugins/runtime-modules/public/presets.d.ts +12 -0
  76. package/plugins/runtime-modules/public/presets.js +10 -0
  77. package/plugins/runtime-modules/public/server.js +1 -1
  78. package/plugins/runtime-modules/public/trees/phi-default-pub-privacy-page-tree.d.ts +4 -0
  79. package/plugins/runtime-modules/public/trees/phi-default-pub-privacy-page-tree.js +66 -0
  80. package/plugins/runtime-modules/public-base-page-references.d.ts +2 -1
  81. package/plugins/runtime-modules/public-base-page-references.js +2 -1
  82. package/plugins/runtime-modules/resolver.js +38 -4
  83. package/plugins/runtime-modules/theme/controller/runtime.js +7 -2
  84. package/plugins/runtime-modules/theme/materialize-images.d.ts +16 -0
  85. package/plugins/runtime-modules/theme/materialize-images.js +37 -0
  86. package/plugins/runtime-modules/user-management/addon-roles.d.ts +35 -0
  87. package/plugins/runtime-modules/user-management/addon-roles.js +76 -0
  88. package/plugins/runtime-modules/user-management/cards.js +1 -1
  89. package/plugins/runtime-modules/user-management/client-data-providers.js +6 -0
  90. package/plugins/runtime-modules/user-management/data-providers.d.ts +11 -2
  91. package/plugins/runtime-modules/user-management/data-providers.js +12 -1
  92. package/plugins/runtime-modules/user-management/definition.d.ts +11 -2
  93. package/plugins/runtime-modules/user-management/ids.d.ts +1 -0
  94. package/plugins/runtime-modules/user-management/ids.js +1 -0
  95. package/plugins/runtime-modules/user-management/services/options.d.ts +8 -0
  96. package/plugins/runtime-modules/user-management/services/options.js +25 -0
  97. package/plugins/runtime-modules/user-management/services/table.js +9 -1
  98. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +20 -2
  99. package/server-helpers/cms-widget-texts.js +1 -1
  100. package/server-helpers/search-index.js +22 -13
  101. package/server-helpers/search-text.d.ts +3 -2
  102. package/server-helpers/search-text.js +6 -5
  103. package/server-helpers/translate.d.ts +13 -2
  104. package/server-helpers/translate.js +10 -6
  105. package/styles/amount-list.css +142 -0
  106. package/styles/controls.css +156 -7
  107. package/styles/gradients.css +21 -20
  108. package/theme/phi-theme-blocks.d.ts +7 -6
  109. package/theme/phi-theme-composition.d.ts +19 -1
  110. package/theme/phi-theme-composition.js +15 -0
  111. package/theme/phi-theme-signet.d.ts +31 -0
  112. package/theme/phi-theme-signet.js +53 -0
  113. package/theme/phi-tokens.d.ts +1 -1
  114. package/theme/phi-tokens.js +5 -1
  115. package/types/cms-plugins.d.ts +10 -1
  116. package/types/site-theme.d.ts +29 -0
@@ -1,7 +1,4 @@
1
1
  import "server-only";
2
- import { request as httpRequest } from "node:http";
3
- import { request as httpsRequest } from "node:https";
4
- import { Readable } from "node:stream";
5
2
  import { logRuntimeEvent } from "./log";
6
3
  /**
7
4
  * The catch-all's segments as a path again, each one encoded on its own.
@@ -36,84 +33,29 @@ function buildTargetUrl(upstreamBaseUrl, upstreamPrefix, request, path) {
36
33
  targetUrl.search = request.nextUrl.search;
37
34
  return targetUrl;
38
35
  }
39
- function toHeadersObject(headers) {
40
- return Object.fromEntries(headers.entries());
41
- }
42
36
  /** Headers that describe one connection, not the response: the runtime writes its own on the way out. */
43
37
  const HOP_BY_HOP_RESPONSE_HEADERS = ["connection", "keep-alive", "transfer-encoding"];
44
38
  /**
45
39
  * The upstream response's headers as the browser may see them.
46
40
  *
47
- * `fetch` hands over a body it has already decoded: undici asks for gzip, deflate and br on its own and
48
- * undoes whatever the Server applied. Passing the Server's `content-encoding` on then tells the browser
49
- * to decode plain bytes a second time (`ERR_CONTENT_DECODING_FAILED`), and its `content-length` counts
50
- * the compressed bytes. Both go for a decoded body; the runtime frames the body it actually sends.
51
- * Asking upstream for `identity` instead would rest on the Server honouring it -- this holds either way.
41
+ * Encoding is each hop's own business. This hop to the Server negotiates for itself -- `fetch` asks for
42
+ * gzip, deflate and br on its own and hands over a body it has already decoded
43
+ * (`buildPhiNextProxyHeaders` does not pass the browser's `accept-encoding` on). Passing the Server's
44
+ * `content-encoding` on then tells the browser to decode plain bytes a second time
45
+ * (`ERR_CONTENT_DECODING_FAILED`), and a runtime that compresses route handler responses itself (Next
46
+ * from 16.4.6) would stack a second layer on a body that still claims the first -- or, from 16.4.5, drop
47
+ * the claim and leave a compressed body unlabelled. The `content-length` counts the compressed bytes.
48
+ * Both go for a decoded body; the runtime frames the body it actually sends and compresses towards the
49
+ * browser itself, as nginx does in front of it.
52
50
  */
53
- export function buildPhiProxyResponseHeaders(upstream, options) {
51
+ export function buildPhiProxyResponseHeaders(upstream) {
54
52
  const headers = new Headers(upstream);
55
53
  for (const name of HOP_BY_HOP_RESPONSE_HEADERS)
56
54
  headers.delete(name);
57
- if (options.bodyDecoded) {
58
- headers.delete("content-encoding");
59
- headers.delete("content-length");
60
- }
55
+ headers.delete("content-encoding");
56
+ headers.delete("content-length");
61
57
  return headers;
62
58
  }
63
- function buildResponseHeaders(headers) {
64
- const responseHeaders = new Headers();
65
- for (const [key, value] of Object.entries(headers)) {
66
- if (HOP_BY_HOP_RESPONSE_HEADERS.includes(key.toLowerCase())) {
67
- continue;
68
- }
69
- if (typeof value === "string") {
70
- responseHeaders.set(key, value);
71
- continue;
72
- }
73
- if (Array.isArray(value)) {
74
- for (const item of value) {
75
- responseHeaders.append(key, item);
76
- }
77
- }
78
- }
79
- return responseHeaders;
80
- }
81
- async function proxyRequestWithNodeHttp(request, targetUrl, headers, timeoutMs) {
82
- const transport = targetUrl.protocol === "https:" ? httpsRequest : httpRequest;
83
- const requestHeaders = toHeadersObject(headers);
84
- const hasBody = request.method !== "GET" && request.method !== "HEAD";
85
- return await new Promise((resolve, reject) => {
86
- const proxyRequest = transport(targetUrl, {
87
- method: request.method,
88
- headers: requestHeaders,
89
- }, (proxyResponse) => {
90
- const chunks = [];
91
- proxyResponse.on("data", (chunk) => {
92
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
93
- });
94
- proxyResponse.on("end", () => {
95
- resolve(new Response(Buffer.concat(chunks), {
96
- status: proxyResponse.statusCode ?? 502,
97
- headers: buildResponseHeaders(proxyResponse.headers),
98
- }));
99
- });
100
- proxyResponse.on("error", reject);
101
- });
102
- const timeoutHandle = setTimeout(() => {
103
- proxyRequest.destroy(new Error("Proxy request timed out."));
104
- }, timeoutMs);
105
- timeoutHandle.unref?.();
106
- proxyRequest.on("error", reject);
107
- proxyRequest.on("close", () => clearTimeout(timeoutHandle));
108
- if (!hasBody || !request.body) {
109
- proxyRequest.end();
110
- return;
111
- }
112
- const bodyStream = Readable.fromWeb(request.body);
113
- bodyStream.on("error", reject);
114
- bodyStream.pipe(proxyRequest);
115
- });
116
- }
117
59
  async function proxyRequest(request, path, config) {
118
60
  if (!config.upstreamBaseUrl) {
119
61
  return Response.json({ message: config.missingBaseUrlMessage }, { status: 500 });
@@ -130,16 +72,20 @@ async function proxyRequest(request, path, config) {
130
72
  }
131
73
  const startedAt = Date.now();
132
74
  try {
133
- const hasBody = request.method !== "GET" && request.method !== "HEAD";
134
- const targetResponse = hasBody
135
- ? await proxyRequestWithNodeHttp(request, targetUrl, config.buildHeaders(request, path), config.timeoutMs)
136
- : await fetch(targetUrl, {
137
- method: request.method,
138
- headers: config.buildHeaders(request, path),
139
- ...(config.buildFetchInit?.(request, path) ?? { cache: "no-store" }),
140
- redirect: "manual",
141
- signal: AbortSignal.timeout(config.timeoutMs),
142
- });
75
+ /*
76
+ * One way upstream for every method, so one rule for what comes back. A body is streamed through
77
+ * (`duplex: "half"` is what fetch asks for a request body that is a stream); the answer is whatever
78
+ * fetch decoded, never the Server's bytes as they came.
79
+ */
80
+ const hasBody = request.method !== "GET" && request.method !== "HEAD" && request.body !== null;
81
+ const targetResponse = await fetch(targetUrl, {
82
+ method: request.method,
83
+ headers: config.buildHeaders(request, path),
84
+ ...(hasBody ? { body: request.body, duplex: "half" } : {}),
85
+ ...(config.buildFetchInit?.(request, path) ?? { cache: "no-store" }),
86
+ redirect: "manual",
87
+ signal: AbortSignal.timeout(config.timeoutMs),
88
+ });
143
89
  const durationMs = Date.now() - startedAt;
144
90
  if (durationMs >= config.timeoutMs / 2 && targetResponse.ok) {
145
91
  logRuntimeEvent("warn", "proxy.request.slow", {
@@ -177,12 +123,9 @@ async function proxyRequest(request, path, config) {
177
123
  },
178
124
  });
179
125
  }
180
- // The Node path hands over the Server's bytes as they came, still encoded; `fetch` decoded them.
181
126
  return new Response(targetResponse.body, {
182
127
  status: targetResponse.status,
183
- headers: hasBody
184
- ? targetResponse.headers
185
- : buildPhiProxyResponseHeaders(targetResponse.headers, { bodyDecoded: true }),
128
+ headers: buildPhiProxyResponseHeaders(targetResponse.headers),
186
129
  });
187
130
  }
188
131
  catch (error) {
@@ -3,6 +3,12 @@ import { getPhiInternalApiTimeoutMs, readPhiSiteRuntimeConfigSync, } from "../he
3
3
  import { PHIS_SITE_KEY_HEADER } from "../constants/http-headers";
4
4
  import { readPhiServerApiCredentials } from "../helpers/phis-server-credentials";
5
5
  const HOP_BY_HOP_HEADERS = new Set(["connection", "content-length", "host"]);
6
+ /**
7
+ * The browser's `accept-encoding` is its agreement with the Site, not with Core: encoding is each hop's
8
+ * own. The Site's `fetch` negotiates its own and decodes, and the answer is compressed again towards the
9
+ * browser by the runtime or nginx. Passed on, it let Core answer in an encoding this hop had not chosen.
10
+ */
11
+ const ENCODING_NEGOTIATION_HEADER = "accept-encoding";
6
12
  /** Headers Core reads as statements about the Site or the caller's standing. None may come from outside. */
7
13
  const PHIS_HEADER_PREFIX = "x-phis-";
8
14
  /**
@@ -98,6 +104,7 @@ export function buildPhiNextProxyHeaders(request, userAgent, options) {
98
104
  request.headers.forEach((value, key) => {
99
105
  const name = key.toLowerCase();
100
106
  if (!HOP_BY_HOP_HEADERS.has(name) &&
107
+ name !== ENCODING_NEGOTIATION_HEADER &&
101
108
  !name.startsWith(PHIS_HEADER_PREFIX) &&
102
109
  name !== "authorization" &&
103
110
  !name.startsWith(FORWARDING_HEADER_PREFIX) &&
@@ -122,6 +129,14 @@ export function buildPhiNextProxyHeaders(request, userAgent, options) {
122
129
  if (clientIp) {
123
130
  headers.set("x-forwarded-for", clientIp);
124
131
  }
132
+ /*
133
+ * A range names bytes of the representation as stored. The Site hands the browser decoded bytes, so
134
+ * what it asks Core for must be the bytes themselves: `identity`, or a range into a compressed body
135
+ * would be cut out of the compressed stream and decoded into nothing.
136
+ */
137
+ if (headers.has("range")) {
138
+ headers.set(ENCODING_NEGOTIATION_HEADER, "identity");
139
+ }
125
140
  if (!headers.has("user-agent")) {
126
141
  headers.set("user-agent", userAgent);
127
142
  }
@@ -10,6 +10,7 @@ import { resolvePhiThemeComposition } from "../theme/phi-theme-composition";
10
10
  import { composePhiFontCatalogue } from "../theme/phi-font-catalogue";
11
11
  import { PHI_REM_ROOT_PX } from "../theme/phi-css-vars";
12
12
  import { buildPhiRootMetadata } from "../helpers/phi-metadata";
13
+ import { describePhiSignetHead } from "../helpers/phi-signet-head";
13
14
  import { localizePath } from "../helpers/locale";
14
15
  import { readPhiSiteRuntimeConfigSync, } from "../helpers/site-runtime";
15
16
  import { loadPhiRootLayoutContext } from "../server-helpers/root-layout";
@@ -85,11 +86,13 @@ function buildPhiNextRootMetadata(runtimeConfig, site, themeBlocks) {
85
86
  "Canonical starter structure for PHIS-powered sites.",
86
87
  },
87
88
  /*
88
- * The Set that is followed, resolved the same way the Brand Widget resolves the Logo, so the tab
89
- * and the header cannot end up wearing two different marks. A Site that follows a Set without one
90
- * hands over nothing and the head stays quiet.
89
+ * The Signet the Site wears, resolved the way the Brand Widget resolves the Logo -- the Site's own,
90
+ * then the followed Set's -- so the tab and the header cannot end up wearing two different marks.
91
+ * The Site's own has an address and the head names it; a followed Set's is named as the data URL it
92
+ * is, which Safari does not show until a Theme save has made it the Site's own. A Site with no
93
+ * Signet hands over nothing and the head stays quiet.
91
94
  */
92
- signet: resolvePhiThemeComposition(site.theme, themeBlocks).markSet.signet,
95
+ signet: describePhiSignetHead(resolvePhiThemeComposition(site.theme, themeBlocks).signet),
93
96
  });
94
97
  }
95
98
  /** The document shell of every dynamic route: the request decides the locale and the colour scheme. */
@@ -1,5 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
  import { isPhiAssetOrBackendPath } from "./static-asset-path";
3
+ import { PHI_SIGNET_ALIAS_PARAM, PHI_SIGNET_ALIAS_PATHS, PHI_SIGNET_PATH } from "../helpers/phi-signet-paths";
3
4
  import { PHI_SITE_SESSION_COOKIE } from "../constants/site-cookies";
4
5
  import { PHI_CMS_SPECIAL_ROOTS } from "../helpers/cms-routing";
5
6
  import { localizePath } from "../helpers/locale";
@@ -148,6 +149,26 @@ export async function proxyPhiNextSiteRequest(request) {
148
149
  ? NextResponse.next()
149
150
  : new NextResponse(null, { status: 404 });
150
151
  }
152
+ const signetAlias = request.method === "GET" || request.method === "HEAD"
153
+ ? PHI_SIGNET_ALIAS_PATHS[pathname]
154
+ : undefined;
155
+ if (signetAlias) {
156
+ /*
157
+ * The paths a browser asks for without reading the document: Safari takes no icon from a data URL
158
+ * and asks for these instead. They are answered by the Site's Signet route, which has the picture
159
+ * and says 404 where there is none or it is not a PNG for the Apple paths. A rewrite, so the address
160
+ * the browser asked for stays what it asked for. This stands in front of a file of the Site's own
161
+ * at the same path, which is the cost of needing no file in the Site (THEME.md, Signet).
162
+ *
163
+ * Plain HTTP for the same reason as the static tree's address below: behind a proxy that terminates
164
+ * TLS `request.url` says `https://localhost:<port>`, and Next fetches a rewrite it counts as external
165
+ * from this process, which speaks HTTP only (`EPROTO`, a 500 on `/favicon.ico`).
166
+ */
167
+ const target = new URL(PHI_SIGNET_PATH, request.url);
168
+ target.protocol = "http:";
169
+ target.searchParams.set(PHI_SIGNET_ALIAS_PARAM, signetAlias);
170
+ return NextResponse.rewrite(target);
171
+ }
151
172
  if (isPhiAssetOrBackendPath(pathname)) {
152
173
  /*
153
174
  * `x-locale` is this proxy's word, set below from the path. A backend route resolves its locale
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.5.7",
3
+ "version": "0.6.1",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -495,14 +495,14 @@
495
495
  ],
496
496
  "peerDependencies": {
497
497
  "@ant-design/icons": "^6.3.2",
498
- "antd": "^6.7.0",
498
+ "antd": "^6.7.1",
499
499
  "next": "^16.2.11",
500
500
  "react": "^19.2.8",
501
501
  "react-dom": "^19.2.8"
502
502
  },
503
503
  "dependencies": {
504
504
  "@ant-design/colors": "^8.0.1",
505
- "@ant-design/cssinjs": "^2.1.2",
505
+ "@ant-design/cssinjs": "~2.1.2",
506
506
  "@ant-design/icons-svg": "^4.6.0",
507
507
  "@dnd-kit/core": "^6.3.1",
508
508
  "@dnd-kit/sortable": "^10.0.0",
@@ -26,6 +26,13 @@ export declare const PHI_PUBLIC_RUNTIME_AREA_DEFINITIONS: {
26
26
  defaultMessage: string;
27
27
  };
28
28
  readonly items: readonly [{
29
+ readonly itemKey: "@phis/ui/modules/public/nav/privacy";
30
+ readonly label: {
31
+ defaultMessage: string;
32
+ };
33
+ readonly icon: "antd:safety-certificate";
34
+ readonly routePresetKey: "public-privacy-page";
35
+ }, {
29
36
  readonly itemKey: "@phis/ui/modules/public/nav/terms";
30
37
  readonly label: {
31
38
  defaultMessage: string;
@@ -33,7 +40,7 @@ export declare const PHI_PUBLIC_RUNTIME_AREA_DEFINITIONS: {
33
40
  readonly icon: "antd:file-text";
34
41
  readonly routePresetKey: "public-terms-page";
35
42
  }];
36
- readonly exportedItemKeys: readonly ["@phis/ui/modules/public/nav/terms"];
43
+ readonly exportedItemKeys: readonly ["@phis/ui/modules/public/nav/privacy", "@phis/ui/modules/public/nav/terms"];
37
44
  }, PhiCmsNavigationSurfaceDescriptor];
38
45
  }[];
39
46
  export declare const PHI_APP_ACCOUNT_NAV_ITEM_KEY = "@phis/ui/modules/app/nav/account";
@@ -231,6 +238,13 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
231
238
  defaultMessage: string;
232
239
  };
233
240
  readonly items: readonly [{
241
+ readonly itemKey: "@phis/ui/modules/public/nav/privacy";
242
+ readonly label: {
243
+ defaultMessage: string;
244
+ };
245
+ readonly icon: "antd:safety-certificate";
246
+ readonly routePresetKey: "public-privacy-page";
247
+ }, {
234
248
  readonly itemKey: "@phis/ui/modules/public/nav/terms";
235
249
  readonly label: {
236
250
  defaultMessage: string;
@@ -238,7 +252,7 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
238
252
  readonly icon: "antd:file-text";
239
253
  readonly routePresetKey: "public-terms-page";
240
254
  }];
241
- readonly exportedItemKeys: readonly ["@phis/ui/modules/public/nav/terms"];
255
+ readonly exportedItemKeys: readonly ["@phis/ui/modules/public/nav/privacy", "@phis/ui/modules/public/nav/terms"];
242
256
  }, PhiCmsNavigationSurfaceDescriptor];
243
257
  } | {
244
258
  area: "app";
@@ -490,6 +504,13 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
490
504
  defaultMessage: string;
491
505
  };
492
506
  readonly items: readonly [{
507
+ readonly itemKey: "@phis/ui/modules/public/nav/privacy";
508
+ readonly label: {
509
+ defaultMessage: string;
510
+ };
511
+ readonly icon: "antd:safety-certificate";
512
+ readonly routePresetKey: "public-privacy-page";
513
+ }, {
493
514
  readonly itemKey: "@phis/ui/modules/public/nav/terms";
494
515
  readonly label: {
495
516
  defaultMessage: string;
@@ -497,7 +518,7 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
497
518
  readonly icon: "antd:file-text";
498
519
  readonly routePresetKey: "public-terms-page";
499
520
  }];
500
- readonly exportedItemKeys: readonly ["@phis/ui/modules/public/nav/terms"];
521
+ readonly exportedItemKeys: readonly ["@phis/ui/modules/public/nav/privacy", "@phis/ui/modules/public/nav/terms"];
501
522
  }, PhiCmsNavigationSurfaceDescriptor];
502
523
  } | {
503
524
  area: "app";
@@ -113,7 +113,9 @@ function sidebarAnchors(settingsItemKey) {
113
113
  };
114
114
  }
115
115
  /*
116
- * The Public surfaces carry one intrinsic entry, the terms, and export it as the one anchor.
116
+ * The Public header carries one intrinsic entry, the terms, and exports it as the one anchor. The footer
117
+ * carries two, the privacy notice and the terms in that order, and exports both: a Site package that has
118
+ * its own imprint places it before the privacy notice.
117
119
  *
118
120
  * The terms are Core's, so their entry is; the contact entry hangs after it, and a Site package's
119
121
  * landing places its Home entry before it. Public has no sidebar and no quick-links surface: the Public
@@ -126,6 +128,12 @@ const publicTermsItem = {
126
128
  icon: "antd:file-text",
127
129
  routePresetKey: "public-terms-page",
128
130
  };
131
+ const publicPrivacyItem = {
132
+ itemKey: "@phis/ui/modules/public/nav/privacy",
133
+ label: label("Privacy"),
134
+ icon: "antd:safety-certificate",
135
+ routePresetKey: "public-privacy-page",
136
+ };
129
137
  const publicNavigationSurfaces = [
130
138
  {
131
139
  navKey: "public:header",
@@ -136,8 +144,8 @@ const publicNavigationSurfaces = [
136
144
  {
137
145
  navKey: "public:footer",
138
146
  label: label("Public footer navigation"),
139
- items: [publicTermsItem],
140
- exportedItemKeys: [publicTermsItem.itemKey],
147
+ items: [publicPrivacyItem, publicTermsItem],
148
+ exportedItemKeys: [publicPrivacyItem.itemKey, publicTermsItem.itemKey],
141
149
  },
142
150
  accountNavigationSurface(PHI_PUBLIC_ACCOUNT_NAV_ITEM_KEY, "public:account"),
143
151
  ];
@@ -98,14 +98,56 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
98
98
  description: string;
99
99
  }[];
100
100
  formProviders: {
101
- fieldTypes: {
101
+ fieldTypes: ({
102
102
  key: `${string}/${string}`;
103
103
  ownerModuleId: "@phis/ui/modules/asset";
104
104
  title: string;
105
105
  description: string;
106
106
  valueType: "json";
107
107
  presentation: "hidden";
108
- }[];
108
+ } | {
109
+ key: `${string}/${string}`;
110
+ ownerModuleId: "@phis/ui/modules/asset";
111
+ title: string;
112
+ description: string;
113
+ valueType: "number";
114
+ presentation: "control";
115
+ settingsFields: ({
116
+ key: string;
117
+ type: "choice";
118
+ mode: "single";
119
+ valueType: "string";
120
+ label: string;
121
+ description: string;
122
+ options: ({
123
+ value: "image";
124
+ label: string;
125
+ } | {
126
+ value: "video";
127
+ label: string;
128
+ } | {
129
+ value: "audio";
130
+ label: string;
131
+ } | {
132
+ value: "pdf";
133
+ label: string;
134
+ } | {
135
+ value: "markdown";
136
+ label: string;
137
+ } | {
138
+ value: "font";
139
+ label: string;
140
+ })[];
141
+ } | {
142
+ key: string;
143
+ type: "boolean";
144
+ label: string;
145
+ description: string;
146
+ mode?: undefined;
147
+ valueType?: undefined;
148
+ options?: undefined;
149
+ })[];
150
+ })[];
109
151
  handlers: ({
110
152
  key: `${string}/${string}`;
111
153
  ownerModuleId: "@phis/ui/modules/asset";
@@ -6,7 +6,7 @@ import { PHI_ASSET_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "./data-providers";
6
6
  import { PHI_CMS_AREA_KEYS } from "../../../constants/cms-areas";
7
7
  import { PHI_CORE_SERVER_BINDING } from "../../../types/server-capabilities";
8
8
  import { PHI_ASSET_FOLDER_FORM_HANDLER_PROVIDER_DESCRIPTOR, PHI_ASSET_METADATA_FORM_HANDLER_PROVIDER_DESCRIPTOR, } from "./metadata-form";
9
- import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR } from "./form-providers";
9
+ import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR, } from "./form-providers";
10
10
  import { PHI_MEDIA_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR, PHI_MEDIA_STORAGE_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR, } from "./settings-forms";
11
11
  export const PHI_ASSET_RUNTIME_MODULE_DEFINITION = {
12
12
  moduleId: PHI_ASSET_RUNTIME_MODULE_ID,
@@ -30,7 +30,10 @@ export const PHI_ASSET_RUNTIME_MODULE_DEFINITION = {
30
30
  description: "Thumbnail, name and metadata, with the Module's own selection and actions.",
31
31
  }],
32
32
  formProviders: {
33
- fieldTypes: [PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR],
33
+ fieldTypes: [
34
+ PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR,
35
+ PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR,
36
+ ],
34
37
  handlers: [
35
38
  PHI_ASSET_METADATA_FORM_HANDLER_PROVIDER_DESCRIPTOR,
36
39
  PHI_ASSET_FOLDER_FORM_HANDLER_PROVIDER_DESCRIPTOR,
@@ -7,3 +7,66 @@ export declare const PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR: {
7
7
  valueType: "json";
8
8
  presentation: "hidden";
9
9
  };
10
+ /**
11
+ * The `media-asset` field type: one Asset of the Site's Media library, chosen with the library's picker.
12
+ * The Asset Module owns it, so a Form in any other Module may use it, and the Form widget mounts this
13
+ * Module's field Providers for it where the Module is active (`FORMS.md`).
14
+ */
15
+ /**
16
+ * The `media-asset` field's wording, read from the Form's Label Set and falling back to English. The
17
+ * picker's own wording (title, search, folder, empty, failed) is the Media picker's and is not repeated.
18
+ */
19
+ export declare const PHI_FORM_MEDIA_ASSET_LABEL_KEYS: {
20
+ readonly choose: "mediaAssetChoose";
21
+ readonly change: "mediaAssetChange";
22
+ readonly remove: "mediaAssetRemove";
23
+ /** Beneath the field when it offers public Assets only (`config.publicOnly`). */
24
+ readonly publicOnlyHint: "mediaAssetPublicOnlyHint";
25
+ /** Beside a chosen Asset that is not public, where the field offers public ones only. */
26
+ readonly notPublic: "mediaAssetNotPublic";
27
+ /** Where the preview would be, when the Asset could not be read. */
28
+ readonly unavailable: "mediaAssetUnavailable";
29
+ };
30
+ export declare const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR: {
31
+ key: `${string}/${string}`;
32
+ ownerModuleId: "@phis/ui/modules/asset";
33
+ title: string;
34
+ description: string;
35
+ valueType: "number";
36
+ presentation: "control";
37
+ settingsFields: ({
38
+ key: string;
39
+ type: "choice";
40
+ mode: "single";
41
+ valueType: "string";
42
+ label: string;
43
+ description: string;
44
+ options: ({
45
+ value: "image";
46
+ label: string;
47
+ } | {
48
+ value: "video";
49
+ label: string;
50
+ } | {
51
+ value: "audio";
52
+ label: string;
53
+ } | {
54
+ value: "pdf";
55
+ label: string;
56
+ } | {
57
+ value: "markdown";
58
+ label: string;
59
+ } | {
60
+ value: "font";
61
+ label: string;
62
+ })[];
63
+ } | {
64
+ key: string;
65
+ type: "boolean";
66
+ label: string;
67
+ description: string;
68
+ mode?: undefined;
69
+ valueType?: undefined;
70
+ options?: undefined;
71
+ })[];
72
+ };
@@ -1,4 +1,6 @@
1
1
  import { PHI_ASSET_RUNTIME_MODULE_ID } from "./ids";
2
+ import { PhiMediaKind } from "../../../constants/media";
3
+ import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY } from "../../../constants/media-library-provider-keys";
2
4
  import { createPhiSharedFormProviderKey } from "../../../components/forms/form-provider-contract";
3
5
  export const PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_KEY = createPhiSharedFormProviderKey("field", "asset-focal-rect");
4
6
  export const PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR = {
@@ -9,3 +11,55 @@ export const PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR = {
9
11
  valueType: "json",
10
12
  presentation: "hidden",
11
13
  };
14
+ /**
15
+ * The `media-asset` field type: one Asset of the Site's Media library, chosen with the library's picker.
16
+ * The Asset Module owns it, so a Form in any other Module may use it, and the Form widget mounts this
17
+ * Module's field Providers for it where the Module is active (`FORMS.md`).
18
+ */
19
+ /**
20
+ * The `media-asset` field's wording, read from the Form's Label Set and falling back to English. The
21
+ * picker's own wording (title, search, folder, empty, failed) is the Media picker's and is not repeated.
22
+ */
23
+ export const PHI_FORM_MEDIA_ASSET_LABEL_KEYS = {
24
+ choose: "mediaAssetChoose",
25
+ change: "mediaAssetChange",
26
+ remove: "mediaAssetRemove",
27
+ /** Beneath the field when it offers public Assets only (`config.publicOnly`). */
28
+ publicOnlyHint: "mediaAssetPublicOnlyHint",
29
+ /** Beside a chosen Asset that is not public, where the field offers public ones only. */
30
+ notPublic: "mediaAssetNotPublic",
31
+ /** Where the preview would be, when the Asset could not be read. */
32
+ unavailable: "mediaAssetUnavailable",
33
+ };
34
+ export const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR = {
35
+ key: PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY,
36
+ ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
37
+ title: "Media asset",
38
+ description: "One Asset of the Site's Media library, as its id.",
39
+ valueType: "number",
40
+ presentation: "control",
41
+ settingsFields: [
42
+ {
43
+ key: "mediaType",
44
+ type: "choice",
45
+ mode: "single",
46
+ valueType: "string",
47
+ label: "Kind",
48
+ description: "Image when nothing is named.",
49
+ options: [
50
+ { value: PhiMediaKind.Image, label: "Image" },
51
+ { value: PhiMediaKind.Video, label: "Video" },
52
+ { value: PhiMediaKind.Audio, label: "Audio" },
53
+ { value: PhiMediaKind.Pdf, label: "PDF" },
54
+ { value: PhiMediaKind.Markdown, label: "Markdown" },
55
+ { value: PhiMediaKind.Font, label: "Font" },
56
+ ],
57
+ },
58
+ {
59
+ key: "publicOnly",
60
+ type: "boolean",
61
+ label: "Public only",
62
+ description: "Offer only Assets that are delivered publicly. The picker greys out the others; the Server that takes the value decides.",
63
+ },
64
+ ],
65
+ };
@@ -1,12 +1,22 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { lazyPhiFormFieldControl } from "../../../components/forms/lazy-form-field-control";
3
4
  import { createPhiFormProviderRegistry, PhiFormProviderRegistryProvider } from "../../../components/forms/form-provider-registry";
4
- import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR } from "./form-providers";
5
+ import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR, } from "./form-providers";
6
+ // Loaded when a `media-asset` field first renders: the picker and the Media library binding stay out of
7
+ // every other Form.
8
+ const PhiLazyMediaAssetFormControl = lazyPhiFormFieldControl(() => import("./media-asset-form-control").then((module) => module.PhiMediaAssetFormControl));
5
9
  const PHI_ASSET_FORM_PROVIDER_REGISTRY = createPhiFormProviderRegistry({
6
- fieldTypes: [{
10
+ fieldTypes: [
11
+ {
7
12
  ...PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR,
8
13
  Control: () => null,
9
- }],
14
+ },
15
+ {
16
+ ...PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR,
17
+ Control: PhiLazyMediaAssetFormControl,
18
+ },
19
+ ],
10
20
  });
11
21
  export function PhiAssetFormUiProvider({ children }) {
12
22
  return (_jsx(PhiFormProviderRegistryProvider, { registry: PHI_ASSET_FORM_PROVIDER_REGISTRY, children: children }));
@@ -0,0 +1,20 @@
1
+ import type { PhiMediaAssetTile, PhiMediaKindValue } from "../../../types/media";
2
+ export type PhiMediaAssetFieldConfig = {
3
+ /** Which kind of Asset the picker lists. */
4
+ mediaType: PhiMediaKindValue;
5
+ /** Whether Assets that are not delivered publicly are greyed out in the picker. */
6
+ publicOnly: boolean;
7
+ };
8
+ /**
9
+ * The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list, or a
10
+ * `publicOnly` that is not a boolean, is a `PhiConfigError` naming the field, never a default put in its
11
+ * place -- a typo in `mediaType` would otherwise quietly offer another kind of file.
12
+ */
13
+ export declare function readPhiMediaAssetFieldConfig(config: Readonly<Record<string, unknown>> | undefined): PhiMediaAssetFieldConfig;
14
+ /**
15
+ * The Asset id a Form value holds, or `null`. A value that is not a positive whole number is not an id,
16
+ * and showing it as one would put a request for Asset `NaN` on the wire.
17
+ */
18
+ export declare function readPhiMediaAssetFieldValue(value: unknown): number | null;
19
+ /** Whether the picker lets one Asset be chosen: always, unless the field offers public Assets only. */
20
+ export declare function isPhiMediaAssetFieldSelectable(config: PhiMediaAssetFieldConfig, asset: Pick<PhiMediaAssetTile, "deliveryPolicy" | "lifecycleStatus">): boolean;