@webiny/app-file-manager 6.4.11 → 6.6.0-alpha.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/app.js +21 -2
- package/app.js.map +1 -1
- package/domain/tagsHelpers.d.ts +2 -2
- package/domain/types.d.ts +0 -8
- package/features/permissions/abstractions.d.ts +2 -2
- package/features/permissions/feature.d.ts +3 -3
- package/features/shared/FILE_FIELDS.js +4 -0
- package/features/shared/FILE_FIELDS.js.map +1 -1
- package/features/shared/FileFieldsProviderWithWcp.d.ts +5 -5
- package/features/shared/FileFieldsProviderWithWcp.js +7 -7
- package/features/shared/FileFieldsProviderWithWcp.js.map +1 -1
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.d.ts +18 -0
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js +33 -0
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js.map +1 -0
- package/modules/AiEnrichment/ReenrichFileGateway.d.ts +12 -0
- package/modules/AiEnrichment/ReenrichFileGateway.js +23 -0
- package/modules/AiEnrichment/ReenrichFileGateway.js.map +1 -0
- package/modules/AiEnrichment/ReenrichWithAi.d.ts +11 -0
- package/modules/AiEnrichment/ReenrichWithAi.js +57 -0
- package/modules/AiEnrichment/ReenrichWithAi.js.map +1 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.d.ts +50 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.js +114 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.js.map +1 -0
- package/modules/AiEnrichment/StreamingPlaceholder.d.ts +15 -0
- package/modules/AiEnrichment/StreamingPlaceholder.js +32 -0
- package/modules/AiEnrichment/StreamingPlaceholder.js.map +1 -0
- package/modules/AiEnrichment/abstractions.d.ts +70 -0
- package/modules/AiEnrichment/abstractions.js +6 -0
- package/modules/AiEnrichment/abstractions.js.map +1 -0
- package/modules/AiEnrichment/feature.d.ts +3 -0
- package/modules/AiEnrichment/feature.js +21 -0
- package/modules/AiEnrichment/feature.js.map +1 -0
- package/modules/AiEnrichment/index.d.ts +2 -0
- package/modules/AiEnrichment/index.js +9 -0
- package/modules/AiEnrichment/index.js.map +1 -0
- package/modules/Enterprise/index.js +3 -3
- package/modules/Enterprise/index.js.map +1 -1
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.d.ts +26 -0
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js +39 -0
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.d.ts +34 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.js +42 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.d.ts +21 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.js +42 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.js +20 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js +20 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.d.ts +16 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js +33 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.d.ts +25 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.js +38 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.js +19 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.js +19 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/feature.d.ts +1 -0
- package/modules/HeadlessCms/fieldType/feature.js +27 -0
- package/modules/HeadlessCms/fieldType/feature.js.map +1 -0
- package/modules/HeadlessCms/fieldType/isAssetField.d.ts +2 -0
- package/modules/HeadlessCms/fieldType/isAssetField.js +4 -0
- package/modules/HeadlessCms/fieldType/isAssetField.js.map +1 -0
- package/package.json +24 -34
- package/presentation/FileActions/FileDetails/EditImage.d.ts +2 -0
- package/presentation/FileActions/FileDetails/EditImage.js +39 -0
- package/presentation/FileActions/FileDetails/EditImage.js.map +1 -0
- package/presentation/FileActions/index.js +8 -0
- package/presentation/FileActions/index.js.map +1 -1
- package/presentation/FileDetails/FileDetailsPresenter.d.ts +5 -4
- package/presentation/FileDetails/FileDetailsPresenter.js +40 -46
- package/presentation/FileDetails/FileDetailsPresenter.js.map +1 -1
- package/presentation/FileDetails/FileDetailsPresenter.test.js +39 -56
- package/presentation/FileDetails/FileDetailsPresenter.test.js.map +1 -1
- package/presentation/FileDetails/abstractions.d.ts +2 -0
- package/presentation/FileDetails/abstractions.js.map +1 -1
- package/presentation/FileDetails/components/Content.d.ts +6 -4
- package/presentation/FileDetails/components/Content.js +2 -2
- package/presentation/FileDetails/components/Content.js.map +1 -1
- package/presentation/FileDetails/components/FileDetailsDrawer.d.ts +2 -2
- package/presentation/FileDetails/components/FileDetailsDrawer.js +11 -5
- package/presentation/FileDetails/components/FileDetailsDrawer.js.map +1 -1
- package/presentation/FileList/FileListDataSource.d.ts +8 -12
- package/presentation/FileList/FileListDataSource.js +47 -87
- package/presentation/FileList/FileListDataSource.js.map +1 -1
- package/presentation/FileList/FileListPresenter.test.js +9 -3
- package/presentation/FileList/FileListPresenter.test.js.map +1 -1
- package/presentation/FileList/FileManagerPresenter.d.ts +1 -0
- package/presentation/FileList/FileManagerPresenter.js +15 -5
- package/presentation/FileList/FileManagerPresenter.js.map +1 -1
- package/presentation/FileList/abstractions.d.ts +3 -0
- package/presentation/FileList/abstractions.js.map +1 -1
- package/presentation/FileList/components/BulkActions/BulkActionBar.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/BulkActionDelete.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/BulkActionMove.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/index.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/index.js +0 -1
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.d.ts +9 -8
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.js +3 -9
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.js.map +1 -1
- package/presentation/FileList/components/Filters/SubFoldersToggle.d.ts +2 -2
- package/presentation/FileList/components/Filters/TagsFilter.d.ts +2 -2
- package/presentation/FileList/components/Filters/TypeFilter.d.ts +2 -2
- package/presentation/FileList/components/Grid/FileGrid.d.ts +2 -2
- package/presentation/FileList/components/Grid/FileGrid.js +1 -1
- package/presentation/FileList/components/Grid/FileGrid.js.map +1 -1
- package/presentation/FileList/components/Grid/FileGrid.test.js +18 -7
- package/presentation/FileList/components/Grid/FileGrid.test.js.map +1 -1
- package/presentation/FileList/components/Header/FileManagerHeader.d.ts +2 -2
- package/presentation/FileList/components/Search/SearchBar.d.ts +2 -2
- package/presentation/FileList/components/Table/FileTable.d.ts +2 -2
- package/presentation/FileList/components/Table/FileTable.js +1 -1
- package/presentation/FileList/components/Table/FileTable.js.map +1 -1
- package/presentation/FileList/components/Table/FileTable.test.js +9 -4
- package/presentation/FileList/components/Table/FileTable.test.js.map +1 -1
- package/presentation/FileList/components/Upload/UploadProgress.d.ts +2 -2
- package/presentation/FileManager/FileManagerBreadcrumbs.d.ts +12 -0
- package/presentation/FileManager/FileManagerBreadcrumbs.js +37 -0
- package/presentation/FileManager/FileManagerBreadcrumbs.js.map +1 -0
- package/presentation/FileManager/FileManagerView.js +36 -2
- package/presentation/FileManager/FileManagerView.js.map +1 -1
- package/presentation/FileManager/RouteParamsSync.d.ts +2 -0
- package/presentation/FileManager/RouteParamsSync.js +30 -0
- package/presentation/FileManager/RouteParamsSync.js.map +1 -0
- package/presentation/Settings/components/SettingsView.d.ts +2 -2
- package/presentation/config/DefaultFileManagerConfig.js +13 -11
- package/presentation/config/DefaultFileManagerConfig.js.map +1 -1
- package/presentation/config/FileManagerViewConfig.d.ts +19 -25
- package/presentation/config/configComponents/Browser/BulkAction.d.ts +10 -8
- package/presentation/config/configComponents/Browser/BulkAction.js +3 -9
- package/presentation/config/configComponents/Browser/BulkAction.js.map +1 -1
- package/presentation/config/configComponents/Browser/FileAction.d.ts +2 -1
- package/presentation/config/configComponents/Browser/FolderAction.d.ts +2 -1
- package/presentation/config/configComponents/Browser/Table/Column.d.ts +9 -8
- package/presentation/config/configComponents/Browser/Table/index.d.ts +9 -9
- package/presentation/config/configComponents/Browser/index.d.ts +20 -20
- package/presentation/config/configComponents/Browser/index.js +0 -8
- package/presentation/config/configComponents/Browser/index.js.map +1 -1
- package/presentation/config/configComponents/FileDetails/index.d.ts +4 -2
- package/presentation/config/thumbnailRenderers/CroppedFileImage.d.ts +18 -0
- package/presentation/config/thumbnailRenderers/CroppedFileImage.js +66 -0
- package/presentation/config/thumbnailRenderers/CroppedFileImage.js.map +1 -0
- package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js.map +1 -1
- package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js.map +1 -1
- package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js.map +1 -1
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.d.ts +22 -0
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.js +56 -0
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.d.ts +13 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.js +36 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.d.ts +7 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.js +32 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.js.map +1 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.d.ts +18 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js +88 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.d.ts +13 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js +60 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.d.ts +15 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.js +25 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.js.map +1 -0
- package/presentation/fieldRenderers/assetValue.d.ts +10 -0
- package/presentation/fieldRenderers/assetValue.js +88 -0
- package/presentation/fieldRenderers/assetValue.js.map +1 -0
- package/presentation/hooks/useCmsImageEditor.d.ts +10 -0
- package/presentation/hooks/useCmsImageEditor.js +76 -0
- package/presentation/hooks/useCmsImageEditor.js.map +1 -0
- package/presentation/hooks/useEditImage.d.ts +14 -0
- package/presentation/hooks/useEditImage.js +67 -0
- package/presentation/hooks/useEditImage.js.map +1 -0
- package/routes.d.ts +1 -0
- package/routes.js +2 -1
- package/routes.js.map +1 -1
- package/modules/HeadlessCms/fileField.d.ts +0 -2
- package/modules/HeadlessCms/fileField.js +0 -44
- package/modules/HeadlessCms/fileField.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/fileField.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/fileField.js +0 -53
- package/modules/HeadlessCms/fileRenderer/fileField.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/fileFields.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/fileFields.js +0 -73
- package/modules/HeadlessCms/fileRenderer/fileFields.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/utils.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/utils.js +0 -15
- package/modules/HeadlessCms/fileRenderer/utils.js.map +0 -1
- package/modules/HeadlessCms/index.d.ts +0 -1
- package/modules/HeadlessCms/index.js +0 -14
- package/modules/HeadlessCms/index.js.map +0 -1
- package/modules/Settings/graphql.d.ts +0 -12
- package/modules/Settings/graphql.js +0 -36
- package/modules/Settings/graphql.js.map +0 -1
- package/modules/Settings/views/FileManagerSettings.d.ts +0 -2
- package/modules/Settings/views/FileManagerSettings.js +0 -134
- package/modules/Settings/views/FileManagerSettings.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.d.ts +0 -7
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.d.ts +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js +0 -44
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.d.ts +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js +0 -52
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.d.ts +0 -61
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js +0 -111
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js +0 -372
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.d.ts +0 -8
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js +0 -31
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.d.ts +0 -11
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js +0 -33
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.js +0 -1
- package/presentation/FileList/components/BulkActions/BulkActionEdit.d.ts +0 -4
- package/presentation/FileList/components/BulkActions/BulkActionEdit.js +0 -105
- package/presentation/FileList/components/BulkActions/BulkActionEdit.js.map +0 -1
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.d.ts +0 -7
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.js +0 -11
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.js.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Skeleton, cn } from "@webiny/admin-ui";
|
|
3
|
+
const WIDTHS = {
|
|
4
|
+
chips: [
|
|
5
|
+
"w-16",
|
|
6
|
+
"w-24",
|
|
7
|
+
"w-20",
|
|
8
|
+
"w-14"
|
|
9
|
+
],
|
|
10
|
+
text: [
|
|
11
|
+
"w-full",
|
|
12
|
+
"w-full",
|
|
13
|
+
"w-3/4"
|
|
14
|
+
]
|
|
15
|
+
};
|
|
16
|
+
const StreamingPlaceholder = ({ loading, variant })=>{
|
|
17
|
+
if (!loading) return /*#__PURE__*/ react.createElement("div", {
|
|
18
|
+
className: "text-sm text-neutral-strong"
|
|
19
|
+
}, "—");
|
|
20
|
+
const chips = "chips" === variant;
|
|
21
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
22
|
+
className: chips ? "flex flex-wrap gap-xs" : "flex flex-col gap-xs"
|
|
23
|
+
}, WIDTHS[variant].map((width)=>/*#__PURE__*/ react.createElement(Skeleton, {
|
|
24
|
+
key: width,
|
|
25
|
+
type: "text",
|
|
26
|
+
size: "sm",
|
|
27
|
+
className: cn(width, chips && "rounded")
|
|
28
|
+
})));
|
|
29
|
+
};
|
|
30
|
+
export { StreamingPlaceholder };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=StreamingPlaceholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/AiEnrichment/StreamingPlaceholder.js","sources":["../../../src/modules/AiEnrichment/StreamingPlaceholder.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, Skeleton } from \"@webiny/admin-ui\";\n\n// Uneven on purpose: equal-length bars read as a table, not as content still arriving.\nconst WIDTHS: Record<StreamingPlaceholderVariant, string[]> = {\n chips: [\"w-16\", \"w-24\", \"w-20\", \"w-14\"],\n text: [\"w-full\", \"w-full\", \"w-3/4\"]\n};\n\nexport type StreamingPlaceholderVariant = \"chips\" | \"text\";\n\nexport interface StreamingPlaceholderProps {\n /** While the producer is still running, an empty field is pending — not empty. */\n loading: boolean;\n variant: StreamingPlaceholderVariant;\n}\n\n/**\n * Stands in for a field that has no content yet: skeleton bars while a stream is running, and a dash\n * once it has stopped and the field genuinely came back empty.\n *\n * The bar widths and layout live here rather than in props, so a caller says what KIND of content is\n * coming and nothing more.\n */\nexport const StreamingPlaceholder = ({ loading, variant }: StreamingPlaceholderProps) => {\n if (!loading) {\n return <div className={\"text-sm text-neutral-strong\"}>{\"—\"}</div>;\n }\n\n const chips = variant === \"chips\";\n\n return (\n <div className={chips ? \"flex flex-wrap gap-xs\" : \"flex flex-col gap-xs\"}>\n {WIDTHS[variant].map(width => (\n <Skeleton\n key={width}\n type={\"text\"}\n size={\"sm\"}\n className={cn(width, chips && \"rounded\")}\n />\n ))}\n </div>\n );\n};\n"],"names":["WIDTHS","StreamingPlaceholder","loading","variant","chips","width","Skeleton","cn"],"mappings":";;AAIA,MAAMA,SAAwD;IAC1D,OAAO;QAAC;QAAQ;QAAQ;QAAQ;KAAO;IACvC,MAAM;QAAC;QAAU;QAAU;KAAQ;AACvC;AAiBO,MAAMC,uBAAuB,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAA6B;IAChF,IAAI,CAACD,SACD,OAAO,WAAP,GAAO,oBAAC;QAAI,WAAW;OAAgC;IAG3D,MAAME,QAAQD,AAAY,YAAZA;IAEd,OAAO,WAAP,GACI,oBAAC;QAAI,WAAWC,QAAQ,0BAA0B;OAC7CJ,MAAM,CAACG,QAAQ,CAAC,GAAG,CAACE,CAAAA,QAAAA,WAAAA,GACjB,oBAACC,UAAQA;YACL,KAAKD;YACL,MAAM;YACN,MAAM;YACN,WAAWE,GAAGF,OAAOD,SAAS;;AAKlD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirrors the server-sent event payloads emitted by the api-side `AiImageEnrichmentStreamRoute`
|
|
3
|
+
* (see `streamEvents.ts` in `@webiny/ai-powerups`). Duplicated rather than imported: the admin app
|
|
4
|
+
* must not depend on an api-side package. Keep the two in sync.
|
|
5
|
+
*/
|
|
6
|
+
export interface EnrichmentStreamStartEvent {
|
|
7
|
+
type: "start";
|
|
8
|
+
fileId: string;
|
|
9
|
+
model: string;
|
|
10
|
+
}
|
|
11
|
+
export interface EnrichmentStreamPartialEvent {
|
|
12
|
+
type: "partial";
|
|
13
|
+
tags: string[];
|
|
14
|
+
description: string;
|
|
15
|
+
}
|
|
16
|
+
export interface EnrichmentStreamDoneEvent {
|
|
17
|
+
type: "done";
|
|
18
|
+
fileId: string;
|
|
19
|
+
tags: string[];
|
|
20
|
+
description: string;
|
|
21
|
+
}
|
|
22
|
+
export interface EnrichmentStreamErrorEvent {
|
|
23
|
+
type: "error";
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
export type EnrichmentStreamEvent = EnrichmentStreamStartEvent | EnrichmentStreamPartialEvent | EnrichmentStreamDoneEvent | EnrichmentStreamErrorEvent;
|
|
27
|
+
export interface IReenrichFileOptions {
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
export interface IReenrichFileGateway {
|
|
31
|
+
/**
|
|
32
|
+
* Re-runs AI enrichment for a file, yielding progress events as they arrive.
|
|
33
|
+
*
|
|
34
|
+
* Failures the server detects before streaming starts (unknown file, non-image, no provider,
|
|
35
|
+
* license) reject instead of yielding an `error` event — they come back as HTTP status codes.
|
|
36
|
+
*/
|
|
37
|
+
execute(fileId: string, options?: IReenrichFileOptions): AsyncGenerator<EnrichmentStreamEvent>;
|
|
38
|
+
}
|
|
39
|
+
export declare const ReenrichFileGateway: import("@webiny/di").Abstraction<IReenrichFileGateway>;
|
|
40
|
+
export declare namespace ReenrichFileGateway {
|
|
41
|
+
type Interface = IReenrichFileGateway;
|
|
42
|
+
type Event = EnrichmentStreamEvent;
|
|
43
|
+
}
|
|
44
|
+
export interface IReenrichWithAiViewModel {
|
|
45
|
+
open: boolean;
|
|
46
|
+
/** What the dialog says under its title: the error when there is one, else the status. */
|
|
47
|
+
message: string;
|
|
48
|
+
tags: string[];
|
|
49
|
+
description: string;
|
|
50
|
+
/** The proposal is complete, so it can be accepted. */
|
|
51
|
+
canSave: boolean;
|
|
52
|
+
/** The model is still producing output, so empty fields are pending rather than absent. */
|
|
53
|
+
loading: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface IReenrichWithAiPresenter {
|
|
56
|
+
readonly vm: IReenrichWithAiViewModel;
|
|
57
|
+
start(fileId: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Accept the proposal: drop the values into the file details form and close. Nothing is written
|
|
60
|
+
* — the user saves the file with Update, the same as for a hand-typed edit.
|
|
61
|
+
*/
|
|
62
|
+
accept(): void;
|
|
63
|
+
setOpen(open: boolean): void;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
}
|
|
66
|
+
export declare const ReenrichWithAiPresenter: import("@webiny/di").Abstraction<IReenrichWithAiPresenter>;
|
|
67
|
+
export declare namespace ReenrichWithAiPresenter {
|
|
68
|
+
type Interface = IReenrichWithAiPresenter;
|
|
69
|
+
type ViewModel = IReenrichWithAiViewModel;
|
|
70
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/admin";
|
|
2
|
+
const ReenrichFileGateway = createAbstraction("ReenrichFileGateway");
|
|
3
|
+
const ReenrichWithAiPresenter = createAbstraction("FileManager/ReenrichWithAiPresenter");
|
|
4
|
+
export { ReenrichFileGateway, ReenrichWithAiPresenter };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/AiEnrichment/abstractions.js","sources":["../../../src/modules/AiEnrichment/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\n/**\n * Mirrors the server-sent event payloads emitted by the api-side `AiImageEnrichmentStreamRoute`\n * (see `streamEvents.ts` in `@webiny/ai-powerups`). Duplicated rather than imported: the admin app\n * must not depend on an api-side package. Keep the two in sync.\n */\nexport interface EnrichmentStreamStartEvent {\n type: \"start\";\n fileId: string;\n model: string;\n}\n\nexport interface EnrichmentStreamPartialEvent {\n type: \"partial\";\n tags: string[];\n description: string;\n}\n\nexport interface EnrichmentStreamDoneEvent {\n type: \"done\";\n fileId: string;\n tags: string[];\n description: string;\n}\n\nexport interface EnrichmentStreamErrorEvent {\n type: \"error\";\n message: string;\n}\n\nexport type EnrichmentStreamEvent =\n | EnrichmentStreamStartEvent\n | EnrichmentStreamPartialEvent\n | EnrichmentStreamDoneEvent\n | EnrichmentStreamErrorEvent;\n\nexport interface IReenrichFileOptions {\n signal?: AbortSignal;\n}\n\nexport interface IReenrichFileGateway {\n /**\n * Re-runs AI enrichment for a file, yielding progress events as they arrive.\n *\n * Failures the server detects before streaming starts (unknown file, non-image, no provider,\n * license) reject instead of yielding an `error` event — they come back as HTTP status codes.\n */\n execute(fileId: string, options?: IReenrichFileOptions): AsyncGenerator<EnrichmentStreamEvent>;\n}\n\nexport const ReenrichFileGateway = createAbstraction<IReenrichFileGateway>(\"ReenrichFileGateway\");\n\nexport namespace ReenrichFileGateway {\n export type Interface = IReenrichFileGateway;\n export type Event = EnrichmentStreamEvent;\n}\n\nexport interface IReenrichWithAiViewModel {\n open: boolean;\n /** What the dialog says under its title: the error when there is one, else the status. */\n message: string;\n tags: string[];\n description: string;\n /** The proposal is complete, so it can be accepted. */\n canSave: boolean;\n /** The model is still producing output, so empty fields are pending rather than absent. */\n loading: boolean;\n}\n\nexport interface IReenrichWithAiPresenter {\n readonly vm: IReenrichWithAiViewModel;\n start(fileId: string): Promise<void>;\n /**\n * Accept the proposal: drop the values into the file details form and close. Nothing is written\n * — the user saves the file with Update, the same as for a hand-typed edit.\n */\n accept(): void;\n setOpen(open: boolean): void;\n dispose(): void;\n}\n\nexport const ReenrichWithAiPresenter = createAbstraction<IReenrichWithAiPresenter>(\n \"FileManager/ReenrichWithAiPresenter\"\n);\n\nexport namespace ReenrichWithAiPresenter {\n export type Interface = IReenrichWithAiPresenter;\n export type ViewModel = IReenrichWithAiViewModel;\n}\n"],"names":["ReenrichFileGateway","createAbstraction","ReenrichWithAiPresenter"],"mappings":";AAmDO,MAAMA,sBAAsBC,kBAAwC;AA+BpE,MAAMC,0BAA0BD,kBACnC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { AiImageEnrichmentEventHandler } from "./AiImageEnrichmentEventHandler.js";
|
|
3
|
+
import { ReenrichFileGateway } from "./ReenrichFileGateway.js";
|
|
4
|
+
import { ReenrichWithAiPresenter } from "./ReenrichWithAiPresenter.js";
|
|
5
|
+
import { ReenrichWithAiPresenter as external_abstractions_js_ReenrichWithAiPresenter } from "./abstractions.js";
|
|
6
|
+
const AiEnrichmentFeature = createFeature({
|
|
7
|
+
name: "FileManager/AiEnrichment",
|
|
8
|
+
register (container) {
|
|
9
|
+
container.register(AiImageEnrichmentEventHandler);
|
|
10
|
+
container.register(ReenrichFileGateway).inSingletonScope();
|
|
11
|
+
container.register(ReenrichWithAiPresenter).inSingletonScope();
|
|
12
|
+
},
|
|
13
|
+
resolve (container) {
|
|
14
|
+
return {
|
|
15
|
+
presenter: container.resolve(external_abstractions_js_ReenrichWithAiPresenter)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export { AiEnrichmentFeature };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/AiEnrichment/feature.js","sources":["../../../src/modules/AiEnrichment/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { AiImageEnrichmentEventHandler } from \"./AiImageEnrichmentEventHandler.js\";\nimport { ReenrichFileGateway } from \"./ReenrichFileGateway.js\";\nimport { ReenrichWithAiPresenter } from \"./ReenrichWithAiPresenter.js\";\nimport { ReenrichWithAiPresenter as PresenterAbstraction } from \"./abstractions.js\";\n\nexport const AiEnrichmentFeature = createFeature({\n name: \"FileManager/AiEnrichment\",\n register(container) {\n container.register(AiImageEnrichmentEventHandler);\n container.register(ReenrichFileGateway).inSingletonScope();\n // Singleton so the dialog's state survives re-renders of the view that reads it.\n container.register(ReenrichWithAiPresenter).inSingletonScope();\n },\n resolve(container) {\n return {\n presenter: container.resolve(PresenterAbstraction)\n };\n }\n});\n"],"names":["AiEnrichmentFeature","createFeature","container","AiImageEnrichmentEventHandler","ReenrichFileGateway","ReenrichWithAiPresenter","PresenterAbstraction"],"mappings":";;;;;AAMO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,qBAAqB,gBAAgB;QAExDF,UAAU,QAAQ,CAACG,yBAAyB,gBAAgB;IAChE;IACA,SAAQH,SAAS;QACb,OAAO;YACH,WAAWA,UAAU,OAAO,CAACI;QACjC;IACJ;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { RegisterFeature } from "@webiny/app-admin";
|
|
3
|
+
import { AiEnrichmentFeature } from "./feature.js";
|
|
4
|
+
const AiEnrichmentModule = ()=>/*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
5
|
+
feature: AiEnrichmentFeature
|
|
6
|
+
});
|
|
7
|
+
export { AiEnrichmentModule };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/AiEnrichment/index.js","sources":["../../../src/modules/AiEnrichment/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { AiEnrichmentFeature } from \"./feature.js\";\n\nexport const AiEnrichmentModule = () => {\n return <RegisterFeature feature={AiEnrichmentFeature} />;\n};\n"],"names":["AiEnrichmentModule","RegisterFeature","AiEnrichmentFeature"],"mappings":";;;AAIO,MAAMA,qBAAqB,IACvB,WAAP,GAAO,oBAACC,iBAAeA;QAAC,SAASC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useFeatureFlags } from "@webiny/app-admin";
|
|
2
2
|
import react from "react";
|
|
3
3
|
import { FileManagerViewConfig } from "../../index.js";
|
|
4
4
|
import { THREAT_SCAN } from "./constants.js";
|
|
@@ -21,8 +21,8 @@ const DisableTableCellWhileThreatScanInProgress = Table.Column.createDecorator((
|
|
|
21
21
|
return /*#__PURE__*/ react.createElement(Original, props);
|
|
22
22
|
});
|
|
23
23
|
const EnterpriseModule = ()=>{
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
24
|
+
const featureFlags = useFeatureFlags();
|
|
25
|
+
if (!featureFlags.isEnabled("fileManager.threatDetection")) return null;
|
|
26
26
|
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(DisableFileWhileThreatScanInProgress, null), /*#__PURE__*/ react.createElement(DisableTableCellWhileThreatScanInProgress, null), /*#__PURE__*/ react.createElement(FileManagerViewConfig, null, /*#__PURE__*/ react.createElement(HandleWebsocketMessages, null)));
|
|
27
27
|
};
|
|
28
28
|
export { EnterpriseModule };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules/Enterprise/index.js","sources":["../../../src/modules/Enterprise/index.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"modules/Enterprise/index.js","sources":["../../../src/modules/Enterprise/index.tsx"],"sourcesContent":["import { useFeatureFlags } from \"@webiny/app-admin\";\nimport React from \"react\";\nimport { FileManagerViewConfig } from \"~/index.js\";\nimport { THREAT_SCAN } from \"~/modules/Enterprise/constants.js\";\nimport { ThreatScanInProgressFileBody } from \"./components/ThreatScanInProgressFileBody.js\";\nimport { ThreatScanInProgressTableCell } from \"./components/ThreatScanInProgressTableCell.js\";\nimport { HandleWebsocketMessages } from \"./HandleWebsocketMessages.js\";\n\nconst { Grid, Table } = FileManagerViewConfig.Browser;\n\nconst DisableFileWhileThreatScanInProgress = Grid.Item.createDecorator(Original => {\n return function Item(props) {\n if (props.file.tags.includes(THREAT_SCAN.IN_PROGRESS)) {\n return <Original {...props} fileBody={<ThreatScanInProgressFileBody />} />;\n }\n return <Original {...props} />;\n };\n});\n\nconst DisableTableCellWhileThreatScanInProgress = Table.Column.createDecorator(Original => {\n return function TableCellActionsWhileThreatScanInProgress(props) {\n if (props.cell) {\n return (\n <Original\n {...props}\n cell={\n <ThreatScanInProgressTableCell>{props.cell}</ThreatScanInProgressTableCell>\n }\n />\n );\n }\n\n return <Original {...props} />;\n };\n});\n\nexport const EnterpriseModule = () => {\n const featureFlags = useFeatureFlags();\n\n if (!featureFlags.isEnabled(\"fileManager.threatDetection\")) {\n return null;\n }\n\n return (\n <>\n <DisableFileWhileThreatScanInProgress />\n <DisableTableCellWhileThreatScanInProgress />\n <FileManagerViewConfig>\n <HandleWebsocketMessages />\n </FileManagerViewConfig>\n </>\n );\n};\n"],"names":["Grid","Table","FileManagerViewConfig","DisableFileWhileThreatScanInProgress","Original","props","THREAT_SCAN","ThreatScanInProgressFileBody","DisableTableCellWhileThreatScanInProgress","ThreatScanInProgressTableCell","EnterpriseModule","featureFlags","useFeatureFlags","HandleWebsocketMessages"],"mappings":";;;;;;;AAQA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC,sBAAsB,OAAO;AAErD,MAAMC,uCAAuCH,KAAK,IAAI,CAAC,eAAe,CAACI,CAAAA,WAC5D,SAAcC,KAAK;QACtB,IAAIA,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAACC,YAAY,WAAW,GAChD,OAAO,WAAP,GAAO,oBAACF,UAAAA;YAAU,GAAGC,KAAK;YAAE,wBAAU,oBAACE,8BAA4BA;;QAEvE,OAAO,WAAP,GAAO,oBAACH,UAAaC;IACzB;AAGJ,MAAMG,4CAA4CP,MAAM,MAAM,CAAC,eAAe,CAACG,CAAAA,WACpE,SAAmDC,KAAK;QAC3D,IAAIA,MAAM,IAAI,EACV,OAAO,WAAP,GACI,oBAACD,UAAAA;YACI,GAAGC,KAAK;YACT,oBACI,oBAACI,+BAA6BA,MAAEJ,MAAM,IAAI;;QAM1D,OAAO,WAAP,GAAO,oBAACD,UAAaC;IACzB;AAGG,MAAMK,mBAAmB;IAC5B,MAAMC,eAAeC;IAErB,IAAI,CAACD,aAAa,SAAS,CAAC,gCACxB,OAAO;IAGX,OAAO,WAAP,GACI,wDACI,oBAACR,sCAAoCA,OAAAA,WAAAA,GACrC,oBAACK,2CAAyCA,OAAAA,WAAAA,GAC1C,oBAACN,uBAAqBA,MAAAA,WAAAA,GAClB,oBAACW,yBAAuBA;AAIxC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CmsFieldEditorGroupModifier } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
|
|
2
|
+
import type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
|
|
3
|
+
import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Adds Asset-specific options to the field settings form in the content-model
|
|
6
|
+
* editor: an "Images only" toggle (parity with the File field) and an optional
|
|
7
|
+
* "Accepted file types" list. Both are honored by the asset picker renderers
|
|
8
|
+
* (`settings.imagesOnly` / `settings.accept`).
|
|
9
|
+
*
|
|
10
|
+
* Applies to the Asset field, which the editor resolves to the `"asset"` field
|
|
11
|
+
* type via `matches()` even though it is stored as an `object`.
|
|
12
|
+
*/
|
|
13
|
+
declare class AssetFieldSettingsModifierImpl implements CmsFieldEditorGroupModifier.Interface {
|
|
14
|
+
group: string;
|
|
15
|
+
shouldApply(context: ICmsFieldEditorContext): boolean;
|
|
16
|
+
modifyForm(form: ICmsFieldEditorFormBuilder): void;
|
|
17
|
+
mapToForm(field: CmsModelField): {
|
|
18
|
+
imagesOnly: boolean;
|
|
19
|
+
accept: any;
|
|
20
|
+
};
|
|
21
|
+
mapFromForm(formData: Record<string, any>, field: CmsModelField): void;
|
|
22
|
+
}
|
|
23
|
+
export declare const AssetFieldSettingsModifier: typeof AssetFieldSettingsModifierImpl & {
|
|
24
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js").ICmsFieldEditorGroupModifier>;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CmsFieldEditorGroupModifier } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
|
|
2
|
+
class AssetFieldSettingsModifierImpl {
|
|
3
|
+
shouldApply(context) {
|
|
4
|
+
return "asset" === context.fieldType.type;
|
|
5
|
+
}
|
|
6
|
+
modifyForm(form) {
|
|
7
|
+
form.fields((fields)=>({
|
|
8
|
+
imagesOnly: fields.boolean().label("Images only").description("Allow only images to be selected").renderer("switch").defaultValue(false),
|
|
9
|
+
accept: fields.text().list().label("Accepted file types").description("MIME types or extensions to allow (e.g. image/png, application/pdf). Leave empty to allow all.").renderer("tags").defaultValue([])
|
|
10
|
+
}));
|
|
11
|
+
form.layout((layout)=>[
|
|
12
|
+
layout.row("imagesOnly"),
|
|
13
|
+
layout.row("accept")
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
16
|
+
mapToForm(field) {
|
|
17
|
+
return {
|
|
18
|
+
imagesOnly: field.settings?.imagesOnly ?? false,
|
|
19
|
+
accept: field.settings?.accept ?? []
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
mapFromForm(formData, field) {
|
|
23
|
+
if (!field.settings) field.settings = {};
|
|
24
|
+
field.settings.imagesOnly = formData.imagesOnly;
|
|
25
|
+
const accept = Array.isArray(formData.accept) ? formData.accept.filter((t)=>"string" == typeof t && t.trim().length > 0) : [];
|
|
26
|
+
if (accept.length > 0) field.settings.accept = accept;
|
|
27
|
+
else delete field.settings.accept;
|
|
28
|
+
}
|
|
29
|
+
constructor(){
|
|
30
|
+
this.group = "general";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const AssetFieldSettingsModifier = CmsFieldEditorGroupModifier.createImplementation({
|
|
34
|
+
implementation: AssetFieldSettingsModifierImpl,
|
|
35
|
+
dependencies: []
|
|
36
|
+
});
|
|
37
|
+
export { AssetFieldSettingsModifier };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=AssetFieldSettingsModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.ts"],"sourcesContent":["import { CmsFieldEditorGroupModifier } from \"@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js\";\nimport type {\n ICmsFieldEditorFormBuilder,\n ICmsFieldEditorContext\n} from \"@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\n\n/**\n * Adds Asset-specific options to the field settings form in the content-model\n * editor: an \"Images only\" toggle (parity with the File field) and an optional\n * \"Accepted file types\" list. Both are honored by the asset picker renderers\n * (`settings.imagesOnly` / `settings.accept`).\n *\n * Applies to the Asset field, which the editor resolves to the `\"asset\"` field\n * type via `matches()` even though it is stored as an `object`.\n */\nclass AssetFieldSettingsModifierImpl implements CmsFieldEditorGroupModifier.Interface {\n group = \"general\";\n\n shouldApply(context: ICmsFieldEditorContext) {\n return context.fieldType.type === \"asset\";\n }\n\n modifyForm(form: ICmsFieldEditorFormBuilder) {\n form.fields(fields => ({\n imagesOnly: fields\n .boolean()\n .label(\"Images only\")\n .description(\"Allow only images to be selected\")\n .renderer(\"switch\")\n .defaultValue(false),\n accept: fields\n .text()\n .list()\n .label(\"Accepted file types\")\n .description(\n \"MIME types or extensions to allow (e.g. image/png, application/pdf). Leave empty to allow all.\"\n )\n .renderer(\"tags\")\n .defaultValue([])\n }));\n form.layout(layout => [layout.row(\"imagesOnly\"), layout.row(\"accept\")]);\n }\n\n mapToForm(field: CmsModelField) {\n return {\n imagesOnly: field.settings?.imagesOnly ?? false,\n accept: field.settings?.accept ?? []\n };\n }\n\n mapFromForm(formData: Record<string, any>, field: CmsModelField) {\n if (!field.settings) {\n field.settings = {};\n }\n field.settings.imagesOnly = formData.imagesOnly;\n const accept = Array.isArray(formData.accept)\n ? formData.accept.filter((t: unknown) => typeof t === \"string\" && t.trim().length > 0)\n : [];\n if (accept.length > 0) {\n field.settings.accept = accept;\n } else {\n delete field.settings.accept;\n }\n }\n}\n\nexport const AssetFieldSettingsModifier = CmsFieldEditorGroupModifier.createImplementation({\n implementation: AssetFieldSettingsModifierImpl,\n dependencies: []\n});\n"],"names":["AssetFieldSettingsModifierImpl","context","form","fields","layout","field","formData","accept","Array","t","AssetFieldSettingsModifier","CmsFieldEditorGroupModifier"],"mappings":";AAgBA,MAAMA;IAGF,YAAYC,OAA+B,EAAE;QACzC,OAAOA,AAA2B,YAA3BA,QAAQ,SAAS,CAAC,IAAI;IACjC;IAEA,WAAWC,IAAgC,EAAE;QACzCA,KAAK,MAAM,CAACC,CAAAA,SAAW;gBACnB,YAAYA,OACP,OAAO,GACP,KAAK,CAAC,eACN,WAAW,CAAC,oCACZ,QAAQ,CAAC,UACT,YAAY,CAAC;gBAClB,QAAQA,OACH,IAAI,GACJ,IAAI,GACJ,KAAK,CAAC,uBACN,WAAW,CACR,kGAEH,QAAQ,CAAC,QACT,YAAY,CAAC,EAAE;YACxB;QACAD,KAAK,MAAM,CAACE,CAAAA,SAAU;gBAACA,OAAO,GAAG,CAAC;gBAAeA,OAAO,GAAG,CAAC;aAAU;IAC1E;IAEA,UAAUC,KAAoB,EAAE;QAC5B,OAAO;YACH,YAAYA,MAAM,QAAQ,EAAE,cAAc;YAC1C,QAAQA,MAAM,QAAQ,EAAE,UAAU,EAAE;QACxC;IACJ;IAEA,YAAYC,QAA6B,EAAED,KAAoB,EAAE;QAC7D,IAAI,CAACA,MAAM,QAAQ,EACfA,MAAM,QAAQ,GAAG,CAAC;QAEtBA,MAAM,QAAQ,CAAC,UAAU,GAAGC,SAAS,UAAU;QAC/C,MAAMC,SAASC,MAAM,OAAO,CAACF,SAAS,MAAM,IACtCA,SAAS,MAAM,CAAC,MAAM,CAAC,CAACG,IAAe,AAAa,YAAb,OAAOA,KAAkBA,EAAE,IAAI,GAAG,MAAM,GAAG,KAClF,EAAE;QACR,IAAIF,OAAO,MAAM,GAAG,GAChBF,MAAM,QAAQ,CAAC,MAAM,GAAGE;aAExB,OAAOF,MAAM,QAAQ,CAAC,MAAM;IAEpC;;aA/CA,KAAK,GAAG;;AAgDZ;AAEO,MAAMK,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CmsFieldType } from "@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js";
|
|
3
|
+
import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Palette entry for the Asset field. It is stored as an `object` field (so it reuses
|
|
6
|
+
* the object GraphQL/storage machinery); `createField()` therefore emits `type:
|
|
7
|
+
* "object"` with the asset renderer, and the API normalizer stamps the canonical
|
|
8
|
+
* nested schema on save. `matches()` lets the field editor resolve this descriptor
|
|
9
|
+
* for an asset field even though its stored type is `object`.
|
|
10
|
+
*/
|
|
11
|
+
declare class AssetFieldTypeImpl implements CmsFieldType.Interface {
|
|
12
|
+
type: string;
|
|
13
|
+
label: string;
|
|
14
|
+
description: string;
|
|
15
|
+
icon: React.JSX.Element;
|
|
16
|
+
allowList: boolean;
|
|
17
|
+
listLabel: string;
|
|
18
|
+
allowPredefinedValues: boolean;
|
|
19
|
+
validators: string[];
|
|
20
|
+
listValidators: string[];
|
|
21
|
+
matches(field: CmsModelField): boolean;
|
|
22
|
+
createField(): {
|
|
23
|
+
type: string;
|
|
24
|
+
validation: never[];
|
|
25
|
+
renderer: {
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
settings: {};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export declare const AssetFieldType: typeof AssetFieldTypeImpl & {
|
|
32
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js").ICmsFieldType>;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { ReactComponent } from "@webiny/icons/collections.svg";
|
|
3
|
+
import { CmsFieldType } from "@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js";
|
|
4
|
+
import { isAssetField } from "./isAssetField.js";
|
|
5
|
+
class AssetFieldTypeImpl {
|
|
6
|
+
matches(field) {
|
|
7
|
+
return isAssetField(field);
|
|
8
|
+
}
|
|
9
|
+
createField() {
|
|
10
|
+
return {
|
|
11
|
+
type: "asset",
|
|
12
|
+
validation: [],
|
|
13
|
+
renderer: {
|
|
14
|
+
name: "asset-input"
|
|
15
|
+
},
|
|
16
|
+
settings: {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
constructor(){
|
|
20
|
+
this.type = "asset";
|
|
21
|
+
this.label = "Asset";
|
|
22
|
+
this.description = "Images, videos, and documents — with per-usage cropping and focal point.";
|
|
23
|
+
this.icon = /*#__PURE__*/ react.createElement(ReactComponent, null);
|
|
24
|
+
this.allowList = true;
|
|
25
|
+
this.listLabel = "Use as a list of assets or a gallery";
|
|
26
|
+
this.allowPredefinedValues = false;
|
|
27
|
+
this.validators = [
|
|
28
|
+
"required"
|
|
29
|
+
];
|
|
30
|
+
this.listValidators = [
|
|
31
|
+
"minLength",
|
|
32
|
+
"maxLength"
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const AssetFieldType = CmsFieldType.createImplementation({
|
|
37
|
+
implementation: AssetFieldTypeImpl,
|
|
38
|
+
dependencies: []
|
|
39
|
+
});
|
|
40
|
+
export { AssetFieldType };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=AssetFieldType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/HeadlessCms/fieldType/AssetFieldType.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetFieldType.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as AssetIcon } from \"@webiny/icons/collections.svg\";\nimport { CmsFieldType } from \"@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport { isAssetField } from \"./isAssetField.js\";\n\n/**\n * Palette entry for the Asset field. It is stored as an `object` field (so it reuses\n * the object GraphQL/storage machinery); `createField()` therefore emits `type:\n * \"object\"` with the asset renderer, and the API normalizer stamps the canonical\n * nested schema on save. `matches()` lets the field editor resolve this descriptor\n * for an asset field even though its stored type is `object`.\n */\nclass AssetFieldTypeImpl implements CmsFieldType.Interface {\n type = \"asset\";\n label = \"Asset\";\n description = \"Images, videos, and documents — with per-usage cropping and focal point.\";\n icon = <AssetIcon />;\n allowList = true;\n listLabel = \"Use as a list of assets or a gallery\";\n allowPredefinedValues = false;\n validators = [\"required\"];\n listValidators = [\"minLength\", \"maxLength\"];\n\n matches(field: CmsModelField) {\n return isAssetField(field);\n }\n\n createField() {\n return {\n type: \"asset\",\n validation: [],\n renderer: { name: \"asset-input\" },\n settings: {}\n };\n }\n}\n\nexport const AssetFieldType = CmsFieldType.createImplementation({\n implementation: AssetFieldTypeImpl,\n dependencies: []\n});\n"],"names":["AssetFieldTypeImpl","field","isAssetField","AssetIcon","AssetFieldType","CmsFieldType"],"mappings":";;;;AAaA,MAAMA;IAWF,QAAQC,KAAoB,EAAE;QAC1B,OAAOC,aAAaD;IACxB;IAEA,cAAc;QACV,OAAO;YACH,MAAM;YACN,YAAY,EAAE;YACd,UAAU;gBAAE,MAAM;YAAc;YAChC,UAAU,CAAC;QACf;IACJ;;aArBA,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAAG;aACd,IAAI,GAAG,WAAP,GAAO,oBAACE,gBAASA;aACjB,SAAS,GAAG;aACZ,SAAS,GAAG;aACZ,qBAAqB,GAAG;aACxB,UAAU,GAAG;YAAC;SAAW;aACzB,cAAc,GAAG;YAAC;YAAa;SAAY;;AAc/C;AAEO,MAAMC,iBAAiBC,aAAa,oBAAoB,CAAC;IAC5D,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IFieldTypeFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
|
|
2
|
+
import { FieldBuilder } from "@webiny/app-admin/features/formModel/FieldBuilder.js";
|
|
3
|
+
export declare class AssetFieldBuilder extends FieldBuilder<"asset"> {
|
|
4
|
+
constructor();
|
|
5
|
+
list(): this;
|
|
6
|
+
imagesOnly(): this;
|
|
7
|
+
accept(mimeTypes: string[]): this;
|
|
8
|
+
}
|
|
9
|
+
declare class AssetFieldTypeFactory implements IFieldTypeFactory {
|
|
10
|
+
readonly type = "asset";
|
|
11
|
+
create(): AssetFieldBuilder;
|
|
12
|
+
}
|
|
13
|
+
export declare const AssetFormFieldType: typeof AssetFieldTypeFactory & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<IFieldTypeFactory>;
|
|
15
|
+
};
|
|
16
|
+
declare module "@webiny/app-admin/features/formModel/abstractions.js" {
|
|
17
|
+
interface IFieldBuilderRegistry {
|
|
18
|
+
asset(): AssetFieldBuilder;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FieldType } from "@webiny/app-admin/features/formModel/abstractions.js";
|
|
2
|
+
import { FieldBuilder } from "@webiny/app-admin/features/formModel/FieldBuilder.js";
|
|
3
|
+
class AssetFieldBuilder extends FieldBuilder {
|
|
4
|
+
constructor(){
|
|
5
|
+
super("asset");
|
|
6
|
+
this._config.renderer = "cmsAssetPicker";
|
|
7
|
+
}
|
|
8
|
+
list() {
|
|
9
|
+
super.list();
|
|
10
|
+
if ("cmsAssetPicker" === this._config.renderer) this._config.renderer = "cmsMultiAssetPicker";
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
imagesOnly() {
|
|
14
|
+
this._config.rendererSettings = {
|
|
15
|
+
...this._config.rendererSettings,
|
|
16
|
+
imagesOnly: true
|
|
17
|
+
};
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
accept(mimeTypes) {
|
|
21
|
+
this._config.rendererSettings = {
|
|
22
|
+
...this._config.rendererSettings,
|
|
23
|
+
accept: mimeTypes
|
|
24
|
+
};
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
class AssetFieldTypeFactory {
|
|
29
|
+
create() {
|
|
30
|
+
return new AssetFieldBuilder();
|
|
31
|
+
}
|
|
32
|
+
constructor(){
|
|
33
|
+
this.type = "asset";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const AssetFormFieldType = FieldType.createImplementation({
|
|
37
|
+
implementation: AssetFieldTypeFactory,
|
|
38
|
+
dependencies: []
|
|
39
|
+
});
|
|
40
|
+
export { AssetFieldBuilder, AssetFormFieldType };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=AssetFormFieldType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/HeadlessCms/fieldType/AssetFormFieldType.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetFormFieldType.ts"],"sourcesContent":["import {\n FieldType,\n type IFieldTypeFactory\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { FieldBuilder } from \"@webiny/app-admin/features/formModel/FieldBuilder.js\";\n\nexport class AssetFieldBuilder extends FieldBuilder<\"asset\"> {\n constructor() {\n super(\"asset\");\n this._config.renderer = \"cmsAssetPicker\";\n }\n\n override list(): this {\n super.list();\n if (this._config.renderer === \"cmsAssetPicker\") {\n this._config.renderer = \"cmsMultiAssetPicker\";\n }\n return this;\n }\n\n imagesOnly(): this {\n this._config.rendererSettings = { ...this._config.rendererSettings, imagesOnly: true };\n return this;\n }\n\n accept(mimeTypes: string[]): this {\n this._config.rendererSettings = { ...this._config.rendererSettings, accept: mimeTypes };\n return this;\n }\n}\n\nclass AssetFieldTypeFactory implements IFieldTypeFactory {\n readonly type = \"asset\";\n create() {\n return new AssetFieldBuilder();\n }\n}\n\nexport const AssetFormFieldType = FieldType.createImplementation({\n implementation: AssetFieldTypeFactory,\n dependencies: []\n});\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldBuilderRegistry {\n asset(): AssetFieldBuilder;\n }\n}\n"],"names":["AssetFieldBuilder","FieldBuilder","mimeTypes","AssetFieldTypeFactory","AssetFormFieldType","FieldType"],"mappings":";;AAMO,MAAMA,0BAA0BC;IACnC,aAAc;QACV,KAAK,CAAC;QACN,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG;IAC5B;IAES,OAAa;QAClB,KAAK,CAAC;QACN,IAAI,AAA0B,qBAA1B,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG;QAE5B,OAAO,IAAI;IACf;IAEA,aAAmB;QACf,IAAI,CAAC,OAAO,CAAC,gBAAgB,GAAG;YAAE,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB;YAAE,YAAY;QAAK;QACrF,OAAO,IAAI;IACf;IAEA,OAAOC,SAAmB,EAAQ;QAC9B,IAAI,CAAC,OAAO,CAAC,gBAAgB,GAAG;YAAE,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB;YAAE,QAAQA;QAAU;QACtF,OAAO,IAAI;IACf;AACJ;AAEA,MAAMC;IAEF,SAAS;QACL,OAAO,IAAIH;IACf;;aAHS,IAAI,GAAG;;AAIpB;AAEO,MAAMI,qBAAqBC,UAAU,oBAAoB,CAAC;IAC7D,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CmsFieldRenderer } from "@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js";
|
|
2
|
+
import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
|
|
3
|
+
declare class AssetInputRendererImpl implements CmsFieldRenderer.Interface {
|
|
4
|
+
rendererName: string;
|
|
5
|
+
formRenderer: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
canUse({ field }: {
|
|
9
|
+
field: CmsModelField;
|
|
10
|
+
}): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const AssetInputRenderer: typeof AssetInputRendererImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js").ICmsFieldRenderer>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CmsFieldRenderer } from "@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js";
|
|
2
|
+
import { isAssetField } from "./isAssetField.js";
|
|
3
|
+
class AssetInputRendererImpl {
|
|
4
|
+
canUse({ field }) {
|
|
5
|
+
return isAssetField(field) && !field.list;
|
|
6
|
+
}
|
|
7
|
+
constructor(){
|
|
8
|
+
this.rendererName = "asset-input";
|
|
9
|
+
this.formRenderer = "cmsAssetPicker";
|
|
10
|
+
this.name = "Asset Input";
|
|
11
|
+
this.description = "Enables selecting a single asset (image, document, or video) via File Manager.";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const AssetInputRenderer = CmsFieldRenderer.createImplementation({
|
|
15
|
+
implementation: AssetInputRendererImpl,
|
|
16
|
+
dependencies: []
|
|
17
|
+
});
|
|
18
|
+
export { AssetInputRenderer };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=AssetInputRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/HeadlessCms/fieldType/AssetInputRenderer.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetInputRenderer.ts"],"sourcesContent":["import { CmsFieldRenderer } from \"@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport { isAssetField } from \"./isAssetField.js\";\n\nclass AssetInputRendererImpl implements CmsFieldRenderer.Interface {\n rendererName = \"asset-input\";\n formRenderer = \"cmsAssetPicker\";\n name = \"Asset Input\";\n description = \"Enables selecting a single asset (image, document, or video) via File Manager.\";\n\n canUse({ field }: { field: CmsModelField }) {\n return isAssetField(field) && !field.list;\n }\n}\n\nexport const AssetInputRenderer = CmsFieldRenderer.createImplementation({\n implementation: AssetInputRendererImpl,\n dependencies: []\n});\n"],"names":["AssetInputRendererImpl","field","isAssetField","AssetInputRenderer","CmsFieldRenderer"],"mappings":";;AAIA,MAAMA;IAMF,OAAO,EAAEC,KAAK,EAA4B,EAAE;QACxC,OAAOC,aAAaD,UAAU,CAACA,MAAM,IAAI;IAC7C;;aAPA,YAAY,GAAG;aACf,YAAY,GAAG;aACf,IAAI,GAAG;aACP,WAAW,GAAG;;AAKlB;AAEO,MAAME,qBAAqBC,iBAAiB,oBAAoB,CAAC;IACpE,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CmsFieldRenderer } from "@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js";
|
|
2
|
+
import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
|
|
3
|
+
declare class AssetInputsRendererImpl implements CmsFieldRenderer.Interface {
|
|
4
|
+
rendererName: string;
|
|
5
|
+
formRenderer: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
canUse({ field }: {
|
|
9
|
+
field: CmsModelField;
|
|
10
|
+
}): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const AssetInputsRenderer: typeof AssetInputsRendererImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js").ICmsFieldRenderer>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CmsFieldRenderer } from "@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js";
|
|
2
|
+
import { isAssetField } from "./isAssetField.js";
|
|
3
|
+
class AssetInputsRendererImpl {
|
|
4
|
+
canUse({ field }) {
|
|
5
|
+
return isAssetField(field) && !!field.list;
|
|
6
|
+
}
|
|
7
|
+
constructor(){
|
|
8
|
+
this.rendererName = "asset-inputs";
|
|
9
|
+
this.formRenderer = "cmsMultiAssetPicker";
|
|
10
|
+
this.name = "Asset Inputs";
|
|
11
|
+
this.description = "Enables selecting multiple assets via File Manager.";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const AssetInputsRenderer = CmsFieldRenderer.createImplementation({
|
|
15
|
+
implementation: AssetInputsRendererImpl,
|
|
16
|
+
dependencies: []
|
|
17
|
+
});
|
|
18
|
+
export { AssetInputsRenderer };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=AssetInputsRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/HeadlessCms/fieldType/AssetInputsRenderer.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetInputsRenderer.ts"],"sourcesContent":["import { CmsFieldRenderer } from \"@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport { isAssetField } from \"./isAssetField.js\";\n\nclass AssetInputsRendererImpl implements CmsFieldRenderer.Interface {\n rendererName = \"asset-inputs\";\n formRenderer = \"cmsMultiAssetPicker\";\n name = \"Asset Inputs\";\n description = \"Enables selecting multiple assets via File Manager.\";\n\n canUse({ field }: { field: CmsModelField }) {\n return isAssetField(field) && !!field.list;\n }\n}\n\nexport const AssetInputsRenderer = CmsFieldRenderer.createImplementation({\n implementation: AssetInputsRendererImpl,\n dependencies: []\n});\n"],"names":["AssetInputsRendererImpl","field","isAssetField","AssetInputsRenderer","CmsFieldRenderer"],"mappings":";;AAIA,MAAMA;IAMF,OAAO,EAAEC,KAAK,EAA4B,EAAE;QACxC,OAAOC,aAAaD,UAAU,CAAC,CAACA,MAAM,IAAI;IAC9C;;aAPA,YAAY,GAAG;aACf,YAAY,GAAG;aACf,IAAI,GAAG;aACP,WAAW,GAAG;;AAKlB;AAEO,MAAME,sBAAsBC,iBAAiB,oBAAoB,CAAC;IACrE,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CmsFieldEditorGroupModifier } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
|
|
2
|
+
import type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
|
|
3
|
+
import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
|
|
4
|
+
declare class FileFieldSettingsModifierImpl implements CmsFieldEditorGroupModifier.Interface {
|
|
5
|
+
group: string;
|
|
6
|
+
shouldApply(context: ICmsFieldEditorContext): boolean;
|
|
7
|
+
modifyForm(form: ICmsFieldEditorFormBuilder): void;
|
|
8
|
+
mapToForm(field: CmsModelField): {
|
|
9
|
+
imagesOnly: boolean;
|
|
10
|
+
};
|
|
11
|
+
mapFromForm(formData: Record<string, any>, field: CmsModelField): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const FileFieldSettingsModifier: typeof FileFieldSettingsModifierImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js").ICmsFieldEditorGroupModifier>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CmsFieldEditorGroupModifier } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
|
|
2
|
+
class FileFieldSettingsModifierImpl {
|
|
3
|
+
shouldApply(context) {
|
|
4
|
+
return "file" === context.fieldType.type;
|
|
5
|
+
}
|
|
6
|
+
modifyForm(form) {
|
|
7
|
+
form.fields((fields)=>({
|
|
8
|
+
imagesOnly: fields.boolean().label("Images only").description("Allow only images to be selected").renderer("switch").defaultValue(false)
|
|
9
|
+
}));
|
|
10
|
+
form.layout((layout)=>[
|
|
11
|
+
layout.row("imagesOnly")
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
14
|
+
mapToForm(field) {
|
|
15
|
+
return {
|
|
16
|
+
imagesOnly: field.settings?.imagesOnly ?? false
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
mapFromForm(formData, field) {
|
|
20
|
+
if (!field.settings) field.settings = {};
|
|
21
|
+
field.settings.imagesOnly = formData.imagesOnly;
|
|
22
|
+
}
|
|
23
|
+
constructor(){
|
|
24
|
+
this.group = "general";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const FileFieldSettingsModifier = CmsFieldEditorGroupModifier.createImplementation({
|
|
28
|
+
implementation: FileFieldSettingsModifierImpl,
|
|
29
|
+
dependencies: []
|
|
30
|
+
});
|
|
31
|
+
export { FileFieldSettingsModifier };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=FileFieldSettingsModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js","sources":["../../../../src/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.ts"],"sourcesContent":["import { CmsFieldEditorGroupModifier } from \"@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js\";\nimport type {\n ICmsFieldEditorFormBuilder,\n ICmsFieldEditorContext\n} from \"@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\n\nclass FileFieldSettingsModifierImpl implements CmsFieldEditorGroupModifier.Interface {\n group = \"general\";\n\n shouldApply(context: ICmsFieldEditorContext) {\n return context.fieldType.type === \"file\";\n }\n\n modifyForm(form: ICmsFieldEditorFormBuilder) {\n form.fields(fields => ({\n imagesOnly: fields\n .boolean()\n .label(\"Images only\")\n .description(\"Allow only images to be selected\")\n .renderer(\"switch\")\n .defaultValue(false)\n }));\n form.layout(layout => [layout.row(\"imagesOnly\")]);\n }\n\n mapToForm(field: CmsModelField) {\n return { imagesOnly: field.settings?.imagesOnly ?? false };\n }\n\n mapFromForm(formData: Record<string, any>, field: CmsModelField) {\n if (!field.settings) {\n field.settings = {};\n }\n field.settings.imagesOnly = formData.imagesOnly;\n }\n}\n\nexport const FileFieldSettingsModifier = CmsFieldEditorGroupModifier.createImplementation({\n implementation: FileFieldSettingsModifierImpl,\n dependencies: []\n});\n"],"names":["FileFieldSettingsModifierImpl","context","form","fields","layout","field","formData","FileFieldSettingsModifier","CmsFieldEditorGroupModifier"],"mappings":";AAOA,MAAMA;IAGF,YAAYC,OAA+B,EAAE;QACzC,OAAOA,AAA2B,WAA3BA,QAAQ,SAAS,CAAC,IAAI;IACjC;IAEA,WAAWC,IAAgC,EAAE;QACzCA,KAAK,MAAM,CAACC,CAAAA,SAAW;gBACnB,YAAYA,OACP,OAAO,GACP,KAAK,CAAC,eACN,WAAW,CAAC,oCACZ,QAAQ,CAAC,UACT,YAAY,CAAC;YACtB;QACAD,KAAK,MAAM,CAACE,CAAAA,SAAU;gBAACA,OAAO,GAAG,CAAC;aAAc;IACpD;IAEA,UAAUC,KAAoB,EAAE;QAC5B,OAAO;YAAE,YAAYA,MAAM,QAAQ,EAAE,cAAc;QAAM;IAC7D;IAEA,YAAYC,QAA6B,EAAED,KAAoB,EAAE;QAC7D,IAAI,CAACA,MAAM,QAAQ,EACfA,MAAM,QAAQ,GAAG,CAAC;QAEtBA,MAAM,QAAQ,CAAC,UAAU,GAAGC,SAAS,UAAU;IACnD;;aA3BA,KAAK,GAAG;;AA4BZ;AAEO,MAAMC,4BAA4BC,4BAA4B,oBAAoB,CAAC;IACtF,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CmsFieldType } from "@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js";
|
|
3
|
+
declare class FileFieldTypeImpl implements CmsFieldType.Interface {
|
|
4
|
+
type: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description: string;
|
|
7
|
+
icon: React.JSX.Element;
|
|
8
|
+
allowList: boolean;
|
|
9
|
+
listLabel: string;
|
|
10
|
+
allowPredefinedValues: boolean;
|
|
11
|
+
validators: string[];
|
|
12
|
+
listValidators: string[];
|
|
13
|
+
deprecated: boolean;
|
|
14
|
+
createField(): {
|
|
15
|
+
type: string;
|
|
16
|
+
validation: never[];
|
|
17
|
+
renderer: {
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare const FileFieldType: typeof FileFieldTypeImpl & {
|
|
23
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js").ICmsFieldType>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|