@absreim/react-bootstrap-data-grid 1.2.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/ColHeaderCell.d.ts +2 -1
  2. package/ColHeaderCell.js +6 -6
  3. package/Grid.d.ts +10 -10
  4. package/Grid.js +56 -43
  5. package/ToggleButton.d.ts +1 -0
  6. package/ToggleButton.js +5 -3
  7. package/editing/EditControlsCell.d.ts +16 -0
  8. package/editing/EditControlsCell.js +19 -0
  9. package/editing/EditableRow.d.ts +20 -0
  10. package/editing/EditableRow.js +67 -0
  11. package/editing/inputStrsToRowDef.d.ts +3 -0
  12. package/editing/inputStrsToRowDef.js +18 -0
  13. package/editing/types.d.ts +14 -0
  14. package/{FilterOptionsTable → filtering}/DateFilterRow.d.ts +8 -2
  15. package/filtering/DateFilterRow.js +46 -0
  16. package/{FilterOptionsTable → filtering}/FilterOptionsTable.d.ts +4 -1
  17. package/{FilterOptionsTable → filtering}/FilterOptionsTable.js +26 -7
  18. package/filtering/FilterRow.d.ts +19 -0
  19. package/filtering/FilterRow.js +18 -0
  20. package/{FilterOptionsTable → filtering}/NumberFilterRow.d.ts +7 -2
  21. package/filtering/NumberFilterRow.js +35 -0
  22. package/filtering/StringFilterRow.d.ts +14 -0
  23. package/filtering/StringFilterRow.js +35 -0
  24. package/filtering/types.d.ts +64 -0
  25. package/filtering/types.js +30 -0
  26. package/{FilterOptionsTable → filtering}/useFormStateFromTableFilterState.d.ts +1 -2
  27. package/index.d.ts +6 -1
  28. package/index.js +6 -1
  29. package/package.json +3 -2
  30. package/pagination/PageSelector.d.ts +2 -2
  31. package/pagination/Pagination.d.ts +3 -1
  32. package/pagination/Pagination.js +2 -2
  33. package/pagination/types.d.ts +12 -0
  34. package/pagination/types.js +1 -0
  35. package/pipeline/useCurrentPageRows.d.ts +4 -0
  36. package/pipeline/useCurrentPageRows.js +14 -0
  37. package/{hooks → pipeline}/useDisplayRows.d.ts +1 -1
  38. package/{hooks → pipeline}/useDisplayRows.js +28 -21
  39. package/{hooks → pipeline}/useEditableFromFilterState.d.ts +1 -1
  40. package/{hooks → pipeline}/useFilter.d.ts +2 -1
  41. package/{hooks → pipeline}/useFilterStateFromEditable.d.ts +2 -1
  42. package/{hooks → pipeline}/useSortedRows.d.ts +2 -1
  43. package/selection/SelectAllHeaderCell.d.ts +2 -1
  44. package/selection/SelectAllHeaderCell.js +7 -6
  45. package/selection/SelectionInput.d.ts +1 -0
  46. package/selection/SelectionInput.js +3 -2
  47. package/selection/types.d.ts +16 -0
  48. package/selection/types.js +4 -0
  49. package/sorting/types.d.ts +13 -0
  50. package/sorting/types.js +1 -0
  51. package/style.scss +4 -4
  52. package/styling/styleModelUnwrappers.d.ts +4 -0
  53. package/styling/styleModelUnwrappers.js +57 -0
  54. package/styling/types.d.ts +44 -0
  55. package/styling/types.js +1 -0
  56. package/types.d.ts +2 -83
  57. package/types.js +1 -30
  58. package/{hooks → util}/useControlledHover.js +3 -7
  59. package/FilterOptionsTable/DateFilterRow.js +0 -45
  60. package/FilterOptionsTable/NumberFilterRow.js +0 -34
  61. package/FilterOptionsTable/StringFilterRow.d.ts +0 -9
  62. package/FilterOptionsTable/StringFilterRow.js +0 -34
  63. package/FilterOptionsTable/types.d.ts +0 -13
  64. /package/{FilterOptionsTable → editing}/types.js +0 -0
  65. /package/{FilterOptionsTable → filtering}/useFormStateFromTableFilterState.js +0 -0
  66. /package/{hooks → pipeline}/useAugmentedRows.d.ts +0 -0
  67. /package/{hooks → pipeline}/useAugmentedRows.js +0 -0
  68. /package/{hooks → pipeline}/useEditableFromFilterState.js +0 -0
  69. /package/{hooks → pipeline}/useFilter.js +0 -0
  70. /package/{hooks → pipeline}/useFilterStateFromEditable.js +0 -0
  71. /package/{hooks → pipeline}/useSortedRows.js +0 -0
  72. /package/{icons → selection}/deselectAll.d.ts +0 -0
  73. /package/{icons → selection}/deselectAll.js +0 -0
  74. /package/{icons → selection}/selectAll.d.ts +0 -0
  75. /package/{icons → selection}/selectAll.js +0 -0
  76. /package/{icons → sorting}/arrowPlaceholder.d.ts +0 -0
  77. /package/{icons → sorting}/arrowPlaceholder.js +0 -0
  78. /package/{icons → sorting}/downArrow.d.ts +0 -0
  79. /package/{icons → sorting}/downArrow.js +0 -0
  80. /package/{icons → sorting}/upArrow.d.ts +0 -0
  81. /package/{icons → sorting}/upArrow.js +0 -0
  82. /package/{hooks → util}/useControlledHover.d.ts +0 -0
