@phis/ui 0.7.2 → 0.7.3

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 (60) hide show
  1. package/components/controls/phi-collection-reorder-context.d.ts +21 -0
  2. package/components/controls/phi-collection-reorder-context.js +6 -0
  3. package/components/controls/phi-collection-sortable-layout-control.d.ts +17 -0
  4. package/components/controls/phi-collection-sortable-layout-control.js +72 -0
  5. package/components/controls/phi-collection-view-control.d.ts +1 -1
  6. package/components/controls/phi-collection-view-control.js +15 -1
  7. package/components/controls/phi-media-asset-tile-control.d.ts +12 -5
  8. package/components/controls/phi-media-picker-control.d.ts +14 -1
  9. package/components/controls/phi-media-picker-control.js +11 -2
  10. package/components/forms/compound-form-controls.d.ts +1 -1
  11. package/components/forms/compound-form-controls.js +6 -4
  12. package/components/forms/form-field-labels.d.ts +3 -1
  13. package/components/forms/form-field-labels.js +19 -6
  14. package/components/forms/form-provider-contract.js +2 -1
  15. package/components/forms/media-asset-field-keys.d.ts +4 -1
  16. package/components/forms/media-asset-field-keys.js +4 -1
  17. package/components/forms/table-field-keys.d.ts +8 -0
  18. package/components/forms/table-field-keys.js +8 -0
  19. package/components/forms/table-field-labels.d.ts +16 -0
  20. package/components/forms/table-field-labels.js +16 -0
  21. package/components/forms/table-field-text.d.ts +9 -0
  22. package/components/forms/table-field-text.js +20 -0
  23. package/components/forms/upload-field-refusal-labels.d.ts +10 -0
  24. package/components/forms/upload-field-refusal-labels.js +24 -0
  25. package/components/forms/upload-form-control.js +3 -16
  26. package/components/media/media-upload-flow.d.ts +13 -1
  27. package/components/media/media-upload-flow.js +16 -0
  28. package/components/media/phi-media-picker-binding.d.ts +48 -1
  29. package/components/media/phi-media-picker-binding.js +99 -6
  30. package/components/media/phi-media-upload.d.ts +7 -1
  31. package/components/media/phi-media-upload.js +17 -5
  32. package/components/widgets/client/shared/phi-collection-reorder.d.ts +45 -0
  33. package/components/widgets/client/shared/phi-collection-reorder.js +110 -0
  34. package/components/widgets/client/shared/phi-collection-view-binding.js +2 -1
  35. package/components/widgets/label-sets/collection-view.d.ts +4 -0
  36. package/components/widgets/label-sets/collection-view.js +16 -0
  37. package/components/widgets/label-sets/table.d.ts +6 -0
  38. package/components/widgets/label-sets/table.js +10 -0
  39. package/components/widgets/label-types/collection-view.d.ts +8 -0
  40. package/components/widgets/label-types/collection-view.js +4 -0
  41. package/controls.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/plugins/runtime-modules/asset/definition.d.ts +8 -0
  44. package/plugins/runtime-modules/asset/form-providers.d.ts +8 -0
  45. package/plugins/runtime-modules/asset/form-providers.js +6 -0
  46. package/plugins/runtime-modules/asset/media-asset-field.d.ts +34 -4
  47. package/plugins/runtime-modules/asset/media-asset-field.js +50 -3
  48. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +13 -0
  49. package/plugins/runtime-modules/asset/media-asset-form-control.js +81 -5
  50. package/plugins/runtime-modules/builder/page-meta-form.js +6 -6
  51. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +5 -0
  52. package/plugins/runtime-modules/core/widgets/collection-view/client.js +50 -4
  53. package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +28 -2
  54. package/plugins/runtime-modules/core/widgets/collection-view/config.js +13 -0
  55. package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +1 -1
  56. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +4 -1
  57. package/plugins/runtime-modules/core/widgets/collection-view/server.js +19 -4
  58. package/types/collection-provider.d.ts +7 -0
  59. package/types/collection-view-widget.d.ts +11 -0
  60. package/types/core-widget-placements.d.ts +5 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Drag reordering of the items a Collection draws, offered by the `collection-view` Widget around
