@teselagen/ui 0.3.43 → 0.3.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.3.43",
3
+ "version": "0.3.45",
4
4
  "main": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -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,
@@ -897,7 +901,7 @@ class DataTable extends React.Component {
897
901
 
898
902
  getRowCopyText = (rowEl, { specificColumn } = {}) => {
899
903
  //takes in a row element
900
- if (!rowEl) return;
904
+ if (!rowEl) return [];
901
905
  const textContent = [];
902
906
  const jsonText = [];
903
907
 
@@ -1704,16 +1708,23 @@ class DataTable extends React.Component {
1704
1708
  additionalBodyEl={
1705
1709
  isCellEditable &&
1706
1710
  !onlyShowRowsWErrors && (
1707
- <Button
1708
- icon="add"
1709
- style={{ marginTop: "auto" }}
1710
- onClick={() => {
1711
- this.insertRows({ numRows: 10, appendToBottom: true });
1711
+ <div
1712
+ style={{
1713
+ width: "100%",
1714
+ display: "flex",
1715
+ justifyContent: "center"
1712
1716
  }}
1713
- minimal
1714
1717
  >
1715
- Add 10 Rows
1716
- </Button>
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>
1717
1728
  )
1718
1729
  }
1719
1730
  className={classNames({
@@ -2961,6 +2972,35 @@ class DataTable extends React.Component {
2961
2972
  return stringText;
2962
2973
  };
2963
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
+
2964
3004
  insertRows = ({ above, numRows = 1, appendToBottom } = {}) => {
2965
3005
  const { entities = [], reduxFormCellValidation } = computePresets(
2966
3006
  this.props
@@ -457,9 +457,9 @@ body:not(.drag-active)
457
457
  .tg-dropdown-cell-edit-container .bp3-tag-input .bp3-button {
458
458
  margin: 0;
459
459
  }
460
- .tg-dropdown-cell-edit-container .bp3-tag-input .bp3-tag-input-values > * {
460
+ /* .tg-dropdown-cell-edit-container .bp3-tag-input .bp3-tag-input-values > * {
461
461
  margin-bottom: 0;
462
- }
462
+ } */
463
463
  .tg-dropdown-cell-edit-container:not(.tg-dropdown-cell-edit-container-multi)
464
464
  .bp3-tag-input {
465
465
  min-height: 0;
@@ -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>
@@ -1,6 +1,22 @@
1
1
  import tippy, { followCursor } from "tippy.js";
2
2
  import "tippy.js/dist/tippy.css";
3
3
 
4
+ let isDragging = false;
5
+ let canSetDragging = false;
6
+ document.addEventListener("mousedown", () => {
7
+ canSetDragging = true;
8
+ isDragging = false;
9
+ });
10
+ document.addEventListener("mousemove", () => {
11
+ if (canSetDragging) {
12
+ isDragging = true;
13
+ }
14
+ });
15
+ document.addEventListener("mouseup", () => {
16
+ canSetDragging = false;
17
+ isDragging = false;
18
+ });
19
+
4
20
  let tippys = [];
5
21
  let recentlyHidden = false;
6
22
  let clearMe;
@@ -142,7 +158,11 @@ let clearMe;
142
158
  dataAvoid,
143
159
  dataAvoidBackup
144
160
  };
145
- if (dataTip && !document.body.classList.contains("drag-active")) {
161
+ if (
162
+ dataTip &&
163
+ !document.body.classList.contains("drag-active") &&
164
+ !isDragging
165
+ ) {
146
166
  if (dataTipStop) break;
147
167
 
148
168
  inner(dataTip, el, opts);
package/style.css CHANGED
@@ -9546,9 +9546,9 @@ body:not(.drag-active)
9546
9546
  .tg-dropdown-cell-edit-container .bp3-tag-input .bp3-button {
9547
9547
  margin: 0;
9548
9548
  }
9549
- .tg-dropdown-cell-edit-container .bp3-tag-input .bp3-tag-input-values > * {
9549
+ /* .tg-dropdown-cell-edit-container .bp3-tag-input .bp3-tag-input-values > * {
9550
9550
  margin-bottom: 0;
9551
- }
9551
+ } */
9552
9552
  .tg-dropdown-cell-edit-container:not(.tg-dropdown-cell-edit-container-multi)
9553
9553
  .bp3-tag-input {
9554
9554
  min-height: 0;