@absreim/react-bootstrap-data-grid 4.1.0 → 4.3.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 (112) hide show
  1. package/common/constants.d.ts +2 -0
  2. package/common/constants.js +2 -0
  3. package/common/editing/types.d.ts +30 -0
  4. package/common/export/types.d.ts +6 -0
  5. package/common/export/useExportFn.js +1 -1
  6. package/common/filtering/DateFilterRow.d.ts +1 -1
  7. package/common/filtering/DateFilterRow.js +1 -1
  8. package/common/filtering/FilterOptionsTable.d.ts +3 -2
  9. package/common/filtering/NumberFilterRow.d.ts +1 -1
  10. package/common/filtering/NumberFilterRow.js +1 -1
  11. package/common/filtering/StringFilterRow.js +1 -1
  12. package/common/filtering/constants.d.ts +19 -0
  13. package/common/filtering/constants.js +44 -0
  14. package/common/filtering/internalTypes.d.ts +77 -0
  15. package/common/filtering/types.d.ts +165 -22
  16. package/common/filtering/types.js +46 -17
  17. package/common/filtering/useFilterFormState.d.ts +1 -1
  18. package/common/icons/CaretDownFill.d.ts +4 -0
  19. package/common/icons/CaretDownFill.js +6 -0
  20. package/common/icons/CaretUp.d.ts +4 -0
  21. package/common/icons/CaretUp.js +6 -0
  22. package/common/icons/CaretUpFill.d.ts +4 -0
  23. package/common/icons/CaretUpFill.js +6 -0
  24. package/common/icons/internalTypes.d.ts +3 -0
  25. package/common/index.d.ts +0 -3
  26. package/common/index.js +0 -3
  27. package/common/internalTypes.d.ts +10 -0
  28. package/common/internalTypes.js +1 -0
  29. package/common/pagination/Pagination.d.ts +1 -1
  30. package/common/pagination/internalTypes.d.ts +8 -0
  31. package/common/pagination/internalTypes.js +1 -0
  32. package/common/pagination/types.d.ts +105 -5
  33. package/common/pipeline/{types.d.ts → internalTypes.d.ts} +5 -0
  34. package/common/pipeline/internalTypes.js +1 -0
  35. package/common/pipeline/useAugFormattedRows.d.ts +3 -2
  36. package/common/pipeline/useColNameToWidth.d.ts +2 -1
  37. package/common/pipeline/useCombinedPipeline/index.d.ts +4 -3
  38. package/common/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +2 -1
  39. package/common/pipeline/useCombinedPipeline/useCurrentPageRows.js +3 -2
  40. package/common/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +2 -1
  41. package/common/pipeline/useCombinedPipeline/useFilterStateStore.d.ts +2 -1
  42. package/common/pipeline/useGridSelectionFns.d.ts +2 -1
  43. package/common/selection/internalTypes.d.ts +34 -0
  44. package/common/selection/internalTypes.js +1 -0
  45. package/common/selection/types.d.ts +91 -17
  46. package/common/selection/types.js +0 -3
  47. package/common/sorting/ArrowPlaceholder.d.ts +3 -0
  48. package/common/sorting/ArrowPlaceholder.js +3 -0
  49. package/common/sorting/DownArrow.d.ts +6 -0
  50. package/common/sorting/DownArrow.js +6 -0
  51. package/common/sorting/UpArrow.d.ts +6 -0
  52. package/common/sorting/UpArrow.js +6 -0
  53. package/common/sorting/internalTypes.d.ts +10 -0
  54. package/common/sorting/internalTypes.js +1 -0
  55. package/common/sorting/types.d.ts +48 -4
  56. package/common/sorting/useSortHeaderStates.d.ts +1 -1
  57. package/common/sorting/useSortHeaderStates.js +8 -7
  58. package/common/styling/types.d.ts +57 -0
  59. package/common/toolbar/Toolbar.d.ts +1 -1
  60. package/common/toolbar/ToolbarContainer.d.ts +1 -1
  61. package/common/toolbar/{types.d.ts → internalTypes.d.ts} +27 -0
  62. package/common/toolbar/internalTypes.js +1 -0
  63. package/common/toolbar/useInterfaces.d.ts +1 -1
  64. package/common/types.d.ts +169 -16
  65. package/common/util/datetime.d.ts +17 -0
  66. package/common/util/datetime.js +17 -0
  67. package/common/util/getWidthStyle.d.ts +9 -0
  68. package/common/util/getWidthStyle.js +9 -0
  69. package/common/util/index.d.ts +0 -4
  70. package/common/util/index.js +0 -4
  71. package/common/util/isSubset.d.ts +12 -1
  72. package/common/util/isSubset.js +13 -2
  73. package/common/util/useControlledHover.d.ts +5 -0
  74. package/common/util/useControlledHover.js +5 -0
  75. package/grid/focus/types.d.ts +11 -0
  76. package/grid/focus/useGridFocus.d.ts +1 -1
  77. package/grid/focus/useGridFocus.js +20 -5
  78. package/grid/main/Grid.d.ts +5 -0
  79. package/grid/main/Grid.js +14 -7
  80. package/grid/main/GridBody.d.ts +1 -1
  81. package/grid/main/GridHeader.d.ts +1 -1
  82. package/grid/main/GridHeader.js +29 -2
  83. package/grid/main/internalTypes.d.ts +31 -0
  84. package/grid/main/internalTypes.js +1 -0
  85. package/grid/main/types.d.ts +120 -19
  86. package/grid/sort/HeaderToggleButton.d.ts +11 -0
  87. package/grid/sort/HeaderToggleButton.js +30 -0
  88. package/grid.css +1 -1
  89. package/grid.scss +95 -33
  90. package/package.json +5 -5
  91. package/table/InternalTable.d.ts +1 -1
  92. package/table/Table.d.ts +5 -1
  93. package/table/Table.js +5 -0
  94. package/table/editing/EditableRow.d.ts +1 -1
  95. package/table/editing/EditableRow.js +1 -1
  96. package/table/internalTypes.d.ts +23 -0
  97. package/table/internalTypes.js +1 -0
  98. package/table/main/BodyRows.d.ts +4 -3
  99. package/table/main/ColHeaderCell/index.d.ts +1 -1
  100. package/table/selection/SelectAllHeaderCell.d.ts +1 -1
  101. package/table/styling/types.d.ts +122 -5
  102. package/table/types.d.ts +57 -15
  103. package/common/sorting/arrowPlaceholder.d.ts +0 -2
  104. package/common/sorting/arrowPlaceholder.js +0 -7
  105. package/common/sorting/downArrow.d.ts +0 -2
  106. package/common/sorting/downArrow.js +0 -3
  107. package/common/sorting/upArrow.d.ts +0 -2
  108. package/common/sorting/upArrow.js +0 -13
  109. package/common/util/trueModulo.d.ts +0 -2
  110. package/common/util/trueModulo.js +0 -4
  111. /package/common/{pipeline/types.js → filtering/internalTypes.js} +0 -0
  112. /package/common/{toolbar/types.js → icons/internalTypes.js} +0 -0