3
+ * whatever renderer draws them.
4
+ *
5
+ * The renderer -- the Provider's Render Client or one a Site chose (`itemRendererKey`) -- lays its items
6
+ * out through `PhiCollectionViewControl`, and that is where each of them gets a drag handle: the
7
+ * renderer is not touched and does not know. `itemKeys` are the keys of the items in the order the
8
+ * renderer draws them, one per item; where the renderer draws another number of items than there are
9
+ * keys, the Control cannot tell which is which and offers no reordering.
10
+ */
11
+ export type PhiCollectionReorderContextValue = {
12
+ itemKeys: readonly (string | number)[];
13
+ /** Every key in the new order, once an item was dropped somewhere else. */
14
+ onReorder: (itemKeys: (string | number)[]) => void;
15
+ /** True while an order is being written; nothing is dragged meanwhile. */
16
+ disabled?: boolean;
17
+ /** The drag handle's name for assistive technology. */
18
+ handleLabel: string;
19
+ };
20
+ export declare const PhiCollectionReorderContext: import("react").Context<PhiCollectionReorderContextValue | null>;
21
+ export declare function usePhiCollectionReorder(): PhiCollectionReorderContextValue | null;
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ export const PhiCollectionReorderContext = createContext(null);
4
+ export function usePhiCollectionReorder() {
5
+ return useContext(PhiCollectionReorderContext);
6
+ }
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from "react";
2
+ import { type PhiCollectionReorderContextValue } from "./phi-collection-reorder-context";
3
+ export type PhiCollectionSortableLayoutControlProps = {
4
+ mode: "grid" | "stack";
5
+ gap: string | number;
6
+ minColumnWidth: string | number;
7
+ /** Drawn by the renderer, one per key of `reorder.itemKeys`, in that order. */
8
+ items: readonly ReactNode[];
9
+ reorder: PhiCollectionReorderContextValue;
10
+ };
11
+ /**
12
+ * A Collection's items in `grid` or `stack` with a drag handle on each, for `PhiCollectionViewControl`
13
+ * while a `PhiCollectionReorderContext` offers reordering. Pointer and keyboard (`@dnd-kit`, as the Table
14
+ * Control sorts its rows); a drop answers every key in the new order and changes nothing itself -- the
15
+ * order shown is the one the items come in.
16
+ */
17
+ export declare function PhiCollectionSortableLayoutControl({ mode, gap, minColumnWidth, items, reorder, }: PhiCollectionSortableLayoutControlProps): import("react").JSX.Element;
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { closestCenter, DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors, } from "@dnd-kit/core";
5
+ import { arrayMove, rectSortingStrategy, SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy, } from "@dnd-kit/sortable";
6
+ import { CSS } from "@dnd-kit/utilities";
7
+ import { PhiIcon } from "../shell/phi-icon";
8
+ import { usePhiConfig } from "../root/phi-config-provider";
9
+ import { PhiCollectionReorderContext } from "./phi-collection-reorder-context";
10
+ function buildGridColumns(minColumnWidth) {
11
+ const width = typeof minColumnWidth === "number" ? `${minColumnWidth}px` : minColumnWidth;
12
+ return `repeat(auto-fill, minmax(${width}, 1fr))`;
13
+ }
14
+ /*
15
+ * One item and its handle. Only the handle starts a drag -- by pointer or, focused, by Space or Enter --
16
+ * so the item's own links, buttons and its click stay its own: a keyboard press on the item's delete
17
+ * button never reaches the drag sensor, which listens on the handle alone.
18
+ */
19
+ function PhiCollectionSortableItem({ id, disabled, handleLabel, children, }) {
20
+ const { token } = usePhiConfig();
21
+ const { attributes, listeners, setNodeRef, setActivatorNodeRef, transform, transition, isDragging } = useSortable({ id, disabled });
22
+ const style = {
23
+ position: "relative",
24
+ minWidth: 0,
25
+ transform: CSS.Translate.toString(transform),
26
+ transition,
27
+ zIndex: isDragging ? 10 : undefined,
28
+ opacity: isDragging ? 0.72 : undefined,
29
+ };
30
+ return (_jsxs("div", { ref: setNodeRef, style: style, "data-phi-collection-sortable-item": "", children: [_jsx(PhiCollectionReorderContext.Provider, { value: null, children: children }), _jsx("span", { ...attributes, ...listeners, ref: setActivatorNodeRef, "aria-label": handleLabel, title: handleLabel, style: {
31
+ position: "absolute",
32
+ top: token.paddingXXS,
33
+ insetInlineStart: token.paddingXXS,
34
+ display: "inline-flex",
35
+ alignItems: "center",
36
+ justifyContent: "center",
37
+ width: token.controlHeightSM,
38
+ height: token.controlHeightSM,
39
+ borderRadius: token.borderRadiusSM,
40
+ background: token.colorBgElevated,
41
+ color: token.colorTextSecondary,
42
+ boxShadow: token.boxShadowTertiary,
43
+ cursor: disabled ? "default" : isDragging ? "grabbing" : "grab",
44
+ opacity: disabled ? 0.5 : 0.9,
45
+ touchAction: "none",
46
+ }, children: _jsx(PhiIcon, { name: "holder", size: "inherit" }) })] }));
47
+ }
48
+ /**
49
+ * A Collection's items in `grid` or `stack` with a drag handle on each, for `PhiCollectionViewControl`
50
+ * while a `PhiCollectionReorderContext` offers reordering. Pointer and keyboard (`@dnd-kit`, as the Table
51
+ * Control sorts its rows); a drop answers every key in the new order and changes nothing itself -- the
52
+ * order shown is the one the items come in.
53
+ */
54
+ export function PhiCollectionSortableLayoutControl({ mode, gap, minColumnWidth, items, reorder, }) {
55
+ const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
56
+ // dnd-kit names items by string; the keys go back out as the Provider gave them.
57
+ const ids = useMemo(() => reorder.itemKeys.map((key) => String(key)), [reorder.itemKeys]);
58
+ const disabled = reorder.disabled === true;
59
+ const onDragEnd = ({ active, over }) => {
60
+ if (!over || active.id === over.id)
61
+ return;
62
+ const from = ids.indexOf(String(active.id));
63
+ const to = ids.indexOf(String(over.id));
64
+ if (from < 0 || to < 0)
65
+ return;
66
+ reorder.onReorder(arrayMove([...reorder.itemKeys], from, to));
67
+ };
68
+ const style = mode === "stack"
69
+ ? { display: "flex", flexDirection: "column", gap, width: "100%" }
70
+ : { display: "grid", gridTemplateColumns: buildGridColumns(minColumnWidth), gap, width: "100%" };
71
+ return (_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: onDragEnd, children: _jsx(SortableContext, { items: ids, strategy: mode === "stack" ? verticalListSortingStrategy : rectSortingStrategy, children: _jsx("div", { style: style, children: items.map((item, index) => (_jsx(PhiCollectionSortableItem, { id: ids[index], disabled: disabled, handleLabel: reorder.handleLabel, children: item }, ids[index]))) }) }) }));
72
+ }
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
2
  import type { PhiControlSize } from "../../types/control";
