@teselagen/ui 0.7.35 → 0.7.36
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/isBeingCalledExcessively.js +1 -0
- package/package.json +1 -1
- package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +0 -5
- package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +0 -2
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +0 -26
- package/src/AdvancedOptions.js +0 -33
- package/src/AdvancedOptions.spec.js +0 -26
- package/src/AssignDefaultsModeContext.js +0 -22
- package/src/AsyncValidateFieldSpinner/index.js +0 -12
- package/src/BlueprintError/index.js +0 -14
- package/src/BounceLoader/index.js +0 -16
- package/src/BounceLoader/style.css +0 -45
- package/src/CollapsibleCard/index.js +0 -68
- package/src/CollapsibleCard/style.css +0 -23
- package/src/DNALoader/index.js +0 -20
- package/src/DNALoader/style.css +0 -251
- package/src/DataTable/CellDragHandle.js +0 -132
- package/src/DataTable/ColumnFilterMenu.js +0 -62
- package/src/DataTable/Columns.js +0 -979
- package/src/DataTable/DisabledLoadingComponent.js +0 -15
- package/src/DataTable/DisplayOptions.js +0 -199
- package/src/DataTable/DropdownCell.js +0 -61
- package/src/DataTable/EditableCell.js +0 -44
- package/src/DataTable/FilterAndSortMenu.js +0 -388
- package/src/DataTable/PagingTool.js +0 -225
- package/src/DataTable/RenderCell.js +0 -191
- package/src/DataTable/SearchBar.js +0 -69
- package/src/DataTable/SortableColumns.js +0 -100
- package/src/DataTable/TableFormTrackerContext.js +0 -10
- package/src/DataTable/ThComponent.js +0 -44
- package/src/DataTable/dataTableEnhancer.js +0 -41
- package/src/DataTable/defaultFormatters.js +0 -32
- package/src/DataTable/defaultValidators.js +0 -40
- package/src/DataTable/editCellHelper.js +0 -44
- package/src/DataTable/getCellVal.js +0 -20
- package/src/DataTable/getVals.js +0 -8
- package/src/DataTable/index.js +0 -3209
- package/src/DataTable/isTruthy.js +0 -12
- package/src/DataTable/isValueEmpty.js +0 -3
- package/src/DataTable/style.css +0 -608
- package/src/DataTable/utils/convertSchema.js +0 -69
- package/src/DataTable/utils/filterLocalEntitiesToHasura.js +0 -236
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +0 -587
- package/src/DataTable/utils/formatPasteData.js +0 -16
- package/src/DataTable/utils/getAllRows.js +0 -11
- package/src/DataTable/utils/getCellCopyText.js +0 -7
- package/src/DataTable/utils/getCellInfo.js +0 -36
- package/src/DataTable/utils/getFieldPathToField.js +0 -7
- package/src/DataTable/utils/getIdOrCodeOrIndex.js +0 -9
- package/src/DataTable/utils/getLastSelectedEntity.js +0 -11
- package/src/DataTable/utils/getNewEntToSelect.js +0 -25
- package/src/DataTable/utils/getRowCopyText.js +0 -28
- package/src/DataTable/utils/getTableConfigFromStorage.js +0 -5
- package/src/DataTable/utils/handleCopyColumn.js +0 -21
- package/src/DataTable/utils/handleCopyHelper.js +0 -15
- package/src/DataTable/utils/handleCopyRows.js +0 -23
- package/src/DataTable/utils/handleCopyTable.js +0 -16
- package/src/DataTable/utils/index.js +0 -55
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -26
- package/src/DataTable/utils/isBottomRightCornerOfRectangle.js +0 -20
- package/src/DataTable/utils/isEntityClean.js +0 -15
- package/src/DataTable/utils/primarySelectedValue.js +0 -1
- package/src/DataTable/utils/queryParams.js +0 -350
- package/src/DataTable/utils/removeCleanRows.js +0 -22
- package/src/DataTable/utils/rowClick.js +0 -181
- package/src/DataTable/utils/selection.js +0 -8
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +0 -253
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +0 -206
- package/src/DataTable/utils/useTableEntities.js +0 -38
- package/src/DataTable/utils/utils.js +0 -37
- package/src/DataTable/utils/withSelectedEntities.js +0 -65
- package/src/DataTable/utils/withTableParams.js +0 -288
- package/src/DataTable/validateTableWideErrors.js +0 -160
- package/src/DataTable/viewColumn.js +0 -97
- package/src/DialogFooter/index.js +0 -86
- package/src/DialogFooter/style.css +0 -9
- package/src/DropdownButton.js +0 -36
- package/src/FillWindow.css +0 -6
- package/src/FillWindow.js +0 -69
- package/src/FormComponents/FormSeparator.js +0 -9
- package/src/FormComponents/LoadingDots.js +0 -14
- package/src/FormComponents/Uploader.js +0 -1278
- package/src/FormComponents/getNewName.js +0 -31
- package/src/FormComponents/index.js +0 -1266
- package/src/FormComponents/itemUpload.js +0 -84
- package/src/FormComponents/sortify.js +0 -73
- package/src/FormComponents/style.css +0 -275
- package/src/FormComponents/tryToMatchSchemas.js +0 -264
- package/src/FormComponents/utils.js +0 -6
- package/src/HotkeysDialog/index.js +0 -79
- package/src/HotkeysDialog/style.css +0 -54
- package/src/InfoHelper/index.js +0 -78
- package/src/InfoHelper/style.css +0 -7
- package/src/IntentText/index.js +0 -18
- package/src/Loading/index.js +0 -70
- package/src/Loading/style.css +0 -4
- package/src/MatchHeaders.js +0 -234
- package/src/MenuBar/index.js +0 -423
- package/src/MenuBar/style.css +0 -45
- package/src/PromptUnsavedChanges/index.js +0 -38
- package/src/ResizableDraggableDialog/index.js +0 -141
- package/src/ResizableDraggableDialog/style.css +0 -42
- package/src/ScrollToTop/index.js +0 -72
- package/src/SimpleStepViz.js +0 -22
- package/src/Tag.js +0 -112
- package/src/TagSelect/index.js +0 -69
- package/src/TagSelect/style.css +0 -13
- package/src/TgHtmlSelect/index.js +0 -20
- package/src/TgSelect/index.js +0 -537
- package/src/TgSelect/style.css +0 -61
- package/src/TgSuggest/index.js +0 -124
- package/src/Timeline/TimelineEvent.js +0 -31
- package/src/Timeline/index.js +0 -15
- package/src/Timeline/style.css +0 -29
- package/src/UploadCsvWizard.css +0 -4
- package/src/UploadCsvWizard.js +0 -719
- package/src/autoTooltip.js +0 -201
- package/src/constants.js +0 -1
- package/src/customIcons.js +0 -361
- package/src/enhancers/withDialog/index.js +0 -196
- package/src/enhancers/withDialog/tg_modalState.js +0 -47
- package/src/enhancers/withField.js +0 -20
- package/src/enhancers/withFields.js +0 -11
- package/src/enhancers/withLocalStorage.js +0 -11
- package/src/index.js +0 -88
- package/src/rerenderOnWindowResize.js +0 -26
- package/src/showAppSpinner.js +0 -12
- package/src/showConfirmationDialog/index.js +0 -148
- package/src/showDialogOnDocBody.js +0 -33
- package/src/style.css +0 -265
- package/src/throwFormError.js +0 -16
- package/src/toastr.js +0 -148
- package/src/typeToCommonType.js +0 -6
- package/src/useDialog.js +0 -63
- package/src/utils/adHoc.js +0 -10
- package/src/utils/basicHandleActionsWithFullState.js +0 -14
- package/src/utils/browserUtils.js +0 -3
- package/src/utils/combineReducersWithFullState.js +0 -14
- package/src/utils/commandControls.js +0 -82
- package/src/utils/commandUtils.js +0 -112
- package/src/utils/determineBlackOrWhiteTextColor.js +0 -4
- package/src/utils/getDayjsFormatter.js +0 -35
- package/src/utils/getTextFromEl.js +0 -28
- package/src/utils/handlerHelpers.js +0 -24
- package/src/utils/hooks/index.js +0 -1
- package/src/utils/hooks/useDeepEqualMemo.js +0 -15
- package/src/utils/hooks/useStableReference.js +0 -9
- package/src/utils/hotkeyUtils.js +0 -131
- package/src/utils/isBeingCalledExcessively.js +0 -24
- package/src/utils/menuUtils.js +0 -433
- package/src/utils/popoverOverflowModifiers.js +0 -11
- package/src/utils/pureNoFunc.js +0 -31
- package/src/utils/renderOnDoc.js +0 -32
- package/src/utils/showProgressToast.js +0 -22
- package/src/utils/tagUtils.js +0 -45
- package/src/utils/tgFormValues.js +0 -35
- package/src/utils/useTraceUpdate.js +0 -19
- package/src/utils/withSelectTableRecords.js +0 -43
- package/src/utils/withStore.js +0 -10
- package/src/wrapDialog.js +0 -116
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useCallback } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import { noop, get, toInteger } from "lodash-es";
|
|
4
|
-
import { Button, Classes } from "@blueprintjs/core";
|
|
5
|
-
import { onEnterOrBlurHelper } from "../utils/handlerHelpers";
|
|
6
|
-
import { defaultPageSizes } from "./utils/queryParams";
|
|
7
|
-
import { getIdOrCodeOrIndex } from "./utils";
|
|
8
|
-
|
|
9
|
-
function PagingInput({ disabled, onBlur, defaultPage }) {
|
|
10
|
-
const [page, setPage] = useState(defaultPage);
|
|
11
|
-
const defaultValue = useRef(defaultPage);
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (page !== defaultPage && defaultValue.current !== defaultPage) {
|
|
15
|
-
setPage(defaultPage);
|
|
16
|
-
}
|
|
17
|
-
defaultValue.current = defaultPage;
|
|
18
|
-
}, [page, defaultPage]);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<input
|
|
22
|
-
name="page"
|
|
23
|
-
style={{
|
|
24
|
-
marginLeft: 5,
|
|
25
|
-
width: page > 999 ? 65 : page > 99 ? 45 : 35,
|
|
26
|
-
marginRight: 8
|
|
27
|
-
}}
|
|
28
|
-
value={page}
|
|
29
|
-
disabled={disabled}
|
|
30
|
-
onChange={e => {
|
|
31
|
-
setPage(e.target.value);
|
|
32
|
-
}}
|
|
33
|
-
{...onEnterOrBlurHelper(onBlur)}
|
|
34
|
-
className={Classes.INPUT}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Define the functional component and its props
|
|
40
|
-
const PagingTool = ({
|
|
41
|
-
controlled_hasNextPage,
|
|
42
|
-
controlled_onRefresh,
|
|
43
|
-
controlled_page,
|
|
44
|
-
controlled_setPage,
|
|
45
|
-
controlled_setPageSize,
|
|
46
|
-
controlled_total,
|
|
47
|
-
disabled: _disabled,
|
|
48
|
-
disableSetPageSize,
|
|
49
|
-
entities,
|
|
50
|
-
entityCount,
|
|
51
|
-
hideSetPageSize,
|
|
52
|
-
hideTotalPages,
|
|
53
|
-
keepSelectionOnPageChange,
|
|
54
|
-
onRefresh: _onRefresh,
|
|
55
|
-
page: _page,
|
|
56
|
-
pageSize,
|
|
57
|
-
pagingDisabled,
|
|
58
|
-
persistPageSize = noop,
|
|
59
|
-
scrollToTop,
|
|
60
|
-
setPage: _setPage,
|
|
61
|
-
setPageSize: _setPageSize,
|
|
62
|
-
setSelectedEntityIdMap
|
|
63
|
-
}) => {
|
|
64
|
-
const page = controlled_page || _page;
|
|
65
|
-
const total = controlled_total || entityCount;
|
|
66
|
-
const disabled = _disabled || pagingDisabled;
|
|
67
|
-
const onRefresh = controlled_onRefresh || _onRefresh;
|
|
68
|
-
const setPage = controlled_setPage || _setPage;
|
|
69
|
-
const setPageSize = controlled_setPageSize || _setPageSize;
|
|
70
|
-
|
|
71
|
-
const onPageChange = useCallback(() => {
|
|
72
|
-
const record = get(entities, "[0]");
|
|
73
|
-
if (
|
|
74
|
-
!keepSelectionOnPageChange &&
|
|
75
|
-
(!record || !getIdOrCodeOrIndex(record))
|
|
76
|
-
) {
|
|
77
|
-
setSelectedEntityIdMap({});
|
|
78
|
-
}
|
|
79
|
-
scrollToTop();
|
|
80
|
-
}, [
|
|
81
|
-
entities,
|
|
82
|
-
keepSelectionOnPageChange,
|
|
83
|
-
scrollToTop,
|
|
84
|
-
setSelectedEntityIdMap
|
|
85
|
-
]);
|
|
86
|
-
// Define local state
|
|
87
|
-
const [refetching, setRefetching] = useState(false);
|
|
88
|
-
|
|
89
|
-
// Initialize additional page sizes
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
const additionalPageSize =
|
|
92
|
-
window.frontEndConfig && window.frontEndConfig.additionalPageSize
|
|
93
|
-
? [toInteger(window.frontEndConfig.additionalPageSize)]
|
|
94
|
-
: [];
|
|
95
|
-
window.tgPageSizes = [...defaultPageSizes, ...additionalPageSize];
|
|
96
|
-
}, []);
|
|
97
|
-
|
|
98
|
-
// Define event handlers for the component
|
|
99
|
-
const onRefreshHandler = async () => {
|
|
100
|
-
setRefetching(true);
|
|
101
|
-
await onRefresh();
|
|
102
|
-
setRefetching(false);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const setPageHandler = page => {
|
|
106
|
-
setPage(page);
|
|
107
|
-
onPageChange(page);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const setPageSizeHandler = e => {
|
|
111
|
-
const newPageSize = parseInt(e.target.value, 10);
|
|
112
|
-
setPageSize(newPageSize);
|
|
113
|
-
persistPageSize(newPageSize);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const pageBackHandler = () => {
|
|
117
|
-
setPageHandler(parseInt(page, 10) - 1);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const pageForwardHandler = () => {
|
|
121
|
-
setPageHandler(parseInt(page, 10) + 1);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const pageInputBlurHandler = e => {
|
|
125
|
-
const lastPage = Math.ceil(total / pageSize);
|
|
126
|
-
const pageValue = parseInt(e.target.value, 10);
|
|
127
|
-
const selectedPage =
|
|
128
|
-
pageValue > lastPage
|
|
129
|
-
? lastPage
|
|
130
|
-
: pageValue < 1 || isNaN(pageValue)
|
|
131
|
-
? 1
|
|
132
|
-
: pageValue;
|
|
133
|
-
setPageHandler(selectedPage);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// Define rendering logic
|
|
137
|
-
const pageStart = (page - 1) * pageSize + 1;
|
|
138
|
-
if (pageStart < 0) throw new Error("We should never have page be <0");
|
|
139
|
-
const backEnabled = page - 1 > 0;
|
|
140
|
-
const forwardEnabled = page * pageSize < total;
|
|
141
|
-
const lastPage = Math.ceil(total / pageSize);
|
|
142
|
-
const options = [...(window.tgPageSizes || defaultPageSizes)];
|
|
143
|
-
if (!options.includes(pageSize)) {
|
|
144
|
-
options.push(pageSize);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<div className="paging-toolbar-container">
|
|
149
|
-
{onRefresh && (
|
|
150
|
-
<Button
|
|
151
|
-
minimal
|
|
152
|
-
loading={refetching}
|
|
153
|
-
icon="refresh"
|
|
154
|
-
disabled={disabled}
|
|
155
|
-
onClick={onRefreshHandler}
|
|
156
|
-
/>
|
|
157
|
-
)}
|
|
158
|
-
{!hideSetPageSize && (
|
|
159
|
-
<div
|
|
160
|
-
title="Set Page Size"
|
|
161
|
-
className={classNames(Classes.SELECT, Classes.MINIMAL)}
|
|
162
|
-
>
|
|
163
|
-
<select
|
|
164
|
-
name="page-size"
|
|
165
|
-
className="paging-page-size"
|
|
166
|
-
onChange={setPageSizeHandler}
|
|
167
|
-
disabled={disabled || disableSetPageSize}
|
|
168
|
-
value={pageSize}
|
|
169
|
-
>
|
|
170
|
-
{[
|
|
171
|
-
<option key="page-size-placeholder" disabled value="fake">
|
|
172
|
-
Size
|
|
173
|
-
</option>,
|
|
174
|
-
...options.map(size => {
|
|
175
|
-
return (
|
|
176
|
-
<option key={size} value={size}>
|
|
177
|
-
{size}
|
|
178
|
-
</option>
|
|
179
|
-
);
|
|
180
|
-
})
|
|
181
|
-
]}
|
|
182
|
-
</select>
|
|
183
|
-
</div>
|
|
184
|
-
)}
|
|
185
|
-
<Button
|
|
186
|
-
onClick={pageBackHandler}
|
|
187
|
-
disabled={!backEnabled || disabled}
|
|
188
|
-
minimal
|
|
189
|
-
className="paging-arrow-left"
|
|
190
|
-
icon="chevron-left"
|
|
191
|
-
/>
|
|
192
|
-
<div>
|
|
193
|
-
{hideTotalPages ? (
|
|
194
|
-
page
|
|
195
|
-
) : total ? (
|
|
196
|
-
<div>
|
|
197
|
-
<PagingInput
|
|
198
|
-
disabled={disabled}
|
|
199
|
-
onBlur={pageInputBlurHandler}
|
|
200
|
-
defaultPage={page}
|
|
201
|
-
lastPage={lastPage}
|
|
202
|
-
/>
|
|
203
|
-
of {lastPage}
|
|
204
|
-
</div>
|
|
205
|
-
) : (
|
|
206
|
-
"No Rows"
|
|
207
|
-
)}
|
|
208
|
-
</div>
|
|
209
|
-
<Button
|
|
210
|
-
style={{ marginLeft: 5 }}
|
|
211
|
-
disabled={
|
|
212
|
-
(controlled_hasNextPage === undefined
|
|
213
|
-
? !forwardEnabled
|
|
214
|
-
: !controlled_hasNextPage) || disabled
|
|
215
|
-
}
|
|
216
|
-
icon="chevron-right"
|
|
217
|
-
minimal
|
|
218
|
-
className="paging-arrow-right"
|
|
219
|
-
onClick={pageForwardHandler}
|
|
220
|
-
/>
|
|
221
|
-
</div>
|
|
222
|
-
);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
export default PagingTool;
|
|
@@ -1,191 +0,0 @@
|
|
|
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 "./EditableCell";
|
|
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
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { Button, Classes, Spinner } from "@blueprintjs/core";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
import { onEnterHelper } from "../utils/handlerHelpers";
|
|
5
|
-
import { InputField } from "../FormComponents";
|
|
6
|
-
|
|
7
|
-
const SearchBar = ({
|
|
8
|
-
searchInput,
|
|
9
|
-
setSearchTerm,
|
|
10
|
-
loading,
|
|
11
|
-
searchMenuButton,
|
|
12
|
-
disabled,
|
|
13
|
-
autoFocusSearch,
|
|
14
|
-
noForm
|
|
15
|
-
}) => {
|
|
16
|
-
const [inputText, setInputText] = useState(searchInput);
|
|
17
|
-
if (noForm) {
|
|
18
|
-
console.error(
|
|
19
|
-
"The search bar requires the component to be wrapped in a form"
|
|
20
|
-
);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
let rightElement;
|
|
24
|
-
// need to always render searchMenuButton so it doesn't close
|
|
25
|
-
if (searchMenuButton) {
|
|
26
|
-
rightElement = (
|
|
27
|
-
<div style={{ display: "flex" }}>
|
|
28
|
-
{loading && <Spinner size="18" />}
|
|
29
|
-
{searchMenuButton}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
} else {
|
|
33
|
-
rightElement = loading ? (
|
|
34
|
-
<Spinner size="18" />
|
|
35
|
-
) : (
|
|
36
|
-
<Button
|
|
37
|
-
minimal
|
|
38
|
-
icon="search"
|
|
39
|
-
onClick={() => {
|
|
40
|
-
setSearchTerm(inputText);
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return (
|
|
46
|
-
<InputField
|
|
47
|
-
autoFocus={autoFocusSearch}
|
|
48
|
-
disabled={disabled}
|
|
49
|
-
loading={loading}
|
|
50
|
-
type="search"
|
|
51
|
-
defaultValue={searchInput}
|
|
52
|
-
value={inputText}
|
|
53
|
-
onChange={e => {
|
|
54
|
-
setInputText(e.target.value);
|
|
55
|
-
}}
|
|
56
|
-
className={classNames("datatable-search-input", Classes.ROUND)}
|
|
57
|
-
placeholder="Search..."
|
|
58
|
-
{...onEnterHelper(e => {
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
e.stopPropagation();
|
|
61
|
-
setSearchTerm(e.target.value);
|
|
62
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
63
|
-
})}
|
|
64
|
-
rightElement={rightElement}
|
|
65
|
-
/>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export default SearchBar;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
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";
|
|
8
|
-
|
|
9
|
-
const CustomTheadComponent = ({
|
|
10
|
-
children: _children,
|
|
11
|
-
className,
|
|
12
|
-
onSortEnd,
|
|
13
|
-
onSortStart,
|
|
14
|
-
style
|
|
15
|
-
}) => {
|
|
16
|
-
// We need to do this because react table gives the children wrapped
|
|
17
|
-
// in another component
|
|
18
|
-
const children = _children.props.children;
|
|
19
|
-
const mouseSensor = useSensor(MouseSensor, {
|
|
20
|
-
activationConstraint: {
|
|
21
|
-
distance: 10
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const sensors = useSensors(mouseSensor);
|
|
26
|
-
const handleDragEnd = event => {
|
|
27
|
-
const { active, over } = event;
|
|
28
|
-
|
|
29
|
-
if (!over || !active) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (active.id === over.id) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
onSortEnd({
|
|
38
|
-
oldIndex: parseInt(active.id),
|
|
39
|
-
newIndex: parseInt(over.id)
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<DndContext
|
|
45
|
-
onDragStart={onSortStart}
|
|
46
|
-
onDragEnd={handleDragEnd}
|
|
47
|
-
modifiers={[restrictToHorizontalAxis]}
|
|
48
|
-
sensors={sensors}
|
|
49
|
-
>
|
|
50
|
-
<div className={"rt-thead " + className} style={style}>
|
|
51
|
-
<div className="rt-tr">
|
|
52
|
-
<SortableContext
|
|
53
|
-
items={children.map((_, index) => `${index}`)}
|
|
54
|
-
strategy={horizontalListSortingStrategy}
|
|
55
|
-
>
|
|
56
|
-
{children}
|
|
57
|
-
</SortableContext>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
</DndContext>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const SortableColumns = ({ className, style, children, moveColumn }) => {
|
|
65
|
-
const shouldCancelStart = e => {
|
|
66
|
-
const className = e.target.className;
|
|
67
|
-
// if its an svg then it's a blueprint icon
|
|
68
|
-
return (
|
|
69
|
-
e.target instanceof SVGElement || className.indexOf("rt-resizer") > -1
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const onSortEnd = (...args) => {
|
|
74
|
-
const { oldIndex, newIndex } = args[0];
|
|
75
|
-
document.body.classList.remove("drag-active");
|
|
76
|
-
moveColumn({
|
|
77
|
-
oldIndex,
|
|
78
|
-
newIndex
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const onSortStart = () => {
|
|
83
|
-
document.body.classList.add("drag-active");
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<CustomTheadComponent
|
|
88
|
-
className={className}
|
|
89
|
-
style={style}
|
|
90
|
-
onSortStart={onSortStart}
|
|
91
|
-
onSortEnd={onSortEnd}
|
|
92
|
-
helperClass="above-dialog"
|
|
93
|
-
shouldCancelStart={shouldCancelStart}
|
|
94
|
-
>
|
|
95
|
-
{children}
|
|
96
|
-
</CustomTheadComponent>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export default SortableColumns;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const TableFormTrackerContext = React.createContext({
|
|
4
|
-
formNames: [],
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
6
|
-
pushFormName: () => {},
|
|
7
|
-
isActive: false
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export default TableFormTrackerContext;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useSortable } from "@dnd-kit/sortable";
|
|
3
|
-
import { CSS } from "@dnd-kit/utilities";
|
|
4
|
-
import classNames from "classnames";
|
|
5
|
-
|
|
6
|
-
export const ThComponent = ({
|
|
7
|
-
toggleSort,
|
|
8
|
-
immovable,
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
style,
|
|
12
|
-
columnindex,
|
|
13
|
-
...rest
|
|
14
|
-
}) => {
|
|
15
|
-
const index = columnindex ?? -1;
|
|
16
|
-
const { attributes, listeners, setNodeRef, transform, transition } =
|
|
17
|
-
useSortable({
|
|
18
|
-
id: `${index}`,
|
|
19
|
-
disabled: immovable === "true"
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const sortStyles = {
|
|
23
|
-
transform: CSS.Transform.toString(transform),
|
|
24
|
-
transition
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div
|
|
29
|
-
style={{ ...sortStyles, ...style }}
|
|
30
|
-
ref={setNodeRef}
|
|
31
|
-
{...attributes}
|
|
32
|
-
{...listeners}
|
|
33
|
-
className={classNames("rt-th", className)}
|
|
34
|
-
onClick={e => toggleSort && toggleSort(e)}
|
|
35
|
-
role="columnheader"
|
|
36
|
-
tabIndex="-1" // Resolves eslint issues without implementing keyboard navigation incorrectly
|
|
37
|
-
columnindex={columnindex}
|
|
38
|
-
index={index}
|
|
39
|
-
{...rest}
|
|
40
|
-
>
|
|
41
|
-
{children}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {options} options
|
|
3
|
-
* @typedef {object} options
|
|
4
|
-
* @property {boolean} isPlural Are we searching for 1 thing or many?
|
|
5
|
-
* @property {string} queryName What the props come back on ( by default = modelName + 'Query')
|
|
6
|
-
*/
|
|
7
|
-
import { reduxForm } from "redux-form";
|
|
8
|
-
import { branch, compose, withProps } from "recompose";
|
|
9
|
-
import { withRouter } from "react-router-dom";
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
Right now DataTable is doing the same as withTableParams, so the logic is being
|
|
13
|
-
run twice. We need to refactor this to make it more DRY.
|
|
14
|
-
We could do two possible refactorings:
|
|
15
|
-
- remove withTableParams and just give all the appropiate props to DataTable. This would
|
|
16
|
-
make the component simpler.
|
|
17
|
-
- remove the logic from DataTable and just use withTableParams and a new hook called
|
|
18
|
-
useTableParams. This would be more flexible in the case we want to be able to use
|
|
19
|
-
pagination in a different component.
|
|
20
|
-
We should avoid having the component handle all the different
|
|
21
|
-
cases of input because of the next reasons:
|
|
22
|
-
1. It makes the component more complex and harder to understand.
|
|
23
|
-
2. It makes the component harder to test.
|
|
24
|
-
3. It makes the component harder to reuse.
|
|
25
|
-
4. Maintaining the the logic in the component is harder.
|
|
26
|
-
Keeping the logic and uses simple makes maintaining easier.
|
|
27
|
-
|
|
28
|
-
In my opinion, reduxForm could be replaced here with regular redux or even just be taken down.
|
|
29
|
-
Could be a major simplification, but this needs to be analized with lims for better
|
|
30
|
-
understanding if it's possible.
|
|
31
|
-
*/
|
|
32
|
-
export default compose(
|
|
33
|
-
// form prop is needed for redux-form, but we are giving this prop as
|
|
34
|
-
// formName, so we need to rename it. Previously it was done in the withTableParams, but now
|
|
35
|
-
// it doesn't have it by default.
|
|
36
|
-
withProps(({ formName }) => ({ form: formName })),
|
|
37
|
-
// the formName is passed via withTableParams and is often user overridden
|
|
38
|
-
branch(props => !props.noForm, reduxForm({})),
|
|
39
|
-
// don't use withRouter if noRouter is passed!
|
|
40
|
-
branch(props => !props.noRouter, withRouter)
|
|
41
|
-
);
|