@absreim/react-bootstrap-data-grid 1.3.0 → 1.4.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/ColHeaderCell.d.ts +2 -1
- package/ColHeaderCell.js +6 -6
- package/Grid.d.ts +8 -10
- package/Grid.js +42 -40
- package/ToggleButton.d.ts +1 -0
- package/ToggleButton.js +5 -3
- package/editing/EditControlsCell.d.ts +5 -0
- package/editing/EditControlsCell.js +15 -2
- package/editing/EditableRow.d.ts +8 -1
- package/editing/EditableRow.js +4 -3
- package/editing/types.d.ts +14 -0
- package/editing/types.js +1 -0
- package/filtering/DateFilterRow.d.ts +8 -2
- package/filtering/DateFilterRow.js +6 -5
- package/filtering/FilterOptionsTable.d.ts +4 -1
- package/filtering/FilterOptionsTable.js +26 -7
- package/filtering/FilterRow.d.ts +19 -0
- package/filtering/FilterRow.js +18 -0
- package/filtering/NumberFilterRow.d.ts +7 -2
- package/filtering/NumberFilterRow.js +7 -6
- package/filtering/StringFilterRow.d.ts +8 -3
- package/filtering/StringFilterRow.js +7 -6
- package/filtering/types.d.ts +52 -1
- package/filtering/types.js +30 -1
- package/filtering/useFormStateFromTableFilterState.d.ts +1 -2
- package/index.d.ts +6 -1
- package/index.js +6 -1
- package/package.json +3 -2
- package/pagination/PageSelector.d.ts +2 -2
- package/pagination/Pagination.d.ts +3 -1
- package/pagination/Pagination.js +2 -2
- package/pagination/types.d.ts +12 -0
- package/pagination/types.js +1 -0
- package/pipeline/useCurrentPageRows.d.ts +4 -0
- package/pipeline/useCurrentPageRows.js +14 -0
- package/{hooks → pipeline}/useEditableFromFilterState.d.ts +1 -1
- package/{hooks → pipeline}/useFilter.d.ts +2 -1
- package/{hooks → pipeline}/useFilterStateFromEditable.d.ts +2 -1
- package/{hooks → pipeline}/useSortedRows.d.ts +2 -1
- package/selection/SelectAllHeaderCell.d.ts +2 -1
- package/selection/SelectAllHeaderCell.js +7 -6
- package/selection/SelectionInput.d.ts +1 -0
- package/selection/SelectionInput.js +3 -2
- package/selection/types.d.ts +16 -0
- package/selection/types.js +4 -0
- package/sorting/types.d.ts +13 -0
- package/sorting/types.js +1 -0
- package/styling/styleModelUnwrappers.d.ts +4 -0
- package/styling/styleModelUnwrappers.js +57 -0
- package/styling/types.d.ts +44 -0
- package/styling/types.js +1 -0
- package/types.d.ts +1 -95
- package/types.js +1 -30
- /package/{hooks → pipeline}/useAugmentedRows.d.ts +0 -0
- /package/{hooks → pipeline}/useAugmentedRows.js +0 -0
- /package/{hooks → pipeline}/useDisplayRows.d.ts +0 -0
- /package/{hooks → pipeline}/useDisplayRows.js +0 -0
- /package/{hooks → pipeline}/useEditableFromFilterState.js +0 -0
- /package/{hooks → pipeline}/useFilter.js +0 -0
- /package/{hooks → pipeline}/useFilterStateFromEditable.js +0 -0
- /package/{hooks → pipeline}/useSortedRows.js +0 -0
- /package/{icons → selection}/deselectAll.d.ts +0 -0
- /package/{icons → selection}/deselectAll.js +0 -0
- /package/{icons → selection}/selectAll.d.ts +0 -0
- /package/{icons → selection}/selectAll.js +0 -0
- /package/{icons → sorting}/arrowPlaceholder.d.ts +0 -0
- /package/{icons → sorting}/arrowPlaceholder.js +0 -0
- /package/{icons → sorting}/downArrow.d.ts +0 -0
- /package/{icons → sorting}/downArrow.js +0 -0
- /package/{icons → sorting}/upArrow.d.ts +0 -0
- /package/{icons → sorting}/upArrow.js +0 -0
- /package/{hooks → util}/useControlledHover.d.ts +0 -0
- /package/{hooks → util}/useControlledHover.js +0 -0
package/ColHeaderCell.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { ColSortModel } from "./types";
|
|
2
|
+
import { ColSortModel } from "./sorting/types";
|
|
3
3
|
interface ColHeaderCellProps {
|
|
4
4
|
label: string;
|
|
5
5
|
sortModel?: ColSortModel;
|
|
6
6
|
ariaColIndex: number;
|
|
7
|
+
additionalClasses?: string[];
|
|
7
8
|
}
|
|
8
9
|
declare const ColHeaderCell: FC<ColHeaderCellProps>;
|
|
9
10
|
export default ColHeaderCell;
|
package/ColHeaderCell.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import downArrow from "./
|
|
4
|
-
import upArrow from "./
|
|
5
|
-
import arrowPlaceholder from "./
|
|
3
|
+
import downArrow from "./sorting/downArrow";
|
|
4
|
+
import upArrow from "./sorting/upArrow";
|
|
5
|
+
import arrowPlaceholder from "./sorting/arrowPlaceholder";
|
|
6
6
|
import classNames from "classnames";
|
|
7
|
-
import useControlledHover from "./
|
|
7
|
+
import useControlledHover from "./util/useControlledHover";
|
|
8
8
|
var ColHeaderCell = function (_a) {
|
|
9
|
-
var label = _a.label, sortModel = _a.sortModel, ariaColIndex = _a.ariaColIndex;
|
|
9
|
+
var label = _a.label, sortModel = _a.sortModel, ariaColIndex = _a.ariaColIndex, additionalClasses = _a.additionalClasses;
|
|
10
10
|
var _b = useControlledHover(), isHovering = _b.isHovering, handleMouseOver = _b.handleMouseOver, handleMouseOut = _b.handleMouseOut;
|
|
11
11
|
var handleClick = function () {
|
|
12
12
|
if (!sortModel) {
|
|
@@ -48,7 +48,7 @@ var ColHeaderCell = function (_a) {
|
|
|
48
48
|
return (_jsxs("th", { className: classNames({
|
|
49
49
|
"rbdg-clickable-grid-header-cell": sortModel,
|
|
50
50
|
"table-active": sortModel === null || sortModel === void 0 ? void 0 : sortModel.sortOrder,
|
|
51
|
-
}), onClick: sortModel && handleClick, onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, "aria-description": sortModel
|
|
51
|
+
}, additionalClasses || []), onClick: sortModel && handleClick, onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, "aria-description": sortModel
|
|
52
52
|
? "Column header"
|
|
53
53
|
: "Column header that can be clicked to change the sorting mode", "aria-colindex": ariaColIndex, children: [label, getSortSymbol()] }));
|
|
54
54
|
};
|
package/Grid.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { ColDef,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
maxPageButtons: number;
|
|
10
|
-
componentSize?: Size;
|
|
11
|
-
}
|
|
2
|
+
import { ColDef, RowDef } from "./types";
|
|
3
|
+
import { StyleModel } from "./styling/types";
|
|
4
|
+
import { EditModel } from "./editing/types";
|
|
5
|
+
import { SelectModel } from "./selection/types";
|
|
6
|
+
import { FilterModel } from "./filtering/types";
|
|
7
|
+
import { TableSortModel } from "./sorting/types";
|
|
8
|
+
import { GridPaginationState } from "./pagination/types";
|
|
12
9
|
export interface GridProps {
|
|
13
10
|
rows: RowDef[];
|
|
14
11
|
cols: ColDef[];
|
|
@@ -18,6 +15,7 @@ export interface GridProps {
|
|
|
18
15
|
selectModel?: SelectModel;
|
|
19
16
|
editModel?: EditModel;
|
|
20
17
|
caption?: string;
|
|
18
|
+
styleModel?: StyleModel;
|
|
21
19
|
}
|
|
22
20
|
declare const Grid: FC<GridProps>;
|
|
23
21
|
export default Grid;
|
package/Grid.js
CHANGED
|
@@ -2,40 +2,34 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
import ColHeaderCell from "./ColHeaderCell";
|
|
5
|
-
import useFilter from "./
|
|
5
|
+
import useFilter from "./pipeline/useFilter";
|
|
6
6
|
import ToggleButton from "./ToggleButton";
|
|
7
7
|
import FilterOptionsTable from "./filtering/FilterOptionsTable";
|
|
8
|
-
import useFilterStateFromEditable from "./
|
|
9
|
-
import useAugmentedRows from "./
|
|
10
|
-
import useSortedRows from "./
|
|
11
|
-
import useDisplayRows from "./
|
|
8
|
+
import useFilterStateFromEditable from "./pipeline/useFilterStateFromEditable";
|
|
9
|
+
import useAugmentedRows from "./pipeline/useAugmentedRows";
|
|
10
|
+
import useSortedRows from "./pipeline/useSortedRows";
|
|
11
|
+
import useDisplayRows from "./pipeline/useDisplayRows";
|
|
12
12
|
import SelectAllHeaderCell from "./selection/SelectAllHeaderCell";
|
|
13
13
|
import SelectionInput from "./selection/SelectionInput";
|
|
14
14
|
import Pagination from "./pagination/Pagination";
|
|
15
15
|
import classNames from "classnames";
|
|
16
16
|
import EditableRow from "./editing/EditableRow";
|
|
17
17
|
import inputStrsToRowDef from "./editing/inputStrsToRowDef";
|
|
18
|
+
import { unwrapAdditionalComponentsStyleModel, unwrapTableStyleModel, } from "./styling/styleModelUnwrappers";
|
|
19
|
+
import useCurrentPageRows from "./pipeline/useCurrentPageRows";
|
|
18
20
|
var Grid = function (_a) {
|
|
19
|
-
var
|
|
21
|
+
var _b;
|
|
22
|
+
var rows = _a.rows, cols = _a.cols, pagination = _a.pagination, sortModel = _a.sortModel, filterModel = _a.filterModel, selectModel = _a.selectModel, editModel = _a.editModel, caption = _a.caption, styleModel = _a.styleModel;
|
|
20
23
|
var editableFilterState = (filterModel === null || filterModel === void 0 ? void 0 : filterModel.tableFilterState) || null;
|
|
21
24
|
var filterState = useFilterStateFromEditable(cols, editableFilterState);
|
|
22
25
|
var augmentedRows = useAugmentedRows(rows);
|
|
23
26
|
var filteredRows = useFilter(augmentedRows, editableFilterState);
|
|
24
27
|
var sortedRows = useSortedRows(filteredRows, cols, sortModel);
|
|
25
|
-
var currentPageRows =
|
|
26
|
-
if (pagination === undefined) {
|
|
27
|
-
return sortedRows;
|
|
28
|
-
}
|
|
29
|
-
var pageSizeOptions = pagination.pageSizeOptions, pageSizeIndex = pagination.pageSizeIndex, currentPage = pagination.currentPage;
|
|
30
|
-
var pageSize = pageSizeOptions[pageSizeIndex];
|
|
31
|
-
var lowerIndex = pageSize * (currentPage - 1);
|
|
32
|
-
var upperIndex = lowerIndex + pageSize;
|
|
33
|
-
return sortedRows.slice(lowerIndex, upperIndex);
|
|
34
|
-
}, [sortedRows, pagination]);
|
|
28
|
+
var currentPageRows = useCurrentPageRows(sortedRows, pagination);
|
|
35
29
|
var showSelectCol = selectModel && selectModel.mode !== "row";
|
|
36
30
|
var ariaColIndexOffset = showSelectCol ? 1 : 0;
|
|
37
31
|
var displayRows = useDisplayRows(currentPageRows, cols, ariaColIndexOffset);
|
|
38
|
-
var
|
|
32
|
+
var _c = useState(false), filterOptionsVisible = _c[0], setFilterOptionsVisible = _c[1];
|
|
39
33
|
var handleToggleFilterOptions = function () {
|
|
40
34
|
setFilterOptionsVisible(!filterOptionsVisible);
|
|
41
35
|
};
|
|
@@ -132,28 +126,36 @@ var Grid = function (_a) {
|
|
|
132
126
|
indexSpecificCallback(rowDef);
|
|
133
127
|
};
|
|
134
128
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
129
|
+
var unwrappedTableModel = useMemo(function () { return unwrapTableStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel); }, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel]);
|
|
130
|
+
var unwrappedAdditionalStyleModel = useMemo(function () {
|
|
131
|
+
return unwrapAdditionalComponentsStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel);
|
|
132
|
+
}, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel]);
|
|
133
|
+
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [filterState && filterModel && (_jsxs("div", { "data-testid": "rbdg-filter-inputs-div", className: classNames(unwrappedAdditionalStyleModel.filterInputsDiv), children: [_jsx(ToggleButton, { isActive: filterOptionsVisible, label: "".concat(filterOptionsVisible ? "Hide" : "Show ", " Filter Options"), onClick: handleToggleFilterOptions, classes: (_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _b === void 0 ? void 0 : _b.filterUiToggleButton }), filterOptionsVisible && (_jsx(FilterOptionsTable, { caption: filterModel.filterTableCaption, filterState: filterState, setFilterState: filterModel.setTableFilterState, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel }))] })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames(unwrappedAdditionalStyleModel.tableAndPaginationDiv), children: [_jsxs("table", { className: classNames("table", {
|
|
134
|
+
"table-hover": rowsAreSelectable,
|
|
135
|
+
}, unwrappedTableModel.table), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames(unwrappedTableModel.caption), children: caption })), _jsx("thead", { className: classNames(unwrappedTableModel.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames(unwrappedTableModel.theadTr), children: [showSelectCol && (_jsx(SelectAllHeaderCell, { selectType: selectModel.type, onClick: selectAllOnClick, selectionExists: selectionExists, additionalClasses: unwrappedTableModel.rowSelectColTh })), cols.map(function (_a, index) {
|
|
136
|
+
var _b;
|
|
137
|
+
var name = _a.name, label = _a.label, sortable = _a.sortable;
|
|
138
|
+
var colSortModel = sortModel && sortable
|
|
139
|
+
? {
|
|
140
|
+
sortOrder: ((_b = sortModel.sortColDef) === null || _b === void 0 ? void 0 : _b.name) === name
|
|
141
|
+
? sortModel.sortColDef.order
|
|
142
|
+
: null,
|
|
143
|
+
setSortOrder: function (order) {
|
|
144
|
+
sortModel.setSortColDef(order && { name: name, order: order });
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
: undefined;
|
|
148
|
+
return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: unwrappedTableModel.theadTh(index) }, name));
|
|
149
|
+
}), editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames(unwrappedTableModel.editColTh), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(unwrappedTableModel.tbody), children: displayRows.map(function (row, index) {
|
|
150
|
+
return (_jsx(EditableRow, { onClick: getRowClickHandler(row.origIndex), className: classNames({
|
|
151
|
+
"table-active": selectedSet.has(row.origIndex),
|
|
152
|
+
}, unwrappedTableModel.tbodyTr(row.origIndex, index)), "aria-rowindex": index + 2, dataRowIndex: row.origIndex, "aria-selected": getAriaSelectedValue(row.origIndex), ariaColIndexOffset: ariaColIndexOffset, cellData: row.contents, updateCallback: getInputStrSubmitCallback &&
|
|
153
|
+
getInputStrSubmitCallback(row.origIndex), deleteCallback: (editModel === null || editModel === void 0 ? void 0 : editModel.getDeleteCallback) &&
|
|
154
|
+
editModel.getDeleteCallback(row.origIndex), dataCellClasses: function (colIndex) {
|
|
155
|
+
return unwrappedTableModel.tbodyTd(row.origIndex, index, colIndex);
|
|
156
|
+
}, dataCellInputClasses: function (colIndex) {
|
|
157
|
+
return unwrappedTableModel.tbodyTdInput(row.origIndex, index, colIndex);
|
|
158
|
+
}, editCellClasses: unwrappedTableModel.editColTd(row.origIndex, index), saveButtonClasses: unwrappedTableModel.editSaveButton(row.origIndex, index), deleteButtonClasses: unwrappedTableModel.editDeleteButton(row.origIndex, index), startButtonClasses: unwrappedTableModel.editStartButton(row.origIndex, index), cancelButtonClasses: unwrappedTableModel.editCancelButton(row.origIndex, index), children: showSelectCol && (_jsx("td", { className: classNames(unwrappedTableModel.rowSelectColTd(row.origIndex, index)), "aria-colindex": 1, children: _jsx(SelectionInput, { selected: selectedSet.has(row.origIndex), selectionInputModel: getSelectInputModel(row.origIndex, selectModel), selectCallback: getSelectHandler(row.origIndex), additionalClasses: unwrappedTableModel.rowSelectInput(row.origIndex, index) }) })) }, row.origIndex));
|
|
159
|
+
}) })] }), pagination && (_jsx(Pagination, { componentSize: pagination.componentSize || "medium", pageSizeOptions: pagination.pageSizeOptions, pageSizeIndex: pagination.pageSizeIndex, handleSetPageSizeIndex: pagination.setPageSizeIndex, handleSetPageNum: pagination.setCurrentPage, prePagingNumRows: sortedRows.length, maxPageButtons: pagination.maxPageButtons, currentPage: pagination.currentPage, pageSelectorJustifyContent: pagination.pageSelectorJustifyContent, pageSelectorAriaLabel: pagination.pageSelectorAriaLabel }))] })] }));
|
|
158
160
|
};
|
|
159
161
|
export default Grid;
|
package/ToggleButton.d.ts
CHANGED
package/ToggleButton.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
var ToggleButton = function (_a) {
|
|
5
|
-
var isActive = _a.isActive, label = _a.label, onClick = _a.onClick;
|
|
6
|
-
var baseClasses = ["btn"
|
|
5
|
+
var isActive = _a.isActive, label = _a.label, onClick = _a.onClick, classes = _a.classes;
|
|
6
|
+
var baseClasses = ["btn"];
|
|
7
7
|
var variableClasses = {
|
|
8
8
|
active: isActive,
|
|
9
9
|
};
|
|
10
|
-
return (_jsx("button", { type: "button", className: classNames(baseClasses, variableClasses
|
|
10
|
+
return (_jsx("button", { type: "button", className: classNames(baseClasses, variableClasses, classes, {
|
|
11
|
+
"btn-primary": !(classes && classes.length > 0),
|
|
12
|
+
}), "aria-pressed": isActive, onClick: onClick, children: label }));
|
|
11
13
|
};
|
|
12
14
|
export default ToggleButton;
|
|
@@ -6,6 +6,11 @@ export interface EditControlsCellProps {
|
|
|
6
6
|
isEditing: boolean;
|
|
7
7
|
saveCallback: () => void;
|
|
8
8
|
deleteCallback?: () => void;
|
|
9
|
+
editControlsCellClasses: string[];
|
|
10
|
+
saveButtonClasses: string[];
|
|
11
|
+
deleteButtonClasses: string[];
|
|
12
|
+
startButtonClasses: string[];
|
|
13
|
+
cancelButtonClasses: string[];
|
|
9
14
|
}
|
|
10
15
|
declare const EditControlsCell: FC<EditControlsCellProps>;
|
|
11
16
|
export default EditControlsCell;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
var stopPropagationWrapper = function (fn) { return function (event) {
|
|
4
|
+
event.stopPropagation();
|
|
5
|
+
fn();
|
|
6
|
+
}; };
|
|
2
7
|
var EditControlsCell = function (_a) {
|
|
3
|
-
var ariaColIndex = _a.ariaColIndex, beginEditingCallback = _a.beginEditingCallback, cancelEditingCallback = _a.cancelEditingCallback, isEditing = _a.isEditing, saveCallback = _a.saveCallback, deleteCallback = _a.deleteCallback;
|
|
4
|
-
return (_jsx("td", { "aria-colindex": ariaColIndex, children: _jsx("div", { className: "hstack gap-2", children: isEditing ? (_jsxs(_Fragment, { children: [_jsx("button", { className:
|
|
8
|
+
var ariaColIndex = _a.ariaColIndex, beginEditingCallback = _a.beginEditingCallback, cancelEditingCallback = _a.cancelEditingCallback, isEditing = _a.isEditing, saveCallback = _a.saveCallback, deleteCallback = _a.deleteCallback, editControlsCellClasses = _a.editControlsCellClasses, saveButtonClasses = _a.saveButtonClasses, deleteButtonClasses = _a.deleteButtonClasses, startButtonClasses = _a.startButtonClasses, cancelButtonClasses = _a.cancelButtonClasses;
|
|
9
|
+
return (_jsx("td", { "aria-colindex": ariaColIndex, className: classNames(editControlsCellClasses), children: _jsx("div", { className: "hstack gap-2", children: isEditing ? (_jsxs(_Fragment, { children: [_jsx("button", { className: classNames("btn", cancelButtonClasses.length === 0
|
|
10
|
+
? ["btn-secondary"]
|
|
11
|
+
: cancelButtonClasses), onClick: stopPropagationWrapper(cancelEditingCallback), children: "Cancel" }), _jsx("button", { className: classNames("btn", saveButtonClasses.length === 0
|
|
12
|
+
? ["btn-primary"]
|
|
13
|
+
: saveButtonClasses), onClick: stopPropagationWrapper(saveCallback), children: "Save" })] })) : (_jsxs(_Fragment, { children: [deleteCallback && (_jsx("button", { className: classNames("btn", deleteButtonClasses.length === 0
|
|
14
|
+
? ["btn-primary"]
|
|
15
|
+
: deleteButtonClasses), onClick: stopPropagationWrapper(deleteCallback), children: "Delete" })), _jsx("button", { className: classNames("btn", startButtonClasses.length === 0
|
|
16
|
+
? ["btn-primary"]
|
|
17
|
+
: startButtonClasses), onClick: stopPropagationWrapper(beginEditingCallback), children: "Edit" })] })) }) }));
|
|
5
18
|
};
|
|
6
19
|
export default EditControlsCell;
|
package/editing/EditableRow.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
-
import { CellData } from "../types";
|
|
3
2
|
import React from "react";
|
|
3
|
+
import { CellData } from "./types";
|
|
4
4
|
export type EditableRowProps = Pick<React.ComponentProps<"tr">, "onClick" | "className" | "aria-rowindex" | "aria-selected"> & {
|
|
5
5
|
ariaColIndexOffset: number;
|
|
6
6
|
dataRowIndex: number;
|
|
@@ -8,6 +8,13 @@ export type EditableRowProps = Pick<React.ComponentProps<"tr">, "onClick" | "cla
|
|
|
8
8
|
cellData: CellData[];
|
|
9
9
|
updateCallback?: (values: string[]) => void;
|
|
10
10
|
deleteCallback?: () => void;
|
|
11
|
+
dataCellClasses: (colIndex: number) => string[];
|
|
12
|
+
dataCellInputClasses: (colIndex: number) => string[];
|
|
13
|
+
editCellClasses: string[];
|
|
14
|
+
deleteButtonClasses: string[];
|
|
15
|
+
cancelButtonClasses: string[];
|
|
16
|
+
startButtonClasses: string[];
|
|
17
|
+
saveButtonClasses: string[];
|
|
11
18
|
};
|
|
12
19
|
declare const EditableRow: FC<EditableRowProps>;
|
|
13
20
|
export default EditableRow;
|
package/editing/EditableRow.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useRef, useState } from "react";
|
|
4
4
|
import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
|
|
5
5
|
import EditControlsCell from "./EditControlsCell";
|
|
6
|
+
import classNames from "classnames";
|
|
6
7
|
var initValueToFormValue = function (value, type) {
|
|
7
8
|
switch (type) {
|
|
8
9
|
case "date":
|
|
@@ -28,7 +29,7 @@ var colDataTypeToInputType = function (colDataType) {
|
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
var EditableRow = function (_a) {
|
|
31
|
-
var ariaColIndexOffset = _a.ariaColIndexOffset, cellData = _a.cellData, children = _a.children, updateCallback = _a.updateCallback, deleteCallback = _a.deleteCallback, onClick = _a.onClick, className = _a.className, ariaRowIndex = _a["aria-rowindex"], ariaSelected = _a["aria-selected"], dataRowIndex = _a.dataRowIndex;
|
|
32
|
+
var ariaColIndexOffset = _a.ariaColIndexOffset, cellData = _a.cellData, children = _a.children, updateCallback = _a.updateCallback, deleteCallback = _a.deleteCallback, onClick = _a.onClick, className = _a.className, ariaRowIndex = _a["aria-rowindex"], ariaSelected = _a["aria-selected"], dataRowIndex = _a.dataRowIndex, dataCellClasses = _a.dataCellClasses, dataCellInputClasses = _a.dataCellInputClasses, editCellClasses = _a.editCellClasses, saveButtonClasses = _a.saveButtonClasses, startButtonClasses = _a.startButtonClasses, cancelButtonClasses = _a.cancelButtonClasses, deleteButtonClasses = _a.deleteButtonClasses;
|
|
32
33
|
var trRef = useRef(null);
|
|
33
34
|
var _b = useState(false), isEditing = _b[0], setIsEditing = _b[1];
|
|
34
35
|
var handleSave = function () {
|
|
@@ -60,7 +61,7 @@ var EditableRow = function (_a) {
|
|
|
60
61
|
};
|
|
61
62
|
return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-rowindex": dataRowIndex, children: [children, cellData.map(function (_a, index) {
|
|
62
63
|
var type = _a.type, value = _a.value, formattedValue = _a.formattedValue, label = _a.label;
|
|
63
|
-
return (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: "editable-cell-input-".concat(dataRowIndex, "-").concat(index), className: "form-control", type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index));
|
|
64
|
-
}), updateCallback && (_jsx(EditControlsCell, { ariaColIndex: ariaColIndexOffset + cellData.length + 1, beginEditingCallback: function () { return setIsEditing(true); }, cancelEditingCallback: function () { return setIsEditing(false); }, isEditing: isEditing, saveCallback: handleSave, deleteCallback: deleteCallback }))] }));
|
|
64
|
+
return (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, className: classNames(dataCellClasses(index)), children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: "editable-cell-input-".concat(dataRowIndex, "-").concat(index), className: classNames("form-control", dataCellInputClasses(index)), type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index));
|
|
65
|
+
}), updateCallback && (_jsx(EditControlsCell, { ariaColIndex: ariaColIndexOffset + cellData.length + 1, beginEditingCallback: function () { return setIsEditing(true); }, cancelEditingCallback: function () { return setIsEditing(false); }, isEditing: isEditing, saveCallback: handleSave, deleteCallback: deleteCallback, editControlsCellClasses: editCellClasses, startButtonClasses: startButtonClasses, deleteButtonClasses: deleteButtonClasses, cancelButtonClasses: cancelButtonClasses, saveButtonClasses: saveButtonClasses }))] }));
|
|
65
66
|
};
|
|
66
67
|
export default EditableRow;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColDataType, ColDataTypeStrings, RowDef } from "../types";
|
|
2
|
+
export interface CellData {
|
|
3
|
+
fieldName: string;
|
|
4
|
+
value: ColDataType;
|
|
5
|
+
type: ColDataTypeStrings;
|
|
6
|
+
ariaColIndex: number;
|
|
7
|
+
formattedValue: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
export type UpdateCallbackGenerator = (origIndex: number) => (rowDef: RowDef) => void;
|
|
11
|
+
export interface EditModel {
|
|
12
|
+
getUpdateCallback: UpdateCallbackGenerator;
|
|
13
|
+
getDeleteCallback?: (origIndex: number) => () => void;
|
|
14
|
+
}
|
package/editing/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { DateFormFilterState } from "./types";
|
|
3
|
-
|
|
3
|
+
import { CommonFilterRowStyleProps } from "./FilterRow";
|
|
4
|
+
export type DateFilterRowProps = {
|
|
5
|
+
ariaRowIndex: number;
|
|
4
6
|
includeTime: boolean;
|
|
5
7
|
columnLabel: string;
|
|
6
8
|
filterState: DateFormFilterState;
|
|
7
9
|
setFilterState: (filterState: DateFormFilterState) => void;
|
|
8
|
-
|
|
10
|
+
schemeSelectClasses: string[];
|
|
11
|
+
enableInputClasses: string[];
|
|
12
|
+
startDateInputClasses: string[];
|
|
13
|
+
endDateInputClasses: string[];
|
|
14
|
+
} & CommonFilterRowStyleProps;
|
|
9
15
|
declare const DateFilterRow: FC<DateFilterRowProps>;
|
|
10
16
|
export default DateFilterRow;
|
|
@@ -11,10 +11,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useMemo } from "react";
|
|
14
|
-
import { dateFilterSchemeNames,
|
|
14
|
+
import { dateFilterSchemeNames, } from "./types";
|
|
15
15
|
import { nanoid } from "nanoid/non-secure";
|
|
16
|
+
import FilterRow from "./FilterRow";
|
|
17
|
+
import classNames from "classnames";
|
|
16
18
|
var DateFilterRow = function (_a) {
|
|
17
|
-
var includeTime = _a.includeTime, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState;
|
|
19
|
+
var ariaRowIndex = _a.ariaRowIndex, includeTime = _a.includeTime, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState, schemeSelectClasses = _a.schemeSelectClasses, enableInputClasses = _a.enableInputClasses, startDateInputClasses = _a.startDateInputClasses, endDateInputClasses = _a.endDateInputClasses, tdClasses = _a.tdClasses, trClasses = _a.trClasses;
|
|
18
20
|
var handleOpChange = function (_a) {
|
|
19
21
|
var target = _a.target;
|
|
20
22
|
setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
|
|
@@ -36,10 +38,9 @@ var DateFilterRow = function (_a) {
|
|
|
36
38
|
var inputId = useMemo(function () { return nanoid(); }, []);
|
|
37
39
|
var startDateInputId = "$startDate-".concat(inputId);
|
|
38
40
|
var endDateInputId = "$endDate-".concat(inputId);
|
|
39
|
-
var checkboxLabel = "".concat(columnLabel, " Column Filter Toggle");
|
|
40
|
-
var opSelectLabel = "".concat(columnLabel, " Column Filter Operator Selection");
|
|
41
41
|
var startDateInputLabel = "".concat(columnLabel, " Column Filter Start Date");
|
|
42
42
|
var endDateInputLabel = "".concat(columnLabel, " Column Filter End Date");
|
|
43
|
-
|
|
43
|
+
var searchStringInputCellContents = (_jsxs(_Fragment, { children: [scheme !== "endAt" && (_jsxs(_Fragment, { children: [scheme === "between" && (_jsx("label", { htmlFor: startDateInputId, children: "Start Date" })), _jsx("input", { id: startDateInputId, className: classNames("form-control", startDateInputClasses), type: inputType, required: enabled, disabled: !enabled, value: startDate, onChange: handleStartValueChange, "aria-label": startDateInputLabel })] })), scheme !== "startFrom" && (_jsxs(_Fragment, { children: [scheme === "between" && (_jsx("label", { htmlFor: endDateInputId, children: "End Date" })), _jsx("input", { id: endDateInputId, className: classNames("form-control", endDateInputClasses), type: inputType, required: enabled, disabled: !enabled, value: endDate, onChange: handleEndValueChange, "aria-label": endDateInputLabel })] }))] }));
|
|
44
|
+
return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: filterState.type === "date" ? "Date" : "Datetime", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: dateFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
|
|
44
45
|
};
|
|
45
46
|
export default DateFilterRow;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { EditableTableFilterState, TableFilterState } from "
|
|
2
|
+
import { EditableTableFilterState, TableFilterState } from "./types";
|
|
3
|
+
import { FilterInputTableStyleModel } from "../styling/types";
|
|
3
4
|
interface FilterOptionsTableProps {
|
|
4
5
|
filterState: TableFilterState;
|
|
5
6
|
setFilterState: (filterState: EditableTableFilterState) => void;
|
|
7
|
+
caption?: string;
|
|
8
|
+
styleModel?: FilterInputTableStyleModel;
|
|
6
9
|
}
|
|
7
10
|
declare const FilterOptionsTable: FC<FilterOptionsTableProps>;
|
|
8
11
|
export default FilterOptionsTable;
|
|
@@ -9,12 +9,23 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
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
|
+
};
|
|
12
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useState } from "react";
|
|
22
|
+
import { useMemo, useState } from "react";
|
|
14
23
|
import StringFilterRow from "./StringFilterRow";
|
|
15
24
|
import NumberFilterRow from "./NumberFilterRow";
|
|
16
25
|
import useFormStateFromTableFilterState from "./useFormStateFromTableFilterState";
|
|
17
26
|
import DateFilterRow from "./DateFilterRow";
|
|
27
|
+
import classNames from "classnames";
|
|
28
|
+
import { unwrapFilterInputTableStyleModel } from "../styling/styleModelUnwrappers";
|
|
18
29
|
var convertFilterFormStateToEditableState = function (filterFormState) {
|
|
19
30
|
return Object.keys(filterFormState).reduce(function (editableState, colName) {
|
|
20
31
|
var rowFilterFormState = filterFormState[colName];
|
|
@@ -62,11 +73,12 @@ var convertFilterFormStateToEditableState = function (filterFormState) {
|
|
|
62
73
|
}, {});
|
|
63
74
|
};
|
|
64
75
|
var FilterOptionsTable = function (_a) {
|
|
65
|
-
var filterState = _a.filterState, setFilterState = _a.setFilterState;
|
|
76
|
+
var filterState = _a.filterState, setFilterState = _a.setFilterState, caption = _a.caption, styleModel = _a.styleModel;
|
|
66
77
|
var formFilterState = useFormStateFromTableFilterState(filterState);
|
|
67
78
|
var _b = useState(formFilterState), formState = _b[0], setFormState = _b[1];
|
|
79
|
+
var unwrappedStyleModel = useMemo(function () { return unwrapFilterInputTableStyleModel(styleModel); }, [styleModel]);
|
|
68
80
|
var getRows = function () {
|
|
69
|
-
return Object.keys(formState).map(function (colName) {
|
|
81
|
+
return Object.keys(formState).map(function (colName, index) {
|
|
70
82
|
function getColStateSetter(colName) {
|
|
71
83
|
return function (rowState) {
|
|
72
84
|
var _a;
|
|
@@ -77,14 +89,20 @@ var FilterOptionsTable = function (_a) {
|
|
|
77
89
|
var colFilterState = formState[colName];
|
|
78
90
|
switch (colFilterState.type) {
|
|
79
91
|
case "string": {
|
|
80
|
-
return (_jsx(StringFilterRow, { columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName)
|
|
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));
|
|
81
95
|
}
|
|
82
96
|
case "number": {
|
|
83
|
-
return (_jsx(NumberFilterRow, { columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName)
|
|
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));
|
|
84
100
|
}
|
|
85
101
|
default: {
|
|
86
102
|
// date or datetime
|
|
87
|
-
return (_jsx(DateFilterRow, { includeTime: colFilterState.type === "datetime", columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName)
|
|
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));
|
|
88
106
|
}
|
|
89
107
|
}
|
|
90
108
|
});
|
|
@@ -94,6 +112,7 @@ var FilterOptionsTable = function (_a) {
|
|
|
94
112
|
var editableTableFilterState = convertFilterFormStateToEditableState(formState);
|
|
95
113
|
setFilterState(editableTableFilterState);
|
|
96
114
|
};
|
|
97
|
-
|
|
115
|
+
// TODO: consider using an accordion to show and hide this component
|
|
116
|
+
return (_jsxs("form", { onSubmit: onSubmit, children: [_jsxs("table", { className: classNames.apply(void 0, __spreadArray(["table"], unwrappedStyleModel.table, false)), children: [caption && (_jsx("caption", { className: classNames(unwrappedStyleModel.caption), children: caption })), _jsx("thead", { className: classNames.apply(void 0, unwrappedStyleModel.thead), children: _jsx("tr", { className: classNames.apply(void 0, unwrappedStyleModel.theadTr), children: ["Enabled", "Column", "Type", "Operator", "Value"].map(function (colName, index) { return (_jsx("th", { className: classNames.apply(void 0, unwrappedStyleModel.theadTh(index)), children: colName }, index)); }) }) }), _jsx("tbody", { className: classNames.apply(void 0, unwrappedStyleModel.tbody), children: getRows() })] }), _jsx("button", { className: classNames("btn", { "btn-secondary": unwrappedStyleModel.submitButton.length === 0 }, unwrappedStyleModel.submitButton), type: "submit", children: "Submit" })] }));
|
|
98
117
|
};
|
|
99
118
|
export default FilterOptionsTable;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChangeEventHandler, ReactNode } from "react";
|
|
2
|
+
export interface FilterRowProps<FilterScheme extends string> {
|
|
3
|
+
ariaRowIndex: number;
|
|
4
|
+
columnLabel: string;
|
|
5
|
+
typeLabel: string;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
enabledChangeHandler: ChangeEventHandler<HTMLInputElement>;
|
|
8
|
+
currentScheme: string;
|
|
9
|
+
handleSchemeChange: ChangeEventHandler<HTMLSelectElement>;
|
|
10
|
+
schemesToLabels: Record<FilterScheme, string>;
|
|
11
|
+
searchStringInputCellContents: ReactNode;
|
|
12
|
+
trClasses: string[];
|
|
13
|
+
tdClasses: (colIndex: number) => string[];
|
|
14
|
+
inputClasses: string[];
|
|
15
|
+
selectClasses: string[];
|
|
16
|
+
}
|
|
17
|
+
export type CommonFilterRowStyleProps = Pick<FilterRowProps<string>, "trClasses" | "tdClasses">;
|
|
18
|
+
export declare function FilterRow<FilterScheme extends string = string>(props: FilterRowProps<FilterScheme>): ReactNode;
|
|
19
|
+
export default FilterRow;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import classNames from "classnames";
|
|
12
|
+
export function FilterRow(props) {
|
|
13
|
+
var ariaRowIndex = props.ariaRowIndex, columnLabel = props.columnLabel, typeLabel = props.typeLabel, enabled = props.enabled, enabledChangeHandler = props.enabledChangeHandler, currentScheme = props.currentScheme, handleSchemeChange = props.handleSchemeChange, schemesToLabels = props.schemesToLabels, searchStringInputCellContents = props.searchStringInputCellContents, trClasses = props.trClasses, tdClasses = props.tdClasses, inputClasses = props.inputClasses, selectClasses = props.selectClasses;
|
|
14
|
+
var checkboxLabel = "".concat(columnLabel, " Column Filter Toggle");
|
|
15
|
+
var opSelectLabel = "".concat(columnLabel, " Column Filter Operator Selection");
|
|
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.apply(void 0, __spreadArray(["form-select"], selectClasses, false)), value: currentScheme, onChange: handleSchemeChange, children: Object.keys(schemesToLabels).map(function (scheme) { return (_jsx("option", { value: scheme, children: schemesToLabels[scheme] }, scheme)); }) }) }), _jsx("td", { className: classNames(tdClasses(4)), "aria-colindex": 5, children: searchStringInputCellContents })] }));
|
|
17
|
+
}
|
|
18
|
+
export default FilterRow;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { NumberFormFilterState } from "./types";
|
|
3
|
-
|
|
3
|
+
import { CommonFilterRowStyleProps } from "./FilterRow";
|
|
4
|
+
export type NumberFilterRowProps = {
|
|
5
|
+
ariaRowIndex: number;
|
|
4
6
|
columnLabel: string;
|
|
5
7
|
filterState: NumberFormFilterState;
|
|
6
8
|
setFilterState: (filterState: NumberFormFilterState) => void;
|
|
7
|
-
|
|
9
|
+
schemeSelectClasses: string[];
|
|
10
|
+
enableInputClasses: string[];
|
|
11
|
+
numberInputClasses: string[];
|
|
12
|
+
} & CommonFilterRowStyleProps;
|
|
8
13
|
declare const NumberFilterRow: FC<NumberFilterRowProps>;
|
|
9
14
|
export default NumberFilterRow;
|
|
@@ -9,10 +9,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx
|
|
13
|
-
import { numberFilterSchemeNames,
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { numberFilterSchemeNames, } from "./types";
|
|
14
|
+
import FilterRow from "./FilterRow";
|
|
15
|
+
import classNames from "classnames";
|
|
14
16
|
var NumberFilterRow = function (_a) {
|
|
15
|
-
var columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState;
|
|
17
|
+
var ariaRowIndex = _a.ariaRowIndex, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState, schemeSelectClasses = _a.schemeSelectClasses, enableInputClasses = _a.enableInputClasses, numberInputClasses = _a.numberInputClasses, tdClasses = _a.tdClasses, trClasses = _a.trClasses;
|
|
16
18
|
var handleOpChange = function (_a) {
|
|
17
19
|
var target = _a.target;
|
|
18
20
|
setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
|
|
@@ -26,9 +28,8 @@ var NumberFilterRow = function (_a) {
|
|
|
26
28
|
setFilterState(__assign(__assign({}, filterState), { inputValue: target.value }));
|
|
27
29
|
};
|
|
28
30
|
var enabled = filterState.enabled, scheme = filterState.scheme, inputValue = filterState.inputValue;
|
|
29
|
-
var checkboxLabel = "".concat(columnLabel, " Column Filter Toggle");
|
|
30
|
-
var opSelectLabel = "".concat(columnLabel, " Column Filter Operator Selection");
|
|
31
31
|
var valueInputLabel = "".concat(columnLabel, " Column Filter Value");
|
|
32
|
-
|
|
32
|
+
var searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control", numberInputClasses), type: "number", required: enabled, disabled: !enabled, value: inputValue, onChange: handleNumInputValueChange }));
|
|
33
|
+
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 }));
|
|
33
34
|
};
|
|
34
35
|
export default NumberFilterRow;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { CommonFilterRowStyleProps } from "./FilterRow";
|
|
3
|
+
import { StringFilterState } from "./types";
|
|
4
|
+
type StringFilterRowProps = {
|
|
5
|
+
ariaRowIndex: number;
|
|
4
6
|
columnLabel: string;
|
|
5
7
|
filterState: StringFilterState;
|
|
6
8
|
setFilterState: (filterState: StringFilterState) => void;
|
|
7
|
-
|
|
9
|
+
schemeSelectClasses: string[];
|
|
10
|
+
enableInputClasses: string[];
|
|
11
|
+
searchStringInputClasses: string[];
|
|
12
|
+
} & CommonFilterRowStyleProps;
|
|
8
13
|
declare const StringFilterRow: FC<StringFilterRowProps>;
|
|
9
14
|
export default StringFilterRow;
|