@teselagen/ui 0.3.42 → 0.3.44
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/index.cjs.js +221 -232
- package/index.es.js +221 -232
- package/package.json +1 -1
- package/src/DataTable/index.js +51 -10
- package/src/UploadCsvWizard.js +1 -0
package/package.json
CHANGED
package/src/DataTable/index.js
CHANGED
|
@@ -96,6 +96,10 @@ const IS_LINUX = window.navigator.platform.toLowerCase().search("linux") > -1;
|
|
|
96
96
|
class DataTable extends React.Component {
|
|
97
97
|
constructor(props) {
|
|
98
98
|
super(props);
|
|
99
|
+
if (this.props.helperProp) {
|
|
100
|
+
this.props.helperProp.addEditableTableEntities =
|
|
101
|
+
this.addEditableTableEntities;
|
|
102
|
+
}
|
|
99
103
|
this.hotkeyEnabler = withHotkeys({
|
|
100
104
|
moveUpARow: {
|
|
101
105
|
global: false,
|
|
@@ -434,7 +438,8 @@ class DataTable extends React.Component {
|
|
|
434
438
|
reduxFormCellValidation
|
|
435
439
|
} = this.props;
|
|
436
440
|
const { newEnts, validationErrors } = this.formatAndValidateEntities(
|
|
437
|
-
initialEntities ||
|
|
441
|
+
initialEntities ||
|
|
442
|
+
(entities && entities.length ? entities : _origEntities)
|
|
438
443
|
);
|
|
439
444
|
change("reduxFormEntities", newEnts);
|
|
440
445
|
const toKeep = {};
|
|
@@ -896,7 +901,7 @@ class DataTable extends React.Component {
|
|
|
896
901
|
|
|
897
902
|
getRowCopyText = (rowEl, { specificColumn } = {}) => {
|
|
898
903
|
//takes in a row element
|
|
899
|
-
if (!rowEl) return;
|
|
904
|
+
if (!rowEl) return [];
|
|
900
905
|
const textContent = [];
|
|
901
906
|
const jsonText = [];
|
|
902
907
|
|
|
@@ -1703,16 +1708,23 @@ class DataTable extends React.Component {
|
|
|
1703
1708
|
additionalBodyEl={
|
|
1704
1709
|
isCellEditable &&
|
|
1705
1710
|
!onlyShowRowsWErrors && (
|
|
1706
|
-
<
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
+
<div
|
|
1712
|
+
style={{
|
|
1713
|
+
width: "100%",
|
|
1714
|
+
display: "flex",
|
|
1715
|
+
justifyContent: "center"
|
|
1711
1716
|
}}
|
|
1712
|
-
minimal
|
|
1713
1717
|
>
|
|
1714
|
-
|
|
1715
|
-
|
|
1718
|
+
<Button
|
|
1719
|
+
icon="add"
|
|
1720
|
+
onClick={() => {
|
|
1721
|
+
this.insertRows({ numRows: 10, appendToBottom: true });
|
|
1722
|
+
}}
|
|
1723
|
+
minimal
|
|
1724
|
+
>
|
|
1725
|
+
Add 10 Rows
|
|
1726
|
+
</Button>
|
|
1727
|
+
</div>
|
|
1716
1728
|
)
|
|
1717
1729
|
}
|
|
1718
1730
|
className={classNames({
|
|
@@ -2960,6 +2972,35 @@ class DataTable extends React.Component {
|
|
|
2960
2972
|
return stringText;
|
|
2961
2973
|
};
|
|
2962
2974
|
|
|
2975
|
+
addEditableTableEntities = incomingEnts => {
|
|
2976
|
+
const { entities = [], reduxFormCellValidation } = computePresets(
|
|
2977
|
+
this.props
|
|
2978
|
+
);
|
|
2979
|
+
|
|
2980
|
+
this.updateEntitiesHelper(entities, entities => {
|
|
2981
|
+
const newEntities = incomingEnts.map(e => ({
|
|
2982
|
+
...e,
|
|
2983
|
+
id: e.id || nanoid(),
|
|
2984
|
+
_isClean: false
|
|
2985
|
+
}));
|
|
2986
|
+
|
|
2987
|
+
const { newEnts, validationErrors } = this.formatAndValidateEntities(
|
|
2988
|
+
newEntities,
|
|
2989
|
+
{
|
|
2990
|
+
useDefaultValues: true,
|
|
2991
|
+
indexToStartAt: entities.length
|
|
2992
|
+
}
|
|
2993
|
+
);
|
|
2994
|
+
|
|
2995
|
+
entities.splice(entities.length, 0, ...newEnts);
|
|
2996
|
+
|
|
2997
|
+
this.updateValidation(entities, {
|
|
2998
|
+
...reduxFormCellValidation,
|
|
2999
|
+
...validationErrors
|
|
3000
|
+
});
|
|
3001
|
+
});
|
|
3002
|
+
};
|
|
3003
|
+
|
|
2963
3004
|
insertRows = ({ above, numRows = 1, appendToBottom } = {}) => {
|
|
2964
3005
|
const { entities = [], reduxFormCellValidation } = computePresets(
|
|
2965
3006
|
this.props
|
package/src/UploadCsvWizard.js
CHANGED
|
@@ -587,6 +587,7 @@ export const PreviewCsvData = observer(function (props) {
|
|
|
587
587
|
isSimple
|
|
588
588
|
keepDirtyOnReinitialize
|
|
589
589
|
isCellEditable
|
|
590
|
+
initialEntities={(initialEntities ? initialEntities : data) || []}
|
|
590
591
|
entities={(initialEntities ? initialEntities : data) || []}
|
|
591
592
|
schema={validateAgainstSchema}
|
|
592
593
|
></DataTable>
|