@absreim/react-bootstrap-data-grid-pro 3.0.0 → 4.1.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.
Files changed (188) hide show
  1. package/common/constants.d.ts +2 -0
  2. package/common/constants.js +2 -0
  3. package/common/editing/types.d.ts +7 -0
  4. package/{grid → common}/filtering/FilterOptionsTable.d.ts +4 -4
  5. package/{grid → common}/filtering/types.d.ts +6 -6
  6. package/common/filtering/useFilterFormState.d.ts +3 -0
  7. package/common/index.d.ts +11 -0
  8. package/common/index.js +11 -0
  9. package/{grid → common}/pagination/PageSelector.d.ts +1 -1
  10. package/{grid → common}/pagination/PageSizeSelector.d.ts +1 -1
  11. package/{grid → common}/pagination/types.d.ts +2 -1
  12. package/{grid → common}/pipeline/useAugFormattedRows.d.ts +1 -1
  13. package/common/pipeline/useColNameToWidth.d.ts +3 -0
  14. package/common/pipeline/useColNameToWidth.js +7 -0
  15. package/{grid → common}/pipeline/useCombinedPipeline/index.d.ts +4 -4
  16. package/{grid → common}/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +1 -1
  17. package/{grid → common}/pipeline/useCombinedPipeline/useDisplayRows.d.ts +1 -1
  18. package/{grid → common}/pipeline/useCombinedPipeline/useDisplayRows.js +1 -2
  19. package/common/pipeline/useCombinedPipeline/useFilter.d.ts +4 -0
  20. package/common/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +4 -0
  21. package/{grid → common}/pipeline/useCombinedPipeline/useSortedRows.d.ts +2 -2
  22. package/{grid → common}/pipeline/useGridSelectionFns.d.ts +2 -2
  23. package/{grid → common}/sorting/types.d.ts +3 -3
  24. package/{grid/main/ColHeaderCell → common/sorting}/useSortHeaderStates.d.ts +2 -2
  25. package/{grid/main/ColHeaderCell → common/sorting}/useSortHeaderStates.js +4 -4
  26. package/common/styling/types.d.ts +21 -0
  27. package/{grid → common}/types.d.ts +21 -30
  28. package/common/util/index.d.ts +5 -0
  29. package/common/util/index.js +5 -0
  30. package/grid/constants.d.ts +2 -0
  31. package/grid/constants.js +2 -0
  32. package/grid/focus/types.d.ts +4 -0
  33. package/grid/focus/useGridFocus.d.ts +10 -0
  34. package/grid/focus/useGridFocus.js +130 -0
  35. package/grid/index.d.ts +3 -10
  36. package/grid/index.js +3 -10
  37. package/grid/{Grid.d.ts → main/Grid.d.ts} +0 -1
  38. package/grid/main/Grid.js +76 -0
  39. package/grid/main/GridBody.d.ts +4 -0
  40. package/grid/main/GridBody.js +26 -0
  41. package/grid/main/GridHeader.d.ts +4 -0
  42. package/grid/main/GridHeader.js +15 -0
  43. package/grid/main/getWidthStyles.d.ts +3 -0
  44. package/grid/main/getWidthStyles.js +6 -0
  45. package/grid/main/types.d.ts +41 -0
  46. package/grid.css +1 -0
  47. package/grid.scss +243 -0
  48. package/package.json +1 -1
  49. package/pro/index.d.ts +5 -0
  50. package/pro/index.js +5 -0
  51. package/{grid/InternalGrid.d.ts → table/InternalTable.d.ts} +6 -6
  52. package/{grid/InternalGrid.js → table/InternalTable.js} +7 -7
  53. package/table/Table.d.ts +5 -0
  54. package/{grid/Grid.js → table/Table.js} +10 -14
  55. package/{grid → table}/editing/EditableRow.d.ts +1 -2
  56. package/{grid → table}/editing/EditableRow.js +2 -2
  57. package/table/index.d.ts +5 -0
  58. package/table/index.js +5 -0
  59. package/{grid → table}/main/BodyRows.d.ts +7 -7
  60. package/{grid → table}/main/BodyRows.js +1 -1
  61. package/{grid → table}/main/ColHeaderCell/index.js +3 -3
  62. package/{grid → table}/selection/SelectAllHeaderCell.d.ts +1 -1
  63. package/table/style.scss +3 -0
  64. package/{grid → table}/styling/types.d.ts +1 -21
  65. package/table/styling/types.js +1 -0
  66. package/table/types.d.ts +19 -0
  67. package/table/types.js +1 -0
  68. package/{grid-pro → table-pro}/ColHeaderCellPro.js +4 -4
  69. package/table-pro/TablePro.d.ts +4 -0
  70. package/{grid-pro/GridPro.js → table-pro/TablePro.js} +9 -9
  71. package/{grid-pro → table-pro}/index.d.ts +2 -2
  72. package/{grid-pro → table-pro}/index.js +2 -2
  73. package/{grid-pro → table-pro}/reorder/ReorderHandleCell.js +1 -1
  74. package/{grid-pro → table-pro}/reorder/useKeyboardReorder.js +1 -1
  75. package/table-pro/resize/types.js +1 -0
  76. package/{grid-pro → table-pro}/resize/useResizeModel.d.ts +1 -1
  77. package/table-pro/style.scss +69 -0
  78. package/{grid-pro → table-pro}/types.d.ts +3 -3
  79. package/table-pro/types.js +1 -0
  80. package/table-pro.scss +1 -0
  81. package/grid/editing/types.d.ts +0 -16
  82. package/grid/filtering/useFilterFormState.d.ts +0 -3
  83. package/grid/pipeline/useCombinedPipeline/useFilter.d.ts +0 -4
  84. package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +0 -4
  85. package/grid-pro/GridPro.d.ts +0 -4
  86. /package/{grid → common}/editing/inputStrsToRowData.d.ts +0 -0
  87. /package/{grid → common}/editing/inputStrsToRowData.js +0 -0
  88. /package/{grid-pro/reorder → common/editing}/types.js +0 -0
  89. /package/{grid → common}/export/ExportForm.d.ts +0 -0
  90. /package/{grid → common}/export/ExportForm.js +0 -0
  91. /package/{grid → common}/export/types.d.ts +0 -0
  92. /package/{grid-pro/resize → common/export}/types.js +0 -0
  93. /package/{grid → common}/export/useExportFn.d.ts +0 -0
  94. /package/{grid → common}/export/useExportFn.js +0 -0
  95. /package/{grid → common}/filtering/DateFilterRow.d.ts +0 -0
  96. /package/{grid → common}/filtering/DateFilterRow.js +0 -0
  97. /package/{grid → common}/filtering/FilterOptionsTable.js +0 -0
  98. /package/{grid → common}/filtering/FilterRow.d.ts +0 -0
  99. /package/{grid → common}/filtering/FilterRow.js +0 -0
  100. /package/{grid → common}/filtering/NumberFilterRow.d.ts +0 -0
  101. /package/{grid → common}/filtering/NumberFilterRow.js +0 -0
  102. /package/{grid → common}/filtering/StringFilterRow.d.ts +0 -0
  103. /package/{grid → common}/filtering/StringFilterRow.js +0 -0
  104. /package/{grid → common}/filtering/types.js +0 -0
  105. /package/{grid → common}/filtering/useFilterFormState.js +0 -0
  106. /package/{grid → common}/pagination/PageSelector.js +0 -0
  107. /package/{grid → common}/pagination/PageSizeSelector.js +0 -0
  108. /package/{grid → common}/pagination/Pagination.d.ts +0 -0
  109. /package/{grid → common}/pagination/Pagination.js +0 -0
  110. /package/{grid-pro → common/pagination}/types.js +0 -0
  111. /package/{grid → common}/pipeline/types.d.ts +0 -0
  112. /package/{grid-pro/util → common/pipeline}/types.js +0 -0
  113. /package/{grid → common}/pipeline/useAugFormattedRows.js +0 -0
  114. /package/{grid → common}/pipeline/useCombinedPipeline/index.js +0 -0
  115. /package/{grid → common}/pipeline/useCombinedPipeline/useCurrentPageRows.js +0 -0
  116. /package/{grid → common}/pipeline/useCombinedPipeline/useFilter.js +0 -0
  117. /package/{grid → common}/pipeline/useCombinedPipeline/useFilterStateFromEditable.js +0 -0
  118. /package/{grid → common}/pipeline/useCombinedPipeline/useFilterStateStore.d.ts +0 -0
  119. /package/{grid → common}/pipeline/useCombinedPipeline/useFilterStateStore.js +0 -0
  120. /package/{grid → common}/pipeline/useCombinedPipeline/useSortedRows.js +0 -0
  121. /package/{grid → common}/pipeline/useGetInputStrSubmitCallback.d.ts +0 -0
  122. /package/{grid → common}/pipeline/useGetInputStrSubmitCallback.js +0 -0
  123. /package/{grid → common}/pipeline/useGridSelectionFns.js +0 -0
  124. /package/{grid → common}/selection/types.d.ts +0 -0
  125. /package/{grid → common}/selection/types.js +0 -0
  126. /package/{grid → common}/sorting/arrowPlaceholder.d.ts +0 -0
  127. /package/{grid → common}/sorting/arrowPlaceholder.js +0 -0
  128. /package/{grid → common}/sorting/downArrow.d.ts +0 -0
  129. /package/{grid → common}/sorting/downArrow.js +0 -0
  130. /package/{grid → common}/sorting/sortOrderToAriaSort.d.ts +0 -0
  131. /package/{grid → common}/sorting/sortOrderToAriaSort.js +0 -0
  132. /package/{grid/editing → common/sorting}/types.js +0 -0
  133. /package/{grid → common}/sorting/upArrow.d.ts +0 -0
  134. /package/{grid → common}/sorting/upArrow.js +0 -0
  135. /package/{grid/export → common/styling}/types.js +0 -0
  136. /package/{grid → common}/toolbar/Toolbar.d.ts +0 -0
  137. /package/{grid → common}/toolbar/Toolbar.js +0 -0
  138. /package/{grid → common}/toolbar/ToolbarContainer.d.ts +0 -0
  139. /package/{grid → common}/toolbar/ToolbarContainer.js +0 -0
  140. /package/{grid → common}/toolbar/types.d.ts +0 -0
  141. /package/{grid/pagination → common/toolbar}/types.js +0 -0
  142. /package/{grid → common}/toolbar/useInterfaces.d.ts +0 -0
  143. /package/{grid → common}/toolbar/useInterfaces.js +0 -0
  144. /package/{grid/pipeline → common}/types.js +0 -0
  145. /package/{grid → common}/util/datetime.d.ts +0 -0
  146. /package/{grid → common}/util/datetime.js +0 -0
  147. /package/{grid → common}/util/getWidthStyle.d.ts +0 -0
  148. /package/{grid → common}/util/getWidthStyle.js +0 -0
  149. /package/{grid → common}/util/isSubset.d.ts +0 -0
  150. /package/{grid → common}/util/isSubset.js +0 -0
  151. /package/{grid → common}/util/trueModulo.d.ts +0 -0
  152. /package/{grid → common}/util/trueModulo.js +0 -0
  153. /package/{grid → common}/util/useControlledHover.d.ts +0 -0
  154. /package/{grid → common}/util/useControlledHover.js +0 -0
  155. /package/grid/{sorting → focus}/types.js +0 -0
  156. /package/grid/{styling → main}/types.js +0 -0
  157. /package/{grid → table}/editing/EditControlsCell.d.ts +0 -0
  158. /package/{grid → table}/editing/EditControlsCell.js +0 -0
  159. /package/{grid → table}/main/ColHeaderCell/index.d.ts +0 -0
  160. /package/{grid → table}/selection/SelectAllHeaderCell.js +0 -0
  161. /package/{grid → table}/selection/SelectionInput.d.ts +0 -0
  162. /package/{grid → table}/selection/SelectionInput.js +0 -0
  163. /package/{grid-pro → table-pro}/ColHeaderCellPro.d.ts +0 -0
  164. /package/{grid-pro → table-pro}/assets/HorizontalGrip.d.ts +0 -0
  165. /package/{grid-pro → table-pro}/assets/HorizontalGrip.js +0 -0
  166. /package/{grid-pro → table-pro}/assets/VerticalGrip.d.ts +0 -0
  167. /package/{grid-pro → table-pro}/assets/VerticalGrip.js +0 -0
  168. /package/{grid-pro/util → table-pro/lib}/regDragCleanup.d.ts +0 -0
  169. /package/{grid-pro/util → table-pro/lib}/regDragCleanup.js +0 -0
  170. /package/{grid-pro/util → table-pro/lib}/types.d.ts +0 -0
  171. /package/{grid/toolbar → table-pro/lib}/types.js +0 -0
  172. /package/{grid-pro → table-pro}/reorder/ReorderHandleCell.d.ts +0 -0
  173. /package/{grid-pro → table-pro}/reorder/ReorderHeaderCell.d.ts +0 -0
  174. /package/{grid-pro → table-pro}/reorder/ReorderHeaderCell.js +0 -0
  175. /package/{grid-pro → table-pro}/reorder/types.d.ts +0 -0
  176. /package/{grid → table-pro/reorder}/types.js +0 -0
  177. /package/{grid-pro → table-pro}/reorder/useKeyboardReorder.d.ts +0 -0
  178. /package/{grid-pro → table-pro}/reorder/useKeyboardReorderListener.d.ts +0 -0
  179. /package/{grid-pro → table-pro}/reorder/useKeyboardReorderListener.js +0 -0
  180. /package/{grid-pro → table-pro}/reorder/useReorderStyles.d.ts +0 -0
  181. /package/{grid-pro → table-pro}/reorder/useReorderStyles.js +0 -0
  182. /package/{grid-pro → table-pro}/resize/types.d.ts +0 -0
  183. /package/{grid-pro → table-pro}/resize/useResizeModel.js +0 -0
  184. /package/{grid-pro → table-pro}/util/index.d.ts +0 -0
  185. /package/{grid-pro → table-pro}/util/index.js +0 -0
  186. /package/{grid-pro → table-pro}/util/reorderRows.d.ts +0 -0
  187. /package/{grid-pro → table-pro}/util/reorderRows.js +0 -0
  188. /package/{style.css → table-pro.css} +0 -0
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useMemo, useRef, } from "react";
4
+ import useCombinedPipeline from "../../common/pipeline/useCombinedPipeline";
5
+ import useAugFormattedRows from "../../common/pipeline/useAugFormattedRows";
6
+ import useColNameToWidth from "../../common/pipeline/useColNameToWidth";
7
+ import GridHeader from "./GridHeader";
8
+ import GridBody from "./GridBody";
9
+ import classNames from "classnames";
10
+ import { CSS_PREFIX } from "../../common/constants";
11
+ import useGridFocus from "../focus/useGridFocus";
12
+ const Grid = ({ rows, cols, filterModel, sortModel, pagination, selectModel, width, height, variant, stripes, hover, borders, small, divider, borderVariant, headerCellVariant, headerRowVariant, bodyCellVariant, bodyRowVariant, headerCellFocusVariant, bodyCellFocusVariant }) => {
13
+ const { displayRows, filteredRows } = useCombinedPipeline({
14
+ rows,
15
+ cols,
16
+ filterModel,
17
+ sortModel,
18
+ pagination,
19
+ selectModel,
20
+ });
21
+ const colNameToWidth = useColNameToWidth(cols);
22
+ const augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
23
+ const gridStyle = useMemo(() => {
24
+ function getWidthProperty(width) {
25
+ if (width === "parent") {
26
+ return "100%";
27
+ }
28
+ if (typeof width === "number") {
29
+ return width;
30
+ }
31
+ return "min-content";
32
+ }
33
+ function getHeightProperty(height) {
34
+ if (height === "parent") {
35
+ return "100%";
36
+ }
37
+ if (typeof height === "number") {
38
+ return height;
39
+ }
40
+ return undefined;
41
+ }
42
+ return {
43
+ width: getWidthProperty(width),
44
+ height: getHeightProperty(height),
45
+ };
46
+ }, [width, height]);
47
+ const vertScrollable = height !== undefined && height !== "auto";
48
+ const gridRef = useRef(null);
49
+ const { effectiveCoords, gridClickHandler, gridKeydownHandler } = useGridFocus(gridRef, rows.length + 1, cols.length);
50
+ const onCopy = useCallback((event) => {
51
+ var _a;
52
+ if (!((_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement))) {
53
+ return;
54
+ }
55
+ const selection = document.getSelection();
56
+ if (!selection || !selection.isCollapsed) {
57
+ return;
58
+ }
59
+ event.preventDefault();
60
+ event.clipboardData.setData("text/plain", selection.focusNode.textContent);
61
+ }, []);
62
+ return (_jsxs("div", { onCopy: onCopy, onClick: gridClickHandler, onKeyDown: gridKeydownHandler, ref: gridRef, style: gridStyle, className: classNames({
63
+ "overflow-x-auto": width !== undefined && width !== "auto",
64
+ "overflow-y-auto": vertScrollable,
65
+ "rbdg-grid-striped": stripes === "rows",
66
+ "rbdg-grid-striped-columns": stripes === "columns",
67
+ "rbdg-grid-hover": !!hover,
68
+ "rbdg-grid-bordered": borders === "full",
69
+ "rbdg-grid-borderless": borders === "none",
70
+ "rbdg-grid-sm": !!small,
71
+ "rbdg-grid-group-divider": !!divider,
72
+ }, "rbdg-grid", variant && `${CSS_PREFIX}-${variant}`, borderVariant && `border-${borderVariant}`), role: "grid", "aria-colcount": cols.length, "aria-rowcount": filteredRows.length + 1, children: [_jsx(GridHeader, { cols: cols, rowVariant: headerRowVariant, cellVariant: headerCellVariant, vertScrollable: vertScrollable, focusColIndex: effectiveCoords.ariaRowIndex === 1
73
+ ? effectiveCoords.ariaColIndex
74
+ : null, cellFocusVariant: headerCellFocusVariant }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
75
+ };
76
+ export default Grid;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { GridBodyProps } from "./types";
3
+ declare const GridBody: FC<GridBodyProps>;
4
+ export default GridBody;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import getWidthStyles from "./getWidthStyles";
3
+ import classNames from "classnames";
4
+ import { CSS_PREFIX, DEFAULT_COL_WIDTH } from "../../common/constants";
5
+ import { GRID_BODY_DATA_TEST_ID } from "../constants";
6
+ const GridBody = ({ augFormattedRows, cols, rowVariant, cellVariant, focusCoords, cellFocusVariant, }) => {
7
+ return (_jsx("div", { role: "rowgroup", "data-testid": GRID_BODY_DATA_TEST_ID, children: augFormattedRows.map((row, rowDisplayIndex) => {
8
+ const ariaRowIndex = row.prePaginationIndex + 2;
9
+ return (_jsx("div", { role: "row", "aria-rowindex": ariaRowIndex, className: classNames("d-flex", "flex-row", rowVariant &&
10
+ rowVariant(row, rowDisplayIndex) &&
11
+ `${CSS_PREFIX}-${rowVariant(row, rowDisplayIndex)}`), children: row.contents.map(({ formattedValue, width }, index) => {
12
+ const ariaColIndex = index + 1;
13
+ const isFocused = focusCoords.ariaColIndex === ariaColIndex &&
14
+ focusCoords.ariaRowIndex === ariaRowIndex;
15
+ const cellVariantVal = cellVariant &&
16
+ cellVariant(row.contents[index], row, index, rowDisplayIndex);
17
+ const cellFocusVariantVal = cellFocusVariant &&
18
+ cellFocusVariant(row.contents[index], row, index, rowDisplayIndex);
19
+ return (_jsx("div", { tabIndex: isFocused ? 0 : -1, style: getWidthStyles(width || DEFAULT_COL_WIDTH), role: "gridcell", className: classNames("rbdg-grid-cell", cellVariantVal && `${CSS_PREFIX}-${cellVariantVal}`, cellFocusVariantVal && `focus-ring-${cellFocusVariantVal}`, {
20
+ "z-2": isFocused,
21
+ "rbdg-focusable-cell": isFocused,
22
+ }), "aria-colindex": ariaColIndex, children: formattedValue }, cols[index].name));
23
+ }) }, row.id));
24
+ }) }));
25
+ };
26
+ export default GridBody;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { GridHeaderProps } from "./types";
3
+ declare const GridHeader: FC<GridHeaderProps>;
4
+ export default GridHeader;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import getWidthStyles from "./getWidthStyles";
3
+ import classNames from "classnames";
4
+ import { CSS_PREFIX, DEFAULT_COL_WIDTH } from "../../common/constants";
5
+ import { GRID_HEADER_DATA_TEST_ID } from "../constants";
6
+ const GridHeader = ({ cols, vertScrollable, rowVariant, cellVariant, focusColIndex, cellFocusVariant }) => {
7
+ return (_jsx("div", { "data-testid": GRID_HEADER_DATA_TEST_ID, role: "rowgroup", className: classNames(vertScrollable ? ["position-sticky", "z-1", "top-0"] : []), children: _jsx("div", { role: "row", className: classNames("d-flex", "flex-row", rowVariant && `${CSS_PREFIX}-${rowVariant}`), "aria-rowindex": 1, children: cols.map((col, index) => {
8
+ const ariaColIndex = index + 1;
9
+ const isFocused = focusColIndex === ariaColIndex;
10
+ const cellVariantVal = cellVariant && cellVariant(col, index);
11
+ const cellFocusVariantVal = cellFocusVariant && cellFocusVariant(col, index);
12
+ return (_jsx("div", { tabIndex: isFocused ? 0 : -1, className: classNames("rbdg-grid-cell", "fw-bold", cellVariantVal && `${CSS_PREFIX}-${cellVariantVal}`, cellFocusVariantVal && `focus-ring-${cellFocusVariantVal}`, { "z-2": isFocused, "rbdg-focusable-cell": isFocused }), role: "columnheader", "aria-colindex": ariaColIndex, style: getWidthStyles(col.width || DEFAULT_COL_WIDTH), children: col.label }, col.name));
13
+ }) }) }));
14
+ };
15
+ export default GridHeader;
@@ -0,0 +1,3 @@
1
+ import { CSSProperties } from "react";
2
+ declare const getWidthStyles: (width: number) => CSSProperties;
3
+ export default getWidthStyles;
@@ -0,0 +1,6 @@
1
+ const getWidthStyles = (width) => ({
2
+ width: width,
3
+ maxWidth: width,
4
+ minWidth: width,
5
+ });
6
+ export default getWidthStyles;
@@ -0,0 +1,41 @@
1
+ import { AugFormattedRow, CellData, ColDef, FormattedRow, MainComponentSharedProps } from "../../common";
2
+ import { FocusCoordinates } from "../focus/types";
3
+ export type BodyCellVariantFn = (cell: CellData, row: FormattedRow, colIndex: number, displayIndex: number) => string | null;
4
+ export type HeaderCellVariantFn = (col: ColDef, colIndex: number) => string | null;
5
+ export type GridProps = MainComponentSharedProps & {
6
+ height?: GridHeightSetting;
7
+ width?: GridWidthSetting;
8
+ variant?: string;
9
+ stripes?: GridStripeSetting;
10
+ hover?: boolean;
11
+ borders?: GridBorderSetting;
12
+ borderVariant?: string;
13
+ small?: boolean;
14
+ divider?: boolean;
15
+ headerRowVariant?: string;
16
+ headerCellVariant?: HeaderCellVariantFn;
17
+ bodyRowVariant?: (row: FormattedRow, displayIndex: number) => string | null;
18
+ bodyCellVariant?: BodyCellVariantFn;
19
+ headerCellFocusVariant?: HeaderCellVariantFn;
20
+ bodyCellFocusVariant?: BodyCellVariantFn;
21
+ };
22
+ export interface GridHeaderProps {
23
+ cols: GridProps["cols"];
24
+ vertScrollable: boolean;
25
+ rowVariant?: GridProps["headerRowVariant"];
26
+ cellVariant?: GridProps["headerCellVariant"];
27
+ focusColIndex: number | null;
28
+ cellFocusVariant?: GridProps["headerCellFocusVariant"];
29
+ }
30
+ export type GridBodyProps = {
31
+ augFormattedRows: AugFormattedRow[];
32
+ cols: GridProps["cols"];
33
+ rowVariant?: GridProps["bodyRowVariant"];
34
+ cellVariant?: GridProps["bodyCellVariant"];
35
+ focusCoords: FocusCoordinates;
36
+ cellFocusVariant?: GridProps["bodyCellFocusVariant"];
37
+ };
38
+ export type GridHeightSetting = number | "auto" | "parent";
39
+ export type GridWidthSetting = number | "auto" | "parent";
40
+ export type GridStripeSetting = "rows" | "columns" | "none";
41
+ export type GridBorderSetting = "horizontal" | "full" | "none";
package/grid.css ADDED
@@ -0,0 +1 @@
1
+ .rbdg-grid>div,.rbdg-grid>div>div,.rbdg-grid>div>div>div{border-color:inherit;border-style:solid;border-width:0}.rbdg-grid{--rbdg-grid-color: var(--bs-emphasis-color);--rbdg-grid-bg: var(--bs-body-bg);--rbdg-grid-border-color: var(--bs-border-color);--rbdg-grid-accent-bg: transparent;--rbdg-grid-striped-color: var(--bs-emphasis-color);--rbdg-grid-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);--rbdg-grid-active-color: var(--bs-emphasis-color);--rbdg-grid-active-bg: rgba(var(--bs-emphasis-color-rgb), 0.1);--rbdg-grid-hover-color: var(--bs-emphasis-color);--rbdg-grid-hover-bg: rgba(var(--bs-emphasis-color-rgb), 0.075);border-color:var(--rbdg-grid-border-color)}.rbdg-grid>div{width:min-content}.rbdg-grid>div>div>div{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding:.5rem .5rem;color:var(--rbdg-grid-color-state, var(--rbdg-grid-color-type, var(--rbdg-grid-color)));background-color:var(--rbdg-grid-bg);border-bottom-width:var(--bs-border-width);box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg)))}.rbdg-grid>div>div>div.rbdg-focusable-cell:focus{outline:0;box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg))),var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.rbdg-grid>div:first-child>div>div{border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-group-divider{--rbdg-grid-divider-border-width: calc(var(--bs-border-width) * 2);--rbdg-grid-divider-border-style: solid;--rbdg-grid-divider-border-color: currentcolor}.rbdg-grid-sm>div>div>div{padding:.25rem .25rem}.rbdg-grid-bordered{border-width:var(--bs-border-width);border-style:solid}.rbdg-grid-bordered>div>div>div:not(:last-child){border-width:0 var(--bs-border-width) 0 0}.rbdg-grid-bordered>div>div>div:last-child{border-width:0}.rbdg-grid-bordered>div:first-child>div{border-top-width:0;border-right-width:0;border-left-width:0;border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-bordered>div:last-child>div:not(:last-child){border-width:0 0 var(--bs-border-width) 0}.rbdg-grid-borderless{--rbdg-grid-divider-borderless-width: 0}.rbdg-grid-borderless>div>div>div{border-bottom-width:0}.rbdg-grid-borderless>:not(:first-child){border-top-width:0}.rbdg-grid-striped>div:nth-of-type(2)>div:nth-of-type(odd)>div{--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-striped-columns>div>div>:nth-child(even){--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-active{--rbdg-grid-color-state: var(--bs-grid-active-color);--rbdg-grid-bg-state: var(--rbdg-grid-active-bg)}.rbdg-grid-hover>div:nth-of-type(2)>div:hover>div{--rbdg-grid-color-state: var(--rbdg-grid-hover-color);--rbdg-grid-bg-state: var(--rbdg-grid-hover-bg)}.rbdg-grid-primary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 226, 254.6);--rbdg-grid-border-color: rgb(165.28, 180.8, 203.68);--rbdg-grid-striped-bg: rgb(196.27, 214.7, 241.87);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 203.4, 229.14);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 209.05, 235.505);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-secondary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(225.6, 227.4, 229);--rbdg-grid-border-color: rgb(180.48, 181.92, 183.2);--rbdg-grid-striped-bg: rgb(214.32, 216.03, 217.55);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(203.04, 204.66, 206.1);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(208.68, 210.345, 211.825);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-success{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(209, 231, 220.8);--rbdg-grid-border-color: rgb(167.2, 184.8, 176.64);--rbdg-grid-striped-bg: rgb(198.55, 219.45, 209.76);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(188.1, 207.9, 198.72);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(193.325, 213.675, 204.24);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-info{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 244.4, 252);--rbdg-grid-border-color: rgb(165.28, 195.52, 201.6);--rbdg-grid-striped-bg: rgb(196.27, 232.18, 239.4);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 219.96, 226.8);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 226.07, 233.1);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-warning{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(255, 242.6, 205.4);--rbdg-grid-border-color: rgb(204, 194.08, 164.32);--rbdg-grid-striped-bg: rgb(242.25, 230.47, 195.13);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(229.5, 218.34, 184.86);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(235.875, 224.405, 189.995);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-danger{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(248, 214.6, 217.8);--rbdg-grid-border-color: rgb(198.4, 171.68, 174.24);--rbdg-grid-striped-bg: rgb(235.6, 203.87, 206.91);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 193.14, 196.02);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 198.505, 201.465);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-light{--rbdg-grid-color: #000;--rbdg-grid-bg: #f8f9fa;--rbdg-grid-border-color: rgb(198.4, 199.2, 200);--rbdg-grid-striped-bg: rgb(235.6, 236.55, 237.5);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 224.1, 225);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 230.325, 231.25);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-dark{--rbdg-grid-color: #fff;--rbdg-grid-bg: #212529;--rbdg-grid-border-color: rgb(77.4, 80.6, 83.8);--rbdg-grid-striped-bg: rgb(44.1, 47.9, 51.7);--rbdg-grid-striped-color: #fff;--rbdg-grid-active-bg: rgb(55.2, 58.8, 62.4);--rbdg-grid-active-color: #fff;--rbdg-grid-hover-bg: rgb(49.65, 53.35, 57.05);--rbdg-grid-hover-color: #fff;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}
package/grid.scss ADDED
@@ -0,0 +1,243 @@
1
+ @use "sass:color";
2
+ @use "sass:math";
3
+
4
+ $rbdg-prefix: "rbdg-";
5
+
6
+ .rbdg-grid > div,
7
+ .rbdg-grid > div > div,
8
+ .rbdg-grid > div > div > div {
9
+ border-color: inherit;
10
+ border-style: solid;
11
+ border-width: 0;
12
+ }
13
+
14
+ // While these rules seem to work, the way that the three border modes, default; bordered; and borderless override each
15
+ // other is quite hard to understand.
16
+ // Consider refactoring so that each type mode, including default, has a separate class that contains rules for just
17
+ // that mode.
18
+ // The way that each border mode that interacts with dividers with quite complicated. Each combination should be tested
19
+ // separately.
20
+
21
+ .rbdg-grid {
22
+ // In Bootstrap's _tables.scss file, there are variable declarations here to reset some variables to the initial
23
+ // value to facilitate nesting of tables styled with Bootstrap's "table" CSS class. Unlike _tables.scss, there is no
24
+ // reset in this file because the RBDG flex grid is not meant to be nested.
25
+
26
+ --#{$rbdg-prefix}grid-color: #{$table-color};
27
+ --#{$rbdg-prefix}grid-bg: #{$table-bg};
28
+ --#{$rbdg-prefix}grid-border-color: #{$table-border-color};
29
+ --#{$rbdg-prefix}grid-accent-bg: #{$table-accent-bg};
30
+ --#{$rbdg-prefix}grid-striped-color: #{$table-striped-color};
31
+ --#{$rbdg-prefix}grid-striped-bg: #{$table-striped-bg};
32
+ --#{$rbdg-prefix}grid-active-color: #{$table-active-color};
33
+ --#{$rbdg-prefix}grid-active-bg: #{$table-active-bg};
34
+ --#{$rbdg-prefix}grid-hover-color: #{$table-hover-color};
35
+ --#{$rbdg-prefix}grid-hover-bg: #{$table-hover-bg};
36
+
37
+ border-color: var(--#{$rbdg-prefix}grid-border-color);
38
+
39
+ > div {
40
+ width: min-content;
41
+
42
+ > div {
43
+ > div {
44
+ text-overflow: ellipsis;
45
+ white-space: nowrap;
46
+ overflow: hidden;
47
+ padding: $table-cell-padding-y $table-cell-padding-x;
48
+ color: var(
49
+ --#{$rbdg-prefix}grid-color-state,
50
+ var(--#{$rbdg-prefix}grid-color-type, var(--#{$rbdg-prefix}grid-color))
51
+ );
52
+ background-color: var(--#{$rbdg-prefix}grid-bg);
53
+ border-bottom-width: $table-border-width;
54
+ box-shadow: inset 0 0 0 9999px var(
55
+ --#{$rbdg-prefix}grid-bg-state,
56
+ var(
57
+ --#{$rbdg-prefix}grid-bg-type,
58
+ var(--#{$rbdg-prefix}grid-accent-bg)
59
+ )
60
+ );
61
+ }
62
+
63
+ > div.rbdg-focusable-cell:focus {
64
+ outline: 0;
65
+ box-shadow: inset 0 0 0 9999px var(
66
+ --#{$rbdg-prefix}grid-bg-state,
67
+ var(
68
+ --#{$rbdg-prefix}grid-bg-type,
69
+ var(--#{$rbdg-prefix}grid-accent-bg)
70
+ )
71
+ ), var(--#{$prefix}focus-ring-x, 0) var(--#{$prefix}focus-ring-y, 0) var(--#{$prefix}focus-ring-blur, 0) var(--#{$prefix}focus-ring-width) var(--#{$prefix}focus-ring-color);
72
+ }
73
+ }
74
+ }
75
+
76
+ // These properties are overridden by the "> div > div > div:not(:last-child)" properties when rbdg-grid-bordered is
77
+ // applied.
78
+ > div:first-child > div > div {
79
+ border-bottom-width: var(
80
+ --#{$rbdg-prefix}grid-divider-border-width,
81
+ var(--#{$rbdg-prefix}grid-divider-borderless-width, $table-border-width)
82
+ );
83
+ border-bottom-style: var(
84
+ --#{$rbdg-prefix}grid-divider-border-style,
85
+ inherit
86
+ );
87
+ border-bottom-color: var(
88
+ --#{$rbdg-prefix}grid-divider-border-color,
89
+ inherit
90
+ );
91
+ }
92
+ }
93
+
94
+ .rbdg-grid-group-divider {
95
+ --#{$rbdg-prefix}grid-divider-border-width: calc(#{$table-border-width} * 2);
96
+ --#{$rbdg-prefix}grid-divider-border-style: solid;
97
+ --#{$rbdg-prefix}grid-divider-border-color: #{$table-group-separator-color};
98
+ }
99
+
100
+ .rbdg-grid-sm {
101
+ > div > div > div {
102
+ padding: $table-cell-padding-y-sm $table-cell-padding-x-sm;
103
+ }
104
+ }
105
+
106
+ .rbdg-grid-bordered {
107
+ border-width: $table-border-width;
108
+ border-style: solid;
109
+
110
+ > div > div {
111
+ > div:not(:last-child) {
112
+ border-width: 0 $table-border-width 0 0;
113
+ }
114
+
115
+ > div:last-child {
116
+ border-width: 0;
117
+ }
118
+ }
119
+
120
+ > div:first-child > div {
121
+ border-top-width: 0;
122
+ border-right-width: 0;
123
+ border-left-width: 0;
124
+ border-bottom-width: var(
125
+ --#{$rbdg-prefix}grid-divider-border-width,
126
+ var(--#{$rbdg-prefix}grid-divider-borderless-width, $table-border-width)
127
+ );
128
+ border-bottom-style: var(
129
+ --#{$rbdg-prefix}grid-divider-border-style,
130
+ inherit
131
+ );
132
+ border-bottom-color: var(
133
+ --#{$rbdg-prefix}grid-divider-border-color,
134
+ inherit
135
+ );
136
+ }
137
+
138
+ > div:last-child {
139
+ > div:not(:last-child) {
140
+ border-width: 0 0 $table-border-width 0;
141
+ }
142
+ }
143
+ }
144
+
145
+ .rbdg-grid-borderless {
146
+ --#{$rbdg-prefix}grid-divider-borderless-width: 0;
147
+
148
+ > div > div > div {
149
+ border-bottom-width: 0;
150
+ }
151
+
152
+ > :not(:first-child) {
153
+ border-top-width: 0;
154
+ }
155
+ }
156
+
157
+ .rbdg-grid-striped {
158
+ > div:nth-of-type(2) > div:nth-of-type(#{$table-striped-order}) > div {
159
+ --#{$rbdg-prefix}grid-color-type: var(--#{$rbdg-prefix}grid-striped-color);
160
+ --#{$rbdg-prefix}grid-bg-type: var(--#{$rbdg-prefix}grid-striped-bg);
161
+ }
162
+ }
163
+
164
+ .rbdg-grid-striped-columns {
165
+ > div > div > :nth-child(#{$table-striped-columns-order}) {
166
+ --#{$rbdg-prefix}grid-color-type: var(--#{$rbdg-prefix}grid-striped-color);
167
+ --#{$rbdg-prefix}grid-bg-type: var(--#{$rbdg-prefix}grid-striped-bg);
168
+ }
169
+ }
170
+
171
+ .rbdg-grid-active {
172
+ --#{$rbdg-prefix}grid-color-state: var(--#{$prefix}grid-active-color);
173
+ --#{$rbdg-prefix}grid-bg-state: var(--#{$rbdg-prefix}grid-active-bg);
174
+ }
175
+
176
+ .rbdg-grid-hover {
177
+ > div:nth-of-type(2) > div:hover > div {
178
+ --#{$rbdg-prefix}grid-color-state: var(--#{$rbdg-prefix}grid-hover-color);
179
+ --#{$rbdg-prefix}grid-bg-state: var(--#{$rbdg-prefix}grid-hover-bg);
180
+ }
181
+ }
182
+
183
+ @mixin rbdg-grid-variant($state, $background) {
184
+ .rbdg-grid-#{$state} {
185
+ $color: color-contrast(opaque($body-bg, $background));
186
+ $hover-bg: color.mix(
187
+ $color,
188
+ $background,
189
+ math.percentage($table-hover-bg-factor)
190
+ );
191
+ $striped-bg: color.mix(
192
+ $color,
193
+ $background,
194
+ math.percentage($table-striped-bg-factor)
195
+ );
196
+ $active-bg: color.mix(
197
+ $color,
198
+ $background,
199
+ math.percentage($table-active-bg-factor)
200
+ );
201
+ $table-border-color: color.mix(
202
+ $color,
203
+ $background,
204
+ math.percentage($table-border-factor)
205
+ );
206
+
207
+ --#{$rbdg-prefix}grid-color: #{$color};
208
+ --#{$rbdg-prefix}grid-bg: #{$background};
209
+ --#{$rbdg-prefix}grid-border-color: #{$table-border-color};
210
+ --#{$rbdg-prefix}grid-striped-bg: #{$striped-bg};
211
+ --#{$rbdg-prefix}grid-striped-color: #{color-contrast($striped-bg)};
212
+ --#{$rbdg-prefix}grid-active-bg: #{$active-bg};
213
+ --#{$rbdg-prefix}grid-active-color: #{color-contrast($active-bg)};
214
+ --#{$rbdg-prefix}grid-hover-bg: #{$hover-bg};
215
+ --#{$rbdg-prefix}grid-hover-color: #{color-contrast($hover-bg)};
216
+
217
+ color: var(--#{$rbdg-prefix}grid-color);
218
+ border-color: var(--#{$rbdg-prefix}grid-border-color);
219
+ }
220
+ }
221
+
222
+ @each $color, $value in $table-variants {
223
+ @include rbdg-grid-variant($color, $value);
224
+ }
225
+
226
+ // A note about Responsive Tables
227
+ //
228
+ // The Bootstrap _tables.scss file contains a series of classes to apply responsive tables at various breakpoints.
229
+ // There is no such equivalent for RBDG flex grid for the following reason.
230
+ //
231
+ // The RBDG flex grid is a div of type "block," so the concept of "responsive" scrollable breakpoints doesn't apply.
232
+ // It appears that for a table, even if the width is to 100%, the browser sometimes disobeys this setting causing
233
+ // the width to be more than the parent, hence the need for responsive tables. Divs do not appear to have this problem.
234
+ //
235
+ // The RBDG flex grid provides other options to achieving a horizontally scrollable grid. They are as follows.
236
+ //
237
+ // When using the default or "auto" setting for the RBDG grid's "width," the intrinsic width of the grid columns is
238
+ // used. In such circumstances, if one wants to make the grid scrollable horizontally, they can enclose the grid in a
239
+ // horizontally-scrollable div.
240
+ //
241
+ // When the grid's width is to set to "parent", the grid takes on the width of the parent (width 100% CSS value) just
242
+ // like the Bootstrap table does. In this case, the grid div itself is horizontally scrollable. In contrast, for
243
+ // responsive Bootstrap tables, it is a div that encloses the table element that is scrollable.
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": "3.0.0",
4
+ "version": "4.1.0",
5
5
  "license": "Commercial. See LICENSE file.",
6
6
  "author": "Brook Li",
7
7
  "homepage": "https://react-bootstrap-data-grid.vercel.app/",
package/pro/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "../grid";
2
+ export * from "../table-pro";
3
+ export { default as Grid } from "../grid";
4
+ export { default as Table } from "../table";
5
+ export { default as TablePro } from "../table-pro";
package/pro/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "../grid";
2
+ export * from "../table-pro";
3
+ export { default as Grid } from "../grid";
4
+ export { default as Table } from "../table";
5
+ export { default as TablePro } from "../table-pro";
@@ -1,9 +1,9 @@
1
1
  import { FC, ReactNode } from "react";
2
- import { BaseGridProps } from "./types";
3
- import { UseCombinedPipelineHook } from "./pipeline/useCombinedPipeline";
4
- import { UseGridSelectionFnsHook } from "./pipeline/useGridSelectionFns";
2
+ import { BaseTableProps } from "./types";
3
+ import { UseCombinedPipelineHook } from "../common/pipeline/useCombinedPipeline";
4
+ import { UseGridSelectionFnsHook } from "../common/pipeline/useGridSelectionFns";
5
5
  export interface InternalGridProps {
6
- gridProps: BaseGridProps;
6
+ gridProps: BaseTableProps;
7
7
  hooks: {
8
8
  selectFns: UseGridSelectionFnsHook;
9
9
  pipelineOutput: UseCombinedPipelineHook;
@@ -17,5 +17,5 @@ export interface InternalGridProps {
17
17
  headerRow?: string[];
18
18
  };
19
19
  }
20
- declare const InternalGrid: FC<InternalGridProps>;
21
- export default InternalGrid;
20
+ declare const InternalTable: FC<InternalGridProps>;
21
+ export default InternalTable;
@@ -2,13 +2,13 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useMemo } from "react";
4
4
  import SelectAllHeaderCell from "./selection/SelectAllHeaderCell";
5
- import Pagination from "./pagination/Pagination";
5
+ import Pagination from "../common/pagination/Pagination";
6
6
  import classNames from "classnames";
7
- import useInterfaces from "./toolbar/useInterfaces";
8
- import ToolbarContainer from "./toolbar/ToolbarContainer";
9
- import useExportFn from "./export/useExportFn";
10
- import getWidthStyle from "./util/getWidthStyle";
11
- const InternalGrid = ({ gridProps: { rows, cols, pagination, filterModel, selectModel, editModel, caption, styleModel, displayMode, allowExport, }, hooks: { pipelineOutput, selectFns }, slots: { colHeaderCells, bodyRows, prefixHeader }, classes, }) => {
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
+ const InternalTable = ({ gridProps: { rows, cols, pagination, filterModel, selectModel, editModel, caption, styleModel, displayMode, allowExport, }, hooks: { pipelineOutput, selectFns }, slots: { colHeaderCells, bodyRows, prefixHeader }, classes, }) => {
12
12
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
13
13
  const { normalizedTableFilterModel, filteredRows, filterState, sortedRowsOutput: { sortedRows }, currentPageRowsOutput: { paginatedRows, normalizedModel }, showSelectCol, } = pipelineOutput;
14
14
  const exportFnInfo = useExportFn({
@@ -55,4 +55,4 @@ const InternalGrid = ({ gridProps: { rows, cols, pagination, filterModel, select
55
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
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 }))] })] }));
57
57
  };
58
- export default InternalGrid;
58
+ export default InternalTable;
@@ -0,0 +1,5 @@
1
+ import { FC } from "react";
2
+ import { TableProps } from "./types";
3
+ declare const Table: FC<TableProps>;
4
+ export default Table;
5
+ export type { TableProps } from "./types";
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useMemo } from "react";
4
- import InternalGrid from "./InternalGrid";
3
+ import InternalTable from "./InternalTable";
5
4
  import ColHeaderCell from "./main/ColHeaderCell";
6
- import useCombinedPipeline from "./pipeline/useCombinedPipeline";
7
- import useGridSelectionFns from "./pipeline/useGridSelectionFns";
8
- import useGetInputStrSubmitCallback from "./pipeline/useGetInputStrSubmitCallback";
9
- 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";
10
9
  import BodyRows from "./main/BodyRows";
11
- const Grid = (props) => {
10
+ import useColNameToWidth from "../common/pipeline/useColNameToWidth";
11
+ const Table = (props) => {
12
12
  const { rows, cols, filterModel, sortModel, pagination, selectModel, styleModel, editModel, } = props;
13
13
  const combinedPipelineOutput = useCombinedPipeline({
14
14
  rows,
@@ -21,11 +21,7 @@ const Grid = (props) => {
21
21
  const { sortedRowsOutput: { sortColDef, setSortColDef, sortingEnabled }, showSelectCol, displayRows, } = combinedPipelineOutput;
22
22
  const gridSelectionFns = useGridSelectionFns(selectModel, rows);
23
23
  const getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
24
- const colNameToWidth = useMemo(() => {
25
- const map = {};
26
- cols.forEach(({ name, width }) => (map[name] = width));
27
- return map;
28
- }, [cols]);
24
+ const colNameToWidth = useColNameToWidth(cols);
29
25
  const augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
30
26
  const colHeaderCells = cols.map(({ name, label, sortable, width }, index) => {
31
27
  var _a;
@@ -41,9 +37,9 @@ const Grid = (props) => {
41
37
  styleModel.mainTableStyleModel.theadTh(index), width: width }, name));
42
38
  });
43
39
  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 }));
44
- return (_jsx(InternalGrid, { gridProps: props, hooks: {
40
+ return (_jsx(InternalTable, { gridProps: props, hooks: {
45
41
  pipelineOutput: combinedPipelineOutput,
46
42
  selectFns: gridSelectionFns,
47
43
  }, slots: { colHeaderCells, bodyRows } }));
48
44
  };
49
- export default Grid;
45
+ export default Table;
@@ -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 "./types";
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;
@@ -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 "../util/datetime";
4
+ import { dateToDatetimeInputStr, dateToInputStr, } from "../../common/util/datetime";
5
5
  import EditControlsCell from "./EditControlsCell";
6
6
  import classNames from "classnames";
7
- import getWidthStyle from "../util/getWidthStyle";
7
+ import getWidthStyle from "../../common/util/getWidthStyle";
8
8
  const initValueToFormValue = (value, type) => {
9
9
  switch (type) {
10
10
  case "date":
@@ -0,0 +1,5 @@
1
+ export * from "./types";
2
+ export * from "./styling/types";
3
+ export * from "../common/selection/types";
4
+ export * from "../common";
5
+ export { default } from "./Table";
package/table/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./types";
2
+ export * from "./styling/types";
3
+ export * from "../common/selection/types";
4
+ export * from "../common";
5
+ export { default } from "./Table";
@@ -1,11 +1,11 @@
1
- import { AugFormattedRow, RowId } from "../types";
2
1
  import { FC, ReactNode } from "react";
3
- import { UseGridSelectionFnsHook } from "../pipeline/useGridSelectionFns";
4
- import { UseCombinedPipelineHook } from "../pipeline/useCombinedPipeline";
5
- import { SelectModel } from "../selection/types";
6
- import { EditModel } from "../editing/types";
7
- import { UseGetInputStrSubmitCallbackHook } from "../pipeline/useGetInputStrSubmitCallback";
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";
8
6
  import { TableStyleModel } from "../styling/types";
7
+ import { AugFormattedRow, FormattedRow, RowId } from "../../common/types";
8
+ import { EditModel } from "../../common/editing/types";
9
9
  interface BodyRowsProps {
10
10
  augFormattedRows: AugFormattedRow[];
11
11
  gridSelectionFns: UseGridSelectionFnsHook;
@@ -15,7 +15,7 @@ interface BodyRowsProps {
15
15
  editModel: EditModel | undefined;
16
16
  getInputStrSubmitCallback: UseGetInputStrSubmitCallbackHook;
17
17
  additionalColIndexOffset?: number;
18
- renderPrefixCells?: (augFormattedRows: AugFormattedRow) => ReactNode;
18
+ renderPrefixCells?: (augFormattedRows: FormattedRow) => ReactNode;
19
19
  additionalRowStyles?: (rowId: RowId, displayIndex: number) => string[];
20
20
  }
21
21
  declare const BodyRows: FC<BodyRowsProps>;