@teselagen/ui 0.4.13 → 0.4.15

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.
Files changed (69) hide show
  1. package/DataTable/ColumnFilterMenu.d.ts +14 -0
  2. package/DataTable/DropdownCell.d.ts +8 -0
  3. package/DataTable/EditabelCell.d.ts +10 -0
  4. package/DataTable/index.d.ts +0 -5
  5. package/DataTable/utils/formatPasteData.d.ts +5 -0
  6. package/DataTable/utils/getAllRows.d.ts +1 -0
  7. package/DataTable/utils/getCellCopyText.d.ts +1 -0
  8. package/DataTable/utils/getCellInfo.d.ts +17 -0
  9. package/DataTable/utils/getFieldPathToField.d.ts +1 -0
  10. package/DataTable/utils/getIdOrCodeOrIndex.d.ts +1 -2
  11. package/DataTable/utils/getLastSelectedEntity.d.ts +1 -0
  12. package/DataTable/utils/getNewEntToSelect.d.ts +6 -0
  13. package/DataTable/utils/getRowCopyText.d.ts +3 -0
  14. package/DataTable/utils/handleCopyColumn.d.ts +1 -0
  15. package/DataTable/utils/handleCopyHelper.d.ts +1 -0
  16. package/DataTable/utils/handleCopyRows.d.ts +5 -0
  17. package/DataTable/utils/index.d.ts +21 -0
  18. package/DataTable/utils/isBottomRightCornerOfRectangle.d.ts +8 -0
  19. package/DataTable/utils/isEntityClean.d.ts +1 -0
  20. package/DataTable/utils/removeCleanRows.d.ts +4 -0
  21. package/DataTable/utils/rowClick.d.ts +10 -2
  22. package/DataTable/utils/utils.d.ts +5 -0
  23. package/FormComponents/Uploader.d.ts +29 -1
  24. package/README.md +18 -0
  25. package/index.cjs.js +14320 -12997
  26. package/index.d.ts +2 -2
  27. package/index.es.js +14335 -13012
  28. package/package.json +5 -4
  29. package/src/DataTable/CellDragHandle.js +6 -7
  30. package/src/DataTable/ColumnFilterMenu.js +60 -0
  31. package/src/DataTable/DropdownCell.js +61 -0
  32. package/src/DataTable/EditabelCell.js +55 -0
  33. package/src/DataTable/PagingTool.js +1 -1
  34. package/src/DataTable/SortableColumns.js +53 -18
  35. package/src/DataTable/dataTableEnhancer.js +1 -1
  36. package/src/DataTable/index.js +385 -759
  37. package/src/DataTable/utils/formatPasteData.js +16 -0
  38. package/src/DataTable/utils/getAllRows.js +11 -0
  39. package/src/DataTable/utils/getCellCopyText.js +7 -0
  40. package/src/DataTable/utils/getCellInfo.js +36 -0
  41. package/src/DataTable/utils/getFieldPathToField.js +7 -0
  42. package/src/DataTable/utils/getIdOrCodeOrIndex.js +1 -1
  43. package/src/DataTable/utils/getLastSelectedEntity.js +11 -0
  44. package/src/DataTable/utils/getNewEntToSelect.js +25 -0
  45. package/src/DataTable/utils/getRowCopyText.js +28 -0
  46. package/src/DataTable/utils/handleCopyColumn.js +21 -0
  47. package/src/DataTable/utils/handleCopyHelper.js +15 -0
  48. package/src/DataTable/utils/handleCopyRows.js +23 -0
  49. package/src/DataTable/utils/index.js +51 -0
  50. package/src/DataTable/utils/isBottomRightCornerOfRectangle.js +20 -0
  51. package/src/DataTable/utils/isEntityClean.js +15 -0
  52. package/src/DataTable/utils/removeCleanRows.js +22 -0
  53. package/src/DataTable/utils/rowClick.js +7 -4
  54. package/src/DataTable/utils/selection.js +1 -1
  55. package/src/DataTable/utils/utils.js +37 -0
  56. package/src/DataTable/validateTableWideErrors.js +1 -1
  57. package/src/FillWindow.js +2 -3
  58. package/src/FormComponents/Uploader.js +400 -400
  59. package/src/FormComponents/tryToMatchSchemas.js +0 -6
  60. package/src/UploadCsvWizard.js +312 -371
  61. package/src/index.js +3 -3
  62. package/src/showDialogOnDocBody.js +5 -9
  63. package/src/useDialog.js +7 -4
  64. package/src/utils/menuUtils.js +3 -2
  65. package/src/utils/renderOnDoc.js +8 -5
  66. package/style.css +7 -7
  67. package/utils/menuUtils.d.ts +7 -0
  68. package/utils/renderOnDoc.d.ts +1 -1
  69. package/src/ExcelCell.js +0 -38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
