@phis/ui 0.5.7 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/controls/phi-amount-list-control.d.ts +69 -0
- package/components/controls/phi-amount-list-control.js +15 -0
- package/components/controls/phi-button-control.js +16 -2
- package/components/controls/phi-form-control.d.ts +6 -0
- package/components/controls/phi-form-control.js +23 -7
- package/components/controls/phi-media-picker-control.d.ts +3 -1
- package/components/controls/phi-media-picker-control.js +2 -2
- package/components/forms/form-descriptor-runtime-client.d.ts +3 -1
- package/components/forms/form-descriptor-runtime-client.js +2 -2
- package/components/forms/form-field-provider-modules.d.ts +23 -0
- package/components/forms/form-field-provider-modules.js +28 -0
- package/components/forms/form-provider-contract.d.ts +7 -0
- package/components/forms/form-provider-contract.js +7 -0
- package/components/forms/lazy-form-field-control.d.ts +14 -0
- package/components/forms/lazy-form-field-control.js +35 -0
- package/components/forms/phi-form-widget.d.ts +3 -2
- package/components/forms/phi-form-widget.js +21 -3
- package/components/forms/shared-form-provider-registry.js +1 -33
- package/components/media/phi-area-upload-widget.js +6 -58
- package/components/media/phi-media-picker-binding.d.ts +16 -1
- package/components/media/phi-media-picker-binding.js +3 -2
- package/components/media/phi-media-upload.d.ts +12 -0
- package/components/media/phi-media-upload.js +22 -0
- package/components/media/phi-upload-drop-area.d.ts +22 -0
- package/components/media/phi-upload-drop-area.js +49 -0
- package/components/root/phi-root-layout.d.ts +1 -0
- package/components/root/phi-root-layout.js +1 -0
- package/components/widgets/helpers/semantic-html-translation.d.ts +4 -1
- package/components/widgets/helpers/semantic-html-translation.js +4 -2
- package/components/widgets/label-sets/admin-users.d.ts +9 -1
- package/components/widgets/label-sets/admin-users.js +14 -2
- package/components/widgets/label-sets/slot-upload.js +6 -3
- package/components/widgets/label-types/slot-upload.d.ts +7 -1
- package/components/widgets/label-types/slot-upload.js +2 -1
- package/components/widgets/shared/markdown-render.js +6 -6
- package/constants/media-library-provider-keys.d.ts +9 -0
- package/constants/media-library-provider-keys.js +9 -0
- package/constants/media.d.ts +2 -0
- package/constants/media.js +2 -0
- package/constants/runtime-module-ownership.js +2 -0
- package/controls.d.ts +4 -0
- package/controls.js +2 -0
- package/gateway/signet-route.d.ts +24 -0
- package/gateway/signet-route.js +107 -0
- package/gateway/site-proxy.js +14 -7
- package/helpers/phi-metadata.d.ts +8 -6
- package/helpers/phi-metadata.js +9 -2
- package/helpers/phi-signet-head.d.ts +26 -0
- package/helpers/phi-signet-head.js +53 -0
- package/helpers/phi-signet-paths.d.ts +16 -0
- package/helpers/phi-signet-paths.js +19 -0
- package/helpers/phi-signet.d.ts +40 -0
- package/helpers/phi-signet.js +70 -0
- package/net/phi-next-proxy.d.ts +10 -8
- package/net/phi-next-proxy.js +27 -84
- package/next/proxy-runtime.js +15 -0
- package/next/root-route.js +7 -4
- package/next/site-proxy.js +21 -0
- package/package.json +3 -3
- package/plugins/runtime-modules/area-definitions.d.ts +24 -3
- package/plugins/runtime-modules/area-definitions.js +11 -3
- package/plugins/runtime-modules/asset/definition.d.ts +44 -2
- package/plugins/runtime-modules/asset/definition.js +5 -2
- package/plugins/runtime-modules/asset/form-providers.d.ts +63 -0
- package/plugins/runtime-modules/asset/form-providers.js +54 -0
- package/plugins/runtime-modules/asset/form-ui-provider.js +13 -3
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +20 -0
- package/plugins/runtime-modules/asset/media-asset-field.js +33 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +21 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +74 -0
- package/plugins/runtime-modules/core/widgets/html/server.js +1 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/client.js +28 -23
- package/plugins/runtime-modules/core/widgets/slot-upload/slot.d.ts +19 -0
- package/plugins/runtime-modules/core/widgets/slot-upload/slot.js +16 -0
- package/plugins/runtime-modules/public/presets.d.ts +12 -0
- package/plugins/runtime-modules/public/presets.js +10 -0
- package/plugins/runtime-modules/public/server.js +1 -1
- package/plugins/runtime-modules/public/trees/phi-default-pub-privacy-page-tree.d.ts +4 -0
- package/plugins/runtime-modules/public/trees/phi-default-pub-privacy-page-tree.js +66 -0
- package/plugins/runtime-modules/public-base-page-references.d.ts +2 -1
- package/plugins/runtime-modules/public-base-page-references.js +2 -1
- package/plugins/runtime-modules/resolver.js +38 -4
- package/plugins/runtime-modules/theme/controller/runtime.js +7 -2
- package/plugins/runtime-modules/theme/materialize-images.d.ts +16 -0
- package/plugins/runtime-modules/theme/materialize-images.js +37 -0
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +35 -0
- package/plugins/runtime-modules/user-management/addon-roles.js +76 -0
- package/plugins/runtime-modules/user-management/cards.js +1 -1
- package/plugins/runtime-modules/user-management/client-data-providers.js +6 -0
- package/plugins/runtime-modules/user-management/data-providers.d.ts +11 -2
- package/plugins/runtime-modules/user-management/data-providers.js +12 -1
- package/plugins/runtime-modules/user-management/definition.d.ts +11 -2
- package/plugins/runtime-modules/user-management/ids.d.ts +1 -0
- package/plugins/runtime-modules/user-management/ids.js +1 -0
- package/plugins/runtime-modules/user-management/services/options.d.ts +8 -0
- package/plugins/runtime-modules/user-management/services/options.js +25 -0
- package/plugins/runtime-modules/user-management/services/table.js +9 -1
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +20 -2
- package/server-helpers/cms-widget-texts.js +1 -1
- package/server-helpers/search-index.js +22 -13
- package/server-helpers/search-text.d.ts +3 -2
- package/server-helpers/search-text.js +6 -5
- package/server-helpers/translate.d.ts +13 -2
- package/server-helpers/translate.js +10 -6
- package/styles/amount-list.css +142 -0
- package/styles/controls.css +156 -7
- package/styles/gradients.css +21 -20
- package/theme/phi-theme-blocks.d.ts +7 -6
- package/theme/phi-theme-composition.d.ts +19 -1
- package/theme/phi-theme-composition.js +15 -0
- package/theme/phi-theme-signet.d.ts +31 -0
- package/theme/phi-theme-signet.js +53 -0
- package/theme/phi-tokens.d.ts +1 -1
- package/theme/phi-tokens.js +5 -1
- package/types/cms-plugins.d.ts +10 -1
- package/types/site-theme.d.ts +29 -0
|
@@ -4,22 +4,21 @@ import { resolvePhiMediaAssetTypeLabel } from "./asset-type-label";
|
|
|
4
4
|
import { PhiTagControl } from "../controls/phi-tag-control";
|
|
5
5
|
import { PhiButtonControl } from "../controls/phi-button-control";
|
|
6
6
|
import NextImage from "next/image";
|
|
7
|
-
import { useMemo,
|
|
7
|
+
import { useMemo, useState } from "react";
|
|
8
8
|
import { PhiCollectionLayoutControl } from "../controls/phi-collection-layout-control";
|
|
9
9
|
import { resolvePhiMediaKindFromContentType, } from "../../constants/media";
|
|
10
10
|
import { normalizePhiImagePreviewTile, resolvePhiMediaAssetDisplayDimensions, } from "./phi-image-preview-data";
|
|
11
11
|
import { PhiMediaKindIcon } from "./phi-media-kind-icon";
|
|
12
12
|
import { resolvePhiMediaUploadInitOptions, } from "./media-upload-flow";
|
|
13
|
-
import {
|
|
13
|
+
import { resolvePhiAreaUploadLabels, resolvePhiUploadStatusLabel, usePhiMediaUpload, } from "./phi-media-upload";
|
|
14
14
|
import { usePhiImagePreviewStore } from "./phi-image-preview-store";
|
|
15
15
|
import { PHI_ASSET_CONTROLLER_STORE_KEY } from "./asset-controller-signals";
|
|
16
16
|
import { applyPhiAssetCollectionData, buildPhiAssetCollectionQuery, PHI_ASSET_COLLECTION_DATA_SOURCE, } from "./asset-collection-runtime";
|
|
17
|
-
import {
|
|
17
|
+
import { PhiUploadDropArea } from "./phi-upload-drop-area";
|
|
18
18
|
import { usePhiApplicationFeedback } from "../runtime/use-phi-application-feedback";
|
|
19
19
|
import { resolvePhiThemeBorderLine } from "../../helpers/border-widget-style";
|
|
20
20
|
import { usePhiConfig } from "../root/phi-config-provider";
|
|
21
21
|
import { usePhiCollectionProviderAction } from "../widgets/client/shared/phi-collection-provider";
|
|
22
|
-
import { PhiFileDropControl } from "../controls/phi-file-drop-control";
|
|
23
22
|
import { PhiProgressControl } from "../controls/phi-progress-control";
|
|
24
23
|
import { PhiFlexControl } from "../controls/phi-flex-control";
|
|
25
24
|
import { PhiTypographyControl } from "../controls/phi-typography-control";
|
|
@@ -45,28 +44,6 @@ function buildUploadWallItem(asset, localId) {
|
|
|
45
44
|
error: null,
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
|
-
function resolveUploadStatusLabel(item, labels) {
|
|
49
|
-
if (item.status === "error") {
|
|
50
|
-
return labels.failedLabel;
|
|
51
|
-
}
|
|
52
|
-
if (item.status === "uploading") {
|
|
53
|
-
return `${item.progress}%`;
|
|
54
|
-
}
|
|
55
|
-
return labels.doneLabel;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The Widget's own wording over the shared reading of every refusal: its duplicate, failure and storage
|
|
59
|
-
* texts, and the shared ones for the rest -- so no control plane string reaches a person.
|
|
60
|
-
*/
|
|
61
|
-
function resolveAreaUploadLabels(labels) {
|
|
62
|
-
return {
|
|
63
|
-
...PHI_MEDIA_UPLOAD_DEFAULT_LABELS,
|
|
64
|
-
errorGeneric: labels.uploadFailedText,
|
|
65
|
-
errorDuplicate: labels.assetExistsLabel,
|
|
66
|
-
errorStorageUnreachable: labels.uploadStorageUnreachableText,
|
|
67
|
-
errorFolderLocked: labels.uploadFolderLockedText,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
47
|
/** A file still on its way, or one that failed, drawn as a tile like the Assets that arrived. */
|
|
71
48
|
function buildPendingWallItem(item, presentationFlags) {
|
|
72
49
|
return {
|
|
@@ -94,15 +71,11 @@ function resolveUploadWallDisplayDimensions(item) {
|
|
|
94
71
|
export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collectionContext }) {
|
|
95
72
|
const { token } = usePhiConfig();
|
|
96
73
|
const { showMessage } = usePhiApplicationFeedback();
|
|
97
|
-
const uploadTileMinHeight = token.controlHeight * 4;
|
|
98
74
|
const uploadTileFrameSize = token.controlHeight * 3;
|
|
99
|
-
const uploadTileIconSize = token.fontSizeHeading3;
|
|
100
75
|
const uploadTileLabelFontSize = token.fontSizeSM;
|
|
101
76
|
const previewState = usePhiImagePreviewStore(PHI_ASSET_CONTROLLER_STORE_KEY);
|
|
102
77
|
const activateCollectionAction = usePhiCollectionProviderAction(PHI_ASSET_COLLECTION_DATA_SOURCE);
|
|
103
|
-
const dragDepth = useRef(0);
|
|
104
78
|
const [uploadWall, setUploadWall] = useState([]);
|
|
105
|
-
const [isDragActive, setIsDragActive] = useState(false);
|
|
106
79
|
const allowDelete = config?.allowDelete ?? true;
|
|
107
80
|
const accept = config?.accept?.trim() || "*/*";
|
|
108
81
|
const multiple = config?.multiple ?? true;
|
|
@@ -171,7 +144,7 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
|
|
|
171
144
|
* often than not -- so no Asset is finalized that nobody sees arrive. What is this Widget's own is the
|
|
172
145
|
* wall: an Asset that arrived becomes a tile, and the listing behind it hears of it.
|
|
173
146
|
*/
|
|
174
|
-
const areaUploadLabels = useMemo(() =>
|
|
147
|
+
const areaUploadLabels = useMemo(() => resolvePhiAreaUploadLabels(labels), [labels]);
|
|
175
148
|
const upload = usePhiMediaUpload({
|
|
176
149
|
labels: areaUploadLabels,
|
|
177
150
|
initOptions: uploadInitOptions,
|
|
@@ -190,32 +163,7 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
|
|
|
190
163
|
.map((item) => buildPendingWallItem(item, uploadInitOptions.presentationFlags ?? 0)),
|
|
191
164
|
...uploadWall,
|
|
192
165
|
];
|
|
193
|
-
return (_jsxs(PhiFlexControl, { vertical: true, gap: 12, style: { width: "100%" }, children: [_jsx(
|
|
194
|
-
dragDepth.current += 1;
|
|
195
|
-
setIsDragActive(true);
|
|
196
|
-
}, onDragLeave: () => {
|
|
197
|
-
dragDepth.current = Math.max(0, dragDepth.current - 1);
|
|
198
|
-
if (dragDepth.current === 0) {
|
|
199
|
-
setIsDragActive(false);
|
|
200
|
-
}
|
|
201
|
-
}, onDragOver: (event) => {
|
|
202
|
-
event.preventDefault();
|
|
203
|
-
event.dataTransfer.dropEffect = "copy";
|
|
204
|
-
setIsDragActive(true);
|
|
205
|
-
}, onDrop: () => {
|
|
206
|
-
dragDepth.current = 0;
|
|
207
|
-
setIsDragActive(false);
|
|
208
|
-
}, style: { width: "100%" }, children: _jsx(PhiFileDropControl, { dropZone: true, multiple: multiple, accept: accept, onFile: (file) => void upload.upload(file), style: {
|
|
209
|
-
padding: 0,
|
|
210
|
-
width: "100%",
|
|
211
|
-
borderColor: isDragActive ? token.colorPrimary : undefined,
|
|
212
|
-
background: isDragActive ? token.colorFillQuaternary : undefined,
|
|
213
|
-
}, children: _jsxs(PhiFlexControl, { vertical: true, align: "center", gap: 4, style: {
|
|
214
|
-
width: "100%",
|
|
215
|
-
minHeight: uploadTileMinHeight,
|
|
216
|
-
justifyContent: "center",
|
|
217
|
-
cursor: isDragActive ? "copy" : "default",
|
|
218
|
-
}, children: [_jsx(PhiIcon, { name: "upload", size: "inherit", style: { fontSize: uploadTileIconSize, color: token.colorTextSecondary } }), _jsx(PhiTypographyControl, { strong: true, children: labels.dropTitle }), _jsx(PhiTypographyControl, { type: "secondary", children: labels.dropHint })] }) }) }), _jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: uploadTileFrameSize, items: wallItems.map((item) => {
|
|
166
|
+
return (_jsxs(PhiFlexControl, { vertical: true, gap: 12, style: { width: "100%" }, children: [_jsx(PhiUploadDropArea, { multiple: multiple, accept: accept, title: labels.dropTitle, hint: labels.dropHint, onFile: (file) => void upload.upload(file) }), _jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: uploadTileFrameSize, items: wallItems.map((item) => {
|
|
219
167
|
const displayDimensions = resolveUploadWallDisplayDimensions(item);
|
|
220
168
|
return (_jsxs("div", { style: {
|
|
221
169
|
border: resolvePhiThemeBorderLine(token.colorBorderSecondary),
|
|
@@ -272,7 +220,7 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
|
|
|
272
220
|
color: "#fff",
|
|
273
221
|
}, children: _jsx(PhiSpinControl, {}) })) : null] }), _jsxs(PhiFlexControl, { vertical: true, gap: 6, style: { padding: token.paddingSM }, children: [_jsx(PhiFlexControl, { align: "center", justify: "space-between", gap: 8, children: _jsx(PhiTypographyControl, { strong: true, ellipsis: true, title: item.title ?? item.originalName, style: { minWidth: 0 }, children: item.title ?? item.originalName }) }), _jsxs(PhiFlexControl, { align: "center", justify: "space-between", gap: 8, wrap: true, children: [_jsx(PhiTypographyControl, { type: "secondary", ellipsis: true, style: { display: "block", minWidth: 0 }, children: resolvePhiMediaAssetTypeLabel(item.kind, item.contentType, item.originalName) }), allowDelete && item.assetId > 0 ? (_jsx(PhiButtonControl, { ariaLabel: labels.deleteLabel, icon: _jsx(PhiIcon, { name: "delete", size: "inherit" }), type: "text", size: "small", danger: true, onClick: () => {
|
|
274
222
|
void deleteUploadedAsset(item.localId, item.assetId);
|
|
275
|
-
} })) : null] }), _jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: true, children: [_jsx(PhiTagControl, { color: item.status === "error" ? "red" : item.status === "uploading" ? "blue" : "green", children:
|
|
223
|
+
} })) : null] }), _jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: true, children: [_jsx(PhiTagControl, { color: item.status === "error" ? "red" : item.status === "uploading" ? "blue" : "green", children: resolvePhiUploadStatusLabel(item, labels) }), item.status === "error" && item.file ? (_jsx(PhiButtonControl, { type: "primary", size: "small", onClick: () => {
|
|
276
224
|
void upload.retry(item.localId);
|
|
277
225
|
}, label: labels.retryLabel })) : null] })] })] }, item.localId));
|
|
278
226
|
}) })] }));
|
|
@@ -18,8 +18,22 @@ export type PhiMediaPickerBindingProps = {
|
|
|
18
18
|
trigger?: ReactNode;
|
|
19
19
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
20
20
|
popupRootClassName?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Offers the Site Space and nothing else, wherever the surface stands: no Space selector, and the query
|
|
23
|
+
* names no Space, which the control plane answers with the Site Space. For a place that stores a
|
|
24
|
+
* reference to an Asset for everybody to see, which a personal or a group Space cannot honestly be.
|
|
25
|
+
* An interface rule like `usePhiMediaSpaceSelectionAllowed`; the server that takes the reference is what
|
|
26
|
+
* enforces it.
|
|
27
|
+
*/
|
|
28
|
+
siteSpaceOnly?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Which of the listed Assets may be chosen; the others stay in the list, greyed out. The list is the
|
|
31
|
+
* control plane's answer and is not narrowed here -- an Asset the question refuses is still one the
|
|
32
|
+
* reader can see exists.
|
|
33
|
+
*/
|
|
34
|
+
isAssetSelectable?: (asset: PhiMediaAssetTile) => boolean;
|
|
21
35
|
};
|
|
22
|
-
export declare function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, }: PhiMediaPickerBindingProps): {
|
|
36
|
+
export declare function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, siteSpaceOnly, isAssetSelectable, }: PhiMediaPickerBindingProps): {
|
|
23
37
|
open: boolean;
|
|
24
38
|
value: number | null;
|
|
25
39
|
assets: PhiMediaAssetTile[];
|
|
@@ -61,6 +75,7 @@ export declare function usePhiMediaPickerBinding({ config, labels, searchLabels,
|
|
|
61
75
|
};
|
|
62
76
|
getPopupContainer: ((triggerNode: HTMLElement) => HTMLElement) | undefined;
|
|
63
77
|
popupRootClassName: string | undefined;
|
|
78
|
+
isAssetSelectable: ((asset: PhiMediaAssetTile) => boolean) | undefined;
|
|
64
79
|
onOpenChange: (next: boolean) => void;
|
|
65
80
|
onCommit: ((assetId: number | null, originalAssetId: number | null) => void) | undefined;
|
|
66
81
|
onDiscard: ((originalAssetId: number | null) => void) | undefined;
|
|
@@ -14,7 +14,7 @@ import { setPhiImagePreviewSelection } from "./phi-image-preview-store";
|
|
|
14
14
|
import { readPhiMediaAssetTiles, readPhiMediaFolders, readPhiMediaSpace, readPhiMediaSpaces, } from "./phi-image-preview-data";
|
|
15
15
|
import { buildPhiMediaSpaceOptions, usePhiMediaSpaceSelectionAllowed, } from "./media-space-selection";
|
|
16
16
|
import { isPhiRecord } from "../../helpers/is-record";
|
|
17
|
-
export function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, }) {
|
|
17
|
+
export function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, siteSpaceOnly = false, isAssetSelectable, }) {
|
|
18
18
|
const [localOpen, setLocalOpen] = useState(false);
|
|
19
19
|
const [localValue, setLocalValue] = useState(controlledValue ?? null);
|
|
20
20
|
const [searchQuery, setSearchQuery] = useState("");
|
|
@@ -36,7 +36,7 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
36
36
|
* been given.
|
|
37
37
|
*/
|
|
38
38
|
const [requestedSpaceAddress, setRequestedSpaceAddress] = useState(null);
|
|
39
|
-
const spaceSelectionAllowed = usePhiMediaSpaceSelectionAllowed();
|
|
39
|
+
const spaceSelectionAllowed = usePhiMediaSpaceSelectionAllowed() && !siteSpaceOnly;
|
|
40
40
|
const [total, setTotal] = useState(0);
|
|
41
41
|
const [loading, setLoading] = useState(false);
|
|
42
42
|
const [loadFailed, setLoadFailed] = useState(false);
|
|
@@ -183,6 +183,7 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
183
183
|
labels: { trigger: labels.picker.triggerLabel, title: labels.picker.popoverTitle, search: labels.tool.searchPlaceholder ?? searchLabels.placeholder, folder: labels.tool.folderLabel, space: labels.space.label, empty: bindingError ?? (loadFailed ? labels.picker.loadFailedDescription : labels.picker.emptyDescription), clear: labels.picker.clearLabel, reload: labels.tool.reloadLabel, tileSize: labels.picker.tileSizeLabel },
|
|
184
184
|
getPopupContainer,
|
|
185
185
|
popupRootClassName,
|
|
186
|
+
isAssetSelectable,
|
|
186
187
|
onOpenChange: updateOpen,
|
|
187
188
|
onCommit,
|
|
188
189
|
onDiscard,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PhiMediaKindValue } from "../../types/media";
|
|
2
|
+
import type { PhiAreaUploadWidgetLabels } from "./media-widget-labels";
|
|
2
3
|
import { type PhiMediaUploadSessionRunner, type PhiMediaUploadInitOptions } from "./media-upload-flow";
|
|
3
4
|
/**
|
|
4
5
|
* What a surface accepts, stated by the Module that offers it.
|
|
@@ -39,6 +40,17 @@ export type PhiMediaUploadLabels = {
|
|
|
39
40
|
* plane message into an interface is what these replace.
|
|
40
41
|
*/
|
|
41
42
|
export declare const PHI_MEDIA_UPLOAD_DEFAULT_LABELS: PhiMediaUploadLabels;
|
|
43
|
+
/**
|
|
44
|
+
* The wording of every refusal on a Media upload surface that has the Media label set: the Widget's own
|
|
45
|
+
* duplicate, failure and storage texts, and the shared ones for the rest -- so no control plane string
|
|
46
|
+
* reaches a person. The Media folder's upload Widget and an Add-on's slot upload read it the same way.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolvePhiAreaUploadLabels(labels: PhiAreaUploadWidgetLabels): PhiMediaUploadLabels;
|
|
49
|
+
/** What an item of an upload says of its state: the percentage on its way, "Failed", or "Done". */
|
|
50
|
+
export declare function resolvePhiUploadStatusLabel(item: {
|
|
51
|
+
status: "uploading" | "done" | "error";
|
|
52
|
+
progress: number;
|
|
53
|
+
}, labels: Pick<PhiAreaUploadWidgetLabels, "failedLabel" | "doneLabel">): string;
|
|
42
54
|
/** The `accept` attribute a file dialog should carry, derived rather than written out by each caller. */
|
|
43
55
|
export declare function resolvePhiMediaUploadAccept(acceptance: PhiMediaUploadAcceptance | undefined): string;
|
|
44
56
|
/** Why this file cannot be sent, or `null` when it can. */
|
|
@@ -21,6 +21,28 @@ export const PHI_MEDIA_UPLOAD_DEFAULT_LABELS = {
|
|
|
21
21
|
errorStorageUnreachable: "The file storage could not be reached.",
|
|
22
22
|
errorFolderLocked: "This folder is locked. Nothing can be uploaded into it until it is unlocked.",
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* The wording of every refusal on a Media upload surface that has the Media label set: the Widget's own
|
|
26
|
+
* duplicate, failure and storage texts, and the shared ones for the rest -- so no control plane string
|
|
27
|
+
* reaches a person. The Media folder's upload Widget and an Add-on's slot upload read it the same way.
|
|
28
|
+
*/
|
|
29
|
+
export function resolvePhiAreaUploadLabels(labels) {
|
|
30
|
+
return {
|
|
31
|
+
...PHI_MEDIA_UPLOAD_DEFAULT_LABELS,
|
|
32
|
+
errorGeneric: labels.uploadFailedText,
|
|
33
|
+
errorDuplicate: labels.assetExistsLabel,
|
|
34
|
+
errorStorageUnreachable: labels.uploadStorageUnreachableText,
|
|
35
|
+
errorFolderLocked: labels.uploadFolderLockedText,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** What an item of an upload says of its state: the percentage on its way, "Failed", or "Done". */
|
|
39
|
+
export function resolvePhiUploadStatusLabel(item, labels) {
|
|
40
|
+
if (item.status === "error")
|
|
41
|
+
return labels.failedLabel;
|
|
42
|
+
if (item.status === "uploading")
|
|
43
|
+
return `${item.progress}%`;
|
|
44
|
+
return labels.doneLabel;
|
|
45
|
+
}
|
|
24
46
|
/** The `accept` attribute a file dialog should carry, derived rather than written out by each caller. */
|
|
25
47
|
export function resolvePhiMediaUploadAccept(acceptance) {
|
|
26
48
|
const types = acceptance?.contentTypes ?? [];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type PhiUploadDropAreaProps = {
|
|
2
|
+
/** What the file dialog offers. The upload's own acceptance check is what refuses. */
|
|
3
|
+
accept?: string;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
/** The bold line of the area (`PhiAreaUploadWidgetLabels.dropTitle`). */
|
|
7
|
+
title: string;
|
|
8
|
+
/** The quiet line under it (`PhiAreaUploadWidgetLabels.dropHint`). */
|
|
9
|
+
hint: string;
|
|
10
|
+
/** Once per file chosen or dropped. */
|
|
11
|
+
onFile: (file: File) => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The area files are dropped on or clicked, as every Media upload surface draws it: the Media folder's
|
|
15
|
+
* upload Widget and an Add-on's slot upload.
|
|
16
|
+
*
|
|
17
|
+
* Shared rather than copied because what it holds is easy to get half right: the highlight while a file
|
|
18
|
+
* is dragged over it, the `data-phi-media-dropzone` mark that `PhiFileDropGuard` lets a drop through
|
|
19
|
+
* for, and that guard itself, which stops a drop beside the area from opening the file in the tab. It
|
|
20
|
+
* transports nothing; the caller hands every file to `usePhiMediaUpload`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function PhiUploadDropArea({ accept, multiple, disabled, title, hint, onFile }: PhiUploadDropAreaProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { PhiFileDropControl } from "../controls/phi-file-drop-control";
|
|
5
|
+
import { PhiFlexControl } from "../controls/phi-flex-control";
|
|
6
|
+
import { PhiTypographyControl } from "../controls/phi-typography-control";
|
|
7
|
+
import { usePhiConfig } from "../root/phi-config-provider";
|
|
8
|
+
import { PhiIcon } from "../shell/phi-icon";
|
|
9
|
+
import { PhiFileDropGuard } from "./phi-file-drop-guard";
|
|
10
|
+
/**
|
|
11
|
+
* The area files are dropped on or clicked, as every Media upload surface draws it: the Media folder's
|
|
12
|
+
* upload Widget and an Add-on's slot upload.
|
|
13
|
+
*
|
|
14
|
+
* Shared rather than copied because what it holds is easy to get half right: the highlight while a file
|
|
15
|
+
* is dragged over it, the `data-phi-media-dropzone` mark that `PhiFileDropGuard` lets a drop through
|
|
16
|
+
* for, and that guard itself, which stops a drop beside the area from opening the file in the tab. It
|
|
17
|
+
* transports nothing; the caller hands every file to `usePhiMediaUpload`.
|
|
18
|
+
*/
|
|
19
|
+
export function PhiUploadDropArea({ accept, multiple, disabled, title, hint, onFile }) {
|
|
20
|
+
const { token } = usePhiConfig();
|
|
21
|
+
const dragDepth = useRef(0);
|
|
22
|
+
const [isDragActive, setIsDragActive] = useState(false);
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx(PhiFileDropGuard, {}), _jsx("div", { "data-phi-media-dropzone": "true", onDragEnter: () => {
|
|
24
|
+
dragDepth.current += 1;
|
|
25
|
+
setIsDragActive(true);
|
|
26
|
+
}, onDragLeave: () => {
|
|
27
|
+
dragDepth.current = Math.max(0, dragDepth.current - 1);
|
|
28
|
+
if (dragDepth.current === 0) {
|
|
29
|
+
setIsDragActive(false);
|
|
30
|
+
}
|
|
31
|
+
}, onDragOver: (event) => {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
event.dataTransfer.dropEffect = "copy";
|
|
34
|
+
setIsDragActive(true);
|
|
35
|
+
}, onDrop: () => {
|
|
36
|
+
dragDepth.current = 0;
|
|
37
|
+
setIsDragActive(false);
|
|
38
|
+
}, style: { width: "100%" }, children: _jsx(PhiFileDropControl, { dropZone: true, ...(multiple === undefined ? {} : { multiple }), ...(accept === undefined ? {} : { accept }), ...(disabled === undefined ? {} : { disabled }), onFile: onFile, style: {
|
|
39
|
+
padding: 0,
|
|
40
|
+
width: "100%",
|
|
41
|
+
borderColor: isDragActive ? token.colorPrimary : undefined,
|
|
42
|
+
background: isDragActive ? token.colorFillQuaternary : undefined,
|
|
43
|
+
}, children: _jsxs(PhiFlexControl, { vertical: true, align: "center", gap: 4, style: {
|
|
44
|
+
width: "100%",
|
|
45
|
+
minHeight: token.controlHeight * 4,
|
|
46
|
+
justifyContent: "center",
|
|
47
|
+
cursor: isDragActive ? "copy" : "default",
|
|
48
|
+
}, children: [_jsx(PhiIcon, { name: "upload", size: "inherit", style: { fontSize: token.fontSizeHeading3, color: token.colorTextSecondary } }), _jsx(PhiTypographyControl, { strong: true, children: title }), _jsx(PhiTypographyControl, { type: "secondary", children: hint })] }) }) })] }));
|
|
49
|
+
}
|
|
@@ -5,6 +5,7 @@ import "../../styles/root.css";
|
|
|
5
5
|
import "../../styles/layout.css";
|
|
6
6
|
import "../../styles/control-shape.css";
|
|
7
7
|
import "../../styles/controls.css";
|
|
8
|
+
import "../../styles/amount-list.css";
|
|
8
9
|
import "../../styles/gradients.css";
|
|
9
10
|
import type { PhiSiteConfig } from "../../types/site-config";
|
|
10
11
|
import type { PhiResolvedLocale } from "../../helpers/site-locale-config";
|
|
@@ -13,6 +13,7 @@ import "../../styles/root.css";
|
|
|
13
13
|
import "../../styles/layout.css";
|
|
14
14
|
import "../../styles/control-shape.css";
|
|
15
15
|
import "../../styles/controls.css";
|
|
16
|
+
import "../../styles/amount-list.css";
|
|
16
17
|
import "../../styles/gradients.css";
|
|
17
18
|
import { getResolvedSiteConfig } from "../../gateway/site-config";
|
|
18
19
|
import { loadPhiAntdLocale } from "../../helpers/antd-locale";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "server-only";
|
|
2
|
+
import type { PhiBlockRuntime } from "../../../types";
|
|
2
3
|
export declare function translateSemanticHtml(sourceHtml: string, sourceLocale?: string,
|
|
3
4
|
/** The render's locale. Without it the request's is asked, and a static render has no request. */
|
|
4
|
-
locale?: string
|
|
5
|
+
locale?: string,
|
|
6
|
+
/** The render's runtime, when the caller holds one: the Site's store is then named, not looked up in the request. */
|
|
7
|
+
runtime?: Pick<PhiBlockRuntime, "site">): Promise<string>;
|
|
@@ -51,7 +51,9 @@ function hasVisibleText(html) {
|
|
|
51
51
|
}
|
|
52
52
|
export async function translateSemanticHtml(sourceHtml, sourceLocale,
|
|
53
53
|
/** The render's locale. Without it the request's is asked, and a static render has no request. */
|
|
54
|
-
locale
|
|
54
|
+
locale,
|
|
55
|
+
/** The render's runtime, when the caller holds one: the Site's store is then named, not looked up in the request. */
|
|
56
|
+
runtime) {
|
|
55
57
|
const sanitized = sanitizePhiHtmlWidgetMarkup(sourceHtml);
|
|
56
58
|
if (!sanitized) {
|
|
57
59
|
return "";
|
|
@@ -68,7 +70,7 @@ locale) {
|
|
|
68
70
|
}
|
|
69
71
|
const msgs = units.map((unit) => unit.html);
|
|
70
72
|
const translated = locale
|
|
71
|
-
? await trBulkForLocale(locale, msgs, 0, "html", sourceLocale)
|
|
73
|
+
? await trBulkForLocale(locale, msgs, 0, "html", sourceLocale, runtime)
|
|
72
74
|
: await trBulk(msgs, 0, "html", sourceLocale);
|
|
73
75
|
units.forEach((unit, index) => {
|
|
74
76
|
const fragment = parseDocument(translated[index] ?? unit.html);
|
|
@@ -9,10 +9,17 @@ export declare function getPhiAdminUsersTableWidgetLabels(options: PhiGlobalTran
|
|
|
9
9
|
footer: string;
|
|
10
10
|
accountTypes: {
|
|
11
11
|
all: string;
|
|
12
|
-
|
|
12
|
+
external: string;
|
|
13
13
|
roles: string;
|
|
14
14
|
auth: string;
|
|
15
15
|
};
|
|
16
|
+
addonRoles: {
|
|
17
|
+
all: string;
|
|
18
|
+
};
|
|
19
|
+
filters: {
|
|
20
|
+
addonRole: string;
|
|
21
|
+
addonRoleHint: string;
|
|
22
|
+
};
|
|
16
23
|
enabledOptions: {
|
|
17
24
|
all: string;
|
|
18
25
|
enabled: string;
|
|
@@ -25,6 +32,7 @@ export declare function getPhiAdminUsersTableWidgetLabels(options: PhiGlobalTran
|
|
|
25
32
|
name: string;
|
|
26
33
|
email: string;
|
|
27
34
|
roles: string;
|
|
35
|
+
addonRoles: string;
|
|
28
36
|
userFlags: string;
|
|
29
37
|
siteFlags: string;
|
|
30
38
|
lastLogin: string;
|
|
@@ -12,7 +12,7 @@ const PHI_ADMIN_USERS_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
|
|
|
12
12
|
add_label: "Add user",
|
|
13
13
|
footer_count: "%1 users of %2 total",
|
|
14
14
|
account_type_all: "All",
|
|
15
|
-
|
|
15
|
+
account_type_external: "External",
|
|
16
16
|
account_type_roles: "Local roles",
|
|
17
17
|
account_type_auth: "Auth",
|
|
18
18
|
enabled_all: "All",
|
|
@@ -24,6 +24,10 @@ const PHI_ADMIN_USERS_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
|
|
|
24
24
|
column_name: "Name",
|
|
25
25
|
column_email: "Email",
|
|
26
26
|
column_roles: "Roles",
|
|
27
|
+
column_addon_roles: "Add-on roles",
|
|
28
|
+
addon_roles_all: "all roles",
|
|
29
|
+
filter_addon_role: "Add-on role",
|
|
30
|
+
filter_addon_role_hint: definePhiMessageLabel("Show users who hold a role of an Add-on, or one role of it. Site Admins hold every role."),
|
|
27
31
|
column_user_flags: "User flags",
|
|
28
32
|
column_site_flags: "Site flags",
|
|
29
33
|
column_last_login: "Last login",
|
|
@@ -96,10 +100,17 @@ export async function getPhiAdminUsersTableWidgetLabels(options) {
|
|
|
96
100
|
footer: labels.footer_count,
|
|
97
101
|
accountTypes: {
|
|
98
102
|
all: labels.account_type_all,
|
|
99
|
-
|
|
103
|
+
external: labels.account_type_external,
|
|
100
104
|
roles: labels.account_type_roles,
|
|
101
105
|
auth: labels.account_type_auth,
|
|
102
106
|
},
|
|
107
|
+
addonRoles: {
|
|
108
|
+
all: labels.addon_roles_all,
|
|
109
|
+
},
|
|
110
|
+
filters: {
|
|
111
|
+
addonRole: labels.filter_addon_role,
|
|
112
|
+
addonRoleHint: labels.filter_addon_role_hint,
|
|
113
|
+
},
|
|
103
114
|
enabledOptions: {
|
|
104
115
|
all: labels.enabled_all,
|
|
105
116
|
enabled: labels.enabled_enabled,
|
|
@@ -112,6 +123,7 @@ export async function getPhiAdminUsersTableWidgetLabels(options) {
|
|
|
112
123
|
name: labels.column_name,
|
|
113
124
|
email: labels.column_email,
|
|
114
125
|
roles: labels.column_roles,
|
|
126
|
+
addonRoles: labels.column_addon_roles,
|
|
115
127
|
userFlags: labels.column_user_flags,
|
|
116
128
|
siteFlags: labels.column_site_flags,
|
|
117
129
|
lastLogin: labels.column_last_login,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { definePhiLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../gateway/label-set";
|
|
3
3
|
import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../gateway/tr";
|
|
4
|
+
import { getPhiMediaWidgetLabels } from "../../media/label-sets/media";
|
|
4
5
|
import { PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS, } from "../label-types/slot-upload";
|
|
5
6
|
const DEFAULTS = PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS;
|
|
6
7
|
const PHI_SLOT_UPLOAD_WIDGET_LABEL_SET = definePhiLabelSet({
|
|
7
8
|
key: "widget:slot-upload",
|
|
8
9
|
ctx: PHI_TR_CTX_WEB_UI_LABEL,
|
|
9
10
|
labels: {
|
|
10
|
-
choose: DEFAULTS.choose,
|
|
11
11
|
remove: DEFAULTS.remove,
|
|
12
12
|
unconfigured: definePhiMessageLabel(DEFAULTS.unconfigured),
|
|
13
13
|
no_row: definePhiMessageLabel(DEFAULTS.noRow),
|
|
@@ -20,11 +20,13 @@ const PHI_SLOT_UPLOAD_WIDGET_LABEL_SET = definePhiLabelSet({
|
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
export async function getPhiSlotUploadWidgetLabels(options) {
|
|
23
|
-
const labels = await
|
|
23
|
+
const [labels, media] = await Promise.all([
|
|
24
|
+
getPhiLabelSet(options, PHI_SLOT_UPLOAD_WIDGET_LABEL_SET),
|
|
25
|
+
getPhiMediaWidgetLabels(options),
|
|
26
|
+
]);
|
|
24
27
|
return {
|
|
25
28
|
unconfigured: labels.unconfigured,
|
|
26
29
|
noRow: labels.no_row,
|
|
27
|
-
choose: labels.choose,
|
|
28
30
|
empty: labels.empty,
|
|
29
31
|
remove: labels.remove,
|
|
30
32
|
fileTitle: labels.file_title,
|
|
@@ -32,5 +34,6 @@ export async function getPhiSlotUploadWidgetLabels(options) {
|
|
|
32
34
|
serverAnswered: labels.server_answered,
|
|
33
35
|
unreachable: labels.unreachable,
|
|
34
36
|
removeFailed: labels.remove_failed,
|
|
37
|
+
upload: media.upload,
|
|
35
38
|
};
|
|
36
39
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { type PhiAreaUploadWidgetLabels } from "../../media/media-widget-labels";
|
|
1
2
|
/**
|
|
2
3
|
* What the slot upload field says. The refusals of the upload it runs are not here: they are the shared
|
|
3
4
|
* reading of `PHI_MEDIA_UPLOAD_DEFAULT_LABELS`, the same as on every other Media upload surface.
|
|
5
|
+
*
|
|
6
|
+
* The drop area's title and hint, the state of an upload and its retry are not written a second time
|
|
7
|
+
* either: `upload` is the Media folder's own set (`label-sets/media.ts`), so the two surfaces share one
|
|
8
|
+
* wording and one translation key per text.
|
|
4
9
|
*/
|
|
5
10
|
export type PhiSlotUploadWidgetLabels = {
|
|
6
11
|
/** The field names no Add-on, table or slot, so there is nowhere to put a file. */
|
|
7
12
|
unconfigured: string;
|
|
8
13
|
/** No row has arrived yet, so there is nothing to upload to. */
|
|
9
14
|
noRow: string;
|
|
10
|
-
choose: string;
|
|
11
15
|
empty: string;
|
|
12
16
|
remove: string;
|
|
13
17
|
/** A file of the slot, `%1` its content type and `%2` its size in bytes. */
|
|
@@ -18,6 +22,8 @@ export type PhiSlotUploadWidgetLabels = {
|
|
|
18
22
|
serverAnswered: string;
|
|
19
23
|
unreachable: string;
|
|
20
24
|
removeFailed: string;
|
|
25
|
+
/** The Media folder's upload texts: `dropTitle`, `dropHint`, `retryLabel`, `failedLabel`, and the refusals. */
|
|
26
|
+
upload: PhiAreaUploadWidgetLabels;
|
|
21
27
|
};
|
|
22
28
|
export declare const PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS: PhiSlotUploadWidgetLabels;
|
|
23
29
|
/** Fills `%1`, `%2`, ... of a slot upload template in order. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { PHI_MEDIA_WIDGET_DEFAULT_LABELS } from "../../media/media-widget-labels";
|
|
1
2
|
export const PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS = {
|
|
2
3
|
unconfigured: "This field names no Add-on, table or slot.",
|
|
3
4
|
noRow: "Nothing selected.",
|
|
4
|
-
choose: "Choose a file",
|
|
5
5
|
empty: "Nothing here yet.",
|
|
6
6
|
remove: "Remove this file",
|
|
7
7
|
fileTitle: "%1 — %2 bytes",
|
|
@@ -9,6 +9,7 @@ export const PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS = {
|
|
|
9
9
|
serverAnswered: "The server answered %1.",
|
|
10
10
|
unreachable: "Unreachable.",
|
|
11
11
|
removeFailed: "That file stayed.",
|
|
12
|
+
upload: PHI_MEDIA_WIDGET_DEFAULT_LABELS.upload,
|
|
12
13
|
};
|
|
13
14
|
/** Fills `%1`, `%2`, ... of a slot upload template in order. */
|
|
14
15
|
export function formatPhiSlotUploadWidgetLabel(template, ...values) {
|
|
@@ -274,18 +274,18 @@ function collectMarkdownTranslationUnits(node, units) {
|
|
|
274
274
|
* locale from the request headers, finds none, and answers in the Site's default -- which left every
|
|
275
275
|
* static Public page's body in its source language under a translated header.
|
|
276
276
|
*/
|
|
277
|
-
function translateUnits(locale, msgs, format, sourceLocale) {
|
|
277
|
+
function translateUnits(locale, msgs, format, sourceLocale, runtime) {
|
|
278
278
|
return locale
|
|
279
|
-
? trBulkForLocale(locale, msgs, 0, format, sourceLocale)
|
|
279
|
+
? trBulkForLocale(locale, msgs, 0, format, sourceLocale, runtime)
|
|
280
280
|
: trBulk(msgs, 0, format, sourceLocale);
|
|
281
281
|
}
|
|
282
|
-
async function buildMarkdownInlineMap(tree, translate, sourceLocale, locale) {
|
|
282
|
+
async function buildMarkdownInlineMap(tree, translate, sourceLocale, locale, runtime) {
|
|
283
283
|
const units = [];
|
|
284
284
|
collectMarkdownTranslationUnits(tree, units);
|
|
285
285
|
const sent = units.filter((entry) => entry.unit.translatable);
|
|
286
286
|
const translated = new Map();
|
|
287
287
|
if (translate && sent.length > 0) {
|
|
288
|
-
const answers = await translateUnits(locale, sent.map((entry) => entry.unit.html), "html", sourceLocale);
|
|
288
|
+
const answers = await translateUnits(locale, sent.map((entry) => entry.unit.html), "html", sourceLocale, runtime);
|
|
289
289
|
sent.forEach((entry, index) => translated.set(entry, answers[index] || entry.unit.html));
|
|
290
290
|
}
|
|
291
291
|
/*
|
|
@@ -298,7 +298,7 @@ async function buildMarkdownInlineMap(tree, translate, sourceLocale, locale) {
|
|
|
298
298
|
? []
|
|
299
299
|
: ["alt", "title"].flatMap((field) => slot[field].trim() ? [{ slot, field, text: slot[field] }] : [])));
|
|
300
300
|
if (translate && imageTexts.length > 0) {
|
|
301
|
-
const answers = await translateUnits(locale, imageTexts.map((entry) => entry.text), "text", sourceLocale);
|
|
301
|
+
const answers = await translateUnits(locale, imageTexts.map((entry) => entry.text), "text", sourceLocale, runtime);
|
|
302
302
|
imageTexts.forEach((entry, index) => {
|
|
303
303
|
entry.slot[entry.field] = answers[index] || entry.text;
|
|
304
304
|
});
|
|
@@ -514,7 +514,7 @@ async function resolveMarkdownRenderDataFromSource(markdown, translate, headingI
|
|
|
514
514
|
headingIdPrefix,
|
|
515
515
|
headingOffset,
|
|
516
516
|
};
|
|
517
|
-
const inlineMap = await buildMarkdownInlineMap(tree, translate, sourceLocale, runtime?.locale.current);
|
|
517
|
+
const inlineMap = await buildMarkdownInlineMap(tree, translate, sourceLocale, runtime?.locale.current, runtime);
|
|
518
518
|
const blocks = promoteMarkdownFigures(protectMarkdownMail(mapBlockNodes(tree.children, context, inlineMap)), figures, imageDefaults);
|
|
519
519
|
return { blocks, headings: context.headings };
|
|
520
520
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PhiFormProviderKey } from "../types/form-descriptor";
|
|
1
2
|
/**
|
|
2
3
|
* The Media library as a Foundation contract.
|
|
3
4
|
*
|
|
@@ -41,3 +42,11 @@ export declare const PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS: {
|
|
|
41
42
|
* Module.
|
|
42
43
|
*/
|
|
43
44
|
export declare const PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY: `${string}/${string}`;
|
|
45
|
+
/**
|
|
46
|
+
* The `media-asset` Form field type, named on the same terms: one Asset of the Site's Media library,
|
|
47
|
+
* chosen with the library's picker. A Form of any Module cites this key in its `fieldProviderKey`; the
|
|
48
|
+
* Asset Module owns the field type, declares it in its `formProviders` and serves its control, and the
|
|
49
|
+
* Form widget mounts that for the Form where the Module is active (FORMS.md). The Foundation names it and
|
|
50
|
+
* holds no reference to the Module -- the resolver reads it to mount the library Provider the picker needs.
|
|
51
|
+
*/
|
|
52
|
+
export declare const PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY: PhiFormProviderKey;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createPhiModuleScopedKey } from "./runtime-module-ownership";
|
|
1
2
|
import { createPhiSharedRuntimeDataProviderKey, createPhiSharedRuntimeItemRendererKey, } from "./runtime-data-provider-key";
|
|
2
3
|
/**
|
|
3
4
|
* The Media library as a Foundation contract.
|
|
@@ -42,3 +43,11 @@ export const PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS = {
|
|
|
42
43
|
* Module.
|
|
43
44
|
*/
|
|
44
45
|
export const PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY = createPhiSharedRuntimeItemRendererKey("media-asset");
|
|
46
|
+
/**
|
|
47
|
+
* The `media-asset` Form field type, named on the same terms: one Asset of the Site's Media library,
|
|
48
|
+
* chosen with the library's picker. A Form of any Module cites this key in its `fieldProviderKey`; the
|
|
49
|
+
* Asset Module owns the field type, declares it in its `formProviders` and serves its control, and the
|
|
50
|
+
* Form widget mounts that for the Form where the Module is active (FORMS.md). The Foundation names it and
|
|
51
|
+
* holds no reference to the Module -- the resolver reads it to mount the library Provider the picker needs.
|
|
52
|
+
*/
|
|
53
|
+
export const PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY = createPhiModuleScopedKey("form-field", "media-asset");
|
package/constants/media.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare const PhiMediaAssetSource: {
|
|
|
21
21
|
readonly ThemeGround: "theme-ground";
|
|
22
22
|
/** A Logo a Theme Set offered, taken over when the Theme was saved. */
|
|
23
23
|
readonly ThemeBrandLogo: "theme-brand-logo";
|
|
24
|
+
/** A Signet a Theme Set offered, taken over when the Theme was saved. */
|
|
25
|
+
readonly ThemeBrandSignet: "theme-brand-signet";
|
|
24
26
|
/** Fetched from the Iconify catalogue by the Mask picker. */
|
|
25
27
|
readonly Iconify: "iconify";
|
|
26
28
|
};
|
package/constants/media.js
CHANGED
|
@@ -24,6 +24,8 @@ export const PhiMediaAssetSource = {
|
|
|
24
24
|
ThemeGround: "theme-ground",
|
|
25
25
|
/** A Logo a Theme Set offered, taken over when the Theme was saved. */
|
|
26
26
|
ThemeBrandLogo: "theme-brand-logo",
|
|
27
|
+
/** A Signet a Theme Set offered, taken over when the Theme was saved. */
|
|
28
|
+
ThemeBrandSignet: "theme-brand-signet",
|
|
27
29
|
/** Fetched from the Iconify catalogue by the Mask picker. */
|
|
28
30
|
Iconify: "iconify",
|
|
29
31
|
};
|
|
@@ -47,6 +47,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
47
47
|
"form-field/email": ["core", "email"],
|
|
48
48
|
"form-field/hidden": ["core", "hidden"],
|
|
49
49
|
"form-field/honeypot": ["core", "honeypot"],
|
|
50
|
+
"form-field/media-asset": ["asset", "media-asset"],
|
|
50
51
|
"form-field/money": ["core", "money"],
|
|
51
52
|
"form-field/multi-select": ["core", "multi-select"],
|
|
52
53
|
"form-field/number": ["core", "number"],
|
|
@@ -168,6 +169,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
168
169
|
"forms/user-management/edit": ["user-management", "edit"],
|
|
169
170
|
"options/admin-site-locales": ["localization", "admin-site-locales"],
|
|
170
171
|
"options/core-site-locales": ["core", "site-locales"],
|
|
172
|
+
"options/user-management-addon-roles": ["user-management", "addon-roles"],
|
|
171
173
|
"options/builder-area-root-route": ["builder", "area-root-route"],
|
|
172
174
|
"options/builder-landing-page": ["builder", "landing-page"],
|
|
173
175
|
"options/builder-collection-item-renderers": ["builder", "collection-item-renderers"],
|