@absreim/react-bootstrap-data-grid-pro 2.4.1 → 2.6.0
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/grid/Grid.js +26 -30
- package/grid/InternalGrid.d.ts +1 -0
- package/grid/InternalGrid.js +17 -18
- package/grid/editing/EditControlsCell.js +3 -4
- package/grid/editing/EditableRow.js +11 -17
- package/grid/editing/inputStrsToRowData.js +4 -4
- package/grid/export/ExportForm.js +25 -49
- package/grid/export/useExportFn.js +34 -58
- package/grid/filtering/DateFilterRow.js +17 -33
- package/grid/filtering/FilterOptionsTable.js +60 -96
- package/grid/filtering/FilterRow.js +4 -13
- package/grid/filtering/NumberFilterRow.js +10 -25
- package/grid/filtering/StringFilterRow.js +10 -25
- package/grid/filtering/types.js +6 -6
- package/grid/filtering/useFilterFormState.js +52 -65
- package/grid/main/BodyRows.d.ts +3 -1
- package/grid/main/BodyRows.js +6 -13
- package/grid/main/ColHeaderCell/index.js +4 -4
- package/grid/main/ColHeaderCell/useSortHeaderStates.js +10 -10
- package/grid/main/ToggleButton.js +3 -4
- package/grid/pagination/PageSelector.js +17 -18
- package/grid/pagination/PageSizeSelector.js +5 -6
- package/grid/pagination/Pagination.js +6 -7
- package/grid/pipeline/useAugFormattedRows.js +5 -20
- package/grid/pipeline/useCombinedPipeline/index.d.ts +2 -2
- package/grid/pipeline/useCombinedPipeline/index.js +21 -22
- package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +3 -3
- package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.js +29 -24
- package/grid/pipeline/useCombinedPipeline/useDisplayRows.d.ts +2 -2
- package/grid/pipeline/useCombinedPipeline/useDisplayRows.js +40 -41
- package/grid/pipeline/useCombinedPipeline/useFilter.d.ts +2 -2
- package/grid/pipeline/useCombinedPipeline/useFilter.js +9 -9
- package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.js +5 -6
- package/grid/pipeline/useCombinedPipeline/useFilterStateStore.js +6 -7
- package/grid/pipeline/useCombinedPipeline/useSortedRows.d.ts +3 -3
- package/grid/pipeline/useCombinedPipeline/useSortedRows.js +22 -27
- package/grid/pipeline/useGetInputStrSubmitCallback.js +6 -6
- package/grid/pipeline/useGridSelectionFns.js +30 -30
- package/grid/pipeline/useUnwrappedGridStyles.js +5 -7
- package/grid/selection/SelectAllHeaderCell.d.ts +1 -0
- package/grid/selection/SelectAllHeaderCell.js +9 -10
- package/grid/selection/SelectionInput.js +4 -6
- package/grid/sorting/arrowPlaceholder.js +1 -1
- package/grid/sorting/downArrow.js +1 -1
- package/grid/sorting/sortOrderToAriaSort.d.ts +4 -0
- package/grid/sorting/sortOrderToAriaSort.js +11 -0
- package/grid/sorting/upArrow.js +1 -10
- package/grid/styling/styleModelUnwrappers.js +22 -33
- package/grid/toolbar/Toolbar.js +61 -9
- package/grid/toolbar/ToolbarContainer.js +3 -6
- package/grid/toolbar/useInterfaces.js +5 -17
- package/grid/types.d.ts +9 -5
- package/grid/util/datetime.js +2 -4
- package/grid/util/getWidthStyle.js +6 -8
- package/grid/util/isSubset.js +3 -4
- package/grid/util/useControlledHover.js +8 -8
- package/grid-pro/ColHeaderCellPro.js +47 -42
- package/grid-pro/GridPro.js +42 -32
- package/grid-pro/assets/HorizontalGrip.d.ts +6 -0
- package/grid-pro/assets/HorizontalGrip.js +3 -0
- package/grid-pro/assets/VerticalGrip.d.ts +6 -0
- package/grid-pro/assets/VerticalGrip.js +3 -0
- package/grid-pro/index.d.ts +3 -0
- package/grid-pro/index.js +3 -0
- package/grid-pro/reorder/ReorderHandleCell.d.ts +12 -0
- package/grid-pro/reorder/ReorderHandleCell.js +220 -0
- package/grid-pro/reorder/ReorderHeaderCell.d.ts +3 -0
- package/grid-pro/reorder/ReorderHeaderCell.js +4 -0
- package/grid-pro/reorder/types.d.ts +12 -0
- package/grid-pro/reorder/types.js +1 -0
- package/grid-pro/resize/useResizeModel.js +40 -62
- package/grid-pro/types.d.ts +9 -2
- package/grid-pro/util/index.d.ts +1 -0
- package/grid-pro/util/index.js +1 -0
- package/grid-pro/util/regDragCleanup.d.ts +3 -0
- package/grid-pro/util/regDragCleanup.js +28 -0
- package/grid-pro/util/reorderRows.d.ts +3 -0
- package/grid-pro/util/reorderRows.js +17 -0
- package/grid-pro/util/types.d.ts +10 -0
- package/grid-pro/util/types.js +1 -0
- package/package.json +1 -1
- package/style.css +1 -1
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
2
|
import { useMemo, useState } from "react";
|
|
23
3
|
import StringFilterRow from "./StringFilterRow";
|
|
@@ -26,92 +6,76 @@ import useFilterFormState from "./useFilterFormState";
|
|
|
26
6
|
import DateFilterRow from "./DateFilterRow";
|
|
27
7
|
import classNames from "classnames";
|
|
28
8
|
import { unwrapFilterInputTableStyleModel } from "../styling/styleModelUnwrappers";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
const convertFilterFormStateToEditableState = (filterFormState) => Object.keys(filterFormState).reduce((editableState, colName) => {
|
|
10
|
+
const rowFilterFormState = filterFormState[colName];
|
|
11
|
+
switch (rowFilterFormState.type) {
|
|
12
|
+
case "string": {
|
|
13
|
+
editableState[colName] = Object.assign({}, rowFilterFormState);
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
case "number": {
|
|
17
|
+
editableState[colName] = {
|
|
18
|
+
type: rowFilterFormState.type,
|
|
19
|
+
enabled: rowFilterFormState.enabled,
|
|
20
|
+
scheme: rowFilterFormState.scheme,
|
|
21
|
+
numValue: rowFilterFormState.inputValue === ""
|
|
22
|
+
? null
|
|
23
|
+
: Number(rowFilterFormState.inputValue),
|
|
24
|
+
};
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
default: {
|
|
28
|
+
// date or datetime
|
|
29
|
+
const partialFilterState = {
|
|
30
|
+
type: rowFilterFormState.type,
|
|
31
|
+
enabled: rowFilterFormState.enabled,
|
|
32
|
+
};
|
|
33
|
+
const inputStrToDate = (str) => str === "" ? null : new Date(str);
|
|
34
|
+
switch (rowFilterFormState.scheme) {
|
|
35
|
+
case "startFrom": {
|
|
36
|
+
editableState[colName] = Object.assign(Object.assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, startDate: inputStrToDate(rowFilterFormState.startDate) });
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "endAt": {
|
|
40
|
+
editableState[colName] = Object.assign(Object.assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, endDate: inputStrToDate(rowFilterFormState.endDate) });
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
default: {
|
|
44
|
+
editableState[colName] = Object.assign(Object.assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, startDate: inputStrToDate(rowFilterFormState.startDate), endDate: inputStrToDate(rowFilterFormState.endDate) });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return editableState;
|
|
50
|
+
}, {});
|
|
51
|
+
const FilterOptionsTable = ({ filterState, setFilterState, caption, styleModel, }) => {
|
|
52
|
+
const formFilterState = useFilterFormState(filterState);
|
|
53
|
+
const [formState, setFormState] = useState(formFilterState);
|
|
54
|
+
const unwrappedStyleModel = useMemo(() => unwrapFilterInputTableStyleModel(styleModel), [styleModel]);
|
|
55
|
+
const getRows = () => Object.keys(formState).map((colName, index) => {
|
|
56
|
+
function getColStateSetter(colName) {
|
|
57
|
+
return (rowState) => setFormState(Object.assign(Object.assign({}, formState), { [colName]: rowState }));
|
|
58
|
+
}
|
|
59
|
+
const colLabel = filterState[colName].label;
|
|
60
|
+
const colFilterState = formState[colName];
|
|
61
|
+
switch (colFilterState.type) {
|
|
33
62
|
case "string": {
|
|
34
|
-
|
|
35
|
-
break;
|
|
63
|
+
return (_jsx(StringFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), searchStringInputClasses: unwrappedStyleModel.searchStringInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: (colIndex) => unwrappedStyleModel.tbodyTd(index, colIndex) }, colName));
|
|
36
64
|
}
|
|
37
65
|
case "number": {
|
|
38
|
-
|
|
39
|
-
type: rowFilterFormState.type,
|
|
40
|
-
enabled: rowFilterFormState.enabled,
|
|
41
|
-
scheme: rowFilterFormState.scheme,
|
|
42
|
-
numValue: rowFilterFormState.inputValue === ""
|
|
43
|
-
? null
|
|
44
|
-
: Number(rowFilterFormState.inputValue),
|
|
45
|
-
};
|
|
46
|
-
break;
|
|
66
|
+
return (_jsx(NumberFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), numberInputClasses: unwrappedStyleModel.numberInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: (colIndex) => unwrappedStyleModel.tbodyTd(index, colIndex) }, colName));
|
|
47
67
|
}
|
|
48
68
|
default: {
|
|
49
69
|
// date or datetime
|
|
50
|
-
|
|
51
|
-
type: rowFilterFormState.type,
|
|
52
|
-
enabled: rowFilterFormState.enabled,
|
|
53
|
-
};
|
|
54
|
-
var inputStrToDate = function (str) {
|
|
55
|
-
return str === "" ? null : new Date(str);
|
|
56
|
-
};
|
|
57
|
-
switch (rowFilterFormState.scheme) {
|
|
58
|
-
case "startFrom": {
|
|
59
|
-
editableState[colName] = __assign(__assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, startDate: inputStrToDate(rowFilterFormState.startDate) });
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
case "endAt": {
|
|
63
|
-
editableState[colName] = __assign(__assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, endDate: inputStrToDate(rowFilterFormState.endDate) });
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
default: {
|
|
67
|
-
editableState[colName] = __assign(__assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, startDate: inputStrToDate(rowFilterFormState.startDate), endDate: inputStrToDate(rowFilterFormState.endDate) });
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
+
return (_jsx(DateFilterRow, { ariaRowIndex: index + 2, includeTime: colFilterState.type === "datetime", columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), startDateInputClasses: unwrappedStyleModel.startDateInput(index), endDateInputClasses: unwrappedStyleModel.endDateInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: (colIndex) => unwrappedStyleModel.tbodyTd(index, colIndex) }, colName));
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
var FilterOptionsTable = function (_a) {
|
|
76
|
-
var filterState = _a.filterState, setFilterState = _a.setFilterState, caption = _a.caption, styleModel = _a.styleModel;
|
|
77
|
-
var formFilterState = useFilterFormState(filterState);
|
|
78
|
-
var _b = useState(formFilterState), formState = _b[0], setFormState = _b[1];
|
|
79
|
-
var unwrappedStyleModel = useMemo(function () { return unwrapFilterInputTableStyleModel(styleModel); }, [styleModel]);
|
|
80
|
-
var getRows = function () {
|
|
81
|
-
return Object.keys(formState).map(function (colName, index) {
|
|
82
|
-
function getColStateSetter(colName) {
|
|
83
|
-
return function (rowState) {
|
|
84
|
-
var _a;
|
|
85
|
-
return setFormState(__assign(__assign({}, formState), (_a = {}, _a[colName] = rowState, _a)));
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
var colLabel = filterState[colName].label;
|
|
89
|
-
var colFilterState = formState[colName];
|
|
90
|
-
switch (colFilterState.type) {
|
|
91
|
-
case "string": {
|
|
92
|
-
return (_jsx(StringFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), searchStringInputClasses: unwrappedStyleModel.searchStringInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: function (colIndex) {
|
|
93
|
-
return unwrappedStyleModel.tbodyTd(index, colIndex);
|
|
94
|
-
} }, colName));
|
|
95
|
-
}
|
|
96
|
-
case "number": {
|
|
97
|
-
return (_jsx(NumberFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), numberInputClasses: unwrappedStyleModel.numberInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: function (colIndex) {
|
|
98
|
-
return unwrappedStyleModel.tbodyTd(index, colIndex);
|
|
99
|
-
} }, colName));
|
|
100
|
-
}
|
|
101
|
-
default: {
|
|
102
|
-
// date or datetime
|
|
103
|
-
return (_jsx(DateFilterRow, { ariaRowIndex: index + 2, includeTime: colFilterState.type === "datetime", columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), startDateInputClasses: unwrappedStyleModel.startDateInput(index), endDateInputClasses: unwrappedStyleModel.endDateInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: function (colIndex) {
|
|
104
|
-
return unwrappedStyleModel.tbodyTd(index, colIndex);
|
|
105
|
-
} }, colName));
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
var onSubmit = function (event) {
|
|
73
|
+
});
|
|
74
|
+
const onSubmit = (event) => {
|
|
111
75
|
event.preventDefault();
|
|
112
|
-
|
|
76
|
+
const editableTableFilterState = convertFilterFormStateToEditableState(formState);
|
|
113
77
|
setFilterState(editableTableFilterState);
|
|
114
78
|
};
|
|
115
|
-
return (_jsxs("form", { onSubmit: onSubmit, className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.form), children: [_jsxs("table", { className: classNames
|
|
79
|
+
return (_jsxs("form", { onSubmit: onSubmit, className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.form), children: [_jsxs("table", { className: classNames("table", ...unwrappedStyleModel.table), children: [caption && (_jsx("caption", { className: classNames(unwrappedStyleModel.caption), children: caption })), _jsx("thead", { className: classNames(...unwrappedStyleModel.thead), children: _jsx("tr", { className: classNames(...unwrappedStyleModel.theadTr), children: ["Enabled", "Column", "Type", "Operator", "Value"].map((colName, index) => (_jsx("th", { className: classNames(...unwrappedStyleModel.theadTh(index)), children: colName }, index))) }) }), _jsx("tbody", { className: classNames(...unwrappedStyleModel.tbody), children: getRows() })] }), _jsx("button", { className: classNames("btn", { "btn-secondary": unwrappedStyleModel.submitButton.length === 0 }, unwrappedStyleModel.submitButton), type: "submit", children: "Submit" })] }));
|
|
116
80
|
};
|
|
117
81
|
export default FilterOptionsTable;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
2
|
import classNames from "classnames";
|
|
12
3
|
export function FilterRow(props) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return (_jsxs("tr", { className: classNames(trClasses), "aria-rowindex": ariaRowIndex, children: [_jsx("td", { className: classNames(tdClasses(0)), "aria-colindex": 1, children: _jsx("input", { className: classNames(inputClasses), name: checkboxLabel, "aria-label": checkboxLabel, type: "checkbox", checked: enabled, onChange: enabledChangeHandler }) }), _jsx("td", { className: classNames(tdClasses(1)), "aria-colindex": 2, children: columnLabel }), _jsx("td", { className: classNames(tdClasses(2)), "aria-colindex": 3, children: typeLabel }), _jsx("td", { className: classNames(tdClasses(3)), "aria-colindex": 4, children: _jsx("select", { name: opSelectLabel, "aria-label": opSelectLabel, disabled: !enabled, className: classNames
|
|
4
|
+
const { ariaRowIndex, columnLabel, typeLabel, enabled, enabledChangeHandler, currentScheme, handleSchemeChange, schemesToLabels, searchStringInputCellContents, trClasses, tdClasses, inputClasses, selectClasses, } = props;
|
|
5
|
+
const checkboxLabel = `${columnLabel} Column Filter Toggle`;
|
|
6
|
+
const opSelectLabel = `${columnLabel} Column Filter Operator Selection`;
|
|
7
|
+
return (_jsxs("tr", { className: classNames(trClasses), "aria-rowindex": ariaRowIndex, children: [_jsx("td", { className: classNames(tdClasses(0)), "aria-colindex": 1, children: _jsx("input", { className: classNames(inputClasses), name: checkboxLabel, "aria-label": checkboxLabel, type: "checkbox", checked: enabled, onChange: enabledChangeHandler }) }), _jsx("td", { className: classNames(tdClasses(1)), "aria-colindex": 2, children: columnLabel }), _jsx("td", { className: classNames(tdClasses(2)), "aria-colindex": 3, children: typeLabel }), _jsx("td", { className: classNames(tdClasses(3)), "aria-colindex": 4, children: _jsx("select", { name: opSelectLabel, "aria-label": opSelectLabel, disabled: !enabled, className: classNames("form-select", ...selectClasses), value: currentScheme, onChange: handleSchemeChange, children: Object.keys(schemesToLabels).map((scheme) => (_jsx("option", { value: scheme, children: schemesToLabels[scheme] }, scheme))) }) }), _jsx("td", { className: classNames(tdClasses(4)), "aria-colindex": 5, children: searchStringInputCellContents })] }));
|
|
17
8
|
}
|
|
18
9
|
export default FilterRow;
|
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import { numberFilterSchemeNames, } from "./types";
|
|
14
3
|
import FilterRow from "./FilterRow";
|
|
15
4
|
import classNames from "classnames";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var target = _a.target;
|
|
20
|
-
setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
|
|
5
|
+
const NumberFilterRow = ({ ariaRowIndex, columnLabel, filterState, setFilterState, schemeSelectClasses, enableInputClasses, numberInputClasses, tdClasses, trClasses, }) => {
|
|
6
|
+
const handleOpChange = ({ target, }) => {
|
|
7
|
+
setFilterState(Object.assign(Object.assign({}, filterState), { scheme: target.value }));
|
|
21
8
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
|
|
9
|
+
const handleEnabledChange = ({ target, }) => {
|
|
10
|
+
setFilterState(Object.assign(Object.assign({}, filterState), { enabled: target.checked }));
|
|
25
11
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
setFilterState(__assign(__assign({}, filterState), { inputValue: target.value }));
|
|
12
|
+
const handleNumInputValueChange = ({ target, }) => {
|
|
13
|
+
setFilterState(Object.assign(Object.assign({}, filterState), { inputValue: target.value }));
|
|
29
14
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
const { enabled, scheme, inputValue } = filterState;
|
|
16
|
+
const valueInputLabel = `${columnLabel} Column Filter Value`;
|
|
17
|
+
const searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control", numberInputClasses), type: "number", required: enabled, disabled: !enabled, value: inputValue, onChange: handleNumInputValueChange }));
|
|
33
18
|
return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: "Number", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: numberFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
|
|
34
19
|
};
|
|
35
20
|
export default NumberFilterRow;
|
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import FilterRow from "./FilterRow";
|
|
14
3
|
import classNames from "classnames";
|
|
15
4
|
import { stringFilterSchemeNames, } from "./types";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var target = _a.target;
|
|
20
|
-
setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
|
|
5
|
+
const StringFilterRow = ({ ariaRowIndex, columnLabel, filterState, setFilterState, schemeSelectClasses, enableInputClasses, searchStringInputClasses, tdClasses, trClasses, }) => {
|
|
6
|
+
const handleOpChange = ({ target, }) => {
|
|
7
|
+
setFilterState(Object.assign(Object.assign({}, filterState), { scheme: target.value }));
|
|
21
8
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
|
|
9
|
+
const handleEnabledChange = ({ target, }) => {
|
|
10
|
+
setFilterState(Object.assign(Object.assign({}, filterState), { enabled: target.checked }));
|
|
25
11
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
setFilterState(__assign(__assign({}, filterState), { searchString: target.value }));
|
|
12
|
+
const handleSearchStringChange = ({ target, }) => {
|
|
13
|
+
setFilterState(Object.assign(Object.assign({}, filterState), { searchString: target.value }));
|
|
29
14
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
const { enabled, scheme, searchString } = filterState;
|
|
16
|
+
const valueInputLabel = `${columnLabel} Column Filter Value`;
|
|
17
|
+
const searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control", searchStringInputClasses), required: enabled, disabled: !enabled, value: searchString, onChange: handleSearchStringChange }));
|
|
33
18
|
return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: "String", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: stringFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
|
|
34
19
|
};
|
|
35
20
|
export default StringFilterRow;
|
package/grid/filtering/types.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const stringFilterSchemes = [
|
|
2
2
|
"contains",
|
|
3
3
|
"startsWith",
|
|
4
4
|
"endsWith",
|
|
5
5
|
];
|
|
6
|
-
export
|
|
6
|
+
export const stringFilterSchemeNames = {
|
|
7
7
|
contains: "Contains",
|
|
8
8
|
startsWith: "Starts With",
|
|
9
9
|
endsWith: "Ends With",
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export const numberFilterSchemes = [
|
|
12
12
|
"equals",
|
|
13
13
|
"greaterThan",
|
|
14
14
|
"lessThan",
|
|
15
15
|
"greaterOrEqual",
|
|
16
16
|
"lessOrEqual",
|
|
17
17
|
];
|
|
18
|
-
export
|
|
18
|
+
export const numberFilterSchemeNames = {
|
|
19
19
|
equals: "=",
|
|
20
20
|
greaterThan: ">",
|
|
21
21
|
lessThan: "<",
|
|
22
22
|
greaterOrEqual: ">=",
|
|
23
23
|
lessOrEqual: "<=",
|
|
24
24
|
};
|
|
25
|
-
export
|
|
26
|
-
export
|
|
25
|
+
export const dateFilterSchemes = ["startFrom", "endAt", "between"];
|
|
26
|
+
export const dateFilterSchemeNames = {
|
|
27
27
|
startFrom: "Start Form",
|
|
28
28
|
endAt: "End At",
|
|
29
29
|
between: "Between",
|
|
@@ -1,72 +1,59 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { useMemo } from "react";
|
|
13
2
|
import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
|
|
14
|
-
|
|
15
|
-
return useMemo(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
3
|
+
const useFilterFormState = (tableFilterState) => {
|
|
4
|
+
return useMemo(() => Object.keys(tableFilterState).reduce((filterFormState, colName) => {
|
|
5
|
+
const editableState = tableFilterState[colName].editableState;
|
|
6
|
+
switch (editableState.type) {
|
|
7
|
+
case "string": {
|
|
8
|
+
filterFormState[colName] = Object.assign({}, editableState);
|
|
9
|
+
break;
|
|
10
|
+
}
|
|
11
|
+
case "number": {
|
|
12
|
+
filterFormState[colName] = {
|
|
13
|
+
type: "number",
|
|
14
|
+
scheme: editableState.scheme,
|
|
15
|
+
enabled: editableState.enabled,
|
|
16
|
+
inputValue: editableState.numValue === null
|
|
17
|
+
? ""
|
|
18
|
+
: String(editableState.numValue),
|
|
19
|
+
};
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
default: {
|
|
23
|
+
// date or datetime
|
|
24
|
+
const partialFormState = {
|
|
25
|
+
type: editableState.type,
|
|
26
|
+
enabled: editableState.enabled,
|
|
27
|
+
};
|
|
28
|
+
const dateToStrConverter = editableState.type === "date"
|
|
29
|
+
? dateToInputStr
|
|
30
|
+
: dateToDatetimeInputStr;
|
|
31
|
+
switch (editableState.scheme) {
|
|
32
|
+
case "startFrom": {
|
|
33
|
+
filterFormState[colName] = Object.assign(Object.assign({}, partialFormState), { scheme: "startFrom", startDate: editableState.startDate === null
|
|
34
|
+
? ""
|
|
35
|
+
: dateToStrConverter(editableState.startDate), endDate: "" });
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "endAt": {
|
|
39
|
+
filterFormState[colName] = Object.assign(Object.assign({}, partialFormState), { scheme: "endAt", startDate: "", endDate: editableState.endDate === null
|
|
40
|
+
? ""
|
|
41
|
+
: dateToStrConverter(editableState.endDate) });
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
default: {
|
|
45
|
+
// between
|
|
46
|
+
filterFormState[colName] = Object.assign(Object.assign({}, partialFormState), { scheme: "between", startDate: editableState.startDate === null
|
|
47
|
+
? ""
|
|
48
|
+
: dateToStrConverter(editableState.startDate), endDate: editableState.endDate === null
|
|
49
|
+
? ""
|
|
50
|
+
: dateToStrConverter(editableState.endDate) });
|
|
51
|
+
break;
|
|
65
52
|
}
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, [tableFilterState]);
|
|
55
|
+
}
|
|
56
|
+
return filterFormState;
|
|
57
|
+
}, {}), [tableFilterState]);
|
|
71
58
|
};
|
|
72
59
|
export default useFilterFormState;
|
package/grid/main/BodyRows.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AugFormattedRow } from "../types";
|
|
2
|
-
import { FC } from "react";
|
|
2
|
+
import { FC, ReactNode } from "react";
|
|
3
3
|
import { UseGridSelectionFnsHook } from "../pipeline/useGridSelectionFns";
|
|
4
4
|
import { UseUnwrappedGridStylesHook } from "../pipeline/useUnwrappedGridStyles";
|
|
5
5
|
import { UseCombinedPipelineHook } from "../pipeline/useCombinedPipeline";
|
|
@@ -14,6 +14,8 @@ interface BodyRowsProps {
|
|
|
14
14
|
selectModel: SelectModel | undefined;
|
|
15
15
|
editModel: EditModel | undefined;
|
|
16
16
|
getInputStrSubmitCallback: UseGetInputStrSubmitCallbackHook;
|
|
17
|
+
additionalColIndexOffset?: number;
|
|
18
|
+
renderPrefixCells?: (augFormattedRows: AugFormattedRow) => ReactNode;
|
|
17
19
|
}
|
|
18
20
|
declare const BodyRows: FC<BodyRowsProps>;
|
|
19
21
|
export default BodyRows;
|
package/grid/main/BodyRows.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import EditableRow from "../editing/EditableRow";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import getWidthStyle from "../util/getWidthStyle";
|
|
5
5
|
import SelectionInput from "../selection/SelectionInput";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, unwrappedTableModel.tbodyTr(row.id, index)), "aria-rowindex": index + 2, dataRowId: row.id, "aria-selected": getAriaSelectedValue(row.id), ariaColIndexOffset: ariaColIndexOffset, cellData: row.contents, updateCallback: getInputStrSubmitCallback && getInputStrSubmitCallback(row.id), deleteCallback: (editModel === null || editModel === void 0 ? void 0 : editModel.getDeleteCallback) && editModel.getDeleteCallback(row.id), dataCellClasses: function (colIndex) {
|
|
12
|
-
return unwrappedTableModel.tbodyTd(row.id, index, colIndex);
|
|
13
|
-
}, dataCellInputClasses: function (colIndex) {
|
|
14
|
-
return unwrappedTableModel.tbodyTdInput(row.id, index, colIndex);
|
|
15
|
-
}, editCellClasses: unwrappedTableModel.editColTd(row.id, index), saveButtonClasses: unwrappedTableModel.editSaveButton(row.id, index), deleteButtonClasses: unwrappedTableModel.editDeleteButton(row.id, index), startButtonClasses: unwrappedTableModel.editStartButton(row.id, index), cancelButtonClasses: unwrappedTableModel.editCancelButton(row.id, index), children: showSelectCol && (_jsx("td", { className: classNames(unwrappedTableModel.rowSelectColTd(row.id, index)), "aria-colindex": 1, style: getWidthStyle(selectModel.selectColWidth), children: _jsx(SelectionInput, { selected: selectedSet.has(row.id), selectionInputModel: getSelectInputModel(row.id, selectModel), selectCallback: getSelectHandler(row.id), additionalClasses: unwrappedTableModel.rowSelectInput(row.id, index) }) })) }, row.id));
|
|
16
|
-
});
|
|
17
|
-
};
|
|
6
|
+
const BodyRows = ({ augFormattedRows, gridSelectionFns: { selectedSet, getSelectInputModel, getSelectHandler, getRowClickHandler, getAriaSelectedValue, }, unwrappedStyles: { unwrappedTableModel }, combinedPipelineOutput: { showSelectCol, ariaColIndexOffset }, selectModel, editModel, getInputStrSubmitCallback, additionalColIndexOffset, renderPrefixCells, }) => augFormattedRows.map((row, index) => {
|
|
7
|
+
return (_jsxs(EditableRow, { onClick: getRowClickHandler(row.id), className: classNames({
|
|
8
|
+
"table-active": selectedSet.has(row.id),
|
|
9
|
+
}, unwrappedTableModel.tbodyTr(row.id, index)), "aria-rowindex": row.prePaginationIndex + 2, dataRowId: row.id, "aria-selected": getAriaSelectedValue(row.id), ariaColIndexOffset: ariaColIndexOffset + (additionalColIndexOffset || 0), cellData: row.contents, updateCallback: getInputStrSubmitCallback && getInputStrSubmitCallback(row.id), deleteCallback: (editModel === null || editModel === void 0 ? void 0 : editModel.getDeleteCallback) && editModel.getDeleteCallback(row.id), dataCellClasses: (colIndex) => unwrappedTableModel.tbodyTd(row.id, index, colIndex), dataCellInputClasses: (colIndex) => unwrappedTableModel.tbodyTdInput(row.id, index, colIndex), editCellClasses: unwrappedTableModel.editColTd(row.id, index), saveButtonClasses: unwrappedTableModel.editSaveButton(row.id, index), deleteButtonClasses: unwrappedTableModel.editDeleteButton(row.id, index), startButtonClasses: unwrappedTableModel.editStartButton(row.id, index), cancelButtonClasses: unwrappedTableModel.editCancelButton(row.id, index), children: [renderPrefixCells && renderPrefixCells(row), showSelectCol && (_jsx("td", { className: classNames(unwrappedTableModel.rowSelectColTd(row.id, index)), "aria-colindex": 1 + (additionalColIndexOffset || 0), style: getWidthStyle(selectModel.selectColWidth), children: _jsx(SelectionInput, { selected: selectedSet.has(row.id), selectionInputModel: getSelectInputModel(row.id, selectModel), selectCallback: getSelectHandler(row.id), additionalClasses: unwrappedTableModel.rowSelectInput(row.id, index) }) }))] }, row.id));
|
|
10
|
+
});
|
|
18
11
|
export default BodyRows;
|
|
@@ -3,14 +3,14 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import getWidthStyle from "../../util/getWidthStyle";
|
|
5
5
|
import useSortHeaderStates from "./useSortHeaderStates";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import sortOrderToAriaSort from "../../sorting/sortOrderToAriaSort";
|
|
7
|
+
const ColHeaderCell = ({ label, sortModel, ariaColIndex, additionalClasses, width, }) => {
|
|
8
|
+
const { handleClick, handleMouseOver, handleMouseOut, sortSymbol } = useSortHeaderStates(sortModel);
|
|
9
9
|
return (_jsxs("th", { className: classNames({
|
|
10
10
|
"rbdg-sort-toggler": sortModel,
|
|
11
11
|
"table-active": sortModel === null || sortModel === void 0 ? void 0 : sortModel.sortOrder,
|
|
12
12
|
}, additionalClasses || []), onClick: sortModel && handleClick, onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, "aria-description": sortModel
|
|
13
13
|
? "Column header"
|
|
14
|
-
: "Column header that can be clicked to change the sorting mode", "aria-colindex": ariaColIndex, style: getWidthStyle(width), children: [label, sortSymbol] }));
|
|
14
|
+
: "Column header that can be clicked to change the sorting mode", "aria-colindex": ariaColIndex, "aria-sort": sortModel ? sortOrderToAriaSort(sortModel.sortOrder) : undefined, style: getWidthStyle(width), children: [label, sortSymbol] }));
|
|
15
15
|
};
|
|
16
16
|
export default ColHeaderCell;
|
|
@@ -3,9 +3,9 @@ import { useMemo } from "react";
|
|
|
3
3
|
import upArrow from "../../sorting/upArrow";
|
|
4
4
|
import arrowPlaceholder from "../../sorting/arrowPlaceholder";
|
|
5
5
|
import downArrow from "../../sorting/downArrow";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const useSortHeaderStates = (sortModel) => {
|
|
7
|
+
const { isHovering, setIsHovering, handleMouseOver, handleMouseOut } = useControlledHover();
|
|
8
|
+
const handleClick = () => {
|
|
9
9
|
if (!sortModel) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
@@ -23,7 +23,7 @@ var useSortHeaderStates = function (sortModel) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
const sortSymbol = useMemo(() => {
|
|
27
27
|
if (!sortModel) {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
@@ -43,12 +43,12 @@ var useSortHeaderStates = function (sortModel) {
|
|
|
43
43
|
}
|
|
44
44
|
}, [isHovering, sortModel]);
|
|
45
45
|
return {
|
|
46
|
-
isHovering
|
|
47
|
-
setIsHovering
|
|
48
|
-
handleMouseOver
|
|
49
|
-
handleMouseOut
|
|
50
|
-
handleClick
|
|
51
|
-
sortSymbol
|
|
46
|
+
isHovering,
|
|
47
|
+
setIsHovering,
|
|
48
|
+
handleMouseOver,
|
|
49
|
+
handleMouseOut,
|
|
50
|
+
handleClick,
|
|
51
|
+
sortSymbol,
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
export default useSortHeaderStates;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import classNames from "classnames";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var variableClasses = {
|
|
4
|
+
const ToggleButton = ({ isActive, label, onClick, classes, }) => {
|
|
5
|
+
const baseClasses = ["btn"];
|
|
6
|
+
const variableClasses = {
|
|
8
7
|
active: isActive,
|
|
9
8
|
};
|
|
10
9
|
return (_jsx("button", { type: "button", className: classNames(baseClasses, variableClasses, classes, {
|