3
3
  export type PhiCollectionViewControlProps = {
4
4
  title?: ReactNode;
@@ -1,15 +1,29 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { lazy, Suspense } from "react";
3
4
  import { PHI_VISUAL_ANCHOR_PART_ATTRIBUTE } from "../../types/visual-anchors";
4
5
  import { usePhiConfig } from "../root/phi-config-provider";
5
6
  import { PhiCollectionHeaderControl } from "./phi-collection-header-control";
6
7
  import { PhiCollectionLayoutControl } from "./phi-collection-layout-control";
7
8
  import { PhiPaginationControl } from "./phi-pagination-control";
8
9
  import { PhiSkeletonControl } from "./phi-skeleton-control";
10
+ import { usePhiCollectionReorder } from "./phi-collection-reorder-context";
11
+ // Loaded where a Collection offers reordering, so a Collection that does not carries no drag code.
12
+ const PhiCollectionSortableLayoutControl = lazy(() => import("./phi-collection-sortable-layout-control").then((module) => ({ default: module.PhiCollectionSortableLayoutControl })));
9
13
  export function PhiCollectionViewControl({ title, description, filters, toolbar, panel, diagnostics, body, items, mode = "grid", gap, minColumnWidth, pagination, }) {
10
14
  const { token } = usePhiConfig();
11
15
  const resolvedGap = gap ?? token.paddingSM;
12
- return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingSM, width: "100%", minWidth: 0 }, children: [_jsx(PhiCollectionHeaderControl, { title: title, description: description, filters: filters, toolbar: toolbar }), panel, diagnostics, _jsx("div", { [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: "items", style: { width: "100%", minWidth: 0 }, children: body ?? (_jsx(PhiCollectionLayoutControl, { mode: mode, gap: resolvedGap, minColumnWidth: minColumnWidth ?? 102, items: [...(items ?? [])] })) }), pagination ? (_jsx("div", { [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: "pagination", style: { display: "flex", justifyContent: "flex-end", width: "100%", minWidth: 0 }, children: _jsx(PhiPaginationControl, { page: pagination.page, pageSize: pagination.pageSize, total: pagination.total, simple: pagination.simple, showSizeChanger: pagination.showSizeChanger, pageSizeOptions: pagination.pageSizeOptions, size: pagination.size, onChange: (value) => pagination.onChange(value.page, value.pageSize) }) })) : null] }));
16
+ /*
17
+ * Reordering offered around this Collection (`PhiCollectionReorderContext`, the `collection-view`
18
+ * Widget's `features.reorder`) puts a handle on each item, in grid and stack. Only where the items are
19
+ * the ones the keys name -- one each, the renderer's own `body` not in their place.
20
+ */
21
+ const reorder = usePhiCollectionReorder();
22
+ const itemList = [...(items ?? [])];
23
+ const sortable = reorder != null && body == null && mode !== "masonry" && itemList.length > 0 &&
24
+ itemList.length === reorder.itemKeys.length;
25
+ const layout = (_jsx(PhiCollectionLayoutControl, { mode: mode, gap: resolvedGap, minColumnWidth: minColumnWidth ?? 102, items: itemList }));
26
+ return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingSM, width: "100%", minWidth: 0 }, children: [_jsx(PhiCollectionHeaderControl, { title: title, description: description, filters: filters, toolbar: toolbar }), panel, diagnostics, _jsx("div", { [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: "items", style: { width: "100%", minWidth: 0 }, children: body ?? (sortable ? (_jsx(Suspense, { fallback: layout, children: _jsx(PhiCollectionSortableLayoutControl, { mode: mode === "stack" ? "stack" : "grid", gap: resolvedGap, minColumnWidth: minColumnWidth ?? 102, items: itemList, reorder: reorder }) })) : layout) }), pagination ? (_jsx("div", { [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: "pagination", style: { display: "flex", justifyContent: "flex-end", width: "100%", minWidth: 0 }, children: _jsx(PhiPaginationControl, { page: pagination.page, pageSize: pagination.pageSize, total: pagination.total, simple: pagination.simple, showSizeChanger: pagination.showSizeChanger, pageSizeOptions: pagination.pageSizeOptions, size: pagination.size, onChange: (value) => pagination.onChange(value.page, value.pageSize) }) })) : null] }));
13
27
  }
