@teselagen/ui 0.9.6 → 0.9.7
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/EditabelCell.d.ts +7 -0
- package/DataTable/ReactTable.d.ts +78 -0
- package/DataTable/defaultProps.d.ts +43 -0
- package/DataTable/index.d.ts +3 -3
- package/DataTable/utils/computePresets.d.ts +1 -0
- package/DataTable/utils/types/Entity.d.ts +9 -0
- package/DataTable/utils/types/Field.d.ts +4 -0
- package/DataTable/utils/types/OrderBy.d.ts +11 -0
- package/DataTable/utils/types/Schema.d.ts +4 -0
- package/DataTable/utils/useDeepEqualMemo.d.ts +1 -0
- package/DataTable/utils/useHotKeysWrapper.d.ts +29 -0
- package/DataTable/utils/useTableParams.d.ts +49 -0
- package/index.cjs.js +22410 -22287
- package/index.es.js +22462 -22339
- package/package.json +1 -2
- package/src/DataTable/Columns.jsx +945 -0
- package/src/DataTable/EditabelCell.js +44 -0
- package/src/DataTable/EditabelCell.jsx +44 -0
- package/src/DataTable/PagingTool.js +2 -2
- package/src/DataTable/ReactTable.js +738 -0
- package/src/DataTable/RenderCell.jsx +191 -0
- package/src/DataTable/defaultProps.js +45 -0
- package/src/DataTable/index.js +217 -1203
- package/src/DataTable/utils/computePresets.js +42 -0
- package/src/DataTable/utils/convertSchema.ts +79 -0
- package/src/DataTable/utils/formatPasteData.ts +34 -0
- package/src/DataTable/utils/getAllRows.ts +11 -0
- package/src/DataTable/utils/getCellCopyText.ts +7 -0
- package/src/DataTable/utils/getCellInfo.ts +46 -0
- package/src/DataTable/utils/getFieldPathToField.ts +10 -0
- package/src/DataTable/utils/getIdOrCodeOrIndex.ts +14 -0
- package/src/DataTable/utils/getLastSelectedEntity.ts +15 -0
- package/src/DataTable/utils/getNewEntToSelect.ts +32 -0
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.ts +35 -0
- package/src/DataTable/utils/isBottomRightCornerOfRectangle.ts +27 -0
- package/src/DataTable/utils/isEntityClean.ts +15 -0
- package/src/DataTable/utils/primarySelectedValue.ts +1 -0
- package/src/DataTable/utils/removeCleanRows.ts +26 -0
- package/src/DataTable/utils/selection.ts +11 -0
- package/src/DataTable/utils/types/Entity.ts +13 -0
- package/src/DataTable/utils/types/Field.ts +4 -0
- package/src/DataTable/utils/types/OrderBy.ts +15 -0
- package/src/DataTable/utils/types/Schema.ts +5 -0
- package/src/DataTable/utils/useDeepEqualMemo.js +10 -0
- package/src/DataTable/utils/useHotKeysWrapper.js +395 -0
- package/src/DataTable/utils/useTableEntities.ts +60 -0
- package/src/DataTable/utils/useTableParams.js +361 -0
- package/src/DataTable/utils/utils.ts +39 -0
- package/src/DataTable/utils/withTableParams.js +1 -1
- package/src/Timeline/TimelineEvent.tsx +36 -0
- package/src/Timeline/index.tsx +21 -0
- package/src/utils/browserUtils.ts +3 -0
- package/src/utils/determineBlackOrWhiteTextColor.ts +11 -0
- package/src/utils/getTextFromEl.ts +45 -0
- package/src/utils/handlerHelpers.ts +32 -0
- package/src/utils/hooks/index.ts +1 -0
- package/src/utils/hooks/useDeepEqualMemo.ts +10 -0
- package/src/utils/hooks/useStableReference.ts +9 -0
- package/src/utils/hotkeyUtils.tsx +155 -0
- package/src/utils/isBeingCalledExcessively.ts +37 -0
- package/style.css +10537 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useSelector } from "react-redux";
|
|
3
|
+
import { Checkbox, Icon } from "@blueprintjs/core";
|
|
4
|
+
import {
|
|
5
|
+
getIdOrCodeOrIndex,
|
|
6
|
+
isBottomRightCornerOfRectangle,
|
|
7
|
+
PRIMARY_SELECTED_VAL
|
|
8
|
+
} from "./utils";
|
|
9
|
+
import { DropdownCell } from "./DropdownCell";
|
|
10
|
+
import { EditableCell } from "./EditabelCell";
|
|
11
|
+
import { getVals } from "./getVals";
|
|
12
|
+
import { CellDragHandle } from "./CellDragHandle";
|
|
13
|
+
|
|
14
|
+
export const RenderCell = ({
|
|
15
|
+
oldFunc,
|
|
16
|
+
getCopyTextForCell,
|
|
17
|
+
column,
|
|
18
|
+
isCellEditable,
|
|
19
|
+
isEntityDisabled,
|
|
20
|
+
finishCellEdit,
|
|
21
|
+
formName,
|
|
22
|
+
noEllipsis,
|
|
23
|
+
cancelCellEdit,
|
|
24
|
+
getCellHoverText,
|
|
25
|
+
selectedCells,
|
|
26
|
+
isSelectionARectangle,
|
|
27
|
+
startCellEdit,
|
|
28
|
+
tableRef,
|
|
29
|
+
onDragEnd,
|
|
30
|
+
args
|
|
31
|
+
}) => {
|
|
32
|
+
const editingCell = useSelector(
|
|
33
|
+
state => state.form?.[formName]?.values?.reduxFormEditingCell
|
|
34
|
+
);
|
|
35
|
+
const initialValue = useSelector(
|
|
36
|
+
state => state.form?.[formName]?.values?.reduxFormInitialValue
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const [row] = args;
|
|
40
|
+
const rowId = getIdOrCodeOrIndex(row.original, row.index);
|
|
41
|
+
const cellId = `${rowId}:${row.column.path}`;
|
|
42
|
+
const isEditingCell = editingCell === cellId;
|
|
43
|
+
let val = oldFunc(...args);
|
|
44
|
+
const oldVal = val;
|
|
45
|
+
const text = getCopyTextForCell(val, row, column);
|
|
46
|
+
const dataTest = {
|
|
47
|
+
"data-test": "tgCell_" + column.path
|
|
48
|
+
};
|
|
49
|
+
const fullValue = row.original?.[row.column.path];
|
|
50
|
+
|
|
51
|
+
if (isEditingCell) {
|
|
52
|
+
if (column.type === "genericSelect") {
|
|
53
|
+
const GenericSelectComp = column.GenericSelectComp;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<GenericSelectComp
|
|
57
|
+
rowId={rowId}
|
|
58
|
+
fullValue={fullValue}
|
|
59
|
+
initialValue={text}
|
|
60
|
+
{...dataTest}
|
|
61
|
+
finishEdit={(newVal, doNotStopEditing) => {
|
|
62
|
+
finishCellEdit(cellId, newVal, doNotStopEditing);
|
|
63
|
+
}}
|
|
64
|
+
dataTest={dataTest}
|
|
65
|
+
cancelEdit={cancelCellEdit}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (column.type === "dropdown" || column.type === "dropdownMulti") {
|
|
70
|
+
return (
|
|
71
|
+
<DropdownCell
|
|
72
|
+
isMulti={dataTest.isMulti || column.type === "dropdownMulti"}
|
|
73
|
+
initialValue={dataTest.initialValue || text}
|
|
74
|
+
options={getVals(column.values)}
|
|
75
|
+
finishEdit={(newVal, doNotStopEditing) => {
|
|
76
|
+
finishCellEdit(cellId, newVal, doNotStopEditing);
|
|
77
|
+
}}
|
|
78
|
+
dataTest={dataTest}
|
|
79
|
+
cancelEdit={cancelCellEdit}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
return (
|
|
84
|
+
<EditableCell
|
|
85
|
+
dataTest={dataTest}
|
|
86
|
+
cancelEdit={cancelCellEdit}
|
|
87
|
+
isNumeric={column.type === "number"}
|
|
88
|
+
initialValue={initialValue || text}
|
|
89
|
+
finishEdit={newVal => {
|
|
90
|
+
finishCellEdit(cellId, newVal);
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const isBool = column.type === "boolean";
|
|
98
|
+
if (isCellEditable && isBool) {
|
|
99
|
+
val = (
|
|
100
|
+
<Checkbox
|
|
101
|
+
disabled={isEntityDisabled(row.original)}
|
|
102
|
+
className="tg-cell-edit-boolean-checkbox"
|
|
103
|
+
checked={oldVal === "True"}
|
|
104
|
+
onChange={e => {
|
|
105
|
+
const checked = e.target.checked;
|
|
106
|
+
finishCellEdit(cellId, checked);
|
|
107
|
+
}}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
noEllipsis = true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//wrap the original tableColumn.Cell function in another div in order to add a title attribute
|
|
114
|
+
let title = text;
|
|
115
|
+
if (getCellHoverText) title = getCellHoverText(...args);
|
|
116
|
+
else if (column.getTitleAttr) title = column.getTitleAttr(...args);
|
|
117
|
+
const isSelectedCell = selectedCells?.[cellId];
|
|
118
|
+
const {
|
|
119
|
+
isRect,
|
|
120
|
+
selectionGrid,
|
|
121
|
+
lastRowIndex,
|
|
122
|
+
lastCellIndex,
|
|
123
|
+
entityMap,
|
|
124
|
+
pathToIndex
|
|
125
|
+
} = isSelectionARectangle();
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<>
|
|
129
|
+
<div
|
|
130
|
+
style={{
|
|
131
|
+
...(!noEllipsis && {
|
|
132
|
+
textOverflow: "ellipsis",
|
|
133
|
+
overflow: "hidden"
|
|
134
|
+
})
|
|
135
|
+
}}
|
|
136
|
+
{...dataTest}
|
|
137
|
+
className="tg-cell-wrapper"
|
|
138
|
+
data-copy-text={text}
|
|
139
|
+
data-copy-json={JSON.stringify(
|
|
140
|
+
//tnw: eventually we'll parse these back out and use either the fullValue (for the generic selects) or the regular text vals for everything else
|
|
141
|
+
column.type === "genericSelect"
|
|
142
|
+
? {
|
|
143
|
+
__strVal: fullValue,
|
|
144
|
+
__genSelCol: column.path
|
|
145
|
+
}
|
|
146
|
+
: { __strVal: text }
|
|
147
|
+
)}
|
|
148
|
+
title={title || undefined}
|
|
149
|
+
>
|
|
150
|
+
{val}
|
|
151
|
+
</div>
|
|
152
|
+
{isCellEditable &&
|
|
153
|
+
(column.type === "dropdown" ||
|
|
154
|
+
column.type === "dropdownMulti" ||
|
|
155
|
+
column.type === "genericSelect") && (
|
|
156
|
+
<Icon
|
|
157
|
+
icon="caret-down"
|
|
158
|
+
style={{
|
|
159
|
+
position: "absolute",
|
|
160
|
+
right: 5,
|
|
161
|
+
opacity: 0.3
|
|
162
|
+
}}
|
|
163
|
+
className="cell-edit-dropdown"
|
|
164
|
+
onClick={() => {
|
|
165
|
+
startCellEdit(cellId);
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
)}
|
|
169
|
+
|
|
170
|
+
{isSelectedCell &&
|
|
171
|
+
(isRect
|
|
172
|
+
? isBottomRightCornerOfRectangle({
|
|
173
|
+
cellId,
|
|
174
|
+
selectionGrid,
|
|
175
|
+
lastRowIndex,
|
|
176
|
+
lastCellIndex,
|
|
177
|
+
entityMap,
|
|
178
|
+
pathToIndex
|
|
179
|
+
})
|
|
180
|
+
: isSelectedCell === PRIMARY_SELECTED_VAL) && (
|
|
181
|
+
<CellDragHandle
|
|
182
|
+
key={cellId}
|
|
183
|
+
thisTable={tableRef.current.tableRef}
|
|
184
|
+
cellId={cellId}
|
|
185
|
+
isSelectionARectangle={isSelectionARectangle}
|
|
186
|
+
onDragEnd={onDragEnd}
|
|
187
|
+
/>
|
|
188
|
+
)}
|
|
189
|
+
</>
|
|
190
|
+
);
|
|
191
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { noop } from "lodash-es";
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
4
|
+
export default {
|
|
5
|
+
//NOTE: DO NOT SET DEFAULTS HERE FOR PROPS THAT GET COMPUTED AS PART OF PRESET GROUPS IN computePresets
|
|
6
|
+
addFilters: noop,
|
|
7
|
+
className: "",
|
|
8
|
+
clearFilters: noop,
|
|
9
|
+
contextMenu: noop,
|
|
10
|
+
disabled: false,
|
|
11
|
+
entities: [],
|
|
12
|
+
extraClasses: "",
|
|
13
|
+
filters: [],
|
|
14
|
+
isCopyable: true,
|
|
15
|
+
isEntityDisabled: noop,
|
|
16
|
+
isLoading: false,
|
|
17
|
+
isSimple: false,
|
|
18
|
+
isSingleSelect: false,
|
|
19
|
+
maxHeight: 600,
|
|
20
|
+
noHeader: false,
|
|
21
|
+
noSelect: false,
|
|
22
|
+
noUserSelect: false,
|
|
23
|
+
onDeselect: noop,
|
|
24
|
+
onMultiRowSelect: noop,
|
|
25
|
+
onRowClick: noop,
|
|
26
|
+
onRowSelect: noop,
|
|
27
|
+
onSingleRowSelect: noop,
|
|
28
|
+
page: 1,
|
|
29
|
+
pageSize: 10,
|
|
30
|
+
reduxFormExpandedEntityIdMap: {},
|
|
31
|
+
reduxFormSearchInput: "",
|
|
32
|
+
reduxFormSelectedEntityIdMap: {},
|
|
33
|
+
removeSingleFilter: noop,
|
|
34
|
+
resized: [],
|
|
35
|
+
resizePersist: noop,
|
|
36
|
+
setFilter: noop,
|
|
37
|
+
setOrder: noop,
|
|
38
|
+
setPage: noop,
|
|
39
|
+
setPageSize: noop,
|
|
40
|
+
setSearchTerm: noop,
|
|
41
|
+
showCount: false,
|
|
42
|
+
style: {},
|
|
43
|
+
withCheckboxes: false,
|
|
44
|
+
withSort: true
|
|
45
|
+
};
|