@absreim/react-bootstrap-data-grid 2.7.0 → 4.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/common/constants.d.ts +2 -0
- package/common/constants.js +2 -0
- package/common/editing/types.d.ts +7 -0
- package/{export → common/export}/ExportForm.d.ts +1 -0
- package/{export → common/export}/ExportForm.js +3 -3
- package/{filtering → common/filtering}/DateFilterRow.d.ts +4 -4
- package/{filtering → common/filtering}/DateFilterRow.js +1 -1
- package/common/filtering/FilterOptionsTable.d.ts +12 -0
- package/{filtering → common/filtering}/FilterOptionsTable.js +17 -20
- package/{filtering → common/filtering}/FilterRow.d.ts +4 -4
- package/{filtering → common/filtering}/FilterRow.js +1 -10
- package/{filtering → common/filtering}/NumberFilterRow.d.ts +3 -3
- package/{filtering → common/filtering}/NumberFilterRow.js +1 -1
- package/{filtering → common/filtering}/StringFilterRow.d.ts +3 -3
- package/{filtering → common/filtering}/StringFilterRow.js +1 -1
- package/{filtering → common/filtering}/types.d.ts +6 -6
- package/common/filtering/useFilterFormState.d.ts +3 -0
- package/{index.d.ts → common/index.d.ts} +8 -7
- package/{index.js → common/index.js} +8 -7
- package/{pagination → common/pagination}/PageSelector.d.ts +1 -1
- package/{pagination → common/pagination}/PageSizeSelector.d.ts +1 -1
- package/{pagination → common/pagination}/Pagination.d.ts +1 -1
- package/{pagination → common/pagination}/Pagination.js +6 -3
- package/{pagination → common/pagination}/types.d.ts +3 -2
- package/{pipeline → common/pipeline}/useAugFormattedRows.d.ts +1 -1
- package/common/pipeline/useColNameToWidth.d.ts +3 -0
- package/common/pipeline/useColNameToWidth.js +12 -0
- package/{pipeline → common/pipeline}/useCombinedPipeline/index.d.ts +4 -4
- package/{pipeline → common/pipeline}/useCombinedPipeline/useCurrentPageRows.d.ts +3 -3
- package/{pipeline → common/pipeline}/useCombinedPipeline/useDisplayRows.d.ts +1 -1
- package/{pipeline → common/pipeline}/useCombinedPipeline/useDisplayRows.js +1 -2
- package/common/pipeline/useCombinedPipeline/useFilter.d.ts +4 -0
- package/common/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +4 -0
- package/{pipeline → common/pipeline}/useCombinedPipeline/useSortedRows.d.ts +2 -2
- package/{pipeline → common/pipeline}/useGridSelectionFns.d.ts +2 -2
- package/{sorting → common/sorting}/types.d.ts +3 -3
- package/{main/ColHeaderCell → common/sorting}/useSortHeaderStates.d.ts +2 -2
- package/{main/ColHeaderCell → common/sorting}/useSortHeaderStates.js +4 -4
- package/common/styling/types.d.ts +21 -0
- package/{toolbar → common/toolbar}/ToolbarContainer.d.ts +2 -2
- package/{toolbar → common/toolbar}/ToolbarContainer.js +11 -7
- package/common/toolbar/types.d.ts +11 -0
- package/common/toolbar/useInterfaces.d.ts +3 -0
- package/{toolbar → common/toolbar}/useInterfaces.js +9 -6
- package/{types.d.ts → common/types.d.ts} +24 -34
- package/common/util/index.d.ts +5 -0
- package/common/util/index.js +5 -0
- package/community/index.d.ts +4 -0
- package/community/index.js +4 -0
- package/grid/constants.d.ts +2 -0
- package/grid/constants.js +2 -0
- package/grid/index.d.ts +3 -0
- package/grid/index.js +3 -0
- package/{Grid.d.ts → grid/main/Grid.d.ts} +0 -1
- package/grid/main/Grid.js +60 -0
- package/grid/main/GridBody.d.ts +4 -0
- package/grid/main/GridBody.js +17 -0
- package/grid/main/GridHeader.d.ts +4 -0
- package/grid/main/GridHeader.js +12 -0
- package/grid/main/getWidthStyles.d.ts +3 -0
- package/grid/main/getWidthStyles.js +6 -0
- package/grid/main/types.d.ts +32 -0
- package/grid/main/types.js +1 -0
- package/grid.css +1 -0
- package/grid.scss +231 -0
- package/package.json +1 -1
- package/table/InternalTable.d.ts +21 -0
- package/table/InternalTable.js +59 -0
- package/table/Table.d.ts +5 -0
- package/{Grid.js → table/Table.js} +11 -21
- package/{editing → table/editing}/EditControlsCell.d.ts +5 -5
- package/table/editing/EditControlsCell.js +11 -0
- package/{editing → table/editing}/EditableRow.d.ts +8 -9
- package/{editing → table/editing}/EditableRow.js +3 -3
- package/table/index.d.ts +5 -0
- package/table/index.js +5 -0
- package/table/main/BodyRows.d.ts +22 -0
- package/table/main/BodyRows.js +34 -0
- package/{main → table/main}/ColHeaderCell/index.js +3 -3
- package/{selection → table/selection}/SelectAllHeaderCell.d.ts +2 -2
- package/{selection → table/selection}/SelectAllHeaderCell.js +2 -4
- package/{selection → table/selection}/SelectionInput.d.ts +1 -1
- package/table/styling/types.d.ts +41 -0
- package/table/styling/types.js +1 -0
- package/table/types.d.ts +19 -0
- package/table/types.js +1 -0
- package/InternalGrid.d.ts +0 -23
- package/InternalGrid.js +0 -57
- package/editing/EditControlsCell.js +0 -19
- package/editing/types.d.ts +0 -16
- package/filtering/FilterOptionsTable.d.ts +0 -11
- package/filtering/useFilterFormState.d.ts +0 -3
- package/main/BodyRows.d.ts +0 -22
- package/main/BodyRows.js +0 -18
- package/main/ToggleButton.d.ts +0 -9
- package/main/ToggleButton.js +0 -14
- package/pipeline/useCombinedPipeline/useEditableFromFilterState.d.ts +0 -3
- package/pipeline/useCombinedPipeline/useEditableFromFilterState.js +0 -14
- package/pipeline/useCombinedPipeline/useFilter.d.ts +0 -4
- package/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +0 -4
- package/pipeline/useUnwrappedGridStyles.d.ts +0 -7
- package/pipeline/useUnwrappedGridStyles.js +0 -17
- package/styling/styleModelUnwrappers.d.ts +0 -4
- package/styling/styleModelUnwrappers.js +0 -58
- package/styling/types.d.ts +0 -62
- package/toolbar/types.d.ts +0 -3
- package/toolbar/useInterfaces.d.ts +0 -9
- /package/{editing → common/editing}/inputStrsToRowData.d.ts +0 -0
- /package/{editing → common/editing}/inputStrsToRowData.js +0 -0
- /package/{editing → common/editing}/types.js +0 -0
- /package/{export → common/export}/types.d.ts +0 -0
- /package/{export → common/export}/types.js +0 -0
- /package/{export → common/export}/useExportFn.d.ts +0 -0
- /package/{export → common/export}/useExportFn.js +0 -0
- /package/{filtering → common/filtering}/types.js +0 -0
- /package/{filtering → common/filtering}/useFilterFormState.js +0 -0
- /package/{pagination → common/pagination}/PageSelector.js +0 -0
- /package/{pagination → common/pagination}/PageSizeSelector.js +0 -0
- /package/{pagination → common/pagination}/types.js +0 -0
- /package/{pipeline → common/pipeline}/types.d.ts +0 -0
- /package/{pipeline → common/pipeline}/types.js +0 -0
- /package/{pipeline → common/pipeline}/useAugFormattedRows.js +0 -0
- /package/{pipeline → common/pipeline}/useCombinedPipeline/index.js +0 -0
- /package/{pipeline → common/pipeline}/useCombinedPipeline/useCurrentPageRows.js +0 -0
- /package/{pipeline → common/pipeline}/useCombinedPipeline/useFilter.js +0 -0
- /package/{pipeline → common/pipeline}/useCombinedPipeline/useFilterStateFromEditable.js +0 -0
- /package/{pipeline → common/pipeline}/useCombinedPipeline/useFilterStateStore.d.ts +0 -0
- /package/{pipeline → common/pipeline}/useCombinedPipeline/useFilterStateStore.js +0 -0
- /package/{pipeline → common/pipeline}/useCombinedPipeline/useSortedRows.js +0 -0
- /package/{pipeline → common/pipeline}/useGetInputStrSubmitCallback.d.ts +0 -0
- /package/{pipeline → common/pipeline}/useGetInputStrSubmitCallback.js +0 -0
- /package/{pipeline → common/pipeline}/useGridSelectionFns.js +0 -0
- /package/{selection → common/selection}/types.d.ts +0 -0
- /package/{selection → common/selection}/types.js +0 -0
- /package/{sorting → common/sorting}/arrowPlaceholder.d.ts +0 -0
- /package/{sorting → common/sorting}/arrowPlaceholder.js +0 -0
- /package/{sorting → common/sorting}/downArrow.d.ts +0 -0
- /package/{sorting → common/sorting}/downArrow.js +0 -0
- /package/{sorting → common/sorting}/sortOrderToAriaSort.d.ts +0 -0
- /package/{sorting → common/sorting}/sortOrderToAriaSort.js +0 -0
- /package/{sorting → common/sorting}/types.js +0 -0
- /package/{sorting → common/sorting}/upArrow.d.ts +0 -0
- /package/{sorting → common/sorting}/upArrow.js +0 -0
- /package/{styling → common/styling}/types.js +0 -0
- /package/{toolbar → common/toolbar}/Toolbar.d.ts +0 -0
- /package/{toolbar → common/toolbar}/Toolbar.js +0 -0
- /package/{toolbar → common/toolbar}/types.js +0 -0
- /package/{types.js → common/types.js} +0 -0
- /package/{util → common/util}/datetime.d.ts +0 -0
- /package/{util → common/util}/datetime.js +0 -0
- /package/{util → common/util}/getWidthStyle.d.ts +0 -0
- /package/{util → common/util}/getWidthStyle.js +0 -0
- /package/{util → common/util}/isSubset.d.ts +0 -0
- /package/{util → common/util}/isSubset.js +0 -0
- /package/{util → common/util}/trueModulo.d.ts +0 -0
- /package/{util → common/util}/trueModulo.js +0 -0
- /package/{util → common/util}/useControlledHover.d.ts +0 -0
- /package/{util → common/util}/useControlledHover.js +0 -0
- /package/{main → table/main}/ColHeaderCell/index.d.ts +0 -0
- /package/{selection → table/selection}/SelectionInput.js +0 -0
- /package/{style.css → table.css} +0 -0
- /package/{style.scss → table.scss} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import SelectAllHeaderCell from "./selection/SelectAllHeaderCell";
|
|
5
|
+
import Pagination from "../common/pagination/Pagination";
|
|
6
|
+
import classNames from "classnames";
|
|
7
|
+
import useInterfaces from "../common/toolbar/useInterfaces";
|
|
8
|
+
import ToolbarContainer from "../common/toolbar/ToolbarContainer";
|
|
9
|
+
import useExportFn from "../common/export/useExportFn";
|
|
10
|
+
import getWidthStyle from "../common/util/getWidthStyle";
|
|
11
|
+
var InternalTable = function (_a) {
|
|
12
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
13
|
+
var _o = _a.gridProps, rows = _o.rows, cols = _o.cols, pagination = _o.pagination, filterModel = _o.filterModel, selectModel = _o.selectModel, editModel = _o.editModel, caption = _o.caption, styleModel = _o.styleModel, displayMode = _o.displayMode, allowExport = _o.allowExport, _p = _a.hooks, pipelineOutput = _p.pipelineOutput, selectFns = _p.selectFns, _q = _a.slots, colHeaderCells = _q.colHeaderCells, bodyRows = _q.bodyRows, prefixHeader = _q.prefixHeader, classes = _a.classes;
|
|
14
|
+
var normalizedTableFilterModel = pipelineOutput.normalizedTableFilterModel, filteredRows = pipelineOutput.filteredRows, filterState = pipelineOutput.filterState, sortedRows = pipelineOutput.sortedRowsOutput.sortedRows, _r = pipelineOutput.currentPageRowsOutput, paginatedRows = _r.paginatedRows, normalizedModel = _r.normalizedModel, showSelectCol = pipelineOutput.showSelectCol;
|
|
15
|
+
var exportFnInfo = useExportFn({
|
|
16
|
+
rows: rows,
|
|
17
|
+
cols: cols,
|
|
18
|
+
filteredRows: filterModel && filteredRows,
|
|
19
|
+
currentPageRows: pagination && paginatedRows,
|
|
20
|
+
});
|
|
21
|
+
var showToolbar = filterModel || allowExport;
|
|
22
|
+
var toolbarPropGen = useMemo(function () { return function (closeUiCallback) {
|
|
23
|
+
return {
|
|
24
|
+
filtering: filterState && filterModel && normalizedTableFilterModel
|
|
25
|
+
? {
|
|
26
|
+
filterState: filterState,
|
|
27
|
+
setFilterState: normalizedTableFilterModel.setTableFilterState,
|
|
28
|
+
caption: filterModel.filterTableCaption,
|
|
29
|
+
styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
30
|
+
closeFormCallback: closeUiCallback,
|
|
31
|
+
}
|
|
32
|
+
: undefined,
|
|
33
|
+
exporting: allowExport
|
|
34
|
+
? {
|
|
35
|
+
exportFnInfo: exportFnInfo,
|
|
36
|
+
styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel,
|
|
37
|
+
closeCallback: closeUiCallback,
|
|
38
|
+
}
|
|
39
|
+
: undefined,
|
|
40
|
+
};
|
|
41
|
+
}; }, [
|
|
42
|
+
allowExport,
|
|
43
|
+
exportFnInfo,
|
|
44
|
+
filterModel,
|
|
45
|
+
filterState,
|
|
46
|
+
normalizedTableFilterModel,
|
|
47
|
+
styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel,
|
|
48
|
+
styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
49
|
+
]);
|
|
50
|
+
var toolbarInterfaces = useInterfaces(toolbarPropGen);
|
|
51
|
+
var rowsAreSelectable = selectFns.rowsAreSelectable, selectionInfo = selectFns.selectionInfo, selectAllOnClick = selectFns.selectAllOnClick;
|
|
52
|
+
var mainTable = (_jsxs("table", { className: classNames({
|
|
53
|
+
"table-hover": rowsAreSelectable,
|
|
54
|
+
"d-block": displayMode === "block",
|
|
55
|
+
}, ((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.table) || "table"), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames((_c = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _c === void 0 ? void 0 : _c.caption), children: caption })), _jsx("thead", { className: classNames((_d = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _d === void 0 ? void 0 : _d.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames((_e = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _e === void 0 ? void 0 : _e.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: (_f = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _f === void 0 ? void 0 : _f.rowSelectColTh, colIndexOffset: prefixHeader ? 1 : 0 })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames((_g = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _g === void 0 ? void 0 : _g.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(classNames((_h = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _h === void 0 ? void 0 : _h.tbody)), children: bodyRows })] }));
|
|
56
|
+
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames((_j = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _j === void 0 ? void 0 : _j.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((_k = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _k === void 0 ? void 0 : _k.tableAndPaginationDiv), children: [_jsx("div", { "data-testid": "rbdg-table-div", className: classNames(((_l = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _l === void 0 ? void 0 : _l.tableDiv) ||
|
|
57
|
+
"table-responsive"), children: mainTable }), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: (_m = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _m === void 0 ? void 0 : _m.paginationUiDiv }))] })] }));
|
|
58
|
+
};
|
|
59
|
+
export default InternalTable;
|
package/table/Table.d.ts
ADDED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import
|
|
4
|
-
import InternalGrid from "./InternalGrid";
|
|
3
|
+
import InternalTable from "./InternalTable";
|
|
5
4
|
import ColHeaderCell from "./main/ColHeaderCell";
|
|
6
|
-
import useCombinedPipeline from "
|
|
7
|
-
import useGridSelectionFns from "
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import useAugFormattedRows from "./pipeline/useAugFormattedRows";
|
|
5
|
+
import useCombinedPipeline from "../common/pipeline/useCombinedPipeline";
|
|
6
|
+
import useGridSelectionFns from "../common/pipeline/useGridSelectionFns";
|
|
7
|
+
import useGetInputStrSubmitCallback from "../common/pipeline/useGetInputStrSubmitCallback";
|
|
8
|
+
import useAugFormattedRows from "../common/pipeline/useAugFormattedRows";
|
|
11
9
|
import BodyRows from "./main/BodyRows";
|
|
12
|
-
|
|
10
|
+
import useColNameToWidth from "../common/pipeline/useColNameToWidth";
|
|
11
|
+
var Table = function (props) {
|
|
13
12
|
var rows = props.rows, cols = props.cols, filterModel = props.filterModel, sortModel = props.sortModel, pagination = props.pagination, selectModel = props.selectModel, styleModel = props.styleModel, editModel = props.editModel;
|
|
14
13
|
var combinedPipelineOutput = useCombinedPipeline({
|
|
15
14
|
rows: rows,
|
|
@@ -21,16 +20,8 @@ var Grid = function (props) {
|
|
|
21
20
|
});
|
|
22
21
|
var _a = combinedPipelineOutput.sortedRowsOutput, sortColDef = _a.sortColDef, setSortColDef = _a.setSortColDef, sortingEnabled = _a.sortingEnabled, showSelectCol = combinedPipelineOutput.showSelectCol, displayRows = combinedPipelineOutput.displayRows;
|
|
23
22
|
var gridSelectionFns = useGridSelectionFns(selectModel, rows);
|
|
24
|
-
var unwrappedStyles = useUnwrappedGridStyles(styleModel);
|
|
25
23
|
var getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
|
|
26
|
-
var colNameToWidth =
|
|
27
|
-
var map = {};
|
|
28
|
-
cols.forEach(function (_a) {
|
|
29
|
-
var name = _a.name, width = _a.width;
|
|
30
|
-
return (map[name] = width);
|
|
31
|
-
});
|
|
32
|
-
return map;
|
|
33
|
-
}, [cols]);
|
|
24
|
+
var colNameToWidth = useColNameToWidth(cols);
|
|
34
25
|
var augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
|
|
35
26
|
var colHeaderCells = cols.map(function (_a, index) {
|
|
36
27
|
var _b;
|
|
@@ -46,11 +37,10 @@ var Grid = function (props) {
|
|
|
46
37
|
return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: ((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.theadTh) &&
|
|
47
38
|
styleModel.mainTableStyleModel.theadTh(index), width: width }, name));
|
|
48
39
|
});
|
|
49
|
-
var bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel,
|
|
50
|
-
return (_jsx(
|
|
40
|
+
var 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 }));
|
|
41
|
+
return (_jsx(InternalTable, { gridProps: props, hooks: {
|
|
51
42
|
pipelineOutput: combinedPipelineOutput,
|
|
52
43
|
selectFns: gridSelectionFns,
|
|
53
|
-
unwrappedStyles: unwrappedStyles,
|
|
54
44
|
}, slots: { colHeaderCells: colHeaderCells, bodyRows: bodyRows } }));
|
|
55
45
|
};
|
|
56
|
-
export default
|
|
46
|
+
export default Table;
|
|
@@ -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>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
var stopPropagationWrapper = function (fn) { return function (event) {
|
|
4
|
+
event.stopPropagation();
|
|
5
|
+
fn();
|
|
6
|
+
}; };
|
|
7
|
+
var EditControlsCell = function (_a) {
|
|
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", { "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" })] }) })] })) }) }));
|
|
10
|
+
};
|
|
11
|
+
export default EditControlsCell;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, FC, ReactNode } from "react";
|
|
2
|
-
import { RowId } from "../types";
|
|
3
2
|
import React from "react";
|
|
4
|
-
import { CellData } from "
|
|
3
|
+
import { CellData, RowId } from "../../common/types";
|
|
5
4
|
export type EditableRowProps = Pick<React.ComponentProps<"tr">, "onClick" | "className" | "aria-rowindex" | "aria-selected"> & {
|
|
6
5
|
ariaColIndexOffset: number;
|
|
7
6
|
dataRowId: RowId;
|
|
@@ -9,13 +8,13 @@ export type EditableRowProps = Pick<React.ComponentProps<"tr">, "onClick" | "cla
|
|
|
9
8
|
cellData: CellData[];
|
|
10
9
|
updateCallback?: (values: string[]) => void;
|
|
11
10
|
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[];
|
|
11
|
+
dataCellClasses: (colIndex: number) => string[] | null;
|
|
12
|
+
dataCellInputClasses: (colIndex: number) => string[] | null;
|
|
13
|
+
editCellClasses: string[] | null;
|
|
14
|
+
deleteButtonClasses: string[] | null;
|
|
15
|
+
cancelButtonClasses: string[] | null;
|
|
16
|
+
startButtonClasses: string[] | null;
|
|
17
|
+
saveButtonClasses: string[] | null;
|
|
19
18
|
editControlCellStyles?: CSSProperties;
|
|
20
19
|
};
|
|
21
20
|
declare const EditableRow: FC<EditableRowProps>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useRef, useState } from "react";
|
|
4
|
-
import { dateToDatetimeInputStr, dateToInputStr } from "
|
|
4
|
+
import { dateToDatetimeInputStr, dateToInputStr, } from "../../common/util/datetime";
|
|
5
5
|
import EditControlsCell from "./EditControlsCell";
|
|
6
6
|
import classNames from "classnames";
|
|
7
|
-
import getWidthStyle from "
|
|
7
|
+
import getWidthStyle from "../../common/util/getWidthStyle";
|
|
8
8
|
var initValueToFormValue = function (value, type) {
|
|
9
9
|
switch (type) {
|
|
10
10
|
case "date":
|
|
@@ -62,7 +62,7 @@ var EditableRow = function (_a) {
|
|
|
62
62
|
};
|
|
63
63
|
return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-rowid": dataRowId, children: [children, cellData.map(function (_a, index) {
|
|
64
64
|
var type = _a.type, value = _a.value, formattedValue = _a.formattedValue, label = _a.label, width = _a.width;
|
|
65
|
-
return (_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-".concat(dataRowId, "-").concat(index), className: classNames("form-control"
|
|
65
|
+
return (_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-".concat(dataRowId, "-").concat(index), className: classNames(dataCellInputClasses(index) || "form-control"), type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index));
|
|
66
66
|
}), 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, style: editControlCellStyles }))] }));
|
|
67
67
|
};
|
|
68
68
|
export default EditableRow;
|
package/table/index.d.ts
ADDED
package/table/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { UseGridSelectionFnsHook } from "../../common/pipeline/useGridSelectionFns";
|
|
3
|
+
import { UseCombinedPipelineHook } from "../../common/pipeline/useCombinedPipeline";
|
|
4
|
+
import { SelectModel } from "../../common/selection/types";
|
|
5
|
+
import { UseGetInputStrSubmitCallbackHook } from "../../common/pipeline/useGetInputStrSubmitCallback";
|
|
6
|
+
import { TableStyleModel } from "../styling/types";
|
|
7
|
+
import { AugFormattedRow, FormattedRow, RowId } from "../../common/types";
|
|
8
|
+
import { EditModel } from "../../common/editing/types";
|
|
9
|
+
interface BodyRowsProps {
|
|
10
|
+
augFormattedRows: AugFormattedRow[];
|
|
11
|
+
gridSelectionFns: UseGridSelectionFnsHook;
|
|
12
|
+
tableStyleModel: TableStyleModel | undefined;
|
|
13
|
+
combinedPipelineOutput: UseCombinedPipelineHook;
|
|
14
|
+
selectModel: SelectModel | undefined;
|
|
15
|
+
editModel: EditModel | undefined;
|
|
16
|
+
getInputStrSubmitCallback: UseGetInputStrSubmitCallbackHook;
|
|
17
|
+
additionalColIndexOffset?: number;
|
|
18
|
+
renderPrefixCells?: (augFormattedRows: FormattedRow) => ReactNode;
|
|
19
|
+
additionalRowStyles?: (rowId: RowId, displayIndex: number) => string[];
|
|
20
|
+
}
|
|
21
|
+
declare const BodyRows: FC<BodyRowsProps>;
|
|
22
|
+
export default BodyRows;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import EditableRow from "../editing/EditableRow";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import getWidthStyle from "../../common/util/getWidthStyle";
|
|
5
|
+
import SelectionInput from "../selection/SelectionInput";
|
|
6
|
+
var BodyRows = function (_a) {
|
|
7
|
+
var augFormattedRows = _a.augFormattedRows, _b = _a.gridSelectionFns, selectedSet = _b.selectedSet, getSelectInputModel = _b.getSelectInputModel, getSelectHandler = _b.getSelectHandler, getRowClickHandler = _b.getRowClickHandler, getAriaSelectedValue = _b.getAriaSelectedValue, tableStyleModel = _a.tableStyleModel, _c = _a.combinedPipelineOutput, showSelectCol = _c.showSelectCol, ariaColIndexOffset = _c.ariaColIndexOffset, selectModel = _a.selectModel, editModel = _a.editModel, getInputStrSubmitCallback = _a.getInputStrSubmitCallback, additionalColIndexOffset = _a.additionalColIndexOffset, renderPrefixCells = _a.renderPrefixCells, additionalRowStyles = _a.additionalRowStyles;
|
|
8
|
+
return augFormattedRows.map(function (row, index) {
|
|
9
|
+
return (_jsxs(EditableRow, { onClick: getRowClickHandler(row.id), className: classNames({
|
|
10
|
+
"table-active": selectedSet.has(row.id),
|
|
11
|
+
}, (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: function (colIndex) {
|
|
12
|
+
return (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd)
|
|
13
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd(row.id, index, colIndex)
|
|
14
|
+
: null;
|
|
15
|
+
}, dataCellInputClasses: function (colIndex) {
|
|
16
|
+
return (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTdInput)
|
|
17
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTdInput(row.id, index, colIndex)
|
|
18
|
+
: null;
|
|
19
|
+
}, editCellClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTd)
|
|
20
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTd(row.id, index)
|
|
21
|
+
: null, saveButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editSaveButton)
|
|
22
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editSaveButton(row.id, index)
|
|
23
|
+
: null, deleteButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editDeleteButton)
|
|
24
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editDeleteButton(row.id, index)
|
|
25
|
+
: null, startButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editStartButton)
|
|
26
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editStartButton(row.id, index)
|
|
27
|
+
: null, cancelButtonClasses: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editCancelButton)
|
|
28
|
+
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editCancelButton(row.id, index)
|
|
29
|
+
: null, children: [renderPrefixCells && renderPrefixCells(row), showSelectCol && (_jsx("td", { className: classNames((tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTd) &&
|
|
30
|
+
(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) &&
|
|
31
|
+
(tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectInput(row.id, index)) }) }))] }, row.id));
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export default BodyRows;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import classNames from "classnames";
|
|
4
|
-
import getWidthStyle from "
|
|
5
|
-
import useSortHeaderStates from "
|
|
6
|
-
import sortOrderToAriaSort from "
|
|
4
|
+
import getWidthStyle from "../../../common/util/getWidthStyle";
|
|
5
|
+
import useSortHeaderStates from "../../../common/sorting/useSortHeaderStates";
|
|
6
|
+
import sortOrderToAriaSort from "../../../common/sorting/sortOrderToAriaSort";
|
|
7
7
|
var ColHeaderCell = function (_a) {
|
|
8
8
|
var label = _a.label, sortModel = _a.sortModel, ariaColIndex = _a.ariaColIndex, additionalClasses = _a.additionalClasses, width = _a.width;
|
|
9
9
|
var _b = useSortHeaderStates(sortModel), handleClick = _b.handleClick, handleMouseOver = _b.handleMouseOver, handleMouseOut = _b.handleMouseOut, sortSymbol = _b.sortSymbol;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CSSProperties, FC } from "react";
|
|
2
|
-
import { SelectionInfo } from "
|
|
2
|
+
import { SelectionInfo } from "../../common/selection/types";
|
|
3
3
|
interface SelectAllHeaderCellProps {
|
|
4
4
|
onClick: () => void;
|
|
5
5
|
selectionInfo: SelectionInfo;
|
|
6
6
|
totalRows: number;
|
|
7
|
-
|
|
7
|
+
customClasses?: string[];
|
|
8
8
|
style?: CSSProperties;
|
|
9
9
|
colIndexOffset?: number;
|
|
10
10
|
}
|
|
@@ -41,15 +41,13 @@ var getCheckboxState = function (selectionInfo, noRows) {
|
|
|
41
41
|
return disabledState;
|
|
42
42
|
};
|
|
43
43
|
var SelectAllHeaderCell = function (_a) {
|
|
44
|
-
var onClick = _a.onClick, selectionInfo = _a.selectionInfo, totalRows = _a.totalRows,
|
|
44
|
+
var onClick = _a.onClick, selectionInfo = _a.selectionInfo, totalRows = _a.totalRows, customClasses = _a.customClasses, style = _a.style, colIndexOffset = _a.colIndexOffset;
|
|
45
45
|
var noRows = totalRows === 0;
|
|
46
46
|
var _b = getCheckboxState(selectionInfo, noRows), indeterminate = _b.indeterminate, checked = _b.checked, disabled = _b.disabled, description = _b.description;
|
|
47
47
|
var ref = useRef(null);
|
|
48
48
|
useEffect(function () {
|
|
49
49
|
ref.current.indeterminate = indeterminate;
|
|
50
50
|
}, [indeterminate]);
|
|
51
|
-
return (_jsx("th", { style: style, "aria-colindex": 1 + (colIndexOffset || 0), title: description, "aria-description": description, className: classNames({
|
|
52
|
-
"btn-primary": !additionalClasses || additionalClasses.length === 0,
|
|
53
|
-
}, additionalClasses || []), children: _jsx("input", { tabIndex: 0, type: "checkbox", checked: checked, ref: ref, disabled: disabled, "aria-label": description, onChange: onClick }) }));
|
|
51
|
+
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 }) }));
|
|
54
52
|
};
|
|
55
53
|
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>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RowId } from "../../common/types";
|
|
2
|
+
export interface SharedTableStyleModel {
|
|
3
|
+
table?: string[];
|
|
4
|
+
tbody?: string[];
|
|
5
|
+
thead?: string[];
|
|
6
|
+
theadTr?: string[];
|
|
7
|
+
theadTh?: (colIndex: number) => string[] | null;
|
|
8
|
+
caption?: string[];
|
|
9
|
+
}
|
|
10
|
+
export type TableStyleModel = SharedTableStyleModel & {
|
|
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
|
+
editColTh?: 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
|
+
rowSelectColTh?: string[];
|
|
21
|
+
rowSelectColTd?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
22
|
+
rowSelectInput?: (rowId: RowId, displayIndex: number) => string[] | null;
|
|
23
|
+
};
|
|
24
|
+
export type FilterInputTableStyleModel = SharedTableStyleModel & {
|
|
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
|
+
submitButton?: string[];
|
|
34
|
+
form?: string[];
|
|
35
|
+
};
|
|
36
|
+
export interface AdditionalComponentsStyleModel {
|
|
37
|
+
topLevelDiv?: string[];
|
|
38
|
+
tableAndPaginationDiv?: string[];
|
|
39
|
+
tableDiv?: string[];
|
|
40
|
+
paginationUiDiv?: string[];
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/table/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColSortModel } from "../common/sorting/types";
|
|
2
|
+
import { ColDefBase, MainComponentSharedProps } from "../common/types";
|
|
3
|
+
import { StyleModel } from "../common/styling/types";
|
|
4
|
+
export type DisplayMode = "table" | "block";
|
|
5
|
+
export type TableProps = MainComponentSharedProps & {
|
|
6
|
+
caption?: string;
|
|
7
|
+
styleModel?: StyleModel;
|
|
8
|
+
displayMode?: DisplayMode;
|
|
9
|
+
};
|
|
10
|
+
export type BaseTableProps = Omit<TableProps, "cols"> & {
|
|
11
|
+
cols: ColDefBase[];
|
|
12
|
+
};
|
|
13
|
+
export interface ColHeaderCellProps {
|
|
14
|
+
label: string;
|
|
15
|
+
sortModel?: ColSortModel;
|
|
16
|
+
ariaColIndex: number;
|
|
17
|
+
additionalClasses?: string[] | null;
|
|
18
|
+
width?: number;
|
|
19
|
+
}
|
package/table/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/InternalGrid.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from "react";
|
|
2
|
-
import { BaseGridProps } from "./types";
|
|
3
|
-
import { UseCombinedPipelineHook } from "./pipeline/useCombinedPipeline";
|
|
4
|
-
import { UseGridSelectionFnsHook } from "./pipeline/useGridSelectionFns";
|
|
5
|
-
import { UseUnwrappedGridStylesHook } from "./pipeline/useUnwrappedGridStyles";
|
|
6
|
-
export interface InternalGridProps {
|
|
7
|
-
gridProps: BaseGridProps;
|
|
8
|
-
hooks: {
|
|
9
|
-
selectFns: UseGridSelectionFnsHook;
|
|
10
|
-
pipelineOutput: UseCombinedPipelineHook;
|
|
11
|
-
unwrappedStyles: UseUnwrappedGridStylesHook;
|
|
12
|
-
};
|
|
13
|
-
slots: {
|
|
14
|
-
colHeaderCells: ReactNode;
|
|
15
|
-
bodyRows: ReactNode;
|
|
16
|
-
prefixHeader?: ReactNode;
|
|
17
|
-
};
|
|
18
|
-
classes?: {
|
|
19
|
-
headerRow?: string[];
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
declare const InternalGrid: FC<InternalGridProps>;
|
|
23
|
-
export default InternalGrid;
|
package/InternalGrid.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
4
|
-
import ToggleButton from "./main/ToggleButton";
|
|
5
|
-
import FilterOptionsTable from "./filtering/FilterOptionsTable";
|
|
6
|
-
import SelectAllHeaderCell from "./selection/SelectAllHeaderCell";
|
|
7
|
-
import Pagination from "./pagination/Pagination";
|
|
8
|
-
import classNames from "classnames";
|
|
9
|
-
import useInterfaces from "./toolbar/useInterfaces";
|
|
10
|
-
import ToolbarContainer from "./toolbar/ToolbarContainer";
|
|
11
|
-
import useExportFn from "./export/useExportFn";
|
|
12
|
-
import getWidthStyle from "./util/getWidthStyle";
|
|
13
|
-
var InternalGrid = function (_a) {
|
|
14
|
-
var _b;
|
|
15
|
-
var _c = _a.gridProps, rows = _c.rows, cols = _c.cols, pagination = _c.pagination, filterModel = _c.filterModel, selectModel = _c.selectModel, editModel = _c.editModel, caption = _c.caption, styleModel = _c.styleModel, useToolbar = _c.useToolbar, responsive = _c.responsive, displayMode = _c.displayMode, _d = _a.hooks, pipelineOutput = _d.pipelineOutput, selectFns = _d.selectFns, unwrappedStyles = _d.unwrappedStyles, _e = _a.slots, colHeaderCells = _e.colHeaderCells, bodyRows = _e.bodyRows, prefixHeader = _e.prefixHeader, classes = _a.classes;
|
|
16
|
-
var normalizedTableFilterModel = pipelineOutput.normalizedTableFilterModel, filteredRows = pipelineOutput.filteredRows, filterState = pipelineOutput.filterState, sortedRows = pipelineOutput.sortedRowsOutput.sortedRows, _f = pipelineOutput.currentPageRowsOutput, paginatedRows = _f.paginatedRows, normalizedModel = _f.normalizedModel, showSelectCol = pipelineOutput.showSelectCol;
|
|
17
|
-
var _g = useState(false), filterOptionsVisible = _g[0], setFilterOptionsVisible = _g[1];
|
|
18
|
-
var exportFnInfo = useExportFn({
|
|
19
|
-
rows: rows,
|
|
20
|
-
cols: cols,
|
|
21
|
-
filteredRows: filterModel && filteredRows,
|
|
22
|
-
currentPageRows: pagination && paginatedRows,
|
|
23
|
-
});
|
|
24
|
-
var toolbarInterfaceParams = useMemo(function () { return ({
|
|
25
|
-
filtering: useToolbar && filterState && filterModel && normalizedTableFilterModel
|
|
26
|
-
? {
|
|
27
|
-
filterState: filterState,
|
|
28
|
-
setFilterState: normalizedTableFilterModel.setTableFilterState,
|
|
29
|
-
caption: filterModel.filterTableCaption,
|
|
30
|
-
styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
31
|
-
}
|
|
32
|
-
: undefined,
|
|
33
|
-
exporting: useToolbar
|
|
34
|
-
? { exportFnInfo: exportFnInfo, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel }
|
|
35
|
-
: undefined,
|
|
36
|
-
}); }, [
|
|
37
|
-
exportFnInfo,
|
|
38
|
-
filterModel,
|
|
39
|
-
filterState,
|
|
40
|
-
normalizedTableFilterModel,
|
|
41
|
-
styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel,
|
|
42
|
-
styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
43
|
-
useToolbar,
|
|
44
|
-
]);
|
|
45
|
-
var toolbarInterfaces = useInterfaces(toolbarInterfaceParams);
|
|
46
|
-
var handleToggleFilterOptions = function () {
|
|
47
|
-
setFilterOptionsVisible(!filterOptionsVisible);
|
|
48
|
-
};
|
|
49
|
-
var rowsAreSelectable = selectFns.rowsAreSelectable, selectionInfo = selectFns.selectionInfo, selectAllOnClick = selectFns.selectAllOnClick;
|
|
50
|
-
var unwrappedTableModel = unwrappedStyles.unwrappedTableModel, unwrappedAdditionalStyleModel = unwrappedStyles.unwrappedAdditionalStyleModel;
|
|
51
|
-
var mainTable = (_jsxs("table", { className: classNames("table", {
|
|
52
|
-
"table-hover": rowsAreSelectable,
|
|
53
|
-
"d-block": displayMode === "block",
|
|
54
|
-
}, 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, (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, additionalClasses: unwrappedTableModel.rowSelectColTh, colIndexOffset: prefixHeader ? 1 : 0 })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames(unwrappedTableModel.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(unwrappedTableModel.tbody), children: bodyRows })] }));
|
|
55
|
-
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [normalizedTableFilterModel && !useToolbar && (_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: normalizedTableFilterModel.setTableFilterState, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel }))] })), useToolbar && (_jsx(ToolbarContainer, { interfaces: toolbarInterfaces, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbarStyleModel })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames(unwrappedAdditionalStyleModel.tableAndPaginationDiv), children: [responsive ? (_jsx("div", { "data-testid": "rbdg-table-div", className: "table-responsive", children: mainTable })) : (_jsx(_Fragment, { children: mainTable })), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: unwrappedAdditionalStyleModel.paginationUiDiv }))] })] }));
|
|
56
|
-
};
|
|
57
|
-
export default InternalGrid;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
var stopPropagationWrapper = function (fn) { return function (event) {
|
|
4
|
-
event.stopPropagation();
|
|
5
|
-
fn();
|
|
6
|
-
}; };
|
|
7
|
-
var EditControlsCell = function (_a) {
|
|
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", { "aria-label": "Cancel", className: classNames("btn", cancelButtonClasses.length === 0
|
|
10
|
-
? ["btn-secondary"]
|
|
11
|
-
: 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
|
|
12
|
-
? ["btn-primary"]
|
|
13
|
-
: 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
|
|
14
|
-
? ["btn-secondary"]
|
|
15
|
-
: 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
|
|
16
|
-
? ["btn-primary"]
|
|
17
|
-
: 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" })] }) })] })) }) }));
|
|
18
|
-
};
|
|
19
|
-
export default EditControlsCell;
|
package/editing/types.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ColDataType, ColDataTypeStrings, RowData, RowId } 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
|
-
width?: number;
|
|
10
|
-
}
|
|
11
|
-
export type UpdateCallbackGenerator = (id: RowId) => (rowData: RowData) => void;
|
|
12
|
-
export interface EditModel {
|
|
13
|
-
getUpdateCallback: UpdateCallbackGenerator;
|
|
14
|
-
getDeleteCallback?: (id: RowId) => () => void;
|
|
15
|
-
editColWidth?: number;
|
|
16
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
import { EditableTableFilterState, TableFilterState } from "./types";
|
|
3
|
-
import { FilterInputTableStyleModel } from "../styling/types";
|
|
4
|
-
export interface FilterOptionsTableProps {
|
|
5
|
-
filterState: TableFilterState;
|
|
6
|
-
setFilterState: (filterState: EditableTableFilterState) => void;
|
|
7
|
-
caption?: string;
|
|
8
|
-
styleModel?: FilterInputTableStyleModel;
|
|
9
|
-
}
|
|
10
|
-
declare const FilterOptionsTable: FC<FilterOptionsTableProps>;
|
|
11
|
-
export default FilterOptionsTable;
|
package/main/BodyRows.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { AugFormattedRow, RowId } from "../types";
|
|
2
|
-
import { FC, ReactNode } from "react";
|
|
3
|
-
import { UseGridSelectionFnsHook } from "../pipeline/useGridSelectionFns";
|
|
4
|
-
import { UseUnwrappedGridStylesHook } from "../pipeline/useUnwrappedGridStyles";
|
|
5
|
-
import { UseCombinedPipelineHook } from "../pipeline/useCombinedPipeline";
|
|
6
|
-
import { SelectModel } from "../selection/types";
|
|
7
|
-
import { EditModel } from "../editing/types";
|
|
8
|
-
import { UseGetInputStrSubmitCallbackHook } from "../pipeline/useGetInputStrSubmitCallback";
|
|
9
|
-
interface BodyRowsProps {
|
|
10
|
-
augFormattedRows: AugFormattedRow[];
|
|
11
|
-
gridSelectionFns: UseGridSelectionFnsHook;
|
|
12
|
-
unwrappedStyles: UseUnwrappedGridStylesHook;
|
|
13
|
-
combinedPipelineOutput: UseCombinedPipelineHook;
|
|
14
|
-
selectModel: SelectModel | undefined;
|
|
15
|
-
editModel: EditModel | undefined;
|
|
16
|
-
getInputStrSubmitCallback: UseGetInputStrSubmitCallbackHook;
|
|
17
|
-
additionalColIndexOffset?: number;
|
|
18
|
-
renderPrefixCells?: (augFormattedRows: AugFormattedRow) => ReactNode;
|
|
19
|
-
additionalRowStyles?: (rowId: RowId, displayIndex: number) => string[];
|
|
20
|
-
}
|
|
21
|
-
declare const BodyRows: FC<BodyRowsProps>;
|
|
22
|
-
export default BodyRows;
|