4
4
  "main": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -16,6 +16,10 @@
16
16
  "@blueprintjs/datetime": "3.23.19",
17
17
  "@blueprintjs/icons": "3.33.0",
18
18
  "@blueprintjs/select": "3.18.11",
19
+ "@dnd-kit/core": "^6.1.0",
20
+ "@dnd-kit/modifiers": "^7.0.0",
21
+ "@dnd-kit/sortable": "^8.0.0",
22
+ "@dnd-kit/utilities": "3.2.2",
19
23
  "@teselagen/react-table": "6.10.16",
20
24
  "bluebird": "3.7.2",
21
25
  "buffer": "5.7.1",
@@ -30,10 +34,8 @@
30
34
  "immer": "^9.0.15",
31
35
  "is-mobile": "^3.0.0",
32
36
  "jszip": "^3.10.1",
33
- "lodash": "4.17.21",
34
37
  "lodash-es": "^4.17.21",
35
38
  "math-expression-evaluator": "^1.3.7",
36
- "mobx": "^6.10.2",
37
39
  "mobx-react": "^9.0.1",
38
40
  "mock-fs": "5.2.0",
39
41
  "nanoid": "^4.0.0",
@@ -47,7 +49,6 @@
47
49
  "react-redux": "^8.0.5",
48
50
  "react-rnd": "^10.2.4",
49
51
  "react-router-dom": "^4.3.1",
50
- "react-sortable-hoc": "^0.6.8",
51
52
  "react-transition-group": "^2.4.0",
52
53
  "recompose": "npm:react-recompose@0.31.1",
53
54
  "redux": "^4.1.2",
@@ -1,21 +1,20 @@
1
1
  import { flatMap } from "lodash-es";
2
2
  import { forEach } from "lodash-es";
3
3
  import React, { useRef } from "react";
4
- import ReactDOM from "react-dom";
5
4
 
