@phis/ui 0.6.2 → 0.6.4

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 (206) hide show
  1. package/components/cms/phi-cms-root-layout.js +2 -0
  2. package/components/controls/phi-mask-picker-control.d.ts +7 -1
  3. package/components/controls/phi-mask-picker-control.js +18 -16
  4. package/components/controls/phi-media-picker-control.d.ts +30 -1
  5. package/components/controls/phi-media-picker-control.js +15 -2
  6. package/components/controls/phi-media-source-item-tile-control.d.ts +22 -0
  7. package/components/controls/phi-media-source-item-tile-control.js +65 -0
  8. package/components/controls/phi-segmented-control.js +15 -1
  9. package/components/forms/form-field-labels.d.ts +19 -0
  10. package/components/forms/form-field-labels.js +78 -0
  11. package/components/forms/form-provider-contract.d.ts +1 -17
  12. package/components/forms/form-provider-contract.js +4 -18
  13. package/components/forms/media-asset-field-keys.d.ts +27 -0
  14. package/components/forms/media-asset-field-keys.js +27 -0
  15. package/components/forms/phi-form-widget.js +5 -1
  16. package/components/forms/upload-field-keys.d.ts +27 -0
  17. package/components/forms/upload-field-keys.js +27 -0
  18. package/components/forms/upload-form-control.js +11 -5
  19. package/components/media/asset-controller-requirement.d.ts +9 -0
  20. package/components/media/asset-controller-requirement.js +42 -0
  21. package/components/media/label-sets/media-upload.d.ts +10 -0
  22. package/components/media/label-sets/media-upload.js +85 -0
  23. package/components/media/label-sets/media.js +31 -135
  24. package/components/media/media-upload-labels.d.ts +43 -0
  25. package/components/media/media-upload-labels.js +23 -0
  26. package/components/media/media-upload-refusals.d.ts +12 -0
  27. package/components/media/media-upload-refusals.js +28 -0
  28. package/components/media/media-widget-labels.d.ts +33 -26
  29. package/components/media/media-widget-labels.js +27 -36
  30. package/components/media/phi-area-upload-widget.js +3 -4
  31. package/components/media/phi-asset-inspector-section.d.ts +2 -2
  32. package/components/media/phi-image-inspector-widget.d.ts +2 -5
  33. package/components/media/phi-media-picker-binding.d.ts +17 -0
  34. package/components/media/phi-media-picker-binding.js +199 -4
  35. package/components/media/phi-media-picker-labels.d.ts +7 -0
  36. package/components/media/phi-media-picker-labels.js +25 -0
  37. package/components/media/phi-media-sources.d.ts +69 -0
  38. package/components/media/phi-media-sources.js +254 -0
  39. package/components/media/phi-media-upload.d.ts +1 -27
  40. package/components/media/phi-media-upload.js +4 -48
  41. package/components/runtime/runtime-controller-materialization.d.ts +5 -4
  42. package/components/runtime/runtime-controller-materialization.js +5 -4
  43. package/components/runtime/runtime-module-context.d.ts +5 -1
  44. package/components/runtime/runtime-module-context.js +4 -1
  45. package/components/runtime/runtime-module-media-source-client-manifest.d.ts +17 -0
  46. package/components/runtime/runtime-module-media-source-client-manifest.js +53 -0
  47. package/components/widgets/client/shared/phi-mask-picker.js +23 -13
  48. package/components/widgets/client/shared/phi-widget-image-tool-button.d.ts +7 -5
  49. package/components/widgets/client/shared/phi-widget-image-tool-button.js +11 -7
  50. package/components/widgets/client/shared/phi-widget-tool-buttons.js +2 -2
  51. package/components/widgets/config/mask.d.ts +6 -8
  52. package/components/widgets/config/mask.js +14 -12
  53. package/components/widgets/label-sets/authoring-tools.js +55 -1
  54. package/components/widgets/label-sets/history.js +0 -2
  55. package/components/widgets/label-sets/slot-upload.js +4 -4
  56. package/components/widgets/label-types/authoring-tools.d.ts +10 -0
  57. package/components/widgets/label-types/authoring-tools.js +6 -0
  58. package/components/widgets/label-types/history.d.ts +1 -1
  59. package/components/widgets/label-types/history.js +0 -1
  60. package/components/widgets/label-types/mask-picker.d.ts +31 -0
  61. package/components/widgets/label-types/mask-picker.js +30 -0
  62. package/components/widgets/label-types/slot-upload.d.ts +2 -2
  63. package/controls.d.ts +2 -0
  64. package/controls.js +1 -0
  65. package/helpers/cms-region-keys.d.ts +1 -1
  66. package/module-client.d.ts +5 -1
  67. package/module-projection-client.js +1 -0
  68. package/next/areas/accounting-client.js +3 -2
  69. package/next/areas/admin-client.js +3 -2
  70. package/next/areas/app-client.js +3 -2
  71. package/next/areas/builder-client.js +3 -2
  72. package/next/areas/editor-client.js +3 -2
  73. package/next/areas/public-client.js +3 -2
  74. package/next/runtime-module-client-boundary.d.ts +3 -1
  75. package/next/runtime-module-client-boundary.js +3 -2
  76. package/package.json +7 -2
  77. package/plugins/runtime-modules/area-module-defaults.js +4 -3
  78. package/plugins/runtime-modules/asset/controller/definition.d.ts +2 -2
  79. package/plugins/runtime-modules/asset/controller/runtime.js +2 -2
  80. package/plugins/runtime-modules/asset/definition.d.ts +3 -2
  81. package/plugins/runtime-modules/asset/definition.js +11 -3
  82. package/plugins/runtime-modules/asset/ids.d.ts +8 -0
  83. package/plugins/runtime-modules/asset/ids.js +8 -0
  84. package/plugins/runtime-modules/asset/labels.d.ts +4 -0
  85. package/plugins/runtime-modules/asset/labels.js +94 -0
  86. package/plugins/runtime-modules/asset/media-asset-form-control.js +32 -7
  87. package/plugins/runtime-modules/asset/metadata-form.js +27 -18
  88. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +14 -11
  89. package/plugins/runtime-modules/asset/widgets/area-upload/config.d.ts +2 -0
  90. package/plugins/runtime-modules/asset/widgets/area-upload/config.js +3 -0
  91. package/plugins/runtime-modules/asset/widgets/area-upload/server.js +3 -3
  92. package/plugins/runtime-modules/asset/widgets/asset-focal-rect/config.d.ts +2 -0
  93. package/plugins/runtime-modules/asset/widgets/asset-focal-rect/config.js +3 -0
  94. package/plugins/runtime-modules/asset/widgets/image-inspector/config.d.ts +2 -0
  95. package/plugins/runtime-modules/asset/widgets/image-inspector/config.js +3 -0
  96. package/plugins/runtime-modules/asset/widgets/image-inspector/server.js +2 -2
  97. package/plugins/runtime-modules/asset/widgets/media-picker/config.d.ts +1 -0
  98. package/plugins/runtime-modules/asset/widgets/media-picker/config.js +3 -0
  99. package/plugins/runtime-modules/auth/presets.d.ts +11 -0
  100. package/plugins/runtime-modules/auth/presets.js +17 -8
  101. package/plugins/runtime-modules/auth/services/installations-table.js +3 -1
  102. package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +1 -4
  103. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +2 -2
  104. package/plugins/runtime-modules/builder/clients/inspector-image-field.d.ts +1 -3
  105. package/plugins/runtime-modules/builder/clients/inspector-image-field.js +4 -5
  106. package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +3 -8
  107. package/plugins/runtime-modules/builder/clients/pages-header.js +2 -0
  108. package/plugins/runtime-modules/builder/clients/widget-inspector.js +0 -1
  109. package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
  110. package/plugins/runtime-modules/builder/controller/page-controller.js +3 -3
  111. package/plugins/runtime-modules/builder/controller/workspace-controller.js +4 -1
  112. package/plugins/runtime-modules/builder/inspector-section-widget.js +5 -2
  113. package/plugins/runtime-modules/builder/module-authoring-catalog.server.js +3 -1
  114. package/plugins/runtime-modules/builder/navigation-catalog.server.js +3 -0
  115. package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +1 -1
  116. package/plugins/runtime-modules/builder/offered-page-catalog.js +8 -3
  117. package/plugins/runtime-modules/builder/options-providers.js +2 -2
  118. package/plugins/runtime-modules/builder/page-address-rule.d.ts +7 -0
  119. package/plugins/runtime-modules/builder/page-address-rule.js +12 -0
  120. package/plugins/runtime-modules/builder/page-presets.server.js +4 -0
  121. package/plugins/runtime-modules/builder/persistence.js +2 -3
  122. package/plugins/runtime-modules/builder/public-route-collisions.d.ts +1 -1
  123. package/plugins/runtime-modules/builder/public-route-collisions.js +6 -1
  124. package/plugins/runtime-modules/builder/runtime-module-sandbox.server.js +8 -1
  125. package/plugins/runtime-modules/builder/runtime-module-selection.js +5 -5
  126. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +24 -6
  127. package/plugins/runtime-modules/builder/signal-endpoints.js +2 -1
  128. package/plugins/runtime-modules/builder/use-offered-page-catalog.d.ts +2 -2
  129. package/plugins/runtime-modules/builder/use-offered-page-catalog.js +5 -3
  130. package/plugins/runtime-modules/builder/widgets/structure-region/plugin.js +19 -12
  131. package/plugins/runtime-modules/client-manifests/accounting.d.ts +1 -0
  132. package/plugins/runtime-modules/client-manifests/accounting.js +1 -0
  133. package/plugins/runtime-modules/client-manifests/admin.d.ts +1 -0
  134. package/plugins/runtime-modules/client-manifests/admin.js +1 -0
  135. package/plugins/runtime-modules/client-manifests/app.d.ts +1 -0
  136. package/plugins/runtime-modules/client-manifests/app.js +1 -0
  137. package/plugins/runtime-modules/client-manifests/builder.d.ts +1 -0
  138. package/plugins/runtime-modules/client-manifests/builder.js +1 -0
  139. package/plugins/runtime-modules/client-manifests/common.d.ts +1 -0
  140. package/plugins/runtime-modules/client-manifests/common.js +3 -0
  141. package/plugins/runtime-modules/client-manifests/editor.d.ts +1 -0
  142. package/plugins/runtime-modules/client-manifests/editor.js +1 -0
  143. package/plugins/runtime-modules/client-manifests/public.d.ts +1 -0
  144. package/plugins/runtime-modules/client-manifests/public.js +1 -0
  145. package/plugins/runtime-modules/contracts.js +61 -0
  146. package/plugins/runtime-modules/core/client-media-sources.d.ts +5 -0
  147. package/plugins/runtime-modules/core/client-media-sources.js +6 -0
  148. package/plugins/runtime-modules/core/messaging/forms.js +2 -15
  149. package/plugins/runtime-modules/core/messaging/labels.d.ts +0 -12
  150. package/plugins/runtime-modules/core/messaging/labels.js +0 -24
  151. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -6
  152. package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +1 -0
  153. package/plugins/runtime-modules/core/widgets/collection-view/config.js +7 -0
  154. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +8 -2
  155. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
  156. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +1 -1
  157. package/plugins/runtime-modules/core/widgets/collection-view/server.js +14 -2
  158. package/plugins/runtime-modules/core/widgets/image/authoring.js +1 -1
  159. package/plugins/runtime-modules/core/widgets/image/editor.d.ts +1 -4
  160. package/plugins/runtime-modules/core/widgets/image/editor.js +2 -2
  161. package/plugins/runtime-modules/core/widgets/slot-upload/client.js +2 -3
  162. package/plugins/runtime-modules/editor/services/releases-table.js +4 -1
  163. package/plugins/runtime-modules/observability/services/table.js +3 -1
  164. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +4 -25
  165. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
  166. package/plugins/runtime-modules/preset-contracts/pub-area.js +0 -1
  167. package/plugins/runtime-modules/resolver.js +27 -1
  168. package/plugins/runtime-modules/settings.d.ts +20 -3
  169. package/plugins/runtime-modules/settings.js +35 -5
  170. package/plugins/runtime-modules/site-module-client-manifests.d.ts +2 -0
  171. package/plugins/runtime-modules/site-module-client-manifests.js +2 -0
  172. package/plugins/runtime-modules/site-modules-client.d.ts +5 -0
  173. package/plugins/runtime-modules/site-modules-client.js +1 -0
  174. package/plugins/runtime-modules/theme/brand-theme-model.js +0 -1
  175. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +97 -192
  176. package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +6 -2
  177. package/plugins/runtime-modules/user-management/services/table.js +3 -1
  178. package/runtime-client-manifests-accounting.d.ts +1 -1
  179. package/runtime-client-manifests-accounting.js +1 -1
  180. package/runtime-client-manifests-admin.d.ts +1 -1
  181. package/runtime-client-manifests-admin.js +1 -1
  182. package/runtime-client-manifests-app.d.ts +1 -1
  183. package/runtime-client-manifests-app.js +1 -1
  184. package/runtime-client-manifests-builder.d.ts +1 -1
  185. package/runtime-client-manifests-builder.js +1 -1
  186. package/runtime-client-manifests-editor.d.ts +1 -1
  187. package/runtime-client-manifests-editor.js +1 -1
  188. package/runtime-client-manifests-public.d.ts +2 -1
  189. package/runtime-client-manifests-public.js +1 -1
  190. package/runtime-media-source-client.d.ts +3 -0
  191. package/runtime-media-source-client.js +2 -0
  192. package/server-helpers/cms-request.js +10 -4
  193. package/theme/phi-theme-presets.d.ts +13 -3
  194. package/theme/phi-theme-presets.js +20 -3
  195. package/theme/phi-theme-seed-derivation.d.ts +240 -0
  196. package/theme/phi-theme-seed-derivation.js +126 -0
  197. package/types/cms-plugins.d.ts +29 -0
  198. package/types/media-source.d.ts +48 -0
  199. package/types/media-source.js +1 -0
  200. package/types/site-config.d.ts +1 -2
  201. package/types/site-theme.d.ts +0 -6
  202. package/types.d.ts +1 -0
  203. package/components/media/asset-controller-routes.d.ts +0 -8
  204. package/components/media/asset-controller-routes.js +0 -31
  205. package/helpers/brand-contact.d.ts +0 -14
  206. package/helpers/brand-contact.js +0 -26
