@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.
- package/common/constants.d.ts +2 -0
- package/common/constants.js +2 -0
- package/common/editing/types.d.ts +7 -0
- package/{grid → common}/filtering/FilterOptionsTable.d.ts +4 -4
- package/{grid → common}/filtering/types.d.ts +6 -6
- package/common/filtering/useFilterFormState.d.ts +3 -0
- package/common/index.d.ts +11 -0
- package/common/index.js +11 -0
- package/{grid → common}/pagination/PageSelector.d.ts +1 -1
- package/{grid → common}/pagination/PageSizeSelector.d.ts +1 -1
- package/{grid → common}/pagination/types.d.ts +2 -1
- package/{grid → common}/pipeline/useAugFormattedRows.d.ts +1 -1
- package/common/pipeline/useColNameToWidth.d.ts +3 -0
- package/common/pipeline/useColNameToWidth.js +7 -0
- package/{grid → common}/pipeline/useCombinedPipeline/index.d.ts +4 -4
- package/{grid → common}/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +1 -1
- package/{grid → common}/pipeline/useCombinedPipeline/useDisplayRows.d.ts +1 -1
- package/{grid → common}/pipeline/useCombinedPipeline/useDisplayRows.js +1 -2
- package/common/pipeline/useCombinedPipeline/useFilter.d.ts +4 -0
- package/common/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +4 -0
- package/{grid → common}/pipeline/useCombinedPipeline/useSortedRows.d.ts +2 -2
- package/{grid → common}/pipeline/useGridSelectionFns.d.ts +2 -2
- package/{grid → common}/sorting/types.d.ts +3 -3
- package/{grid/main/ColHeaderCell → common/sorting}/useSortHeaderStates.d.ts +2 -2
- package/{grid/main/ColHeaderCell → common/sorting}/useSortHeaderStates.js +4 -4
- package/common/styling/types.d.ts +21 -0
- package/{grid → common}/types.d.ts +21 -30
- package/common/util/index.d.ts +5 -0
- package/common/util/index.js +5 -0
- package/grid/constants.d.ts +2 -0
- package/grid/constants.js +2 -0
- package/grid/focus/types.d.ts +4 -0
- package/grid/focus/useGridFocus.d.ts +10 -0
- package/grid/focus/useGridFocus.js +130 -0
- package/grid/index.d.ts +3 -10
- package/grid/index.js +3 -10
- package/grid/{Grid.d.ts → main/Grid.d.ts} +0 -1
- package/grid/main/Grid.js +76 -0
- package/grid/main/GridBody.d.ts +4 -0
- package/grid/main/GridBody.js +26 -0
- package/grid/main/GridHeader.d.ts +4 -0
- package/grid/main/GridHeader.js +15 -0
- package/grid/main/getWidthStyles.d.ts +3 -0
- package/grid/main/getWidthStyles.js +6 -0
- package/grid/main/types.d.ts +41 -0
- package/grid.css +1 -0
- package/grid.scss +243 -0
- package/package.json +1 -1
- package/pro/index.d.ts +5 -0
- package/pro/index.js +5 -0
- package/{grid/InternalGrid.d.ts → table/InternalTable.d.ts} +6 -6
- package/{grid/InternalGrid.js → table/InternalTable.js} +7 -7
- package/table/Table.d.ts +5 -0
- package/{grid/Grid.js → table/Table.js} +10 -14
- package/{grid → table}/editing/EditableRow.d.ts +1 -2
- package/{grid → table}/editing/EditableRow.js +2 -2
- package/table/index.d.ts +5 -0
- package/table/index.js +5 -0
- package/{grid → table}/main/BodyRows.d.ts +7 -7
- package/{grid → table}/main/BodyRows.js +1 -1
- package/{grid → table}/main/ColHeaderCell/index.js +3 -3
- package/{grid → table}/selection/SelectAllHeaderCell.d.ts +1 -1
- package/table/style.scss +3 -0
- package/{grid → table}/styling/types.d.ts +1 -21
- package/table/styling/types.js +1 -0
- package/table/types.d.ts +19 -0
- package/table/types.js +1 -0
- package/{grid-pro → table-pro}/ColHeaderCellPro.js +4 -4
- package/table-pro/TablePro.d.ts +4 -0
- package/{grid-pro/GridPro.js → table-pro/TablePro.js} +9 -9
- package/{grid-pro → table-pro}/index.d.ts +2 -2
- package/{grid-pro → table-pro}/index.js +2 -2
- package/{grid-pro → table-pro}/reorder/ReorderHandleCell.js +1 -1
- package/{grid-pro → table-pro}/reorder/useKeyboardReorder.js +1 -1
- package/table-pro/resize/types.js +1 -0
- package/{grid-pro → table-pro}/resize/useResizeModel.d.ts +1 -1
- package/table-pro/style.scss +69 -0
- package/{grid-pro → table-pro}/types.d.ts +3 -3
- package/table-pro/types.js +1 -0
- package/table-pro.scss +1 -0
- package/grid/editing/types.d.ts +0 -16
- package/grid/filtering/useFilterFormState.d.ts +0 -3
- package/grid/pipeline/useCombinedPipeline/useFilter.d.ts +0 -4
- package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +0 -4
- package/grid-pro/GridPro.d.ts +0 -4
- /package/{grid → common}/editing/inputStrsToRowData.d.ts +0 -0
- /package/{grid → common}/editing/inputStrsToRowData.js +0 -0
- /package/{grid-pro/reorder → common/editing}/types.js +0 -0
- /package/{grid → common}/export/ExportForm.d.ts +0 -0
- /package/{grid → common}/export/ExportForm.js +0 -0
- /package/{grid → common}/export/types.d.ts +0 -0
- /package/{grid-pro/resize → common/export}/types.js +0 -0
- /package/{grid → common}/export/useExportFn.d.ts +0 -0
- /package/{grid → common}/export/useExportFn.js +0 -0
- /package/{grid → common}/filtering/DateFilterRow.d.ts +0 -0
- /package/{grid → common}/filtering/DateFilterRow.js +0 -0
- /package/{grid → common}/filtering/FilterOptionsTable.js +0 -0
- /package/{grid → common}/filtering/FilterRow.d.ts +0 -0
- /package/{grid → common}/filtering/FilterRow.js +0 -0
- /package/{grid → common}/filtering/NumberFilterRow.d.ts +0 -0
- /package/{grid → common}/filtering/NumberFilterRow.js +0 -0
- /package/{grid → common}/filtering/StringFilterRow.d.ts +0 -0
- /package/{grid → common}/filtering/StringFilterRow.js +0 -0
- /package/{grid → common}/filtering/types.js +0 -0
- /package/{grid → common}/filtering/useFilterFormState.js +0 -0
- /package/{grid → common}/pagination/PageSelector.js +0 -0
- /package/{grid → common}/pagination/PageSizeSelector.js +0 -0
- /package/{grid → common}/pagination/Pagination.d.ts +0 -0
- /package/{grid → common}/pagination/Pagination.js +0 -0
- /package/{grid-pro → common/pagination}/types.js +0 -0
- /package/{grid → common}/pipeline/types.d.ts +0 -0
- /package/{grid-pro/util → common/pipeline}/types.js +0 -0
- /package/{grid → common}/pipeline/useAugFormattedRows.js +0 -0
- /package/{grid → common}/pipeline/useCombinedPipeline/index.js +0 -0
- /package/{grid → common}/pipeline/useCombinedPipeline/useCurrentPageRows.js +0 -0
- /package/{grid → common}/pipeline/useCombinedPipeline/useFilter.js +0 -0
- /package/{grid → common}/pipeline/useCombinedPipeline/useFilterStateFromEditable.js +0 -0
- /package/{grid → common}/pipeline/useCombinedPipeline/useFilterStateStore.d.ts +0 -0
- /package/{grid → common}/pipeline/useCombinedPipeline/useFilterStateStore.js +0 -0
- /package/{grid → common}/pipeline/useCombinedPipeline/useSortedRows.js +0 -0
- /package/{grid → common}/pipeline/useGetInputStrSubmitCallback.d.ts +0 -0
- /package/{grid → common}/pipeline/useGetInputStrSubmitCallback.js +0 -0
- /package/{grid → common}/pipeline/useGridSelectionFns.js +0 -0
- /package/{grid → common}/selection/types.d.ts +0 -0
- /package/{grid → common}/selection/types.js +0 -0
- /package/{grid → common}/sorting/arrowPlaceholder.d.ts +0 -0
- /package/{grid → common}/sorting/arrowPlaceholder.js +0 -0
- /package/{grid → common}/sorting/downArrow.d.ts +0 -0
- /package/{grid → common}/sorting/downArrow.js +0 -0
- /package/{grid → common}/sorting/sortOrderToAriaSort.d.ts +0 -0
- /package/{grid → common}/sorting/sortOrderToAriaSort.js +0 -0
- /package/{grid/editing → common/sorting}/types.js +0 -0
- /package/{grid → common}/sorting/upArrow.d.ts +0 -0
- /package/{grid → common}/sorting/upArrow.js +0 -0
- /package/{grid/export → common/styling}/types.js +0 -0
- /package/{grid → common}/toolbar/Toolbar.d.ts +0 -0
- /package/{grid → common}/toolbar/Toolbar.js +0 -0
- /package/{grid → common}/toolbar/ToolbarContainer.d.ts +0 -0
- /package/{grid → common}/toolbar/ToolbarContainer.js +0 -0
- /package/{grid → common}/toolbar/types.d.ts +0 -0
- /package/{grid/pagination → common/toolbar}/types.js +0 -0
- /package/{grid → common}/toolbar/useInterfaces.d.ts +0 -0
- /package/{grid → common}/toolbar/useInterfaces.js +0 -0
- /package/{grid/pipeline → common}/types.js +0 -0
- /package/{grid → common}/util/datetime.d.ts +0 -0
- /package/{grid → common}/util/datetime.js +0 -0
- /package/{grid → common}/util/getWidthStyle.d.ts +0 -0
- /package/{grid → common}/util/getWidthStyle.js +0 -0
- /package/{grid → common}/util/isSubset.d.ts +0 -0
- /package/{grid → common}/util/isSubset.js +0 -0
- /package/{grid → common}/util/trueModulo.d.ts +0 -0
- /package/{grid → common}/util/trueModulo.js +0 -0
- /package/{grid → common}/util/useControlledHover.d.ts +0 -0
- /package/{grid → common}/util/useControlledHover.js +0 -0
- /package/grid/{sorting → focus}/types.js +0 -0
- /package/grid/{styling → main}/types.js +0 -0
- /package/{grid → table}/editing/EditControlsCell.d.ts +0 -0
- /package/{grid → table}/editing/EditControlsCell.js +0 -0
- /package/{grid → table}/main/ColHeaderCell/index.d.ts +0 -0
- /package/{grid → table}/selection/SelectAllHeaderCell.js +0 -0
- /package/{grid → table}/selection/SelectionInput.d.ts +0 -0
- /package/{grid → table}/selection/SelectionInput.js +0 -0
- /package/{grid-pro → table-pro}/ColHeaderCellPro.d.ts +0 -0
- /package/{grid-pro → table-pro}/assets/HorizontalGrip.d.ts +0 -0
- /package/{grid-pro → table-pro}/assets/HorizontalGrip.js +0 -0
- /package/{grid-pro → table-pro}/assets/VerticalGrip.d.ts +0 -0
- /package/{grid-pro → table-pro}/assets/VerticalGrip.js +0 -0
- /package/{grid-pro/util → table-pro/lib}/regDragCleanup.d.ts +0 -0
- /package/{grid-pro/util → table-pro/lib}/regDragCleanup.js +0 -0
- /package/{grid-pro/util → table-pro/lib}/types.d.ts +0 -0
- /package/{grid/toolbar → table-pro/lib}/types.js +0 -0
- /package/{grid-pro → table-pro}/reorder/ReorderHandleCell.d.ts +0 -0
- /package/{grid-pro → table-pro}/reorder/ReorderHeaderCell.d.ts +0 -0
- /package/{grid-pro → table-pro}/reorder/ReorderHeaderCell.js +0 -0
- /package/{grid-pro → table-pro}/reorder/types.d.ts +0 -0
- /package/{grid → table-pro/reorder}/types.js +0 -0
- /package/{grid-pro → table-pro}/reorder/useKeyboardReorder.d.ts +0 -0
- /package/{grid-pro → table-pro}/reorder/useKeyboardReorderListener.d.ts +0 -0
- /package/{grid-pro → table-pro}/reorder/useKeyboardReorderListener.js +0 -0
- /package/{grid-pro → table-pro}/reorder/useReorderStyles.d.ts +0 -0
- /package/{grid-pro → table-pro}/reorder/useReorderStyles.js +0 -0
- /package/{grid-pro → table-pro}/resize/types.d.ts +0 -0
- /package/{grid-pro → table-pro}/resize/useResizeModel.js +0 -0
- /package/{grid-pro → table-pro}/util/index.d.ts +0 -0
- /package/{grid-pro → table-pro}/util/index.js +0 -0
- /package/{grid-pro → table-pro}/util/reorderRows.d.ts +0 -0
- /package/{grid-pro → table-pro}/util/reorderRows.js +0 -0
- /package/{style.css → table-pro.css} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowData, RowId } from "../types";
|
|
2
|
+
export type UpdateCallbackGenerator = (id: RowId) => (rowData: RowData) => void;
|
|
3
|
+
export interface EditModel {
|
|
4
|
+
getUpdateCallback: UpdateCallbackGenerator;
|
|
5
|
+
getDeleteCallback?: (id: RowId) => () => void;
|
|
6
|
+
editColWidth?: number;
|
|
7
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { FilterInputTableStyleModel } from "
|
|
2
|
+
import { EditableFilterState, FilterState } from "./types";
|
|
3
|
+
import { FilterInputTableStyleModel } from "../../table/styling/types";
|
|
4
4
|
export interface FilterOptionsTableProps {
|
|
5
|
-
filterState:
|
|
6
|
-
setFilterState: (filterState:
|
|
5
|
+
filterState: FilterState;
|
|
6
|
+
setFilterState: (filterState: EditableFilterState) => void;
|
|
7
7
|
closeFormCallback: () => void;
|
|
8
8
|
caption?: string;
|
|
9
9
|
styleModel?: FilterInputTableStyleModel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
1
|
+
export type FilterState = Record<string, ColFilterState>;
|
|
2
|
+
export type EditableFilterState = Record<string, EditableColFilterState>;
|
|
3
3
|
export interface ColFilterState {
|
|
4
|
-
editableState:
|
|
4
|
+
editableState: EditableColFilterState;
|
|
5
5
|
label: string;
|
|
6
6
|
}
|
|
7
7
|
export interface AbstractFilterState {
|
|
@@ -44,11 +44,11 @@ export interface BetweenDatesFilterState extends AbstractDateFilterState {
|
|
|
44
44
|
endDate: Date | null;
|
|
45
45
|
}
|
|
46
46
|
export type DateFilterState = StartDateFilterState | EndDateFilterState | BetweenDatesFilterState;
|
|
47
|
-
export type
|
|
47
|
+
export type EditableColFilterState = StringFilterState | NumberFilterState | DateFilterState;
|
|
48
48
|
export interface ControlledFilterModel {
|
|
49
49
|
type?: "controlled";
|
|
50
|
-
tableFilterState:
|
|
51
|
-
setTableFilterState: (state:
|
|
50
|
+
tableFilterState: EditableFilterState;
|
|
51
|
+
setTableFilterState: (state: EditableFilterState) => void;
|
|
52
52
|
filterTableCaption?: string;
|
|
53
53
|
}
|
|
54
54
|
export type UncontrolledFilterModel = Partial<Pick<ControlledFilterModel, "tableFilterState" | "filterTableCaption">> & {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./editing/types";
|
|
2
|
+
export * from "./export/types";
|
|
3
|
+
export * from "./filtering/types";
|
|
4
|
+
export * from "./pagination/types";
|
|
5
|
+
export * from "./pipeline/types";
|
|
6
|
+
export * from "./sorting/types";
|
|
7
|
+
export * from "./styling/types";
|
|
8
|
+
export * from "./toolbar/types";
|
|
9
|
+
export * from "./selection/types";
|
|
10
|
+
export * from "./types";
|
|
11
|
+
export * from "./util";
|
package/common/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./editing/types";
|
|
2
|
+
export * from "./export/types";
|
|
3
|
+
export * from "./filtering/types";
|
|
4
|
+
export * from "./pagination/types";
|
|
5
|
+
export * from "./pipeline/types";
|
|
6
|
+
export * from "./sorting/types";
|
|
7
|
+
export * from "./styling/types";
|
|
8
|
+
export * from "./toolbar/types";
|
|
9
|
+
export * from "./selection/types";
|
|
10
|
+
export * from "./types";
|
|
11
|
+
export * from "./util";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export type JustifyContentSetting = "start" | "end" | "center" | "between" | "around" | "evenly";
|
|
2
|
+
export type Size = "small" | "medium" | "large";
|
|
2
3
|
export interface PaginationOptions {
|
|
3
4
|
pageSizeOptions?: number[];
|
|
4
5
|
maxPageButtons?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AugFormattedRow, FormattedRow } from "../types";
|
|
2
1
|
import { ColNameToWidth } from "./types";
|
|
2
|
+
import { AugFormattedRow, FormattedRow } from "../";
|
|
3
3
|
declare const useAugFormattedRows: (colNameToWidth: ColNameToWidth, rows: FormattedRow[]) => AugFormattedRow[];
|
|
4
4
|
export default useAugFormattedRows;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { SortedRowsOutput } from "./useSortedRows";
|
|
2
2
|
import { CurrentPageRowsOutput } from "./useCurrentPageRows";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export type CombinedPipelineParams = Pick<
|
|
3
|
+
import { NormalizedTableFilterModel, FilterState } from "../../";
|
|
4
|
+
import { ColDefBase, FormattedRow, MainComponentSharedProps, RowDef } from "../../types";
|
|
5
|
+
export type CombinedPipelineParams = Pick<MainComponentSharedProps, "rows" | "filterModel" | "sortModel" | "pagination" | "selectModel"> & {
|
|
6
6
|
cols: ColDefBase[];
|
|
7
7
|
};
|
|
8
8
|
export interface UseCombinedPipelineHook {
|
|
9
9
|
normalizedTableFilterModel: NormalizedTableFilterModel | null;
|
|
10
10
|
filteredRows: RowDef[];
|
|
11
|
-
filterState:
|
|
11
|
+
filterState: FilterState | null;
|
|
12
12
|
sortedRowsOutput: SortedRowsOutput;
|
|
13
13
|
currentPageRowsOutput: CurrentPageRowsOutput;
|
|
14
14
|
showSelectCol: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AugRowDef, PostPaginationRowDef } from "../../types";
|
|
2
1
|
import { NormalizedPaginationModel, PaginationModel } from "../../pagination/types";
|
|
2
|
+
import { AugRowDef, PostPaginationRowDef } from "../../";
|
|
3
3
|
export interface CurrentPageRowsOutput {
|
|
4
4
|
paginatedRows: PostPaginationRowDef[];
|
|
5
5
|
normalizedModel: NormalizedPaginationModel | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColDef, FormattedRow, PostPaginationRowDef } from "../../types";
|
|
2
2
|
declare const useDisplayRows: (currentPageRows: PostPaginationRowDef[], cols: ColDef[], ariaColIndexOffset: number) => FormattedRow[];
|
|
3
3
|
export default useDisplayRows;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { dateToDatetimeInputStr, dateToInputStr } from "../../util
|
|
2
|
+
import { dateToDatetimeInputStr, dateToInputStr } from "../../util";
|
|
3
3
|
const getFormattedValue = (value, formatter, typeString) => {
|
|
4
4
|
if (formatter) {
|
|
5
5
|
return formatter(value);
|
|
@@ -31,7 +31,6 @@ const useDisplayRows = (currentPageRows, cols, ariaColIndexOffset) => useMemo(()
|
|
|
31
31
|
const displayRow = [];
|
|
32
32
|
Object.keys(row.data).forEach((name) => {
|
|
33
33
|
if (!nameToIndex.has(name)) {
|
|
34
|
-
console.error(`Warning: row data contains a property named "${name}", but it was not found among the column definitions.`);
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
const index = nameToIndex.get(name);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EditableFilterState, FilterState } from "../../filtering/types";
|
|
2
|
+
import { ColDef } from "../../types";
|
|
3
|
+
declare const useFilterStateFromEditable: (colDefs: ColDef[], editableFilterState: EditableFilterState | null) => FilterState | null;
|
|
4
|
+
export default useFilterStateFromEditable;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { SortColDef, SortModel } from "../../sorting/types";
|
|
1
2
|
import { AugRowDef, ColDefBase } from "../../types";
|
|
2
|
-
import { SortColDef, TableSortModel } from "../../sorting/types";
|
|
3
3
|
export interface SortedRowsOutput {
|
|
4
4
|
sortedRows: AugRowDef[];
|
|
5
5
|
sortingEnabled: boolean;
|
|
6
6
|
sortColDef: SortColDef | null | undefined;
|
|
7
7
|
setSortColDef: ((sortColDef: SortColDef | null) => void) | undefined;
|
|
8
8
|
}
|
|
9
|
-
declare const useSortedRows: (rows: AugRowDef[], cols: ColDefBase[], sortModel:
|
|
9
|
+
declare const useSortedRows: (rows: AugRowDef[], cols: ColDefBase[], sortModel: SortModel | undefined) => SortedRowsOutput;
|
|
10
10
|
export default useSortedRows;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RowDef, RowId } from "../types";
|
|
2
1
|
import { MouseEventHandler } from "react";
|
|
3
2
|
import { SelectionInfo, SelectModel } from "../selection/types";
|
|
4
|
-
import { SelectionInputModel } from "
|
|
3
|
+
import { SelectionInputModel } from "../../table/selection/SelectionInput";
|
|
4
|
+
import { RowDef, RowId } from "../types";
|
|
5
5
|
export interface UseGridSelectionFnsHook {
|
|
6
6
|
selectedSet: Set<RowId>;
|
|
7
7
|
rowsAreSelectable: boolean | undefined;
|
|
@@ -7,13 +7,13 @@ export interface ColSortModel {
|
|
|
7
7
|
sortOrder: SortOrder | null;
|
|
8
8
|
setSortOrder: (order: SortOrder | null) => void;
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface ControlledSortModel {
|
|
11
11
|
type?: "controlled";
|
|
12
12
|
sortColDef: SortColDef | null;
|
|
13
13
|
setSortColDef: (sortColDef: SortColDef | null) => void;
|
|
14
14
|
}
|
|
15
|
-
export interface
|
|
15
|
+
export interface UncontrolledSortModel {
|
|
16
16
|
type: "uncontrolled";
|
|
17
17
|
initialSortColDef: SortColDef | null;
|
|
18
18
|
}
|
|
19
|
-
export type
|
|
19
|
+
export type SortModel = ControlledSortModel | UncontrolledSortModel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UseControlledHoverHook } from "
|
|
1
|
+
import { UseControlledHoverHook } from "../util/useControlledHover";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
import { ColSortModel } from "
|
|
3
|
+
import { ColSortModel } from "./types";
|
|
4
4
|
export type UseSortHeaderStatesHook = UseControlledHoverHook<HTMLTableCellElement> & {
|
|
5
5
|
handleClick: () => void;
|
|
6
6
|
sortSymbol: ReactNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import useControlledHover from "
|
|
1
|
+
import useControlledHover from "../util/useControlledHover";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import upArrow from "
|
|
4
|
-
import arrowPlaceholder from "
|
|
5
|
-
import downArrow from "
|
|
3
|
+
import upArrow from "./upArrow";
|
|
4
|
+
import arrowPlaceholder from "./arrowPlaceholder";
|
|
5
|
+
import downArrow from "./downArrow";
|
|
6
6
|
const useSortHeaderStates = (sortModel) => {
|
|
7
7
|
const { isHovering, setIsHovering, handleMouseOver, handleMouseOut } = useControlledHover();
|
|
8
8
|
const handleClick = () => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AdditionalComponentsStyleModel, FilterInputTableStyleModel, TableStyleModel } from "../../table";
|
|
2
|
+
export interface ToolbarStyleModel {
|
|
3
|
+
activeButton?: string[];
|
|
4
|
+
inactiveButton?: string[];
|
|
5
|
+
toolbar?: string[];
|
|
6
|
+
interfaceContainer?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ExportFormStyleModel {
|
|
9
|
+
legend?: string[];
|
|
10
|
+
radioContainer?: string[];
|
|
11
|
+
radioInput?: string[];
|
|
12
|
+
radioLabel?: string[];
|
|
13
|
+
submitButton?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface StyleModel {
|
|
16
|
+
mainTableStyleModel?: TableStyleModel;
|
|
17
|
+
filterInputTableStyleModel?: FilterInputTableStyleModel;
|
|
18
|
+
additionalComponentsStyleModel?: AdditionalComponentsStyleModel;
|
|
19
|
+
toolbarStyleModel?: ToolbarStyleModel;
|
|
20
|
+
exportFormStyleModel?: ExportFormStyleModel;
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditModel } from "./editing/types";
|
|
2
2
|
import { PaginationModel } from "./pagination/types";
|
|
3
|
-
import {
|
|
3
|
+
import { SortModel } from "./sorting/types";
|
|
4
4
|
import { FilterModel } from "./filtering/types";
|
|
5
5
|
import { SelectModel } from "./selection/types";
|
|
6
6
|
import { StyleModel } from "./styling/types";
|
|
@@ -23,44 +23,35 @@ export interface RowDef<Data extends ValidRowData = ValidRowData> {
|
|
|
23
23
|
id: RowId;
|
|
24
24
|
data: RowData<Data>;
|
|
25
25
|
}
|
|
26
|
-
export
|
|
27
|
-
origIndex: number;
|
|
28
|
-
};
|
|
29
|
-
export type PostPaginationRowDef<Data extends ValidRowData = ValidRowData> = AugRowDef<Data> & {
|
|
30
|
-
prePaginationIndex: number;
|
|
31
|
-
};
|
|
32
|
-
export type FormattedRow = {
|
|
33
|
-
contents: CellData[];
|
|
34
|
-
} & Omit<PostPaginationRowDef, "data">;
|
|
35
|
-
export type AugCellData = CellData & {
|
|
36
|
-
width?: number;
|
|
37
|
-
};
|
|
38
|
-
export type AugFormattedRow = Omit<FormattedRow, "contents"> & {
|
|
39
|
-
contents: AugCellData[];
|
|
40
|
-
};
|
|
41
|
-
export type JustifyContentSetting = "start" | "end" | "center" | "between" | "around" | "evenly";
|
|
42
|
-
export type Size = "small" | "medium" | "large";
|
|
43
|
-
export type DisplayMode = "table" | "block";
|
|
44
|
-
export interface GridProps {
|
|
26
|
+
export interface MainComponentSharedProps {
|
|
45
27
|
rows: RowDef[];
|
|
46
28
|
cols: ColDef[];
|
|
47
29
|
pagination?: PaginationModel;
|
|
48
|
-
sortModel?:
|
|
30
|
+
sortModel?: SortModel;
|
|
49
31
|
filterModel?: FilterModel;
|
|
50
32
|
selectModel?: SelectModel;
|
|
51
33
|
editModel?: EditModel;
|
|
52
|
-
caption?: string;
|
|
53
34
|
styleModel?: StyleModel;
|
|
54
|
-
displayMode?: DisplayMode;
|
|
55
35
|
allowExport?: boolean;
|
|
56
36
|
}
|
|
57
|
-
export type
|
|
58
|
-
|
|
37
|
+
export type AugRowDef<Data extends ValidRowData = ValidRowData> = RowDef<Data> & {
|
|
38
|
+
origIndex: number;
|
|
59
39
|
};
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
export type PostPaginationRowDef<Data extends ValidRowData = ValidRowData> = AugRowDef<Data> & {
|
|
41
|
+
prePaginationIndex: number;
|
|
42
|
+
};
|
|
43
|
+
export interface CellData {
|
|
44
|
+
fieldName: string;
|
|
45
|
+
value: ColDataType;
|
|
46
|
+
type: ColDataTypeStrings;
|
|
63
47
|
ariaColIndex: number;
|
|
64
|
-
|
|
48
|
+
formattedValue: string;
|
|
49
|
+
label: string;
|
|
65
50
|
width?: number;
|
|
66
51
|
}
|
|
52
|
+
export type FormattedRow = {
|
|
53
|
+
contents: Omit<CellData, "width">[];
|
|
54
|
+
} & Omit<PostPaginationRowDef, "data">;
|
|
55
|
+
export type AugFormattedRow = {
|
|
56
|
+
contents: CellData[];
|
|
57
|
+
} & Omit<PostPaginationRowDef, "data">;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyboardEventHandler, PointerEventHandler, RefObject } from "react";
|
|
2
|
+
import { FocusCoordinates } from "./types";
|
|
3
|
+
export interface GridFocusOutput {
|
|
4
|
+
effectiveCoords: FocusCoordinates;
|
|
5
|
+
gridClickHandler: PointerEventHandler<HTMLDivElement>;
|
|
6
|
+
gridKeydownHandler: KeyboardEventHandler<HTMLDivElement>;
|
|
7
|
+
}
|
|
8
|
+
declare const useGridFocus: (gridRef: RefObject<HTMLDivElement | null>, numRows: number, // Number that includes the header row
|
|
9
|
+
numCols: number) => GridFocusOutput;
|
|
10
|
+
export default useGridFocus;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState, } from "react";
|
|
2
|
+
const startingCoordinates = {
|
|
3
|
+
ariaColIndex: 1,
|
|
4
|
+
ariaRowIndex: 1,
|
|
5
|
+
};
|
|
6
|
+
const useGridFocus = (gridRef, numRows, numCols) => {
|
|
7
|
+
const [coords, setCoords] = useState(startingCoordinates);
|
|
8
|
+
// Even though row and col count can be gotten from attributes, it needs to
|
|
9
|
+
// be a prop here to update effective coordinates at the appropriate times.
|
|
10
|
+
const effectiveCoords = useMemo(() => ({
|
|
11
|
+
ariaColIndex: Math.min(coords.ariaColIndex, numCols),
|
|
12
|
+
ariaRowIndex: Math.min(coords.ariaRowIndex, numRows),
|
|
13
|
+
}), [coords.ariaColIndex, coords.ariaRowIndex, numCols, numRows]);
|
|
14
|
+
const gridClickHandler = useCallback((event) => {
|
|
15
|
+
let cursor = event.target;
|
|
16
|
+
while (cursor !== event.currentTarget && !cursor.hasAttribute("aria-colindex")) {
|
|
17
|
+
cursor = cursor.parentElement;
|
|
18
|
+
}
|
|
19
|
+
if (!cursor.hasAttribute("aria-colindex")) {
|
|
20
|
+
// This is a legit outcome if the click was registered at a level above
|
|
21
|
+
// grid cells or column headers.
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const row = cursor.parentElement;
|
|
25
|
+
setCoords({
|
|
26
|
+
ariaColIndex: Number(cursor.getAttribute("aria-colIndex")),
|
|
27
|
+
ariaRowIndex: Number(row.getAttribute("aria-rowIndex")),
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
30
|
+
const gridKeydownHandler = useCallback((event) => {
|
|
31
|
+
switch (event.code) {
|
|
32
|
+
case "ArrowDown": {
|
|
33
|
+
if (effectiveCoords.ariaRowIndex !== numRows) {
|
|
34
|
+
setCoords({
|
|
35
|
+
ariaColIndex: effectiveCoords.ariaColIndex,
|
|
36
|
+
ariaRowIndex: effectiveCoords.ariaRowIndex + 1,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "ArrowUp": {
|
|
42
|
+
if (effectiveCoords.ariaRowIndex !== 1) {
|
|
43
|
+
setCoords({
|
|
44
|
+
ariaColIndex: effectiveCoords.ariaColIndex,
|
|
45
|
+
ariaRowIndex: effectiveCoords.ariaRowIndex - 1,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "ArrowLeft": {
|
|
51
|
+
if (effectiveCoords.ariaColIndex !== 1) {
|
|
52
|
+
setCoords({
|
|
53
|
+
ariaColIndex: effectiveCoords.ariaColIndex - 1,
|
|
54
|
+
ariaRowIndex: effectiveCoords.ariaRowIndex,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "ArrowRight": {
|
|
60
|
+
if (effectiveCoords.ariaColIndex !== numCols) {
|
|
61
|
+
setCoords({
|
|
62
|
+
ariaColIndex: effectiveCoords.ariaColIndex + 1,
|
|
63
|
+
ariaRowIndex: effectiveCoords.ariaRowIndex,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "Home": {
|
|
69
|
+
if (event.ctrlKey || event.metaKey) {
|
|
70
|
+
setCoords({
|
|
71
|
+
ariaColIndex: 1,
|
|
72
|
+
ariaRowIndex: 1,
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
setCoords({
|
|
77
|
+
ariaColIndex: 1,
|
|
78
|
+
ariaRowIndex: effectiveCoords.ariaRowIndex,
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "End": {
|
|
83
|
+
if (event.ctrlKey || event.metaKey) {
|
|
84
|
+
setCoords({
|
|
85
|
+
ariaColIndex: numCols,
|
|
86
|
+
ariaRowIndex: numRows,
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
setCoords({
|
|
91
|
+
ariaColIndex: numCols,
|
|
92
|
+
ariaRowIndex: effectiveCoords.ariaRowIndex,
|
|
93
|
+
});
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default: {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
// Optionally set the element focus here. Not sure how much differences it
|
|
102
|
+
// makes in terms of performance vs relying on the useEffect hook.
|
|
103
|
+
}, [
|
|
104
|
+
effectiveCoords.ariaColIndex,
|
|
105
|
+
effectiveCoords.ariaRowIndex,
|
|
106
|
+
numCols,
|
|
107
|
+
numRows,
|
|
108
|
+
]);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!gridRef.current) {
|
|
111
|
+
// Not completely sure when this code can be reached, but it seems like a
|
|
112
|
+
// decent solution to just return. At the worst the user may need to click
|
|
113
|
+
// or do a keypress again during a corner case.
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!gridRef.current.contains(document.activeElement)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const elToFocus = gridRef.current.querySelector(`:scope > div > div[aria-rowindex="${effectiveCoords.ariaRowIndex}"] > div[aria-colindex="${effectiveCoords.ariaColIndex}"]`);
|
|
120
|
+
if (elToFocus !== document.activeElement) {
|
|
121
|
+
elToFocus.focus({ preventScroll: true });
|
|
122
|
+
}
|
|
123
|
+
}, [effectiveCoords.ariaColIndex, effectiveCoords.ariaRowIndex, gridRef]);
|
|
124
|
+
return {
|
|
125
|
+
effectiveCoords,
|
|
126
|
+
gridClickHandler,
|
|
127
|
+
gridKeydownHandler
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export default useGridFocus;
|
package/grid/index.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "
|
|
3
|
-
export
|
|
4
|
-
export * from "./selection/types";
|
|
5
|
-
export * from "./filtering/types";
|
|
6
|
-
export * from "./sorting/types";
|
|
7
|
-
export * from "./pagination/types";
|
|
8
|
-
export * from "./Grid";
|
|
9
|
-
export * from "./util/datetime";
|
|
10
|
-
export { default } from "./Grid";
|
|
1
|
+
export * from "./main/types";
|
|
2
|
+
export * from "../common";
|
|
3
|
+
export { default } from "./main/Grid";
|
package/grid/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "
|
|
3
|
-
export
|
|
4
|
-
export * from "./selection/types";
|
|
5
|
-
export * from "./filtering/types";
|
|
6
|
-
export * from "./sorting/types";
|
|
7
|
-
export * from "./pagination/types";
|
|
8
|
-
export * from "./Grid";
|
|
9
|
-
export * from "./util/datetime";
|
|
10
|
-
export { default } from "./Grid";
|
|
1
|
+
export * from "./main/types";
|
|
2
|
+
export * from "../common";
|
|
3
|
+
export { default } from "./main/Grid";
|