@@ -1,9 +1,14 @@
1
1
  import { FC } from "react";
2
2
  import { NumberFormFilterState } from "./types";
3
- interface NumberFilterRowProps {
3
+ import { CommonFilterRowStyleProps } from "./FilterRow";
4
+ export type NumberFilterRowProps = {
5
+ ariaRowIndex: number;
4
6
  columnLabel: string;
5
7
  filterState: NumberFormFilterState;
6
8
  setFilterState: (filterState: NumberFormFilterState) => void;
7
- }
9
+ schemeSelectClasses: string[];
10
+ enableInputClasses: string[];
11
+ numberInputClasses: string[];
12
+ } & CommonFilterRowStyleProps;
8
13
  declare const NumberFilterRow: FC<NumberFilterRowProps>;
9
14
  export default NumberFilterRow;
@@ -0,0 +1,35 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { numberFilterSchemeNames, } from "./types";
14
+ import FilterRow from "./FilterRow";
15
+ import classNames from "classnames";
16
+ var NumberFilterRow = function (_a) {
17
+ var ariaRowIndex = _a.ariaRowIndex, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState, schemeSelectClasses = _a.schemeSelectClasses, enableInputClasses = _a.enableInputClasses, numberInputClasses = _a.numberInputClasses, tdClasses = _a.tdClasses, trClasses = _a.trClasses;
18
+ var handleOpChange = function (_a) {
19
+ var target = _a.target;
20
+ setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
21
+ };
22
+ var handleEnabledChange = function (_a) {
23
+ var target = _a.target;
24
+ setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
25
+ };
26
+ var handleNumInputValueChange = function (_a) {
27
+ var target = _a.target;
28
+ setFilterState(__assign(__assign({}, filterState), { inputValue: target.value }));
29
+ };
30
+ var enabled = filterState.enabled, scheme = filterState.scheme, inputValue = filterState.inputValue;
31
+ var valueInputLabel = "".concat(columnLabel, " Column Filter Value");
32
+ var searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control", numberInputClasses), type: "number", required: enabled, disabled: !enabled, value: inputValue, onChange: handleNumInputValueChange }));
33
+ return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: "Number", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: numberFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
34
+ };
35
+ export default NumberFilterRow;
@@ -0,0 +1,14 @@
1
+ import { FC } from "react";
2
+ import { CommonFilterRowStyleProps } from "./FilterRow";
3
+ import { StringFilterState } from "./types";
4
+ type StringFilterRowProps = {
5
+ ariaRowIndex: number;
6
+ columnLabel: string;
7
+ filterState: StringFilterState;
8
+ setFilterState: (filterState: StringFilterState) => void;
9
+ schemeSelectClasses: string[];
10
+ enableInputClasses: string[];
11
+ searchStringInputClasses: string[];
12
+ } & CommonFilterRowStyleProps;
13
+ declare const StringFilterRow: FC<StringFilterRowProps>;
14
+ export default StringFilterRow;
@@ -0,0 +1,35 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import FilterRow from "./FilterRow";
14
+ import classNames from "classnames";
15
+ import { stringFilterSchemeNames, } from "./types";
16
+ var StringFilterRow = function (_a) {
17
+ var ariaRowIndex = _a.ariaRowIndex, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState, schemeSelectClasses = _a.schemeSelectClasses, enableInputClasses = _a.enableInputClasses, searchStringInputClasses = _a.searchStringInputClasses, tdClasses = _a.tdClasses, trClasses = _a.trClasses;
18
+ var handleOpChange = function (_a) {
19
+ var target = _a.target;
20
+ setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
21
+ };
22
+ var handleEnabledChange = function (_a) {
23
+ var target = _a.target;
24
+ setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
25
+ };
26
+ var handleSearchStringChange = function (_a) {
27
+ var target = _a.target;
28
+ setFilterState(__assign(__assign({}, filterState), { searchString: target.value }));
29
+ };
30
+ var enabled = filterState.enabled, scheme = filterState.scheme, searchString = filterState.searchString;
31
+ var valueInputLabel = "".concat(columnLabel, " Column Filter Value");
32
+ var searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control", searchStringInputClasses), required: enabled, disabled: !enabled, value: searchString, onChange: handleSearchStringChange }));
33
+ return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: "String", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: stringFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
34
+ };
35
+ export default StringFilterRow;
@@ -0,0 +1,64 @@
1
+ export type TableFilterState = Record<string, ColFilterState>;
2
+ export type EditableTableFilterState = Record<string, FilterState>;
3
+ export interface ColFilterState {
4
+ editableState: FilterState;
5
+ label: string;
6
+ }
7
+ export interface AbstractFilterState {
8
+ enabled: boolean;
9
+ }
10
+ export declare const stringFilterSchemes: readonly ["contains", "startsWith", "endsWith"];
11
+ export type StringFilterScheme = (typeof stringFilterSchemes)[number];
12
+ export declare const stringFilterSchemeNames: Record<StringFilterScheme, string>;
13
+ export interface StringFilterState extends AbstractFilterState {
14
+ type: "string";
15
+ scheme: StringFilterScheme;
16
+ searchString: string;
17
+ }
18
+ export declare const numberFilterSchemes: readonly ["equals", "greaterThan", "lessThan", "greaterOrEqual", "lessOrEqual"];
19
+ export type NumberFilterScheme = (typeof numberFilterSchemes)[number];
20
+ export declare const numberFilterSchemeNames: Record<NumberFilterScheme, string>;
21
+ export interface NumberFilterState extends AbstractFilterState {
22
+ type: "number";
23
+ scheme: NumberFilterScheme;
24
+ numValue: number | null;
25
+ }
26
+ export declare const dateFilterSchemes: readonly ["startFrom", "endAt", "between"];
27
+ export type DateFilterScheme = (typeof dateFilterSchemes)[number];
28
+ export declare const dateFilterSchemeNames: Record<DateFilterScheme, string>;
29
+ export interface AbstractDateFilterState extends AbstractFilterState {
30
+ type: "date" | "datetime";
31
+ scheme: DateFilterScheme;
32
+ }
33
+ export interface StartDateFilterState extends AbstractDateFilterState {
34
+ scheme: "startFrom";
35
+ startDate: Date | null;
36
+ }
37
+ export interface EndDateFilterState extends AbstractDateFilterState {
38
+ scheme: "endAt";
39
+ endDate: Date | null;
40
+ }
41
+ export interface BetweenDatesFilterState extends AbstractDateFilterState {
42
+ scheme: "between";
43
+ startDate: Date | null;
44
+ endDate: Date | null;
45
+ }
46
+ export type DateFilterState = StartDateFilterState | EndDateFilterState | BetweenDatesFilterState;
47
+ export type FilterState = StringFilterState | NumberFilterState | DateFilterState;
48
+ export interface FilterModel {
49
+ tableFilterState: EditableTableFilterState;
50
+ setTableFilterState: (state: EditableTableFilterState) => void;
51
+ filterTableCaption?: string;
52
+ }
53
+ export interface NumberFormFilterState extends AbstractFilterState {
54
+ type: "number";
55
+ scheme: NumberFilterScheme;
56
+ inputValue: string;
57
+ }
58
+ export interface DateFormFilterState extends AbstractDateFilterState {
59
+ scheme: DateFilterScheme;
60
+ startDate: string;
61
+ endDate: string;
62
+ }
63
+ export type FilterFormRowState = StringFilterState | NumberFormFilterState | DateFormFilterState;
64
+ export type FilterFormState = Record<string, FilterFormRowState>;
@@ -0,0 +1,30 @@
1
+ export var stringFilterSchemes = [
2
+ "contains",
3
+ "startsWith",
4
+ "endsWith",
5
+ ];
6
+ export var stringFilterSchemeNames = {
7
+ contains: "Contains",
8
+ startsWith: "Starts With",
9
+ endsWith: "Ends With",
10
+ };
11
+ export var numberFilterSchemes = [
12
+ "equals",
13
+ "greaterThan",
14
+ "lessThan",
15
+ "greaterOrEqual",
16
+ "lessOrEqual",
17
+ ];
18
+ export var numberFilterSchemeNames = {
19
+ equals: "=",
20
+ greaterThan: ">",
21
+ lessThan: "<",
22
+ greaterOrEqual: ">=",
23
+ lessOrEqual: "<=",
24
+ };
25
+ export var dateFilterSchemes = ["startFrom", "endAt", "between"];
26
+ export var dateFilterSchemeNames = {
27
+ startFrom: "Start Form",
28
+ endAt: "End At",
29
+ between: "Between",
30
+ };
@@ -1,4 +1,3 @@
1
- import { TableFilterState } from "../types";
2
- import { FilterFormState } from "./types";
1
+ import { FilterFormState, TableFilterState } from "./types";
3
2
  declare const useFormStateFromTableFilterState: (tableFilterState: TableFilterState) => FilterFormState;
