@phis/ui 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/controls/phi-collection-reorder-context.d.ts +21 -0
- package/components/controls/phi-collection-reorder-context.js +6 -0
- package/components/controls/phi-collection-sortable-layout-control.d.ts +17 -0
- package/components/controls/phi-collection-sortable-layout-control.js +72 -0
- package/components/controls/phi-collection-view-control.d.ts +1 -1
- package/components/controls/phi-collection-view-control.js +15 -1
- package/components/controls/phi-media-asset-tile-control.d.ts +14 -6
- package/components/controls/phi-media-picker-control.d.ts +13 -2
- package/components/controls/phi-media-picker-control.js +9 -2
- package/components/forms/compound-form-controls.d.ts +1 -1
- package/components/forms/compound-form-controls.js +6 -4
- package/components/forms/form-field-labels.d.ts +4 -2
- package/components/forms/form-field-labels.js +30 -9
- package/components/forms/form-provider-contract.js +2 -1
- package/components/forms/media-asset-field-keys.d.ts +13 -2
- package/components/forms/media-asset-field-keys.js +17 -2
- package/components/forms/table-field-keys.d.ts +8 -0
- package/components/forms/table-field-keys.js +8 -0
- package/components/forms/table-field-labels.d.ts +16 -0
- package/components/forms/table-field-labels.js +16 -0
- package/components/forms/table-field-text.d.ts +9 -0
- package/components/forms/table-field-text.js +20 -0
- package/components/forms/upload-field-refusal-labels.d.ts +10 -0
- package/components/forms/upload-field-refusal-labels.js +24 -0
- package/components/forms/upload-form-control.js +3 -16
- package/components/media/label-sets/media.js +4 -0
- package/components/media/media-folder-name-path.d.ts +14 -0
- package/components/media/media-folder-name-path.js +40 -2
- package/components/media/media-library-resource.d.ts +70 -0
- package/components/media/media-library-resource.js +41 -0
- package/components/media/media-upload-flow.d.ts +13 -1
- package/components/media/media-upload-flow.js +16 -0
- package/components/media/media-widget-labels.d.ts +13 -0
- package/components/media/media-widget-labels.js +2 -0
- package/components/media/phi-area-upload-widget.d.ts +31 -1
- package/components/media/phi-area-upload-widget.js +33 -7
- package/components/media/phi-image-preview-data.d.ts +8 -1
- package/components/media/phi-image-preview-data.js +29 -0
- package/components/media/phi-media-picker-binding.d.ts +50 -1
- package/components/media/phi-media-picker-binding.js +86 -6
- package/components/media/phi-media-upload.d.ts +7 -1
- package/components/media/phi-media-upload.js +17 -5
- package/components/media/use-media-library-add-picker.d.ts +94 -0
- package/components/media/use-media-library-add-picker.js +40 -0
- package/components/widgets/client/shared/phi-collection-reorder.d.ts +45 -0
- package/components/widgets/client/shared/phi-collection-reorder.js +110 -0
- package/components/widgets/client/shared/phi-collection-view-binding.js +2 -1
- package/components/widgets/label-sets/collection-view.d.ts +4 -0
- package/components/widgets/label-sets/collection-view.js +16 -0
- package/components/widgets/label-sets/table.d.ts +6 -0
- package/components/widgets/label-sets/table.js +10 -0
- package/components/widgets/label-types/collection-view.d.ts +8 -0
- package/components/widgets/label-types/collection-view.js +4 -0
- package/constants/media-library-provider-keys.d.ts +7 -0
- package/constants/media-library-provider-keys.js +7 -0
- package/constants/runtime-module-ownership.js +1 -0
- package/controls.d.ts +1 -1
- package/helpers/preset-tree-contract-check.d.ts +35 -0
- package/helpers/preset-tree-contract-check.js +211 -0
- package/module-page-check.d.ts +6 -0
- package/module-page-check.js +6 -0
- package/package.json +1 -1
- package/plugins/runtime-modules/asset/data-providers.d.ts +56 -38
- package/plugins/runtime-modules/asset/data-providers.js +4 -32
- package/plugins/runtime-modules/asset/definition.d.ts +123 -38
- package/plugins/runtime-modules/asset/definition.js +2 -1
- package/plugins/runtime-modules/asset/form-providers.d.ts +93 -2
- package/plugins/runtime-modules/asset/form-providers.js +76 -11
- package/plugins/runtime-modules/asset/form-ui-provider.js +7 -1
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +34 -4
- package/plugins/runtime-modules/asset/media-asset-field.js +30 -5
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +14 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +72 -37
- package/plugins/runtime-modules/asset/media-assets-field.d.ts +37 -0
- package/plugins/runtime-modules/asset/media-assets-field.js +81 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +27 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.js +182 -0
- package/plugins/runtime-modules/asset/media-field-picker-labels.d.ts +9 -0
- package/plugins/runtime-modules/asset/media-field-picker-labels.js +49 -0
- package/plugins/runtime-modules/asset/services/collection.js +12 -0
- package/plugins/runtime-modules/builder/page-meta-form.js +6 -6
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.d.ts +24 -0
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.js +55 -0
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +26 -2
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +125 -32
- package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +59 -5
- package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +53 -2
- package/plugins/runtime-modules/core/widgets/collection-view/config.js +47 -0
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +5 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.js +26 -9
- package/plugins/runtime-modules/descriptor-compiler.d.ts +4 -0
- package/plugins/runtime-modules/descriptor-compiler.js +9 -204
- package/plugins/runtime-modules/resolver.js +31 -5
- package/types/collection-provider.d.ts +7 -0
- package/types/collection-view-widget.d.ts +30 -0
- package/types/core-widget-placements.d.ts +14 -0
- package/types/media.d.ts +16 -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,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,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
|
-
|
|
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,16 @@
|
|
|
1
1
|
import type { PhiControlSize } from "../../types/control";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PhiMediaCollectionItem } from "../../types/media";
|
|
3
3
|
import { type PhiCollectionLayoutControlProps } from "./phi-collection-layout-control";
|
|
4
|
-
|
|
5
|
-
|
|
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). The
|
|
8
|
+
* item a Collection hands the Media renderer is this and its Folder (`PhiMediaCollectionItem`).
|
|
9
|
+
*/
|
|
10
|
+
export type PhiMediaAssetTileControlAsset = Omit<PhiMediaCollectionItem, "folderId">;
|
|
11
|
+
/** `onSelect` and `onDelete` hand back the Asset as it was passed in, in its own type. */
|
|
12
|
+
export type PhiMediaAssetTileControlProps<TAsset extends PhiMediaAssetTileControlAsset = PhiMediaAssetTileControlAsset> = {
|
|
13
|
+
asset: TAsset;
|
|
6
14
|
minColumnWidth: string | number;
|
|
7
15
|
selected?: boolean;
|
|
8
16
|
mode?: "grid" | "masonry" | "stack";
|
|
@@ -15,15 +23,15 @@ export type PhiMediaAssetTileControlProps = {
|
|
|
15
23
|
* where it was started. The button reports it and refuses a second press while it stands.
|
|
16
24
|
*/
|
|
17
25
|
deleting?: boolean;
|
|
18
|
-
onSelect?: (asset:
|
|
19
|
-
onDelete?: (asset:
|
|
26
|
+
onSelect?: (asset: TAsset) => void;
|
|
27
|
+
onDelete?: (asset: TAsset) => void;
|
|
20
28
|
deleteLabel?: string;
|
|
21
29
|
showTypeLabel?: boolean;
|
|
22
30
|
showDeleteAction?: boolean;
|
|
23
31
|
showDimensions?: boolean;
|
|
24
32
|
showIdLabel?: boolean;
|
|
25
33
|
};
|
|
26
|
-
export declare function PhiMediaAssetTileControl({ asset, minColumnWidth, selected, mode, size, disabled, deleting, onSelect, onDelete, deleteLabel, showTypeLabel, showDeleteAction, showDimensions, showIdLabel, }: PhiMediaAssetTileControlProps): import("react").JSX.Element;
|
|
34
|
+
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
35
|
export type PhiMediaAssetCollectionSkeletonControlProps = Pick<PhiCollectionLayoutControlProps, "mode" | "gap" | "minColumnWidth"> & {
|
|
28
36
|
active?: boolean;
|
|
29
37
|
count?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import type { PhisMediaSourceItem } from "@phis/contracts/media-source";
|
|
3
3
|
import type { PhiMediaAssetTile } from "../../types/media";
|
|
4
4
|
import type { PhiControlOption } from "./phi-control-options";
|
|
@@ -29,6 +29,16 @@ 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
|
+
* The upload surface, where the picker offers one: the Upload button beside Reload shows it above the
|
|
34
|
+
* library's tiles -- the Media library's own upload surface (`PhiAreaUploadBinding`, one file), which
|
|
35
|
+
* the host draws, so a picker without upload carries no transport. It is drawn only while the picker is
|
|
36
|
+
* open and the panel shown, so closing either stops what is on its way. `choose` chooses an Asset that
|
|
37
|
+
* arrived as if it had been picked in the library, and closes the picker. Absent, no upload is offered.
|
|
38
|
+
*/
|
|
39
|
+
uploadPanel?: (choose: (assetId: number) => void) => ReactNode;
|
|
40
|
+
/** Why the last upload did not work, or the Folder could not be opened, said above the library's tiles. */
|
|
41
|
+
uploadNotice?: string | null;
|
|
32
42
|
folders?: readonly PhiControlOption[];
|
|
33
43
|
folderValue?: string;
|
|
34
44
|
query?: string;
|
|
@@ -61,6 +71,7 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
|
|
|
61
71
|
source: string;
|
|
62
72
|
importing: string;
|
|
63
73
|
loadMore: string;
|
|
74
|
+
upload: string;
|
|
64
75
|
}>;
|
|
65
76
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
66
77
|
popupRootClassName?: string;
|
|
@@ -78,4 +89,4 @@ export type PhiMediaPickerControlProps = PhiPickerTransactionCallbacks<number |
|
|
|
78
89
|
onMinColumnWidthChange?: (minColumnWidth: number) => void;
|
|
79
90
|
onReload?: () => void;
|
|
80
91
|
};
|
|
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;
|
|
92
|
+
export declare function PhiMediaPickerControl({ open, value, assets, spaces, spaceValue, sources, sourceValue, sourceItems, sourceHasMore, importingItemId, sourceNotice, uploadPanel, 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;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
3
4
|
import { Flex, Typography } from "antd";
|
|
4
5
|
import { usePhiConfig } from "../root/phi-config-provider";
|
|
5
6
|
import { PhiButtonControl } from "./phi-button-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, uploadPanel, 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,8 @@ 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 [uploadShown, setUploadShown] = useState(false);
|
|
38
|
+
const uploadOffered = uploadPanel != null && !sourceActive;
|
|
36
39
|
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
40
|
void onSourceItemSelect?.(item).then((asset) => {
|
|
38
41
|
if (!asset)
|
|
@@ -51,6 +54,10 @@ export function PhiMediaPickerControl({ open, value = null, assets, spaces = [],
|
|
|
51
54
|
minHeight: 0,
|
|
52
55
|
}, 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
56
|
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 })
|
|
57
|
+
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 }), uploadOffered ? (_jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: "upload", size: "inherit" }), ariaLabel: labels?.upload ?? "Upload", tooltip: labels?.upload ?? "Upload", type: uploadShown ? "primary" : "default", size: "small", disabled: locked, onClick: () => setUploadShown((current) => !current) })) : null] }), uploadOffered && uploadShown && picker.open && !locked ? uploadPanel((assetId) => {
|
|
58
|
+
setUploadShown(false);
|
|
59
|
+
picker.changeValue(assetId);
|
|
60
|
+
picker.closePicker("commit");
|
|
61
|
+
}) : 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
62
|
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
63
|
}
|
|
@@ -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 =
|
|
128
|
-
const removeLabel =
|
|
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:
|
|
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 })] }));
|
|
@@ -4,8 +4,10 @@ import type { PhiFormRenderContext } from "./form-resolution";
|
|
|
4
4
|
/**
|
|
5
5
|
* What a Form's field types say for themselves, under the keys their controls read.
|
|
6
6
|
*
|
|
7
|
-
* The `media-asset`
|
|
8
|
-
* for every Form that has such a field
|
|
7
|
+
* The `media-asset` and `media-assets` fields are the same: the picker they open and the upload surface
|
|
8
|
+
* say the Media Label Set's words, read here for every Form that has such a field
|
|
9
|
+
* (`media-asset-field-keys.ts`), and the upload says its 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
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { getPhiMediaWidgetLabels } from "../media/label-sets/media";
|
|
3
3
|
import { getPhiMediaUploadLabels } from "../media/label-sets/media-upload";
|
|
4
|
-
import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY } from "../../constants/media-library-provider-keys";
|
|
4
|
+
import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY, } from "../../constants/media-library-provider-keys";
|
|
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
|
-
* The `media-asset`
|
|
12
|
-
* for every Form that has such a field
|
|
14
|
+
* The `media-asset` and `media-assets` fields are the same: the picker they open and the upload surface
|
|
15
|
+
* say the Media Label Set's words, read here for every Form that has such a field
|
|
16
|
+
* (`media-asset-field-keys.ts`), and the upload says its 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
|
|
@@ -22,8 +27,10 @@ import { PHI_FORM_UPLOAD_FIELD_PROVIDER_KEY, PHI_FORM_UPLOAD_LABEL_KEYS } from "
|
|
|
22
27
|
*/
|
|
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
|
-
const hasMediaAsset = descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY
|
|
26
|
-
|
|
30
|
+
const hasMediaAsset = descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY ||
|
|
31
|
+
field.fieldProviderKey === PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY);
|
|
32
|
+
const hasTable = descriptor.fields.some((field) => field.fieldProviderKey === PHI_FORM_TABLE_FIELD_PROVIDER_KEY);
|
|
33
|
+
if (!hasUpload && !hasMediaAsset && !hasTable)
|
|
27
34
|
return {};
|
|
28
35
|
const rt = phiRuntime(context.runtime);
|
|
29
36
|
const options = {
|
|
@@ -31,11 +38,12 @@ export async function resolvePhiFormFieldLabels(context, descriptor) {
|
|
|
31
38
|
internalToken: rt.internalToken,
|
|
32
39
|
locale: context.runtime.locale.current,
|
|
33
40
|
};
|
|
34
|
-
const [upload, media] = await Promise.all([
|
|
35
|
-
hasUpload ? readUploadFieldLabels(options) : {},
|
|
41
|
+
const [upload, media, table] = await Promise.all([
|
|
42
|
+
hasUpload || hasMediaAsset ? readUploadFieldLabels(options) : {},
|
|
36
43
|
hasMediaAsset ? readMediaAssetFieldLabels(options) : {},
|
|
44
|
+
hasTable ? readTableFieldLabels(options) : {},
|
|
37
45
|
]);
|
|
38
|
-
return { ...upload, ...media };
|
|
46
|
+
return { ...upload, ...media, ...table };
|
|
39
47
|
}
|
|
40
48
|
async function readUploadFieldLabels(options) {
|
|
41
49
|
const { field, refusals } = await getPhiMediaUploadLabels(options);
|
|
@@ -56,8 +64,13 @@ async function readUploadFieldLabels(options) {
|
|
|
56
64
|
[keys.errorFolderLocked]: refusals.errorFolderLocked,
|
|
57
65
|
};
|
|
58
66
|
}
|
|
67
|
+
async function readTableFieldLabels(options) {
|
|
68
|
+
const { add, remove, empty } = await getPhiTableFormFieldLabels(options);
|
|
69
|
+
const keys = PHI_FORM_TABLE_LABEL_KEYS;
|
|
70
|
+
return { [keys.add]: add, [keys.remove]: remove, [keys.empty]: empty };
|
|
71
|
+
}
|
|
59
72
|
async function readMediaAssetFieldLabels(options) {
|
|
60
|
-
const { tool, picker, space } = await getPhiMediaWidgetLabels(options);
|
|
73
|
+
const { tool, picker, space, upload } = await getPhiMediaWidgetLabels(options);
|
|
61
74
|
const keys = PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS;
|
|
62
75
|
return {
|
|
63
76
|
[keys.popoverTitle]: picker.popoverTitle,
|
|
@@ -74,5 +87,13 @@ async function readMediaAssetFieldLabels(options) {
|
|
|
74
87
|
[keys.importingLabel]: picker.importingLabel,
|
|
75
88
|
[keys.importFailedText]: picker.importFailedText,
|
|
76
89
|
[keys.loadMoreLabel]: picker.loadMoreLabel,
|
|
90
|
+
[keys.chooseFromLibraryLabel]: tool.chooseFromLibraryLabel,
|
|
91
|
+
[keys.uploadLabel]: upload.uploadToggleLabel,
|
|
92
|
+
[keys.uploadDropTitle]: upload.dropTitle,
|
|
93
|
+
[keys.uploadDropHint]: upload.dropHint,
|
|
94
|
+
[keys.uploadRetryLabel]: upload.retryLabel,
|
|
95
|
+
[keys.uploadDoneLabel]: upload.doneLabel,
|
|
96
|
+
[keys.uploadFailedLabel]: upload.failedLabel,
|
|
97
|
+
[keys.uploadSuccessTemplate]: upload.uploadSuccessTemplate,
|
|
77
98
|
};
|
|
78
99
|
}
|
|
@@ -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:
|
|
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,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `media-asset`
|
|
2
|
+
* The `media-asset` and `media-assets` fields' picker words, under the keys their controls read them from.
|
|
3
3
|
*
|
|
4
4
|
* The field opens the Media library's own picker, and the picker's words are the Media Label Set's
|
|
5
5
|
* (`getPhiMediaWidgetLabels`). The Form Widget reads that set on the Server for every Form that has a
|
|
@@ -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,14 @@ 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 `media-assets` field's button that opens the picker (the Media Label Set's "Choose from Media library"). */
|
|
29
|
+
readonly chooseFromLibraryLabel: "mediaAssetPickerChooseFromLibrary";
|
|
30
|
+
/** The picker's upload button (the Media Label Set's upload toggle). */
|
|
31
|
+
readonly uploadLabel: "mediaAssetPickerUpload";
|
|
32
|
+
readonly uploadDropTitle: "mediaAssetPickerUploadDropTitle";
|
|
33
|
+
readonly uploadDropHint: "mediaAssetPickerUploadDropHint";
|
|
34
|
+
readonly uploadRetryLabel: "mediaAssetPickerUploadRetry";
|
|
35
|
+
readonly uploadDoneLabel: "mediaAssetPickerUploadDone";
|
|
36
|
+
readonly uploadFailedLabel: "mediaAssetPickerUploadFailed";
|
|
37
|
+
readonly uploadSuccessTemplate: "mediaAssetPickerUploadSuccess";
|
|
27
38
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `media-asset`
|
|
2
|
+
* The `media-asset` and `media-assets` fields' picker words, under the keys their controls read them from.
|
|
3
3
|
*
|
|
4
4
|
* The field opens the Media library's own picker, and the picker's words are the Media Label Set's
|
|
5
5
|
* (`getPhiMediaWidgetLabels`). The Form Widget reads that set on the Server for every Form that has a
|
|
@@ -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,18 @@ export const PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS = {
|
|
|
24
25
|
importingLabel: "mediaAssetPickerImporting",
|
|
25
26
|
importFailedText: "mediaAssetPickerImportFailed",
|
|
26
27
|
loadMoreLabel: "mediaAssetPickerLoadMore",
|
|
28
|
+
/** The `media-assets` field's button that opens the picker (the Media Label Set's "Choose from Media library"). */
|
|
29
|
+
chooseFromLibraryLabel: "mediaAssetPickerChooseFromLibrary",
|
|
30
|
+
/** The picker's upload button (the Media Label Set's upload toggle). */
|
|
31
|
+
uploadLabel: "mediaAssetPickerUpload",
|
|
32
|
+
/*
|
|
33
|
+
* The upload surface the button shows, the Media library's own (`PhiAreaUploadBinding`): its drop area,
|
|
34
|
+
* the state of the file on its way, and the message once it arrived (`widget:upload`'s `area_*`).
|
|
35
|
+
*/
|
|
36
|
+
uploadDropTitle: "mediaAssetPickerUploadDropTitle",
|
|
37
|
+
uploadDropHint: "mediaAssetPickerUploadDropHint",
|
|
38
|
+
uploadRetryLabel: "mediaAssetPickerUploadRetry",
|
|
39
|
+
uploadDoneLabel: "mediaAssetPickerUploadDone",
|
|
40
|
+
uploadFailedLabel: "mediaAssetPickerUploadFailed",
|
|
41
|
+
uploadSuccessTemplate: "mediaAssetPickerUploadSuccess",
|
|
27
42
|
};
|
|
@@ -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;
|