@phis/ui 0.6.0 → 0.6.2

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 (92) hide show
  1. package/components/controls/phi-form-control.d.ts +6 -0
  2. package/components/controls/phi-form-control.js +23 -7
  3. package/components/controls/phi-media-picker-control.d.ts +3 -1
  4. package/components/controls/phi-media-picker-control.js +2 -2
  5. package/components/forms/form-descriptor-runtime-client.d.ts +3 -1
  6. package/components/forms/form-descriptor-runtime-client.js +2 -2
  7. package/components/forms/form-field-provider-modules.d.ts +23 -0
  8. package/components/forms/form-field-provider-modules.js +28 -0
  9. package/components/forms/form-provider-contract.d.ts +7 -0
  10. package/components/forms/form-provider-contract.js +7 -0
  11. package/components/forms/lazy-form-field-control.d.ts +14 -0
  12. package/components/forms/lazy-form-field-control.js +35 -0
  13. package/components/forms/phi-form-widget.d.ts +3 -2
  14. package/components/forms/phi-form-widget.js +21 -3
  15. package/components/forms/shared-form-provider-registry.js +1 -33
  16. package/components/media/phi-area-upload-widget.js +6 -58
  17. package/components/media/phi-media-picker-binding.d.ts +16 -1
  18. package/components/media/phi-media-picker-binding.js +3 -2
  19. package/components/media/phi-media-upload.d.ts +12 -0
  20. package/components/media/phi-media-upload.js +22 -0
  21. package/components/media/phi-upload-drop-area.d.ts +22 -0
  22. package/components/media/phi-upload-drop-area.js +49 -0
  23. package/components/widgets/helpers/semantic-html-translation.d.ts +4 -1
  24. package/components/widgets/helpers/semantic-html-translation.js +4 -2
  25. package/components/widgets/label-sets/admin-users.d.ts +9 -1
  26. package/components/widgets/label-sets/admin-users.js +14 -2
  27. package/components/widgets/label-sets/slot-upload.js +6 -3
  28. package/components/widgets/label-types/slot-upload.d.ts +7 -1
  29. package/components/widgets/label-types/slot-upload.js +2 -1
  30. package/components/widgets/shared/markdown-render.js +6 -6
  31. package/constants/media-library-provider-keys.d.ts +9 -0
  32. package/constants/media-library-provider-keys.js +9 -0
  33. package/constants/runtime-module-ownership.js +2 -0
  34. package/controls.d.ts +2 -0
  35. package/controls.js +1 -0
  36. package/gateway/signet-route.js +11 -6
  37. package/helpers/phi-signet-head.d.ts +4 -3
  38. package/helpers/phi-signet-head.js +17 -5
  39. package/helpers/phi-signet.d.ts +12 -0
  40. package/helpers/phi-signet.js +11 -0
  41. package/net/phi-next-proxy.d.ts +10 -8
  42. package/net/phi-next-proxy.js +27 -84
  43. package/next/proxy-runtime.js +15 -0
  44. package/next/site-proxy.js +5 -0
  45. package/package.json +1 -1
  46. package/plugins/runtime-modules/asset/definition.d.ts +44 -2
  47. package/plugins/runtime-modules/asset/definition.js +5 -2
  48. package/plugins/runtime-modules/asset/form-providers.d.ts +63 -0
  49. package/plugins/runtime-modules/asset/form-providers.js +54 -0
  50. package/plugins/runtime-modules/asset/form-ui-provider.js +13 -3
  51. package/plugins/runtime-modules/asset/media-asset-field.d.ts +20 -0
  52. package/plugins/runtime-modules/asset/media-asset-field.js +33 -0
  53. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +21 -0
  54. package/plugins/runtime-modules/asset/media-asset-form-control.js +74 -0
  55. package/plugins/runtime-modules/builder/clients/pages-workspace.js +4 -4
  56. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +2 -2
  57. package/plugins/runtime-modules/builder/controller/page-controller.js +5 -5
  58. package/plugins/runtime-modules/builder/persistence.js +4 -4
  59. package/plugins/runtime-modules/builder/region-keys.d.ts +10 -0
  60. package/plugins/runtime-modules/builder/region-keys.js +10 -0
  61. package/plugins/runtime-modules/core/widgets/html/server.js +1 -1
  62. package/plugins/runtime-modules/core/widgets/slot-upload/client.js +28 -23
  63. package/plugins/runtime-modules/core/widgets/slot-upload/slot.d.ts +19 -0
  64. package/plugins/runtime-modules/core/widgets/slot-upload/slot.js +16 -0
  65. package/plugins/runtime-modules/resolver.js +38 -4
  66. package/plugins/runtime-modules/user-management/addon-roles.d.ts +35 -0
  67. package/plugins/runtime-modules/user-management/addon-roles.js +76 -0
  68. package/plugins/runtime-modules/user-management/cards.js +1 -1
  69. package/plugins/runtime-modules/user-management/client-data-providers.js +6 -0
  70. package/plugins/runtime-modules/user-management/data-providers.d.ts +11 -2
  71. package/plugins/runtime-modules/user-management/data-providers.js +12 -1
  72. package/plugins/runtime-modules/user-management/definition.d.ts +11 -2
  73. package/plugins/runtime-modules/user-management/ids.d.ts +1 -0
  74. package/plugins/runtime-modules/user-management/ids.js +1 -0
  75. package/plugins/runtime-modules/user-management/services/options.d.ts +8 -0
  76. package/plugins/runtime-modules/user-management/services/options.js +25 -0
  77. package/plugins/runtime-modules/user-management/services/table.js +9 -1
  78. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +20 -2
  79. package/server-helpers/cms-widget-texts.js +1 -1
  80. package/server-helpers/search-index.js +29 -19
  81. package/server-helpers/search-text.d.ts +3 -2
  82. package/server-helpers/search-text.js +6 -5
  83. package/server-helpers/site-build-id.d.ts +25 -0
  84. package/server-helpers/site-build-id.js +27 -0
  85. package/server-helpers/translate.d.ts +13 -2
  86. package/server-helpers/translate.js +10 -6
  87. package/theme/phi-theme-signet.d.ts +6 -0
  88. package/theme/phi-theme-signet.js +37 -1
  89. package/theme/phi-tokens.d.ts +1 -1
  90. package/theme/phi-tokens.js +5 -1
  91. package/types/cms-plugins.d.ts +10 -1
  92. package/types/site-theme.d.ts +14 -2