14
28
  export function PhiCollectionViewSkeletonControl({ mode = "grid", gap, minColumnWidth, active = true, count = 8, }) {
15
29
  const { token } = usePhiConfig();
@@ -1,8 +1,15 @@
1
1
  import type { PhiControlSize } from "../../types/control";
2
2
  import type { PhiMediaAssetTile } from "../../types/media";
3
3
  import { type PhiCollectionLayoutControlProps } from "./phi-collection-layout-control";
4
- export type PhiMediaAssetTileControlProps = {
5
- asset: PhiMediaAssetTile;
4
+ /**
5
+ * What a tile reads of an Asset, and nothing more: a whole `PhiMediaAssetTile` fits, and so does an
6
+ * Asset a Module holds in a shape of its own with these fields (`width`/`height` for the dimensions
7
+ * label, `deliveryPolicy`/`lifecycleStatus` for whether the picture is public and may be optimised).
8
+ */
9
+ export type PhiMediaAssetTileControlAsset = Pick<PhiMediaAssetTile, "id" | "kind" | "originalName" | "title" | "altText" | "contentType" | "deliveryUrl" | "thumbnailUrl" | "previewUrl" | "deliveryPolicy" | "lifecycleStatus" | "width" | "height" | "blurDataUrl">;
10
+ /** `onSelect` and `onDelete` hand back the Asset as it was passed in, in its own type. */
11
+ export type PhiMediaAssetTileControlProps<TAsset extends PhiMediaAssetTileControlAsset = PhiMediaAssetTileControlAsset> = {
12
+ asset: TAsset;
6
13
  minColumnWidth: string | number;
7
14
  selected?: boolean;
8
15
  mode?: "grid" | "masonry" | "stack";
@@ -15,15 +22,15 @@ export type PhiMediaAssetTileControlProps = {
15
22
  * where it was started. The button reports it and refuses a second press while it stands.
16
23
  */
17
24
  deleting?: boolean;
18
- onSelect?: (asset: PhiMediaAssetTile) => void;
19
- onDelete?: (asset: PhiMediaAssetTile) => void;
25
+ onSelect?: (asset: TAsset) => void;
26
+ onDelete?: (asset: TAsset) => void;
20
27
  deleteLabel?: string;
21
28
  showTypeLabel?: boolean;
22
29
  showDeleteAction?: boolean;
23
30
  showDimensions?: boolean;
24
31
  showIdLabel?: boolean;
25
32
  };
26
- export declare function PhiMediaAssetTileControl({ asset, minColumnWidth, selected, mode, size, disabled, deleting, onSelect, onDelete, deleteLabel, showTypeLabel, showDeleteAction, showDimensions, showIdLabel, }: PhiMediaAssetTileControlProps): import("react").JSX.Element;
33
+ export declare function PhiMediaAssetTileControl<TAsset extends PhiMediaAssetTileControlAsset = PhiMediaAssetTileControlAsset>({ asset, minColumnWidth, selected, mode, size, disabled, deleting, onSelect, onDelete, deleteLabel, showTypeLabel, showDeleteAction, showDimensions, showIdLabel, }: PhiMediaAssetTileControlProps<TAsset>): import("react").JSX.Element;
27
34
  export type PhiMediaAssetCollectionSkeletonControlProps = Pick<PhiCollectionLayoutControlProps, "mode" | "gap" | "minColumnWidth"> & {
28
35
  active?: boolean;
29
36
  count?: number;
@@ -29,6 +29,18 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
29
29
  importingItemId?: string | null;
30
30
  /** Why the last import did not work, said above the tiles. */
31
31
  sourceNotice?: string | null;
32
+ /**
33
+ * A file from the reader's machine was chosen to go into the library, where the picker offers that.
34
+ * Answers the Asset it became -- chosen then as if it had been picked in the library -- or null where
35
+ * nothing is to be chosen and the picker stays as it is. Absent, the picker offers no upload.
36
+ */
37
+ onUpload?: (file: File) => Promise<PhiMediaAssetTile | null>;
38
+ /** What the file dialog offers, as a MIME or extension list. */
39
+ uploadAccept?: string;
40
+ /** How far the upload on its way is, in per cent; null while none is. */
41
+ uploadProgress?: number | null;
42
+ /** Why the last upload did not work, said above the library's tiles. */
43
+ uploadNotice?: string | null;
32
44
  folders?: readonly PhiControlOption[];
33
45
  folderValue?: string;
34
46
  query?: string;
@@ -61,6 +73,7 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
61
73
  source: string;
62
74
  importing: string;
63
75
  loadMore: string;
76
+ upload: string;
64
77
  }>;
65
78
  getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
66
79
  popupRootClassName?: string;
@@ -78,4 +91,4 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
78
91
  onMinColumnWidthChange?: (minColumnWidth: number) => void;
79
92
  onReload?: () => void;
80
93
  };
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;
94
+ export declare function PhiMediaPickerControl({ open, value, assets, spaces, spaceValue, sources, sourceValue, sourceItems, sourceHasMore, importingItemId, sourceNotice, onUpload, uploadAccept, uploadProgress, uploadNotice, 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;
@@ -5,6 +5,7 @@ import { usePhiConfig } from "../root/phi-config-provider";
5
5
  import { PhiButtonControl } from "./phi-button-control";
6
6
  import { PhiCascaderControl } from "./phi-cascader-control";
7
7
  import { PhiEmptyControl } from "./phi-empty-control";
8
+ import { PhiFileDropControl } from "./phi-file-drop-control";
8
9
  import { PhiSelectControl } from "./phi-select-control";
9
10
  import { PhiCollectionLayoutControl } from "./phi-collection-layout-control";
10
11
  import { PhiMediaAssetCollectionSkeletonControl, PhiMediaAssetTileControl, } from "./phi-media-asset-tile-control";
@@ -16,7 +17,7 @@ import { PhiSliderControl } from "./phi-slider-control";
16
17
  import { PhiTextControl } from "./phi-text-control";
17
18
  import { usePhiImmediatePicker } from "./use-phi-immediate-picker";
18
19
  import { PhiIcon } from "../shell/phi-icon";
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, }) {
20
+ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [], spaceValue = null, sources = [], sourceValue = "", sourceItems = [], sourceHasMore = false, importingItemId = null, sourceNotice = null, onUpload, uploadAccept, uploadProgress = null, uploadNotice = 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, }) {
20
21
  const { token } = usePhiConfig();
21
22
  const locked = disabled || readOnly;
22
23
  const resolvedMinColumnWidth = normalizePhiMediaPickerMinColumnWidth(minColumnWidth);
@@ -33,6 +34,7 @@ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [],
33
34
  // A source is shown while one other than the library is named; its items stand where the tiles do.
34
35
  const sourceActive = sources.length > 1 && sourceValue !== "";
35
36
  const importing = importingItemId != null;
37
+ const uploading = uploadProgress != null;
36
38
  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
39
  void onSourceItemSelect?.(item).then((asset) => {
38
40
  if (!asset)
@@ -51,6 +53,13 @@ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [],
51
53
  minHeight: 0,
52
54
  }, 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)
53
55
  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] })] }));
