diginet-core-ui 1.3.96 → 1.3.97
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/components/form-control/attachment/index.js +54 -47
- package/components/form-control/dropdown/index.js +395 -335
- package/components/popover/index.js +32 -32
- package/global/index.js +19 -2
- package/icons/basic.js +28 -0
- package/package.json +1 -1
- package/readme.md +5 -0
|
@@ -48,7 +48,7 @@ const icons = {
|
|
|
48
48
|
};
|
|
49
49
|
const oldAttached = [];
|
|
50
50
|
const allNewAttached = new FormData();
|
|
51
|
-
const attached = [];
|
|
51
|
+
const attached = []; // attached = [...dataState, ...newDataState]
|
|
52
52
|
const chosenItems = [];
|
|
53
53
|
const getType = data => {
|
|
54
54
|
if (data.type !== undefined) {
|
|
@@ -155,10 +155,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
155
155
|
const [showModal, setShowModal] = useState(false);
|
|
156
156
|
const [showPopup, setShowPopup] = useState(false);
|
|
157
157
|
const [viewTypeState, setViewTypeState] = useState(viewType);
|
|
158
|
-
const [isEmpty, setIsEmpty] = useState(null);
|
|
159
158
|
const [newDataState, setNewDataState] = useState([]);
|
|
160
159
|
const [dataState, setDataState] = useState([]);
|
|
161
160
|
const isEnable = !readOnly && !disabled;
|
|
161
|
+
const isEmpty = !((dataState === null || dataState === void 0 ? void 0 : dataState.length) + (newDataState === null || newDataState === void 0 ? void 0 : newDataState.length));
|
|
162
162
|
const _AttachmentRootCSS = AttachmentRootCSS(isEmpty, isEnable);
|
|
163
163
|
|
|
164
164
|
// Start handler
|
|
@@ -222,9 +222,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
222
222
|
attachedRef.current.appendChild(el);
|
|
223
223
|
});
|
|
224
224
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
|
|
226
|
+
// const afterChangeFile = (length = 0) => {
|
|
227
|
+
// setIsEmpty(!length);
|
|
228
|
+
// };
|
|
229
|
+
|
|
228
230
|
const onChangeFiles = async e => {
|
|
229
231
|
var _e$target, _e$target$files;
|
|
230
232
|
if (!isEnable) return;
|
|
@@ -253,10 +255,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
253
255
|
}
|
|
254
256
|
const length = files.length;
|
|
255
257
|
if (!lengthAttached && !length) {
|
|
256
|
-
afterChangeFile();
|
|
258
|
+
// afterChangeFile();
|
|
257
259
|
return;
|
|
258
260
|
}
|
|
259
|
-
afterChangeFile(lengthAttached + length);
|
|
261
|
+
// afterChangeFile(lengthAttached + length);
|
|
260
262
|
if (multiple || inputProps && inputProps.multiple) {
|
|
261
263
|
for (let i = 0; i < length; i++) {
|
|
262
264
|
files[i].FileName = files[i].name;
|
|
@@ -281,10 +283,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
281
283
|
newAttached: files,
|
|
282
284
|
allNewAttached: allNewAttached.getAll('files')
|
|
283
285
|
});
|
|
284
|
-
} else if (!attached.length) {
|
|
285
|
-
afterChangeFile();
|
|
286
286
|
}
|
|
287
|
+
// else if (!attached.length) {
|
|
288
|
+
// afterChangeFile();
|
|
289
|
+
// }
|
|
287
290
|
};
|
|
291
|
+
|
|
288
292
|
const onProgressing = file => {
|
|
289
293
|
return new Promise((resolve, reject) => {
|
|
290
294
|
const reader = new FileReader();
|
|
@@ -357,28 +361,35 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
357
361
|
}
|
|
358
362
|
};
|
|
359
363
|
const onRemoveMultiple = () => {
|
|
364
|
+
const attachedItems = [...dataState, ...newDataState];
|
|
360
365
|
const nodeList = attachedRef.current.querySelectorAll('.chosen');
|
|
361
366
|
const recentRemovedAttached = [];
|
|
367
|
+
const tempDataState = [...dataState];
|
|
368
|
+
const tempNewDataState = [...newDataState];
|
|
362
369
|
nodeList.forEach(itemEl => {
|
|
363
370
|
const parent = itemEl.parentNode;
|
|
364
371
|
const index = Array.from(attachedRef.current.children).indexOf(parent);
|
|
365
|
-
const deletedFile =
|
|
372
|
+
const deletedFile = attachedItems[index];
|
|
366
373
|
removedAttachedRef.current.push(deletedFile);
|
|
367
374
|
recentRemovedAttached.push(deletedFile);
|
|
368
|
-
if (Object.prototype.toString.call(deletedFile) === '[object File]' &&
|
|
369
|
-
removeFileOutInputFiles(
|
|
375
|
+
if (Object.prototype.toString.call(deletedFile) === '[object File]' && tempNewDataState !== null && tempNewDataState !== void 0 && tempNewDataState.length) {
|
|
376
|
+
removeFileOutInputFiles(tempNewDataState.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)));
|
|
377
|
+
tempNewDataState.splice(tempNewDataState.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)), 1);
|
|
378
|
+
setNewDataState(tempNewDataState);
|
|
370
379
|
} else {
|
|
371
|
-
oldAttached.splice(oldAttached.findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate), 1);
|
|
372
|
-
|
|
380
|
+
oldAttached.splice(oldAttached.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)), 1);
|
|
381
|
+
tempDataState.splice(tempDataState.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)), 1);
|
|
382
|
+
setDataState(tempDataState);
|
|
373
383
|
}
|
|
374
384
|
});
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
385
|
+
const tempAttachedItems = [...tempDataState, ...tempNewDataState];
|
|
386
|
+
// if (tempAttachedItems.length < 2) {
|
|
387
|
+
// afterChangeFile(tempAttachedItems?.length || 0);
|
|
388
|
+
// }
|
|
378
389
|
stripDomain();
|
|
379
390
|
if (onChange) onChange({
|
|
380
391
|
element: nodeList,
|
|
381
|
-
attached,
|
|
392
|
+
attached: tempAttachedItems,
|
|
382
393
|
recentRemovedAttached,
|
|
383
394
|
removedAttached: removedAttachedRef.current,
|
|
384
395
|
oldAttached,
|
|
@@ -442,8 +453,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
442
453
|
allNewAttached.delete('files');
|
|
443
454
|
files.forEach(file => allNewAttached.append('files', file));
|
|
444
455
|
// newAttachedRef.current = files || [];
|
|
445
|
-
setNewDataState(files || []);
|
|
456
|
+
// setNewDataState(files || []);
|
|
446
457
|
}
|
|
458
|
+
|
|
447
459
|
attachmentInputRef.current.files = dt.files;
|
|
448
460
|
return dt.files;
|
|
449
461
|
};
|
|
@@ -735,7 +747,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
735
747
|
}, [maxFile, maxSizeProp, multiple, accept]);
|
|
736
748
|
useEffect(() => {
|
|
737
749
|
oldAttached.length = 0;
|
|
738
|
-
afterChangeFile((
|
|
750
|
+
// afterChangeFile((data?.length || 0) + (newDataState?.length || 0));
|
|
739
751
|
if (data) {
|
|
740
752
|
// Load files data was uploaded
|
|
741
753
|
const length = data.length;
|
|
@@ -830,7 +842,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
830
842
|
uppercase: true,
|
|
831
843
|
required: required,
|
|
832
844
|
type: 'h5',
|
|
833
|
-
color: 'text
|
|
845
|
+
color: 'text/sub',
|
|
834
846
|
ref: attachTextRef
|
|
835
847
|
}, label), error ? jsx(HelperText, null, error) : null), jsx("div", {
|
|
836
848
|
css: AttachmentHeaderIconCSS
|
|
@@ -868,11 +880,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
868
880
|
}), isEmpty ? jsx(Typography, {
|
|
869
881
|
css: userSelectNone,
|
|
870
882
|
type: 'p3',
|
|
871
|
-
color: 'system
|
|
883
|
+
color: 'system/rest'
|
|
872
884
|
}, hintText) : null) : isEmpty ? jsx(Typography, {
|
|
873
885
|
css: userSelectNone,
|
|
874
886
|
type: 'p3',
|
|
875
|
-
color: 'system
|
|
887
|
+
color: 'system/rest'
|
|
876
888
|
}, getGlobal('noFileText')) : null)), allowSort && !isEmpty ? jsx(Popover, {
|
|
877
889
|
ref: popoverRef,
|
|
878
890
|
anchor: jsx(ButtonIcon, {
|
|
@@ -958,15 +970,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
958
970
|
}, jsx(Typography, {
|
|
959
971
|
className: 'username',
|
|
960
972
|
type: 'p2',
|
|
961
|
-
color: 'text
|
|
973
|
+
color: 'text/sub'
|
|
962
974
|
}, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx(Typography, {
|
|
963
975
|
className: 'datetime',
|
|
964
976
|
type: 'p2',
|
|
965
|
-
color: 'text
|
|
977
|
+
color: 'text/sub'
|
|
966
978
|
}, getDateTime(date)), jsx(Typography, {
|
|
967
979
|
className: 'filesize',
|
|
968
980
|
type: 'p2',
|
|
969
|
-
color: 'text
|
|
981
|
+
color: 'text/sub'
|
|
970
982
|
}, calculateSize(item.FileSize || item.size))) : null, isNew ? jsx("span", {
|
|
971
983
|
css: AttachedLinearCSS
|
|
972
984
|
}, jsx(LinearProgress, {
|
|
@@ -1108,9 +1120,9 @@ const AttachedItemInfoIconCSS = css`
|
|
|
1108
1120
|
${positionAbsolute};
|
|
1109
1121
|
${borderRadius50};
|
|
1110
1122
|
${parseWidthHeight(4, 4)};
|
|
1111
|
-
${bgColor('semantic
|
|
1123
|
+
${bgColor('semantic/success')};
|
|
1112
1124
|
${top(4.5)};
|
|
1113
|
-
${left(-2)}
|
|
1125
|
+
${left(-2)};
|
|
1114
1126
|
}
|
|
1115
1127
|
`;
|
|
1116
1128
|
const AttachedItemOwnerCSS = css`
|
|
@@ -1119,7 +1131,7 @@ const AttachedItemOwnerCSS = css`
|
|
|
1119
1131
|
${itemsCenter};
|
|
1120
1132
|
${userSelectNone};
|
|
1121
1133
|
${parseHeight('100%')};
|
|
1122
|
-
${textColor('text
|
|
1134
|
+
${textColor('text/sub')};
|
|
1123
1135
|
`;
|
|
1124
1136
|
const DetailInfoCSS = css`
|
|
1125
1137
|
${displayFlex};
|
|
@@ -1145,7 +1157,7 @@ const AttachedLinearCSS = css`
|
|
|
1145
1157
|
${displayFlex};
|
|
1146
1158
|
${positionAbsolute};
|
|
1147
1159
|
${itemsCenter};
|
|
1148
|
-
${bgColor('system
|
|
1160
|
+
${bgColor('system/white')};
|
|
1149
1161
|
${parseWidthHeight('100%')};
|
|
1150
1162
|
${top(0)};
|
|
1151
1163
|
`;
|
|
@@ -1242,27 +1254,27 @@ const AttachmentRootCSS = (isEmpty, isEnable) => css`
|
|
|
1242
1254
|
${positionRelative};
|
|
1243
1255
|
${borderRadius4px};
|
|
1244
1256
|
${boxBorder};
|
|
1245
|
-
${border(1, 'line
|
|
1257
|
+
${border(1, 'line/normal')};
|
|
1246
1258
|
${parseHeight(isEmpty && !isEnable ? 120 : 280)};
|
|
1247
|
-
${bgColor('system
|
|
1259
|
+
${bgColor('system/white')};
|
|
1248
1260
|
.css-${AttachedCSS.name} {
|
|
1249
1261
|
.css-${AttachedItemCSS.name} {
|
|
1250
1262
|
&:hover {
|
|
1251
|
-
${bgColor('fill
|
|
1263
|
+
${bgColor('fill/hover')};
|
|
1252
1264
|
.css-${AttachedLinearCSS.name} {
|
|
1253
|
-
${bgColor('fill
|
|
1265
|
+
${bgColor('fill/hover')};
|
|
1254
1266
|
}
|
|
1255
1267
|
}
|
|
1256
1268
|
&:active {
|
|
1257
|
-
${bgColor('fill
|
|
1269
|
+
${bgColor('fill/pressed')};
|
|
1258
1270
|
.css-${AttachedLinearCSS.name} {
|
|
1259
|
-
${bgColor('fill
|
|
1271
|
+
${bgColor('fill/pressed')};
|
|
1260
1272
|
}
|
|
1261
1273
|
}
|
|
1262
1274
|
&.chosen {
|
|
1263
|
-
${bgColor('fill
|
|
1275
|
+
${bgColor('fill/focus')};
|
|
1264
1276
|
.css-${AttachedItemInfoCSS.name}, .css-${AttachedItemOwnerCSS.name} {
|
|
1265
|
-
${bgColor('fill
|
|
1277
|
+
${bgColor('fill/focus')};
|
|
1266
1278
|
}
|
|
1267
1279
|
}
|
|
1268
1280
|
}
|
|
@@ -1277,22 +1289,17 @@ const AttachmentRootCSS = (isEmpty, isEnable) => css`
|
|
|
1277
1289
|
}
|
|
1278
1290
|
`;
|
|
1279
1291
|
Attachment.defaultProps = {
|
|
1280
|
-
allowSort: true,
|
|
1281
|
-
className: '',
|
|
1282
|
-
data: [],
|
|
1283
1292
|
deleteNotifyText: getGlobal('deleteNotifyText'),
|
|
1284
|
-
disabled: false,
|
|
1285
1293
|
hintText: getGlobal('dropFileHere'),
|
|
1286
1294
|
label: getGlobal('attachText'),
|
|
1287
|
-
|
|
1288
|
-
multiple: true,
|
|
1289
|
-
style: {},
|
|
1295
|
+
maxSize: getGlobal('maxSizeUpload'),
|
|
1290
1296
|
uploadErrorInfo: {
|
|
1291
1297
|
maxFile: getGlobal(['errorDefault', 'maxFile']),
|
|
1292
1298
|
maxSize: getGlobal(['errorDefault', 'maxSize']),
|
|
1293
1299
|
fileType: getGlobal(['errorDefault', 'fileType']),
|
|
1294
1300
|
existingFile: getGlobal(['errorDefault', 'existingFile'])
|
|
1295
|
-
}
|
|
1301
|
+
},
|
|
1302
|
+
...getGlobal(['components', 'attachment', 'defaultProps'])
|
|
1296
1303
|
};
|
|
1297
1304
|
Attachment.propTypes = {
|
|
1298
1305
|
/** File types that can be accepted. */
|
|
@@ -1333,7 +1340,7 @@ Attachment.propTypes = {
|
|
|
1333
1340
|
/** Limit the number of uploaded files. */
|
|
1334
1341
|
maxFile: PropTypes.number,
|
|
1335
1342
|
/** Limit the size of uploaded files. */
|
|
1336
|
-
maxSize: PropTypes.string,
|
|
1343
|
+
maxSize: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1337
1344
|
/** Allows to attach multiple files. */
|
|
1338
1345
|
multiple: PropTypes.bool,
|
|
1339
1346
|
/** Callback fired when the files attached is changed. */
|