@phis/ui 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/cms/phi-cms-root-layout.js +2 -0
- package/components/controls/phi-mask-picker-control.d.ts +7 -1
- package/components/controls/phi-mask-picker-control.js +18 -16
- package/components/controls/phi-media-picker-control.d.ts +30 -1
- package/components/controls/phi-media-picker-control.js +15 -2
- package/components/controls/phi-media-source-item-tile-control.d.ts +22 -0
- package/components/controls/phi-media-source-item-tile-control.js +65 -0
- package/components/forms/form-field-labels.d.ts +19 -0
- package/components/forms/form-field-labels.js +78 -0
- package/components/forms/form-provider-contract.d.ts +1 -17
- package/components/forms/form-provider-contract.js +4 -18
- package/components/forms/media-asset-field-keys.d.ts +27 -0
- package/components/forms/media-asset-field-keys.js +27 -0
- package/components/forms/phi-form-widget.js +5 -1
- package/components/forms/upload-field-keys.d.ts +27 -0
- package/components/forms/upload-field-keys.js +27 -0
- package/components/forms/upload-form-control.js +11 -5
- package/components/media/asset-controller-requirement.d.ts +9 -0
- package/components/media/asset-controller-requirement.js +42 -0
- package/components/media/label-sets/media-upload.d.ts +10 -0
- package/components/media/label-sets/media-upload.js +85 -0
- package/components/media/label-sets/media.js +31 -135
- package/components/media/media-upload-labels.d.ts +43 -0
- package/components/media/media-upload-labels.js +23 -0
- package/components/media/media-upload-refusals.d.ts +12 -0
- package/components/media/media-upload-refusals.js +28 -0
- package/components/media/media-widget-labels.d.ts +33 -26
- package/components/media/media-widget-labels.js +27 -36
- package/components/media/phi-area-upload-widget.js +3 -4
- package/components/media/phi-asset-inspector-section.d.ts +2 -2
- package/components/media/phi-image-inspector-widget.d.ts +2 -5
- package/components/media/phi-media-picker-binding.d.ts +17 -0
- package/components/media/phi-media-picker-binding.js +199 -4
- package/components/media/phi-media-picker-labels.d.ts +7 -0
- package/components/media/phi-media-picker-labels.js +25 -0
- package/components/media/phi-media-sources.d.ts +69 -0
- package/components/media/phi-media-sources.js +254 -0
- package/components/media/phi-media-upload.d.ts +1 -27
- package/components/media/phi-media-upload.js +4 -48
- package/components/runtime/runtime-controller-materialization.d.ts +5 -4
- package/components/runtime/runtime-controller-materialization.js +5 -4
- package/components/runtime/runtime-module-context.d.ts +5 -1
- package/components/runtime/runtime-module-context.js +4 -1
- package/components/runtime/runtime-module-media-source-client-manifest.d.ts +17 -0
- package/components/runtime/runtime-module-media-source-client-manifest.js +53 -0
- package/components/widgets/client/shared/phi-mask-picker.js +23 -13
- package/components/widgets/client/shared/phi-widget-image-tool-button.d.ts +7 -5
- package/components/widgets/client/shared/phi-widget-image-tool-button.js +11 -7
- package/components/widgets/client/shared/phi-widget-tool-buttons.js +2 -2
- package/components/widgets/config/mask.d.ts +6 -8
- package/components/widgets/config/mask.js +14 -12
- package/components/widgets/label-sets/authoring-tools.js +55 -1
- package/components/widgets/label-sets/history.js +0 -2
- package/components/widgets/label-sets/slot-upload.js +4 -4
- package/components/widgets/label-types/authoring-tools.d.ts +10 -0
- package/components/widgets/label-types/authoring-tools.js +6 -0
- package/components/widgets/label-types/history.d.ts +1 -1
- package/components/widgets/label-types/history.js +0 -1
- package/components/widgets/label-types/mask-picker.d.ts +31 -0
- package/components/widgets/label-types/mask-picker.js +30 -0
- package/components/widgets/label-types/slot-upload.d.ts +2 -2
- package/controls.d.ts +2 -0
- package/controls.js +1 -0
- package/helpers/cms-region-keys.d.ts +1 -1
- package/module-client.d.ts +5 -1
- package/module-projection-client.js +1 -0
- package/next/areas/accounting-client.js +3 -2
- package/next/areas/admin-client.js +3 -2
- package/next/areas/app-client.js +3 -2
- package/next/areas/builder-client.js +3 -2
- package/next/areas/editor-client.js +3 -2
- package/next/areas/public-client.js +3 -2
- package/next/runtime-module-client-boundary.d.ts +3 -1
- package/next/runtime-module-client-boundary.js +3 -2
- package/package.json +7 -2
- package/plugins/runtime-modules/area-module-defaults.js +4 -3
- package/plugins/runtime-modules/asset/controller/definition.d.ts +2 -2
- package/plugins/runtime-modules/asset/controller/runtime.js +2 -2
- package/plugins/runtime-modules/asset/definition.d.ts +3 -2
- package/plugins/runtime-modules/asset/definition.js +11 -3
- package/plugins/runtime-modules/asset/ids.d.ts +8 -0
- package/plugins/runtime-modules/asset/ids.js +8 -0
- package/plugins/runtime-modules/asset/labels.d.ts +4 -0
- package/plugins/runtime-modules/asset/labels.js +94 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +32 -7
- package/plugins/runtime-modules/asset/metadata-form.js +27 -18
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +14 -11
- package/plugins/runtime-modules/asset/widgets/area-upload/config.d.ts +2 -0
- package/plugins/runtime-modules/asset/widgets/area-upload/config.js +3 -0
- package/plugins/runtime-modules/asset/widgets/area-upload/server.js +3 -3
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/config.d.ts +2 -0
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/config.js +3 -0
- package/plugins/runtime-modules/asset/widgets/image-inspector/config.d.ts +2 -0
- package/plugins/runtime-modules/asset/widgets/image-inspector/config.js +3 -0
- package/plugins/runtime-modules/asset/widgets/image-inspector/server.js +2 -2
- package/plugins/runtime-modules/asset/widgets/media-picker/config.d.ts +1 -0
- package/plugins/runtime-modules/asset/widgets/media-picker/config.js +3 -0
- package/plugins/runtime-modules/auth/presets.d.ts +11 -0
- package/plugins/runtime-modules/auth/presets.js +17 -8
- package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +1 -4
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +2 -2
- package/plugins/runtime-modules/builder/clients/inspector-image-field.d.ts +1 -3
- package/plugins/runtime-modules/builder/clients/inspector-image-field.js +4 -5
- package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +3 -8
- package/plugins/runtime-modules/builder/clients/pages-header.js +2 -0
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +0 -1
- package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
- package/plugins/runtime-modules/builder/controller/page-controller.js +3 -3
- package/plugins/runtime-modules/builder/controller/workspace-controller.js +4 -1
- package/plugins/runtime-modules/builder/inspector-section-widget.js +5 -2
- package/plugins/runtime-modules/builder/module-authoring-catalog.server.js +3 -1
- package/plugins/runtime-modules/builder/navigation-catalog.server.js +3 -0
- package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +1 -1
- package/plugins/runtime-modules/builder/offered-page-catalog.js +8 -3
- package/plugins/runtime-modules/builder/options-providers.js +2 -2
- package/plugins/runtime-modules/builder/page-address-rule.d.ts +7 -0
- package/plugins/runtime-modules/builder/page-address-rule.js +12 -0
- package/plugins/runtime-modules/builder/page-presets.server.js +4 -0
- package/plugins/runtime-modules/builder/persistence.js +2 -3
- package/plugins/runtime-modules/builder/public-route-collisions.d.ts +1 -1
- package/plugins/runtime-modules/builder/public-route-collisions.js +6 -1
- package/plugins/runtime-modules/builder/runtime-module-sandbox.server.js +8 -1
- package/plugins/runtime-modules/builder/runtime-module-selection.js +5 -5
- package/plugins/runtime-modules/builder/services/runtime-modules-table.js +24 -6
- package/plugins/runtime-modules/builder/signal-endpoints.js +2 -1
- package/plugins/runtime-modules/builder/use-offered-page-catalog.d.ts +2 -2
- package/plugins/runtime-modules/builder/use-offered-page-catalog.js +5 -3
- package/plugins/runtime-modules/builder/widgets/structure-region/plugin.js +19 -12
- package/plugins/runtime-modules/client-manifests/accounting.d.ts +1 -0
- package/plugins/runtime-modules/client-manifests/accounting.js +1 -0
- package/plugins/runtime-modules/client-manifests/admin.d.ts +1 -0
- package/plugins/runtime-modules/client-manifests/admin.js +1 -0
- package/plugins/runtime-modules/client-manifests/app.d.ts +1 -0
- package/plugins/runtime-modules/client-manifests/app.js +1 -0
- package/plugins/runtime-modules/client-manifests/builder.d.ts +1 -0
- package/plugins/runtime-modules/client-manifests/builder.js +1 -0
- package/plugins/runtime-modules/client-manifests/common.d.ts +1 -0
- package/plugins/runtime-modules/client-manifests/common.js +3 -0
- package/plugins/runtime-modules/client-manifests/editor.d.ts +1 -0
- package/plugins/runtime-modules/client-manifests/editor.js +1 -0
- package/plugins/runtime-modules/client-manifests/public.d.ts +1 -0
- package/plugins/runtime-modules/client-manifests/public.js +1 -0
- package/plugins/runtime-modules/contracts.js +61 -0
- package/plugins/runtime-modules/core/client-media-sources.d.ts +5 -0
- package/plugins/runtime-modules/core/client-media-sources.js +6 -0
- package/plugins/runtime-modules/core/messaging/forms.js +2 -15
- package/plugins/runtime-modules/core/messaging/labels.d.ts +0 -12
- package/plugins/runtime-modules/core/messaging/labels.js +0 -24
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -6
- package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/collection-view/config.js +7 -0
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +8 -2
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
- package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.js +14 -2
- package/plugins/runtime-modules/core/widgets/image/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/image/editor.d.ts +1 -4
- package/plugins/runtime-modules/core/widgets/image/editor.js +2 -2
- package/plugins/runtime-modules/core/widgets/slot-upload/client.js +2 -3
- package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +4 -25
- package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
- package/plugins/runtime-modules/preset-contracts/pub-area.js +0 -1
- package/plugins/runtime-modules/resolver.js +27 -1
- package/plugins/runtime-modules/settings.d.ts +20 -3
- package/plugins/runtime-modules/settings.js +35 -5
- package/plugins/runtime-modules/site-module-client-manifests.d.ts +2 -0
- package/plugins/runtime-modules/site-module-client-manifests.js +2 -0
- package/plugins/runtime-modules/site-modules-client.d.ts +5 -0
- package/plugins/runtime-modules/site-modules-client.js +1 -0
- package/plugins/runtime-modules/theme/brand-theme-model.js +0 -1
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +97 -192
- package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +6 -2
- package/runtime-client-manifests-accounting.d.ts +1 -1
- package/runtime-client-manifests-accounting.js +1 -1
- package/runtime-client-manifests-admin.d.ts +1 -1
- package/runtime-client-manifests-admin.js +1 -1
- package/runtime-client-manifests-app.d.ts +1 -1
- package/runtime-client-manifests-app.js +1 -1
- package/runtime-client-manifests-builder.d.ts +1 -1
- package/runtime-client-manifests-builder.js +1 -1
- package/runtime-client-manifests-editor.d.ts +1 -1
- package/runtime-client-manifests-editor.js +1 -1
- package/runtime-client-manifests-public.d.ts +2 -1
- package/runtime-client-manifests-public.js +1 -1
- package/runtime-media-source-client.d.ts +3 -0
- package/runtime-media-source-client.js +2 -0
- package/server-helpers/cms-request.js +10 -4
- package/theme/phi-theme-presets.d.ts +13 -3
- package/theme/phi-theme-presets.js +20 -3
- package/theme/phi-theme-seed-derivation.d.ts +240 -0
- package/theme/phi-theme-seed-derivation.js +126 -0
- package/types/cms-plugins.d.ts +29 -0
- package/types/media-source.d.ts +48 -0
- package/types/media-source.js +1 -0
- package/types/site-config.d.ts +1 -2
- package/types/site-theme.d.ts +0 -6
- package/types.d.ts +1 -0
- package/components/media/asset-controller-routes.d.ts +0 -8
- package/components/media/asset-controller-routes.js +0 -31
- package/helpers/brand-contact.d.ts +0 -14
- package/helpers/brand-contact.js +0 -26
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PhiMediaUploadLabels } from "./media-upload-labels";
|
|
1
2
|
export type PhiAssetPreviewToolWidgetLabels = {
|
|
2
3
|
searchPlaceholder: string;
|
|
3
4
|
folderLabel: string;
|
|
@@ -11,11 +12,9 @@ export type PhiAssetPreviewToolWidgetLabels = {
|
|
|
11
12
|
folderLockFailedText: string;
|
|
12
13
|
flagsLabel: string;
|
|
13
14
|
flagPlaceholder: string;
|
|
14
|
-
uploadToggleLabel: string;
|
|
15
15
|
kindLabel: string;
|
|
16
16
|
resetLabel: string;
|
|
17
17
|
reloadLabel: string;
|
|
18
|
-
assetsTemplate: string;
|
|
19
18
|
imageKindLabel: string;
|
|
20
19
|
videoKindLabel: string;
|
|
21
20
|
audioKindLabel: string;
|
|
@@ -26,6 +25,14 @@ export type PhiAssetPreviewToolWidgetLabels = {
|
|
|
26
25
|
fontKindLabel: string;
|
|
27
26
|
binaryKindLabel: string;
|
|
28
27
|
otherKindLabel: string;
|
|
28
|
+
/**
|
|
29
|
+
* The four flag words. Here and not with the Asset Module's editor because Core's toolbar flag filter
|
|
30
|
+
* reads them, and Core cannot import the Module; the Module's metadata form reads them from here.
|
|
31
|
+
*/
|
|
32
|
+
featuredFlagLabel: string;
|
|
33
|
+
lockedFlagLabel: string;
|
|
34
|
+
maskFlagLabel: string;
|
|
35
|
+
backgroundFlagLabel: string;
|
|
29
36
|
};
|
|
30
37
|
export type PhiAreaUploadWidgetLabels = {
|
|
31
38
|
dropTitle: string;
|
|
@@ -35,15 +42,11 @@ export type PhiAreaUploadWidgetLabels = {
|
|
|
35
42
|
deleteLabel: string;
|
|
36
43
|
doneLabel: string;
|
|
37
44
|
failedLabel: string;
|
|
38
|
-
assetExistsLabel: string;
|
|
39
45
|
deleteSuccessTemplate: string;
|
|
40
46
|
uploadSuccessTemplate: string;
|
|
41
|
-
uploadFailedText: string;
|
|
42
|
-
/** The body never reached the storage Provider, or the Provider refused it. */
|
|
43
|
-
uploadStorageUnreachableText: string;
|
|
44
|
-
/** The Folder the upload was meant for is locked. */
|
|
45
|
-
uploadFolderLockedText: string;
|
|
46
47
|
deleteFailedText: string;
|
|
48
|
+
/** The upload's own refusals, which are Core's `widget:upload` texts and not this Widget's. */
|
|
49
|
+
refusals: PhiMediaUploadLabels;
|
|
47
50
|
};
|
|
48
51
|
export type PhiAssetPreviewGridWidgetLabels = {
|
|
49
52
|
emptyDescription: string;
|
|
@@ -67,11 +70,9 @@ export type PhiAssetInspectorWidgetLabels = {
|
|
|
67
70
|
logoVariantLabel: string;
|
|
68
71
|
landscapeVariantLabel: string;
|
|
69
72
|
portraitVariantLabel: string;
|
|
70
|
-
storageKeyLabel: string;
|
|
71
73
|
publicUrlLabel: string;
|
|
72
74
|
contentTypeLabel: string;
|
|
73
75
|
originalNameLabel: string;
|
|
74
|
-
restrictedLabel: string;
|
|
75
76
|
copyLabelTemplate: string;
|
|
76
77
|
};
|
|
77
78
|
export type PhiAssetInspectorEditorWidgetLabels = {
|
|
@@ -79,7 +80,6 @@ export type PhiAssetInspectorEditorWidgetLabels = {
|
|
|
79
80
|
altLabel: string;
|
|
80
81
|
folderPathLabel: string;
|
|
81
82
|
folderPathPlaceholder: string;
|
|
82
|
-
folderPathHelp: string;
|
|
83
83
|
createFolderTitle: string;
|
|
84
84
|
folderNameLabel: string;
|
|
85
85
|
folderNamePlaceholder: string;
|
|
@@ -89,28 +89,29 @@ export type PhiAssetInspectorEditorWidgetLabels = {
|
|
|
89
89
|
flagsLabel: string;
|
|
90
90
|
focalRectLabel: string;
|
|
91
91
|
focalRectButtonLabel: string;
|
|
92
|
-
focalRectSaveLabel: string;
|
|
93
|
-
focalRectResetLabel: string;
|
|
94
|
-
focalRectClearLabel: string;
|
|
95
|
-
focalRectHelpLabel: string;
|
|
96
|
-
saveLabel: string;
|
|
97
|
-
savingLabel: string;
|
|
98
|
-
saveSuccessText: string;
|
|
99
|
-
saveFailedText: string;
|
|
100
|
-
featuredFlagLabel: string;
|
|
101
|
-
lockedFlagLabel: string;
|
|
102
|
-
maskFlagLabel: string;
|
|
103
|
-
backgroundFlagLabel: string;
|
|
104
92
|
};
|
|
93
|
+
/**
|
|
94
|
+
* What the Foundation's Media surfaces say, one Label Set for all of them (`label-sets/media.ts`): the
|
|
95
|
+
* picker, the Space names, the grid and the toolbar, and the upload surface's own texts, which are Core's
|
|
96
|
+
* `widget:upload` set. The inspector and the metadata editor are the Asset Module's and are not here.
|
|
97
|
+
*/
|
|
105
98
|
export type PhiAssetWidgetLabels = {
|
|
106
99
|
tool: PhiAssetPreviewToolWidgetLabels;
|
|
107
100
|
upload: PhiAreaUploadWidgetLabels;
|
|
108
101
|
grid: PhiAssetPreviewGridWidgetLabels;
|
|
109
|
-
inspector: PhiAssetInspectorWidgetLabels;
|
|
110
|
-
editor: PhiAssetInspectorEditorWidgetLabels;
|
|
111
102
|
picker: PhiMediaPickerWidgetLabels;
|
|
112
103
|
space: PhiMediaSpaceSelectorLabels;
|
|
113
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* What the Asset Module's own surfaces say: the Inspector's sections and the metadata editor. The types
|
|
107
|
+
* and the English defaults stay in the Foundation because Foundation components draw them (the inspector
|
|
108
|
+
* section, the focal rect) and take them as props; only the Label Set that translates them, and its
|
|
109
|
+
* loader, are the Module's (`plugins/runtime-modules/asset/labels.ts`).
|
|
110
|
+
*/
|
|
111
|
+
export type PhiAssetModuleLabels = {
|
|
112
|
+
inspector: PhiAssetInspectorWidgetLabels;
|
|
113
|
+
editor: PhiAssetInspectorEditorWidgetLabels;
|
|
114
|
+
};
|
|
114
115
|
/**
|
|
115
116
|
* Names for the Spaces a viewer may work in. A group Space is named after its group, so only the
|
|
116
117
|
* unnamed kinds -- the Site's own library and a personal Space -- need a word here.
|
|
@@ -124,10 +125,16 @@ export type PhiMediaSpaceSelectorLabels = {
|
|
|
124
125
|
export type PhiMediaPickerWidgetLabels = {
|
|
125
126
|
triggerLabel: string;
|
|
126
127
|
popoverTitle: string;
|
|
127
|
-
selectedLabel: string;
|
|
128
128
|
emptyDescription: string;
|
|
129
129
|
loadFailedDescription: string;
|
|
130
130
|
clearLabel: string;
|
|
131
131
|
tileSizeLabel: string;
|
|
132
|
+
/** The switch beside the Space select: the Site's library, or a media source. */
|
|
133
|
+
sourceLabel: string;
|
|
134
|
+
sourceFailedText: string;
|
|
135
|
+
importingLabel: string;
|
|
136
|
+
importFailedText: string;
|
|
137
|
+
loadMoreLabel: string;
|
|
132
138
|
};
|
|
133
139
|
export declare const PHI_MEDIA_WIDGET_DEFAULT_LABELS: PhiAssetWidgetLabels;
|
|
140
|
+
export declare const PHI_ASSET_MODULE_DEFAULT_LABELS: PhiAssetModuleLabels;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_MEDIA_UPLOAD_DEFAULT_LABELS } from "./media-upload-labels";
|
|
1
2
|
export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
2
3
|
tool: {
|
|
3
4
|
searchPlaceholder: "Search assets",
|
|
@@ -10,11 +11,9 @@ export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
|
10
11
|
folderLockFailedText: "The folder could not be changed.",
|
|
11
12
|
flagsLabel: "Flags",
|
|
12
13
|
flagPlaceholder: "Flag",
|
|
13
|
-
uploadToggleLabel: "Upload",
|
|
14
14
|
kindLabel: "Kind",
|
|
15
15
|
resetLabel: "Reset",
|
|
16
16
|
reloadLabel: "Reload",
|
|
17
|
-
assetsTemplate: "%1 assets",
|
|
18
17
|
imageKindLabel: "image",
|
|
19
18
|
videoKindLabel: "video",
|
|
20
19
|
audioKindLabel: "audio",
|
|
@@ -25,6 +24,10 @@ export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
|
25
24
|
fontKindLabel: "font",
|
|
26
25
|
binaryKindLabel: "binary",
|
|
27
26
|
otherKindLabel: "other",
|
|
27
|
+
featuredFlagLabel: "featured",
|
|
28
|
+
lockedFlagLabel: "locked",
|
|
29
|
+
maskFlagLabel: "mask",
|
|
30
|
+
backgroundFlagLabel: "background",
|
|
28
31
|
},
|
|
29
32
|
upload: {
|
|
30
33
|
dropTitle: "Drop assets here",
|
|
@@ -34,13 +37,10 @@ export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
|
34
37
|
deleteLabel: "Delete",
|
|
35
38
|
doneLabel: "Done",
|
|
36
39
|
failedLabel: "Failed",
|
|
37
|
-
assetExistsLabel: "This asset already exists.",
|
|
38
40
|
deleteSuccessTemplate: "Asset %1 deleted.",
|
|
39
41
|
uploadSuccessTemplate: "Uploaded %1.",
|
|
40
|
-
uploadFailedText: "Upload failed.",
|
|
41
|
-
uploadStorageUnreachableText: "The file storage could not be reached. The upload never left this browser.",
|
|
42
|
-
uploadFolderLockedText: "This folder is locked. Nothing can be uploaded into it until it is unlocked.",
|
|
43
42
|
deleteFailedText: "Delete failed.",
|
|
43
|
+
refusals: PHI_MEDIA_UPLOAD_DEFAULT_LABELS,
|
|
44
44
|
},
|
|
45
45
|
grid: {
|
|
46
46
|
emptyDescription: "No assets found.",
|
|
@@ -48,6 +48,27 @@ export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
|
48
48
|
deleteSuccessTemplate: "Asset %1 deleted.",
|
|
49
49
|
deleteFailedText: "Delete failed.",
|
|
50
50
|
},
|
|
51
|
+
picker: {
|
|
52
|
+
triggerLabel: "Mediathek",
|
|
53
|
+
popoverTitle: "Mediathek",
|
|
54
|
+
emptyDescription: "No assets found.",
|
|
55
|
+
loadFailedDescription: "The media library could not be loaded.",
|
|
56
|
+
clearLabel: "Clear selection",
|
|
57
|
+
tileSizeLabel: "Tile size",
|
|
58
|
+
sourceLabel: "Source",
|
|
59
|
+
sourceFailedText: "The source did not answer.",
|
|
60
|
+
importingLabel: "Importing...",
|
|
61
|
+
importFailedText: "The file could not be imported.",
|
|
62
|
+
loadMoreLabel: "Load more",
|
|
63
|
+
},
|
|
64
|
+
space: {
|
|
65
|
+
label: "Space",
|
|
66
|
+
site: "Site library",
|
|
67
|
+
user: "My files",
|
|
68
|
+
group: "Group",
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
export const PHI_ASSET_MODULE_DEFAULT_LABELS = {
|
|
51
72
|
inspector: {
|
|
52
73
|
inspectorTitle: "Asset inspector",
|
|
53
74
|
previewTitle: "Preview",
|
|
@@ -64,11 +85,9 @@ export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
|
64
85
|
logoVariantLabel: "Logo",
|
|
65
86
|
landscapeVariantLabel: "Landscape",
|
|
66
87
|
portraitVariantLabel: "Portrait",
|
|
67
|
-
storageKeyLabel: "Storage key",
|
|
68
88
|
publicUrlLabel: "Public URL",
|
|
69
89
|
contentTypeLabel: "Content type",
|
|
70
90
|
originalNameLabel: "Original name",
|
|
71
|
-
restrictedLabel: "Restricted",
|
|
72
91
|
copyLabelTemplate: "Copy %1",
|
|
73
92
|
},
|
|
74
93
|
editor: {
|
|
@@ -76,7 +95,6 @@ export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
|
76
95
|
altLabel: "Alt text",
|
|
77
96
|
folderPathLabel: "Folder path",
|
|
78
97
|
folderPathPlaceholder: "Summer 2024 / Costa Rica",
|
|
79
|
-
folderPathHelp: "Select an existing folder.",
|
|
80
98
|
createFolderTitle: "Create folder",
|
|
81
99
|
folderNameLabel: "Name",
|
|
82
100
|
folderNamePlaceholder: "Folder name",
|
|
@@ -86,32 +104,5 @@ export const PHI_MEDIA_WIDGET_DEFAULT_LABELS = {
|
|
|
86
104
|
flagsLabel: "Flags",
|
|
87
105
|
focalRectLabel: "Focal rect",
|
|
88
106
|
focalRectButtonLabel: "Focal rect",
|
|
89
|
-
focalRectSaveLabel: "Save focal rect",
|
|
90
|
-
focalRectResetLabel: "Reset",
|
|
91
|
-
focalRectClearLabel: "Clear",
|
|
92
|
-
focalRectHelpLabel: "Drag a rectangle over the original image. The rect is stored on the asset and clears cached variants when changed.",
|
|
93
|
-
saveLabel: "Save",
|
|
94
|
-
savingLabel: "Saving...",
|
|
95
|
-
saveSuccessText: "Asset saved.",
|
|
96
|
-
saveFailedText: "Save failed.",
|
|
97
|
-
featuredFlagLabel: "featured",
|
|
98
|
-
lockedFlagLabel: "locked",
|
|
99
|
-
maskFlagLabel: "mask",
|
|
100
|
-
backgroundFlagLabel: "background",
|
|
101
|
-
},
|
|
102
|
-
picker: {
|
|
103
|
-
triggerLabel: "Mediathek",
|
|
104
|
-
popoverTitle: "Mediathek",
|
|
105
|
-
selectedLabel: "Selected asset",
|
|
106
|
-
emptyDescription: "No assets found.",
|
|
107
|
-
loadFailedDescription: "The media library could not be loaded.",
|
|
108
|
-
clearLabel: "Clear selection",
|
|
109
|
-
tileSizeLabel: "Tile size",
|
|
110
|
-
},
|
|
111
|
-
space: {
|
|
112
|
-
label: "Space",
|
|
113
|
-
site: "Site library",
|
|
114
|
-
user: "My files",
|
|
115
|
-
group: "Group",
|
|
116
107
|
},
|
|
117
108
|
};
|
|
@@ -10,7 +10,7 @@ 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 { 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";
|
|
@@ -144,9 +144,8 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
|
|
|
144
144
|
* often than not -- so no Asset is finalized that nobody sees arrive. What is this Widget's own is the
|
|
145
145
|
* wall: an Asset that arrived becomes a tile, and the listing behind it hears of it.
|
|
146
146
|
*/
|
|
147
|
-
const areaUploadLabels = useMemo(() => resolvePhiAreaUploadLabels(labels), [labels]);
|
|
148
147
|
const upload = usePhiMediaUpload({
|
|
149
|
-
labels:
|
|
148
|
+
labels: labels.refusals,
|
|
150
149
|
initOptions: uploadInitOptions,
|
|
151
150
|
onUploaded: (asset, file) => {
|
|
152
151
|
const uploadedTile = normalizePhiImagePreviewTile(asset, []);
|
|
@@ -210,7 +209,7 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, collect
|
|
|
210
209
|
color: token.colorTextLightSolid,
|
|
211
210
|
padding: 12,
|
|
212
211
|
textAlign: "center",
|
|
213
|
-
}, children: _jsx(PhiTypographyControl, { style: { color: token.colorTextLightSolid }, children: item.error ?? labels.
|
|
212
|
+
}, children: _jsx(PhiTypographyControl, { style: { color: token.colorTextLightSolid }, children: item.error ?? labels.refusals.errorGeneric }) })) : null, item.deleting ? (_jsx("div", { style: {
|
|
214
213
|
position: "absolute",
|
|
215
214
|
inset: 0,
|
|
216
215
|
display: "flex",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PhiImageAssetVariantKeyValue, PhiMediaAsset } from "../../types/media";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PhiAssetModuleLabels } from "./media-widget-labels";
|
|
3
3
|
import type { MediaFocalRect } from "./focal-rect";
|
|
4
4
|
export declare function PhiAssetInspectorSection({ section, asset, selectedVariantKey, sitePublicUrl, onVariantKeyChange, labels, focalRect, onFocalRectOpen, }: {
|
|
5
5
|
section: "preview" | "technical";
|
|
@@ -7,7 +7,7 @@ export declare function PhiAssetInspectorSection({ section, asset, selectedVaria
|
|
|
7
7
|
selectedVariantKey: PhiImageAssetVariantKeyValue | null;
|
|
8
8
|
sitePublicUrl?: string | null;
|
|
9
9
|
onVariantKeyChange?: (value: PhiImageAssetVariantKeyValue | null) => void;
|
|
10
|
-
labels:
|
|
10
|
+
labels: PhiAssetModuleLabels;
|
|
11
11
|
focalRect: MediaFocalRect | null;
|
|
12
12
|
onFocalRectOpen?: () => void;
|
|
13
13
|
}): import("react").JSX.Element;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { PhiCmsAssetInspectorWidgetConfig } from "../../types/media";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PhiAssetModuleLabels } from "./media-widget-labels";
|
|
3
3
|
export type PhiAssetConfigWidgetProps = {
|
|
4
4
|
config?: PhiCmsAssetInspectorWidgetConfig | null;
|
|
5
|
-
labels:
|
|
6
|
-
inspector: PhiAssetInspectorWidgetLabels;
|
|
7
|
-
editor: PhiAssetWidgetLabels["editor"];
|
|
8
|
-
};
|
|
5
|
+
labels: PhiAssetModuleLabels;
|
|
9
6
|
sitePublicUrl?: string | null;
|
|
10
7
|
locale: string;
|
|
11
8
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import { type PhisMediaSourceItem } from "@phis/contracts/media-source";
|
|
2
3
|
import type { PhiMediaAssetTile } from "../../types/media";
|
|
3
4
|
import type { PhiCmsMediaPickerWidgetConfig } from "../../types/media";
|
|
4
5
|
import type { PhiSearchWidgetLabels } from "../widgets/label-types/search";
|
|
@@ -42,6 +43,15 @@ export declare function usePhiMediaPickerBinding({ config, labels, searchLabels,
|
|
|
42
43
|
label: string;
|
|
43
44
|
}[];
|
|
44
45
|
spaceValue: string | null;
|
|
46
|
+
sources: {
|
|
47
|
+
value: string;
|
|
48
|
+
label: string;
|
|
49
|
+
}[];
|
|
50
|
+
sourceValue: string;
|
|
51
|
+
sourceItems: readonly PhisMediaSourceItem[];
|
|
52
|
+
sourceHasMore: boolean;
|
|
53
|
+
importingItemId: string | null;
|
|
54
|
+
sourceNotice: string | null;
|
|
45
55
|
folders: ({
|
|
46
56
|
value: string;
|
|
47
57
|
label: string;
|
|
@@ -69,9 +79,13 @@ export declare function usePhiMediaPickerBinding({ config, labels, searchLabels,
|
|
|
69
79
|
folder: string;
|
|
70
80
|
space: string;
|
|
71
81
|
empty: string;
|
|
82
|
+
sourceEmpty: string;
|
|
72
83
|
clear: string;
|
|
73
84
|
reload: string;
|
|
74
85
|
tileSize: string;
|
|
86
|
+
source: string;
|
|
87
|
+
importing: string;
|
|
88
|
+
loadMore: string;
|
|
75
89
|
};
|
|
76
90
|
getPopupContainer: ((triggerNode: HTMLElement) => HTMLElement) | undefined;
|
|
77
91
|
popupRootClassName: string | undefined;
|
|
@@ -81,6 +95,9 @@ export declare function usePhiMediaPickerBinding({ config, labels, searchLabels,
|
|
|
81
95
|
onDiscard: ((originalAssetId: number | null) => void) | undefined;
|
|
82
96
|
onQueryChange: (nextQuery: string) => void;
|
|
83
97
|
onSpaceChange: (nextSpace: string) => void;
|
|
98
|
+
onSourceChange: (nextSource: string) => void;
|
|
99
|
+
onSourceItemSelect: (item: PhisMediaSourceItem) => Promise<PhiMediaAssetTile | null>;
|
|
100
|
+
onSourceLoadMore: () => void;
|
|
84
101
|
onFolderChange: (nextFolder: string) => void;
|
|
85
102
|
onPageChange: (nextPage: number, nextPageSize: number) => void;
|
|
86
103
|
onMinColumnWidthChange: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { PHIS_MEDIA_SOURCE_PAGE_MAX_ITEMS, PHIS_MEDIA_SOURCE_QUERY_MAX_LENGTH, } from "@phis/contracts/media-source";
|
|
4
5
|
import { PhiImageAssetVariantKey, PhiMediaKind } from "../../constants/media";
|
|
5
6
|
import { usePhiControlSignalController } from "../widgets/client/shared/phi-control-signals";
|
|
6
7
|
import { usePhiCollectionProvider } from "../widgets/client/shared/phi-collection-provider";
|
|
@@ -14,6 +15,8 @@ import { setPhiImagePreviewSelection } from "./phi-image-preview-store";
|
|
|
14
15
|
import { readPhiMediaAssetTiles, readPhiMediaFolders, readPhiMediaSpace, readPhiMediaSpaces, } from "./phi-image-preview-data";
|
|
15
16
|
import { buildPhiMediaSpaceOptions, usePhiMediaSpaceSelectionAllowed, } from "./media-space-selection";
|
|
16
17
|
import { isPhiRecord } from "../../helpers/is-record";
|
|
18
|
+
import { readPhiMediaSourceImportErrorMessage, usePhiMediaSources, } from "./phi-media-sources";
|
|
19
|
+
import { usePhiCollectionProviderAction } from "../widgets/client/shared/phi-collection-provider";
|
|
17
20
|
export function usePhiMediaPickerBinding({ config, labels, searchLabels, value: controlledValue, onAssetSelect, onAssetClear, open: controlledOpen, onOpenChange, onCommit, onDiscard, onPopupOpenChange, trigger, getPopupContainer, popupRootClassName, siteSpaceOnly = false, isAssetSelectable, }) {
|
|
18
21
|
const [localOpen, setLocalOpen] = useState(false);
|
|
19
22
|
const [localValue, setLocalValue] = useState(controlledValue ?? null);
|
|
@@ -37,6 +40,17 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
37
40
|
*/
|
|
38
41
|
const [requestedSpaceAddress, setRequestedSpaceAddress] = useState(null);
|
|
39
42
|
const spaceSelectionAllowed = usePhiMediaSpaceSelectionAllowed() && !siteSpaceOnly;
|
|
43
|
+
// "" is the Site's library; anything else is the id of a media source (`phi-media-sources.tsx`).
|
|
44
|
+
const [sourceId, setSourceId] = useState("");
|
|
45
|
+
// Tagged with the source that answered, so that another source never shows these for a frame.
|
|
46
|
+
const [sourcePageOf, setSourcePageOf] = useState({ sourceId: "", items: [] });
|
|
47
|
+
const [sourceCursor, setSourceCursor] = useState(null);
|
|
48
|
+
const [sourceLoading, setSourceLoading] = useState(false);
|
|
49
|
+
const [sourceFailed, setSourceFailed] = useState(false);
|
|
50
|
+
const [importingItemId, setImportingItemId] = useState(null);
|
|
51
|
+
const [importFailure, setImportFailure] = useState(null);
|
|
52
|
+
const sourceRequestRef = useRef(null);
|
|
53
|
+
const importRequestRef = useRef(null);
|
|
40
54
|
const [total, setTotal] = useState(0);
|
|
41
55
|
const [loading, setLoading] = useState(false);
|
|
42
56
|
const [loadFailed, setLoadFailed] = useState(false);
|
|
@@ -49,11 +63,28 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
49
63
|
: null;
|
|
50
64
|
const source = config?.dataSource ?? PHI_ASSET_COLLECTION_DATA_SOURCE;
|
|
51
65
|
const { provider, bindingError } = usePhiCollectionProvider(source);
|
|
66
|
+
const updateAsset = usePhiCollectionProviderAction(source);
|
|
52
67
|
const locale = usePhiIntlLocale();
|
|
53
68
|
const timeZone = usePhiIntlTimeZone();
|
|
54
69
|
const folderOptions = useMemo(() => buildPhiMediaFolderCascaderOptions(folders), [folders]);
|
|
55
70
|
const spaceOptions = useMemo(() => buildPhiMediaSpaceOptions(spaces, labels.space), [labels.space, spaces]);
|
|
56
71
|
const folderValue = useMemo(() => buildPhiMediaFolderValueById(folders, folderId), [folderId, folders]);
|
|
72
|
+
/*
|
|
73
|
+
* The sources are asked for when the picker is open and not before. The switch is shown only on the Site
|
|
74
|
+
* Space, because an import always goes to the Site Space: where the surface may name a Space, the one
|
|
75
|
+
* the last answer served decides; a surface that never may (`siteSpaceOnly`, the Builder, the Editor)
|
|
76
|
+
* is on the Site Space by construction. Before the first answer nothing was named, which is the Site Space.
|
|
77
|
+
*/
|
|
78
|
+
const mediaSources = usePhiMediaSources({ enabled: isOpen });
|
|
79
|
+
const activeSpaceKind = spaces.find((space) => space.address === spaceAddress)?.kind ?? null;
|
|
80
|
+
const onSiteSpace = !spaceSelectionAllowed || spaceAddress == null || activeSpaceKind === "site";
|
|
81
|
+
const sourceSwitchShown = onSiteSpace && mediaSources.length > 0;
|
|
82
|
+
const activeSource = sourceSwitchShown ? mediaSources.find((entry) => entry.id === sourceId) ?? null : null;
|
|
83
|
+
const sourceOptions = useMemo(() => sourceSwitchShown
|
|
84
|
+
? [{ value: "", label: labels.space.site }, ...mediaSources.map((entry) => ({ value: entry.id, label: entry.label }))]
|
|
85
|
+
: [], [labels.space.site, mediaSources, sourceSwitchShown]);
|
|
86
|
+
const sourceQuery = searchQuery.trim().slice(0, PHIS_MEDIA_SOURCE_QUERY_MAX_LENGTH);
|
|
87
|
+
const sourcePageSize = Math.min(Math.max(pageSize, 1), PHIS_MEDIA_SOURCE_PAGE_MAX_ITEMS);
|
|
57
88
|
const query = useMemo(() => ({
|
|
58
89
|
page,
|
|
59
90
|
pageSize,
|
|
@@ -82,6 +113,9 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
82
113
|
return;
|
|
83
114
|
if (!provider || !source)
|
|
84
115
|
return;
|
|
116
|
+
// The source's items stand where the library's tiles do; the library is read again when it comes back.
|
|
117
|
+
if (activeSource)
|
|
118
|
+
return;
|
|
85
119
|
const abortController = new AbortController();
|
|
86
120
|
const load = async () => {
|
|
87
121
|
setLoading(true);
|
|
@@ -127,12 +161,158 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
127
161
|
};
|
|
128
162
|
void load();
|
|
129
163
|
return () => abortController.abort();
|
|
130
|
-
}, [isOpen, locale, provider, query, refreshToken, source, timeZone]);
|
|
164
|
+
}, [activeSource, isOpen, locale, provider, query, refreshToken, source, timeZone]);
|
|
165
|
+
const activeSourceId = activeSource?.id ?? null;
|
|
166
|
+
const readSourcePage = useCallback(async (cursor, signal) => {
|
|
167
|
+
if (!activeSource)
|
|
168
|
+
return null;
|
|
169
|
+
return activeSource.list({
|
|
170
|
+
query: sourceQuery,
|
|
171
|
+
kinds: [mediaType],
|
|
172
|
+
cursor,
|
|
173
|
+
limit: sourcePageSize,
|
|
174
|
+
locale,
|
|
175
|
+
signal,
|
|
176
|
+
});
|
|
177
|
+
}, [activeSource, locale, mediaType, sourcePageSize, sourceQuery]);
|
|
178
|
+
// The first page of the active source, again whenever the source or what was typed changes.
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (!isOpen || !activeSourceId)
|
|
181
|
+
return;
|
|
182
|
+
const abortController = new AbortController();
|
|
183
|
+
sourceRequestRef.current = abortController;
|
|
184
|
+
void (async () => {
|
|
185
|
+
setSourceLoading(true);
|
|
186
|
+
setSourceFailed(false);
|
|
187
|
+
setSourcePageOf({ sourceId: activeSourceId, items: [] });
|
|
188
|
+
setSourceCursor(null);
|
|
189
|
+
try {
|
|
190
|
+
const page = await readSourcePage(null, abortController.signal);
|
|
191
|
+
if (!page || abortController.signal.aborted)
|
|
192
|
+
return;
|
|
193
|
+
setSourcePageOf({ sourceId: activeSourceId, items: page.items });
|
|
194
|
+
setSourceCursor(page.nextCursor);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (abortController.signal.aborted)
|
|
198
|
+
return;
|
|
199
|
+
console.error("Media source failed to list.", error);
|
|
200
|
+
setSourceFailed(true);
|
|
201
|
+
}
|
|
202
|
+
finally {
|
|
203
|
+
if (!abortController.signal.aborted)
|
|
204
|
+
setSourceLoading(false);
|
|
205
|
+
}
|
|
206
|
+
})();
|
|
207
|
+
// Also what "Load more" asked since: it answers the question that was asked before.
|
|
208
|
+
return () => {
|
|
209
|
+
abortController.abort();
|
|
210
|
+
sourceRequestRef.current?.abort();
|
|
211
|
+
};
|
|
212
|
+
}, [activeSourceId, isOpen, readSourcePage]);
|
|
213
|
+
// A closed picker stops what it asked: the listing and an import on its way.
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
if (isOpen)
|
|
216
|
+
return;
|
|
217
|
+
sourceRequestRef.current?.abort();
|
|
218
|
+
importRequestRef.current?.abort();
|
|
219
|
+
importRequestRef.current = null;
|
|
220
|
+
}, [isOpen]);
|
|
221
|
+
useEffect(() => () => {
|
|
222
|
+
sourceRequestRef.current?.abort();
|
|
223
|
+
importRequestRef.current?.abort();
|
|
224
|
+
}, []);
|
|
225
|
+
const loadMoreSourceItems = () => {
|
|
226
|
+
if (!sourceCursor || sourceLoading)
|
|
227
|
+
return;
|
|
228
|
+
const abortController = new AbortController();
|
|
229
|
+
sourceRequestRef.current = abortController;
|
|
230
|
+
setSourceLoading(true);
|
|
231
|
+
setSourceFailed(false);
|
|
232
|
+
void (async () => {
|
|
233
|
+
try {
|
|
234
|
+
const page = await readSourcePage(sourceCursor, abortController.signal);
|
|
235
|
+
if (!page || abortController.signal.aborted)
|
|
236
|
+
return;
|
|
237
|
+
setSourcePageOf((current) => ({ sourceId: current.sourceId, items: [...current.items, ...page.items] }));
|
|
238
|
+
setSourceCursor(page.nextCursor);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
if (abortController.signal.aborted)
|
|
242
|
+
return;
|
|
243
|
+
console.error("Media source failed to list.", error);
|
|
244
|
+
setSourceFailed(true);
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
if (!abortController.signal.aborted)
|
|
248
|
+
setSourceLoading(false);
|
|
249
|
+
}
|
|
250
|
+
})();
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Imports the chosen item and answers the Asset it became, which the Control then chooses exactly as it
|
|
254
|
+
* would a tile of the library. Nothing but a refusal says anything: a stopped import (the picker closed,
|
|
255
|
+
* another source chosen) is not a failure, and the picker stays in the source view for the reader to
|
|
256
|
+
* try again.
|
|
257
|
+
*/
|
|
258
|
+
const importSourceItem = async (item) => {
|
|
259
|
+
if (!activeSource || importRequestRef.current)
|
|
260
|
+
return null;
|
|
261
|
+
const abortController = new AbortController();
|
|
262
|
+
importRequestRef.current = abortController;
|
|
263
|
+
setImportingItemId(item.id);
|
|
264
|
+
setImportFailure(null);
|
|
265
|
+
try {
|
|
266
|
+
const imported = await activeSource.importItem({ item, folderId, signal: abortController.signal });
|
|
267
|
+
if (abortController.signal.aborted)
|
|
268
|
+
return null;
|
|
269
|
+
let tile = imported.asset;
|
|
270
|
+
if (imported.metadata) {
|
|
271
|
+
/*
|
|
272
|
+
* A Module's file arrives titled after its file name; its own title and alt text are written
|
|
273
|
+
* through the Asset update the library already has. The Asset exists by now, so a refusal here
|
|
274
|
+
* leaves it chosen with the file's name rather than losing what was imported.
|
|
275
|
+
*/
|
|
276
|
+
try {
|
|
277
|
+
await updateAsset({
|
|
278
|
+
actionKey: "update",
|
|
279
|
+
itemKey: tile.id,
|
|
280
|
+
item: { title: imported.metadata.title, altText: imported.metadata.altText },
|
|
281
|
+
query,
|
|
282
|
+
});
|
|
283
|
+
tile = { ...tile, title: imported.metadata.title, altText: imported.metadata.altText };
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
console.error("Media picker could not set the imported Asset's title.", error);
|
|
287
|
+
}
|
|
288
|
+
if (abortController.signal.aborted)
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
assetCacheRef.current.set(tile.id, tile);
|
|
292
|
+
setSourceId("");
|
|
293
|
+
return tile;
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
if (abortController.signal.aborted)
|
|
297
|
+
return null;
|
|
298
|
+
console.error("Media source import failed.", error);
|
|
299
|
+
setImportFailure(readPhiMediaSourceImportErrorMessage(error, labels.upload.refusals, labels.picker.importFailedText));
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
if (importRequestRef.current === abortController)
|
|
304
|
+
importRequestRef.current = null;
|
|
305
|
+
setImportingItemId(null);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
131
308
|
const resolvedAssets = provider && source ? assets : [];
|
|
132
309
|
const updateOpen = (next) => {
|
|
133
310
|
if (controlledOpen == null)
|
|
134
311
|
setLocalOpen(next);
|
|
135
312
|
if (next) {
|
|
313
|
+
// A picker opens on the Site's library, whatever source the last opening ended in.
|
|
314
|
+
setSourceId("");
|
|
315
|
+
setImportFailure(null);
|
|
136
316
|
setRefreshToken((current) => current + 1);
|
|
137
317
|
reloadSignals.emitCapability("reload", null);
|
|
138
318
|
kindSignals.emitCapability("kind", mediaType);
|
|
@@ -168,6 +348,12 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
168
348
|
assets: resolvedAssets,
|
|
169
349
|
spaces: spaceSelectionAllowed ? spaceOptions : [],
|
|
170
350
|
spaceValue: spaceSelectionAllowed ? spaceAddress : null,
|
|
351
|
+
sources: sourceOptions,
|
|
352
|
+
sourceValue: activeSource?.id ?? "",
|
|
353
|
+
sourceItems: activeSource && sourcePageOf.sourceId === activeSource.id ? sourcePageOf.items : [],
|
|
354
|
+
sourceHasMore: activeSource != null && sourceCursor != null,
|
|
355
|
+
importingItemId,
|
|
356
|
+
sourceNotice: importFailure,
|
|
171
357
|
folders: provider && source ? folderOptions : [],
|
|
172
358
|
folderValue,
|
|
173
359
|
query: searchQuery,
|
|
@@ -175,12 +361,12 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
175
361
|
pageSize,
|
|
176
362
|
minColumnWidth,
|
|
177
363
|
total: provider && source ? total : 0,
|
|
178
|
-
loading,
|
|
364
|
+
loading: activeSource ? sourceLoading : loading,
|
|
179
365
|
showSearchBar: config?.showSearchBar ?? true,
|
|
180
366
|
showFolderFilter: config?.showFolderFilter ?? true,
|
|
181
367
|
showPagination: config?.showPagination ?? true,
|
|
182
368
|
trigger,
|
|
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 },
|
|
369
|
+
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), sourceEmpty: sourceFailed ? labels.picker.sourceFailedText : labels.picker.emptyDescription, clear: labels.picker.clearLabel, reload: labels.tool.reloadLabel, tileSize: labels.picker.tileSizeLabel, source: labels.picker.sourceLabel, importing: labels.picker.importingLabel, loadMore: labels.picker.loadMoreLabel },
|
|
184
370
|
getPopupContainer,
|
|
185
371
|
popupRootClassName,
|
|
186
372
|
isAssetSelectable,
|
|
@@ -197,6 +383,15 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
|
|
|
197
383
|
setFolderId(null);
|
|
198
384
|
setPage(1);
|
|
199
385
|
},
|
|
386
|
+
onSourceChange: (nextSource) => {
|
|
387
|
+
// What was asked of the source before is not an answer to what is asked now.
|
|
388
|
+
importRequestRef.current?.abort();
|
|
389
|
+
importRequestRef.current = null;
|
|
390
|
+
setImportFailure(null);
|
|
391
|
+
setSourceId(nextSource);
|
|
392
|
+
},
|
|
393
|
+
onSourceItemSelect: importSourceItem,
|
|
394
|
+
onSourceLoadMore: loadMoreSourceItems,
|
|
200
395
|
onFolderChange: (nextFolder) => { setFolderId(resolvePhiMediaFolderIdFromValue(folders, nextFolder)); setPage(1); pathSignals.emitCapability("path", nextFolder); },
|
|
201
396
|
onPageChange: (nextPage, nextPageSize) => { setPage(nextPage); setPageSize(nextPageSize); paginationSignals.emitCapability("pagination", { page: nextPage, pageSize: nextPageSize, total }); },
|
|
202
397
|
onMinColumnWidthChange: setMinColumnWidth,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type PhiAssetWidgetLabels } from "./media-widget-labels";
|
|
3
|
+
export declare function PhiMediaPickerLabelsProvider({ labels, children, }: {
|
|
4
|
+
labels?: PhiAssetWidgetLabels;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export declare function usePhiMediaPickerLabels(): PhiAssetWidgetLabels;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { PHI_MEDIA_WIDGET_DEFAULT_LABELS } from "./media-widget-labels";
|
|
5
|
+
/**
|
|
6
|
+
* The words of the Media picker, read where a picker is opened.
|
|
7
|
+
*
|
|
8
|
+
* A picker is opened from many surfaces that have no Media Widget of their own: the Builder's image tool
|
|
9
|
+
* button and mask picker, the Inspector's image and background fields, the Theme's logo and background
|
|
10
|
+
* controls. Each of them used to take the English defaults, so the picker said "Search assets" and "No
|
|
11
|
+
* assets found." to a reader of any language. Handing the loaded set down as a prop would teach every
|
|
12
|
+
* station on the way about strings it only passes on, so the server half that renders the surface loads
|
|
13
|
+
* `getPhiMediaWidgetLabels` and wraps the client subtree in this provider -- the way
|
|
14
|
+
* `PhiAuthoringToolsLabelsProvider` does for the tool captions.
|
|
15
|
+
*
|
|
16
|
+
* Outside a provider the reading is the English defaults, which is what every one of those surfaces said
|
|
17
|
+
* before.
|
|
18
|
+
*/
|
|
19
|
+
const PhiMediaPickerLabelsContext = createContext(PHI_MEDIA_WIDGET_DEFAULT_LABELS);
|
|
20
|
+
export function PhiMediaPickerLabelsProvider({ labels, children, }) {
|
|
21
|
+
return (_jsx(PhiMediaPickerLabelsContext.Provider, { value: labels ?? PHI_MEDIA_WIDGET_DEFAULT_LABELS, children: children }));
|
|
22
|
+
}
|
|
23
|
+
export function usePhiMediaPickerLabels() {
|
|
24
|
+
return useContext(PhiMediaPickerLabelsContext);
|
|
25
|
+
}
|