56
+ 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 }), onUpload && !sourceActive ? (_jsx(PhiFileDropControl, { accept: uploadAccept, disabled: locked || uploading, onFile: (file) => {
57
+ void onUpload(file).then((asset) => {
58
+ if (!asset)
59
+ return;
60
+ picker.changeValue(asset.id);
61
+ picker.closePicker("commit");
62
+ });
63
+ }, children: _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: "upload", size: "inherit" }), label: uploading ? `${uploadProgress}%` : labels?.upload ?? "Upload", ariaLabel: labels?.upload ?? "Upload", size: "small", loading: uploading, disabled: locked || uploading }) })) : null] }), sourceActive && sourceNotice ? (_jsx(Typography.Text, { type: "danger", role: "alert", children: sourceNotice })) : null, !sourceActive && uploadNotice ? (_jsx(Typography.Text, { type: "danger", role: "alert", children: uploadNotice })) : 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] })] }));
55
64
  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 }) })) }));
56
65
  }
@@ -1,3 +1,3 @@
1
1
  import type { PhiFormFieldProviderProps } from "./form-provider-registry";
2
- export declare function PhiCompoundTableFormControl({ field, label, description, value, onChange, disabled, readOnly, formContext, }: PhiFormFieldProviderProps): import("react").JSX.Element;
2
+ export declare function PhiCompoundTableFormControl({ field, label, description, value, onChange, disabled, readOnly, formContext, labels, }: PhiFormFieldProviderProps): import("react").JSX.Element;
3
3
  export declare function PhiCompoundTreeFormControl({ field, label, description, value, onChange, disabled, readOnly }: PhiFormFieldProviderProps): import("react").JSX.Element;
@@ -10,6 +10,7 @@ import { PhiToolbarControl } from "../controls/phi-toolbar-control";
10
10
  import { readPhiDotPath as readPath } from "../../helpers/dot-path";
11
11
  import { movePhiTableBindingRows } from "../../helpers/table-binding";
12
12
  import { PhiIcon } from "../shell/phi-icon";
13
+ import { readPhiFormTableFieldText as readTableFieldText } from "./table-field-text";
13
14
  function readRecords(value) {
14
15
  return Array.isArray(value)
15
16
  ? value.filter((entry) => isPhiRecord(entry)).map((entry) => ({ ...entry }))
@@ -110,7 +111,7 @@ function applyMove(rows, identityPath, parentPath, move) {
110
111
  ? setPath(row, parentPath, parentIdentity)
111
112
  : row);
112
113
  }
113
- export function PhiCompoundTableFormControl({ field, label, description, value, onChange, disabled, readOnly, formContext, }) {
114
+ export function PhiCompoundTableFormControl({ field, label, description, value, onChange, disabled, readOnly, formContext, labels, }) {
114
115
  const rows = useMemo(() => readRecords(value), [value]);
115
116
  const nextRowSequenceRef = useRef(0);
116
117
  const config = field.config ?? {};
@@ -124,8 +125,9 @@ export function PhiCompoundTableFormControl({ field, label, description, value,
124
125
  : null;
125
126
  const addEnabled = addConfig?.enabled === true;
126
127
  const removeEnabled = removeConfig?.enabled === true;
127
- const addLabel = typeof addConfig?.label === "string" ? addConfig.label : "Add";
128
- const removeLabel = typeof removeConfig?.label === "string" ? removeConfig.label : "Remove";
128
+ const addLabel = readTableFieldText(addConfig?.label, labels, "add");
129
+ const removeLabel = readTableFieldText(removeConfig?.label, labels, "remove");
130
+ const emptyText = readTableFieldText(config.emptyText, labels, "empty");
129
131
  const addSourceFields = isPhiRecord(addConfig?.sourceFields)
130
132
  ? addConfig.sourceFields
131
133
  : null;
@@ -195,7 +197,7 @@ export function PhiCompoundTableFormControl({ field, label, description, value,
195
197
  icon: _jsx(PhiIcon, { name: "plus", size: "inherit" }),
196
198
  type: "primary",
197
199
  }], compact: true, showLabels: true, size: "small", disabled: locked, onActivate: (key) => { if (key === "add")
198
- appendRow(); } })) : null }), _jsx(PhiTableControl, { rows: rows, rowIdentityPath: identityPath, columns: renderedColumns, columnOrder: columnOrder, sortingMode: "none", sorts: [], bordered: config.bordered === true, striped: config.striped === true, size: "small", emptyText: typeof config.emptyText === "string" ? config.emptyText : undefined, layout: layout, rowReordering: config.reorder === true && !locked ? {
200
+ appendRow(); } })) : null }), _jsx(PhiTableControl, { rows: rows, rowIdentityPath: identityPath, columns: renderedColumns, columnOrder: columnOrder, sortingMode: "none", sorts: [], bordered: config.bordered === true, striped: config.striped === true, size: "small", emptyText: emptyText, layout: layout, rowReordering: config.reorder === true && !locked ? {
199
201
  enabled: true,
200
202
  onMove: (move) => onChange?.(applyMove(rows, identityPath, typeof config.parentRowIdentityPath === "string" ? config.parentRowIdentityPath : null, move)),
201
203
  } : undefined })] }));