@@ -167,6 +167,8 @@ export async function PhiCmsAreaBoundary({ root, cmsBridge, children, path, page
167
167
  ? [...runtimeModuleScope.moduleSet.dataProviderDescriptorsByKey.values()]
168
168
  : [], calendarAdapterDescriptors: [
169
169
  ...runtimeModuleScope.moduleSet.calendarAdapterDescriptorsByKey.values(),
170
+ ], mediaSourceDescriptors: [
171
+ ...runtimeModuleScope.moduleSet.mediaSourceDescriptorsByKey.values(),
170
172
  ], videoProviderDescriptors: [
171
173
  ...runtimeModuleScope.moduleSet.videoProviderDescriptorsByKey.values(),
172
174
  ], children: _jsx(PhiModuleIconsProvider, { sets: collectPhiModuleIconSets(runtimeModuleScope.moduleSet.moduleDefinitionsById.values()), children: _jsxs(PhiRuntimeModuleDataProviderHost, { providerKeys: [...scope.runtimeRegistry.dataProviderDescriptorsByKey.keys()], children: [areaControllers.registeredControllerSettings && areaControllers.registeredControllerSettings.length > 0 ? (_jsx(PhiRuntimeControllerServerHost, { controllers: areaControllers.registeredControllerSettings, runtime: runtime, registry: areaControllers.controllerDefinitionsByType, controllerModuleIdsByType: runtimeModuleScope.moduleSet.ownerModuleIdByControllerType, runtimeModuleCatalog: scope.runtimeRegistry.runtimeModuleCatalog, serverCapabilities: scope.runtimeRegistry.serverCapabilities })) : null, children, filteredLayoutTree ? (_jsx(PhiCmsOverlayRenderer, { tree: filteredLayoutTree, runtime: runtime, registry: scope.runtimeRegistry, signalScope: "area", deferredOrigin: { area: runtime.area, root, path: path ?? pagePath ?? null } })) : null] }) }) }) }));
@@ -1,5 +1,7 @@
1
1
  import { type ReactNode } from "react";
2
2
  import { type PhiMaskConfig } from "../widgets/config/mask";
3
+ import { type PhiMaskPickerControlLabels } from "../widgets/label-types/mask-picker";
4
+ import type { PhiIconPickerControlLabels } from "../widgets/label-types/icon-picker";
3
5
  import { type PhiMediaPickerControlProps } from "./phi-media-picker-control";
4
6
  import type { PhiPickerPlacement, PhiPickerTransactionCallbacks } from "./phi-picker-control-contract";
5
7
  export type PhiMaskPickerControlProps = PhiPickerTransactionCallbacks<PhiMaskConfig | undefined> & {
@@ -16,5 +18,9 @@ export type PhiMaskPickerControlProps = PhiPickerTransactionCallbacks<PhiMaskCon
16
18
  getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
17
19
  onUploadFile?: (file: File) => void;
18
20
  onIconSelect?: (icon: string | null) => void;
21
+ /** What the picker says; English where nobody passes the translated set. */
22
+ labels?: PhiMaskPickerControlLabels;
23
+ /** What the Iconify picker inside it says, handed on as it is. */
24
+ iconPickerLabels?: PhiIconPickerControlLabels;
19
25
  };