@@ -16,6 +16,12 @@ export type PhiFormControlProps = {
16
16
  disabled?: boolean;
17
17
  readOnly?: boolean;
18
18
  conditionControllerStates?: Readonly<Record<string, Record<string, unknown>>>;
19
+ /**
20
+ * The fields whose field type belongs to a Module that is not active in this Area. Each says so in the
21
+ * place of its control instead of failing as a missing Provider, and its value is neither validated nor
22
+ * dropped: what the form holds for it goes out with the submit unchanged.
23
+ */
24
+ unavailableFieldKeys?: readonly string[];
19
25
  form?: PhiFormControlFormInstance;
20
26
  onValuesChange?: (changedValues: Record<string, unknown>, allValues: Record<string, unknown>) => void;
21
27
  onSubmit: (values: Record<string, unknown>) => void | Promise<void>;
@@ -7,7 +7,7 @@ import { collectPhiRuntimeValueConditions, evaluatePhiRuntimeConditionExpression
7
7
  import { extendPhiFormProviderRegistry, usePhiFormProviderRegistry, } from "../forms/form-provider-registry";
8
8
  import { PhiAlertControl } from "./phi-alert-control";
9
9
  import { PhiDescriptionHint } from "./phi-description-tooltip-icon";
10
- import { PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_VALIDATION_PROVIDER_KEYS, } from "../forms/form-provider-contract";
10
+ import { PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_FIELD_UNAVAILABLE_DEFAULT_LABEL, PHI_FORM_FIELD_UNAVAILABLE_LABEL_KEY, PHI_FORM_VALIDATION_PROVIDER_KEYS, } from "../forms/form-provider-contract";
11
11
  import { phiFormCellOpensColumn, phiFormControlGridColumn, phiFormFieldFollowsLayoutColumns, phiFormLabelGridColumn, resolvePhiFormGridPlacement, resolvePhiFormLayout, PHI_FORM_RESPONSIVE_MODES, resolvePhiFormText, shouldPhiFormSubmitOnKeyDown, } from "../forms/form-descriptor-contract";
12
12
  import { PHI_SHARED_FORM_PROVIDER_REGISTRY } from "../forms/shared-form-provider-registry";
13
13
  import { resolvePhiControlOptionsDependencies, usePhiControlOptionsProvider, } from "./phi-options-provider";
@@ -136,11 +136,12 @@ function PhiResolvedFormFieldControl({ id, provider, field, label, description,
136
136
  // One empty object for every form without controllers, so the fields drawn are not recomputed on
137
137
  // every render for a new `{}`.
138
138
  const PHI_FORM_NO_CONTROLLER_STATES = Object.freeze({});
139
- export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, registry, labels, formConfig, initialValues, submitOnEnter, disabled = false, readOnly = false, conditionControllerStates = PHI_FORM_NO_CONTROLLER_STATES, form: providedForm, onValuesChange, onSubmit, onSubmittingChange, onValidationFailed, onFormReady, onStateChange, onBlurCapture, }, ref) {
139
+ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, registry, labels, formConfig, initialValues, submitOnEnter, disabled = false, readOnly = false, conditionControllerStates = PHI_FORM_NO_CONTROLLER_STATES, unavailableFieldKeys, form: providedForm, onValuesChange, onSubmit, onSubmittingChange, onValidationFailed, onFormReady, onStateChange, onBlurCapture, }, ref) {
140
140
  const contributedRegistry = usePhiFormProviderRegistry();
141
141
  const activeRegistry = useMemo(() => registry ?? (contributedRegistry
142
142
  ? extendPhiFormProviderRegistry(PHI_SHARED_FORM_PROVIDER_REGISTRY, contributedRegistry)
143
143
  : PHI_SHARED_FORM_PROVIDER_REGISTRY), [contributedRegistry, registry]);
144
+ const unavailableKeys = useMemo(() => new Set(unavailableFieldKeys ?? []), [unavailableFieldKeys]);
144
145
  const [internalForm] = Form.useForm();
145
146
  const form = providedForm ?? internalForm;
146
147
  /*
@@ -244,7 +245,16 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
244
245
  setSubmitting(true);
245
246
  onSubmittingChange?.(true);
246
247
  try {
247
- await onSubmit(values);
248
+ /*
249
+ * A field that is not drawn is not part of what the form validated, and so not part of `values`.
250
+ * What it holds is what the Server knows about it, and a save that leaves it out would say it was
251
+ * emptied.
252
+ */
253
+ const kept = Object.fromEntries([...unavailableKeys].flatMap((key) => {
254
+ const held = form.getFieldValue(key);
255
+ return held === undefined ? [] : [[key, held]];
256
+ }));
257
+ await onSubmit({ ...kept, ...values });
248
258
  }
249
259
  finally {
250
260
  setSubmitting(false);
@@ -328,14 +338,16 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
328
338
  * away as everything inside it.
329
339
  */
330
340
  const lastInFlowFieldKey = useMemo(() => {
331
- const inFlow = renderedFields.filter((field) => activeRegistry.fieldTypesByKey.get(field.fieldProviderKey)?.presentation === "control");
341
+ const inFlow = renderedFields.filter((field) => unavailableKeys.has(field.key) ||
342
+ activeRegistry.fieldTypesByKey.get(field.fieldProviderKey)?.presentation === "control");
332
343
  return inFlow.length === 0 ? null : inFlow[inFlow.length - 1].key;
333
- }, [activeRegistry, renderedFields]);
344
+ }, [activeRegistry, renderedFields, unavailableKeys]);
334
345
  const placementByMode = useMemo(() => {
335
346
  const entries = renderedFields.map((field) => ({
336
347
  key: field.key,
337
348
  placement: field.placement,
338
- inFlow: activeRegistry.fieldTypesByKey.get(field.fieldProviderKey)?.presentation === "control",
349
+ inFlow: unavailableKeys.has(field.key) ||
350
+ activeRegistry.fieldTypesByKey.get(field.fieldProviderKey)?.presentation === "control",
339
351
  hasLabel: field.label != null && field.controlLabel == null,
340
352
  }));
341
353
  return {
@@ -343,7 +355,7 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
343
355
  medium: resolvePhiFormGridPlacement(layout, entries, "medium"),
344
356
  wide: resolvePhiFormGridPlacement(layout, entries, "wide"),
345
357
  };
346
- }, [activeRegistry, layout, renderedFields]);
358
+ }, [activeRegistry, layout, renderedFields, unavailableKeys]);
347
359
  return (_jsx("div", { style: { width: "100%", minWidth: 0 }, children: _jsx(Form, { className: "phi-form-descriptor", name: formDomName, form: form, layout: "vertical", colon: false, initialValues: resolvedInitialValues, disabled: disabled,
348
360
  /*
349
361
  * The form is the grid, and its tracks are the twenty-four every range is written against. Labels
@@ -428,6 +440,10 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
428
440
  : "0px"],
429
441
  ];
430
442
  }));
443
+ if (!provider && unavailableKeys.has(field.key)) {
444
+ const unavailableLabel = field.label ? resolvePhiFormText(field.label, labels, formConfig) : undefined;
445
+ return (_jsx("div", { className: "phi-form-cell phi-form-cell--control", style: cellProperties("control"), children: _jsx(PhiAlertControl, { level: "info", title: labels?.[PHI_FORM_FIELD_UNAVAILABLE_LABEL_KEY]?.trim() || PHI_FORM_FIELD_UNAVAILABLE_DEFAULT_LABEL, description: unavailableLabel }) }, field.key));
446
+ }
431
447
  if (!provider) {
432
448
  return (_jsx("div", { className: "phi-form-cell phi-form-cell--control", style: cellProperties("control"), children: _jsx(PhiAlertControl, { level: "error", showIcon: true, title: `Form field is not renderable: ${field.key}`, description: `Missing field provider: ${field.fieldProviderKey}` }) }, field.key));
433
449
  }
@@ -27,6 +27,8 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
27
27
  showFolderFilter?: boolean;
28
28
  showPagination?: boolean;
29
29
  trigger?: ReactNode;
30
+ /** Which Assets may be chosen. The others are listed and greyed out; absent, every Asset may be. */
31
+ isAssetSelectable?: (asset: PhiMediaAssetTile) => boolean;
30
32
  labels?: Partial<{
31
33
  trigger: string;
32
34
  title: string;
@@ -47,4 +49,4 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
47
49
  onMinColumnWidthChange?: (minColumnWidth: number) => void;
48
50
  onReload?: () => void;
49
51
  };
50
- export declare function PhiMediaPickerControl({ open, value, assets, spaces, spaceValue, folders, folderValue, query, page, pageSize, total, minColumnWidth, loading, disabled, readOnly, placement, showSearchBar, showFolderFilter, showPagination, trigger, labels, getPopupContainer, popupRootClassName, onOpenChange, onQueryChange, onSpaceChange, onFolderChange, onPageChange, onMinColumnWidthChange, onReload, onChange, onCommit, onDiscard, }: PhiMediaPickerControlProps): import("react").JSX.Element;
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;
@@ -15,7 +15,7 @@ import { PhiSliderControl } from "./phi-slider-control";
15
15
  import { PhiTextControl } from "./phi-text-control";
16
16
  import { usePhiImmediatePicker } from "./use-phi-immediate-picker";
17
17
  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, labels, getPopupContainer, popupRootClassName, onOpenChange, onQueryChange, onSpaceChange, onFolderChange, onPageChange, onMinColumnWidthChange, onReload, onChange, onCommit, onDiscard, }) {
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
19
  const { token } = usePhiConfig();
20
20
  const locked = disabled || readOnly;
21
21
  const resolvedMinColumnWidth = normalizePhiMediaPickerMinColumnWidth(minColumnWidth);
@@ -29,7 +29,7 @@ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [],
29
29
  onOpenChange,
30
30
  });
31
31
  const selected = assets.find((asset) => asset.id === picker.value) ?? null;
32
- const tileItems = assets.map((asset) => (_jsx(PhiMediaAssetTileControl, { asset: asset, minColumnWidth: resolvedMinColumnWidth, selected: asset.id === picker.value, size: "small", disabled: locked, showTypeLabel: false, showDeleteAction: false, showDimensions: false, showIdLabel: false, onSelect: (nextAsset) => {
32
+ 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
33
  picker.changeValue(nextAsset.id);
34
34
  picker.closePicker("commit");
35
35
  } }, asset.id)));
@@ -9,5 +9,7 @@ export type PhiFormDescriptorRuntimeClientProps = {
9
9
  formId: string;
10
10
  formControllerAddress: PhiSignalAddress;
11
11
  widgetConfig?: PhiCmsFormWidgetConfig;
12
+ /** The fields whose field type belongs to a Module that is not active in this Area. */
13
+ unavailableFieldKeys?: readonly string[];
12
14
  };
13
- export declare function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, }: PhiFormDescriptorRuntimeClientProps): import("react").JSX.Element;
15
+ export declare function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, unavailableFieldKeys, }: PhiFormDescriptorRuntimeClientProps): import("react").JSX.Element;
@@ -27,7 +27,7 @@ import { usePhiInDialogBody } from "../overlays/phi-dialog-body-context";
27
27
  /** How long before its window closes a token is renewed rather than sent: the request takes time too. */