6
- export function CellDragHandle({
5
+ export const CellDragHandle = ({
7
6
  thisTable,
8
7
  onDragEnd,
9
8
  cellId,
10
9
  isSelectionARectangle
11
- }) {
10
+ }) => {
12
11
  const xStart = useRef(0);
13
12
  const timeoutkey = useRef();
14
13
  const rowsToSelect = useRef();
15
14
  const rectangleCellPaths = useRef();
16
15
 
17
16
  const handleDrag = useRef(e => {
18
- const table = ReactDOM.findDOMNode(thisTable).querySelector(".rt-table");
17
+ const table = thisTable.querySelector(".rt-table");
19
18
  const trs = table.querySelectorAll(`.rt-tr-group.with-row-data`);
20
19
  const [rowId, path] = cellId.split(":");
21
20
  const selectedTr = table.querySelector(
@@ -83,7 +82,7 @@ export function CellDragHandle({
83
82
 
84
83
  const mouseup = useRef(() => {
85
84
  clearTimeout(timeoutkey.current);
86
- const table = ReactDOM.findDOMNode(thisTable);
85
+ const table = thisTable;
87
86
  const trs = table.querySelectorAll(`.rt-tr-group.with-row-data`);
88
87
  const [, path] = cellId.split(":");
89
88
  //remove the dashed borders
@@ -126,6 +125,6 @@ export function CellDragHandle({
126
125
  document.addEventListener("mouseup", mouseup.current, false);
127
126
  }}
128
127
  className="cellDragHandle"
129
- ></div>
128
+ />
130
129
  );
131
- }
130
+ };
@@ -0,0 +1,60 @@
1
+ import React, { useState } from "react";
2
+ import classNames from "classnames";
3
+ import { Icon, Popover } from "@blueprintjs/core";
4
+
5
+ export const ColumnFilterMenu = ({
6
+ addFilters,
7
+ compact,
8
+ currentFilter,
9
+ currentParams,
10
+ dataType,
11
+ extraCompact,
12
+ filterActiveForColumn,
13
+ FilterMenu,
14
+ filterOn,
15
+ removeSingleFilter,
16
+ schemaForField,
17
+ setNewParams
18
+ }) => {
19
+ const [columnFilterMenuOpen, setColumnFilterMenuOpen] = useState(false);
20
+ return (
21
+ <Popover
22
+ position="bottom"
23
+ onClose={() => {
24
+ setColumnFilterMenuOpen(false);
25
+ }}
26
+ isOpen={columnFilterMenuOpen}
27
+ modifiers={{
28
+ preventOverflow: { enabled: true },
29
+ hide: { enabled: false },
30
+ flip: { enabled: false }
31
+ }}
32
+ >
33
+ <Icon
34
+ style={{ marginLeft: 5 }}
35
+ icon="filter"
36
+ iconSize={extraCompact ? 14 : undefined}
37
+ onClick={() => {
38
+ setColumnFilterMenuOpen(!columnFilterMenuOpen);
39
+ }}
40
+ className={classNames("tg-filter-menu-button", {
41
+ "tg-active-filter": !!filterActiveForColumn
42
+ })}
43
+ />
44
+ <FilterMenu
45
+ addFilters={addFilters}
46
+ compact={compact}
47
+ currentFilter={currentFilter}
48
+ currentParams={currentParams}
49
+ dataType={dataType}
50
+ filterOn={filterOn}
51
+ removeSingleFilter={removeSingleFilter}
52
+ schemaForField={schemaForField}
53
+ setNewParams={setNewParams}
54
+ togglePopover={() => {
55
+ setColumnFilterMenuOpen(false);
56
+ }}
57
+ />
58
+ </Popover>
59
+ );
60
+ };
@@ -0,0 +1,61 @@
1
+ import React, { useState } from "react";
2
+ import classNames from "classnames";
3
+ import TgSelect from "../TgSelect";
4
+
5
+ export const DropdownCell = ({
6
+ options,
7
+ isMulti,
8
+ initialValue,
9
+ finishEdit,
10
+ cancelEdit,
11
+ dataTest
12
+ }) => {
13
+ const [v, setV] = useState(
14
+ isMulti
15
+ ? initialValue.split(",").map(v => ({ value: v, label: v }))
16
+ : initialValue
17
+ );
18
+ return (
19
+ <div
20
+ className={classNames("tg-dropdown-cell-edit-container", {
21
+ "tg-dropdown-cell-edit-container-multi": isMulti
22
+ })}
23
+ >
24
+ <TgSelect
25
+ small
26
+ multi={isMulti}
27
+ autoOpen
28
+ value={v}
29
+ onChange={val => {
30
+ if (isMulti) {
31
+ setV(val);
32
+ return;
33
+ }
34
+ finishEdit(val ? val.value : null);
35
+ }}
36
+ {...dataTest}
37
+ popoverProps={{
38
+ onClose: e => {
39
+ if (isMulti) {
40
+ if (e && e.key === "Escape") {
41
+ cancelEdit();
42
+ } else {
43
+ finishEdit(
44
+ v && v.map
45
+ ? v
46
+ .map(v => v.value)
47
+ .filter(v => v)
48
+ .join(",")
49
+ : v
50
+ );
51
+ }
52
+ } else {
53
+ cancelEdit();
54
+ }
55
+ }
56
+ }}
57
+ options={options.map(value => ({ label: value, value }))}
58
+ />
59
+ </div>
60
+ );
61
+ };
@@ -0,0 +1,55 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+
3
+ export const EditableCell = ({
4
+ cancelEdit,
5
+ dataTest,
6
+ finishEdit,
7
+ initialValue,
8
+ isEditableCellInitialValue,
9
+ isNumeric,
10
+ shouldSelectAll,
11
+ stopSelectAll
12
+ }) => {
13
+ const [value, setValue] = useState(initialValue);
14
+ const inputRef = useRef(null);
15
+
16
+ useEffect(() => {
17
+ if (inputRef.current) {
18
+ inputRef.current.focus();
19
+ if (isEditableCellInitialValue && !isNumeric) {
20
+ inputRef.current.selectionStart = inputRef.current.value.length;
21
+ inputRef.current.selectionEnd = inputRef.current.value.length;
22
+ } else if (shouldSelectAll) {
23
+ inputRef.current.select();
24
+ stopSelectAll();
25
+ }
26
+ }
27
+ }, [isEditableCellInitialValue, isNumeric, shouldSelectAll, stopSelectAll]);
28
+
29
+ return (
30
+ <input
31
+ style={{
32
+ border: 0,
33
+ width: "95%",
34
+ fontSize: 12,
35
+ background: "none"
36
+ }}
37
+ ref={inputRef}
38
+ {...dataTest}
39
+ autoFocus
40
+ onKeyDown={e => {
41
+ if (e.key === "Enter") {
42
+ finishEdit(value);
43
+ e.stopPropagation();
44
+ } else if (e.key === "Escape") {
45
+ e.stopPropagation();
46
+ cancelEdit();
47
+ }
48
+ }}
49
+ onBlur={() => finishEdit(value)}
50
+ onChange={e => setValue(e.target.value)}
51
+ type={isNumeric ? "number" : undefined}
52
+ value={value}
53
+ />
54
+ );
55
+ };
@@ -5,7 +5,7 @@ import { noop, get, toInteger } from "lodash-es";
5
5
  import { Button, Classes } from "@blueprintjs/core";
6
6
  import { onEnterOrBlurHelper } from "../utils/handlerHelpers";
7
7
  import { defaultPageSizes } from "./utils/queryParams";
8
- import getIdOrCodeOrIndex from "./utils/getIdOrCodeOrIndex";
8
+ import { getIdOrCodeOrIndex } from "./utils";
9
9
 
10
10
  function PagingInput({ disabled, onBlur, defaultPage }) {
11
11
  const [page, setPage] = useState(defaultPage);
@@ -1,24 +1,62 @@
1
1
  import React, { Component } from "react";
2
- import { SortableContainer } from "react-sortable-hoc";
2
+ import { MouseSensor, useSensor, useSensors, DndContext } from "@dnd-kit/core";
3
+ import {
4
+ SortableContext,
5
+ horizontalListSortingStrategy
6
+ } from "@dnd-kit/sortable";
7
+ import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
3
8
 
4
9
  function CustomTheadComponent(props) {
5
10
  const headerColumns = props.children.props.children;
11
+ const mouseSensor = useSensor(MouseSensor, {
12
+ activationConstraint: {
13
+ distance: 10
14
+ }
15
+ });
16
+
17
+ const sensors = useSensors(mouseSensor);
18
+ function handleDragEnd(event) {
19
+ const { active, over } = event;
20
+
21
+ if (!over || !active) {
22
+ return;
23
+ }
24
+
25
+ if (active.id === over.id) {
26
+ return;
27
+ }
28
+ props.onSortEnd({
29
+ oldIndex: parseInt(active.id),
30
+ newIndex: parseInt(over.id)
31
+ });
32
+ }
33
+
6
34
  return (
7
- <div className={"rt-thead " + props.className} style={props.style}>
8
- <div className="rt-tr">
9
- {headerColumns.map(column => {
10
- // if a column is marked as immovable just return regular column
11
- if (column.props.immovable === "true") return column;
12
- // keeps track of hidden columns here so columnIndex might not equal i
13
- return column;
14
- })}
15
- </div>
16
- </div>
35
+ <DndContext
36
+ onDragStart={props.onSortStart}
37
+ onDragEnd={handleDragEnd}
38
+ modifiers={[restrictToHorizontalAxis]}
39
+ sensors={sensors}
40
+ >
41
+ <SortableContext
42
+ items={headerColumns.map((_item, index) => `${index}`)}
43
+ strategy={horizontalListSortingStrategy}
44
+ >
45
+ <div className={"rt-thead " + props.className} style={props.style}>
46
+ <div className="rt-tr">
47
+ {headerColumns.map(column => {
48
+ // if a column is marked as immovable just return regular column
49
+ if (column.props.immovable === "true") return column;
50
+ // keeps track of hidden columns here so columnIndex might not equal i
51
+ return column;
52
+ })}
53
+ </div>
54
+ </div>
55
+ </SortableContext>
56
+ </DndContext>
17
57
  );
18
58
  }
19
59
 
20
- const SortableCustomTheadComponent = SortableContainer(CustomTheadComponent);
21
-
22
60
  class SortableColumns extends Component {
23
61
  shouldCancelStart = e => {
24
62
  const className = e.target.className;
@@ -43,15 +81,12 @@ class SortableColumns extends Component {
43
81
 
44
82
  render() {
45
83
  return (
46
- <SortableCustomTheadComponent
84
+ <CustomTheadComponent
47
85
  {...this.props}
48
- lockAxis="x"
49
86
  onSortStart={this.onSortStart}
50
- axis="x"
51
- distance={10}
87
+ onSortEnd={this.onSortEnd}
52
88
  helperClass="above-dialog"
53
89
  shouldCancelStart={this.shouldCancelStart}
54
- onSortEnd={this.onSortEnd}
55
90
  />
56
91
  );
57
92
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { reduxForm } from "redux-form";
8
8
 
9
- import { arrayMove } from "react-sortable-hoc";
9
+ import { arrayMove } from "@dnd-kit/sortable";
10
10
  import { toArray, keyBy, get } from "lodash-es";
11
11
  import { withProps, withState, branch, compose } from "recompose";
12
12
  import withTableParams from "../DataTable/utils/withTableParams";