20
- export declare function PhiMaskPickerControl({ value, open, buttonAriaLabel, buttonIcon, placement, mediaPickerProps, selectedIcon, uploading, uploadProgress, popupRootClassName, getPopupContainer, onUploadFile, onIconSelect, onChange, onCommit, onDiscard, onOpenChange, }: PhiMaskPickerControlProps): import("react").JSX.Element;
26
+ export declare function PhiMaskPickerControl({ value, open, buttonAriaLabel, buttonIcon, placement, mediaPickerProps, selectedIcon, uploading, uploadProgress, popupRootClassName, getPopupContainer, onUploadFile, onIconSelect, labels, iconPickerLabels, onChange, onCommit, onDiscard, onOpenChange, }: PhiMaskPickerControlProps): import("react").JSX.Element;
@@ -2,7 +2,8 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useRef, useState } from "react";
4
4
  import { Flex, Typography } from "antd";
5
- import { mergePhiMaskConfigDefaults, mergePhiMaskConfigPatch, PHI_MASK_PRESET_OPTIONS, resolvePhiMaskStyle, } from "../widgets/config/mask";
5
+ import { mergePhiMaskConfigDefaults, mergePhiMaskConfigPatch, PHI_MASK_PRESET_VALUES, resolvePhiMaskStyle, } from "../widgets/config/mask";
6
+ import { formatPhiMaskPickerLabel, PHI_MASK_PICKER_CONTROL_DEFAULT_LABELS, } from "../widgets/label-types/mask-picker";
6
7
  import { PhiIcon } from "../shell/phi-icon";
7
8
  import { PhiFileDropControl } from "./phi-file-drop-control";
8
9
  import { PhiButtonControl } from "./phi-button-control";
@@ -25,7 +26,8 @@ function renderMaskPreview(mask, label, selected = false) {
25
26
  ...resolvePhiMaskStyle(mask),
26
27
  } }), _jsx(Typography.Text, { style: { fontSize: 11, textAlign: "center" }, children: label })] }));
27
28
  }
