@lowdefy/plugin-aws 5.1.0 → 5.2.0
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/dist/blocks/S3Download/S3Download.js +17 -5
- package/dist/blocks/S3Download/meta.js +15 -36
- package/dist/blocks/S3UploadButton/S3UploadButton.js +19 -7
- package/dist/blocks/S3UploadButton/meta.js +37 -4
- package/dist/blocks/S3UploadDragger/S3UploadDragger.js +28 -8
- package/dist/blocks/S3UploadDragger/meta.js +43 -7
- package/dist/blocks/S3UploadDragger/style.module.css +30 -0
- package/dist/blocks/S3UploadPhoto/S3UploadPhoto.js +24 -25
- package/dist/blocks/S3UploadPhoto/meta.js +45 -6
- package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js +4 -1
- package/dist/schemas/uploadTheme.js +53 -0
- package/package.json +8 -7
- package/dist/blocks/S3Download/schema.js +0 -107
- package/dist/blocks/S3UploadButton/__snapshots__/S3UploadButton.mock.test.js.snap +0 -1597
- package/dist/blocks/S3UploadButton/__snapshots__/S3UploadButton.test.js.snap +0 -281
- package/dist/blocks/S3UploadButton/schema.js +0 -121
- package/dist/blocks/S3UploadButton/tests.yaml +0 -44
- package/dist/blocks/S3UploadDragger/schema.js +0 -119
- package/dist/blocks/S3UploadPhoto/schema.js +0 -113
|
@@ -40,6 +40,7 @@ const S3Download = ({ blockId, classNames = {}, methods, properties, styles = {}
|
|
|
40
40
|
]
|
|
41
41
|
});
|
|
42
42
|
}, []);
|
|
43
|
+
const showRemoveIcon = properties.showRemoveIcon ?? false;
|
|
43
44
|
return /*#__PURE__*/ React.createElement(Upload, {
|
|
44
45
|
id: blockId,
|
|
45
46
|
className: classNames.element,
|
|
@@ -49,14 +50,25 @@ const S3Download = ({ blockId, classNames = {}, methods, properties, styles = {}
|
|
|
49
50
|
file,
|
|
50
51
|
methods
|
|
51
52
|
}),
|
|
52
|
-
showUploadList: {
|
|
53
|
-
showRemoveIcon: false,
|
|
54
|
-
showDownloadIcon: true
|
|
55
|
-
},
|
|
56
53
|
onDownload: async (file)=>await downloadFile({
|
|
57
54
|
file,
|
|
58
55
|
methods
|
|
59
|
-
})
|
|
56
|
+
}),
|
|
57
|
+
onRemove: (file)=>{
|
|
58
|
+
methods.triggerEvent({
|
|
59
|
+
name: 'onRemove',
|
|
60
|
+
event: {
|
|
61
|
+
file
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
// Controlled fileList: the YAML handler decides whether to update state.
|
|
65
|
+
// Return false so antd doesn't fire onChange with a removed-file list.
|
|
66
|
+
return false;
|
|
67
|
+
},
|
|
68
|
+
showUploadList: {
|
|
69
|
+
showDownloadIcon: true,
|
|
70
|
+
showRemoveIcon
|
|
71
|
+
}
|
|
60
72
|
});
|
|
61
73
|
};
|
|
62
74
|
export default withBlockDefaults(withTheme('Upload', S3Download));
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
15
|
+
*/ import uploadTheme from '../../schemas/uploadTheme.js';
|
|
16
|
+
export default {
|
|
16
17
|
category: 'display',
|
|
17
18
|
icons: [],
|
|
18
19
|
valueType: null,
|
|
@@ -20,7 +21,13 @@
|
|
|
20
21
|
element: 'The S3Download element.'
|
|
21
22
|
},
|
|
22
23
|
events: {
|
|
23
|
-
onChange: 'Triggered when the upload state is changing.'
|
|
24
|
+
onChange: 'Triggered when the upload state is changing.',
|
|
25
|
+
onRemove: {
|
|
26
|
+
description: 'Triggered when a file remove icon is clicked. The file is NOT removed automatically — the handler is responsible for updating `fileList` (e.g. via `SetState`).',
|
|
27
|
+
event: {
|
|
28
|
+
file: 'The file whose remove icon was clicked.'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
24
31
|
},
|
|
25
32
|
properties: {
|
|
26
33
|
type: 'object',
|
|
@@ -64,40 +71,12 @@
|
|
|
64
71
|
type: 'string',
|
|
65
72
|
description: 'Id of a request of type AwsS3PresignedGetObject that defines which S3 bucket and file to download.'
|
|
66
73
|
},
|
|
67
|
-
|
|
68
|
-
type: '
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
properties: {
|
|
75
|
-
actionsColor: {
|
|
76
|
-
type: 'string',
|
|
77
|
-
description: 'Color of action icons (download, preview).'
|
|
78
|
-
},
|
|
79
|
-
pictureCardSize: {
|
|
80
|
-
type: 'number',
|
|
81
|
-
description: 'Size of list items in card type (affects both picture-card and picture-circle).'
|
|
82
|
-
},
|
|
83
|
-
controlItemBgHover: {
|
|
84
|
-
type: 'string',
|
|
85
|
-
description: 'Background color of file item on hover.'
|
|
86
|
-
},
|
|
87
|
-
colorIcon: {
|
|
88
|
-
type: 'string',
|
|
89
|
-
description: 'Color of file icons.'
|
|
90
|
-
},
|
|
91
|
-
fontSize: {
|
|
92
|
-
type: 'number',
|
|
93
|
-
description: 'Font size of file name text.'
|
|
94
|
-
},
|
|
95
|
-
borderRadiusSM: {
|
|
96
|
-
type: 'number',
|
|
97
|
-
description: 'Border radius of file list items.'
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
74
|
+
showRemoveIcon: {
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
default: false,
|
|
77
|
+
description: 'Show a remove (×) icon next to each file in the list. Clicking it fires the `onRemove` event; the file is not removed from `fileList` automatically — the action handler is responsible.'
|
|
78
|
+
},
|
|
79
|
+
theme: uploadTheme
|
|
101
80
|
}
|
|
102
81
|
}
|
|
103
82
|
};
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React, { useEffect } from 'react';
|
|
16
|
-
import { withBlockDefaults } from '@lowdefy/block-utils';
|
|
16
|
+
import { cn, withBlockDefaults } from '@lowdefy/block-utils';
|
|
17
17
|
import { Button } from '@lowdefy/blocks-antd/blocks';
|
|
18
18
|
import { Upload } from 'antd';
|
|
19
19
|
import useFileList from '../utils/useFileList.js';
|
|
20
20
|
import getS3Upload from '../utils/getS3Upload.js';
|
|
21
|
+
import withTheme from '../withTheme.js';
|
|
21
22
|
const S3UploadButtonBlock = ({ blockId, classNames = {}, components, events, methods, properties, styles = {}, value })=>{
|
|
22
23
|
const [state, loadFileList, setFileList, removeFile, setValue] = useFileList({
|
|
23
24
|
properties,
|
|
@@ -53,15 +54,26 @@ const S3UploadButtonBlock = ({ blockId, classNames = {}, components, events, met
|
|
|
53
54
|
}, [
|
|
54
55
|
value
|
|
55
56
|
]);
|
|
56
|
-
return /*#__PURE__*/ React.createElement(
|
|
57
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
58
|
+
id: blockId,
|
|
59
|
+
className: cn('lf-s3-upload-button', classNames.element),
|
|
60
|
+
style: styles.element
|
|
61
|
+
}, /*#__PURE__*/ React.createElement(Upload, {
|
|
57
62
|
accept: properties.accept ?? '*',
|
|
58
63
|
beforeUpload: loadFileList,
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
classNames: {
|
|
65
|
+
trigger: classNames.trigger,
|
|
66
|
+
list: classNames.list,
|
|
67
|
+
item: classNames.item
|
|
68
|
+
},
|
|
69
|
+
styles: {
|
|
70
|
+
trigger: styles.trigger,
|
|
71
|
+
list: styles.list,
|
|
72
|
+
item: styles.item
|
|
73
|
+
},
|
|
61
74
|
customRequest: s3UploadRequest,
|
|
62
75
|
disabled: properties.disabled,
|
|
63
76
|
fileList: state.fileList,
|
|
64
|
-
id: blockId,
|
|
65
77
|
maxCount: properties.maxCount,
|
|
66
78
|
multiple: !properties.singleFile,
|
|
67
79
|
onRemove: removeFile,
|
|
@@ -83,6 +95,6 @@ const S3UploadButtonBlock = ({ blockId, classNames = {}, components, events, met
|
|
|
83
95
|
...properties.button
|
|
84
96
|
},
|
|
85
97
|
methods: methods
|
|
86
|
-
}));
|
|
98
|
+
})));
|
|
87
99
|
};
|
|
88
|
-
export default withBlockDefaults(S3UploadButtonBlock);
|
|
100
|
+
export default withBlockDefaults(withTheme('Upload', S3UploadButtonBlock));
|
|
@@ -12,14 +12,18 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
15
|
+
*/ import uploadTheme from '../../schemas/uploadTheme.js';
|
|
16
|
+
export default {
|
|
16
17
|
category: 'input',
|
|
17
18
|
icons: [
|
|
18
19
|
'AiOutlineUpload'
|
|
19
20
|
],
|
|
20
21
|
valueType: 'object',
|
|
21
22
|
cssKeys: {
|
|
22
|
-
element: 'The
|
|
23
|
+
element: 'The outer block wrapper around the upload button and list.',
|
|
24
|
+
trigger: 'The antd upload trigger (.ant-upload-select) that wraps the button.',
|
|
25
|
+
list: 'The uploaded file list container.',
|
|
26
|
+
item: 'Each uploaded file row in the list.'
|
|
23
27
|
},
|
|
24
28
|
events: {
|
|
25
29
|
onBeforeUpload: {
|
|
@@ -139,7 +143,35 @@
|
|
|
139
143
|
},
|
|
140
144
|
s3PostPolicyRequestId: {
|
|
141
145
|
type: 'string',
|
|
142
|
-
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
146
|
+
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.',
|
|
147
|
+
docs: {
|
|
148
|
+
displayType: 'manual',
|
|
149
|
+
block: {
|
|
150
|
+
id: 'block_properties_s3PostPolicyRequestId',
|
|
151
|
+
layout: {
|
|
152
|
+
_global: 'settings_input_layout'
|
|
153
|
+
},
|
|
154
|
+
type: 'Label',
|
|
155
|
+
required: true,
|
|
156
|
+
properties: {
|
|
157
|
+
title: 's3PostPolicyRequestId',
|
|
158
|
+
span: 8,
|
|
159
|
+
align: 'right'
|
|
160
|
+
},
|
|
161
|
+
blocks: [
|
|
162
|
+
{
|
|
163
|
+
id: 'block_properties_s3PostPolicyRequestId_text',
|
|
164
|
+
type: 'Markdown',
|
|
165
|
+
style: {
|
|
166
|
+
color: '#8c8c8c'
|
|
167
|
+
},
|
|
168
|
+
properties: {
|
|
169
|
+
content: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
143
175
|
},
|
|
144
176
|
showUploadList: {
|
|
145
177
|
type: 'boolean',
|
|
@@ -150,7 +182,8 @@
|
|
|
150
182
|
type: 'boolean',
|
|
151
183
|
default: false,
|
|
152
184
|
description: 'Only allow a single file to be uploaded. Only one file can be selected in the prompt.'
|
|
153
|
-
}
|
|
185
|
+
},
|
|
186
|
+
theme: uploadTheme
|
|
154
187
|
}
|
|
155
188
|
}
|
|
156
189
|
};
|
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React, { useEffect } from 'react';
|
|
16
|
-
import { Upload } from 'antd';
|
|
17
|
-
import {
|
|
16
|
+
import { Upload, theme as antdTheme } from 'antd';
|
|
17
|
+
import { cn, renderHtml, withBlockDefaults } from '@lowdefy/block-utils';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
18
19
|
import useFileList from '../utils/useFileList.js';
|
|
19
20
|
import getS3Upload from '../utils/getS3Upload.js';
|
|
20
21
|
import getOnPaste from '../utils/getOnPaste.js';
|
|
22
|
+
import withTheme from '../withTheme.js';
|
|
23
|
+
import './style.module.css';
|
|
21
24
|
const { Dragger } = Upload;
|
|
22
25
|
const S3UploadDragger = ({ blockId, classNames = {}, methods, properties, styles = {}, value })=>{
|
|
23
26
|
const [state, loadFileList, setFileList, removeFile, setValue] = useFileList({
|
|
@@ -61,15 +64,32 @@ const S3UploadDragger = ({ blockId, classNames = {}, methods, properties, styles
|
|
|
61
64
|
}, [
|
|
62
65
|
onPaste
|
|
63
66
|
]);
|
|
67
|
+
const { token } = antdTheme.useToken();
|
|
68
|
+
const height = type.isNone(properties.height) ? token.controlHeight : properties.height;
|
|
64
69
|
return /*#__PURE__*/ React.createElement("div", {
|
|
65
70
|
id: blockId,
|
|
66
|
-
|
|
71
|
+
className: cn('lf-s3-upload-dragger', classNames.element),
|
|
72
|
+
onPaste: onPaste,
|
|
73
|
+
style: {
|
|
74
|
+
'--lf-s3-dragger-height': type.isNumber(height) ? `${height}px` : height,
|
|
75
|
+
...styles.element
|
|
76
|
+
}
|
|
67
77
|
}, /*#__PURE__*/ React.createElement(Dragger, {
|
|
68
78
|
accept: properties.accept ?? '*',
|
|
69
79
|
beforeUpload: loadFileList,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
classNames: {
|
|
81
|
+
trigger: classNames.trigger,
|
|
82
|
+
list: classNames.list,
|
|
83
|
+
item: classNames.item
|
|
84
|
+
},
|
|
85
|
+
styles: {
|
|
86
|
+
root: {
|
|
87
|
+
display: 'block'
|
|
88
|
+
},
|
|
89
|
+
trigger: styles.trigger,
|
|
90
|
+
list: styles.list,
|
|
91
|
+
item: styles.item
|
|
92
|
+
},
|
|
73
93
|
customRequest: s3UploadRequest,
|
|
74
94
|
disabled: properties.disabled,
|
|
75
95
|
fileList: state.fileList,
|
|
@@ -83,11 +103,11 @@ const S3UploadDragger = ({ blockId, classNames = {}, methods, properties, styles
|
|
|
83
103
|
});
|
|
84
104
|
}
|
|
85
105
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
86
|
-
className: classNames.hint,
|
|
106
|
+
className: cn(classNames.hint),
|
|
87
107
|
style: styles.hint
|
|
88
108
|
}, renderHtml({
|
|
89
109
|
html: properties.title ?? 'Click or drag to add a file.',
|
|
90
110
|
methods
|
|
91
111
|
}))));
|
|
92
112
|
};
|
|
93
|
-
export default withBlockDefaults(S3UploadDragger);
|
|
113
|
+
export default withBlockDefaults(withTheme('Upload', S3UploadDragger));
|
|
@@ -12,13 +12,17 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
15
|
+
*/ import uploadTheme from '../../schemas/uploadTheme.js';
|
|
16
|
+
export default {
|
|
16
17
|
category: 'input',
|
|
17
18
|
icons: [],
|
|
18
19
|
valueType: 'object',
|
|
19
20
|
cssKeys: {
|
|
20
|
-
element: 'The
|
|
21
|
-
hint: 'The hint
|
|
21
|
+
element: 'The outer dragger box (height container, background, border, shadow).',
|
|
22
|
+
hint: 'The hint content shown inside the drop area.',
|
|
23
|
+
trigger: 'The antd drag surface (.ant-upload-drag). Target for hover/drag-hover border and background.',
|
|
24
|
+
list: 'The uploaded file list container.',
|
|
25
|
+
item: 'Each uploaded file row in the list.'
|
|
22
26
|
},
|
|
23
27
|
events: {
|
|
24
28
|
onBeforeUpload: {
|
|
@@ -64,8 +68,11 @@
|
|
|
64
68
|
],
|
|
65
69
|
properties: {
|
|
66
70
|
height: {
|
|
67
|
-
type:
|
|
68
|
-
|
|
71
|
+
type: [
|
|
72
|
+
'number',
|
|
73
|
+
'string'
|
|
74
|
+
],
|
|
75
|
+
description: 'Height of the dragger area. A number is applied in pixels; a string is passed through as a CSS length (e.g. "300px", "50vh"). Defaults to the antd `controlHeight` theme token. If `style.element.height` is set, it overrides this.'
|
|
69
76
|
},
|
|
70
77
|
title: {
|
|
71
78
|
type: 'string',
|
|
@@ -85,7 +92,35 @@
|
|
|
85
92
|
},
|
|
86
93
|
s3PostPolicyRequestId: {
|
|
87
94
|
type: 'string',
|
|
88
|
-
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
95
|
+
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.',
|
|
96
|
+
docs: {
|
|
97
|
+
displayType: 'manual',
|
|
98
|
+
block: {
|
|
99
|
+
id: 'block_properties_s3PostPolicyRequestId',
|
|
100
|
+
layout: {
|
|
101
|
+
_global: 'settings_input_layout'
|
|
102
|
+
},
|
|
103
|
+
type: 'Label',
|
|
104
|
+
required: true,
|
|
105
|
+
properties: {
|
|
106
|
+
title: 's3PostPolicyRequestId',
|
|
107
|
+
span: 8,
|
|
108
|
+
align: 'right'
|
|
109
|
+
},
|
|
110
|
+
blocks: [
|
|
111
|
+
{
|
|
112
|
+
id: 'block_properties_s3PostPolicyRequestId_text',
|
|
113
|
+
type: 'Markdown',
|
|
114
|
+
style: {
|
|
115
|
+
color: '#8c8c8c'
|
|
116
|
+
},
|
|
117
|
+
properties: {
|
|
118
|
+
content: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
89
124
|
},
|
|
90
125
|
showUploadList: {
|
|
91
126
|
type: 'boolean',
|
|
@@ -96,7 +131,8 @@
|
|
|
96
131
|
type: 'boolean',
|
|
97
132
|
default: false,
|
|
98
133
|
description: 'Only allow a single file to be uploaded. Only one file can be selected in the prompt.'
|
|
99
|
-
}
|
|
134
|
+
},
|
|
135
|
+
theme: uploadTheme
|
|
100
136
|
}
|
|
101
137
|
}
|
|
102
138
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
@layer components {
|
|
18
|
+
/* Height applies to the drop zone, not the outer wrapper, so the file list
|
|
19
|
+
(rendered as a sibling of `.ant-upload-drag` inside the Dragger root) can
|
|
20
|
+
flow inline below it instead of overflowing a fixed-height container. */
|
|
21
|
+
:global(.lf-s3-upload-dragger .ant-upload-drag) {
|
|
22
|
+
height: var(--lf-s3-dragger-height);
|
|
23
|
+
}
|
|
24
|
+
/* antd v6 applies `padding: token.padding` to `.ant-upload-drag .ant-upload`,
|
|
25
|
+
which overflows the drag area when the wrapper height is small. Scope the
|
|
26
|
+
override to this block and let users add padding via style.hint. */
|
|
27
|
+
:global(.lf-s3-upload-dragger .ant-upload-drag .ant-upload) {
|
|
28
|
+
padding: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React, { useEffect, useState } from 'react';
|
|
16
|
-
import {
|
|
16
|
+
import { cn, renderHtml, withBlockDefaults } from '@lowdefy/block-utils';
|
|
17
17
|
import { Upload } from 'antd';
|
|
18
18
|
import useFileList from '../utils/useFileList.js';
|
|
19
19
|
import getS3Upload from '../utils/getS3Upload.js';
|
|
20
|
+
import withTheme from '../withTheme.js';
|
|
20
21
|
const S3UploadPhoto = ({ blockId, classNames = {}, components: { Icon }, events, methods, properties, styles = {}, value })=>{
|
|
21
22
|
const [state, loadFileList, setFileList, removeFile, setValue] = useFileList({
|
|
22
23
|
properties,
|
|
@@ -54,14 +55,26 @@ const S3UploadPhoto = ({ blockId, classNames = {}, components: { Icon }, events,
|
|
|
54
55
|
}, [
|
|
55
56
|
value
|
|
56
57
|
]);
|
|
57
|
-
return /*#__PURE__*/ React.createElement(
|
|
58
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
59
|
+
id: blockId,
|
|
60
|
+
className: cn('lf-s3-upload-photo', classNames.element),
|
|
61
|
+
style: styles.element
|
|
62
|
+
}, /*#__PURE__*/ React.createElement(Upload, {
|
|
58
63
|
accept: "image/*",
|
|
59
64
|
beforeUpload: loadFileList,
|
|
60
|
-
|
|
65
|
+
classNames: {
|
|
66
|
+
trigger: classNames.trigger,
|
|
67
|
+
list: classNames.list,
|
|
68
|
+
item: classNames.item
|
|
69
|
+
},
|
|
70
|
+
styles: {
|
|
71
|
+
trigger: styles.trigger,
|
|
72
|
+
list: styles.list,
|
|
73
|
+
item: styles.item
|
|
74
|
+
},
|
|
61
75
|
customRequest: s3UploadRequest,
|
|
62
76
|
disabled: properties.disabled,
|
|
63
77
|
fileList: state.fileList,
|
|
64
|
-
id: blockId,
|
|
65
78
|
listType: "picture-card",
|
|
66
79
|
maxCount: properties.maxCount,
|
|
67
80
|
multiple: !properties.singleFile,
|
|
@@ -73,36 +86,22 @@ const S3UploadPhoto = ({ blockId, classNames = {}, components: { Icon }, events,
|
|
|
73
86
|
});
|
|
74
87
|
}
|
|
75
88
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
76
|
-
className:
|
|
77
|
-
|
|
78
|
-
}, loading ? /*#__PURE__*/ React.createElement(Icon, {
|
|
79
|
-
blockId: `${blockId}_icon`,
|
|
80
|
-
classNames: {
|
|
81
|
-
element: classNames.icon
|
|
82
|
-
},
|
|
83
|
-
events: events,
|
|
84
|
-
properties: {
|
|
85
|
-
name: 'AiOutlineLoading',
|
|
86
|
-
size: 24
|
|
87
|
-
},
|
|
88
|
-
styles: {
|
|
89
|
-
element: styles.icon
|
|
90
|
-
}
|
|
91
|
-
}) : /*#__PURE__*/ React.createElement(Icon, {
|
|
89
|
+
className: "lf-s3-upload-photo-content"
|
|
90
|
+
}, /*#__PURE__*/ React.createElement(Icon, {
|
|
92
91
|
blockId: `${blockId}_icon`,
|
|
93
92
|
classNames: {
|
|
94
|
-
element: classNames.icon
|
|
93
|
+
element: cn('lf-s3-upload-photo-icon', classNames.icon)
|
|
95
94
|
},
|
|
96
95
|
events: events,
|
|
97
96
|
properties: {
|
|
98
|
-
name: 'AiOutlineCamera',
|
|
97
|
+
name: loading ? 'AiOutlineLoading' : 'AiOutlineCamera',
|
|
99
98
|
size: 24
|
|
100
99
|
},
|
|
101
100
|
styles: {
|
|
102
101
|
element: styles.icon
|
|
103
102
|
}
|
|
104
103
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
105
|
-
className: classNames.title,
|
|
104
|
+
className: cn('lf-s3-upload-photo-title', classNames.title),
|
|
106
105
|
style: {
|
|
107
106
|
marginTop: 8,
|
|
108
107
|
...styles.title
|
|
@@ -110,6 +109,6 @@ const S3UploadPhoto = ({ blockId, classNames = {}, components: { Icon }, events,
|
|
|
110
109
|
}, renderHtml({
|
|
111
110
|
html: properties.title ?? 'Upload image',
|
|
112
111
|
methods
|
|
113
|
-
}))));
|
|
112
|
+
})))));
|
|
114
113
|
};
|
|
115
|
-
export default withBlockDefaults(S3UploadPhoto);
|
|
114
|
+
export default withBlockDefaults(withTheme('Upload', S3UploadPhoto));
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
15
|
+
*/ import uploadTheme from '../../schemas/uploadTheme.js';
|
|
16
|
+
export default {
|
|
16
17
|
category: 'input',
|
|
17
18
|
icons: [
|
|
18
19
|
'AiOutlineLoading',
|
|
@@ -20,11 +21,20 @@
|
|
|
20
21
|
],
|
|
21
22
|
valueType: 'object',
|
|
22
23
|
cssKeys: {
|
|
23
|
-
element: 'The upload
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
element: 'The outer block wrapper around the upload card and list.',
|
|
25
|
+
trigger: 'The antd upload trigger card (.ant-upload-select) — the dashed upload tile.',
|
|
26
|
+
list: 'The uploaded photos list container.',
|
|
27
|
+
item: 'Each uploaded photo tile in the list.',
|
|
28
|
+
icon: 'The icon shown inside the upload trigger card (camera / loading).',
|
|
29
|
+
title: 'The title text shown below the icon inside the upload trigger card.'
|
|
26
30
|
},
|
|
27
31
|
events: {
|
|
32
|
+
onBeforeUpload: {
|
|
33
|
+
description: 'Triggered before upload starts. If any action throws, the upload is cancelled.',
|
|
34
|
+
event: {
|
|
35
|
+
file: 'The raw File object selected by the user.'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
28
38
|
onChange: 'Triggered when the upload state is changing.',
|
|
29
39
|
onProgress: {
|
|
30
40
|
description: 'Triggered when the upload state is in progress.',
|
|
@@ -76,7 +86,35 @@
|
|
|
76
86
|
},
|
|
77
87
|
s3PostPolicyRequestId: {
|
|
78
88
|
type: 'string',
|
|
79
|
-
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
89
|
+
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.',
|
|
90
|
+
docs: {
|
|
91
|
+
displayType: 'manual',
|
|
92
|
+
block: {
|
|
93
|
+
id: 'block_properties_s3PostPolicyRequestId',
|
|
94
|
+
layout: {
|
|
95
|
+
_global: 'settings_input_layout'
|
|
96
|
+
},
|
|
97
|
+
type: 'Label',
|
|
98
|
+
required: true,
|
|
99
|
+
properties: {
|
|
100
|
+
title: 's3PostPolicyRequestId',
|
|
101
|
+
span: 8,
|
|
102
|
+
align: 'right'
|
|
103
|
+
},
|
|
104
|
+
blocks: [
|
|
105
|
+
{
|
|
106
|
+
id: 'block_properties_s3PostPolicyRequestId_text',
|
|
107
|
+
type: 'Markdown',
|
|
108
|
+
style: {
|
|
109
|
+
color: '#8c8c8c'
|
|
110
|
+
},
|
|
111
|
+
properties: {
|
|
112
|
+
content: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
80
118
|
},
|
|
81
119
|
showUploadList: {
|
|
82
120
|
type: 'boolean',
|
|
@@ -87,7 +125,8 @@
|
|
|
87
125
|
type: 'boolean',
|
|
88
126
|
default: false,
|
|
89
127
|
description: 'Only allow a single file to be uploaded. Only one file can be selected in the prompt.'
|
|
90
|
-
}
|
|
128
|
+
},
|
|
129
|
+
theme: uploadTheme
|
|
91
130
|
}
|
|
92
131
|
}
|
|
93
132
|
};
|
|
@@ -38,7 +38,10 @@ async function AwsS3PresignedPostPolicy({ request, connection }) {
|
|
|
38
38
|
}
|
|
39
39
|
Object.keys(fields).forEach((field)=>{
|
|
40
40
|
if (fields[field]) {
|
|
41
|
-
|
|
41
|
+
// S3 user metadata values must be ASCII. URL-encode x-amz-meta-* values so
|
|
42
|
+
// non-ASCII characters (names, URLs, etc.) survive the round trip. Other
|
|
43
|
+
// protocol fields (acl, Content-Type, ...) must be passed through literally.
|
|
44
|
+
params.Fields[field] = field.toLowerCase().startsWith('x-amz-meta-') ? encodeURIComponent(fields[field]) : fields[field];
|
|
42
45
|
}
|
|
43
46
|
});
|
|
44
47
|
const s3 = new S3Client({
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ // Shared antd Upload component-token schema for S3 blocks wrapped in
|
|
16
|
+
// `withTheme('Upload', …)`. Values are forwarded into a scoped
|
|
17
|
+
// `<ConfigProvider theme={{ components: { Upload: theme } }}>` wrapper.
|
|
18
|
+
// See https://ant.design/components/upload#design-token.
|
|
19
|
+
const uploadTheme = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
description: 'Antd design token overrides for this block. See <a href="https://ant.design/components/upload#design-token">antd design tokens</a>.',
|
|
22
|
+
docs: {
|
|
23
|
+
displayType: 'yaml',
|
|
24
|
+
link: 'https://ant.design/components/upload#design-token'
|
|
25
|
+
},
|
|
26
|
+
properties: {
|
|
27
|
+
actionsColor: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Color of action icons (download, preview, remove).'
|
|
30
|
+
},
|
|
31
|
+
pictureCardSize: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
description: 'Size of list items in card type (affects both picture-card and picture-circle).'
|
|
34
|
+
},
|
|
35
|
+
controlItemBgHover: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Background color of file item on hover.'
|
|
38
|
+
},
|
|
39
|
+
colorIcon: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Color of file icons.'
|
|
42
|
+
},
|
|
43
|
+
fontSize: {
|
|
44
|
+
type: 'number',
|
|
45
|
+
description: 'Font size of file name text.'
|
|
46
|
+
},
|
|
47
|
+
borderRadiusSM: {
|
|
48
|
+
type: 'number',
|
|
49
|
+
description: 'Border radius of file list items.'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export default uploadTheme;
|