@teselagen/ui 0.5.23-beta.31 → 0.5.23-beta.33
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/DataTable/utils/index.d.ts +1 -2
- package/FormComponents/Uploader.d.ts +1 -1
- package/index.cjs.js +103 -86
- package/index.d.ts +2 -1
- package/index.es.js +103 -86
- package/package.json +1 -1
- package/src/DataTable/EditabelCell.js +4 -4
- package/src/DataTable/index.js +2 -2
- package/src/DataTable/utils/index.js +0 -2
- package/src/DataTable/utils/useTableParams.js +0 -1
- package/src/DataTable/utils/withTableParams.js +1 -1
- package/src/FormComponents/Uploader.js +103 -86
- package/src/FormComponents/index.js +8 -4
- package/src/TgSelect/index.js +1 -1
- package/src/UploadCsvWizard.js +2 -1
- package/src/index.js +2 -1
- package/src/utils/hooks/index.js +1 -0
- package/src/utils/hooks/useDeepEqualMemo.js +10 -0
- package/src/utils/hooks/useStableReference.js +9 -0
- package/utils/hooks/index.d.ts +1 -0
- package/utils/hooks/useDeepEqualMemo.d.ts +1 -0
- package/utils/hooks/useStableReference.d.ts +1 -0
- package/FormComponents/AbstractField.d.ts +0 -1
- package/src/FormComponents/AbstractField.js +0 -388
|
@@ -18,7 +18,6 @@ import { isBottomRightCornerOfRectangle } from './isBottomRightCornerOfRectangle
|
|
|
18
18
|
import { isEntityClean } from './isEntityClean';
|
|
19
19
|
import { PRIMARY_SELECTED_VAL } from './primarySelectedValue';
|
|
20
20
|
import { removeCleanRows } from './removeCleanRows';
|
|
21
|
-
import { useDeepEqualMemo } from './useDeepEqualMemo';
|
|
22
21
|
import { useTableEntities } from './useTableEntities';
|
|
23
22
|
|
|
24
|
-
export { defaultParsePaste, formatPasteData, getAllRows, getCellCopyText, getCellInfo, getEntityIdToEntity, getFieldPathToIndex, getFieldPathToField, getIdOrCodeOrIndex, getLastSelectedEntity, getNewEntToSelect, getNumberStrAtEnd, getRecordsFromIdMap, getRowCopyText, getSelectedRowsFromEntities, handleCopyColumn, handleCopyHelper, handleCopyRows, handleCopyTable, isBottomRightCornerOfRectangle, isEntityClean, PRIMARY_SELECTED_VAL, removeCleanRows, stripNumberAtEnd,
|
|
23
|
+
export { defaultParsePaste, formatPasteData, getAllRows, getCellCopyText, getCellInfo, getEntityIdToEntity, getFieldPathToIndex, getFieldPathToField, getIdOrCodeOrIndex, getLastSelectedEntity, getNewEntToSelect, getNumberStrAtEnd, getRecordsFromIdMap, getRowCopyText, getSelectedRowsFromEntities, handleCopyColumn, handleCopyHelper, handleCopyRows, handleCopyTable, isBottomRightCornerOfRectangle, isEntityClean, PRIMARY_SELECTED_VAL, removeCleanRows, stripNumberAtEnd, useTableEntities };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default Uploader;
|
|
2
|
-
declare function Uploader({ accept: __accept, action, autoUnzip, beforeUpload, callout: _callout, className, contentOverride: maybeContentOverride, disabled
|
|
2
|
+
declare function Uploader({ accept: __accept, action, autoUnzip, beforeUpload, callout: _callout, className, contentOverride: maybeContentOverride, disabled, dropzoneProps, fileLimit, fileList, innerIcon, innerText, meta: { form: formName }, minimal, name, noBuildCsvOption, noRedux, onChange: _onChange, onFieldSubmit, onFileClick, onFileSuccess, onPreviewClick, onRemove, overflowList, readBeforeUpload, showFilesCount, showUploadList, threeDotMenuItems, validateAgainstSchema: _validateAgainstSchema }: {
|
|
3
3
|
accept: any;
|
|
4
4
|
action: any;
|
|
5
5
|
autoUnzip: any;
|
package/index.cjs.js
CHANGED
|
@@ -17147,13 +17147,6 @@ const handleCopyTable = /* @__PURE__ */ __name((e2, opts) => {
|
|
|
17147
17147
|
}
|
|
17148
17148
|
}, "handleCopyTable");
|
|
17149
17149
|
const PRIMARY_SELECTED_VAL = "main_cell";
|
|
17150
|
-
const useDeepEqualMemo = /* @__PURE__ */ __name((value) => {
|
|
17151
|
-
const ref2 = React$1.useRef();
|
|
17152
|
-
if (!isEqual(value, ref2.current)) {
|
|
17153
|
-
ref2.current = value;
|
|
17154
|
-
}
|
|
17155
|
-
return ref2.current;
|
|
17156
|
-
}, "useDeepEqualMemo");
|
|
17157
17150
|
const useTableEntities = /* @__PURE__ */ __name((tableFormName) => {
|
|
17158
17151
|
const dispatch = reactRedux.useDispatch();
|
|
17159
17152
|
const selectTableEntities = React$1.useCallback(
|
|
@@ -17189,6 +17182,13 @@ const useTableEntities = /* @__PURE__ */ __name((tableFormName) => {
|
|
|
17189
17182
|
});
|
|
17190
17183
|
return { selectTableEntities, allOrderedEntities, selectedEntities };
|
|
17191
17184
|
}, "useTableEntities");
|
|
17185
|
+
const useDeepEqualMemo = /* @__PURE__ */ __name((value) => {
|
|
17186
|
+
const ref2 = React$1.useRef();
|
|
17187
|
+
if (!isEqual(value, ref2.current)) {
|
|
17188
|
+
ref2.current = value;
|
|
17189
|
+
}
|
|
17190
|
+
return ref2.current;
|
|
17191
|
+
}, "useDeepEqualMemo");
|
|
17192
17192
|
function rowClick(e2, rowInfo, entities, {
|
|
17193
17193
|
reduxFormSelectedEntityIdMap,
|
|
17194
17194
|
isSingleSelect,
|
|
@@ -31035,7 +31035,7 @@ const _TgSelect = class _TgSelect extends React$1.Component {
|
|
|
31035
31035
|
e2.preventDefault();
|
|
31036
31036
|
let newValue = null;
|
|
31037
31037
|
if (multi) {
|
|
31038
|
-
newValue = filter(value, (obj) => obj.disabled) || [];
|
|
31038
|
+
newValue = filter(value, (obj) => obj == null ? void 0 : obj.disabled) || [];
|
|
31039
31039
|
} else if (value && value.disabled) {
|
|
31040
31040
|
newValue = value;
|
|
31041
31041
|
}
|
|
@@ -31783,6 +31783,13 @@ const sortify = /* @__PURE__ */ __name((value, replacer, space2) => {
|
|
|
31783
31783
|
}, "sortify");
|
|
31784
31784
|
const REQUIRED_ERROR = "This field is required.";
|
|
31785
31785
|
const fieldRequired = /* @__PURE__ */ __name((value) => !value || Array.isArray(value) && !value.length ? REQUIRED_ERROR : void 0, "fieldRequired");
|
|
31786
|
+
const useStableReference = /* @__PURE__ */ __name((value) => {
|
|
31787
|
+
const ref2 = React$1.useRef();
|
|
31788
|
+
React$1.useEffect(() => {
|
|
31789
|
+
ref2.current = value;
|
|
31790
|
+
}, [value]);
|
|
31791
|
+
return ref2;
|
|
31792
|
+
}, "useStableReference");
|
|
31786
31793
|
function getIntent({
|
|
31787
31794
|
showErrorIfUntouched,
|
|
31788
31795
|
meta: { touched, error, warning: warning2 }
|
|
@@ -31872,8 +31879,8 @@ const AbstractInput = /* @__PURE__ */ __name(({
|
|
|
31872
31879
|
noFillField,
|
|
31873
31880
|
noMarginBottom,
|
|
31874
31881
|
noOuterLabel,
|
|
31875
|
-
onDefaultValChanged,
|
|
31876
|
-
onFieldSubmit,
|
|
31882
|
+
onDefaultValChanged: _onDefaultValChanged,
|
|
31883
|
+
onFieldSubmit: _onFieldSubmit,
|
|
31877
31884
|
rightEl,
|
|
31878
31885
|
secondaryLabel,
|
|
31879
31886
|
setAssignDefaultsMode,
|
|
@@ -31885,11 +31892,13 @@ const AbstractInput = /* @__PURE__ */ __name(({
|
|
|
31885
31892
|
tooltipProps
|
|
31886
31893
|
}) => {
|
|
31887
31894
|
const dispatch = reactRedux.useDispatch();
|
|
31895
|
+
const onDefaultValChanged = useStableReference(_onDefaultValChanged);
|
|
31896
|
+
const onFieldSubmit = useStableReference(_onFieldSubmit);
|
|
31888
31897
|
React$1.useEffect(() => {
|
|
31889
31898
|
if (defaultValue2 !== void 0) {
|
|
31890
31899
|
dispatch(reduxForm.change(form, name, defaultValue2));
|
|
31891
|
-
onDefaultValChanged && onDefaultValChanged(defaultValue2, name, form);
|
|
31892
|
-
onFieldSubmit && onFieldSubmit(defaultValue2);
|
|
31900
|
+
onDefaultValChanged.current && onDefaultValChanged.current(defaultValue2, name, form);
|
|
31901
|
+
onFieldSubmit.current && onFieldSubmit.current(defaultValue2);
|
|
31893
31902
|
}
|
|
31894
31903
|
}, [defaultValue2, dispatch, form, name, onDefaultValChanged, onFieldSubmit]);
|
|
31895
31904
|
const showError = (touched || showErrorIfUntouched) && error && !asyncValidating;
|
|
@@ -67390,6 +67399,9 @@ const InnerDropZone = /* @__PURE__ */ __name(({
|
|
|
67390
67399
|
)
|
|
67391
67400
|
)
|
|
67392
67401
|
), showFilesCount ? /* @__PURE__ */ React$1.createElement("div", { className: "tg-upload-file-list-counter" }, "Files: ", fileList ? fileList.length : 0) : null), "InnerDropZone");
|
|
67402
|
+
const onFileSuccessDefault = /* @__PURE__ */ __name(() => __async(exports, null, function* () {
|
|
67403
|
+
return;
|
|
67404
|
+
}), "onFileSuccessDefault");
|
|
67393
67405
|
const Uploader = /* @__PURE__ */ __name(({
|
|
67394
67406
|
accept: __accept,
|
|
67395
67407
|
action: action2,
|
|
@@ -67398,7 +67410,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67398
67410
|
callout: _callout,
|
|
67399
67411
|
className = "",
|
|
67400
67412
|
contentOverride: maybeContentOverride,
|
|
67401
|
-
disabled
|
|
67413
|
+
disabled,
|
|
67402
67414
|
dropzoneProps = {},
|
|
67403
67415
|
fileLimit,
|
|
67404
67416
|
fileList,
|
|
@@ -67416,9 +67428,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67416
67428
|
//called when all files have successfully uploaded
|
|
67417
67429
|
onFileClick,
|
|
67418
67430
|
// called when a file link in the filelist is clicked
|
|
67419
|
-
onFileSuccess =
|
|
67420
|
-
return;
|
|
67421
|
-
}), "onFileSuccess"),
|
|
67431
|
+
onFileSuccess = onFileSuccessDefault,
|
|
67422
67432
|
//called each time a file is finished and before the file.loading gets set to false, needs to return a promise!
|
|
67423
67433
|
onPreviewClick,
|
|
67424
67434
|
onRemove = noop$4,
|
|
@@ -67437,83 +67447,92 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67437
67447
|
const [resolvedAccept, setResolvedAccept] = React$1.useState();
|
|
67438
67448
|
const [loading, setLoading] = React$1.useState(false);
|
|
67439
67449
|
const filesToClean = React$1.useRef([]);
|
|
67440
|
-
const
|
|
67441
|
-
|
|
67442
|
-
|
|
67443
|
-
|
|
67444
|
-
|
|
67445
|
-
|
|
67446
|
-
|
|
67447
|
-
|
|
67448
|
-
|
|
67449
|
-
|
|
67450
|
-
|
|
67451
|
-
|
|
67452
|
-
|
|
67453
|
-
|
|
67454
|
-
|
|
67455
|
-
|
|
67456
|
-
|
|
67457
|
-
|
|
67458
|
-
|
|
67459
|
-
|
|
67460
|
-
|
|
67461
|
-
|
|
67462
|
-
|
|
67463
|
-
|
|
67464
|
-
const
|
|
67465
|
-
|
|
67466
|
-
|
|
67467
|
-
|
|
67468
|
-
|
|
67469
|
-
|
|
67450
|
+
const stableOnChange = useStableReference(_onChange);
|
|
67451
|
+
const stableBeforeUpload = useStableReference(beforeUpload);
|
|
67452
|
+
const onChange = React$1.useCallback(
|
|
67453
|
+
(val) => {
|
|
67454
|
+
require$$2$1.flushSync(() => {
|
|
67455
|
+
if (noRedux) {
|
|
67456
|
+
return stableOnChange.current(val);
|
|
67457
|
+
}
|
|
67458
|
+
dispatch(reduxForm.touch(formName, name));
|
|
67459
|
+
dispatch(reduxForm.change(formName, name, val));
|
|
67460
|
+
});
|
|
67461
|
+
},
|
|
67462
|
+
[dispatch, formName, name, noRedux, stableOnChange]
|
|
67463
|
+
);
|
|
67464
|
+
const handleSecondHalfOfUpload = React$1.useCallback(
|
|
67465
|
+
(_0) => __async(exports, [_0], function* ({ acceptedFiles, cleanedFileList }) {
|
|
67466
|
+
onChange(cleanedFileList);
|
|
67467
|
+
const keepGoing = stableBeforeUpload.current ? yield stableBeforeUpload.current(cleanedFileList, onChange) : true;
|
|
67468
|
+
if (!keepGoing)
|
|
67469
|
+
return;
|
|
67470
|
+
if (action2) {
|
|
67471
|
+
const responses = [];
|
|
67472
|
+
yield Promise.all(
|
|
67473
|
+
acceptedFiles.map((fileToUpload) => __async(exports, null, function* () {
|
|
67474
|
+
const data = new FormData();
|
|
67475
|
+
data.append("file", fileToUpload);
|
|
67476
|
+
try {
|
|
67477
|
+
const res = yield window.serverApi ? window.serverApi.post(action2, data) : fetch(action2, {
|
|
67478
|
+
method: "POST",
|
|
67479
|
+
body: data
|
|
67480
|
+
});
|
|
67481
|
+
responses.push(res.data && res.data[0]);
|
|
67482
|
+
onFileSuccess(res.data[0]).then(() => {
|
|
67483
|
+
cleanedFileList = cleanedFileList.map((file) => {
|
|
67484
|
+
const fileToReturn = __spreadValues(__spreadValues({}, file), res.data[0]);
|
|
67485
|
+
if (fileToReturn.id === fileToUpload.id) {
|
|
67486
|
+
fileToReturn.loading = false;
|
|
67487
|
+
}
|
|
67488
|
+
return fileToReturn;
|
|
67489
|
+
});
|
|
67490
|
+
onChange(cleanedFileList);
|
|
67491
|
+
});
|
|
67492
|
+
} catch (err) {
|
|
67493
|
+
console.error("Error uploading file:", err);
|
|
67494
|
+
responses.push(__spreadProps(__spreadValues({}, fileToUpload), {
|
|
67495
|
+
error: err && err.msg ? err.msg : err
|
|
67496
|
+
}));
|
|
67470
67497
|
cleanedFileList = cleanedFileList.map((file) => {
|
|
67471
|
-
const fileToReturn = __spreadValues(
|
|
67498
|
+
const fileToReturn = __spreadValues({}, file);
|
|
67472
67499
|
if (fileToReturn.id === fileToUpload.id) {
|
|
67473
67500
|
fileToReturn.loading = false;
|
|
67501
|
+
fileToReturn.error = true;
|
|
67474
67502
|
}
|
|
67475
67503
|
return fileToReturn;
|
|
67476
67504
|
});
|
|
67477
67505
|
onChange(cleanedFileList);
|
|
67506
|
+
}
|
|
67507
|
+
}))
|
|
67508
|
+
);
|
|
67509
|
+
onFieldSubmit(responses);
|
|
67510
|
+
} else {
|
|
67511
|
+
onChange(
|
|
67512
|
+
cleanedFileList.map(function(file) {
|
|
67513
|
+
return __spreadProps(__spreadValues({}, file), {
|
|
67514
|
+
loading: false
|
|
67478
67515
|
});
|
|
67479
|
-
}
|
|
67480
|
-
|
|
67481
|
-
|
|
67482
|
-
|
|
67483
|
-
|
|
67484
|
-
|
|
67485
|
-
|
|
67486
|
-
if (fileToReturn.id === fileToUpload.id) {
|
|
67487
|
-
fileToReturn.loading = false;
|
|
67488
|
-
fileToReturn.error = true;
|
|
67489
|
-
}
|
|
67490
|
-
return fileToReturn;
|
|
67491
|
-
});
|
|
67492
|
-
onChange(cleanedFileList);
|
|
67493
|
-
}
|
|
67494
|
-
}))
|
|
67495
|
-
);
|
|
67496
|
-
onFieldSubmit(responses);
|
|
67497
|
-
} else {
|
|
67498
|
-
onChange(
|
|
67499
|
-
cleanedFileList.map(function(file) {
|
|
67500
|
-
return __spreadProps(__spreadValues({}, file), {
|
|
67501
|
-
loading: false
|
|
67502
|
-
});
|
|
67503
|
-
})
|
|
67504
|
-
);
|
|
67505
|
-
}
|
|
67506
|
-
setLoading(false);
|
|
67507
|
-
}), "handleSecondHalfOfUpload");
|
|
67516
|
+
})
|
|
67517
|
+
);
|
|
67518
|
+
}
|
|
67519
|
+
setLoading(false);
|
|
67520
|
+
}),
|
|
67521
|
+
[action2, stableBeforeUpload, onChange, onFieldSubmit, onFileSuccess]
|
|
67522
|
+
);
|
|
67508
67523
|
const isAcceptPromise = React$1.useMemo(
|
|
67509
67524
|
() => (__accept == null ? void 0 : __accept.then) || (Array.isArray(__accept) ? __accept.some((acc) => acc == null ? void 0 : acc.then) : false),
|
|
67510
67525
|
[__accept]
|
|
67511
67526
|
);
|
|
67512
|
-
|
|
67513
|
-
|
|
67514
|
-
|
|
67515
|
-
|
|
67516
|
-
|
|
67527
|
+
const _accept = React$1.useMemo(() => {
|
|
67528
|
+
if (resolvedAccept) {
|
|
67529
|
+
return resolvedAccept;
|
|
67530
|
+
}
|
|
67531
|
+
if (isAcceptPromise && !resolvedAccept) {
|
|
67532
|
+
return [];
|
|
67533
|
+
}
|
|
67534
|
+
return __accept;
|
|
67535
|
+
}, [__accept, isAcceptPromise, resolvedAccept]);
|
|
67517
67536
|
React$1.useEffect(() => {
|
|
67518
67537
|
if (isAcceptPromise) {
|
|
67519
67538
|
setAcceptLoading(true);
|
|
@@ -67526,9 +67545,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67526
67545
|
);
|
|
67527
67546
|
}
|
|
67528
67547
|
}, [__accept, isAcceptPromise]);
|
|
67529
|
-
|
|
67530
|
-
_accept = [];
|
|
67531
|
-
}
|
|
67548
|
+
let dropzoneDisabled = disabled;
|
|
67532
67549
|
if (acceptLoading)
|
|
67533
67550
|
dropzoneDisabled = true;
|
|
67534
67551
|
const accept = React$1.useMemo(
|
|
@@ -67753,7 +67770,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67753
67770
|
style: { fontSize: 11, marginBottom: 5 }
|
|
67754
67771
|
},
|
|
67755
67772
|
advancedAccept && !acceptLoading ? /* @__PURE__ */ React$1.createElement("div", null, "Accepts ", /* @__PURE__ */ React$1.createElement("span", null, advancedAccept.map((acc, i) => {
|
|
67756
|
-
const
|
|
67773
|
+
const disabled2 = !(acc.description || acc.exampleFile || acc.exampleFiles);
|
|
67757
67774
|
const PopOrTooltip = acc.exampleFiles ? core.Popover : core.Tooltip;
|
|
67758
67775
|
const hasDownload = acc.exampleFile || acc.exampleFiles;
|
|
67759
67776
|
const CustomTag = !hasDownload ? "span" : "a";
|
|
@@ -67762,7 +67779,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67762
67779
|
{
|
|
67763
67780
|
key: i,
|
|
67764
67781
|
interactionKind: "hover",
|
|
67765
|
-
disabled,
|
|
67782
|
+
disabled: disabled2,
|
|
67766
67783
|
modifiers: popoverOverflowModifiers,
|
|
67767
67784
|
content: acc.exampleFiles ? /* @__PURE__ */ React$1.createElement(core.Menu, null, acc.exampleFiles.map(
|
|
67768
67785
|
({ description, subtext, exampleFile, icon }, i2) => /* @__PURE__ */ React$1.createElement(
|
package/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './utils/commandUtils';
|
|
|
15
15
|
export * from './utils/commandControls';
|
|
16
16
|
export * from './utils/useTraceUpdate';
|
|
17
17
|
export { default as Uploader } from './FormComponents/Uploader';
|
|
18
|
+
export { useDeepEqualMemo } from './utils/hooks';
|
|
18
19
|
export { default as Loading } from './Loading';
|
|
19
20
|
export { throwFormError } from './throwFormError';
|
|
20
21
|
export { default as AdvancedOptions } from './AdvancedOptions';
|
|
@@ -57,6 +58,6 @@ export { mergeSchemas, default as convertSchema } from './DataTable/utils/conver
|
|
|
57
58
|
export { getCurrentParamsFromUrl, setCurrentParamsOnUrl } from './DataTable/utils/queryParams';
|
|
58
59
|
export { default as withSelectedEntities, getSelectedEntities } from './DataTable/utils/withSelectedEntities';
|
|
59
60
|
export { default as DataTable, ConnectedPagingTool as PagingTool } from './DataTable';
|
|
60
|
-
export { removeCleanRows, useTableEntities, getIdOrCodeOrIndex
|
|
61
|
+
export { removeCleanRows, useTableEntities, getIdOrCodeOrIndex } from './DataTable/utils';
|
|
61
62
|
export { default as withTableParams, useTableParams } from './DataTable/utils/withTableParams';
|
|
62
63
|
export { default as Timeline, TimelineEvent } from './Timeline';
|
package/index.es.js
CHANGED
|
@@ -17129,13 +17129,6 @@ const handleCopyTable = /* @__PURE__ */ __name((e2, opts) => {
|
|
|
17129
17129
|
}
|
|
17130
17130
|
}, "handleCopyTable");
|
|
17131
17131
|
const PRIMARY_SELECTED_VAL = "main_cell";
|
|
17132
|
-
const useDeepEqualMemo = /* @__PURE__ */ __name((value) => {
|
|
17133
|
-
const ref2 = useRef();
|
|
17134
|
-
if (!isEqual(value, ref2.current)) {
|
|
17135
|
-
ref2.current = value;
|
|
17136
|
-
}
|
|
17137
|
-
return ref2.current;
|
|
17138
|
-
}, "useDeepEqualMemo");
|
|
17139
17132
|
const useTableEntities = /* @__PURE__ */ __name((tableFormName) => {
|
|
17140
17133
|
const dispatch = useDispatch();
|
|
17141
17134
|
const selectTableEntities = useCallback(
|
|
@@ -17171,6 +17164,13 @@ const useTableEntities = /* @__PURE__ */ __name((tableFormName) => {
|
|
|
17171
17164
|
});
|
|
17172
17165
|
return { selectTableEntities, allOrderedEntities, selectedEntities };
|
|
17173
17166
|
}, "useTableEntities");
|
|
17167
|
+
const useDeepEqualMemo = /* @__PURE__ */ __name((value) => {
|
|
17168
|
+
const ref2 = useRef();
|
|
17169
|
+
if (!isEqual(value, ref2.current)) {
|
|
17170
|
+
ref2.current = value;
|
|
17171
|
+
}
|
|
17172
|
+
return ref2.current;
|
|
17173
|
+
}, "useDeepEqualMemo");
|
|
17174
17174
|
function rowClick(e2, rowInfo, entities, {
|
|
17175
17175
|
reduxFormSelectedEntityIdMap,
|
|
17176
17176
|
isSingleSelect,
|
|
@@ -31017,7 +31017,7 @@ const _TgSelect = class _TgSelect extends React__default.Component {
|
|
|
31017
31017
|
e2.preventDefault();
|
|
31018
31018
|
let newValue = null;
|
|
31019
31019
|
if (multi) {
|
|
31020
|
-
newValue = filter(value, (obj) => obj.disabled) || [];
|
|
31020
|
+
newValue = filter(value, (obj) => obj == null ? void 0 : obj.disabled) || [];
|
|
31021
31021
|
} else if (value && value.disabled) {
|
|
31022
31022
|
newValue = value;
|
|
31023
31023
|
}
|
|
@@ -31765,6 +31765,13 @@ const sortify = /* @__PURE__ */ __name((value, replacer, space2) => {
|
|
|
31765
31765
|
}, "sortify");
|
|
31766
31766
|
const REQUIRED_ERROR = "This field is required.";
|
|
31767
31767
|
const fieldRequired = /* @__PURE__ */ __name((value) => !value || Array.isArray(value) && !value.length ? REQUIRED_ERROR : void 0, "fieldRequired");
|
|
31768
|
+
const useStableReference = /* @__PURE__ */ __name((value) => {
|
|
31769
|
+
const ref2 = useRef();
|
|
31770
|
+
useEffect(() => {
|
|
31771
|
+
ref2.current = value;
|
|
31772
|
+
}, [value]);
|
|
31773
|
+
return ref2;
|
|
31774
|
+
}, "useStableReference");
|
|
31768
31775
|
function getIntent({
|
|
31769
31776
|
showErrorIfUntouched,
|
|
31770
31777
|
meta: { touched, error, warning: warning2 }
|
|
@@ -31854,8 +31861,8 @@ const AbstractInput = /* @__PURE__ */ __name(({
|
|
|
31854
31861
|
noFillField,
|
|
31855
31862
|
noMarginBottom,
|
|
31856
31863
|
noOuterLabel,
|
|
31857
|
-
onDefaultValChanged,
|
|
31858
|
-
onFieldSubmit,
|
|
31864
|
+
onDefaultValChanged: _onDefaultValChanged,
|
|
31865
|
+
onFieldSubmit: _onFieldSubmit,
|
|
31859
31866
|
rightEl,
|
|
31860
31867
|
secondaryLabel,
|
|
31861
31868
|
setAssignDefaultsMode,
|
|
@@ -31867,11 +31874,13 @@ const AbstractInput = /* @__PURE__ */ __name(({
|
|
|
31867
31874
|
tooltipProps
|
|
31868
31875
|
}) => {
|
|
31869
31876
|
const dispatch = useDispatch();
|
|
31877
|
+
const onDefaultValChanged = useStableReference(_onDefaultValChanged);
|
|
31878
|
+
const onFieldSubmit = useStableReference(_onFieldSubmit);
|
|
31870
31879
|
useEffect(() => {
|
|
31871
31880
|
if (defaultValue2 !== void 0) {
|
|
31872
31881
|
dispatch(change(form, name, defaultValue2));
|
|
31873
|
-
onDefaultValChanged && onDefaultValChanged(defaultValue2, name, form);
|
|
31874
|
-
onFieldSubmit && onFieldSubmit(defaultValue2);
|
|
31882
|
+
onDefaultValChanged.current && onDefaultValChanged.current(defaultValue2, name, form);
|
|
31883
|
+
onFieldSubmit.current && onFieldSubmit.current(defaultValue2);
|
|
31875
31884
|
}
|
|
31876
31885
|
}, [defaultValue2, dispatch, form, name, onDefaultValChanged, onFieldSubmit]);
|
|
31877
31886
|
const showError = (touched || showErrorIfUntouched) && error && !asyncValidating;
|
|
@@ -67372,6 +67381,9 @@ const InnerDropZone = /* @__PURE__ */ __name(({
|
|
|
67372
67381
|
)
|
|
67373
67382
|
)
|
|
67374
67383
|
), showFilesCount ? /* @__PURE__ */ React__default.createElement("div", { className: "tg-upload-file-list-counter" }, "Files: ", fileList ? fileList.length : 0) : null), "InnerDropZone");
|
|
67384
|
+
const onFileSuccessDefault = /* @__PURE__ */ __name(() => __async(void 0, null, function* () {
|
|
67385
|
+
return;
|
|
67386
|
+
}), "onFileSuccessDefault");
|
|
67375
67387
|
const Uploader = /* @__PURE__ */ __name(({
|
|
67376
67388
|
accept: __accept,
|
|
67377
67389
|
action: action2,
|
|
@@ -67380,7 +67392,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67380
67392
|
callout: _callout,
|
|
67381
67393
|
className = "",
|
|
67382
67394
|
contentOverride: maybeContentOverride,
|
|
67383
|
-
disabled
|
|
67395
|
+
disabled,
|
|
67384
67396
|
dropzoneProps = {},
|
|
67385
67397
|
fileLimit,
|
|
67386
67398
|
fileList,
|
|
@@ -67398,9 +67410,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67398
67410
|
//called when all files have successfully uploaded
|
|
67399
67411
|
onFileClick,
|
|
67400
67412
|
// called when a file link in the filelist is clicked
|
|
67401
|
-
onFileSuccess =
|
|
67402
|
-
return;
|
|
67403
|
-
}), "onFileSuccess"),
|
|
67413
|
+
onFileSuccess = onFileSuccessDefault,
|
|
67404
67414
|
//called each time a file is finished and before the file.loading gets set to false, needs to return a promise!
|
|
67405
67415
|
onPreviewClick,
|
|
67406
67416
|
onRemove = noop$4,
|
|
@@ -67419,83 +67429,92 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67419
67429
|
const [resolvedAccept, setResolvedAccept] = useState();
|
|
67420
67430
|
const [loading, setLoading] = useState(false);
|
|
67421
67431
|
const filesToClean = useRef([]);
|
|
67422
|
-
const
|
|
67423
|
-
|
|
67424
|
-
|
|
67425
|
-
|
|
67426
|
-
|
|
67427
|
-
|
|
67428
|
-
|
|
67429
|
-
|
|
67430
|
-
|
|
67431
|
-
|
|
67432
|
-
|
|
67433
|
-
|
|
67434
|
-
|
|
67435
|
-
|
|
67436
|
-
|
|
67437
|
-
|
|
67438
|
-
|
|
67439
|
-
|
|
67440
|
-
|
|
67441
|
-
|
|
67442
|
-
|
|
67443
|
-
|
|
67444
|
-
|
|
67445
|
-
|
|
67446
|
-
const
|
|
67447
|
-
|
|
67448
|
-
|
|
67449
|
-
|
|
67450
|
-
|
|
67451
|
-
|
|
67432
|
+
const stableOnChange = useStableReference(_onChange);
|
|
67433
|
+
const stableBeforeUpload = useStableReference(beforeUpload);
|
|
67434
|
+
const onChange = useCallback(
|
|
67435
|
+
(val) => {
|
|
67436
|
+
flushSync(() => {
|
|
67437
|
+
if (noRedux) {
|
|
67438
|
+
return stableOnChange.current(val);
|
|
67439
|
+
}
|
|
67440
|
+
dispatch(touch(formName, name));
|
|
67441
|
+
dispatch(change(formName, name, val));
|
|
67442
|
+
});
|
|
67443
|
+
},
|
|
67444
|
+
[dispatch, formName, name, noRedux, stableOnChange]
|
|
67445
|
+
);
|
|
67446
|
+
const handleSecondHalfOfUpload = useCallback(
|
|
67447
|
+
(_0) => __async(void 0, [_0], function* ({ acceptedFiles, cleanedFileList }) {
|
|
67448
|
+
onChange(cleanedFileList);
|
|
67449
|
+
const keepGoing = stableBeforeUpload.current ? yield stableBeforeUpload.current(cleanedFileList, onChange) : true;
|
|
67450
|
+
if (!keepGoing)
|
|
67451
|
+
return;
|
|
67452
|
+
if (action2) {
|
|
67453
|
+
const responses = [];
|
|
67454
|
+
yield Promise.all(
|
|
67455
|
+
acceptedFiles.map((fileToUpload) => __async(void 0, null, function* () {
|
|
67456
|
+
const data = new FormData();
|
|
67457
|
+
data.append("file", fileToUpload);
|
|
67458
|
+
try {
|
|
67459
|
+
const res = yield window.serverApi ? window.serverApi.post(action2, data) : fetch(action2, {
|
|
67460
|
+
method: "POST",
|
|
67461
|
+
body: data
|
|
67462
|
+
});
|
|
67463
|
+
responses.push(res.data && res.data[0]);
|
|
67464
|
+
onFileSuccess(res.data[0]).then(() => {
|
|
67465
|
+
cleanedFileList = cleanedFileList.map((file) => {
|
|
67466
|
+
const fileToReturn = __spreadValues(__spreadValues({}, file), res.data[0]);
|
|
67467
|
+
if (fileToReturn.id === fileToUpload.id) {
|
|
67468
|
+
fileToReturn.loading = false;
|
|
67469
|
+
}
|
|
67470
|
+
return fileToReturn;
|
|
67471
|
+
});
|
|
67472
|
+
onChange(cleanedFileList);
|
|
67473
|
+
});
|
|
67474
|
+
} catch (err) {
|
|
67475
|
+
console.error("Error uploading file:", err);
|
|
67476
|
+
responses.push(__spreadProps(__spreadValues({}, fileToUpload), {
|
|
67477
|
+
error: err && err.msg ? err.msg : err
|
|
67478
|
+
}));
|
|
67452
67479
|
cleanedFileList = cleanedFileList.map((file) => {
|
|
67453
|
-
const fileToReturn = __spreadValues(
|
|
67480
|
+
const fileToReturn = __spreadValues({}, file);
|
|
67454
67481
|
if (fileToReturn.id === fileToUpload.id) {
|
|
67455
67482
|
fileToReturn.loading = false;
|
|
67483
|
+
fileToReturn.error = true;
|
|
67456
67484
|
}
|
|
67457
67485
|
return fileToReturn;
|
|
67458
67486
|
});
|
|
67459
67487
|
onChange(cleanedFileList);
|
|
67488
|
+
}
|
|
67489
|
+
}))
|
|
67490
|
+
);
|
|
67491
|
+
onFieldSubmit(responses);
|
|
67492
|
+
} else {
|
|
67493
|
+
onChange(
|
|
67494
|
+
cleanedFileList.map(function(file) {
|
|
67495
|
+
return __spreadProps(__spreadValues({}, file), {
|
|
67496
|
+
loading: false
|
|
67460
67497
|
});
|
|
67461
|
-
}
|
|
67462
|
-
|
|
67463
|
-
|
|
67464
|
-
|
|
67465
|
-
|
|
67466
|
-
|
|
67467
|
-
|
|
67468
|
-
if (fileToReturn.id === fileToUpload.id) {
|
|
67469
|
-
fileToReturn.loading = false;
|
|
67470
|
-
fileToReturn.error = true;
|
|
67471
|
-
}
|
|
67472
|
-
return fileToReturn;
|
|
67473
|
-
});
|
|
67474
|
-
onChange(cleanedFileList);
|
|
67475
|
-
}
|
|
67476
|
-
}))
|
|
67477
|
-
);
|
|
67478
|
-
onFieldSubmit(responses);
|
|
67479
|
-
} else {
|
|
67480
|
-
onChange(
|
|
67481
|
-
cleanedFileList.map(function(file) {
|
|
67482
|
-
return __spreadProps(__spreadValues({}, file), {
|
|
67483
|
-
loading: false
|
|
67484
|
-
});
|
|
67485
|
-
})
|
|
67486
|
-
);
|
|
67487
|
-
}
|
|
67488
|
-
setLoading(false);
|
|
67489
|
-
}), "handleSecondHalfOfUpload");
|
|
67498
|
+
})
|
|
67499
|
+
);
|
|
67500
|
+
}
|
|
67501
|
+
setLoading(false);
|
|
67502
|
+
}),
|
|
67503
|
+
[action2, stableBeforeUpload, onChange, onFieldSubmit, onFileSuccess]
|
|
67504
|
+
);
|
|
67490
67505
|
const isAcceptPromise = useMemo(
|
|
67491
67506
|
() => (__accept == null ? void 0 : __accept.then) || (Array.isArray(__accept) ? __accept.some((acc) => acc == null ? void 0 : acc.then) : false),
|
|
67492
67507
|
[__accept]
|
|
67493
67508
|
);
|
|
67494
|
-
|
|
67495
|
-
|
|
67496
|
-
|
|
67497
|
-
|
|
67498
|
-
|
|
67509
|
+
const _accept = useMemo(() => {
|
|
67510
|
+
if (resolvedAccept) {
|
|
67511
|
+
return resolvedAccept;
|
|
67512
|
+
}
|
|
67513
|
+
if (isAcceptPromise && !resolvedAccept) {
|
|
67514
|
+
return [];
|
|
67515
|
+
}
|
|
67516
|
+
return __accept;
|
|
67517
|
+
}, [__accept, isAcceptPromise, resolvedAccept]);
|
|
67499
67518
|
useEffect(() => {
|
|
67500
67519
|
if (isAcceptPromise) {
|
|
67501
67520
|
setAcceptLoading(true);
|
|
@@ -67508,9 +67527,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67508
67527
|
);
|
|
67509
67528
|
}
|
|
67510
67529
|
}, [__accept, isAcceptPromise]);
|
|
67511
|
-
|
|
67512
|
-
_accept = [];
|
|
67513
|
-
}
|
|
67530
|
+
let dropzoneDisabled = disabled;
|
|
67514
67531
|
if (acceptLoading)
|
|
67515
67532
|
dropzoneDisabled = true;
|
|
67516
67533
|
const accept = useMemo(
|
|
@@ -67735,7 +67752,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67735
67752
|
style: { fontSize: 11, marginBottom: 5 }
|
|
67736
67753
|
},
|
|
67737
67754
|
advancedAccept && !acceptLoading ? /* @__PURE__ */ React__default.createElement("div", null, "Accepts ", /* @__PURE__ */ React__default.createElement("span", null, advancedAccept.map((acc, i) => {
|
|
67738
|
-
const
|
|
67755
|
+
const disabled2 = !(acc.description || acc.exampleFile || acc.exampleFiles);
|
|
67739
67756
|
const PopOrTooltip = acc.exampleFiles ? Popover : Tooltip;
|
|
67740
67757
|
const hasDownload = acc.exampleFile || acc.exampleFiles;
|
|
67741
67758
|
const CustomTag = !hasDownload ? "span" : "a";
|
|
@@ -67744,7 +67761,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67744
67761
|
{
|
|
67745
67762
|
key: i,
|
|
67746
67763
|
interactionKind: "hover",
|
|
67747
|
-
disabled,
|
|
67764
|
+
disabled: disabled2,
|
|
67748
67765
|
modifiers: popoverOverflowModifiers,
|
|
67749
67766
|
content: acc.exampleFiles ? /* @__PURE__ */ React__default.createElement(Menu, null, acc.exampleFiles.map(
|
|
67750
67767
|
({ description, subtext, exampleFile, icon }, i2) => /* @__PURE__ */ React__default.createElement(
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from "react";
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
export const EditableCell = ({
|
|
4
|
-
value,
|
|
5
|
-
setValue,
|
|
6
4
|
cancelEdit,
|
|
7
5
|
dataTest,
|
|
8
6
|
finishEdit,
|
|
9
|
-
isNumeric
|
|
7
|
+
isNumeric,
|
|
8
|
+
initialValue
|
|
10
9
|
}) => {
|
|
10
|
+
const [value, setValue] = useState(initialValue);
|
|
11
11
|
const inputRef = useRef(null);
|
|
12
12
|
|
|
13
13
|
useEffect(() => {
|
package/src/DataTable/index.js
CHANGED
|
@@ -67,9 +67,9 @@ import {
|
|
|
67
67
|
handleCopyTable,
|
|
68
68
|
isEntityClean,
|
|
69
69
|
PRIMARY_SELECTED_VAL,
|
|
70
|
-
removeCleanRows
|
|
71
|
-
useDeepEqualMemo
|
|
70
|
+
removeCleanRows
|
|
72
71
|
} from "./utils";
|
|
72
|
+
import { useDeepEqualMemo } from "../utils/hooks";
|
|
73
73
|
import rowClick, {
|
|
74
74
|
changeSelectedEntities,
|
|
75
75
|
finalizeSelection
|