4
3
  export default useFormStateFromTableFilterState;
package/index.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  export * from "./types";
2
+ export * from "./styling/types";
3
+ export * from "./editing/types";
4
+ export * from "./selection/types";
5
+ export * from "./filtering/types";
6
+ export * from "./sorting/types";
7
+ export * from "./pagination/types";
2
8
  export * from "./Grid";
3
- export * from "./pagination/PageSelector";
4
9
  export { default } from "./Grid";
package/index.js CHANGED
@@ -1,4 +1,9 @@
1
1
  export * from "./types";
2
+ export * from "./styling/types";
3
+ export * from "./editing/types";
4
+ export * from "./selection/types";
5
+ export * from "./filtering/types";
6
+ export * from "./sorting/types";
7
+ export * from "./pagination/types";
2
8
  export * from "./Grid";
3
- export * from "./pagination/PageSelector";
4
9
  export { default } from "./Grid";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@absreim/react-bootstrap-data-grid",
3
3
  "description": "Data grid UI component for use with web apps using React and Bootstrap",
4
- "version": "1.2.2",
4
+ "version": "1.4.0",
5
5
  "license": "MIT",
6
6
  "author": "Brook Li",
7
7
  "homepage": "https://react-bootstrap-data-grid.vercel.app/",
@@ -11,7 +11,8 @@
11
11
  "bootstrap",
