@absreim/react-bootstrap-data-grid-pro 2.7.0 → 3.0.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 +1 -4
- package/grid/InternalGrid.d.ts +0 -2
- package/grid/InternalGrid.js +31 -29
- package/grid/editing/EditControlsCell.d.ts +5 -5
- package/grid/editing/EditControlsCell.js +1 -9
- package/grid/editing/EditableRow.d.ts +7 -7
- package/grid/editing/EditableRow.js +1 -1
- package/grid/export/ExportForm.d.ts +1 -0
- package/grid/export/ExportForm.js +3 -3
- package/grid/filtering/DateFilterRow.d.ts +4 -4
- package/grid/filtering/DateFilterRow.js +1 -1
- package/grid/filtering/FilterOptionsTable.d.ts +1 -0
- package/grid/filtering/FilterOptionsTable.js +14 -8
- package/grid/filtering/FilterRow.d.ts +4 -4
- package/grid/filtering/FilterRow.js +1 -1
- package/grid/filtering/NumberFilterRow.d.ts +3 -3
- package/grid/filtering/NumberFilterRow.js +1 -1
- package/grid/filtering/StringFilterRow.d.ts +3 -3
- package/grid/filtering/StringFilterRow.js +1 -1
- package/grid/main/BodyRows.d.ts +2 -2
- package/grid/main/BodyRows.js +18 -2
- package/grid/pagination/Pagination.d.ts +1 -1
- package/grid/pagination/Pagination.js +6 -3
- package/grid/pagination/types.d.ts +1 -1
- package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +2 -2
- package/grid/selection/SelectAllHeaderCell.d.ts +1 -1
- package/grid/selection/SelectAllHeaderCell.js +2 -4
- package/grid/selection/SelectionInput.d.ts +1 -1
- package/grid/styling/types.d.ts +20 -21
- package/grid/toolbar/ToolbarContainer.d.ts +2 -2
- package/grid/toolbar/ToolbarContainer.js +11 -7
- package/grid/toolbar/types.d.ts +8 -0
- package/grid/toolbar/useInterfaces.d.ts +2 -8
- package/grid/toolbar/useInterfaces.js +9 -5
- package/grid/types.d.ts +5 -6
- package/grid-pro/GridPro.js +1 -4
- package/package.json +1 -1
- package/grid/main/ToggleButton.d.ts +0 -9
- package/grid/main/ToggleButton.js +0 -13
- package/grid/pipeline/useUnwrappedGridStyles.d.ts +0 -7
- package/grid/pipeline/useUnwrappedGridStyles.js +0 -15
- package/grid/styling/styleModelUnwrappers.d.ts +0 -4
- package/grid/styling/styleModelUnwrappers.js +0 -47
package/grid/Grid.js
CHANGED
|
@@ -5,7 +5,6 @@ import InternalGrid from "./InternalGrid";
|
|
|
5
5
|
import ColHeaderCell from "./main/ColHeaderCell";
|
|
6
6
|
import useCombinedPipeline from "./pipeline/useCombinedPipeline";
|
|
7
7
|
import useGridSelectionFns from "./pipeline/useGridSelectionFns";
|
|
8
|
-
import useUnwrappedGridStyles from "./pipeline/useUnwrappedGridStyles";
|
|
9
8
|
import useGetInputStrSubmitCallback from "./pipeline/useGetInputStrSubmitCallback";
|
|
10
9
|
import useAugFormattedRows from "./pipeline/useAugFormattedRows";
|
|
11
10
|
import BodyRows from "./main/BodyRows";
|
|
@@ -21,7 +20,6 @@ const Grid = (props) => {
|
|
|
21
20
|
});
|
|
22
21
|
const { sortedRowsOutput: { sortColDef, setSortColDef, sortingEnabled }, showSelectCol, displayRows, } = combinedPipelineOutput;
|
|
23
22
|
const gridSelectionFns = useGridSelectionFns(selectModel, rows);
|
|
24
|
-
const unwrappedStyles = useUnwrappedGridStyles(styleModel);
|
|
25
23
|
const getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
|
|
26
24
|
const colNameToWidth = useMemo(() => {
|
|
27
25
|
const map = {};
|
|
@@ -42,11 +40,10 @@ const Grid = (props) => {
|
|
|
42
40
|
return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: ((_a = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _a === void 0 ? void 0 : _a.theadTh) &&
|
|
43
41
|
styleModel.mainTableStyleModel.theadTh(index), width: width }, name));
|
|
44
42
|
});
|
|
45
|
-
const bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel,
|
|
43
|
+
const bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel, combinedPipelineOutput: combinedPipelineOutput, editModel: editModel, getInputStrSubmitCallback: getInputStrSubmitCallback, tableStyleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel }));
|
|
46
44
|
return (_jsx(InternalGrid, { gridProps: props, hooks: {
|
|
47
45
|
pipelineOutput: combinedPipelineOutput,
|
|
48
46
|
selectFns: gridSelectionFns,
|
|
49
|
-
unwrappedStyles,
|
|
50
47
|
}, slots: { colHeaderCells, bodyRows } }));
|
|
51
48
|
};
|
|
52
49
|
export default Grid;
|
package/grid/InternalGrid.d.ts
CHANGED
|
@@ -2,13 +2,11 @@ import { FC, ReactNode } from "react";
|
|
|
2
2
|
import { BaseGridProps } from "./types";
|
|
3
3
|
import { UseCombinedPipelineHook } from "./pipeline/useCombinedPipeline";
|
|
4
4
|
import { UseGridSelectionFnsHook } from "./pipeline/useGridSelectionFns";
|
|
5
|
-
import { UseUnwrappedGridStylesHook } from "./pipeline/useUnwrappedGridStyles";
|
|
6
5
|
export interface InternalGridProps {
|
|
7
6
|
gridProps: BaseGridProps;
|
|
8
7
|
hooks: {
|
|
9
8
|
selectFns: UseGridSelectionFnsHook;
|
|
10
9
|
pipelineOutput: UseCombinedPipelineHook;
|
|
11
|
-
unwrappedStyles: UseUnwrappedGridStylesHook;
|
|
12
10
|
};
|
|
13
11
|
slots: {
|
|
14
12
|
colHeaderCells: ReactNode;
|
package/grid/InternalGrid.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
3
|
-
import { useMemo
|
|
4
|
-
import ToggleButton from "./main/ToggleButton";
|
|
5
|
-
import FilterOptionsTable from "./filtering/FilterOptionsTable";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
6
4
|
import SelectAllHeaderCell from "./selection/SelectAllHeaderCell";
|
|
7
5
|
import Pagination from "./pagination/Pagination";
|
|
8
6
|
import classNames from "classnames";
|
|
@@ -10,47 +8,51 @@ import useInterfaces from "./toolbar/useInterfaces";
|
|
|
10
8
|
import ToolbarContainer from "./toolbar/ToolbarContainer";
|
|
11
9
|
import useExportFn from "./export/useExportFn";
|
|
12
10
|
import getWidthStyle from "./util/getWidthStyle";
|
|
13
|
-
const InternalGrid = ({ gridProps: { rows, cols, pagination, filterModel, selectModel, editModel, caption, styleModel,
|
|
14
|
-
var _a;
|
|
11
|
+
const InternalGrid = ({ gridProps: { rows, cols, pagination, filterModel, selectModel, editModel, caption, styleModel, displayMode, allowExport, }, hooks: { pipelineOutput, selectFns }, slots: { colHeaderCells, bodyRows, prefixHeader }, classes, }) => {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
15
13
|
const { normalizedTableFilterModel, filteredRows, filterState, sortedRowsOutput: { sortedRows }, currentPageRowsOutput: { paginatedRows, normalizedModel }, showSelectCol, } = pipelineOutput;
|
|
16
|
-
const [filterOptionsVisible, setFilterOptionsVisible] = useState(false);
|
|
17
14
|
const exportFnInfo = useExportFn({
|
|
18
15
|
rows,
|
|
19
16
|
cols,
|
|
20
17
|
filteredRows: filterModel && filteredRows,
|
|
21
18
|
currentPageRows: pagination && paginatedRows,
|
|
22
19
|
});
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
const showToolbar = filterModel || allowExport;
|
|
21
|
+
const toolbarPropGen = useMemo(() => (closeUiCallback) => {
|
|
22
|
+
return {
|
|
23
|
+
filtering: filterState && filterModel && normalizedTableFilterModel
|
|
24
|
+
? {
|
|
25
|
+
filterState: filterState,
|
|
26
|
+
setFilterState: normalizedTableFilterModel.setTableFilterState,
|
|
27
|
+
caption: filterModel.filterTableCaption,
|
|
28
|
+
styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
29
|
+
closeFormCallback: closeUiCallback,
|
|
30
|
+
}
|
|
31
|
+
: undefined,
|
|
32
|
+
exporting: allowExport
|
|
33
|
+
? {
|
|
34
|
+
exportFnInfo,
|
|
35
|
+
styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel,
|
|
36
|
+
closeCallback: closeUiCallback,
|
|
37
|
+
}
|
|
38
|
+
: undefined,
|
|
39
|
+
};
|
|
40
|
+
}, [
|
|
41
|
+
allowExport,
|
|
36
42
|
exportFnInfo,
|
|
37
43
|
filterModel,
|
|
38
44
|
filterState,
|
|
39
45
|
normalizedTableFilterModel,
|
|
40
46
|
styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel,
|
|
41
47
|
styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
42
|
-
useToolbar,
|
|
43
48
|
]);
|
|
44
|
-
const toolbarInterfaces = useInterfaces(
|
|
45
|
-
const handleToggleFilterOptions = () => {
|
|
46
|
-
setFilterOptionsVisible(!filterOptionsVisible);
|
|
47
|
-
};
|
|
49
|
+
const toolbarInterfaces = useInterfaces(toolbarPropGen);
|
|
48
50
|
const { rowsAreSelectable, selectionInfo, selectAllOnClick } = selectFns;
|
|
49
|
-
const
|
|
50
|
-
const mainTable = (_jsxs("table", { className: classNames("table", {
|
|
51
|
+
const mainTable = (_jsxs("table", { className: classNames({
|
|
51
52
|
"table-hover": rowsAreSelectable,
|
|
52
53
|
"d-block": displayMode === "block",
|
|
53
|
-
},
|
|
54
|
-
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(
|
|
54
|
+
}, ((_a = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _a === void 0 ? void 0 : _a.table) || "table"), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.caption), children: caption })), _jsx("thead", { className: classNames((_c = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _c === void 0 ? void 0 : _c.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames((_d = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _d === void 0 ? void 0 : _d.theadTr, (classes === null || classes === void 0 ? void 0 : classes.headerRow) || []), children: [prefixHeader, showSelectCol && (_jsx(SelectAllHeaderCell, { style: getWidthStyle(selectModel === null || selectModel === void 0 ? void 0 : selectModel.selectColWidth), selectionInfo: selectionInfo, onClick: selectAllOnClick, totalRows: rows.length, customClasses: (_e = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _e === void 0 ? void 0 : _e.rowSelectColTh, colIndexOffset: prefixHeader ? 1 : 0 })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames((_f = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _f === void 0 ? void 0 : _f.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(classNames((_g = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _g === void 0 ? void 0 : _g.tbody)), children: bodyRows })] }));
|
|
55
|
+
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames((_h = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _h === void 0 ? void 0 : _h.topLevelDiv), children: [showToolbar && (_jsx(ToolbarContainer, { interfaceGen: toolbarInterfaces, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbarStyleModel })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames((_j = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _j === void 0 ? void 0 : _j.tableAndPaginationDiv), children: [_jsx("div", { "data-testid": "rbdg-table-div", className: classNames(((_k = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _k === void 0 ? void 0 : _k.tableDiv) ||
|
|
56
|
+
"table-responsive"), children: mainTable }), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: (_l = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _l === void 0 ? void 0 : _l.paginationUiDiv }))] })] }));
|
|
55
57
|
};
|
|
56
58
|
export default InternalGrid;
|
|
@@ -6,11 +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
|
+
editControlsCellClasses: string[] | null;
|
|
10
|
+
saveButtonClasses: string[] | null;
|
|
11
|
+
deleteButtonClasses: string[] | null;
|
|
12
|
+
startButtonClasses: string[] | null;
|
|
13
|
+
cancelButtonClasses: string[] | null;
|
|
14
14
|
style?: CSSProperties;
|
|
15
15
|
}
|
|
16
16
|
declare const EditControlsCell: FC<EditControlsCellProps>;
|
|
@@ -5,14 +5,6 @@ const stopPropagationWrapper = (fn) => (event) => {
|
|
|
5
5
|
fn();
|
|
6
6
|
};
|
|
7
7
|
const EditControlsCell = ({ ariaColIndex, beginEditingCallback, cancelEditingCallback, isEditing, saveCallback, deleteCallback, editControlsCellClasses, saveButtonClasses, deleteButtonClasses, startButtonClasses, cancelButtonClasses, }) => {
|
|
8
|
-
return (_jsx("td", { "aria-colindex": ariaColIndex, className: classNames(editControlsCellClasses), children: _jsx("div", { className: "hstack gap-2", children: isEditing ? (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": "Cancel", className: classNames("btn",
|
|
9
|
-
? ["btn-secondary"]
|
|
10
|
-
: cancelButtonClasses), onClick: stopPropagationWrapper(cancelEditingCallback), title: "Cancel", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: _jsx("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293z" }) }) }), _jsx("button", { "aria-label": "Save", className: classNames("btn", saveButtonClasses.length === 0
|
|
11
|
-
? ["btn-primary"]
|
|
12
|
-
: saveButtonClasses), onClick: stopPropagationWrapper(saveCallback), title: "Save", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [_jsx("path", { d: "M12 2h-2v3h2z" }), _jsx("path", { d: "M1.5 0A1.5 1.5 0 0 0 0 1.5v13A1.5 1.5 0 0 0 1.5 16h13a1.5 1.5 0 0 0 1.5-1.5V2.914a1.5 1.5 0 0 0-.44-1.06L14.147.439A1.5 1.5 0 0 0 13.086 0zM4 6a1 1 0 0 1-1-1V1h10v4a1 1 0 0 1-1 1zM3 9h10a1 1 0 0 1 1 1v5H2v-5a1 1 0 0 1 1-1" })] }) })] })) : (_jsxs(_Fragment, { children: [deleteCallback && (_jsx("button", { "aria-label": "Delete", className: classNames("btn", deleteButtonClasses.length === 0
|
|
13
|
-
? ["btn-secondary"]
|
|
14
|
-
: deleteButtonClasses), onClick: stopPropagationWrapper(deleteCallback), title: "Delete", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: _jsx("path", { d: "M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5M8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5m3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0" }) }) })), _jsx("button", { "aria-label": "Edit", className: classNames("btn", startButtonClasses.length === 0
|
|
15
|
-
? ["btn-primary"]
|
|
16
|
-
: startButtonClasses), onClick: stopPropagationWrapper(beginEditingCallback), title: "Edit", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [_jsx("path", { d: "M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z" }), _jsx("path", { fillRule: "evenodd", d: "M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5z" })] }) })] })) }) }));
|
|
8
|
+
return (_jsx("td", { "aria-colindex": ariaColIndex, className: classNames(editControlsCellClasses), children: _jsx("div", { className: "hstack gap-2", children: isEditing ? (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": "Cancel", className: classNames(cancelButtonClasses || ["btn", "btn-secondary"]), onClick: stopPropagationWrapper(cancelEditingCallback), title: "Cancel", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: _jsx("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293z" }) }) }), _jsx("button", { "aria-label": "Save", className: classNames(saveButtonClasses || ["btn", "btn-primary"]), onClick: stopPropagationWrapper(saveCallback), title: "Save", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [_jsx("path", { d: "M12 2h-2v3h2z" }), _jsx("path", { d: "M1.5 0A1.5 1.5 0 0 0 0 1.5v13A1.5 1.5 0 0 0 1.5 16h13a1.5 1.5 0 0 0 1.5-1.5V2.914a1.5 1.5 0 0 0-.44-1.06L14.147.439A1.5 1.5 0 0 0 13.086 0zM4 6a1 1 0 0 1-1-1V1h10v4a1 1 0 0 1-1 1zM3 9h10a1 1 0 0 1 1 1v5H2v-5a1 1 0 0 1 1-1" })] }) })] })) : (_jsxs(_Fragment, { children: [deleteCallback && (_jsx("button", { "aria-label": "Delete", className: classNames(deleteButtonClasses || ["btn", "btn-secondary"]), onClick: stopPropagationWrapper(deleteCallback), title: "Delete", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: _jsx("path", { d: "M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5M8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5m3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0" }) }) })), _jsx("button", { "aria-label": "Edit", className: classNames(startButtonClasses || ["btn", "btn-primary"]), onClick: stopPropagationWrapper(beginEditingCallback), title: "Edit", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [_jsx("path", { d: "M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z" }), _jsx("path", { fillRule: "evenodd", d: "M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5z" })] }) })] })) }) }));
|
|
17
9
|
};
|
|
18
10
|
export default EditControlsCell;
|
|
@@ -9,13 +9,13 @@ export type EditableRowProps = Pick<React.ComponentProps<"tr">, "onClick" | "cla
|
|
|
9
9
|
cellData: CellData[];
|
|
10
10
|
updateCallback?: (values: string[]) => void;
|
|
11
11
|
deleteCallback?: () => void;
|
|
12
|
-
dataCellClasses: (colIndex: number) => string[];
|
|
13
|
-
dataCellInputClasses: (colIndex: number) => string[];
|
|
14
|
-
editCellClasses: string[];
|
|
15
|
-
deleteButtonClasses: string[];
|
|
16
|
-
cancelButtonClasses: string[];
|
|
17
|
-
startButtonClasses: string[];
|
|
18
|
-
saveButtonClasses: string[];
|
|
12
|
+
dataCellClasses: (colIndex: number) => string[] | null;
|
|
13
|
+
dataCellInputClasses: (colIndex: number) => string[] | null;
|
|
14
|
+
editCellClasses: string[] | null;
|
|
15
|
+
deleteButtonClasses: string[] | null;
|
|
16
|
+
cancelButtonClasses: string[] | null;
|
|
17
|
+
startButtonClasses: string[] | null;
|
|
18
|
+
saveButtonClasses: string[] | null;
|
|
19
19
|
editControlCellStyles?: CSSProperties;
|
|
20
20
|
};
|
|
21
21
|
declare const EditableRow: FC<EditableRowProps>;
|
|
@@ -57,6 +57,6 @@ const EditableRow = ({ ariaColIndexOffset, cellData, children, updateCallback, d
|
|
|
57
57
|
setIsEditing(false);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-rowid": dataRowId, children: [children, cellData.map(({ type, value, formattedValue, label, width }, index) => (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, className: classNames(dataCellClasses(index)), style: getWidthStyle(width), children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: `editable-cell-input-${dataRowId}-${index}`, className: classNames("form-control"
|
|
60
|
+
return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-rowid": dataRowId, children: [children, cellData.map(({ type, value, formattedValue, label, width }, index) => (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, className: classNames(dataCellClasses(index)), style: getWidthStyle(width), children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: `editable-cell-input-${dataRowId}-${index}`, className: classNames(dataCellInputClasses(index) || "form-control"), type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index))), updateCallback && (_jsx(EditControlsCell, { ariaColIndex: ariaColIndexOffset + cellData.length + 1, beginEditingCallback: () => setIsEditing(true), cancelEditingCallback: () => setIsEditing(false), isEditing: isEditing, saveCallback: handleSave, deleteCallback: deleteCallback, editControlsCellClasses: editCellClasses, startButtonClasses: startButtonClasses, deleteButtonClasses: deleteButtonClasses, cancelButtonClasses: cancelButtonClasses, saveButtonClasses: saveButtonClasses, style: editControlCellStyles }))] }));
|
|
61
61
|
};
|
|
62
62
|
export default EditableRow;
|
|
@@ -3,6 +3,7 @@ import { FC } from "react";
|
|
|
3
3
|
import { ExportFormStyleModel } from "../styling/types";
|
|
4
4
|
export interface ExportFormProps {
|
|
5
5
|
exportFnInfo: ExportFnInfo;
|
|
6
|
+
closeCallback: () => void;
|
|
6
7
|
styleModel?: ExportFormStyleModel;
|
|
7
8
|
}
|
|
8
9
|
declare const ExportForm: FC<ExportFormProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId, useState } from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
|
-
const ExportForm = ({ exportFnInfo: { exportFn, formattersExist, paginationEnabled, filteringEnabled, rowCounts, }, styleModel, }) => {
|
|
4
|
+
const ExportForm = ({ exportFnInfo: { exportFn, formattersExist, paginationEnabled, filteringEnabled, rowCounts, }, closeCallback, styleModel, }) => {
|
|
5
5
|
const formId = useId();
|
|
6
6
|
const [formState, setFormState] = useState({
|
|
7
7
|
stage: "original",
|
|
@@ -67,7 +67,7 @@ const ExportForm = ({ exportFnInfo: { exportFn, formattersExist, paginationEnabl
|
|
|
67
67
|
const radioContainerClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioContainer) || ["form-check"]);
|
|
68
68
|
const radioInputClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioInput) || ["form-check-input"]);
|
|
69
69
|
const radioLabelClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioLabel) || ["form-check-label"]);
|
|
70
|
-
const submitButtonClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.submitButton) || ["btn", "btn-
|
|
71
|
-
return (_jsxs("form", { onSubmit: handleSubmit, children: [_jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose data to export" }), stageOptions.map(({ value, label, disabled }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${value}`, value: value, checked: formState.stage === value, onChange: getChangeHandler("stage", value), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${value}`, children: label })] }, value)))] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose whether to apply formatters" }), formatOptions.map(({ formatted, label, disabled }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${formatted}`, value: String(formatted), checked: formState.formatted === formatted, onChange: getChangeHandler("formatted", formatted), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${formatted}`, children: label })] }, String(formatted))))] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose the file type" }), fileTypeOptions.map(({ fileType, label }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${fileType}`, value: fileType, checked: formState.fileType === fileType, onChange: getChangeHandler("fileType", fileType) }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${fileType}`, children: label })] }, fileType)))] }), _jsx("button", { type: "submit", className: submitButtonClasses, children: "Submit" })] }));
|
|
70
|
+
const submitButtonClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.submitButton) || ["btn", "btn-primary"]);
|
|
71
|
+
return (_jsxs("form", { onSubmit: handleSubmit, children: [_jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose data to export" }), stageOptions.map(({ value, label, disabled }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${value}`, value: value, checked: formState.stage === value, onChange: getChangeHandler("stage", value), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${value}`, children: label })] }, value)))] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose whether to apply formatters" }), formatOptions.map(({ formatted, label, disabled }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${formatted}`, value: String(formatted), checked: formState.formatted === formatted, onChange: getChangeHandler("formatted", formatted), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${formatted}`, children: label })] }, String(formatted))))] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose the file type" }), fileTypeOptions.map(({ fileType, label }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${fileType}`, value: fileType, checked: formState.fileType === fileType, onChange: getChangeHandler("fileType", fileType) }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${fileType}`, children: label })] }, fileType)))] }), _jsxs("div", { className: "hstack justify-content-end gap-2", children: [_jsx("button", { className: "btn btn-secondary", onClick: closeCallback, type: "button", children: "Cancel" }), _jsx("button", { type: "submit", className: submitButtonClasses, children: "Submit" })] })] }));
|
|
72
72
|
};
|
|
73
73
|
export default ExportForm;
|
|
@@ -7,10 +7,10 @@ export type DateFilterRowProps = {
|
|
|
7
7
|
columnLabel: string;
|
|
8
8
|
filterState: DateFormFilterState;
|
|
9
9
|
setFilterState: (filterState: DateFormFilterState) => void;
|
|
10
|
-
schemeSelectClasses: string[];
|
|
11
|
-
enableInputClasses: string[];
|
|
12
|
-
startDateInputClasses: string[];
|
|
13
|
-
endDateInputClasses: string[];
|
|
10
|
+
schemeSelectClasses: string[] | null | undefined;
|
|
11
|
+
enableInputClasses: string[] | null | undefined;
|
|
12
|
+
startDateInputClasses: string[] | null | undefined;
|
|
13
|
+
endDateInputClasses: string[] | null | undefined;
|
|
14
14
|
} & CommonFilterRowStyleProps;
|
|
15
15
|
declare const DateFilterRow: FC<DateFilterRowProps>;
|
|
16
16
|
export default DateFilterRow;
|
|
@@ -23,7 +23,7 @@ const DateFilterRow = ({ ariaRowIndex, includeTime, columnLabel, filterState, se
|
|
|
23
23
|
const endDateInputId = `$endDate-${inputId}`;
|
|
24
24
|
const startDateInputLabel = `${columnLabel} Column Filter Start Date`;
|
|
25
25
|
const endDateInputLabel = `${columnLabel} Column Filter End Date`;
|
|
26
|
-
const 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"
|
|
26
|
+
const searchStringInputCellContents = (_jsxs(_Fragment, { children: [scheme !== "endAt" && (_jsxs(_Fragment, { children: [scheme === "between" && (_jsx("label", { htmlFor: startDateInputId, children: "Start Date" })), _jsx("input", { id: startDateInputId, className: classNames(startDateInputClasses || "form-control"), 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(endDateInputClasses || "form-control"), type: inputType, required: enabled, disabled: !enabled, value: endDate, onChange: handleEndValueChange, "aria-label": endDateInputLabel })] }))] }));
|
|
27
27
|
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 }));
|
|
28
28
|
};
|
|
29
29
|
export default DateFilterRow;
|
|
@@ -4,6 +4,7 @@ import { FilterInputTableStyleModel } from "../styling/types";
|
|
|
4
4
|
export interface FilterOptionsTableProps {
|
|
5
5
|
filterState: TableFilterState;
|
|
6
6
|
setFilterState: (filterState: EditableTableFilterState) => void;
|
|
7
|
+
closeFormCallback: () => void;
|
|
7
8
|
caption?: string;
|
|
8
9
|
styleModel?: FilterInputTableStyleModel;
|
|
9
10
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
import StringFilterRow from "./StringFilterRow";
|
|
4
4
|
import NumberFilterRow from "./NumberFilterRow";
|
|
5
5
|
import useFilterFormState from "./useFilterFormState";
|
|
6
6
|
import DateFilterRow from "./DateFilterRow";
|
|
7
7
|
import classNames from "classnames";
|
|
8
|
-
import { unwrapFilterInputTableStyleModel } from "../styling/styleModelUnwrappers";
|
|
9
8
|
const convertFilterFormStateToEditableState = (filterFormState) => Object.keys(filterFormState).reduce((editableState, colName) => {
|
|
10
9
|
const rowFilterFormState = filterFormState[colName];
|
|
11
10
|
switch (rowFilterFormState.type) {
|
|
@@ -48,10 +47,9 @@ const convertFilterFormStateToEditableState = (filterFormState) => Object.keys(f
|
|
|
48
47
|
}
|
|
49
48
|
return editableState;
|
|
50
49
|
}, {});
|
|
51
|
-
const FilterOptionsTable = ({ filterState, setFilterState, caption, styleModel, }) => {
|
|
50
|
+
const FilterOptionsTable = ({ filterState, setFilterState, caption, styleModel, closeFormCallback, }) => {
|
|
52
51
|
const formFilterState = useFilterFormState(filterState);
|
|
53
52
|
const [formState, setFormState] = useState(formFilterState);
|
|
54
|
-
const unwrappedStyleModel = useMemo(() => unwrapFilterInputTableStyleModel(styleModel), [styleModel]);
|
|
55
53
|
const getRows = () => Object.keys(formState).map((colName, index) => {
|
|
56
54
|
function getColStateSetter(colName) {
|
|
57
55
|
return (rowState) => setFormState(Object.assign(Object.assign({}, formState), { [colName]: rowState }));
|
|
@@ -60,14 +58,21 @@ const FilterOptionsTable = ({ filterState, setFilterState, caption, styleModel,
|
|
|
60
58
|
const colFilterState = formState[colName];
|
|
61
59
|
switch (colFilterState.type) {
|
|
62
60
|
case "string": {
|
|
63
|
-
return (_jsx(StringFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses:
|
|
61
|
+
return (_jsx(StringFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.schemeSelectionInput) &&
|
|
62
|
+
(styleModel === null || styleModel === void 0 ? void 0 : styleModel.schemeSelectionInput(index)), enableInputClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.enablementInput) &&
|
|
63
|
+
(styleModel === null || styleModel === void 0 ? void 0 : styleModel.enablementInput(index)), searchStringInputClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.searchStringInput) &&
|
|
64
|
+
(styleModel === null || styleModel === void 0 ? void 0 : styleModel.searchStringInput(index)), trClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTr) && (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTr(index)), tdClasses: (colIndex) => (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTd) && (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTd(index, colIndex)) }, colName));
|
|
64
65
|
}
|
|
65
66
|
case "number": {
|
|
66
|
-
return (_jsx(NumberFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses:
|
|
67
|
+
return (_jsx(NumberFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.schemeSelectionInput) &&
|
|
68
|
+
(styleModel === null || styleModel === void 0 ? void 0 : styleModel.schemeSelectionInput(index)), enableInputClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.enablementInput) &&
|
|
69
|
+
(styleModel === null || styleModel === void 0 ? void 0 : styleModel.enablementInput(index)), numberInputClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.numberInput) && (styleModel === null || styleModel === void 0 ? void 0 : styleModel.numberInput(index)), trClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTr) && (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTr(index)), tdClasses: (colIndex) => (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTd) && (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTd(index, colIndex)) }, colName));
|
|
67
70
|
}
|
|
68
71
|
default: {
|
|
69
72
|
// date or datetime
|
|
70
|
-
return (_jsx(DateFilterRow, { ariaRowIndex: index + 2, includeTime: colFilterState.type === "datetime", columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses:
|
|
73
|
+
return (_jsx(DateFilterRow, { ariaRowIndex: index + 2, includeTime: colFilterState.type === "datetime", columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.schemeSelectionInput) &&
|
|
74
|
+
(styleModel === null || styleModel === void 0 ? void 0 : styleModel.schemeSelectionInput(index)), enableInputClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.enablementInput) &&
|
|
75
|
+
(styleModel === null || styleModel === void 0 ? void 0 : styleModel.enablementInput(index)), startDateInputClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.startDateInput) && styleModel.startDateInput(index), endDateInputClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.endDateInput) && styleModel.endDateInput(index), trClasses: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTr) && (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTr(index)), tdClasses: (colIndex) => (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTd) && (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbodyTd(index, colIndex)) }, colName));
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
});
|
|
@@ -75,7 +80,8 @@ const FilterOptionsTable = ({ filterState, setFilterState, caption, styleModel,
|
|
|
75
80
|
event.preventDefault();
|
|
76
81
|
const editableTableFilterState = convertFilterFormStateToEditableState(formState);
|
|
77
82
|
setFilterState(editableTableFilterState);
|
|
83
|
+
closeFormCallback();
|
|
78
84
|
};
|
|
79
|
-
return (_jsxs("form", { onSubmit: onSubmit, className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.form), children: [_jsxs("table", { className: classNames(
|
|
85
|
+
return (_jsxs("form", { onSubmit: onSubmit, className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.form), children: [_jsxs("table", { className: classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.table) || "table"), children: [caption && (_jsx("caption", { className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.caption), children: caption })), _jsx("thead", { className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.thead), children: _jsx("tr", { className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.theadTr), children: ["Enabled", "Column", "Type", "Operator", "Value"].map((colName, index) => (_jsx("th", { className: classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.theadTh) && styleModel.theadTh(index)), children: colName }, index))) }) }), _jsx("tbody", { className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.tbody), children: getRows() })] }), _jsxs("div", { className: "hstack justify-content-end gap-2", children: [_jsx("button", { className: "btn btn-secondary", onClick: closeFormCallback, type: "button", children: "Cancel" }), _jsx("button", { className: classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.submitButton) || ["btn", "btn-primary"]), type: "submit", children: "Submit" })] })] }));
|
|
80
86
|
};
|
|
81
87
|
export default FilterOptionsTable;
|
|
@@ -9,10 +9,10 @@ export interface FilterRowProps<FilterScheme extends string> {
|
|
|
9
9
|
handleSchemeChange: ChangeEventHandler<HTMLSelectElement>;
|
|
10
10
|
schemesToLabels: Record<FilterScheme, string>;
|
|
11
11
|
searchStringInputCellContents: ReactNode;
|
|
12
|
-
trClasses: string[];
|
|
13
|
-
tdClasses: (colIndex: number) => string[];
|
|
14
|
-
inputClasses: string[];
|
|
15
|
-
selectClasses: string[];
|
|
12
|
+
trClasses: string[] | null | undefined;
|
|
13
|
+
tdClasses: (colIndex: number) => (string[] | null) | undefined;
|
|
14
|
+
inputClasses: string[] | null | undefined;
|
|
15
|
+
selectClasses: string[] | null | undefined;
|
|
16
16
|
}
|
|
17
17
|
export type CommonFilterRowStyleProps = Pick<FilterRowProps<string>, "trClasses" | "tdClasses">;
|
|
18
18
|
export declare function FilterRow<FilterScheme extends string = string>(props: FilterRowProps<FilterScheme>): ReactNode;
|
|
@@ -4,6 +4,6 @@ export function FilterRow(props) {
|
|
|
4
4
|
const { ariaRowIndex, columnLabel, typeLabel, enabled, enabledChangeHandler, currentScheme, handleSchemeChange, schemesToLabels, searchStringInputCellContents, trClasses, tdClasses, inputClasses, selectClasses, } = props;
|
|
5
5
|
const checkboxLabel = `${columnLabel} Column Filter Toggle`;
|
|
6
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"
|
|
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(selectClasses || "form-select"), 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 })] }));
|
|
8
8
|
}
|
|
9
9
|
export default FilterRow;
|
|
@@ -6,9 +6,9 @@ export type NumberFilterRowProps = {
|
|
|
6
6
|
columnLabel: string;
|
|
7
7
|
filterState: NumberFormFilterState;
|
|
8
8
|
setFilterState: (filterState: NumberFormFilterState) => void;
|
|
9
|
-
schemeSelectClasses: string[];
|
|
10
|
-
enableInputClasses: string[];
|
|
11
|
-
numberInputClasses: string[];
|
|
9
|
+
schemeSelectClasses: string[] | null | undefined;
|
|
10
|
+
enableInputClasses: string[] | null | undefined;
|
|
11
|
+
numberInputClasses: string[] | null | undefined;
|
|
12
12
|
} & CommonFilterRowStyleProps;
|
|
13
13
|
declare const NumberFilterRow: FC<NumberFilterRowProps>;
|
|
14
14
|
export default NumberFilterRow;
|
|
@@ -14,7 +14,7 @@ const NumberFilterRow = ({ ariaRowIndex, columnLabel, filterState, setFilterStat
|
|
|
14
14
|
};
|
|
15
15
|
const { enabled, scheme, inputValue } = filterState;
|
|
16
16
|
const valueInputLabel = `${columnLabel} Column Filter Value`;
|
|
17
|
-
const searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control"
|
|
17
|
+
const searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames(numberInputClasses || "form-control"), type: "number", required: enabled, disabled: !enabled, value: inputValue, onChange: handleNumInputValueChange }));
|
|
18
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 }));
|
|
19
19
|
};
|
|
20
20
|
export default NumberFilterRow;
|
|
@@ -6,9 +6,9 @@ type StringFilterRowProps = {
|
|
|
6
6
|
columnLabel: string;
|
|
7
7
|
filterState: StringFilterState;
|
|
8
8
|
setFilterState: (filterState: StringFilterState) => void;
|
|
9
|
-
schemeSelectClasses: string[];
|
|
10
|
-
enableInputClasses: string[];
|
|
11
|
-
searchStringInputClasses: string[];
|
|
9
|
+
schemeSelectClasses: string[] | null | undefined;
|
|
10
|
+
enableInputClasses: string[] | null | undefined;
|
|
11
|
+
searchStringInputClasses: string[] | null | undefined;
|
|
12
12
|
} & CommonFilterRowStyleProps;
|
|
13
13
|
declare const StringFilterRow: FC<StringFilterRowProps>;
|
|
14
14
|
export default StringFilterRow;
|
|
@@ -14,7 +14,7 @@ const StringFilterRow = ({ ariaRowIndex, columnLabel, filterState, setFilterStat
|
|
|
14
14
|
};
|
|
15
15
|
const { enabled, scheme, searchString } = filterState;
|
|
16
16
|
const valueInputLabel = `${columnLabel} Column Filter Value`;
|
|
17
|
-
const searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control"
|
|
17
|
+
const searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames(searchStringInputClasses || "form-control"), required: enabled, disabled: !enabled, value: searchString, onChange: handleSearchStringChange }));
|
|
18
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 }));
|
|
19
19
|
};
|
|
20
20
|
export default StringFilterRow;
|
package/grid/main/BodyRows.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { AugFormattedRow, RowId } from "../types";
|
|
2
2
|
import { FC, ReactNode } from "react";
|
|
3
3
|
import { UseGridSelectionFnsHook } from "../pipeline/useGridSelectionFns";
|
|
4
|
-
import { UseUnwrappedGridStylesHook } from "../pipeline/useUnwrappedGridStyles";
|
|
5
4
|
import { UseCombinedPipelineHook } from "../pipeline/useCombinedPipeline";
|
|
6
5
|
import { SelectModel } from "../selection/types";
|
|
7
6
|
import { EditModel } from "../editing/types";
|
|
8
7
|
import { UseGetInputStrSubmitCallbackHook } from "../pipeline/useGetInputStrSubmitCallback";
|
|
8
|
+
import { TableStyleModel } from "../styling/types";
|
|
9
9
|
interface BodyRowsProps {
|
|
10
10
|
augFormattedRows: AugFormattedRow[];
|
|
11
11
|
gridSelectionFns: UseGridSelectionFnsHook;
|
|
12
|
-
|
|
12
|
+
tableStyleModel: TableStyleModel | undefined;
|
|
13
13
|
combinedPipelineOutput: UseCombinedPipelineHook;
|
|
14
14
|
selectModel: SelectModel | undefined;
|
|
15
15
|
editModel: EditModel | undefined;
|
package/grid/main/BodyRows.js
CHANGED
|
@@ -3,9 +3,25 @@ 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
|
-
const BodyRows = ({ augFormattedRows, gridSelectionFns: { selectedSet, getSelectInputModel, getSelectHandler, getRowClickHandler, getAriaSelectedValue, },
|
|
6
|
+
const BodyRows = ({ augFormattedRows, gridSelectionFns: { selectedSet, getSelectInputModel, getSelectHandler, getRowClickHandler, getAriaSelectedValue, }, tableStyleModel, combinedPipelineOutput: { showSelectCol, ariaColIndexOffset }, selectModel, editModel, getInputStrSubmitCallback, additionalColIndexOffset, renderPrefixCells, additionalRowStyles, }) => augFormattedRows.map((row, index) => {
|
|
7
7
|
return (_jsxs(EditableRow, { onClick: getRowClickHandler(row.id), className: classNames({
|
|
8
8
|
"table-active": selectedSet.has(row.id),
|
|
9
|
-
},
|
|
9
|
+
}, (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTr) && (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTr(row.id, index)), additionalRowStyles ? additionalRowStyles(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) => (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd)
|
|
10
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd(row.id, index, colIndex)
|
|
11
|
+
: null, dataCellInputClasses: (colIndex) => (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTdInput)
|
|
12
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTdInput(row.id, index, colIndex)
|
|
13
|
+
: null, editCellClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTd)
|
|
14
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTd(row.id, index)
|
|
15
|
+
: null, saveButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editSaveButton)
|
|
16
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editSaveButton(row.id, index)
|
|
17
|
+
: null, deleteButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editDeleteButton)
|
|
18
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editDeleteButton(row.id, index)
|
|
19
|
+
: null, startButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editStartButton)
|
|
20
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editStartButton(row.id, index)
|
|
21
|
+
: null, cancelButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editCancelButton)
|
|
22
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editCancelButton(row.id, index)
|
|
23
|
+
: null, children: [renderPrefixCells && renderPrefixCells(row), showSelectCol && (_jsx("td", { className: classNames((tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTd) &&
|
|
24
|
+
(tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTd(row.id, index))), "aria-colindex": 1 + (additionalColIndexOffset || 0), style: getWidthStyle(selectModel.selectColWidth), children: _jsx(SelectionInput, { index: index, selected: selectedSet.has(row.id), selectionInputModel: getSelectInputModel(row.id, selectModel), selectCallback: getSelectHandler(row.id), additionalClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectInput) &&
|
|
25
|
+
(tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectInput(row.id, index)) }) }))] }, row.id));
|
|
10
26
|
});
|
|
11
27
|
export default BodyRows;
|
|
@@ -3,7 +3,7 @@ import { NormalizedPaginationModel } from "./types";
|
|
|
3
3
|
export interface PaginationProps {
|
|
4
4
|
normalizedModel: NormalizedPaginationModel;
|
|
5
5
|
prePagingNumRows: number;
|
|
6
|
-
containerDivClasses: string[];
|
|
6
|
+
containerDivClasses: string[] | undefined;
|
|
7
7
|
}
|
|
8
8
|
declare const Pagination: FC<PaginationProps>;
|
|
9
9
|
export default Pagination;
|
|
@@ -16,8 +16,11 @@ const Pagination = ({ normalizedModel, prePagingNumRows, containerDivClasses, })
|
|
|
16
16
|
setCurrentPage(maxPages);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
return (_jsxs("div", { "data-testid": "pagination ui container div", className: classNames(containerDivClasses
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
return (_jsxs("div", { "data-testid": "pagination ui container div", className: classNames(containerDivClasses || [
|
|
20
|
+
"d-flex",
|
|
21
|
+
"justify-content-end",
|
|
22
|
+
"gap-2",
|
|
23
|
+
"px-2",
|
|
24
|
+
]), children: [_jsx(PageSizeSelector, { componentSize: componentSize, pageSizeOptions: pageSizeOptions, pageSizeIndex: pageSizeIndex, handleSetPageSize: pageIndexAwarePageSizeSetter }), _jsx(PageSelector, { numPages: numPages, pageNum: currentPage, numButtons: maxPageButtons, setPageNum: setCurrentPage, size: componentSize, ariaLabel: pageSelectorAriaLabel, alignment: pageSelectorJustifyContent })] }));
|
|
22
25
|
};
|
|
23
26
|
export default Pagination;
|
|
@@ -18,5 +18,5 @@ export type UncontrolledPaginationModel = PaginationOptions & {
|
|
|
18
18
|
startingPageSizeIndex?: number;
|
|
19
19
|
startingCurrentPage?: number;
|
|
20
20
|
};
|
|
21
|
-
export type
|
|
21
|
+
export type PaginationModel = ControlledPaginationModel | UncontrolledPaginationModel;
|
|
22
22
|
export type NormalizedPaginationModel = Required<Omit<ControlledPaginationModel, "type" | "pageSelectorAriaLabel" | "pageSelectorJustifyContent">> & Pick<ControlledPaginationModel, "pageSelectorAriaLabel" | "pageSelectorJustifyContent">;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AugRowDef, PostPaginationRowDef } from "../../types";
|
|
2
|
-
import { NormalizedPaginationModel,
|
|
2
|
+
import { NormalizedPaginationModel, PaginationModel } from "../../pagination/types";
|
|
3
3
|
export interface CurrentPageRowsOutput {
|
|
4
4
|
paginatedRows: PostPaginationRowDef[];
|
|
5
5
|
normalizedModel: NormalizedPaginationModel | null;
|
|
6
6
|
}
|
|
7
|
-
declare const useCurrentPageRows: (sortedRows: AugRowDef[], paginationModel:
|
|
7
|
+
declare const useCurrentPageRows: (sortedRows: AugRowDef[], paginationModel: PaginationModel | undefined) => CurrentPageRowsOutput;
|
|
8
8
|
export default useCurrentPageRows;
|
|
@@ -40,15 +40,13 @@ const getCheckboxState = (selectionInfo, noRows) => {
|
|
|
40
40
|
// single select mode and none selected
|
|
41
41
|
return disabledState;
|
|
42
42
|
};
|
|
43
|
-
const SelectAllHeaderCell = ({ onClick, selectionInfo, totalRows,
|
|
43
|
+
const SelectAllHeaderCell = ({ onClick, selectionInfo, totalRows, customClasses, style, colIndexOffset, }) => {
|
|
44
44
|
const noRows = totalRows === 0;
|
|
45
45
|
const { indeterminate, checked, disabled, description } = getCheckboxState(selectionInfo, noRows);
|
|
46
46
|
const ref = useRef(null);
|
|
47
47
|
useEffect(() => {
|
|
48
48
|
ref.current.indeterminate = indeterminate;
|
|
49
49
|
}, [indeterminate]);
|
|
50
|
-
return (_jsx("th", { style: style, "aria-colindex": 1 + (colIndexOffset || 0), title: description, "aria-description": description, className: classNames({
|
|
51
|
-
"btn-primary": !additionalClasses || additionalClasses.length === 0,
|
|
52
|
-
}, additionalClasses || []), children: _jsx("input", { tabIndex: 0, type: "checkbox", checked: checked, ref: ref, disabled: disabled, "aria-label": description, onChange: onClick }) }));
|
|
50
|
+
return (_jsx("th", { style: style, "aria-colindex": 1 + (colIndexOffset || 0), title: description, "aria-description": description, className: classNames(customClasses || "btn-primary"), children: _jsx("input", { tabIndex: 0, type: "checkbox", checked: checked, ref: ref, disabled: disabled, "aria-label": description, onChange: onClick }) }));
|
|
53
51
|
};
|
|
54
52
|
export default SelectAllHeaderCell;
|
|
@@ -13,7 +13,7 @@ export interface SelectionInputProps {
|
|
|
13
13
|
selected: boolean;
|
|
14
14
|
selectionInputModel: SelectionInputModel;
|
|
15
15
|
selectCallback: () => void;
|
|
16
|
-
additionalClasses?: string[];
|
|
16
|
+
additionalClasses?: string[] | null;
|
|
17
17
|
index: number;
|
|
18
18
|
}
|
|
19
19
|
declare const SelectionInput: FC<SelectionInputProps>;
|
package/grid/styling/types.d.ts
CHANGED
|
@@ -4,40 +4,39 @@ export interface SharedTableStyleModel {
|
|
|
4
4
|
tbody?: string[];
|
|
5
5
|
thead?: string[];
|
|
6
6
|
theadTr?: string[];
|
|
7
|
-
theadTh?: (colIndex: number) => string[];
|
|
7
|
+
theadTh?: (colIndex: number) => string[] | null;
|
|
8
8
|
caption?: string[];
|
|
9
9
|
}
|
|
10
10
|
export type TableStyleModel = SharedTableStyleModel & {
|
|
11
|
-
tbodyTr?: (rowId: RowId, displayIndex: number) => string[];
|
|
12
|
-
tbodyTd?: (rowId: RowId, displayRowIndex: number, colIndex: number) => string[];
|
|
13
|
-
tbodyTdInput?: (rowId: RowId, displayRowIndex: number, colIndex: number) => string[];
|
|
11
|
+
tbodyTr?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
12
|
+
tbodyTd?: (rowId: RowId, displayRowIndex: number, colIndex: number) => string[] | null;
|
|
13
|
+
tbodyTdInput?: (rowId: RowId, displayRowIndex: number, colIndex: number) => string[] | null;
|
|
14
14
|
editColTh?: string[];
|
|
15
|
-
editColTd?: (rowId: RowId, displayIndex: number) => string[];
|
|
16
|
-
editStartButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
17
|
-
editDeleteButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
18
|
-
editSaveButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
19
|
-
editCancelButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
15
|
+
editColTd?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
16
|
+
editStartButton?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
17
|
+
editDeleteButton?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
18
|
+
editSaveButton?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
19
|
+
editCancelButton?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
20
20
|
rowSelectColTh?: string[];
|
|
21
|
-
rowSelectColTd?: (rowId: RowId, displayIndex: number) => string[];
|
|
22
|
-
rowSelectInput?: (rowId: RowId, displayIndex: number) => string[];
|
|
21
|
+
rowSelectColTd?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
22
|
+
rowSelectInput?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
23
23
|
};
|
|
24
24
|
export type FilterInputTableStyleModel = SharedTableStyleModel & {
|
|
25
|
-
tbodyTr?: (rowIndex: number) => string[];
|
|
26
|
-
tbodyTd?: (rowIndex: number, colIndex: number) => string[];
|
|
27
|
-
enablementInput?: (rowIndex: number) => string[];
|
|
28
|
-
schemeSelectionInput?: (rowIndex: number) => string[];
|
|
29
|
-
searchStringInput?: (rowIndex: number) => string[];
|
|
30
|
-
numberInput?: (rowIndex: number) => string[];
|
|
31
|
-
startDateInput?: (rowIndex: number) => string[];
|
|
32
|
-
endDateInput?: (rowIndex: number) => string[];
|
|
25
|
+
tbodyTr?: (rowIndex: number) => string[] | null;
|
|
26
|
+
tbodyTd?: (rowIndex: number, colIndex: number) => string[] | null;
|
|
27
|
+
enablementInput?: (rowIndex: number) => string[] | null;
|
|
28
|
+
schemeSelectionInput?: (rowIndex: number) => string[] | null;
|
|
29
|
+
searchStringInput?: (rowIndex: number) => string[] | null;
|
|
30
|
+
numberInput?: (rowIndex: number) => string[] | null;
|
|
31
|
+
startDateInput?: (rowIndex: number) => string[] | null;
|
|
32
|
+
endDateInput?: (rowIndex: number) => string[] | null;
|
|
33
33
|
submitButton?: string[];
|
|
34
34
|
form?: string[];
|
|
35
35
|
};
|
|
36
36
|
export interface AdditionalComponentsStyleModel {
|
|
37
37
|
topLevelDiv?: string[];
|
|
38
|
-
filterInputsDiv?: string[];
|
|
39
38
|
tableAndPaginationDiv?: string[];
|
|
40
|
-
|
|
39
|
+
tableDiv?: string[];
|
|
41
40
|
paginationUiDiv?: string[];
|
|
42
41
|
}
|
|
43
42
|
export interface ToolbarStyleModel {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InterfaceNodeGenerator } from "./types";
|
|
2
2
|
import { FC } from "react";
|
|
3
3
|
import { ToolbarStyleModel } from "../styling/types";
|
|
4
4
|
interface ToolbarContainerProps {
|
|
5
|
-
|
|
5
|
+
interfaceGen: InterfaceNodeGenerator;
|
|
6
6
|
styleModel?: ToolbarStyleModel;
|
|
7
7
|
}
|
|
8
8
|
declare const ToolbarContainer: FC<ToolbarContainerProps>;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useCallback, useMemo, useState } from "react";
|
|
3
3
|
import Toolbar from "./Toolbar";
|
|
4
4
|
import classNames from "classnames";
|
|
5
|
-
const ToolbarContainer = ({
|
|
5
|
+
const ToolbarContainer = ({ interfaceGen, styleModel, }) => {
|
|
6
6
|
const [option, setOption] = useState(null);
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return prev
|
|
11
|
-
|
|
7
|
+
const closeUiCallback = useCallback(() => setOption(null), []);
|
|
8
|
+
const interfaces = useMemo(() => interfaceGen(closeUiCallback), [closeUiCallback, interfaceGen]);
|
|
9
|
+
const enabledFeatures = useMemo(() => {
|
|
10
|
+
return Object.keys(interfaces).reduce((prev, toolbarOption) => {
|
|
11
|
+
prev[toolbarOption] =
|
|
12
|
+
!!interfaces[toolbarOption];
|
|
13
|
+
return prev;
|
|
14
|
+
}, {});
|
|
15
|
+
}, [interfaces]);
|
|
12
16
|
return (_jsxs("div", { className: "vstack", "data-testid": "toolbar container", children: [_jsx(Toolbar, { enabledFeatures: enabledFeatures, option: option, setOption: setOption, toolbarClasses: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbar, activeClasses: styleModel === null || styleModel === void 0 ? void 0 : styleModel.activeButton, inactiveClasses: styleModel === null || styleModel === void 0 ? void 0 : styleModel.inactiveButton }), _jsx("div", { className: "position-relative", children: option !== null && (_jsx("div", { "data-testid": "toolbar feature interface content container", className: classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.interfaceContainer) || [
|
|
13
17
|
"position-absolute",
|
|
14
18
|
"z-1",
|
package/grid/toolbar/types.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { FilterOptionsTableProps } from "../filtering/FilterOptionsTable";
|
|
3
|
+
import { ExportFormProps } from "../export/ExportForm";
|
|
2
4
|
export type ToolbarOption = "filtering" | "exporting";
|
|
3
5
|
export type ToolbarInterfaces = Partial<Record<ToolbarOption, ReactNode>>;
|
|
6
|
+
export interface InterfaceParams {
|
|
7
|
+
filtering?: FilterOptionsTableProps;
|
|
8
|
+
exporting?: ExportFormProps;
|
|
9
|
+
}
|
|
10
|
+
export type InterfacePropGenerator = (closeUiCallback: () => void) => InterfaceParams;
|
|
11
|
+
export type InterfaceNodeGenerator = (closeUiCallback: () => void) => ToolbarInterfaces;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ExportFormProps } from "../export/ExportForm";
|
|
4
|
-
export interface InterfaceParams {
|
|
5
|
-
filtering?: FilterOptionsTableProps;
|
|
6
|
-
exporting?: ExportFormProps;
|
|
7
|
-
}
|
|
8
|
-
declare const useInterfaces: (params: InterfaceParams) => ToolbarInterfaces;
|
|
1
|
+
import { InterfacePropGenerator, ToolbarInterfaces } from "./types";
|
|
2
|
+
declare const useInterfaces: (gen: InterfacePropGenerator) => (closeCallback: () => void) => ToolbarInterfaces;
|
|
9
3
|
export default useInterfaces;
|
|
@@ -2,10 +2,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import FilterOptionsTable from "../filtering/FilterOptionsTable";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import ExportForm from "../export/ExportForm";
|
|
5
|
-
const useInterfaces = (
|
|
6
|
-
return useMemo(() => ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const useInterfaces = (gen) => {
|
|
6
|
+
return useMemo(() => (closeCallback) => {
|
|
7
|
+
const props = gen(closeCallback);
|
|
8
|
+
const { exporting, filtering } = props;
|
|
9
|
+
return {
|
|
10
|
+
filtering: filtering ? (_jsx(FilterOptionsTable, Object.assign({}, filtering))) : undefined,
|
|
11
|
+
exporting: exporting ? _jsx(ExportForm, Object.assign({}, exporting)) : undefined,
|
|
12
|
+
};
|
|
13
|
+
}, [gen]);
|
|
10
14
|
};
|
|
11
15
|
export default useInterfaces;
|
package/grid/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CellData, EditModel } from "./editing/types";
|
|
2
|
-
import {
|
|
2
|
+
import { PaginationModel } from "./pagination/types";
|
|
3
3
|
import { ColSortModel, TableSortModel } from "./sorting/types";
|
|
4
4
|
import { FilterModel } from "./filtering/types";
|
|
5
5
|
import { SelectModel } from "./selection/types";
|
|
@@ -26,7 +26,7 @@ export interface RowDef<Data extends ValidRowData = ValidRowData> {
|
|
|
26
26
|
export type AugRowDef<Data extends ValidRowData = ValidRowData> = RowDef<Data> & {
|
|
27
27
|
origIndex: number;
|
|
28
28
|
};
|
|
29
|
-
export type PostPaginationRowDef<Data extends ValidRowData = ValidRowData> = AugRowDef & {
|
|
29
|
+
export type PostPaginationRowDef<Data extends ValidRowData = ValidRowData> = AugRowDef<Data> & {
|
|
30
30
|
prePaginationIndex: number;
|
|
31
31
|
};
|
|
32
32
|
export type FormattedRow = {
|
|
@@ -44,16 +44,15 @@ export type DisplayMode = "table" | "block";
|
|
|
44
44
|
export interface GridProps {
|
|
45
45
|
rows: RowDef[];
|
|
46
46
|
cols: ColDef[];
|
|
47
|
-
pagination?:
|
|
47
|
+
pagination?: PaginationModel;
|
|
48
48
|
sortModel?: TableSortModel;
|
|
49
49
|
filterModel?: FilterModel;
|
|
50
50
|
selectModel?: SelectModel;
|
|
51
51
|
editModel?: EditModel;
|
|
52
52
|
caption?: string;
|
|
53
53
|
styleModel?: StyleModel;
|
|
54
|
-
useToolbar?: boolean;
|
|
55
|
-
responsive?: boolean;
|
|
56
54
|
displayMode?: DisplayMode;
|
|
55
|
+
allowExport?: boolean;
|
|
57
56
|
}
|
|
58
57
|
export type BaseGridProps = Omit<GridProps, "cols"> & {
|
|
59
58
|
cols: ColDefBase[];
|
|
@@ -62,6 +61,6 @@ export interface ColHeaderCellProps {
|
|
|
62
61
|
label: string;
|
|
63
62
|
sortModel?: ColSortModel;
|
|
64
63
|
ariaColIndex: number;
|
|
65
|
-
additionalClasses?: string[];
|
|
64
|
+
additionalClasses?: string[] | null;
|
|
66
65
|
width?: number;
|
|
67
66
|
}
|
package/grid-pro/GridPro.js
CHANGED
|
@@ -5,7 +5,6 @@ import useCombinedPipeline from "../grid/pipeline/useCombinedPipeline";
|
|
|
5
5
|
import InternalGrid from "../grid/InternalGrid";
|
|
6
6
|
import ColHeaderCellPro from "./ColHeaderCellPro";
|
|
7
7
|
import useGridSelectionFns from "../grid/pipeline/useGridSelectionFns";
|
|
8
|
-
import useUnwrappedGridStyles from "../grid/pipeline/useUnwrappedGridStyles";
|
|
9
8
|
import useGetInputStrSubmitCallback from "../grid/pipeline/useGetInputStrSubmitCallback";
|
|
10
9
|
import useAugFormattedRows from "../grid/pipeline/useAugFormattedRows";
|
|
11
10
|
import useResizeModel from "./resize/useResizeModel";
|
|
@@ -27,7 +26,6 @@ const GridPro = (props) => {
|
|
|
27
26
|
});
|
|
28
27
|
const { sortedRowsOutput: { sortColDef, setSortColDef, sortingEnabled }, showSelectCol, displayRows, filterState, } = combinedPipelineOutput;
|
|
29
28
|
const gridSelectionFns = useGridSelectionFns(selectModel, rows);
|
|
30
|
-
const unwrappedStyles = useUnwrappedGridStyles(styleModel);
|
|
31
29
|
const getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
|
|
32
30
|
const resizeModel = useResizeModel(cols, displayMode);
|
|
33
31
|
const colNameToWidth = useMemo(() => Object.keys(resizeModel).reduce((prev, fieldName) => {
|
|
@@ -117,12 +115,11 @@ const GridPro = (props) => {
|
|
|
117
115
|
setDragee,
|
|
118
116
|
sortingOccurring,
|
|
119
117
|
]);
|
|
120
|
-
const bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel,
|
|
118
|
+
const bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel, combinedPipelineOutput: combinedPipelineOutput, editModel: editModel, getInputStrSubmitCallback: getInputStrSubmitCallback, renderPrefixCells: renderPrefixCells, additionalColIndexOffset: reorder ? 1 : 0, additionalRowStyles: additionalBodyRowStyles, tableStyleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel }));
|
|
121
119
|
const prefixHeader = reorder ? _jsx(ReorderHeaderCell, {}) : null;
|
|
122
120
|
return (_jsx(InternalGrid, { gridProps: props, hooks: {
|
|
123
121
|
pipelineOutput: combinedPipelineOutput,
|
|
124
122
|
selectFns: gridSelectionFns,
|
|
125
|
-
unwrappedStyles,
|
|
126
123
|
}, slots: { colHeaderCells, bodyRows, prefixHeader }, classes: {
|
|
127
124
|
headerRow: additionalHeaderRowStyles,
|
|
128
125
|
} }));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absreim/react-bootstrap-data-grid-pro",
|
|
3
3
|
"description": "Pro Version of data grid UI component for use with web apps using React and Bootstrap",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"license": "Commercial. See LICENSE file.",
|
|
6
6
|
"author": "Brook Li",
|
|
7
7
|
"homepage": "https://react-bootstrap-data-grid.vercel.app/",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
const ToggleButton = ({ isActive, label, onClick, classes, }) => {
|
|
5
|
-
const baseClasses = ["btn"];
|
|
6
|
-
const variableClasses = {
|
|
7
|
-
active: isActive,
|
|
8
|
-
};
|
|
9
|
-
return (_jsx("button", { type: "button", className: classNames(baseClasses, variableClasses, classes, {
|
|
10
|
-
"btn-primary": !(classes && classes.length > 0),
|
|
11
|
-
}), "aria-pressed": isActive, onClick: onClick, children: label }));
|
|
12
|
-
};
|
|
13
|
-
export default ToggleButton;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AdditionalComponentsStyleModel, StyleModel, TableStyleModel } from "../styling/types";
|
|
2
|
-
export interface UseUnwrappedGridStylesHook {
|
|
3
|
-
unwrappedTableModel: Required<TableStyleModel>;
|
|
4
|
-
unwrappedAdditionalStyleModel: Required<AdditionalComponentsStyleModel>;
|
|
5
|
-
}
|
|
6
|
-
declare const UseUnwrappedGridStyles: (styleModel: StyleModel | undefined) => UseUnwrappedGridStylesHook;
|
|
7
|
-
export default UseUnwrappedGridStyles;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import { unwrapAdditionalComponentsStyleModel, unwrapTableStyleModel, } from "../styling/styleModelUnwrappers";
|
|
3
|
-
const UseUnwrappedGridStyles = (styleModel) => {
|
|
4
|
-
// To give the developer the ability to specify between removing existing styles
|
|
5
|
-
// and simply adding additional ones, we should migrate off of this "unwrapped"
|
|
6
|
-
// design over time and instead apply logic based on the original params that
|
|
7
|
-
// can be undefined.
|
|
8
|
-
const unwrappedTableModel = useMemo(() => unwrapTableStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel), [styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel]);
|
|
9
|
-
const unwrappedAdditionalStyleModel = useMemo(() => unwrapAdditionalComponentsStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel), [styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel]);
|
|
10
|
-
return {
|
|
11
|
-
unwrappedTableModel,
|
|
12
|
-
unwrappedAdditionalStyleModel,
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export default UseUnwrappedGridStyles;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { AdditionalComponentsStyleModel, FilterInputTableStyleModel, TableStyleModel } from "./types";
|
|
2
|
-
export declare const unwrapTableStyleModel: (tableStyleModel: TableStyleModel | undefined) => Required<TableStyleModel>;
|
|
3
|
-
export declare const unwrapFilterInputTableStyleModel: (filterTableStyleModel: FilterInputTableStyleModel | undefined) => Required<FilterInputTableStyleModel>;
|
|
4
|
-
export declare const unwrapAdditionalComponentsStyleModel: (styleModel: AdditionalComponentsStyleModel | undefined) => Required<AdditionalComponentsStyleModel>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const unwrapSharedStyleModel = (sharedStyleModel) => ({
|
|
2
|
-
table: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.table) || [],
|
|
3
|
-
tbody: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.tbody) || [],
|
|
4
|
-
thead: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.thead) || [],
|
|
5
|
-
theadTr: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.theadTr) || [],
|
|
6
|
-
theadTh: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.theadTh) ? sharedStyleModel.theadTh : () => [],
|
|
7
|
-
caption: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.caption) || [],
|
|
8
|
-
});
|
|
9
|
-
export const unwrapTableStyleModel = (tableStyleModel) => (Object.assign(Object.assign({}, unwrapSharedStyleModel(tableStyleModel)), { tbodyTr: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTr) ? tableStyleModel.tbodyTr : () => [], tbodyTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd) ? tableStyleModel.tbodyTd : () => [], tbodyTdInput: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTdInput)
|
|
10
|
-
? tableStyleModel.tbodyTdInput
|
|
11
|
-
: () => [], editColTh: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTh) || [], editColTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTd) ? tableStyleModel.editColTd : () => [], editCancelButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editCancelButton)
|
|
12
|
-
? tableStyleModel.editCancelButton
|
|
13
|
-
: () => [], editDeleteButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editDeleteButton)
|
|
14
|
-
? tableStyleModel.editDeleteButton
|
|
15
|
-
: () => [], editSaveButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editSaveButton)
|
|
16
|
-
? tableStyleModel.editSaveButton
|
|
17
|
-
: () => [], editStartButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editStartButton)
|
|
18
|
-
? tableStyleModel.editStartButton
|
|
19
|
-
: () => [], rowSelectColTh: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTh) || [], rowSelectColTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTd)
|
|
20
|
-
? tableStyleModel.rowSelectColTd
|
|
21
|
-
: () => [], rowSelectInput: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectInput)
|
|
22
|
-
? tableStyleModel.rowSelectInput
|
|
23
|
-
: () => [] }));
|
|
24
|
-
export const unwrapFilterInputTableStyleModel = (filterTableStyleModel) => (Object.assign(Object.assign({}, unwrapSharedStyleModel(filterTableStyleModel)), { tbodyTr: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.tbodyTr)
|
|
25
|
-
? filterTableStyleModel.tbodyTr
|
|
26
|
-
: () => [], tbodyTd: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.tbodyTd)
|
|
27
|
-
? filterTableStyleModel.tbodyTd
|
|
28
|
-
: () => [], enablementInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.enablementInput)
|
|
29
|
-
? filterTableStyleModel.enablementInput
|
|
30
|
-
: () => [], schemeSelectionInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.schemeSelectionInput)
|
|
31
|
-
? filterTableStyleModel.schemeSelectionInput
|
|
32
|
-
: () => [], searchStringInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.searchStringInput)
|
|
33
|
-
? filterTableStyleModel.searchStringInput
|
|
34
|
-
: () => [], numberInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.numberInput)
|
|
35
|
-
? filterTableStyleModel.numberInput
|
|
36
|
-
: () => [], startDateInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.startDateInput)
|
|
37
|
-
? filterTableStyleModel.startDateInput
|
|
38
|
-
: () => [], endDateInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.endDateInput)
|
|
39
|
-
? filterTableStyleModel.endDateInput
|
|
40
|
-
: () => [], submitButton: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.submitButton) || [], form: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.form) || [] }));
|
|
41
|
-
export const unwrapAdditionalComponentsStyleModel = (styleModel) => ({
|
|
42
|
-
topLevelDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.topLevelDiv) || [],
|
|
43
|
-
filterInputsDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputsDiv) || [],
|
|
44
|
-
tableAndPaginationDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tableAndPaginationDiv) || [],
|
|
45
|
-
filterUiToggleButton: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterUiToggleButton) || [],
|
|
46
|
-
paginationUiDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.paginationUiDiv) || [],
|
|
47
|
-
});
|