28
- export function PhiMaskPickerControl({ value, open, buttonAriaLabel = "Select mask", buttonIcon = _jsx(PhiIcon, { name: "star", size: "inherit" }), placement = "bottomRight", mediaPickerProps, selectedIcon, uploading = false, uploadProgress = 0, popupRootClassName, getPopupContainer, onUploadFile, onIconSelect, onChange, onCommit, onDiscard, onOpenChange, }) {
29
+ export function PhiMaskPickerControl({ value, open, buttonAriaLabel, buttonIcon = _jsx(PhiIcon, { name: "star", size: "inherit" }), placement = "bottomRight", mediaPickerProps, selectedIcon, uploading = false, uploadProgress = 0, popupRootClassName, getPopupContainer, onUploadFile, onIconSelect, labels = PHI_MASK_PICKER_CONTROL_DEFAULT_LABELS, iconPickerLabels, onChange, onCommit, onDiscard, onOpenChange, }) {
30
+ const uploadingLabel = formatPhiMaskPickerLabel(labels.uploading, uploadProgress);
29
31
  const contentRef = useRef(null);
30
32
  const [mode, setMode] = useState(resolveInitialMode(value));
31
33
  const picker = usePhiImmediatePicker({
@@ -49,32 +51,32 @@ export function PhiMaskPickerControl({ value, open, buttonAriaLabel = "Select ma
49
51
  });
50
52
  };
51
53
  const popupContainer = (triggerNode) => contentRef.current ?? triggerNode.parentElement ?? document.body;
52
- const content = (_jsx("div", { ref: contentRef, style: { width: 360, maxWidth: "calc(100vw - (var(--phi-padding-lg) * 2))" }, onClick: (event) => event.stopPropagation(), onMouseDown: (event) => event.stopPropagation(), onPointerDown: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: _jsxs(Flex, { vertical: true, gap: "var(--phi-padding-sm)", children: [_jsxs(Flex, { align: "center", justify: "space-between", gap: "var(--phi-padding-sm)", children: [_jsx(Typography.Text, { strong: true, children: "Mask" }), _jsx(PhiButtonControl, { size: "small", type: "text", danger: true, icon: _jsx(PhiIcon, { name: "delete", size: "inherit" }), ariaLabel: "Clear mask", onClick: () => picker.changeValue(undefined) })] }), _jsx(PhiSegmentedControl, { block: true, value: mode, options: [
53
- { value: "preset", label: "Presets" },
54
- { value: "asset", label: "Media" },
54
+ const content = (_jsx("div", { ref: contentRef, style: { width: 360, maxWidth: "calc(100vw - (var(--phi-padding-lg) * 2))" }, onClick: (event) => event.stopPropagation(), onMouseDown: (event) => event.stopPropagation(), onPointerDown: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: _jsxs(Flex, { vertical: true, gap: "var(--phi-padding-sm)", children: [_jsxs(Flex, { align: "center", justify: "space-between", gap: "var(--phi-padding-sm)", children: [_jsx(Typography.Text, { strong: true, children: labels.title }), _jsx(PhiButtonControl, { size: "small", type: "text", danger: true, icon: _jsx(PhiIcon, { name: "delete", size: "inherit" }), ariaLabel: labels.clear, onClick: () => picker.changeValue(undefined) })] }), _jsx(PhiSegmentedControl, { block: true, value: mode, options: [
55
+ { value: "preset", label: labels.modePresets },
56
+ { value: "asset", label: labels.modeMedia },
55
57
  ], onChange: setMode }), mode === "preset" ? (_jsx("div", { style: {
56
58
  display: "grid",
57
59
  gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
58
60
  gap: "var(--phi-padding-sm)",
59
- }, children: PHI_MASK_PRESET_OPTIONS.map((preset) => {
60
- const selected = resolvedMask.source !== "asset" && resolvedMask.preset === preset.value;
61
- return (_jsx(PhiButtonControl, { type: selected ? "primary" : "default", style: { height: "auto", padding: "var(--phi-padding-xs)" }, onClick: () => selectPreset(preset.value), label: renderMaskPreview({
61
+ }, children: PHI_MASK_PRESET_VALUES.map((preset) => {
62
+ const selected = resolvedMask.source !== "asset" && resolvedMask.preset === preset;
63
+ return (_jsx(PhiButtonControl, { type: selected ? "primary" : "default", style: { height: "auto", padding: "var(--phi-padding-xs)" }, onClick: () => selectPreset(preset), label: renderMaskPreview({
62
64
  ...resolvedMask,
63
65
  enabled: true,
64
66
  source: "preset",
65
- preset: preset.value,
66
- }, preset.label, selected) }, preset.value));
67
- }) })) : null, mode === "asset" ? (_jsxs(Flex, { vertical: true, gap: "var(--phi-padding-xs)", children: [_jsx(PhiMediaPickerControl, { ...mediaPickerProps, getPopupContainer: popupContainer, popupRootClassName: popupRootClassName, trigger: _jsx("span", { style: { display: "block" }, children: _jsx(PhiButtonControl, { block: true, label: "Select mask asset", onClick: () => undefined }) }) }), _jsx(PhiFileDropControl, { accept: ".svg,.png,image/svg+xml,image/png", onFile: (file) => onUploadFile?.(file), disabled: uploading, style: { width: "100%" }, children: _jsx("span", { style: { display: "block", width: "100%" }, children: _jsx(PhiButtonControl, { block: true, icon: _jsx(PhiIcon, { name: "upload", size: "inherit" }), loading: uploading, label: uploading ? `Uploading ${uploadProgress}%` : "Upload SVG or PNG mask", onClick: () => undefined }) }) }), _jsx(PhiIconPickerControl, { value: selectedIcon, onChange: onIconSelect, disabled: uploading, buttonAriaLabel: "Select Iconify mask", buttonIcon: selectedIcon ? _jsx(PhiIcon, { name: selectedIcon, size: 16 }) : _jsx(PhiIcon, { name: "star", size: "inherit" }), buttonLabel: uploading ? `Uploading ${uploadProgress}%` : "Select Iconify icon", buttonType: "default", buttonSize: "medium", buttonBlock: true, buttonStyle: { width: "100%" }, getPopupContainer: popupContainer, rootClassName: popupRootClassName })] })) : null, [
68
- ["Scale", Math.round((resolvedMask.scale ?? 1) * 100), 25, 200, "%", (next) => patchMask({ scale: next / 100 })],
69
- ["Offset X", resolvedMask.offsetX ?? 0, -100, 100, "%", (next) => patchMask({ offsetX: next })],
70
- ["Offset Y", resolvedMask.offsetY ?? 0, -100, 100, "%", (next) => patchMask({ offsetY: next })],
71
- ["Rotation", resolvedMask.rotationDeg ?? 0, -180, 180, "deg", (next) => patchMask({ rotationDeg: next })],
67
+ preset,
68
+ }, labels.presets[preset], selected) }, preset));
69
+ }) })) : null, mode === "asset" ? (_jsxs(Flex, { vertical: true, gap: "var(--phi-padding-xs)", children: [_jsx(PhiMediaPickerControl, { ...mediaPickerProps, getPopupContainer: popupContainer, popupRootClassName: popupRootClassName, trigger: _jsx("span", { style: { display: "block" }, children: _jsx(PhiButtonControl, { block: true, label: labels.selectAsset, onClick: () => undefined }) }) }), _jsx(PhiFileDropControl, { accept: ".svg,.png,image/svg+xml,image/png", onFile: (file) => onUploadFile?.(file), disabled: uploading, style: { width: "100%" }, children: _jsx("span", { style: { display: "block", width: "100%" }, children: _jsx(PhiButtonControl, { block: true, icon: _jsx(PhiIcon, { name: "upload", size: "inherit" }), loading: uploading, label: uploading ? uploadingLabel : labels.upload, onClick: () => undefined }) }) }), _jsx(PhiIconPickerControl, { value: selectedIcon, onChange: onIconSelect, disabled: uploading, buttonAriaLabel: labels.selectIconify, buttonIcon: selectedIcon ? _jsx(PhiIcon, { name: selectedIcon, size: 16 }) : _jsx(PhiIcon, { name: "star", size: "inherit" }), buttonLabel: uploading ? uploadingLabel : labels.iconifyButton, labels: iconPickerLabels, buttonType: "default", buttonSize: "medium", buttonBlock: true, buttonStyle: { width: "100%" }, getPopupContainer: popupContainer, rootClassName: popupRootClassName })] })) : null, [
70
+ [labels.scale, Math.round((resolvedMask.scale ?? 1) * 100), 25, 200, "%", (next) => patchMask({ scale: next / 100 })],
71
+ [labels.offsetX, resolvedMask.offsetX ?? 0, -100, 100, "%", (next) => patchMask({ offsetX: next })],
72
+ [labels.offsetY, resolvedMask.offsetY ?? 0, -100, 100, "%", (next) => patchMask({ offsetY: next })],
73
+ [labels.rotation, resolvedMask.rotationDeg ?? 0, -180, 180, "deg", (next) => patchMask({ rotationDeg: next })],
72
74
  ].map(([label, sliderValue, min, max, suffix, change]) => (_jsxs(Flex, { vertical: true, gap: 4, children: [_jsxs(Flex, { align: "center", justify: "space-between", children: [_jsx(Typography.Text, { type: "secondary", children: label }), _jsxs(Typography.Text, { type: "secondary", children: [sliderValue, suffix] })] }), _jsx(PhiSliderControl, { min: min, max: max, tooltipMode: "hidden", value: sliderValue, onChange: change })] }, label)))] }) }));
73
75
  return (_jsx(PhiPopoverControl, { open: picker.open, content: content, placement: placement, destroyOnHidden: false, rootClassName: popupRootClassName, getPopupContainer: getPopupContainer, onOpenChange: (nextOpen) => {
74
76
  if (nextOpen)
75
77
  setMode(resolveInitialMode(value));
76
78
  picker.handleOpenChange(nextOpen);
77
- }, children: _jsx("span", { style: { display: "inline-flex" }, children: _jsx(PhiButtonControl, { type: "text", size: "small", icon: buttonIcon, ariaLabel: buttonAriaLabel, style: { width: 24, minWidth: 24, height: 24, padding: 0 }, onClick: () => {
79
+ }, children: _jsx("span", { style: { display: "inline-flex" }, children: _jsx(PhiButtonControl, { type: "text", size: "small", icon: buttonIcon, ariaLabel: buttonAriaLabel ?? labels.button, style: { width: 24, minWidth: 24, height: 24, padding: 0 }, onClick: () => {
78
80
  if (picker.open)
79
81
  picker.closePicker("commit");
80
82
  else
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { PhisMediaSourceItem } from "@phis/contracts/media-source";
2
3
  import type { PhiMediaAssetTile } from "../../types/media";
3
4
  import type { PhiControlOption } from "./phi-control-options";
4
5
  import type { PhiPickerPlacement, PhiPickerTransactionCallbacks } from "./phi-picker-control-contract";
@@ -12,6 +13,22 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
12
13
  */
13
14
  spaces?: readonly PhiControlOption[];
14
15
  spaceValue?: string | null;
16
+ /**
17
+ * The places a file can be chosen from: the Site's library first, then each media source. Empty
18
+ * unless there is a source to choose and the picker stands on the Site Space, so a picker without
19
+ * one never renders the switch.
20
+ */
21
+ sources?: readonly PhiControlOption[];
22
+ /** Which of `sources` is shown; `""` is the Site's library. */
23
+ sourceValue?: string;
24
+ /** What the source offers, in the order it answered; drawn instead of the library's tiles. */
25
+ sourceItems?: readonly PhisMediaSourceItem[];
26
+ /** Whether the source has a further page, which "Load more" asks for. */
27
+ sourceHasMore?: boolean;
28
+ /** The item whose import is in flight, if any. */
29
+ importingItemId?: string | null;
30
+ /** Why the last import did not work, said above the tiles. */
31
+ sourceNotice?: string | null;
15
32
  folders?: readonly PhiControlOption[];
16
33
  folderValue?: string;
17
34
  query?: string;
@@ -36,17 +53,29 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
36
53
  folder: string;
37
54
  space: string;
38
55
  empty: string;
56
+ /** What an empty or failed source says, where the library's `empty` would be the wrong words. */
57
+ sourceEmpty: string;
39
58
  clear: string;
40
59
  reload: string;
41
60
  tileSize: string;
61
+ source: string;
62
+ importing: string;
63
+ loadMore: string;
42
64
  }>;
43
65
  getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
44
66
  popupRootClassName?: string;
45
67
  onQueryChange?: (query: string) => void;
46
68
  onSpaceChange?: (space: string) => void;
69
+ onSourceChange?: (source: string) => void;
70
+ /**
71
+ * An item was chosen. Answers the Asset it became -- chosen then as if it had been picked in the
72
+ * library -- or null where nothing was imported and the picker stays as it is.
73
+ */
74
+ onSourceItemSelect?: (item: PhisMediaSourceItem) => Promise<PhiMediaAssetTile | null>;
75
+ onSourceLoadMore?: () => void;
47
76
  onFolderChange?: (folder: string) => void;
48
77
  onPageChange?: (page: number, pageSize: number) => void;
49
78
  onMinColumnWidthChange?: (minColumnWidth: number) => void;
50
79
  onReload?: () => void;
51
80
  };
52
- export declare function PhiMediaPickerControl({ open, value, assets, spaces, spaceValue, folders, folderValue, query, page, pageSize, total, minColumnWidth, loading, disabled, readOnly, placement, showSearchBar, showFolderFilter, showPagination, trigger, isAssetSelectable, labels, getPopupContainer, popupRootClassName, onOpenChange, onQueryChange, onSpaceChange, onFolderChange, onPageChange, onMinColumnWidthChange, onReload, onChange, onCommit, onDiscard, }: PhiMediaPickerControlProps): import("react").JSX.Element;
81
+ export declare function PhiMediaPickerControl({ open, value, assets, spaces, spaceValue, sources, sourceValue, sourceItems, sourceHasMore, importingItemId, sourceNotice, folders, folderValue, query, page, pageSize, total, minColumnWidth, loading, disabled, readOnly, placement, showSearchBar, showFolderFilter, showPagination, trigger, isAssetSelectable, labels, getPopupContainer, popupRootClassName, onOpenChange, onQueryChange, onSpaceChange, onSourceChange, onSourceItemSelect, onSourceLoadMore, onFolderChange, onPageChange, onMinColumnWidthChange, onReload, onChange, onCommit, onDiscard, }: PhiMediaPickerControlProps): import("react").JSX.Element;
@@ -8,6 +8,7 @@ import { PhiEmptyControl } from "./phi-empty-control";
8
8
  import { PhiSelectControl } from "./phi-select-control";
9
9
  import { PhiCollectionLayoutControl } from "./phi-collection-layout-control";
10
10
  import { PhiMediaAssetCollectionSkeletonControl, PhiMediaAssetTileControl, } from "./phi-media-asset-tile-control";
11
+ import { PhiMediaSourceItemTileControl } from "./phi-media-source-item-tile-control";
11
12
  import { PHI_MEDIA_PICKER_COLUMN_WIDTH_STEP, PHI_MEDIA_PICKER_DEFAULT_COLUMN_WIDTH, PHI_MEDIA_PICKER_MAX_COLUMN_WIDTH, PHI_MEDIA_PICKER_MIN_COLUMN_WIDTH, normalizePhiMediaPickerMinColumnWidth, } from "./phi-media-picker-control-contract";
12
13
  import { PhiPaginationControl } from "./phi-pagination-control";
13
14
  import { PhiPopoverControl } from "./phi-popover-control";
@@ -15,7 +16,7 @@ import { PhiSliderControl } from "./phi-slider-control";
15
16
  import { PhiTextControl } from "./phi-text-control";
16
17
  import { usePhiImmediatePicker } from "./use-phi-immediate-picker";
17
18
  import { PhiIcon } from "../shell/phi-icon";
18
- export function PhiMediaPickerControl({ open, value = null, assets, spaces = [], spaceValue = null, folders = [], folderValue = "/", query = "", page = 1, pageSize = 20, total = assets.length, minColumnWidth = PHI_MEDIA_PICKER_DEFAULT_COLUMN_WIDTH, loading, disabled, readOnly, placement = "left", showSearchBar = true, showFolderFilter = true, showPagination = true, trigger, isAssetSelectable, labels, getPopupContainer, popupRootClassName, onOpenChange, onQueryChange, onSpaceChange, onFolderChange, onPageChange, onMinColumnWidthChange, onReload, onChange, onCommit, onDiscard, }) {
19
+ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [], spaceValue = null, sources = [], sourceValue = "", sourceItems = [], sourceHasMore = false, importingItemId = null, sourceNotice = null, folders = [], folderValue = "/", query = "", page = 1, pageSize = 20, total = assets.length, minColumnWidth = PHI_MEDIA_PICKER_DEFAULT_COLUMN_WIDTH, loading, disabled, readOnly, placement = "left", showSearchBar = true, showFolderFilter = true, showPagination = true, trigger, isAssetSelectable, labels, getPopupContainer, popupRootClassName, onOpenChange, onQueryChange, onSpaceChange, onSourceChange, onSourceItemSelect, onSourceLoadMore, onFolderChange, onPageChange, onMinColumnWidthChange, onReload, onChange, onCommit, onDiscard, }) {
19
20
  const { token } = usePhiConfig();
20
21
  const locked = disabled || readOnly;
21
22
  const resolvedMinColumnWidth = normalizePhiMediaPickerMinColumnWidth(minColumnWidth);
@@ -29,6 +30,17 @@ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [],
29
30
  onOpenChange,
30
31
  });
31
32
  const selected = assets.find((asset) => asset.id === picker.value) ?? null;
33
+ // A source is shown while one other than the library is named; its items stand where the tiles do.
34
+ const sourceActive = sources.length > 1 && sourceValue !== "";
35
+ const importing = importingItemId != null;
36
+ const sourceTileItems = sourceItems.map((item) => (_jsx(PhiMediaSourceItemTileControl, { title: item.title, thumbnailUrl: item.thumbnailUrl, credit: item.credit, minColumnWidth: resolvedMinColumnWidth, busy: importingItemId === item.id, busyLabel: labels?.importing, disabled: locked || importing, onSelect: () => {
37
+ void onSourceItemSelect?.(item).then((asset) => {
38
+ if (!asset)
39
+ return;
40
+ picker.changeValue(asset.id);
41
+ picker.closePicker("commit");
42
+ });
43
+ } }, item.id)));
32
44
  const tileItems = assets.map((asset) => (_jsx(PhiMediaAssetTileControl, { asset: asset, minColumnWidth: resolvedMinColumnWidth, selected: asset.id === picker.value, size: "small", disabled: locked || (isAssetSelectable != null && !isAssetSelectable(asset)), showTypeLabel: false, showDeleteAction: false, showDimensions: false, showIdLabel: false, onSelect: (nextAsset) => {
33
45
  picker.changeValue(nextAsset.id);
34
46
  picker.closePicker("commit");
@@ -38,6 +50,7 @@ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [],
38
50
  height: "min(480px, calc(100dvh - 48px))",
39
51
  minHeight: 0,
40
52
  }, children: [_jsx(Typography.Text, { strong: true, children: labels?.title ?? "Select media" }), _jsxs(Flex, { gap: token.paddingSM, align: "center", wrap: true, children: [showSearchBar ? (_jsx("div", { style: { flex: "1 1 220px" }, children: _jsx(PhiTextControl, { inputType: "search", value: query, size: "small", placeholder: labels?.search ?? "Search", disabled: locked, onChange: (next) => onQueryChange?.(next ?? "") }) })) : null, spaces.length > 1 ? (_jsx("div", { style: { flex: "0 1 160px" }, children: _jsx(PhiSelectControl, { value: spaceValue ?? undefined, options: spaces, size: "small", placeholder: labels?.space ?? "Space", disabled: locked, getPopupContainer: getPopupContainer, popupRootClassName: popupRootClassName, onChange: (next) => { if (typeof next === "string" && next)
41
- onSpaceChange?.(next); } }) })) : null, showFolderFilter ? (_jsx("div", { style: { flex: "1 1 180px" }, children: _jsx(PhiCascaderControl, { value: folderValue, options: folders, allowRoot: true, rootValue: "/", separator: "/", size: "small", placeholder: labels?.folder ?? "Folder", disabled: locked, getPopupContainer: getPopupContainer, classNames: popupRootClassName ? { popup: { root: popupRootClassName } } : undefined, onChange: (next) => onFolderChange?.(next ?? "/") }) })) : null, _jsx(PhiButtonControl, { ariaLabel: labels?.reload ?? "Reload", tooltip: labels?.reload ?? "Reload", icon: _jsx(PhiIcon, { name: "reload", size: "inherit" }), size: "small", disabled: locked, onClick: onReload })] }), _jsx("div", { style: { flex: "1 1 auto", minHeight: 0, overflow: "auto" }, children: loading && assets.length === 0 ? (_jsx(PhiMediaAssetCollectionSkeletonControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: resolvedMinColumnWidth, count: Math.min(pageSize, 12), size: "small" })) : assets.length === 0 ? (_jsx(PhiEmptyControl, { description: labels?.empty ?? "No media" })) : (_jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: resolvedMinColumnWidth, items: tileItems })) }), _jsxs(Flex, { align: "center", gap: token.paddingSM, style: { flex: "0 0 auto", minWidth: 0 }, children: [_jsx(Typography.Text, { type: "secondary", ellipsis: true, style: { flex: "0 1 180px", minWidth: 0 }, children: selected?.title || selected?.originalName || "" }), _jsxs(Flex, { align: "center", gap: token.paddingXS, style: { flex: "1 1 160px", minWidth: 120 }, children: [_jsx(PhiSliderControl, { ariaLabel: labels?.tileSize ?? "Tile size", value: resolvedMinColumnWidth, min: PHI_MEDIA_PICKER_MIN_COLUMN_WIDTH, max: PHI_MEDIA_PICKER_MAX_COLUMN_WIDTH, step: PHI_MEDIA_PICKER_COLUMN_WIDTH_STEP, tooltipSuffix: " px", disabled: locked, style: { flex: "1 1 auto", minWidth: 0 }, onChange: onMinColumnWidthChange }), _jsxs(Typography.Text, { type: "secondary", style: { fontSize: token.fontSizeSM, whiteSpace: "nowrap" }, children: [resolvedMinColumnWidth, "px"] })] }), _jsx(PhiButtonControl, { label: labels?.clear ?? "Clear", size: "small", disabled: locked || picker.value == null, onClick: () => picker.changeValue(null) }), showPagination ? (_jsx(PhiPaginationControl, { page: page, pageSize: pageSize, total: total, size: "small", disabled: locked, showSizeChanger: true, getPopupContainer: getPopupContainer, popupRootClassName: popupRootClassName, onChange: (next) => onPageChange?.(next.page, next.pageSize) })) : null] })] }));
53
+ onSpaceChange?.(next); } }) })) : null, sources.length > 1 ? (_jsx("div", { style: { flex: "0 1 160px" }, children: _jsx(PhiSelectControl, { value: sourceValue, options: sources, size: "small", ariaLabel: labels?.source ?? "Source", placeholder: labels?.source ?? "Source", disabled: locked || importing, getPopupContainer: getPopupContainer, popupRootClassName: popupRootClassName, onChange: (next) => { if (typeof next === "string")
54
+ onSourceChange?.(next); } }) })) : null, showFolderFilter ? (_jsx("div", { style: { flex: "1 1 180px" }, children: _jsx(PhiCascaderControl, { value: folderValue, options: folders, allowRoot: true, rootValue: "/", separator: "/", size: "small", placeholder: labels?.folder ?? "Folder", disabled: locked, getPopupContainer: getPopupContainer, classNames: popupRootClassName ? { popup: { root: popupRootClassName } } : undefined, onChange: (next) => onFolderChange?.(next ?? "/") }) })) : null, _jsx(PhiButtonControl, { ariaLabel: labels?.reload ?? "Reload", tooltip: labels?.reload ?? "Reload", icon: _jsx(PhiIcon, { name: "reload", size: "inherit" }), size: "small", disabled: locked, onClick: onReload })] }), sourceActive && sourceNotice ? (_jsx(Typography.Text, { type: "danger", role: "alert", children: sourceNotice })) : null, _jsx("div", { style: { flex: "1 1 auto", minHeight: 0, overflow: "auto" }, children: sourceActive ? (loading && sourceItems.length === 0 ? (_jsx(PhiMediaAssetCollectionSkeletonControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: resolvedMinColumnWidth, count: Math.min(pageSize, 12), size: "small" })) : sourceItems.length === 0 ? (_jsx(PhiEmptyControl, { description: labels?.sourceEmpty ?? labels?.empty ?? "No media" })) : (_jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: resolvedMinColumnWidth, items: sourceTileItems }))) : loading && assets.length === 0 ? (_jsx(PhiMediaAssetCollectionSkeletonControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: resolvedMinColumnWidth, count: Math.min(pageSize, 12), size: "small" })) : assets.length === 0 ? (_jsx(PhiEmptyControl, { description: labels?.empty ?? "No media" })) : (_jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: resolvedMinColumnWidth, items: tileItems })) }), _jsxs(Flex, { align: "center", gap: token.paddingSM, style: { flex: "0 0 auto", minWidth: 0 }, children: [_jsx(Typography.Text, { type: "secondary", ellipsis: true, style: { flex: "0 1 180px", minWidth: 0 }, children: selected?.title || selected?.originalName || "" }), _jsxs(Flex, { align: "center", gap: token.paddingXS, style: { flex: "1 1 160px", minWidth: 120 }, children: [_jsx(PhiSliderControl, { ariaLabel: labels?.tileSize ?? "Tile size", value: resolvedMinColumnWidth, min: PHI_MEDIA_PICKER_MIN_COLUMN_WIDTH, max: PHI_MEDIA_PICKER_MAX_COLUMN_WIDTH, step: PHI_MEDIA_PICKER_COLUMN_WIDTH_STEP, tooltipSuffix: " px", disabled: locked, style: { flex: "1 1 auto", minWidth: 0 }, onChange: onMinColumnWidthChange }), _jsxs(Typography.Text, { type: "secondary", style: { fontSize: token.fontSizeSM, whiteSpace: "nowrap" }, children: [resolvedMinColumnWidth, "px"] })] }), _jsx(PhiButtonControl, { label: labels?.clear ?? "Clear", size: "small", disabled: locked || picker.value == null, onClick: () => picker.changeValue(null) }), sourceActive ? (sourceHasMore ? (_jsx(PhiButtonControl, { label: labels?.loadMore ?? "Load more", size: "small", loading: loading, disabled: locked || importing, onClick: onSourceLoadMore })) : null) : showPagination ? (_jsx(PhiPaginationControl, { page: page, pageSize: pageSize, total: total, size: "small", disabled: locked, showSizeChanger: true, getPopupContainer: getPopupContainer, popupRootClassName: popupRootClassName, onChange: (next) => onPageChange?.(next.page, next.pageSize) })) : null] })] }));
42
55
  return (_jsx(PhiPopoverControl, { open: picker.open, content: content, placement: placement, disabled: locked, getPopupContainer: getPopupContainer, rootClassName: popupRootClassName, onOpenChange: picker.handleOpenChange, children: trigger ?? (_jsx("span", { children: _jsx(PhiButtonControl, { block: true, icon: _jsx(PhiIcon, { name: "picture", size: "inherit" }), label: labels?.trigger ?? "Select media", disabled: locked, onClick: picker.openPicker }) })) }));
