@itcase/forms 1.0.69 → 1.0.71
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/css/form/Field/FileInput/FileInput.css +14 -16
- package/dist/itcase-forms.cjs.js +50 -34
- package/dist/itcase-forms.esm.js +50 -34
- package/package.json +30 -30
|
@@ -6,27 +6,26 @@
|
|
|
6
6
|
z-index: 1;
|
|
7
7
|
outline: 0;
|
|
8
8
|
@mixin easing easeOutQuart, all, 0.2s;
|
|
9
|
-
&-wrapper {
|
|
10
|
-
display: grid;
|
|
11
|
-
gap: 16px;
|
|
12
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
13
|
-
}
|
|
14
9
|
&_size {
|
|
15
10
|
@each $size in normal, compact {
|
|
16
11
|
&_$(size) {
|
|
17
12
|
^^&-wrapper {
|
|
18
|
-
padding: var(--fileinput-size-$(size)-padding)
|
|
13
|
+
padding: var(--fileinput-size-$(size)-padding);
|
|
19
14
|
}
|
|
20
15
|
}
|
|
21
16
|
}
|
|
22
17
|
}
|
|
18
|
+
&-wrapper {
|
|
19
|
+
display: grid;
|
|
20
|
+
gap: 16px;
|
|
21
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
22
|
+
}
|
|
23
23
|
^&__hint {
|
|
24
24
|
width: 100%;
|
|
25
25
|
min-height: 120px;
|
|
26
26
|
display: flex;
|
|
27
27
|
flex-flow: column nowrap;
|
|
28
|
-
|
|
29
|
-
align-content: center;
|
|
28
|
+
place-content: center center;
|
|
30
29
|
align-items: center;
|
|
31
30
|
cursor: pointer;
|
|
32
31
|
&-title {
|
|
@@ -70,25 +69,24 @@
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
&-loader {
|
|
73
|
-
position: absolute;
|
|
74
|
-
left: 0;
|
|
75
|
-
top: 0;
|
|
76
72
|
width: 100%;
|
|
77
73
|
height: 100%;
|
|
74
|
+
position: absolute;
|
|
78
75
|
display: flex;
|
|
76
|
+
left: 0;
|
|
77
|
+
top: 0;
|
|
79
78
|
}
|
|
80
79
|
&-image {
|
|
81
|
-
grid-column-start: 1;
|
|
82
|
-
grid-row-start: span 2;
|
|
83
|
-
display: flex;
|
|
84
80
|
position: relative;
|
|
85
81
|
overflow: hidden;
|
|
82
|
+
display: flex;
|
|
86
83
|
justify-content: center;
|
|
87
84
|
align-items: center;
|
|
85
|
+
grid-column-start: 1;
|
|
86
|
+
grid-row-start: span 2;
|
|
88
87
|
&-inner {
|
|
89
|
-
max-width: 100%;
|
|
90
88
|
height: auto;
|
|
91
|
-
|
|
89
|
+
max-width: 100%;
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
&-name {
|
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -956,12 +956,21 @@ const FileInputDropzone = /*#__PURE__*/React__default.default.memo(function File
|
|
|
956
956
|
[dropzoneProps, change]);
|
|
957
957
|
|
|
958
958
|
//
|
|
959
|
-
const convertFiledValueAndSaveAsFiles = React.useCallback(async
|
|
959
|
+
const convertFiledValueAndSaveAsFiles = React.useCallback(async currentFilesList => {
|
|
960
960
|
setFileIsLoading(true);
|
|
961
|
-
const newFiles =
|
|
961
|
+
const newFiles = [];
|
|
962
|
+
for (const fileItem of currentFilesList) {
|
|
963
|
+
if (typeof fileItem === 'string') {
|
|
964
|
+
const newFile = await convertToFile(fileItem, isPreviews);
|
|
965
|
+
if (newFile) {
|
|
966
|
+
newFiles.push(newFile);
|
|
967
|
+
}
|
|
968
|
+
} else {
|
|
969
|
+
newFiles.push(fileItem);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
962
972
|
changeFormState(newFiles);
|
|
963
973
|
setFileIsLoading(false);
|
|
964
|
-
return newFiles;
|
|
965
974
|
}, [isPreviews, changeFormState]);
|
|
966
975
|
|
|
967
976
|
// Delete file from dropzone
|
|
@@ -1041,12 +1050,23 @@ const FileInputDropzone = /*#__PURE__*/React__default.default.memo(function File
|
|
|
1041
1050
|
}
|
|
1042
1051
|
});
|
|
1043
1052
|
React.useEffect(() => {
|
|
1044
|
-
|
|
1045
|
-
|
|
1053
|
+
const currentFilesList = castArray__default.default(inputValue);
|
|
1054
|
+
const isNeedToConvert = currentFilesList.some(fileItem => typeof fileItem === 'string');
|
|
1055
|
+
if (isNeedToConvert) {
|
|
1056
|
+
// First time convert value to Files and save to local and form state
|
|
1057
|
+
convertFiledValueAndSaveAsFiles(currentFilesList);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1046
1060
|
// Make sure to revoke the data uris to avoid memory leaks, will run on unmount
|
|
1047
|
-
return () =>
|
|
1061
|
+
return () => {
|
|
1062
|
+
filesList.forEach(file => {
|
|
1063
|
+
if (file?.preview) {
|
|
1064
|
+
URL.revokeObjectURL(file.preview);
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
};
|
|
1048
1068
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1049
|
-
}, []);
|
|
1069
|
+
}, [inputValue]);
|
|
1050
1070
|
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1051
1071
|
prefix: 'fill_',
|
|
1052
1072
|
propsKey: 'fill'
|
|
@@ -1197,8 +1217,8 @@ FileInputDropzone.propTypes = {
|
|
|
1197
1217
|
async function getFileByURL(url) {
|
|
1198
1218
|
try {
|
|
1199
1219
|
const response = await axios__default.default({
|
|
1200
|
-
|
|
1201
|
-
|
|
1220
|
+
responseType: 'blob',
|
|
1221
|
+
url: url
|
|
1202
1222
|
});
|
|
1203
1223
|
const blobObject = response.data;
|
|
1204
1224
|
const dirtyFilename = response.headers['content-disposition']?.split('filename=')[1];
|
|
@@ -1218,36 +1238,32 @@ async function getFileByURL(url) {
|
|
|
1218
1238
|
return null;
|
|
1219
1239
|
}
|
|
1220
1240
|
}
|
|
1221
|
-
async function
|
|
1222
|
-
|
|
1223
|
-
for (const value of castArray__default.default(inputValue)) {
|
|
1224
|
-
let newFile = null;
|
|
1225
|
-
|
|
1226
|
-
// Download image by url and save as File instance
|
|
1227
|
-
const isURL = typeof value === 'string' && value.includes('/');
|
|
1228
|
-
if (value.image || isURL) {
|
|
1229
|
-
newFile = await getFileByURL(value.image || value);
|
|
1230
|
-
if (newFile) {
|
|
1231
|
-
setFileDataURL(newFile);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1241
|
+
async function convertToFile(inputValue, isPreviews) {
|
|
1242
|
+
let newFile = null;
|
|
1234
1243
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1244
|
+
// Download image by url and save as File instance
|
|
1245
|
+
const isURL = typeof inputValue === 'string' && inputValue.includes('/');
|
|
1246
|
+
if (inputValue.image || isURL) {
|
|
1247
|
+
newFile = await getFileByURL(inputValue.image || inputValue);
|
|
1248
|
+
if (newFile) {
|
|
1249
|
+
setFileDataURL(newFile);
|
|
1239
1250
|
}
|
|
1251
|
+
}
|
|
1240
1252
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1253
|
+
// Convert dataURL to File instance
|
|
1254
|
+
if (inputValue.dataURL) {
|
|
1255
|
+
newFile = common.createFileFromDataURL(inputValue.name || inputValue.path, inputValue.dataURL);
|
|
1256
|
+
newFile.dataURL = inputValue.dataURL;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// Save new File to state
|
|
1260
|
+
if (newFile) {
|
|
1261
|
+
newFile.id = inputValue.id;
|
|
1262
|
+
if (isPreviews) {
|
|
1263
|
+
newFile.preview = URL.createObjectURL(newFile);
|
|
1248
1264
|
}
|
|
1249
1265
|
}
|
|
1250
|
-
return
|
|
1266
|
+
return newFile;
|
|
1251
1267
|
}
|
|
1252
1268
|
function setFileDataURL(file, resolve) {
|
|
1253
1269
|
resolve = resolve || (() => {});
|
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -942,12 +942,21 @@ const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(pro
|
|
|
942
942
|
[dropzoneProps, change]);
|
|
943
943
|
|
|
944
944
|
//
|
|
945
|
-
const convertFiledValueAndSaveAsFiles = useCallback(async
|
|
945
|
+
const convertFiledValueAndSaveAsFiles = useCallback(async currentFilesList => {
|
|
946
946
|
setFileIsLoading(true);
|
|
947
|
-
const newFiles =
|
|
947
|
+
const newFiles = [];
|
|
948
|
+
for (const fileItem of currentFilesList) {
|
|
949
|
+
if (typeof fileItem === 'string') {
|
|
950
|
+
const newFile = await convertToFile(fileItem, isPreviews);
|
|
951
|
+
if (newFile) {
|
|
952
|
+
newFiles.push(newFile);
|
|
953
|
+
}
|
|
954
|
+
} else {
|
|
955
|
+
newFiles.push(fileItem);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
948
958
|
changeFormState(newFiles);
|
|
949
959
|
setFileIsLoading(false);
|
|
950
|
-
return newFiles;
|
|
951
960
|
}, [isPreviews, changeFormState]);
|
|
952
961
|
|
|
953
962
|
// Delete file from dropzone
|
|
@@ -1027,12 +1036,23 @@ const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(pro
|
|
|
1027
1036
|
}
|
|
1028
1037
|
});
|
|
1029
1038
|
useEffect(() => {
|
|
1030
|
-
|
|
1031
|
-
|
|
1039
|
+
const currentFilesList = castArray(inputValue);
|
|
1040
|
+
const isNeedToConvert = currentFilesList.some(fileItem => typeof fileItem === 'string');
|
|
1041
|
+
if (isNeedToConvert) {
|
|
1042
|
+
// First time convert value to Files and save to local and form state
|
|
1043
|
+
convertFiledValueAndSaveAsFiles(currentFilesList);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1032
1046
|
// Make sure to revoke the data uris to avoid memory leaks, will run on unmount
|
|
1033
|
-
return () =>
|
|
1047
|
+
return () => {
|
|
1048
|
+
filesList.forEach(file => {
|
|
1049
|
+
if (file?.preview) {
|
|
1050
|
+
URL.revokeObjectURL(file.preview);
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
};
|
|
1034
1054
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1035
|
-
}, []);
|
|
1055
|
+
}, [inputValue]);
|
|
1036
1056
|
const fillClass = useDeviceTargetClass(props, {
|
|
1037
1057
|
prefix: 'fill_',
|
|
1038
1058
|
propsKey: 'fill'
|
|
@@ -1183,8 +1203,8 @@ FileInputDropzone.propTypes = {
|
|
|
1183
1203
|
async function getFileByURL(url) {
|
|
1184
1204
|
try {
|
|
1185
1205
|
const response = await axios({
|
|
1186
|
-
|
|
1187
|
-
|
|
1206
|
+
responseType: 'blob',
|
|
1207
|
+
url: url
|
|
1188
1208
|
});
|
|
1189
1209
|
const blobObject = response.data;
|
|
1190
1210
|
const dirtyFilename = response.headers['content-disposition']?.split('filename=')[1];
|
|
@@ -1204,36 +1224,32 @@ async function getFileByURL(url) {
|
|
|
1204
1224
|
return null;
|
|
1205
1225
|
}
|
|
1206
1226
|
}
|
|
1207
|
-
async function
|
|
1208
|
-
|
|
1209
|
-
for (const value of castArray(inputValue)) {
|
|
1210
|
-
let newFile = null;
|
|
1211
|
-
|
|
1212
|
-
// Download image by url and save as File instance
|
|
1213
|
-
const isURL = typeof value === 'string' && value.includes('/');
|
|
1214
|
-
if (value.image || isURL) {
|
|
1215
|
-
newFile = await getFileByURL(value.image || value);
|
|
1216
|
-
if (newFile) {
|
|
1217
|
-
setFileDataURL(newFile);
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1227
|
+
async function convertToFile(inputValue, isPreviews) {
|
|
1228
|
+
let newFile = null;
|
|
1220
1229
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1230
|
+
// Download image by url and save as File instance
|
|
1231
|
+
const isURL = typeof inputValue === 'string' && inputValue.includes('/');
|
|
1232
|
+
if (inputValue.image || isURL) {
|
|
1233
|
+
newFile = await getFileByURL(inputValue.image || inputValue);
|
|
1234
|
+
if (newFile) {
|
|
1235
|
+
setFileDataURL(newFile);
|
|
1225
1236
|
}
|
|
1237
|
+
}
|
|
1226
1238
|
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1239
|
+
// Convert dataURL to File instance
|
|
1240
|
+
if (inputValue.dataURL) {
|
|
1241
|
+
newFile = createFileFromDataURL(inputValue.name || inputValue.path, inputValue.dataURL);
|
|
1242
|
+
newFile.dataURL = inputValue.dataURL;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// Save new File to state
|
|
1246
|
+
if (newFile) {
|
|
1247
|
+
newFile.id = inputValue.id;
|
|
1248
|
+
if (isPreviews) {
|
|
1249
|
+
newFile.preview = URL.createObjectURL(newFile);
|
|
1234
1250
|
}
|
|
1235
1251
|
}
|
|
1236
|
-
return
|
|
1252
|
+
return newFile;
|
|
1237
1253
|
}
|
|
1238
1254
|
function setFileDataURL(file, resolve) {
|
|
1239
1255
|
resolve = resolve || (() => {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/forms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.71",
|
|
4
4
|
"description": "Forms fields, inputs, etc.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,65 +30,65 @@
|
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@itcase/common": "^1.2.
|
|
34
|
-
"@itcase/ui": "^1.2.
|
|
33
|
+
"@itcase/common": "^1.2.15",
|
|
34
|
+
"@itcase/ui": "^1.2.21",
|
|
35
35
|
"axios": "^1.7.7",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"final-form": "^4.20.10",
|
|
38
38
|
"final-form-focus": "^1.1.2",
|
|
39
|
-
"libphonenumber-js": "^1.11.
|
|
39
|
+
"libphonenumber-js": "^1.11.12",
|
|
40
40
|
"lodash": "^4.17.21",
|
|
41
41
|
"luxon": "^3.5.0",
|
|
42
|
-
"postcss": "^8.4.
|
|
42
|
+
"postcss": "^8.4.47",
|
|
43
43
|
"prop-types": "^15.8.1",
|
|
44
44
|
"react": "^18.3.1",
|
|
45
45
|
"react-date-range": "^2.0.1",
|
|
46
|
-
"react-datepicker": "^7.
|
|
46
|
+
"react-datepicker": "^7.5.0",
|
|
47
47
|
"react-dom": "^18.3.1",
|
|
48
|
-
"react-dropzone": "^14.2.
|
|
48
|
+
"react-dropzone": "^14.2.10",
|
|
49
49
|
"react-final-form": "^6.5.9",
|
|
50
50
|
"react-imask": "^7.6.1",
|
|
51
|
-
"react-select": "^5.8.
|
|
51
|
+
"react-select": "^5.8.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@itcase/lint": "^1.0.
|
|
55
|
-
"@babel/core": "^7.25.
|
|
56
|
-
"@babel/eslint-parser": "^7.25.
|
|
57
|
-
"@babel/preset-env": "^7.25.
|
|
58
|
-
"@babel/preset-react": "^7.
|
|
54
|
+
"@itcase/lint": "^1.0.14",
|
|
55
|
+
"@babel/core": "^7.25.9",
|
|
56
|
+
"@babel/eslint-parser": "^7.25.9",
|
|
57
|
+
"@babel/preset-env": "^7.25.9",
|
|
58
|
+
"@babel/preset-react": "^7.25.9",
|
|
59
59
|
"@commitlint/cli": "^19.5.0",
|
|
60
60
|
"@commitlint/config-conventional": "^19.5.0",
|
|
61
|
-
"@eslint/compat": "^1.
|
|
61
|
+
"@eslint/compat": "^1.2.1",
|
|
62
62
|
"@eslint/eslintrc": "^3.1.0",
|
|
63
63
|
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
|
|
64
64
|
"@rollup/plugin-babel": "^6.0.4",
|
|
65
|
-
"@rollup/plugin-commonjs": "^
|
|
65
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
66
66
|
"@rollup/plugin-json": "^6.1.0",
|
|
67
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
67
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
68
68
|
"@rollup/plugin-terser": "^0.4.4",
|
|
69
69
|
"@semantic-release/changelog": "^6.0.3",
|
|
70
70
|
"@semantic-release/git": "^10.0.1",
|
|
71
71
|
"@semantic-release/release-notes-generator": "14.0.1",
|
|
72
72
|
"@types/react": "^18",
|
|
73
|
-
"@types/react-dom": "^18.3.
|
|
73
|
+
"@types/react-dom": "^18.3.1",
|
|
74
74
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
75
75
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
76
76
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
77
|
-
"eslint": "9.
|
|
77
|
+
"eslint": "9.13.0",
|
|
78
78
|
"eslint-config-prettier": "9.1.0",
|
|
79
79
|
"eslint-config-standard": "17.1.0",
|
|
80
80
|
"eslint-plugin-babel": "5.3.1",
|
|
81
|
-
"eslint-plugin-import": "2.
|
|
82
|
-
"eslint-plugin-n": "17.
|
|
81
|
+
"eslint-plugin-import": "2.31.0",
|
|
82
|
+
"eslint-plugin-n": "17.11.1",
|
|
83
83
|
"eslint-plugin-node": "11.1.0",
|
|
84
84
|
"eslint-plugin-prettier": "5.2.1",
|
|
85
85
|
"eslint-plugin-promise": "7.1.0",
|
|
86
|
-
"eslint-plugin-react": "7.
|
|
87
|
-
"eslint-plugin-react-hooks": "
|
|
86
|
+
"eslint-plugin-react": "7.37.2",
|
|
87
|
+
"eslint-plugin-react-hooks": "5.0.0",
|
|
88
88
|
"eslint-plugin-standard": "5.0.0",
|
|
89
89
|
"husky": "^9.1.6",
|
|
90
90
|
"lint-staged": "^15.2.10",
|
|
91
|
-
"npm": "^10.
|
|
91
|
+
"npm": "^10.9.0",
|
|
92
92
|
"postcss-aspect-ratio-polyfill": "^2.0.0",
|
|
93
93
|
"postcss-cli": "^11.0.0",
|
|
94
94
|
"postcss-combine-duplicated-selectors": "^10.0.3",
|
|
@@ -101,23 +101,23 @@
|
|
|
101
101
|
"postcss-hexrgba": "^2.1.0",
|
|
102
102
|
"postcss-import": "^16.1.0",
|
|
103
103
|
"postcss-import-ext-glob": "^2.1.1",
|
|
104
|
-
"postcss-mixins": "^11.0.
|
|
104
|
+
"postcss-mixins": "^11.0.3",
|
|
105
105
|
"postcss-nested": "^6.2.0",
|
|
106
106
|
"postcss-nested-ancestors": "^3.0.0",
|
|
107
|
-
"postcss-normalize": "^13.0.
|
|
107
|
+
"postcss-normalize": "^13.0.1",
|
|
108
108
|
"postcss-prepend-imports": "^1.0.1",
|
|
109
|
-
"postcss-preset-env": "^10.0.
|
|
109
|
+
"postcss-preset-env": "^10.0.8",
|
|
110
110
|
"postcss-pxtorem": "^6.1.0",
|
|
111
111
|
"postcss-responsive-type": "github:ITCase/postcss-responsive-type",
|
|
112
112
|
"postcss-sort-media-queries": "^5.2.0",
|
|
113
113
|
"prettier": "3.3.3",
|
|
114
|
-
"rollup": "^4.
|
|
114
|
+
"rollup": "^4.24.0",
|
|
115
115
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
116
|
-
"semantic-release": "^24.1.
|
|
117
|
-
"stylelint": "^16.
|
|
116
|
+
"semantic-release": "^24.1.3",
|
|
117
|
+
"stylelint": "^16.10.0",
|
|
118
118
|
"stylelint-config-standard": "^36.0.1",
|
|
119
119
|
"stylelint-no-unsupported-browser-features": "^8.0.1",
|
|
120
120
|
"stylelint-order": "^6.0.4",
|
|
121
|
-
"typescript": "^5.6.
|
|
121
|
+
"typescript": "^5.6.3"
|
|
122
122
|
}
|
|
123
123
|
}
|