12
12
  "data",
13
13
  "table",
14
- "grid"
14
+ "grid",
15
+ "datagrid"
15
16
  ],
16
17
  "dependencies": {
17
18
  "classnames": "^2.5.1",
@@ -1,6 +1,6 @@
1
1
  import { JustifyContentSetting, Size } from "../types";
2
2
  import { FC } from "react";
3
- export interface PaginationProps {
3
+ export interface PageSelectorProps {
4
4
  numPages: number;
5
5
  pageNum: number;
6
6
  numButtons: number;
@@ -20,5 +20,5 @@ export interface PaginationProps {
20
20
  * @param alignment - Flexbox justify-content setting on the <ul> element
21
21
  * @param size - Size variant of the <ul> element
22
22
  */
23
- declare const PageSelector: FC<PaginationProps>;
23
+ declare const PageSelector: FC<PageSelectorProps>;
24
24
  export default PageSelector;
@@ -1,5 +1,5 @@
1
1
  import { FC } from "react";
2
- import { Size } from "../types";
2
+ import { JustifyContentSetting, Size } from "../types";
3
3
  export interface PaginationProps {
4
4
  componentSize: Size;
5
5
  pageSizeOptions: number[];
@@ -9,6 +9,8 @@ export interface PaginationProps {
9
9
  prePagingNumRows: number;
10
10
  maxPageButtons: number;
11
11
  currentPage: number;
12
+ pageSelectorAriaLabel?: string;
13
+ pageSelectorJustifyContent?: JustifyContentSetting;
12
14
  }
13
15
  declare const Pagination: FC<PaginationProps>;
14
16
  export default Pagination;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import PageSizeSelector from "./PageSizeSelector";
3
3
  import PageSelector from "./PageSelector";
4
4
  var Pagination = function (_a) {
5
- var componentSize = _a.componentSize, pageSizeOptions = _a.pageSizeOptions, pageSizeIndex = _a.pageSizeIndex, handleSetPageSizeIndex = _a.handleSetPageSizeIndex, handleSetPageNum = _a.handleSetPageNum, prePagingNumRows = _a.prePagingNumRows, maxPageButtons = _a.maxPageButtons, currentPage = _a.currentPage;
5
+ var componentSize = _a.componentSize, pageSizeOptions = _a.pageSizeOptions, pageSizeIndex = _a.pageSizeIndex, handleSetPageSizeIndex = _a.handleSetPageSizeIndex, handleSetPageNum = _a.handleSetPageNum, prePagingNumRows = _a.prePagingNumRows, maxPageButtons = _a.maxPageButtons, currentPage = _a.currentPage, pageSelectorAriaLabel = _a.pageSelectorAriaLabel, pageSelectorJustifyContent = _a.pageSelectorJustifyContent;
6
6
  var numPages = Math.ceil(prePagingNumRows / pageSizeOptions[pageSizeIndex]);
7
7
  var pageIndexAwarePageSizeSetter = function (newPageSizeIndex) {
8
8
  var newPageSize = pageSizeOptions[newPageSizeIndex];
@@ -15,6 +15,6 @@ var Pagination = function (_a) {
15
15
  handleSetPageNum(maxPages);
16
16
  }
17
17
  };
18
- return (_jsxs("div", { className: "d-flex justify-content-end gap-2", children: [_jsx(PageSizeSelector, { componentSize: componentSize, pageSizeOptions: pageSizeOptions, pageSizeIndex: pageSizeIndex, handleSetPageSize: pageIndexAwarePageSizeSetter }), _jsx(PageSelector, { numPages: numPages, pageNum: currentPage, numButtons: maxPageButtons, setPageNum: handleSetPageNum, size: componentSize })] }));
18
+ return (_jsxs("div", { className: "d-flex justify-content-end gap-2", children: [_jsx(PageSizeSelector, { componentSize: componentSize, pageSizeOptions: pageSizeOptions, pageSizeIndex: pageSizeIndex, handleSetPageSize: pageIndexAwarePageSizeSetter }), _jsx(PageSelector, { numPages: numPages, pageNum: currentPage, numButtons: maxPageButtons, setPageNum: handleSetPageNum, size: componentSize, ariaLabel: pageSelectorAriaLabel, alignment: pageSelectorJustifyContent })] }));
19
19
  };
20
20
  export default Pagination;
@@ -0,0 +1,12 @@
1
+ import { JustifyContentSetting, Size } from "../types";
2
+ export interface GridPaginationState {
3
+ pageSizeOptions: number[];
4
+ pageSizeIndex: number;
5
+ setPageSizeIndex: (pageSizeIndex: number) => void;
6
+ currentPage: number;
7
+ setCurrentPage: (pageNum: number) => void;
8
+ maxPageButtons: number;
9
+ componentSize?: Size;
10
+ pageSelectorAriaLabel?: string;
11
+ pageSelectorJustifyContent?: JustifyContentSetting;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { AugRowDef } from "../types";
2
+ import { GridPaginationState } from "../pagination/types";
3
+ declare const useCurrentPageRows: (sortedRows: AugRowDef[], pagination: GridPaginationState | undefined) => AugRowDef[];
4
+ export default useCurrentPageRows;
@@ -0,0 +1,14 @@
1
+ import { useMemo } from "react";
2
+ var useCurrentPageRows = function (sortedRows, pagination) {
3
+ return useMemo(function () {
4
+ if (pagination === undefined) {
5
+ return sortedRows;
6
+ }
7
+ var pageSizeOptions = pagination.pageSizeOptions, pageSizeIndex = pagination.pageSizeIndex, currentPage = pagination.currentPage;
8
+ var pageSize = pageSizeOptions[pageSizeIndex];
9
+ var lowerIndex = pageSize * (currentPage - 1);
10
+ var upperIndex = lowerIndex + pageSize;
11
+ return sortedRows.slice(lowerIndex, upperIndex);
12
+ }, [sortedRows, pagination]);
13
+ };
14
+ export default useCurrentPageRows;
@@ -1,3 +1,3 @@
1
1
  import { AugRowDef, FormattedRow, ColDef } from "../types";
2
- declare const useDisplayRows: (currentPageRows: AugRowDef[], cols: ColDef[]) => FormattedRow[];
2
+ declare const useDisplayRows: (currentPageRows: AugRowDef[], cols: ColDef[], ariaColIndexOffset: number) => FormattedRow[];
3
3
  export default useDisplayRows;
@@ -1,5 +1,20 @@
1
1
  import { useMemo } from "react";
2
- var useDisplayRows = function (currentPageRows, cols) {
2
+ var getFormattedValue = function (value, formatter, typeString) {
3
+ if (formatter) {
4
+ return formatter(value);
5
+ }
6
+ if (typeString === "date") {
7
+ return value.toDateString();
8
+ }
9
+ if (typeString === "datetime") {
10
+ return value.toLocaleString();
11
+ }
12
+ if (typeString === "number") {
13
+ return value.toLocaleString();
14
+ }
15
+ return value;
16
+ };
17
+ var useDisplayRows = function (currentPageRows, cols, ariaColIndexOffset) {
3
18
  return useMemo(function () {
4
19
  var nameToIndex = new Map();
5
20
  cols.forEach(function (_a, index) {
@@ -24,29 +39,21 @@ var useDisplayRows = function (currentPageRows, cols) {
24
39
  return;
25
40
  }
26
41
  var index = nameToIndex.get(name);
27
- var formatter = cols[index].formatter;
28
- var typeString = cols[index].type;
42
+ var col = cols[index];
43
+ var formatter = col.formatter;
44
+ var typeString = col.type;
29
45
  var value = row.data[name];
30
- if (formatter) {
31
- displayRow[index] = formatter(value);
32
- return;
33
- }
34
- if (typeString === "date") {
35
- displayRow[index] = value.toDateString();
36
- return;
37
- }
38
- if (typeString === "datetime") {
39
- displayRow[index] = value.toLocaleString();
40
- return;
41
- }
42
- if (typeString === "number") {
43
- displayRow[index] = value.toLocaleString();
44
- return;
45
- }
46
- displayRow[index] = value;
46
+ displayRow[index] = {
47
+ fieldName: cols[index].name,
48
+ value: value,
49
+ type: typeString,
50
+ ariaColIndex: index + 1 + ariaColIndexOffset,
51
+ formattedValue: getFormattedValue(value, formatter, typeString),
52
+ label: cols[index].label,
53
+ };
47
54
  });
48
55
  return { contents: displayRow, origIndex: row.meta.origIndex };
49
56
  });
50
- }, [currentPageRows, cols]);
57
+ }, [currentPageRows, cols, ariaColIndexOffset]);
51
58
  };
52
59
  export default useDisplayRows;
@@ -1,3 +1,3 @@
1
- import { EditableTableFilterState, TableFilterState } from "../types";
1
+ import { EditableTableFilterState, TableFilterState } from "../filtering/types";
2
2
  declare const useEditableFromFilterState: (filterState: TableFilterState | null) => EditableTableFilterState | null;
3
3
  export default useEditableFromFilterState;
@@ -1,3 +1,4 @@
1
- import { AugRowDef, EditableTableFilterState } from "../types";
1
+ import { AugRowDef } from "../types";
2
+ import { EditableTableFilterState } from "../filtering/types";
2
3
  declare const useFilter: (rows: AugRowDef[], filterState: EditableTableFilterState | null) => AugRowDef[];
3
4
  export default useFilter;
@@ -1,3 +1,4 @@
1
- import { ColDef, EditableTableFilterState, TableFilterState } from "../types";
1
+ import { ColDef } from "../types";
2
+ import { EditableTableFilterState, TableFilterState } from "../filtering/types";
2
3
  declare const useFilterStateFromEditable: (colDefs: ColDef[], editableFilterState: EditableTableFilterState | null) => TableFilterState | null;
3
4
  export default useFilterStateFromEditable;
@@ -1,3 +1,4 @@
1
- import { AugRowDef, ColDef, TableSortModel } from "../types";
1
+ import { AugRowDef, ColDef } from "../types";
2
+ import { TableSortModel } from "../sorting/types";
2
3
  declare const useSortedRows: (rows: AugRowDef[], cols: ColDef[], sortModel: TableSortModel | undefined) => AugRowDef[];
3
4
  export default useSortedRows;
@@ -1,9 +1,10 @@
1
- import { SelectType } from "../types";
2
1
  import { FC } from "react";
2
+ import { SelectType } from "./types";
3
3
  interface SelectAllHeaderCellProps {
4
4
  onClick: () => void;
5
5
  selectType: SelectType;
6
6
  selectionExists: boolean;
7
+ additionalClasses?: string[];
7
8
  }
8
9
  declare const SelectAllHeaderCell: FC<SelectAllHeaderCellProps>;
9
10
  export default SelectAllHeaderCell;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import deselectAll from "../icons/deselectAll";
3
- import selectAll from "../icons/selectAll";
4
- import arrowPlaceholder from "../icons/arrowPlaceholder";
2
+ import deselectAll from "./deselectAll";
3
+ import selectAll from "./selectAll";
4
+ import arrowPlaceholder from "../sorting/arrowPlaceholder";
5
5
  import classNames from "classnames";
6
6
  // It seems like React does not support setting indeterminate states on
7
7
  // checkboxes in a controlled manner, which caused me to not want to refactor
@@ -31,11 +31,12 @@ var getCellAriaDescription = function (selectMode, existingSelection) {
31
31
  return "Selection input header cell";
32
32
  };
33
33
  var SelectAllHeaderCell = function (_a) {
34
- var onClick = _a.onClick, selectType = _a.selectType, selectionExists = _a.selectionExists;
34
+ var onClick = _a.onClick, selectType = _a.selectType, selectionExists = _a.selectionExists, additionalClasses = _a.additionalClasses;
35
35
  var disabled = selectType === "single" && !selectionExists;
36
36
  var description = getCellAriaDescription(selectType, selectionExists);
37
- return (_jsx("th", { "aria-colindex": 1, title: description, "aria-description": description, className: classNames("rbdg-select-header-cell", "btn-primary", {
37
+ return (_jsx("th", { "aria-colindex": 1, title: description, "aria-description": description, className: classNames("rbdg-select-header-cell", {
38
+ "btn-primary": !additionalClasses || additionalClasses.length === 0,
38
39
  "rbdg-clickable-grid-header-cell": !disabled,
39
- }), onClick: onClick, children: getSelectIcon(selectType, selectionExists) }));
40
+ }, additionalClasses || []), onClick: onClick, children: getSelectIcon(selectType, selectionExists) }));
40
41
  };
41
42
  export default SelectAllHeaderCell;
@@ -13,6 +13,7 @@ export interface SelectionInputProps {
13
13
  selected: boolean;
14
14
  selectionInputModel: SelectionInputModel;
15
15
  selectCallback: () => void;
16
+ additionalClasses?: string[];
16
17
  }
17
18
  declare const SelectionInput: FC<SelectionInputProps>;
18
19
  export default SelectionInput;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import classNames from "classnames";
2
3
  var SelectionInput = function (_a) {
3
- var selectionInputModel = _a.selectionInputModel, selected = _a.selected, selectCallback = _a.selectCallback;
4
+ var selectionInputModel = _a.selectionInputModel, selected = _a.selected, selectCallback = _a.selectCallback, additionalClasses = _a.additionalClasses;
4
5
  var type = selectionInputModel.type;
5
6
  var onChange = function (_a) {
6
7
  var checked = _a.target.checked;
@@ -15,7 +16,7 @@ var SelectionInput = function (_a) {
15
16
  selectCallback();
16
17
  }
17
18
  };
18
- return (_jsx("input", { "aria-description": "input to select the current row", onClick: function (event) {
19
+ return (_jsx("input", { className: classNames(additionalClasses || []), "aria-label": "Input to select the current row", onClick: function (event) {
19
20
  event.stopPropagation();
20
21
  }, type: type, checked: selected, onChange: onChange, name: selectionInputModel.name }));
21
22
  };
@@ -0,0 +1,16 @@
1
+ export type SelectMode = "column" | "row" | "both";
2
+ export type SelectType = "single" | "multi";
3
+ export interface MultiSelectModel {
4
+ mode: SelectMode;
5
+ type: "multi";
6
+ selected: number[];
7
+ setSelected: (selected: number[]) => void;
8
+ }
9
+ export interface SingleSelectModel {
10
+ mode: SelectMode;
11
+ type: "single";
12
+ selected: number | null;
13
+ setSelected: (selected: number | null) => void;
14
+ groupName: string;
15
+ }
16
+ export type SelectModel = SingleSelectModel | MultiSelectModel;
@@ -0,0 +1,4 @@
1
+ // Selected indices are based on the original index of the input rows. If
2
+ // filtered-out items are included in the 'selected' property, there will be a
3
+ // visual indication to the user of that fact.
4
+ export {};
@@ -0,0 +1,13 @@
1
+ export type SortOrder = "asc" | "desc";
2
+ export interface SortColDef {
3
+ name: string;
4
+ order: SortOrder;
5
+ }
6
+ export interface ColSortModel {
7
+ sortOrder: SortOrder | null;
8
+ setSortOrder: (order: SortOrder | null) => void;
9
+ }
10
+ export interface TableSortModel {
11
+ sortColDef: SortColDef | null;
12
+ setSortColDef: (sortColDef: SortColDef | null) => void;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
package/style.scss CHANGED
@@ -4,18 +4,18 @@
4
4
 
5
5
  .rbdg-select-header-cell {
6
6
  .rdbg-svg-icon {
7
- background-color: var(--bs-btn-bg)
7
+ background-color: var(--bs-btn-bg);
8
8
  }
9
9
  .rdbg-svg-icon-foreground {
10
- color: var(--bs-btn-color)
10
+ color: var(--bs-btn-color);
11
11
  }
12
12
 
13
13
  &:hover {
14
14
  .rdbg-svg-icon {
15
- background-color: var(--bs-btn-hover-bg)
15
+ background-color: var(--bs-btn-hover-bg);
16
16
  }
17
17
  .rdbg-svg-icon-foreground {
18
- color: var(--bs-btn-hover-color)
18
+ color: var(--bs-btn-hover-color);
19
19
  }
20
20
  }
21
21
  }
@@ -0,0 +1,4 @@
1
+ import { AdditionalComponentsStyleModel, FilterInputTableStyleModel, TableStyleModel } from "./types";
2
+ export declare const unwrapTableStyleModel: (tableStyleModel: TableStyleModel | undefined) => Required<TableStyleModel>;
3
+ export declare const unwrapFilterInputTableStyleModel: (filterTableStyleModel: FilterInputTableStyleModel | undefined) => Required<FilterInputTableStyleModel>;
4
+ export declare const unwrapAdditionalComponentsStyleModel: (styleModel: AdditionalComponentsStyleModel | undefined) => Required<AdditionalComponentsStyleModel>;