@uxf/ui 1.0.0-beta.136 → 1.0.0-beta.138
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/css/checkbox-button.css +2 -2
- package/css/checkbox-input.css +1 -1
- package/css/checkbox.css +4 -4
- package/css/dropzone.css +3 -3
- package/css/error-message.css +1 -1
- package/css/form-control.css +1 -1
- package/css/radio.css +4 -4
- package/dropzone/dropzone-input.d.ts +1 -1
- package/dropzone/dropzone-input.js +1 -1
- package/dropzone/dropzone-list.d.ts +1 -1
- package/dropzone/dropzone-list.js +5 -4
- package/package.json +1 -1
- package/utils/mocks/uploadFIle.mock.js +11 -8
package/css/checkbox-button.css
CHANGED
package/css/checkbox-input.css
CHANGED
package/css/checkbox.css
CHANGED
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
&.is-invalid {
|
|
70
|
-
@apply border-
|
|
70
|
+
@apply border-error-500;
|
|
71
71
|
|
|
72
72
|
&.is-selected {
|
|
73
|
-
@apply bg-
|
|
73
|
+
@apply bg-error-500;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
.uxf-checkbox__inner {
|
|
@@ -109,10 +109,10 @@
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
&.is-invalid {
|
|
112
|
-
@apply border-
|
|
112
|
+
@apply border-error-500;
|
|
113
113
|
|
|
114
114
|
&.is-selected {
|
|
115
|
-
@apply bg-
|
|
115
|
+
@apply bg-error-500;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
.uxf-checkbox__inner {
|
package/css/dropzone.css
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
&.is-invalid {
|
|
17
|
-
@apply border-error-
|
|
17
|
+
@apply border-error-500;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
&.is-disabled {
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
|
|
45
45
|
&.is-invalid {
|
|
46
46
|
:root .light & {
|
|
47
|
-
@apply border-error-
|
|
47
|
+
@apply border-error-500 text-error-500;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
:root .dark & {
|
|
51
|
-
@apply border-error-
|
|
51
|
+
@apply border-error-500 text-error-500;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
package/css/error-message.css
CHANGED
package/css/form-control.css
CHANGED
package/css/radio.css
CHANGED
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
&.is-invalid {
|
|
54
|
-
@apply border-
|
|
54
|
+
@apply border-error-500;
|
|
55
55
|
|
|
56
56
|
&.is-selected {
|
|
57
|
-
@apply bg-
|
|
57
|
+
@apply bg-error-500;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
.uxf-radio__inner {
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
&.is-invalid {
|
|
90
|
-
@apply border-
|
|
90
|
+
@apply border-error-500;
|
|
91
91
|
|
|
92
92
|
&.is-selected {
|
|
93
|
-
@apply bg-
|
|
93
|
+
@apply bg-error-500;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
.uxf-radio__inner {
|
|
@@ -2,7 +2,7 @@ import { FileResponse, FormControlProps, UploadOptions } from "@uxf/ui/types";
|
|
|
2
2
|
import React, { ReactNode } from "react";
|
|
3
3
|
import { IconName } from "../icon/types";
|
|
4
4
|
import { Accept, DropzoneFile } from "./types";
|
|
5
|
-
export interface DropzoneInputProps extends FormControlProps<DropzoneFile[]> {
|
|
5
|
+
export interface DropzoneInputProps extends FormControlProps<DropzoneFile[] | undefined> {
|
|
6
6
|
accept?: Accept;
|
|
7
7
|
helperText?: ReactNode;
|
|
8
8
|
icon?: IconName;
|
|
@@ -73,7 +73,7 @@ exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
73
73
|
originalFile: file,
|
|
74
74
|
progress: 0,
|
|
75
75
|
}));
|
|
76
|
-
props.onChange([...props.value, ...files]);
|
|
76
|
+
props.onChange(props.value ? [...props.value, ...files] : files);
|
|
77
77
|
for (const file of files) {
|
|
78
78
|
if (!file.originalFile) {
|
|
79
79
|
file.error = "File not found";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormControlProps } from "@uxf/ui/types";
|
|
2
2
|
import { FC, ReactNode } from "react";
|
|
3
3
|
import { DropzoneFile } from "./types";
|
|
4
|
-
export interface DropzoneListProps extends FormControlProps<DropzoneFile[]> {
|
|
4
|
+
export interface DropzoneListProps extends FormControlProps<DropzoneFile[] | undefined> {
|
|
5
5
|
errorText?: string;
|
|
6
6
|
onAbortWarning?: string;
|
|
7
7
|
onRemoveWarning?: string;
|
|
@@ -54,24 +54,25 @@ function getIconName(extension) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
const DropzoneList = (props) => {
|
|
57
|
+
var _a, _b;
|
|
57
58
|
const context = (0, react_1.useContext)(context_1.UiContext);
|
|
58
59
|
const onRemove = (file, isUploading) => () => {
|
|
59
60
|
var _a;
|
|
60
61
|
// eslint-disable-next-line no-alert
|
|
61
|
-
if (isUploading && confirm(props.onAbortWarning || "Do you want to abort the file?")) {
|
|
62
|
+
if (props.value && isUploading && confirm(props.onAbortWarning || "Do you want to abort the file?")) {
|
|
62
63
|
(_a = file.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
63
64
|
props.onChange(props.value.filter((f) => f.id !== file.id));
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
// eslint-disable-next-line no-alert
|
|
67
|
-
if (!isUploading && confirm(props.onRemoveWarning || "Do you want to delete the file?")) {
|
|
68
|
+
if (props.value && !isUploading && confirm(props.onRemoveWarning || "Do you want to delete the file?")) {
|
|
68
69
|
props.onChange(props.value.filter((f) => f.id !== file.id));
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
|
-
if (props.value.length === 0) {
|
|
72
|
+
if (((_a = props.value) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
74
|
-
return (react_1.default.createElement("ul", { className: "uxf-dropzone-list" }, props.value.map((file) => {
|
|
75
|
+
return (react_1.default.createElement("ul", { className: "uxf-dropzone-list" }, (_b = props.value) === null || _b === void 0 ? void 0 : _b.map((file) => {
|
|
75
76
|
var _a, _b, _c;
|
|
76
77
|
const isUploading = file.id < 0 && !file.error;
|
|
77
78
|
return ((_b = (_a = props.renderItem) === null || _a === void 0 ? void 0 : _a.call(props, file)) !== null && _b !== void 0 ? _b : (react_1.default.createElement("li", { className: "uxf-dropzone-list__item-wrapper", key: file.id },
|
package/package.json
CHANGED
|
@@ -16,18 +16,11 @@ function uploadFile(file, uploadOptions) {
|
|
|
16
16
|
const time = file.size / 10;
|
|
17
17
|
const interval = time / 10;
|
|
18
18
|
let loaded = 0;
|
|
19
|
-
const timeoutTimer = window.setTimeout(() => {
|
|
20
|
-
resolve({
|
|
21
|
-
id: Math.round(Math.random() * 100000000),
|
|
22
|
-
uuid: getRandomUuid(),
|
|
23
|
-
name: file.name,
|
|
24
|
-
extension: file.name.split(".").slice(-1).join(""),
|
|
25
|
-
});
|
|
26
|
-
}, time);
|
|
27
19
|
const intervalTimer = window.setInterval(() => {
|
|
28
20
|
var _a, _b;
|
|
29
21
|
if ((_a = uploadOptions === null || uploadOptions === void 0 ? void 0 : uploadOptions.abortController) === null || _a === void 0 ? void 0 : _a.signal.aborted) {
|
|
30
22
|
clearInterval(intervalTimer);
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
31
24
|
clearTimeout(timeoutTimer);
|
|
32
25
|
return;
|
|
33
26
|
}
|
|
@@ -38,6 +31,16 @@ function uploadFile(file, uploadOptions) {
|
|
|
38
31
|
total: file.size,
|
|
39
32
|
});
|
|
40
33
|
}, interval);
|
|
34
|
+
const timeoutTimer = window.setTimeout(() => {
|
|
35
|
+
clearInterval(intervalTimer);
|
|
36
|
+
clearTimeout(timeoutTimer);
|
|
37
|
+
resolve({
|
|
38
|
+
id: Math.round(Math.random() * 100000000),
|
|
39
|
+
uuid: getRandomUuid(),
|
|
40
|
+
name: file.name,
|
|
41
|
+
extension: file.name.split(".").slice(-1).join(""),
|
|
42
|
+
});
|
|
43
|
+
}, time);
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
exports.uploadFile = uploadFile;
|