@@ -1,21 +1,78 @@
1
1
  import { AdditionalComponentsStyleModel, FilterInputTableStyleModel, TableStyleModel } from "../../table";
2
+ /**
3
+ * CSS styles for the toolbar.
4
+ *
5
+ * @public
6
+ */
2
7
  export interface ToolbarStyleModel {
8
+ /**
9
+ * Styles for the button of the currently selected tool.
10
+ */
3
11
  activeButton?: string[];
12
+ /**
13
+ * Styles for the buttons of tools that are not currently selected.
14
+ */
4
15
  inactiveButton?: string[];
16
+ /**
17
+ * Styles for the div element that contains the other elements of the toolbar.
18
+ */
5
19
  toolbar?: string[];
20
+ /**
21
+ * Styles for the div element that contains the interface for each tool.
22
+ */
6
23
  interfaceContainer?: string[];
7
24
  }
25
+ /**
26
+ * CSS styles for the UI for exporting data.
27
+ *
28
+ * @public
29
+ */
8
30
  export interface ExportFormStyleModel {
31
+ /**
32
+ * Styles for fieldset legend elements.
33
+ */
9
34
  legend?: string[];
35
+ /**
36
+ * Styles for the div elements that contain radio buttons.
37
+ */
10
38
  radioContainer?: string[];
39
+ /**
40
+ * Styles for the radio button input elements.
41
+ */
11
42
  radioInput?: string[];
43
+ /**
44
+ * Styles for the label elements for radio button input elements.
45
+ */
12
46
  radioLabel?: string[];
47
+ /**
48
+ * Styles for the submit button.
49
+ */
13
50
  submitButton?: string[];
14
51
  }