43
56
  }
@@ -0,0 +1,22 @@
1
+ export type PhiMediaSourceItemTileControlProps = {
2
+ /** What the source calls the item; also what the picture says when it cannot be shown. */
3
+ title: string;
4
+ /** An absolute `https:` address of a small rendition, loaded by the browser straight from the source. */
5
+ thumbnailUrl: string;
6
+ credit?: string | null;
7
+ minColumnWidth: string | number;
8
+ /** Whether this tile's own import is in flight; the tile says so and refuses a second press. */
9
+ busy?: boolean;
10
+ busyLabel?: string;
11
+ disabled?: boolean;
12
+ onSelect?: () => void;
13
+ };
14
+ /**
15
+ * One thing a media source offers, drawn like an Asset's tile.
16
+ *
17
+ * The picture is a plain `<img>`, never `next/image` and never an address on this Site's server: the
18
+ * optimiser would make the Site's server fetch a foreign address, which is exactly what a source's
19
+ * thumbnail must not cause. The reader's browser loads it, lazily, and tells the source no more than the
20
+ * fact that somebody looked (`referrerPolicy`).
21
+ */
22
+ export declare function PhiMediaSourceItemTileControl({ title, thumbnailUrl, credit, minColumnWidth, busy, busyLabel, disabled, onSelect, }: PhiMediaSourceItemTileControlProps): import("react").JSX.Element;
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Flex, Typography } from "antd";
4
+ import { resolvePhiThemeBorderLine } from "../../helpers/border-widget-style";
5
+ import { usePhiConfig } from "../root/phi-config-provider";
6
+ import { PhiSpinControl } from "./phi-spin-control";
7
+ /**
8
+ * One thing a media source offers, drawn like an Asset's tile.
9
+ *
10
+ * The picture is a plain `<img>`, never `next/image` and never an address on this Site's server: the
11
+ * optimiser would make the Site's server fetch a foreign address, which is exactly what a source's
12
+ * thumbnail must not cause. The reader's browser loads it, lazily, and tells the source no more than the
13
+ * fact that somebody looked (`referrerPolicy`).
14
+ */
15
+ export function PhiMediaSourceItemTileControl({ title, thumbnailUrl, credit = null, minColumnWidth, busy = false, busyLabel, disabled = false, onSelect, }) {
16
+ const { token } = usePhiConfig();
17
+ const selectable = Boolean(onSelect) && !disabled && !busy;
18
+ const cardStyle = {
19
+ border: resolvePhiThemeBorderLine(token.colorBorderSecondary),
20
+ borderRadius: "var(--phi-surface-radius)",
21
+ overflow: "hidden",
22
+ padding: 0,
23
+ cursor: selectable ? "pointer" : "default",
24
+ background: token.colorBgContainer,
25
+ opacity: disabled ? 0.65 : undefined,
26
+ textAlign: "left",
27
+ width: "100%",
28
+ position: "relative",
29
+ isolation: "isolate",
30
+ minWidth: typeof minColumnWidth === "number" ? 0 : undefined,
31
+ };
32
+ return (_jsxs("div", { role: onSelect ? "button" : undefined, "aria-busy": busy || undefined, "aria-disabled": disabled || busy || undefined, tabIndex: selectable ? 0 : undefined, style: cardStyle, onClick: selectable ? onSelect : undefined, onKeyDown: selectable
33
+ ? (event) => {
34
+ if (event.key !== "Enter" && event.key !== " ")
35
+ return;
36
+ event.preventDefault();
37
+ onSelect?.();
38
+ }
39
+ : undefined, children: [_jsxs("div", { style: {
40
+ position: "relative",
41
+ width: "100%",
42
+ aspectRatio: "1 / 1",
43
+ background: token.colorFillTertiary,
44
+ overflow: "hidden",
45
+ }, children: [_jsx("img", { alt: title, src: thumbnailUrl, loading: "lazy", referrerPolicy: "no-referrer", style: { position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover" } }), busy ? (_jsxs(Flex, { vertical: true, align: "center", justify: "center", gap: token.paddingXXS, style: { position: "absolute", inset: 0, zIndex: 2, background: token.colorBgMask }, children: [_jsx(PhiSpinControl, { size: "small" }), busyLabel ? (_jsx(Typography.Text, { style: { color: token.colorTextLightSolid, fontSize: token.fontSizeSM }, children: busyLabel })) : null] })) : null, _jsx("div", { style: {
46
+ position: "absolute",
47
+ zIndex: 1,
48
+ right: 0,
49
+ bottom: 0,
50
+ left: 0,
51
+ paddingBlock: token.paddingXXS,
52
+ paddingInline: token.paddingXS,
53
+ background: token.colorBgMask,
54
+ }, children: _jsx(Typography.Text, { strong: true, ellipsis: true, title: title, style: {
55
+ display: "block",
56
+ color: token.colorTextLightSolid,
57
+ fontSize: token.fontSizeSM,
58
+ lineHeight: 1,
59
+ }, children: title }) })] }), credit ? (_jsx(Typography.Text, { type: "secondary", ellipsis: { tooltip: credit }, style: {
60
+ display: "block",
61
+ paddingBlock: token.paddingXXS,
62
+ paddingInline: token.paddingXS,
63
+ fontSize: token.fontSizeSM,
64
+ }, children: credit })) : null] }));
65
+ }
@@ -3,12 +3,26 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Segmented } from "antd";
4
4
  import { PHI_THEME_GRADIENT_CSS_VARS } from "../../theme/phi-theme-gradients";