28
28
  const PHI_FORM_GUARD_EXPIRY_MARGIN_MS = 60_000;
29
29
  const EMPTY_FORM_VALUES = {};
30
- export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, }) {
30
+ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedInitialValues, formId, formControllerAddress, widgetConfig, unavailableFieldKeys, }) {
31
31
  const formClient = usePhiRuntimeFormClient({ controllerAddress: formControllerAddress });
32
32
  const formRef = useRef(null);
33
33
  const submitCorrelationRef = useRef(null);
@@ -467,7 +467,7 @@ export function PhiFormDescriptorRuntimeClient({ descriptor, labels, loadedIniti
467
467
  activeForm.setFieldsValue(pendingValuesRef.current);
468
468
  pendingValuesRef.current = null;
469
469
  }
470
- }, conditionControllerStates: conditionControllerStates, onValuesChange: (changed, all) => {
470
+ }, conditionControllerStates: conditionControllerStates, unavailableFieldKeys: unavailableFieldKeys, onValuesChange: (changed, all) => {
471
471
  // A value moved, so whatever validation refused before is no longer what is being asked.
472
472
  rejectedRef.current = false;
473
473
  runtimeBinding.onValuesChange(changed, all);
@@ -0,0 +1,23 @@
1
+ import type { PhiFormFieldDescriptor, PhiFormProviderKey } from "../../types/form-descriptor";
2
+ import type { PhiRuntimeModuleId } from "../../types/cms-module-descriptors";
3
+ /**
4
+ * Which Modules a Form's field types belong to, other than the Form's own.
5
+ *
6
+ * A field type is a Module's to offer, and a Form of any Module may use it. For each field whose type an
7
+ * installed Module owns:
8
+ * - the owner is the Form's own Module: nothing to add, its UI provider is mounted anyway;
9
+ * - the owner is active in the Area and brings a UI provider: that provider is mounted for this Form;
10
+ * - the owner is not active in the Area: the field is marked unavailable, and the Form says so in its place.
11
+ *
12
+ * A key no installed Module owns (the shared registry's) is not this question's business.
13
+ */
14
+ export declare function readPhiFormFieldProviderModules({ fields, formOwnerModuleId, ownerModuleIdByFieldTypeKey, activeModuleIds, uiProviderModuleIds, }: {
15
+ fields: readonly Pick<PhiFormFieldDescriptor, "key" | "fieldProviderKey">[];
16
+ formOwnerModuleId: PhiRuntimeModuleId;
17
+ ownerModuleIdByFieldTypeKey: ReadonlyMap<PhiFormProviderKey, PhiRuntimeModuleId>;
18
+ activeModuleIds: ReadonlySet<PhiRuntimeModuleId>;
19
+ uiProviderModuleIds: ReadonlySet<PhiRuntimeModuleId>;
20
+ }): {
21
+ providerModuleIds: `${string}/${string}`[];
22
+ unavailableFieldKeys: string[];
23
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Which Modules a Form's field types belong to, other than the Form's own.
3
+ *
4
+ * A field type is a Module's to offer, and a Form of any Module may use it. For each field whose type an
5
+ * installed Module owns:
6
+ * - the owner is the Form's own Module: nothing to add, its UI provider is mounted anyway;
7
+ * - the owner is active in the Area and brings a UI provider: that provider is mounted for this Form;
8
+ * - the owner is not active in the Area: the field is marked unavailable, and the Form says so in its place.
9
+ *
10
+ * A key no installed Module owns (the shared registry's) is not this question's business.
11
+ */
12
+ export function readPhiFormFieldProviderModules({ fields, formOwnerModuleId, ownerModuleIdByFieldTypeKey, activeModuleIds, uiProviderModuleIds, }) {
13
+ const providerModuleIds = new Set();
14
+ const unavailableFieldKeys = [];
15
+ for (const field of fields) {
16
+ const owner = ownerModuleIdByFieldTypeKey.get(field.fieldProviderKey);
17
+ if (!owner || owner === formOwnerModuleId) {
18
+ continue;
19
+ }
20
+ if (!activeModuleIds.has(owner)) {
21
+ unavailableFieldKeys.push(field.key);
22
+ }
23
+ else if (uiProviderModuleIds.has(owner)) {
24
+ providerModuleIds.add(owner);
25
+ }
26
+ }
27
+ return { providerModuleIds: [...providerModuleIds], unavailableFieldKeys };
28
+ }
@@ -83,6 +83,13 @@ export declare const PHI_FORM_LINK_TARGET_LABEL_KEYS: {
83
83
  /** Where the Pages would be, when the Site could not list them. */
84
84
  readonly pagesUnavailable: "linkTargetPagesUnavailable";
85
85
  };
86
+ /**
87
+ * What a field says in the place of its control when the Module that owns its field type is not active in
88
+ * this Area (`PhiFormControl`'s `unavailableFieldKeys`), read from the Form's Label Set and falling back to
89
+ * English. The value the field holds is kept and sent unchanged.
90
+ */
91
+ export declare const PHI_FORM_FIELD_UNAVAILABLE_LABEL_KEY = "fieldUnavailable";
92
+ export declare const PHI_FORM_FIELD_UNAVAILABLE_DEFAULT_LABEL = "This field is not available in this area.";
86
93
  export declare const PHI_FORM_UPLOAD_LABEL_KEYS: {
87
94
  readonly trigger: "uploadTrigger";
88
95
  /** Beneath the trigger in an upload area (`config.presentation: "area"`): that a drop works too. */
@@ -91,6 +91,13 @@ export const PHI_FORM_LINK_TARGET_LABEL_KEYS = {
91
91
  /** Where the Pages would be, when the Site could not list them. */
92
92
  pagesUnavailable: "linkTargetPagesUnavailable",
93
93
  };
94
+ /**
95
+ * What a field says in the place of its control when the Module that owns its field type is not active in
96
+ * this Area (`PhiFormControl`'s `unavailableFieldKeys`), read from the Form's Label Set and falling back to
97
+ * English. The value the field holds is kept and sent unchanged.
98
+ */
99
+ export const PHI_FORM_FIELD_UNAVAILABLE_LABEL_KEY = "fieldUnavailable";
100
+ export const PHI_FORM_FIELD_UNAVAILABLE_DEFAULT_LABEL = "This field is not available in this area.";
94
101
  export const PHI_FORM_UPLOAD_LABEL_KEYS = {
95
102
  trigger: "uploadTrigger",
96
103
  /** Beneath the trigger in an upload area (`config.presentation: "area"`): that a drop works too. */
@@ -0,0 +1,14 @@
1
+ import { type ComponentType } from "react";
2
+ import type { PhiFormFieldProviderProps } from "./form-provider-registry";
3
+ /**
4
+ * A field Control whose code loads when a field of its kind is first rendered.
5
+ *
6
+ * Every kind in the shared registry that has code of its own to ship: the choice and number fields, the slider and the
7
+ * cascader, the date and time picker, and the compound Table and Tree fields, which bring the Table and
8
+ * Tree Controls with an editor for every column kind. Only text and toggle fields stay in the registry
9
+ * itself. The choice fields stayed too once, as kinds nearly every form has -- but the form every
10
+ * Landing carries is the sign-in, which has none of them, and paid for the Select on every first visit.
11
+ */
12
+ export declare function lazyPhiFormFieldControl(load: () => Promise<ComponentType<PhiFormFieldProviderProps>>,
13
+ /** How many control rows the field occupies once loaded, so the form keeps its height meanwhile. */
14
+ placeholderRows?: number): ComponentType<PhiFormFieldProviderProps>;
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { lazy, Suspense } from "react";
4
+ /**
5
+ * A field Control whose code loads when a field of its kind is first rendered.
6
+ *
7
+ * Every kind in the shared registry that has code of its own to ship: the choice and number fields, the slider and the
8
+ * cascader, the date and time picker, and the compound Table and Tree fields, which bring the Table and
9
+ * Tree Controls with an editor for every column kind. Only text and toggle fields stay in the registry
10
+ * itself. The choice fields stayed too once, as kinds nearly every form has -- but the form every
11
+ * Landing carries is the sign-in, which has none of them, and paid for the Select on every first visit.
12
+ */
13
+ export function lazyPhiFormFieldControl(load,
14
+ /** How many control rows the field occupies once loaded, so the form keeps its height meanwhile. */
15
+ placeholderRows = 1) {
16
+ const LazyControl = lazy(async () => ({ default: await load() }));
17
+ /*
18
+ * Only shown where the browser renders the field before its chunk arrived -- a navigation without a
19
+ * server render. On a server-rendered page React keeps the server HTML until the chunk is there.
20
+ */
21
+ const placeholder = (_jsx("div", { "aria-busy": "true", style: {
22
+ blockSize: `calc(var(--phi-control-height) * ${placeholderRows} + var(--phi-padding-sm) * ${placeholderRows - 1})`,
23
+ /*
24
+ * The Control shape, because this stands where a Control is about to stand. `grown-md` is half a
25
+ * Control line, which on the one-row placeholder is exactly the capsule and on a taller one is the
26
+ * capsule held -- the same answer the field itself will give when it arrives, so the shape does not
27
+ * change under the reader at the moment the chunk lands.
28
+ */
29
+ borderRadius: "var(--phi-control-radius-grown-md)",
30
+ background: "var(--phi-color-fill-quaternary)",
31
+ } }));
32
+ return function PhiLazyFormFieldControl(props) {
33
+ return (_jsx(Suspense, { fallback: placeholder, children: _jsx(LazyControl, { ...props }) }));
34
+ };
35
+ }
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from "react";
1
2
  import type { PhiBlockRuntime } from "../../types";
2
3
  import type { PhiCmsRuntimeRenderRegistry } from "../../types/cms-plugins";
3
4
  import type { PhiFormId } from "../../types/form-id";
@@ -5,11 +6,11 @@ import type { PhiCmsFormWidgetConfig } from "./form-widget-config";
5
6
  import { type PhiRuntimeFeatureState } from "../../types/runtime-condition";
6
7
  export type PhiFormWidgetProps = {
7
8
  runtime: Pick<PhiBlockRuntime, "site" | "locale"> & Partial<Pick<PhiBlockRuntime, "area">>;
8
- registry: Pick<PhiCmsRuntimeRenderRegistry, "formDefinitionsById" | "uiProviderModuleIds">;
9
+ registry: Pick<PhiCmsRuntimeRenderRegistry, "formDefinitionsById" | "uiProviderModuleIds" | "activeModuleIds" | "ownerModuleIdByFormFieldTypeKey">;
9
10
  formId: PhiFormId;
10
11
  formInstanceKey?: string | number | null;
11
12
  config?: PhiCmsFormWidgetConfig;
12
13
  /** What the active Modules published about this Site, as the renderer already resolved it. */
13
14
  features?: PhiRuntimeFeatureState | null;
14
15
  };
15
- export declare function PhiFormWidget({ runtime, registry, formId, formInstanceKey, config, features, }: PhiFormWidgetProps): Promise<import("react").JSX.Element | null>;
16
+ export declare function PhiFormWidget({ runtime, registry, formId, formInstanceKey, config, features, }: PhiFormWidgetProps): Promise<string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined>;
@@ -6,6 +6,7 @@ import { resolvePhiFormLabels } from "./form-resolution";
6
6
  import { createPhiRuntimeFormControllerAddress } from "./runtime-form-controller-address";
7
7
  import { PhiRuntimeModuleRenderClientHost } from "../runtime/runtime-module-render-client-manifest";
8
8
  import { PhiRuntimeRenderClientType } from "../../constants/runtime-render-client-types";
9
+ import { readPhiFormFieldProviderModules } from "./form-field-provider-modules";
9
10
  import { resolvePhiFormText } from "./form-descriptor-contract";
10
11
  import { PHI_FORM_DEFAULT_SUBMIT_LABEL } from "../../types/form-descriptor";
11
12
  import { readPhiRuntimeConditionValue, } from "../../types/runtime-condition";
@@ -33,6 +34,20 @@ export async function PhiFormWidget({ runtime, registry, formId, formInstanceKey
33
34
  };
34
35
  const ownerModuleId = resolvedForm.definition.ownerModuleId;
35
36
  const hasUiProvider = registry.uiProviderModuleIds.has(ownerModuleId);
37
+ /*
38
+ * A field type belongs to a Module, and the Form is not always that Module's own: the Media library's
39
+ * `media-asset` field stands in Forms of any Module. So the widget reads whose field types this Form
40
+ * uses and mounts those Modules' UI providers beside the Form owner's -- each wraps only this Form's
41
+ * subtree, and composes with the one outside it. A Module that is not active in this Area has nothing
42
+ * to mount; its fields are marked, and the Form says so in their place (`unavailableFieldKeys`).
43
+ */
44
+ const { providerModuleIds: fieldProviderModuleIds, unavailableFieldKeys } = readPhiFormFieldProviderModules({
45
+ fields: resolvedForm.definition.descriptor.fields,
46
+ formOwnerModuleId: ownerModuleId,
47
+ ownerModuleIdByFieldTypeKey: registry.ownerModuleIdByFormFieldTypeKey,
48
+ activeModuleIds: registry.activeModuleIds,
49
+ uiProviderModuleIds: registry.uiProviderModuleIds,
50
+ });
36
51
  /*
37
52
  * Both reads happen here, on the server, and both are the form's own: what it is called, and what it
38
53
  * already knows. Asking for either after hydration is a blank card for as long as the page takes to
@@ -78,9 +93,11 @@ export async function PhiFormWidget({ runtime, registry, formId, formInstanceKey
78
93
  children: node,
79
94
  };
80
95
  const framed = (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiRuntimeRenderClientType.FormWidgetFrame, componentProps: frameProps }));
81
- return hasUiProvider
82
- ? (_jsx(PhiRuntimeModuleUiProviderHost, { moduleId: ownerModuleId, children: framed }))
83
- : framed;
96
+ const providerModuleIds = [
97
+ ...(hasUiProvider ? [ownerModuleId] : []),
98
+ ...fieldProviderModuleIds,
99
+ ];
100
+ return providerModuleIds.reduceRight((children, moduleId) => (_jsx(PhiRuntimeModuleUiProviderHost, { moduleId: moduleId, children: children })), framed);
84
101
  };
85
102
  return wrapFormUiProvider(_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiRuntimeRenderClientType.FormDescriptor, componentProps: {
86
103
  descriptor: resolvedForm.definition.descriptor,
@@ -89,5 +106,6 @@ export async function PhiFormWidget({ runtime, registry, formId, formInstanceKey
89
106
  formId: resolvedForm.definition.formId,
90
107
  formControllerAddress: renderOptions.formControllerAddress,
91
108
  widgetConfig: config,
109
+ ...(unavailableFieldKeys.length > 0 ? { unavailableFieldKeys } : {}),
92
110
  } }));
93
111
  }
@@ -1,44 +1,12 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { lazy, Suspense } from "react";
4
3
  import { createPhiFormProviderRegistry, } from "./form-provider-registry";
5
4
  import { PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_VALIDATION_PROVIDER_KEYS, PHI_SHARED_FORM_FIELD_TYPE_PROVIDER_DESCRIPTORS, PHI_SHARED_FORM_VALIDATION_PROVIDER_DESCRIPTORS, } from "./form-provider-contract";
6
5
  import { PhiTextControl } from "../controls/phi-text-control";
7
6
  import { PhiCheckboxControl } from "../controls/phi-checkbox-control";
8
7
  import { PhiCheckboxGroupControl } from "../controls/phi-checkbox-group-control";
9
8
  import { PhiSwitchControl } from "../controls/phi-switch-control";
10
- /**
11
- * A field Control whose code loads when a field of its kind is first rendered.
12
- *
13
- * Every kind below that has code of its own to ship: the choice and number fields, the slider and the
14
- * cascader, the date and time picker, and the compound Table and Tree fields, which bring the Table and
15
- * Tree Controls with an editor for every column kind. Only text and toggle fields stay in the registry
16
- * itself. The choice fields stayed too once, as kinds nearly every form has -- but the form every
17
- * Landing carries is the sign-in, which has none of them, and paid for the Select on every first visit.
18
- */
19
- function lazyPhiFormFieldControl(load,
20
- /** How many control rows the field occupies once loaded, so the form keeps its height meanwhile. */
21
- placeholderRows = 1) {
22
- const LazyControl = lazy(async () => ({ default: await load() }));
23
- /*
24
- * Only shown where the browser renders the field before its chunk arrived -- a navigation without a
25
- * server render. On a server-rendered page React keeps the server HTML until the chunk is there.
26
- */
27
- const placeholder = (_jsx("div", { "aria-busy": "true", style: {
28
- blockSize: `calc(var(--phi-control-height) * ${placeholderRows} + var(--phi-padding-sm) * ${placeholderRows - 1})`,
29
- /*
30
- * The Control shape, because this stands where a Control is about to stand. `grown-md` is half a
31
- * Control line, which on the one-row placeholder is exactly the capsule and on a taller one is the
32
- * capsule held -- the same answer the field itself will give when it arrives, so the shape does not
33
- * change under the reader at the moment the chunk lands.
34
- */
35
- borderRadius: "var(--phi-control-radius-grown-md)",
36
- background: "var(--phi-color-fill-quaternary)",
37
- } }));
38
- return function PhiLazyFormFieldControl(props) {
39
- return (_jsx(Suspense, { fallback: placeholder, children: _jsx(LazyControl, { ...props }) }));
40
- };
41
- }
9
+ import { lazyPhiFormFieldControl } from "./lazy-form-field-control";
42
10
  const PhiLazyLinkTargetFormControl = lazyPhiFormFieldControl(() => import("./link-target-form-control").then((module) => module.PhiLinkTargetFormControl));
43
11
  const PhiLazySelectFormControl = lazyPhiFormFieldControl(() => import("./choice-form-field-controls").then((module) => module.PhiSelectFormControl));
44
12
  const PhiLazyMultiSelectFormControl = lazyPhiFormFieldControl(() => import("./choice-form-field-controls").then((module) => module.PhiMultiSelectFormControl));
@@ -4,22 +4,21 @@ import { resolvePhiMediaAssetTypeLabel } from "./asset-type-label";
4
4
  import { PhiTagControl } from "../controls/phi-tag-control";
5
5
  import { PhiButtonControl } from "../controls/phi-button-control";
6
6
  import NextImage from "next/image";
7
- import { useMemo, useRef, useState } from "react";
7
+ import { useMemo, useState } from "react";
8
8
  import { PhiCollectionLayoutControl } from "../controls/phi-collection-layout-control";
9
9
  import { resolvePhiMediaKindFromContentType, } from "../../constants/media";
10
10
  import { normalizePhiImagePreviewTile, resolvePhiMediaAssetDisplayDimensions, } from "./phi-image-preview-data";
11
11
  import { PhiMediaKindIcon } from "./phi-media-kind-icon";
12
12
  import { resolvePhiMediaUploadInitOptions, } from "./media-upload-flow";
13
- import { PHI_MEDIA_UPLOAD_DEFAULT_LABELS, usePhiMediaUpload, } from "./phi-media-upload";
13
+ import { resolvePhiAreaUploadLabels, resolvePhiUploadStatusLabel, usePhiMediaUpload, } from "./phi-media-upload";
14
14
  import { usePhiImagePreviewStore } from "./phi-image-preview-store";
15
15
  import { PHI_ASSET_CONTROLLER_STORE_KEY } from "./asset-controller-signals";
16
16
  import { applyPhiAssetCollectionData, buildPhiAssetCollectionQuery, PHI_ASSET_COLLECTION_DATA_SOURCE, } from "./asset-collection-runtime";
17
- import { PhiFileDropGuard } from "./phi-file-drop-guard";
17
+ import { PhiUploadDropArea } from "./phi-upload-drop-area";
18
18
  import { usePhiApplicationFeedback } from "../runtime/use-phi-application-feedback";
19
19
  import { resolvePhiThemeBorderLine } from "../../helpers/border-widget-style";
20
20
  import { usePhiConfig } from "../root/phi-config-provider";
21
21
  import { usePhiCollectionProviderAction } from "../widgets/client/shared/phi-collection-provider";
22
- import { PhiFileDropControl } from "../controls/phi-file-drop-control";
23
22
  import { PhiProgressControl } from "../controls/phi-progress-control";
24
23
  import { PhiFlexControl } from "../controls/phi-flex-control";
25
24
  import { PhiTypographyControl } from "../controls/phi-typography-control";
@@ -45,28 +44,6 @@ function buildUploadWallItem(asset, localId) {
45
44
  error: null,
46
45
  };
47
46
  }
48
- function resolveUploadStatusLabel(item, labels) {
49
- if (item.status === "error") {
50
- return labels.failedLabel;
51
- }
52
- if (item.status === "uploading") {
53
- return `${item.progress}%`;
54
- }
55
- return labels.doneLabel;
56
- }
57
- /**
58
- * The Widget's own wording over the shared reading of every refusal: its duplicate, failure and storage
59
- * texts, and the shared ones for the rest -- so no control plane string reaches a person.
60
- */
61
- function resolveAreaUploadLabels(labels) {
62
- return {
63
- ...PHI_MEDIA_UPLOAD_DEFAULT_LABELS,
64
- errorGeneric: labels.uploadFailedText,
65
- errorDuplicate: labels.assetExistsLabel,
66
- errorStorageUnreachable: labels.uploadStorageUnreachableText,
67
- errorFolderLocked: labels.uploadFolderLockedText,
68
- };
69
- }
70
47
  /** A file still on its way, or one that failed, drawn as a tile like the Assets that arrived. */
71
48
  function buildPendingWallItem(item, presentationFlags) {
72
49
  return {
@@ -94,15 +71,11 @@ function resolveUploadWallDisplayDimensions(item) {
94
71
  export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collectionContext }) {
95
72
  const { token } = usePhiConfig();
96
73
  const { showMessage } = usePhiApplicationFeedback();
97
- const uploadTileMinHeight = token.controlHeight * 4;
98
74
  const uploadTileFrameSize = token.controlHeight * 3;
99
- const uploadTileIconSize = token.fontSizeHeading3;
100
75
  const uploadTileLabelFontSize = token.fontSizeSM;
101
76
  const previewState = usePhiImagePreviewStore(PHI_ASSET_CONTROLLER_STORE_KEY);
102
77
  const activateCollectionAction = usePhiCollectionProviderAction(PHI_ASSET_COLLECTION_DATA_SOURCE);
103
- const dragDepth = useRef(0);
104
78
  const [uploadWall, setUploadWall] = useState([]);
105
- const [isDragActive, setIsDragActive] = useState(false);
106
79
  const allowDelete = config?.allowDelete ?? true;
107
80
  const accept = config?.accept?.trim() || "*/*";
108
81
  const multiple = config?.multiple ?? true;
@@ -171,7 +144,7 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
171
144
  * often than not -- so no Asset is finalized that nobody sees arrive. What is this Widget's own is the
172
145
  * wall: an Asset that arrived becomes a tile, and the listing behind it hears of it.
173
146
  */
174
- const areaUploadLabels = useMemo(() => resolveAreaUploadLabels(labels), [labels]);
147
+ const areaUploadLabels = useMemo(() => resolvePhiAreaUploadLabels(labels), [labels]);
175
148
  const upload = usePhiMediaUpload({
176
149
  labels: areaUploadLabels,
177
150
  initOptions: uploadInitOptions,
@@ -190,32 +163,7 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
190
163
  .map((item) => buildPendingWallItem(item, uploadInitOptions.presentationFlags ?? 0)),
191
164
  ...uploadWall,
192
165
  ];
193
- return (_jsxs(PhiFlexControl, { vertical: true, gap: 12, style: { width: "100%" }, children: [_jsx(PhiFileDropGuard, {}), _jsx("div", { "data-phi-media-dropzone": "true", onDragEnter: () => {
194
- dragDepth.current += 1;
195
- setIsDragActive(true);
196
- }, onDragLeave: () => {
197
- dragDepth.current = Math.max(0, dragDepth.current - 1);
198
- if (dragDepth.current === 0) {
199
- setIsDragActive(false);
200
- }
201
- }, onDragOver: (event) => {
202
- event.preventDefault();
203
- event.dataTransfer.dropEffect = "copy";
204
- setIsDragActive(true);
205
- }, onDrop: () => {
206
- dragDepth.current = 0;
207
- setIsDragActive(false);
208
- }, style: { width: "100%" }, children: _jsx(PhiFileDropControl, { dropZone: true, multiple: multiple, accept: accept, onFile: (file) => void upload.upload(file), style: {
209
- padding: 0,
210
- width: "100%",
211
- borderColor: isDragActive ? token.colorPrimary : undefined,
212
- background: isDragActive ? token.colorFillQuaternary : undefined,
213
- }, children: _jsxs(PhiFlexControl, { vertical: true, align: "center", gap: 4, style: {
214
- width: "100%",
215
- minHeight: uploadTileMinHeight,
216
- justifyContent: "center",
217
- cursor: isDragActive ? "copy" : "default",
218
- }, children: [_jsx(PhiIcon, { name: "upload", size: "inherit", style: { fontSize: uploadTileIconSize, color: token.colorTextSecondary } }), _jsx(PhiTypographyControl, { strong: true, children: labels.dropTitle }), _jsx(PhiTypographyControl, { type: "secondary", children: labels.dropHint })] }) }) }), _jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: uploadTileFrameSize, items: wallItems.map((item) => {
166
+ return (_jsxs(PhiFlexControl, { vertical: true, gap: 12, style: { width: "100%" }, children: [_jsx(PhiUploadDropArea, { multiple: multiple, accept: accept, title: labels.dropTitle, hint: labels.dropHint, onFile: (file) => void upload.upload(file) }), _jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: uploadTileFrameSize, items: wallItems.map((item) => {
219
167
  const displayDimensions = resolveUploadWallDisplayDimensions(item);
220
168
  return (_jsxs("div", { style: {
221
169
  border: resolvePhiThemeBorderLine(token.colorBorderSecondary),
@@ -272,7 +220,7 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
272
220
  color: "#fff",
273
221
  }, children: _jsx(PhiSpinControl, {}) })) : null] }), _jsxs(PhiFlexControl, { vertical: true, gap: 6, style: { padding: token.paddingSM }, children: [_jsx(PhiFlexControl, { align: "center", justify: "space-between", gap: 8, children: _jsx(PhiTypographyControl, { strong: true, ellipsis: true, title: item.title ?? item.originalName, style: { minWidth: 0 }, children: item.title ?? item.originalName }) }), _jsxs(PhiFlexControl, { align: "center", justify: "space-between", gap: 8, wrap: true, children: [_jsx(PhiTypographyControl, { type: "secondary", ellipsis: true, style: { display: "block", minWidth: 0 }, children: resolvePhiMediaAssetTypeLabel(item.kind, item.contentType, item.originalName) }), allowDelete && item.assetId > 0 ? (_jsx(PhiButtonControl, { ariaLabel: labels.deleteLabel, icon: _jsx(PhiIcon, { name: "delete", size: "inherit" }), type: "text", size: "small", danger: true, onClick: () => {
274
222
  void deleteUploadedAsset(item.localId, item.assetId);
275
- } })) : null] }), _jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: true, children: [_jsx(PhiTagControl, { color: item.status === "error" ? "red" : item.status === "uploading" ? "blue" : "green", children: resolveUploadStatusLabel(item, labels) }), item.status === "error" && item.file ? (_jsx(PhiButtonControl, { type: "primary", size: "small", onClick: () => {
223
+ } })) : null] }), _jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: true, children: [_jsx(PhiTagControl, { color: item.status === "error" ? "red" : item.status === "uploading" ? "blue" : "green", children: resolvePhiUploadStatusLabel(item, labels) }), item.status === "error" && item.file ? (_jsx(PhiButtonControl, { type: "primary", size: "small", onClick: () => {
276
224
  void upload.retry(item.localId);
277
225
  }, label: labels.retryLabel })) : null] })] })] }, item.localId));
278
226
  }) })] }));
@@ -18,8 +18,22 @@ export type PhiMediaPickerBindingProps = {
18
18
  trigger?: ReactNode;
19
19
  getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
20
20
  popupRootClassName?: string;
21
+ /**
22
+ * Offers the Site Space and nothing else, wherever the surface stands: no Space selector, and the query
23
+ * names no Space, which the control plane answers with the Site Space. For a place that stores a
24
+ * reference to an Asset for everybody to see, which a personal or a group Space cannot honestly be.
25
+ * An interface rule like `usePhiMediaSpaceSelectionAllowed`; the server that takes the reference is what
26
+ * enforces it.
27
+ */
28
+ siteSpaceOnly?: boolean;
29
+ /**
30
+ * Which of the listed Assets may be chosen; the others stay in the list, greyed out. The list is the
31
+ * control plane's answer and is not narrowed here -- an Asset the question refuses is still one the
32
+ * reader can see exists.
33
+ */
34
+ isAssetSelectable?: (asset: PhiMediaAssetTile) => boolean;
21
35
  };
22
- export declare function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, }: PhiMediaPickerBindingProps): {
36
+ export declare function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, siteSpaceOnly, isAssetSelectable, }: PhiMediaPickerBindingProps): {
23
37
  open: boolean;
24
38
  value: number | null;
25
39
  assets: PhiMediaAssetTile[];
@@ -61,6 +75,7 @@ export declare function usePhiMediaPickerBinding({ config, labels, searchLabels,
61
75
  };
62
76
  getPopupContainer: ((triggerNode: HTMLElement) => HTMLElement) | undefined;
63
77
  popupRootClassName: string | undefined;
78
+ isAssetSelectable: ((asset: PhiMediaAssetTile) => boolean) | undefined;
64
79
  onOpenChange: (next: boolean) => void;
65
80
  onCommit: ((assetId: number | null, originalAssetId: number | null) => void) | undefined;
66
81
  onDiscard: ((originalAssetId: number | null) => void) | undefined;
@@ -14,7 +14,7 @@ import { setPhiImagePreviewSelection } from "./phi-image-preview-store";
14
14
  import { readPhiMediaAssetTiles, readPhiMediaFolders, readPhiMediaSpace, readPhiMediaSpaces, } from "./phi-image-preview-data";
15
15
  import { buildPhiMediaSpaceOptions, usePhiMediaSpaceSelectionAllowed, } from "./media-space-selection";
16
16
  import { isPhiRecord } from "../../helpers/is-record";
17
- export function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, }) {
17
+ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, siteSpaceOnly = false, isAssetSelectable, }) {
18
18
  const [localOpen, setLocalOpen] = useState(false);
19
19
  const [localValue, setLocalValue] = useState(controlledValue ?? null);
20
20
  const [searchQuery, setSearchQuery] = useState("");
@@ -36,7 +36,7 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
36
36
  * been given.
37
37
  */
38
38
  const [requestedSpaceAddress, setRequestedSpaceAddress] = useState(null);
39
- const spaceSelectionAllowed = usePhiMediaSpaceSelectionAllowed();
39
+ const spaceSelectionAllowed = usePhiMediaSpaceSelectionAllowed() && !siteSpaceOnly;
40
40
  const [total, setTotal] = useState(0);
41
41
  const [loading, setLoading] = useState(false);
42
42
  const [loadFailed, setLoadFailed] = useState(false);
@@ -183,6 +183,7 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
183
183
  labels: { trigger: labels.picker.triggerLabel, title: labels.picker.popoverTitle, search: labels.tool.searchPlaceholder ?? searchLabels.placeholder, folder: labels.tool.folderLabel, space: labels.space.label, empty: bindingError ?? (loadFailed ? labels.picker.loadFailedDescription : labels.picker.emptyDescription), clear: labels.picker.clearLabel, reload: labels.tool.reloadLabel, tileSize: labels.picker.tileSizeLabel },
184
184
  getPopupContainer,
185
185
  popupRootClassName,
186
+ isAssetSelectable,
186
187
  onOpenChange: updateOpen,
187
188
  onCommit,
188
189
  onDiscard,