@@ -5,7 +5,9 @@ import type { PhiFormRenderContext } from "./form-resolution";
5
5
  * What a Form's field types say for themselves, under the keys their controls read.
6
6
  *
7
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`).
8
+ * for every Form that has such a field (`media-asset-field-keys.ts`), and the upload inside it says the
9
+ * upload's refusals and its hold under the upload field's keys. The `table` field says its add, remove and
10
+ * empty words from Core's `widget:table` set (`table-field-labels.ts`) where its config names none.
9
11
  *
10
12
  * A field type whose control speaks -- the upload field's trigger, its drop hint, its holds and the
11
13
  * refusals of the upload -- says it from Core's `widget:upload` Label Set, read here for every Form that
@@ -5,11 +5,16 @@ import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY } from "../../constants/media-l
5
5
  import { phiRuntime } from "../../server-helpers/phi-runtime";
6
6
  import { PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS } from "./media-asset-field-keys";
7
7
  import { PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY, PHI_FORM_UPLOAD_LABEL_KEYS } from "./upload-field-keys";
8
+ import { getPhiTableFormFieldLabels } from "../widgets/label-sets/table";
9
+ import { PHI_FORM_TABLE_FIELD_PROVIDER_KEY } from "./table-field-keys";
10
+ import { PHI_FORM_TABLE_LABEL_KEYS } from "./table-field-labels";
8
11
  /**
9
12
  * What a Form's field types say for themselves, under the keys their controls read.
10
13
  *
11
14
  * 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`).
15
+ * for every Form that has such a field (`media-asset-field-keys.ts`), and the upload inside it says the
16
+ * upload's refusals and its hold under the upload field's keys. The `table` field says its add, remove and
17
+ * empty words from Core's `widget:table` set (`table-field-labels.ts`) where its config names none.
13
18
  *
14
19
  * A field type whose control speaks -- the upload field's trigger, its drop hint, its holds and the
15
20
  * refusals of the upload -- says it from Core's `widget:upload` Label Set, read here for every Form that
@@ -23,7 +28,8 @@ import { PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY, PHI_FORM_UPLOAD_LABEL_KEYS } from "
23
28
  export async function resolvePhiFormFieldLabels(context, descriptor) {
24
29
  const hasUpload = descriptor.fields.some((field) => field.fieldProviderKey === PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY);
25
30
  const hasMediaAsset = descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY);
26
- if (!hasUpload && !hasMediaAsset)
31
+ const hasTable = descriptor.fields.some((field) => field.fieldProviderKey === PHI_FORM_TABLE_FIELD_PROVIDER_KEY);
32
+ if (!hasUpload && !hasMediaAsset && !hasTable)
27
33
  return {};
28
34
  const rt = phiRuntime(context.runtime);
