@onehat/ui 0.3.133 → 0.3.136
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/package.json +1 -1
- package/src/Components/Form/Field/Tag/Tag.js +1 -1
- package/src/Components/Hoc/Secondary/withSecondarySideEditor.js +1 -1
- package/src/Components/Hoc/withPdfButton.js +1 -1
- package/src/Components/Hoc/withPresetButtons.js +6 -0
- package/src/PlatformImports/Web/Attachments.js +29 -8
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from 'native-base';
|
|
7
7
|
import {
|
|
8
8
|
EDITOR_TYPE__WINDOWED,
|
|
9
|
-
} from '
|
|
9
|
+
} from '../../../../Constants/Editor.js';
|
|
10
10
|
import withAlert from '../../../Hoc/withAlert.js';
|
|
11
11
|
import withComponent from '../../../Hoc/withComponent.js';
|
|
12
12
|
import withData from '../../../Hoc/withData.js';
|
|
@@ -11,7 +11,7 @@ import FormPanel from '../Panel/FormPanel.js';
|
|
|
11
11
|
import inArray from '../../Functions/inArray.js';
|
|
12
12
|
import Pdf from '../Icons/Pdf.js';
|
|
13
13
|
import useAdjustedWindowSize from '../../Hooks/useAdjustedWindowSize.js';
|
|
14
|
-
import { EDITOR_TYPE__PLAIN } from '
|
|
14
|
+
import { EDITOR_TYPE__PLAIN } from '../../Constants/Editor.js';
|
|
15
15
|
import UiGlobals from '../../UiGlobals.js';
|
|
16
16
|
import _ from 'lodash';
|
|
17
17
|
|
|
@@ -54,6 +54,9 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
54
54
|
disableDuplicate = !isEditor,
|
|
55
55
|
disablePrint = !isGrid,
|
|
56
56
|
|
|
57
|
+
// withAlert
|
|
58
|
+
showInfo,
|
|
59
|
+
|
|
57
60
|
// withComponent
|
|
58
61
|
self,
|
|
59
62
|
|
|
@@ -276,6 +279,9 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
276
279
|
|
|
277
280
|
// Send it to clipboard
|
|
278
281
|
navigator?.clipboard.writeText(text);
|
|
282
|
+
if (showInfo) {
|
|
283
|
+
showInfo('Copied to clipboard!');
|
|
284
|
+
}
|
|
279
285
|
};
|
|
280
286
|
// onPrint = () => {
|
|
281
287
|
// debugger;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Column,
|
|
6
6
|
Pressable,
|
|
7
7
|
Row,
|
|
8
|
+
Spinner,
|
|
8
9
|
Text,
|
|
9
10
|
} from 'native-base';
|
|
10
11
|
import {
|
|
@@ -18,8 +19,9 @@ import {
|
|
|
18
19
|
FILE_MODE_FILE,
|
|
19
20
|
} from '../../Constants/File.js';
|
|
20
21
|
import { Avatar, Dropzone, FileMosaic, FileCard, FileInputButton, } from "@files-ui/react";
|
|
21
|
-
import
|
|
22
|
-
import
|
|
22
|
+
import inArray from '../../Functions/inArray.js';
|
|
23
|
+
import IconButton from '../../Components/Buttons/IconButton.js';
|
|
24
|
+
import Xmark from '../../Components/Icons/Xmark.js'
|
|
23
25
|
import withAlert from '../../Components/Hoc/withAlert.js';
|
|
24
26
|
import withData from '../../Components/Hoc/withData.js';
|
|
25
27
|
import _ from 'lodash';
|
|
@@ -49,7 +51,9 @@ function FileCardCustom(props) {
|
|
|
49
51
|
type: mimetype,
|
|
50
52
|
onDelete,
|
|
51
53
|
downloadUrl,
|
|
52
|
-
|
|
54
|
+
uploadStatus,
|
|
55
|
+
} = props,
|
|
56
|
+
isDownloading = uploadStatus && inArray(uploadStatus, ['preparing', 'uploading', 'success']);
|
|
53
57
|
return <Pressable
|
|
54
58
|
px={3}
|
|
55
59
|
py={1}
|
|
@@ -62,8 +66,9 @@ function FileCardCustom(props) {
|
|
|
62
66
|
downloadWithFetch(downloadUrl);
|
|
63
67
|
}}
|
|
64
68
|
>
|
|
69
|
+
{isDownloading && <Spinner mr={2} />}
|
|
65
70
|
<Text>{filename}</Text>
|
|
66
|
-
<IconButton icon={Xmark} onPress={() => onDelete(id)} />
|
|
71
|
+
{onDelete && <IconButton ml={1} icon={Xmark} onPress={() => onDelete(id)} />}
|
|
67
72
|
</Pressable>;
|
|
68
73
|
}
|
|
69
74
|
|
|
@@ -95,6 +100,7 @@ function AttachmentsElement(props) {
|
|
|
95
100
|
Repository,
|
|
96
101
|
|
|
97
102
|
// withAlert
|
|
103
|
+
alert,
|
|
98
104
|
confirm,
|
|
99
105
|
|
|
100
106
|
} = props,
|
|
@@ -136,6 +142,10 @@ function AttachmentsElement(props) {
|
|
|
136
142
|
setShowAll(!showAll);
|
|
137
143
|
},
|
|
138
144
|
onDropzoneChange = (files) => {
|
|
145
|
+
if (!files.length) {
|
|
146
|
+
alert('No files accepted. Perhaps they were too large or the wrong file type?');
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
139
149
|
setFiles(files);
|
|
140
150
|
_.each(files, (file) => {
|
|
141
151
|
file.extraUploadData = {
|
|
@@ -148,7 +158,8 @@ function AttachmentsElement(props) {
|
|
|
148
158
|
setIsUploading(true);
|
|
149
159
|
},
|
|
150
160
|
onUploadFinish = (files) => {
|
|
151
|
-
let isDoneUploading = true
|
|
161
|
+
let isDoneUploading = true,
|
|
162
|
+
isError = false;
|
|
152
163
|
|
|
153
164
|
_.each(files, (file) => {
|
|
154
165
|
if (!file.xhr || file.xhr.status !== 200) {
|
|
@@ -158,8 +169,18 @@ function AttachmentsElement(props) {
|
|
|
158
169
|
});
|
|
159
170
|
|
|
160
171
|
if (isDoneUploading) {
|
|
161
|
-
|
|
162
|
-
|
|
172
|
+
_.each(files, (file) => {
|
|
173
|
+
if (file.uploadStatus === 'error') {
|
|
174
|
+
isError = true;
|
|
175
|
+
const msg = file.serverResponse?.payload || 'An error occurred';
|
|
176
|
+
alert(msg);
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
if (!isError) {
|
|
181
|
+
setIsUploading(false);
|
|
182
|
+
Repository.reload();
|
|
183
|
+
}
|
|
163
184
|
}
|
|
164
185
|
},
|
|
165
186
|
onFileDelete = (id) => {
|
|
@@ -278,7 +299,7 @@ function AttachmentsElement(props) {
|
|
|
278
299
|
{Repository.total <= COLLAPSED_MAX ? null :
|
|
279
300
|
<Button
|
|
280
301
|
onPress={toggleShowAll}
|
|
281
|
-
|
|
302
|
+
mt={4}
|
|
282
303
|
_text={{
|
|
283
304
|
color: 'trueGray.600',
|
|
284
305
|
fontStyle: 'italic',
|