5
5
  import { PhiLabeledControl, usePhiControlLabel } from "./phi-labeled-control";
6
+ import { PhiTruncatedHoverText } from "./phi-truncated-hover-text";
7
+ /* The segment's own box cuts its words: the hover text measures this element and nothing around it. */
8
+ const PHI_SEGMENT_LABEL_STYLE = {
9
+ display: "block",
10
+ overflow: "hidden",
11
+ textOverflow: "ellipsis",
12
+ whiteSpace: "nowrap",
13
+ };
6
14
  export function PhiSegmentedControl({ value, label, options, disabled, readOnly, block, size, gradient, onFocus, onBlur, onChange, }) {
7
15
  const { labelId, labelledBy } = usePhiControlLabel(label);
8
16
  const gradientVars = gradient ? PHI_THEME_GRADIENT_CSS_VARS[gradient] : null;
9
17
  const control = (_jsx(Segmented, { "aria-labelledby": labelledBy, block: block, value: value, disabled: disabled || readOnly || !onChange, options: options.map((option) => ({
10
18
  value: option.value,
11
- label: option.label,
19
+ /*
20
+ * A segment too narrow for its words shows them whole in the house tooltip, and only then. A
21
+ * segment with a description says that instead, which is more than its label.
22
+ */
23
+ label: option.description
24
+ ? option.label
25
+ : (_jsx(PhiTruncatedHoverText, { title: option.label, children: _jsx("span", { style: PHI_SEGMENT_LABEL_STYLE, children: option.label }) })),
12
26
  disabled: option.disabled,
13
27
  /*
14
28
  * No browser tooltip: left out, the Segmented writes the label into `title` and every segment
@@ -0,0 +1,19 @@
1
+ import "server-only";
2
+ import type { PhiFormDescriptor } from "../../types/form-descriptor";
3
+ import type { PhiFormRenderContext } from "./form-resolution";
4
+ /**
5
+ * What a Form's field types say for themselves, under the keys their controls read.
6
+ *
7
+ * The `media-asset` field is the same: the picker it opens says the Media Label Set's words, read here
8
+ * for every Form that has such a field (`media-asset-field-keys.ts`).
9
+ *
10
+ * A field type whose control speaks -- the upload field's trigger, its drop hint, its holds and the
11
+ * refusals of the upload -- says it from Core's `widget:upload` Label Set, read here for every Form that
12
+ * has such a field. So a Module that places an upload field translates none of it, and no Form says it
13
+ * in English because it forgot to. The Form Widget lays the Form's own Label Set over this, so a Form
14
+ * that means different words for its field still says them.
15
+ *
16
+ * Beside the Form resolution rather than inside it: only the Form Widget draws fields, and the resolution
17
+ * is part of the `@phis/ui/forms` entry, whose graph has no business carrying the translator.
18
+ */
19
+ export declare function resolvePhiFormFieldLabels(context: PhiFormRenderContext, descriptor: PhiFormDescriptor): Promise<Record<string, string>>;
@@ -0,0 +1,78 @@
1
+ import "server-only";
2
+ import { getPhiMediaWidgetLabels } from "../media/label-sets/media";
3
+ import { getPhiMediaUploadLabels } from "../media/label-sets/media-upload";
4
+ import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY } from "../../constants/media-library-provider-keys";
5
+ import { phiRuntime } from "../../server-helpers/phi-runtime";
6
+ import { PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS } from "./media-asset-field-keys";
7
+ import { PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY, PHI_FORM_UPLOAD_LABEL_KEYS } from "./upload-field-keys";
8
+ /**
9
+ * What a Form's field types say for themselves, under the keys their controls read.
10
+ *
11
+ * The `media-asset` field is the same: the picker it opens says the Media Label Set's words, read here
12
+ * for every Form that has such a field (`media-asset-field-keys.ts`).
13
+ *
14
+ * A field type whose control speaks -- the upload field's trigger, its drop hint, its holds and the
15
+ * refusals of the upload -- says it from Core's `widget:upload` Label Set, read here for every Form that
16
+ * has such a field. So a Module that places an upload field translates none of it, and no Form says it
17
+ * in English because it forgot to. The Form Widget lays the Form's own Label Set over this, so a Form
18
+ * that means different words for its field still says them.
19
+ *
20
+ * Beside the Form resolution rather than inside it: only the Form Widget draws fields, and the resolution
21
+ * is part of the `@phis/ui/forms` entry, whose graph has no business carrying the translator.
22
+ */
23
+ export async function resolvePhiFormFieldLabels(context, descriptor) {
24
+ const hasUpload = descriptor.fields.some((field) => field.fieldProviderKey === PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY);
25
+ const hasMediaAsset = descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY);
26
+ if (!hasUpload && !hasMediaAsset)
27
+ return {};
28
+ const rt = phiRuntime(context.runtime);
29
+ const options = {
30
+ apiBaseUrl: rt.apiBaseUrl,
31
+ internalToken: rt.internalToken,
32
+ locale: context.runtime.locale.current,
33
+ };
34
+ const [upload, media] = await Promise.all([
35
+ hasUpload ? readUploadFieldLabels(options) : {},
36
+ hasMediaAsset ? readMediaAssetFieldLabels(options) : {},
37
+ ]);
38
+ return { ...upload, ...media };
39
+ }
40
+ async function readUploadFieldLabels(options) {
41
+ const { field, refusals } = await getPhiMediaUploadLabels(options);
42
+ const keys = PHI_FORM_UPLOAD_LABEL_KEYS;
43
+ return {
44
+ [keys.trigger]: field.trigger,
45
+ [keys.dropHint]: field.dropHint,
46
+ [keys.tooMany]: field.tooMany,
47
+ [keys.pending]: field.pending,
48
+ [keys.errorGeneric]: refusals.errorGeneric,
49
+ [keys.errorNetwork]: refusals.errorNetwork,
50
+ [keys.errorTooLarge]: refusals.errorTooLarge,
51
+ [keys.errorDuplicate]: refusals.errorDuplicate,
52
+ [keys.errorTypeNotAllowed]: refusals.errorTypeNotAllowed,
53
+ [keys.errorQuotaExceeded]: refusals.errorQuotaExceeded,
54
+ [keys.errorSpaceUnavailable]: refusals.errorSpaceUnavailable,
55
+ [keys.errorStorageUnreachable]: refusals.errorStorageUnreachable,
56
+ [keys.errorFolderLocked]: refusals.errorFolderLocked,
57
+ };
58
+ }
59
+ async function readMediaAssetFieldLabels(options) {
60
+ const { tool, picker, space } = await getPhiMediaWidgetLabels(options);
61
+ const keys = PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS;
62
+ return {
63
+ [keys.popoverTitle]: picker.popoverTitle,
64
+ [keys.searchPlaceholder]: tool.searchPlaceholder,
65
+ [keys.folderLabel]: tool.folderLabel,
66
+ [keys.spaceLabel]: space.label,
67
+ [keys.emptyDescription]: picker.emptyDescription,
68
+ [keys.loadFailedDescription]: picker.loadFailedDescription,
69
+ [keys.clearLabel]: picker.clearLabel,
70
+ [keys.reloadLabel]: tool.reloadLabel,
71
+ [keys.tileSizeLabel]: picker.tileSizeLabel,
72
+ [keys.sourceLabel]: picker.sourceLabel,
73
+ [keys.sourceFailedText]: picker.sourceFailedText,
74
+ [keys.importingLabel]: picker.importingLabel,
75
+ [keys.importFailedText]: picker.importFailedText,
76
+ [keys.loadMoreLabel]: picker.loadMoreLabel,
77
+ };
78
+ }
@@ -90,23 +90,7 @@ export declare const PHI_FORM_LINK_TARGET_LABEL_KEYS: {
90
90
  */
91
91
  export declare const PHI_FORM_FIELD_UNAVAILABLE_LABEL_KEY = "fieldUnavailable";
92
92
  export declare const PHI_FORM_FIELD_UNAVAILABLE_DEFAULT_LABEL = "This field is not available in this area.";
93
- export declare const PHI_FORM_UPLOAD_LABEL_KEYS: {
94
- readonly trigger: "uploadTrigger";
95
- /** Beneath the trigger in an upload area (`config.presentation: "area"`): that a drop works too. */
96
- readonly dropHint: "uploadDropHint";
97
- readonly tooMany: "uploadErrorTooMany";
98
- /** Shown on the field when the Form is submitted while a file is still on its way. */
99
- readonly pending: "uploadPending";
100
- readonly errorGeneric: "uploadErrorGeneric";
101
- readonly errorNetwork: "uploadErrorNetwork";
102
- readonly errorTooLarge: "uploadErrorTooLarge";
103
- readonly errorDuplicate: "uploadErrorDuplicate";
104
- readonly errorTypeNotAllowed: "uploadErrorTypeNotAllowed";
105
- readonly errorQuotaExceeded: "uploadErrorQuotaExceeded";
106
- readonly errorSpaceUnavailable: "uploadErrorSpaceUnavailable";
107
- readonly errorStorageUnreachable: "uploadErrorStorageUnreachable";
108
- readonly errorFolderLocked: "uploadErrorFolderLocked";
109
- };
93
+ export { PHI_FORM_UPLOAD_LABEL_KEYS } from "./upload-field-keys";
110
94
  export type PhiSharedFormFieldTypeDescriptor = Omit<PhiFormFieldTypeProviderDescriptor, "ownerModuleId">;
111
95
  export type PhiSharedFormValidationDescriptor = Omit<PhiFormValidationProviderDescriptor, "ownerModuleId">;
112
96
  export declare const PHI_SHARED_FORM_FIELD_TYPE_PROVIDER_DESCRIPTORS: readonly [{
@@ -1,6 +1,7 @@
1
1
  import { createPhiModuleScopedKey } from "../../constants/runtime-module-ownership";
2
2
  import { PhiMediaKind } from "../../constants/media";
3
3
  import { PHIS_PAYMENT_CURRENCY_EXPONENTS } from "@phis/contracts/payments";
4
+ import { PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY } from "./upload-field-keys";
4
5
  export function createPhiSharedFormProviderKey(kind, key) {
5
6
  const normalizedKey = key.trim();
6
7
  if (!normalizedKey || normalizedKey.includes("/") || normalizedKey.includes(":")) {
@@ -30,7 +31,8 @@ export const PHI_FORM_FIELD_PROVIDER_KEYS = {
30
31
  cascader: createPhiSharedFormProviderKey("field", "cascader"),
31
32
  table: createPhiSharedFormProviderKey("field", "table"),
32
33
  tree: createPhiSharedFormProviderKey("field", "tree"),
33
- upload: createPhiSharedFormProviderKey("field", "upload"),
34
+ // Spelled beside its label keys, which the Form Widget reads on the Server without this whole file.
35
+ upload: PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY,
34
36
  linkTarget: createPhiSharedFormProviderKey("field", "link-target"),
35
37
  money: createPhiSharedFormProviderKey("field", "money"),
36
38
  };
@@ -98,23 +100,7 @@ export const PHI_FORM_LINK_TARGET_LABEL_KEYS = {
98
100
  */
99
101
  export const PHI_FORM_FIELD_UNAVAILABLE_LABEL_KEY = "fieldUnavailable";
100
102
  export const PHI_FORM_FIELD_UNAVAILABLE_DEFAULT_LABEL = "This field is not available in this area.";
101
- export const PHI_FORM_UPLOAD_LABEL_KEYS = {
102
- trigger: "uploadTrigger",
103
- /** Beneath the trigger in an upload area (`config.presentation: "area"`): that a drop works too. */
104
- dropHint: "uploadDropHint",
105
- tooMany: "uploadErrorTooMany",
106
- /** Shown on the field when the Form is submitted while a file is still on its way. */
107
- pending: "uploadPending",
108
- errorGeneric: "uploadErrorGeneric",
109
- errorNetwork: "uploadErrorNetwork",
110
- errorTooLarge: "uploadErrorTooLarge",
111
- errorDuplicate: "uploadErrorDuplicate",
112
- errorTypeNotAllowed: "uploadErrorTypeNotAllowed",
113
- errorQuotaExceeded: "uploadErrorQuotaExceeded",
114
- errorSpaceUnavailable: "uploadErrorSpaceUnavailable",
115
- errorStorageUnreachable: "uploadErrorStorageUnreachable",
116
- errorFolderLocked: "uploadErrorFolderLocked",
117
- };
103
+ export { PHI_FORM_UPLOAD_LABEL_KEYS } from "./upload-field-keys";
118
104
  /** Every currency a payment accepts, by its ISO 4217 code, for the money field's settings. */
119
105
  const PHI_MONEY_CURRENCY_OPTIONS = Object.keys(PHIS_PAYMENT_CURRENCY_EXPONENTS)
120
106
  .sort()
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The `media-asset` field's picker words, under the keys its control reads them from.
3
+ *
4
+ * The field opens the Media library's own picker, and the picker's words are the Media Label Set's
5
+ * (`getPhiMediaWidgetLabels`). The Form Widget reads that set on the Server for every Form that has a
6
+ * `media-asset` field (`form-field-labels.ts`) and hands the words to the control under these keys, so a
7
+ * Module that places the field translates none of them. A Foundation file for the same reason
8
+ * `upload-field-keys.ts` is: the Server reads it without the Asset Module, and the Module's control reads
9
+ * it without the Server. Where the field's own wording is the Form's -- Choose, Change, Remove -- the keys
10
+ * are the Module's (`PHI_FORM_MEDIA_ASSET_LABEL_KEYS`).
11
+ */
12
+ export declare const PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS: {
13
+ readonly popoverTitle: "mediaAssetPickerTitle";
14
+ readonly searchPlaceholder: "mediaAssetPickerSearch";
15
+ readonly folderLabel: "mediaAssetPickerFolder";
16
+ readonly spaceLabel: "mediaAssetPickerSpace";
17
+ readonly emptyDescription: "mediaAssetPickerEmpty";
18
+ readonly loadFailedDescription: "mediaAssetPickerLoadFailed";
19
+ readonly clearLabel: "mediaAssetPickerClear";
20
+ readonly reloadLabel: "mediaAssetPickerReload";
21
+ readonly tileSizeLabel: "mediaAssetPickerTileSize";
22
+ readonly sourceLabel: "mediaAssetPickerSource";
23
+ readonly sourceFailedText: "mediaAssetPickerSourceFailed";
24
+ readonly importingLabel: "mediaAssetPickerImporting";
25
+ readonly importFailedText: "mediaAssetPickerImportFailed";
26
+ readonly loadMoreLabel: "mediaAssetPickerLoadMore";
27
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The `media-asset` field's picker words, under the keys its control reads them from.
3
+ *
4
+ * The field opens the Media library's own picker, and the picker's words are the Media Label Set's
5
+ * (`getPhiMediaWidgetLabels`). The Form Widget reads that set on the Server for every Form that has a
6
+ * `media-asset` field (`form-field-labels.ts`) and hands the words to the control under these keys, so a
7
+ * Module that places the field translates none of them. A Foundation file for the same reason
8
+ * `upload-field-keys.ts` is: the Server reads it without the Asset Module, and the Module's control reads
9
+ * it without the Server. Where the field's own wording is the Form's -- Choose, Change, Remove -- the keys
10
+ * are the Module's (`PHI_FORM_MEDIA_ASSET_LABEL_KEYS`).
11
+ */
12
+ export const PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS = {
13
+ popoverTitle: "mediaAssetPickerTitle",
14
+ searchPlaceholder: "mediaAssetPickerSearch",
15
+ folderLabel: "mediaAssetPickerFolder",
16
+ spaceLabel: "mediaAssetPickerSpace",
17
+ emptyDescription: "mediaAssetPickerEmpty",
18
+ loadFailedDescription: "mediaAssetPickerLoadFailed",
19
+ clearLabel: "mediaAssetPickerClear",
20
+ reloadLabel: "mediaAssetPickerReload",
21
+ tileSizeLabel: "mediaAssetPickerTileSize",
22
+ sourceLabel: "mediaAssetPickerSource",
23
+ sourceFailedText: "mediaAssetPickerSourceFailed",
24
+ importingLabel: "mediaAssetPickerImporting",
25
+ importFailedText: "mediaAssetPickerImportFailed",
26
+ loadMoreLabel: "mediaAssetPickerLoadMore",
27
+ };
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { normalizePhiFormKey } from "../../helpers/form-id";
3
3
  import { phiRuntime } from "../../server-helpers/phi-runtime";
4
4
  import { getResolvedFormDefinition } from "../../gateway/form-registry";
5
+ import { resolvePhiFormFieldLabels } from "./form-field-labels";
5
6
  import { resolvePhiFormLabels } from "./form-resolution";
6
7
  import { createPhiRuntimeFormControllerAddress } from "./runtime-form-controller-address";
7
8
  import { PhiRuntimeModuleRenderClientHost } from "../runtime/runtime-module-render-client-manifest";
@@ -54,10 +55,13 @@ export async function PhiFormWidget({ runtime, registry, formId, formInstanceKey
54
55
  * become interactive, which is the wait a visitor reads as a slow site.
55
56
  */
56
57
  const renderContext = { runtime, resolvedForm, options: renderOptions };
57
- const [labels, loadedInitialValues] = await Promise.all([
58
+ const [fieldLabels, formLabels, loadedInitialValues] = await Promise.all([
59
+ resolvePhiFormFieldLabels(renderContext, resolvedForm.definition.descriptor),
58
60
  resolvePhiFormLabels(renderContext),
59
61
  resolvedForm.definition.loadInitialValues?.(renderContext) ?? null,
60
62
  ]);
63
+ // What the field types say for themselves, under what the Form says for itself.
64
+ const labels = { ...fieldLabels, ...formLabels };
61
65
  /*
62
66
  * A link is offered only where it leads somewhere that exists: a Site with registration switched off
63
67
  * has no account to create. The fact is read from the same published Module state a node condition