52
+ /**
53
+ * Top level object that is passed as a prop to a table to enable custom styles.
54
+ *
55
+ * @public
56
+ */
15
57
  export interface StyleModel {
58
+ /**
59
+ * Styles for the main table (as opposed to the filter options table).
60
+ */
16
61
  mainTableStyleModel?: TableStyleModel;
62
+ /**
63
+ * Styles for the filter options table.
64
+ */
17
65
  filterInputTableStyleModel?: FilterInputTableStyleModel;
66
+ /**
67
+ * Styles for components that don't fit into other categories.
68
+ */
18
69
  additionalComponentsStyleModel?: AdditionalComponentsStyleModel;
70
+ /**
71
+ * Styles for the toolbar.
72
+ */
19
73
  toolbarStyleModel?: ToolbarStyleModel;
74
+ /**
75
+ * Styles for the data export UI.
76
+ */
20
77
  exportFormStyleModel?: ExportFormStyleModel;
21
78
  }
@@ -1,4 +1,4 @@
1
- import { ToolbarOption } from "./types";
1
+ import { ToolbarOption } from "./internalTypes";
2
2
  import { FC } from "react";
3
3
  export interface ToolbarProps {
4
4
  enabledFeatures: Partial<Record<ToolbarOption, boolean>>;
@@ -1,4 +1,4 @@
1
- import { InterfaceNodeGenerator } from "./types";
1
+ import { InterfaceNodeGenerator } from "./internalTypes";
2
2
  import { FC } from "react";
3
3
  import { ToolbarStyleModel } from "../styling/types";
4
4
  interface ToolbarContainerProps {
@@ -1,11 +1,38 @@
1
1
  import { ReactNode } from "react";
2
2
  import { FilterOptionsTableProps } from "../filtering/FilterOptionsTable";
3
3
  import { ExportFormProps } from "../export/ExportForm";
4
+ /**
5
+ * Strings representing different tools on the toolbar.
6
+ *
7
+ * @internal
8
+ */
4
9
  export type ToolbarOption = "filtering" | "exporting";
10
+ /**
11
+ * A mapping React elements for different toolbar tools.
12
+ *
13
+ * @internal
14
+ */
5
15
  export type ToolbarInterfaces = Partial<Record<ToolbarOption, ReactNode>>;
16
+ /**
17
+ * Props to pass to the components that implement different tools.
18
+ *
19
+ * @internal
20
+ */
6
21
  export interface InterfaceParams {
7
22
  filtering?: FilterOptionsTableProps;
8
23
  exporting?: ExportFormProps;
9
24
  }
25
+ /**
26
+ * Defines props for toolbar tool UI React components while allowing the
27
+ * callback to close the tool UI to be supplied later.
28
+ *
29
+ * @internal
30
+ */
10
31
  export type InterfacePropGenerator = (closeUiCallback: () => void) => InterfaceParams;
32
+ /**
33
+ * Defines toolbar tool UI React elements while allowing the callback
34
+ * to close the tool UI to be supplied later.
35
+ *
36
+ * @internal
37
+ */
11
38
  export type InterfaceNodeGenerator = (closeUiCallback: () => void) => ToolbarInterfaces;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,3 @@
1
- import { InterfacePropGenerator, ToolbarInterfaces } from "./types";
1
+ import { InterfacePropGenerator, ToolbarInterfaces } from "./internalTypes";
2
2
  declare const useInterfaces: (gen: InterfacePropGenerator) => (closeCallback: () => void) => ToolbarInterfaces;
3
3
  export default useInterfaces;
package/common/types.d.ts CHANGED
@@ -1,57 +1,210 @@
1
- import { EditModel } from "./editing/types";
2
- import { PaginationModel } from "./pagination/types";
3
1
  import { SortModel } from "./sorting/types";
4
- import { FilterModel } from "./filtering/types";
5
- import { SelectModel } from "./selection/types";
6
- import { StyleModel } from "./styling/types";
2
+ /**
3
+ * Union of all possible column data types.
4
+ *
5
+ * @public
6
+ */
7
7
  export type ColDataType = string | number | Date;
8
+ /**
9
+ * Union of strings that describe the type of a column.
10
+ *
11
+ * @public
12
+ */
8
13
  export type ColDataTypeStrings = "string" | "number" | "date" | "datetime";
14
+ /**
15
+ * Properties to a define a column that is shared between community and pro
16
+ * editions.
17
+ *
18
+ * @typeParam ValueType - the type of the value of the column (e.g. string,
19
+ * number, or Date)
20
+ *
21
+ * @public
22
+ */
9
23
  export interface ColDefBase<ValueType = any> {
24
+ /**
25
+ * String that specifies the data type of the column.
26
+ */
10
27
  type: ColDataTypeStrings;
28
+ /**
29
+ * The name of the property for the column in the {@link RowDef} object.
30
+ */
11
31
  name: string;
32
+ /**
33
+ * The display name of the property in places like the column heading.
34
+ */
12
35
  label: string;
36
+ /**
37
+ * The formatter function for the column.
38
+ */
13
39
  formatter?: (value: ValueType) => string;
40
+ /**
41
+ * Specifies whether the column is sortable.
42
+ *
43
+ * @defaultValue false
44
+ */
14
45
  sortable?: boolean;
15
46
  }
16
- export type ColDef<ValueType = any> = ColDefBase<ValueType> & {
47
+ /**
48
+ * Column definition properties specific to the community edition of the table
49
+ * and grid.
50
+ *
51
+ * @public
52
+ */
53
+ export interface CommunitySpecificColProps {
54
+ /**
55
+ * Sets the min-width and max-width CSS properties for all cells of the
56
+ * column.
57
+ *
58
+ * For the table, if no value is specified, then no value for min-width
59
+ * or max-width will be set.
60
+ *
61
+ * @defaultValue - 100 for the grid, undefined for the table
62
+ */
17
63
  width?: number;
18
- };
64
+ }
65
+ /**
66
+ * Column definition object for the community edition of the table and grid.
67
+ *
68
+ * @typeParam ValueType - the type of the value of the column (e.g. string,
69
+ * number, or Date)
70
+ *
71
+ * @public
72
+ */
73
+ export type ColDef<ValueType = any> = ColDefBase<ValueType> & CommunitySpecificColProps;
74
+ /**
75
+ * Type alias for "data" property of the {@link RowDef} interface. This type
76
+ * alias represents the most general type possible. One can specify a more
77
+ * specific type via the Data type parameter.
78
+ *
79
+ * @public
80
+ */
19
81
  export type ValidRowData = Record<string, any>;
82
+ /**
83
+ * The data fields for a row in a table or grid. Excludes the primary key for
84
+ * the row, which is stored separately in the "id" field of the {@link RowDef}
85
+ * interface.
86
+ *
87
+ * @typeParam Data - the type of the object. A more specific type can be
88
+ * specified in place of the default {@link ValidRowData} type to assist in
89
+ * type safety and IDE coding assistance.
90
+ *
91
+ * @public
92
+ */
20
93
  export type RowData<Data extends ValidRowData = ValidRowData> = Data;
94
+ /**
95
+ * A union of the possible values for an id of a {@link RowDef} object.
96
+ *
97
+ * @public
98
+ */
21
99
  export type RowId = string | number;
100
+ /**
101
+ * An object that represents a single row.
102
+ *
103
+ * @typeParam Data - the type of the "data" property. Can be specified to
104
+ * enhance type safety.
105
+ *
106
+ * @public
107
+ */
22
108
  export interface RowDef<Data extends ValidRowData = ValidRowData> {
109
+ /**
110
+ * An id for the row that must be unique among all rows passed in the "rows"
111
+ * prop of the {@link Table} or {@link Grid}.
112
+ */
23
113
  id: RowId;
114
+ /**
115
+ * Contains all data fields for different columns of the row.
116
+ */
24
117
  data: RowData<Data>;
25
118
  }
119
+ /**
120
+ * Interface that contains parameters shared between the {@link Table},
121
+ * {@link TablePro}, and {@link Grid} components.
122
+ *
123
+ * @public
124
+ */
26
125
  export interface MainComponentSharedProps {
126
+ /**
127
+ * The rows of data to be displayed by the table or grid.
128
+ */
27
129
  rows: RowDef[];
130
+ /**
131
+ * The column definitions of the table or grid.
132
+ */
28
133
  cols: ColDef[];
29
- pagination?: PaginationModel;
134
+ /**
135
+ * The sort model of the table or grid. Passing a truthy value enables the
136
+ * sorting feature of the component.
137
+ */
30
138
  sortModel?: SortModel;
31
- filterModel?: FilterModel;
32
- selectModel?: SelectModel;
33
- editModel?: EditModel;
34
- styleModel?: StyleModel;
35
- allowExport?: boolean;
36
139
  }
140
+ /**
141
+ * {@link RowDef} object that additionally contains the index of the row in the
142
+ * original array.
143
+ *
144
+ * @typeParam Data - type of the data property of the {@link RowDef} object
145
+ *
146
+ * @public
147
+ */
37
148
  export type AugRowDef<Data extends ValidRowData = ValidRowData> = RowDef<Data> & {
38
149
  origIndex: number;
39
150
  };
151
+ /**
152
+ * Row definition object that additionally contains index of the row before
153
+ * pagination was applied.
154
+ *
155
+ * @public
156
+ */
40
157
  export type PostPaginationRowDef<Data extends ValidRowData = ValidRowData> = AugRowDef<Data> & {
41
158
  prePaginationIndex: number;
42
159
  };
160
+ /**
161
+ * Object that describes the contents for a single table or grid cell along
162
+ * with various metadata.
163
+ *
164
+ * @public
165
+ */
43
166
  export interface CellData {
167
+ /**
168
+ * The name of the property in the {@link RowDef} "data" property that
169
+ * contains the value for the cell.
170
+ */
44
171
  fieldName: string;
172
+ /**
173
+ * The raw, unformatted, value of the cell.
174
+ */
45
175
  value: ColDataType;
176
+ /**
177
+ * A string that specifies of the value type of the column for the cell.
178
+ * Same as the "type" property in corresponding {@link ColDef} object.
179
+ */
46
180
  type: ColDataTypeStrings;
181
+ /**
182
+ * The ARIA column index of the column that contains the cell.
183
+ */
47
184
  ariaColIndex: number;
185
+ /**
186
+ * The value of the cell after the column's formatter function is applied.
187
+ */
48
188
  formattedValue: string;
189
+ /**
190
+ * The label of the column that the cell is in. Same as the property of the
191
+ * same name in the corresponding {@link ColDef} object.
192
+ */
49
193
  label: string;
194
+ /**
195
+ * The width of the column that the cell is in. Same as the property of the
196
+ * same name in the corresponding {@link ColDef} object.
197
+ */
50
198
  width?: number;
51
199
  }
200
+ /**
201
+ * Comprehensive information for an entire row of a table or grid, after
202
+ * postprocessing such as sorting, pagination, and filtering are applied.
203
+ *
204
+ * Contains an array of {@link CellData} in the order that the columns appear.
205
+ *
206
+ * @public
207
+ */
52
208
  export type FormattedRow = {
53
209
  contents: Omit<CellData, "width">[];
54
210
  } & Omit<PostPaginationRowDef, "data">;
55
- export type AugFormattedRow = {
56
- contents: CellData[];
57
- } & Omit<PostPaginationRowDef, "data">;
@@ -1,2 +1,19 @@
1
+ /**
2
+ * Returns a string that represents a date in the format used by the input
3
+ * element of type "date".
4
+ *
5
+ * @param date - the Date object to format
6
+ * @returns a string in the format YYYY-MM-DD
7
+ *
8
+ * @public
9
+ */
1
10
  export declare const dateToInputStr: (date: Date) => string;
11
+ /**
12
+ * Returns of string representation of datetime from a Date object.
13
+ *
14
+ * @param date - the Date object to format
15
+ * @returns a string in the format YYYY-MM-DDTHH:mm
16
+ *
17
+ * @public
18
+ */
2
19
  export declare const dateToDatetimeInputStr: (date: Date) => string;
@@ -1,5 +1,22 @@
1
1
  import dayjs from "dayjs";
2
+ /**
3
+ * Returns a string that represents a date in the format used by the input
4
+ * element of type "date".
5
+ *
6
+ * @param date - the Date object to format
7
+ * @returns a string in the format YYYY-MM-DD
8
+ *
9
+ * @public
10
+ */
2
11
  export var dateToInputStr = function (date) { return dayjs(date).format("YYYY-MM-DD"); };
12
+ /**
13
+ * Returns of string representation of datetime from a Date object.
14
+ *
15
+ * @param date - the Date object to format
16
+ * @returns a string in the format YYYY-MM-DDTHH:mm
17
+ *
18
+ * @public
19
+ */
3
20
  export var dateToDatetimeInputStr = function (date) {
4
21
  return dayjs(date).format("YYYY-MM-DDTHH:mm");
5
22
  };
@@ -1,3 +1,12 @@
1
1
  import { CSSProperties } from "react";
2
+ /**
3
+ * Given a number representing a width, returns a React CSSProperties object
4
+ * that sets the min-width and max-width CSS properties based on that number.
5
+ * Returns undefined if the input is undefined.
6
+ *
7
+ * @param width - the number representing the width, or undefined
8
+ *
9
+ * @internal
10
+ */
2
11
  declare const getWidthStyle: (width: number | undefined) => CSSProperties | undefined;
3
12
  export default getWidthStyle;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Given a number representing a width, returns a React CSSProperties object
3
+ * that sets the min-width and max-width CSS properties based on that number.
4
+ * Returns undefined if the input is undefined.
5
+ *
6
+ * @param width - the number representing the width, or undefined
7
+ *
8
+ * @internal
9
+ */
1
10
  var getWidthStyle = function (width) {
2
11
  return width === undefined
3
12
  ? undefined
@@ -1,5 +1 @@
1
1
  export * from "./datetime";
2
- export { default as getWidthStyle } from "./getWidthStyle";
3
- export { default as isSubset } from "./isSubset";
4
- export { default as trueModulo } from "./trueModulo";
5
- export { default as useControlledHover } from "./useControlledHover";
@@ -1,5 +1 @@
1
1
  export * from "./datetime";
2
- export { default as getWidthStyle } from "./getWidthStyle";
3
- export { default as isSubset } from "./isSubset";
4
- export { default as trueModulo } from "./trueModulo";
5
- export { default as useControlledHover } from "./useControlledHover";
@@ -1,2 +1,13 @@
1
- declare const isSubset: <T>(subset: T[], superSet: T[]) => boolean;
1
+ /**
2
+ * Determines whether the elements of an array is the subset of another.
3
+ *
4
+ * @param subset - an array that may be the subset of another set
5
+ * @param superset - an array that may be the superset of another set
6
+ *
7
+ * @returns a boolean value indicating whether the elements in subset are a
8
+ * subset of the elements in superset
9
+ *
10
+ * @internal
11
+ */
12
+ declare const isSubset: <T>(subset: T[], superset: T[]) => boolean;
2
13
  export default isSubset;
@@ -1,5 +1,16 @@
1
- var isSubset = function (subset, superSet) {
2
- var supersetSet = new Set(superSet);
1
+ /**
2
+ * Determines whether the elements of an array is the subset of another.
3
+ *
4
+ * @param subset - an array that may be the subset of another set
5
+ * @param superset - an array that may be the superset of another set
6
+ *
7
+ * @returns a boolean value indicating whether the elements in subset are a
8
+ * subset of the elements in superset
9
+ *
10
+ * @internal
11
+ */
12
+ var isSubset = function (subset, superset) {
13
+ var supersetSet = new Set(superset);
3
14
  for (var _i = 0, subset_1 = subset; _i < subset_1.length; _i++) {
4
15
  var member = subset_1[_i];
5
16
  if (!supersetSet.has(member)) {
@@ -5,5 +5,10 @@ export interface UseControlledHoverHook<T> {
5
5
  handleMouseOver: MouseEventHandler<T>;
6
6
  handleMouseOut: MouseEventHandler<T>;
7
7
  }
8
+ /**
9
+ * Implements React state-based hovering for an element.
10
+ *
11
+ * @internal
12
+ */
8
13
  declare const useControlledHover: <T>() => UseControlledHoverHook<T>;
9
14
  export default useControlledHover;
@@ -1,4 +1,9 @@
1
1
  import { useState } from "react";
2
+ /**
3
+ * Implements React state-based hovering for an element.
4
+ *
5
+ * @internal
6
+ */
2
7
  var useControlledHover = function () {
3
8
  var _a = useState(false), isHovering = _a[0], setIsHovering = _a[1];
4
9
  var handleMouseOver = function () { return setIsHovering(true); };
@@ -1,4 +1,15 @@
1
+ /**
2
+ * Grid cell coordinates based on ARIA row index and column index.
3
+ *
4
+ * @public
5
+ */
1
6
  export interface FocusCoordinates {
7
+ /**
8
+ * The ARIA row index.
9
+ */
2
10
  ariaRowIndex: number;
11
+ /**
12
+ * The ARIA column index.
13
+ */
3
14
  ariaColIndex: number;
4
15
  }
@@ -6,5 +6,5 @@ export interface GridFocusOutput {
6
6
  gridKeydownHandler: KeyboardEventHandler<HTMLDivElement>;
7
7
  }
8
8
  declare const useGridFocus: (gridRef: RefObject<HTMLDivElement | null>, numRows: number, // Number that includes the header row
9
- numCols: number) => GridFocusOutput;
9
+ numCols: number, sortableColIndices: number[]) => GridFocusOutput;
10
10
  export default useGridFocus;
@@ -3,7 +3,7 @@ var startingCoordinates = {
3
3
  ariaColIndex: 1,
4
4
  ariaRowIndex: 1,
5
5
  };
6
- var useGridFocus = function (gridRef, numRows, numCols) {
6
+ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
7
7
  var _a = useState(startingCoordinates), coords = _a[0], setCoords = _a[1];
8
8
  // Even though row and col count can be gotten from attributes, it needs to
9
9
  // be a prop here to update effective coordinates at the appropriate times.
@@ -11,9 +11,16 @@ var useGridFocus = function (gridRef, numRows, numCols) {
11
11
  ariaColIndex: Math.min(coords.ariaColIndex, numCols),
12
12
  ariaRowIndex: Math.min(coords.ariaRowIndex, numRows),
13
13
  }); }, [coords.ariaColIndex, coords.ariaRowIndex, numCols, numRows]);
14
+ var currentCellIsSortableHeader = useMemo(function () {
15
+ if (coords.ariaRowIndex !== 1) {
16
+ return false;
17
+ }
18
+ return sortableColIndices.includes(coords.ariaColIndex);
19
+ }, [coords.ariaColIndex, coords.ariaRowIndex, sortableColIndices]);
14
20
  var gridClickHandler = useCallback(function (event) {
15
21
  var cursor = event.target;
16
- while (cursor !== event.currentTarget && !cursor.hasAttribute("aria-colindex")) {
22
+ while (cursor !== event.currentTarget &&
23
+ !cursor.hasAttribute("aria-colindex")) {
17
24
  cursor = cursor.parentElement;
18
25
  }
19
26
  if (!cursor.hasAttribute("aria-colindex")) {
@@ -116,15 +123,23 @@ var useGridFocus = function (gridRef, numRows, numCols) {
116
123
  if (!gridRef.current.contains(document.activeElement)) {
117
124
  return;
118
125
  }
119
- var elToFocus = gridRef.current.querySelector(":scope > div > div[aria-rowindex=\"".concat(effectiveCoords.ariaRowIndex, "\"] > div[aria-colindex=\"").concat(effectiveCoords.ariaColIndex, "\"]"));
126
+ var cellSelector = ":scope > div > div[aria-rowindex=\"".concat(effectiveCoords.ariaRowIndex, "\"] > div[aria-colindex=\"").concat(effectiveCoords.ariaColIndex, "\"]");
127
+ var elToFocus = gridRef.current.querySelector(currentCellIsSortableHeader
128
+ ? cellSelector + " .rbdg-grid-header-button"
129
+ : cellSelector);
120
130
  if (elToFocus !== document.activeElement) {
121
131
  elToFocus.focus({ preventScroll: true });
122
132
  }
123
- }, [effectiveCoords.ariaColIndex, effectiveCoords.ariaRowIndex, gridRef]);
133
+ }, [
134
+ effectiveCoords.ariaColIndex,
135
+ effectiveCoords.ariaRowIndex,
136
+ gridRef,
137
+ currentCellIsSortableHeader,
138
+ ]);
124
139
  return {
125
140
  effectiveCoords: effectiveCoords,
126
141
  gridClickHandler: gridClickHandler,
127
- gridKeydownHandler: gridKeydownHandler
142
+ gridKeydownHandler: gridKeydownHandler,
128
143
  };
129
144
  };
130
145
  export default useGridFocus;
@@ -1,4 +1,9 @@
1
1
  import { FC } from "react";
2
2
  import { GridProps } from "./types";
3
+ /**
4
+ * The main component for the grid feature of react-bootstrap-data-grid.
5
+ *
6
+ * @public
7
+ */
3
8
  declare const Grid: FC<GridProps>;
4
9
  export default Grid;
package/grid/main/Grid.js CHANGED
@@ -9,16 +9,18 @@ import GridBody from "./GridBody";
9
9
  import classNames from "classnames";
10
10
  import { CSS_PREFIX } from "../../common/constants";
11
11
  import useGridFocus from "../focus/useGridFocus";
12
+ /**
13
+ * The main component for the grid feature of react-bootstrap-data-grid.
14
+ *
15
+ * @public
16
+ */
12
17
  var Grid = function (_a) {
13
- var rows = _a.rows, cols = _a.cols, filterModel = _a.filterModel, sortModel = _a.sortModel, pagination = _a.pagination, selectModel = _a.selectModel, width = _a.width, height = _a.height, variant = _a.variant, stripes = _a.stripes, hover = _a.hover, borders = _a.borders, small = _a.small, divider = _a.divider, borderVariant = _a.borderVariant, headerCellVariant = _a.headerCellVariant, headerRowVariant = _a.headerRowVariant, bodyCellVariant = _a.bodyCellVariant, bodyRowVariant = _a.bodyRowVariant, headerCellFocusVariant = _a.headerCellFocusVariant, bodyCellFocusVariant = _a.bodyCellFocusVariant;
18
+ var rows = _a.rows, cols = _a.cols, sortModel = _a.sortModel, width = _a.width, height = _a.height, variant = _a.variant, stripes = _a.stripes, hover = _a.hover, borders = _a.borders, small = _a.small, divider = _a.divider, borderVariant = _a.borderVariant, headerCellVariant = _a.headerCellVariant, headerRowVariant = _a.headerRowVariant, bodyCellVariant = _a.bodyCellVariant, bodyRowVariant = _a.bodyRowVariant, headerCellFocusVariant = _a.headerCellFocusVariant, bodyCellFocusVariant = _a.bodyCellFocusVariant;
14
19
  var _b = useCombinedPipeline({
15
20
  rows: rows,
16
21
  cols: cols,
17
- filterModel: filterModel,
18
22
  sortModel: sortModel,
19
- pagination: pagination,
20
- selectModel: selectModel,
21
- }), displayRows = _b.displayRows, filteredRows = _b.filteredRows;
23
+ }), displayRows = _b.displayRows, filteredRows = _b.filteredRows, sortedRowsOutput = _b.sortedRowsOutput;
22
24
  var colNameToWidth = useColNameToWidth(cols);
23
25
  var augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
24
26
  var gridStyle = useMemo(function () {
@@ -47,7 +49,12 @@ var Grid = function (_a) {
47
49
  }, [width, height]);
48
50
  var vertScrollable = height !== undefined && height !== "auto";
49
51
  var gridRef = useRef(null);
50
- var _c = useGridFocus(gridRef, rows.length + 1, cols.length), effectiveCoords = _c.effectiveCoords, gridClickHandler = _c.gridClickHandler, gridKeydownHandler = _c.gridKeydownHandler;
52
+ var sortableColIndices = sortModel
53
+ ? cols
54
+ .map(function (_, index) { return index + 1; })
55
+ .filter(function (ariaColIndex) { return cols[ariaColIndex - 1].sortable; })
56
+ : [];
57
+ var _c = useGridFocus(gridRef, rows.length + 1, cols.length, sortableColIndices), effectiveCoords = _c.effectiveCoords, gridClickHandler = _c.gridClickHandler, gridKeydownHandler = _c.gridKeydownHandler;
51
58
  var onCopy = useCallback(function (event) {
52
59
  var _a;
53
60
  if (!((_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement))) {
@@ -72,6 +79,6 @@ var Grid = function (_a) {
72
79
  "rbdg-grid-group-divider": !!divider,
73
80
  }, "rbdg-grid", variant && "".concat(CSS_PREFIX, "-").concat(variant), borderVariant && "border-".concat(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
74
81
  ? effectiveCoords.ariaColIndex
75
- : null, cellFocusVariant: headerCellFocusVariant }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
82
+ : null, cellFocusVariant: headerCellFocusVariant, sortInfo: sortedRowsOutput }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
76
83
  };
77
84
  export default Grid;
@@ -1,4 +1,4 @@
1
1
  import { FC } from "react";
2
- import { GridBodyProps } from "./types";
2
+ import { GridBodyProps } from "./internalTypes";
3
3
  declare const GridBody: FC<GridBodyProps>;
4
4
  export default GridBody;
@@ -1,4 +1,4 @@
1
1
  import { FC } from "react";
2
- import { GridHeaderProps } from "./types";
2
+ import { GridHeaderProps } from "./internalTypes";
3
3
  declare const GridHeader: FC<GridHeaderProps>;
4
4
  export default GridHeader;