29
35
  const options = {
@@ -31,11 +37,12 @@ export async function resolvePhiFormFieldLabels(context, descriptor) {
31
37
  internalToken: rt.internalToken,
32
38
  locale: context.runtime.locale.current,
33
39
  };
34
- const [upload, media] = await Promise.all([
35
- hasUpload ? readUploadFieldLabels(options) : {},
40
+ const [upload, media, table] = await Promise.all([
41
+ hasUpload || hasMediaAsset ? readUploadFieldLabels(options) : {},
36
42
  hasMediaAsset ? readMediaAssetFieldLabels(options) : {},
43
+ hasTable ? readTableFieldLabels(options) : {},
37
44
  ]);
38
- return { ...upload, ...media };
45
+ return { ...upload, ...media, ...table };
39
46
  }
40
47
  async function readUploadFieldLabels(options) {
41
48
  const { field, refusals } = await getPhiMediaUploadLabels(options);
@@ -56,8 +63,13 @@ async function readUploadFieldLabels(options) {
56
63
  [keys.errorFolderLocked]: refusals.errorFolderLocked,
57
64
  };
58
65
  }
66
+ async function readTableFieldLabels(options) {
67
+ const { add, remove, empty } = await getPhiTableFormFieldLabels(options);
68
+ const keys = PHI_FORM_TABLE_LABEL_KEYS;
69
+ return { [keys.add]: add, [keys.remove]: remove, [keys.empty]: empty };
70
+ }
59
71
  async function readMediaAssetFieldLabels(options) {
60
- const { tool, picker, space } = await getPhiMediaWidgetLabels(options);
72
+ const { tool, picker, space, upload } = await getPhiMediaWidgetLabels(options);
61
73
  const keys = PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS;
62
74
  return {
63
75
  [keys.popoverTitle]: picker.popoverTitle,
@@ -74,5 +86,6 @@ async function readMediaAssetFieldLabels(options) {
74
86
  [keys.importingLabel]: picker.importingLabel,
75
87
  [keys.importFailedText]: picker.importFailedText,
76
88
  [keys.loadMoreLabel]: picker.loadMoreLabel,
89
+ [keys.uploadLabel]: upload.uploadToggleLabel,
77
90
  };
78
91
  }
@@ -2,6 +2,7 @@ import { createPhiModuleScopedKey } from "../../constants/runtime-module-ownersh
2
2
  import { PhiMediaKind } from "../../constants/media";
3
3
  import { PHIS_PAYMENT_CURRENCY_EXPONENTS } from "@phis/contracts/payments";
4
4
  import { PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY } from "./upload-field-keys";
5
+ import { PHI_FORM_TABLE_FIELD_PROVIDER_KEY } from "./table-field-keys";
5
6
  export function createPhiSharedFormProviderKey(kind, key) {
6
7
  const normalizedKey = key.trim();
7
8
  if (!normalizedKey || normalizedKey.includes("/") || normalizedKey.includes(":")) {
@@ -29,7 +30,7 @@ export const PHI_FORM_FIELD_PROVIDER_KEYS = {
29
30
  switch: createPhiSharedFormProviderKey("field", "switch"),
30
31
  segmented: createPhiSharedFormProviderKey("field", "segmented"),
31
32
  cascader: createPhiSharedFormProviderKey("field", "cascader"),
32
- table: createPhiSharedFormProviderKey("field", "table"),
33
+ table: PHI_FORM_TABLE_FIELD_PROVIDER_KEY,
33
34
  tree: createPhiSharedFormProviderKey("field", "tree"),
34
35
  // Spelled beside its label keys, which the Form Widget reads on the Server without this whole file.
35
36
  upload: PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY,
@@ -7,7 +7,8 @@
7
7
  * Module that places the field translates none of them. A Foundation file for the same reason
8
8
  * `upload-field-keys.ts` is: the Server reads it without the Asset Module, and the Module's control reads
9
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`).
10
+ * are the Module's (`PHI_FORM_MEDIA_ASSET_LABEL_KEYS`). The upload inside the picker says its refusals and
11
+ * its hold under the upload field's keys (`PHI_FORM_UPLOAD_LABEL_KEYS`), read for this field as well.
11
12
  */
12
13
  export declare const PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS: {
13
14
  readonly popoverTitle: "mediaAssetPickerTitle";
@@ -24,4 +25,6 @@ export declare const PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS: {
24
25
  readonly importingLabel: "mediaAssetPickerImporting";
25
26
  readonly importFailedText: "mediaAssetPickerImportFailed";
26
27
  readonly loadMoreLabel: "mediaAssetPickerLoadMore";
28
+ /** The picker's upload button (the Media Label Set's upload toggle). */
29
+ readonly uploadLabel: "mediaAssetPickerUpload";
27
30
  };
@@ -7,7 +7,8 @@
7
7
  * Module that places the field translates none of them. A Foundation file for the same reason
8
8
  * `upload-field-keys.ts` is: the Server reads it without the Asset Module, and the Module's control reads
9
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`).
10
+ * are the Module's (`PHI_FORM_MEDIA_ASSET_LABEL_KEYS`). The upload inside the picker says its refusals and
11
+ * its hold under the upload field's keys (`PHI_FORM_UPLOAD_LABEL_KEYS`), read for this field as well.
11
12
  */
12
13
  export const PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS = {
13
14
  popoverTitle: "mediaAssetPickerTitle",
@@ -24,4 +25,6 @@ export const PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS = {
24
25
  importingLabel: "mediaAssetPickerImporting",
25
26
  importFailedText: "mediaAssetPickerImportFailed",
26
27
  loadMoreLabel: "mediaAssetPickerLoadMore",
28
+ /** The picker's upload button (the Media Label Set's upload toggle). */
29
+ uploadLabel: "mediaAssetPickerUpload",
27
30
  };
@@ -0,0 +1,8 @@
1
+ import type { PhiFormProviderKey } from "../../types/form-descriptor";
2
+ /**
3
+ * The Core `table` field's own names, apart from the rest of the Form contract, for the reason
4
+ * `upload-field-keys.ts` is: the Form Widget reads the field's words on the Server (`form-field-labels.ts`)
5
+ * and needs only which field type is the table field; the keys its control reads the words under are in
6
+ * `table-field-labels.ts`, without imports, because Core's `widget:table` set reads its defaults there.
7
+ */
8
+ export declare const PHI_FORM_TABLE_FIELD_PROVIDER_KEY: PhiFormProviderKey;
@@ -0,0 +1,8 @@
1
+ import { createPhiModuleScopedKey } from "../../constants/runtime-module-ownership";
2
+ /**
3
+ * The Core `table` field's own names, apart from the rest of the Form contract, for the reason
4
+ * `upload-field-keys.ts` is: the Form Widget reads the field's words on the Server (`form-field-labels.ts`)
5
+ * and needs only which field type is the table field; the keys its control reads the words under are in
6
+ * `table-field-labels.ts`, without imports, because Core's `widget:table` set reads its defaults there.
7
+ */
8
+ export const PHI_FORM_TABLE_FIELD_PROVIDER_KEY = createPhiModuleScopedKey("form-field", "table");
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The words the table field says where its `config` names none: the add action, the remove action and
3
+ * the empty table. The Form Widget puts Core's `widget:table` words here for every Form with a table
4
+ * field, and the Form's own Label Set may say them differently under the same keys.
5
+ */
6
+ export declare const PHI_FORM_TABLE_LABEL_KEYS: {
7
+ readonly add: "tableAdd";
8
+ readonly remove: "tableRemove";
9
+ readonly empty: "tableEmpty";
10
+ };
11
+ /** The source wording of those words, for a Form rendered without a resolution behind it. */
12
+ export declare const PHI_FORM_TABLE_DEFAULT_LABELS: {
13
+ readonly add: "Add";
14
+ readonly remove: "Remove";
15
+ readonly empty: "No rows yet.";
16
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The words the table field says where its `config` names none: the add action, the remove action and
3
+ * the empty table. The Form Widget puts Core's `widget:table` words here for every Form with a table
4
+ * field, and the Form's own Label Set may say them differently under the same keys.
5
+ */
6
+ export const PHI_FORM_TABLE_LABEL_KEYS = {
7
+ add: "tableAdd",
8
+ remove: "tableRemove",
9
+ empty: "tableEmpty",
10
+ };
11
+ /** The source wording of those words, for a Form rendered without a resolution behind it. */
12
+ export const PHI_FORM_TABLE_DEFAULT_LABELS = {
13
+ add: "Add",
14
+ remove: "Remove",
15
+ empty: "No rows yet.",
16
+ };
@@ -0,0 +1,9 @@
1
+ import { PHI_FORM_TABLE_LABEL_KEYS } from "./table-field-labels";
2
+ /**
3
+ * One of the table field's words: the text its `config` names -- a label reference (`{ kind: "label",
4
+ * key, fallback }`) read from the Form's labels, or a literal (`{ kind: "literal", value }`), as a field's
5
+ * own label is written -- or else the Form's word under `PHI_FORM_TABLE_LABEL_KEYS`, which the Form Widget
6
+ * fills from Core's `widget:table` set, or else the English source. A plain string is not a text: it would
7
+ * be English in every language.
8
+ */
9
+ export declare function readPhiFormTableFieldText(value: unknown, labels: Readonly<Record<string, string>> | undefined, key: keyof typeof PHI_FORM_TABLE_LABEL_KEYS): string;
@@ -0,0 +1,20 @@
1
+ import { isPhiRecord } from "../../helpers/is-record";
2
+ import { resolvePhiFormText } from "@phis/contracts/forms";
3
+ import { PHI_FORM_TABLE_DEFAULT_LABELS, PHI_FORM_TABLE_LABEL_KEYS } from "./table-field-labels";
4
+ /**
5
+ * One of the table field's words: the text its `config` names -- a label reference (`{ kind: "label",
6
+ * key, fallback }`) read from the Form's labels, or a literal (`{ kind: "literal", value }`), as a field's
7
+ * own label is written -- or else the Form's word under `PHI_FORM_TABLE_LABEL_KEYS`, which the Form Widget
8
+ * fills from Core's `widget:table` set, or else the English source. A plain string is not a text: it would
9
+ * be English in every language.
10
+ */
11
+ export function readPhiFormTableFieldText(value, labels, key) {
12
+ if (isPhiRecord(value)) {
13
+ if (value.kind === "label" && typeof value.key === "string" && typeof value.fallback === "string") {
14
+ return resolvePhiFormText({ kind: "label", key: value.key, fallback: value.fallback }, labels);
15
+ }
16
+ if (value.kind === "literal" && typeof value.value === "string")
17
+ return value.value;
18
+ }
19
+ return labels?.[PHI_FORM_TABLE_LABEL_KEYS[key]]?.trim() || PHI_FORM_TABLE_DEFAULT_LABELS[key];
20
+ }
@@ -0,0 +1,10 @@
1
+ import { type PhiMediaUploadLabels } from "../media/media-upload-labels";
2
+ /**
3
+ * The upload's refusals as a field control reads them from its labels: under `PHI_FORM_UPLOAD_LABEL_KEYS`,
4
+ * where the Form Widget put Core's `widget:upload` words for every Form with an upload field or a
5
+ * `media-asset` field (`form-field-labels.ts`), and the source wording where it put none.
6
+ *
7
+ * Beside the keys rather than in their file: the keys are on the Server graph of every Page
8
+ * (`form-field-labels.ts`, `form-provider-contract.ts`), and only the field controls read the words back.
9
+ */
10
+ export declare function readPhiFormUploadRefusalLabels(labels: Readonly<Record<string, string>> | undefined): PhiMediaUploadLabels;
@@ -0,0 +1,24 @@
1
+ import { PHI_MEDIA_UPLOAD_DEFAULT_LABELS } from "../media/media-upload-labels";
2
+ import { PHI_FORM_UPLOAD_LABEL_KEYS } from "./upload-field-keys";
3
+ /**
4
+ * The upload's refusals as a field control reads them from its labels: under `PHI_FORM_UPLOAD_LABEL_KEYS`,
5
+ * where the Form Widget put Core's `widget:upload` words for every Form with an upload field or a
6
+ * `media-asset` field (`form-field-labels.ts`), and the source wording where it put none.
7
+ *
8
+ * Beside the keys rather than in their file: the keys are on the Server graph of every Page
9
+ * (`form-field-labels.ts`, `form-provider-contract.ts`), and only the field controls read the words back.
10
+ */
11
+ export function readPhiFormUploadRefusalLabels(labels) {
12
+ const read = (key) => labels?.[PHI_FORM_UPLOAD_LABEL_KEYS[key]]?.trim() || PHI_MEDIA_UPLOAD_DEFAULT_LABELS[key];
13
+ return {
14
+ errorGeneric: read("errorGeneric"),
15
+ errorNetwork: read("errorNetwork"),
16
+ errorTooLarge: read("errorTooLarge"),
17
+ errorDuplicate: read("errorDuplicate"),
18
+ errorTypeNotAllowed: read("errorTypeNotAllowed"),
19
+ errorQuotaExceeded: read("errorQuotaExceeded"),
20
+ errorSpaceUnavailable: read("errorSpaceUnavailable"),
21
+ errorStorageUnreachable: read("errorStorageUnreachable"),
22
+ errorFolderLocked: read("errorFolderLocked"),
23
+ };
24
+ }