@absreim/react-bootstrap-data-grid 1.3.0 → 1.4.1

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 (73) hide show
  1. package/ColHeaderCell.d.ts +2 -1
  2. package/ColHeaderCell.js +6 -6
  3. package/Grid.d.ts +8 -10
  4. package/Grid.js +42 -40
  5. package/ToggleButton.d.ts +1 -0
  6. package/ToggleButton.js +5 -3
  7. package/editing/EditControlsCell.d.ts +5 -0
  8. package/editing/EditControlsCell.js +15 -2
  9. package/editing/EditableRow.d.ts +8 -1
  10. package/editing/EditableRow.js +4 -3
  11. package/editing/types.d.ts +14 -0
  12. package/editing/types.js +1 -0
  13. package/filtering/DateFilterRow.d.ts +8 -2
  14. package/filtering/DateFilterRow.js +6 -5
  15. package/filtering/FilterOptionsTable.d.ts +4 -1
  16. package/filtering/FilterOptionsTable.js +26 -7
  17. package/filtering/FilterRow.d.ts +19 -0
  18. package/filtering/FilterRow.js +18 -0
  19. package/filtering/NumberFilterRow.d.ts +7 -2
  20. package/filtering/NumberFilterRow.js +7 -6
  21. package/filtering/StringFilterRow.d.ts +8 -3
  22. package/filtering/StringFilterRow.js +7 -6
  23. package/filtering/types.d.ts +52 -1
  24. package/filtering/types.js +30 -1
  25. package/filtering/useFormStateFromTableFilterState.d.ts +1 -2
  26. package/index.d.ts +7 -1
  27. package/index.js +7 -1
  28. package/package.json +4 -3
  29. package/pagination/PageSelector.d.ts +2 -2
  30. package/pagination/Pagination.d.ts +3 -1
  31. package/pagination/Pagination.js +2 -2
  32. package/pagination/types.d.ts +12 -0
  33. package/pagination/types.js +1 -0
  34. package/pipeline/useCurrentPageRows.d.ts +4 -0
  35. package/pipeline/useCurrentPageRows.js +14 -0
  36. package/{hooks → pipeline}/useEditableFromFilterState.d.ts +1 -1
  37. package/{hooks → pipeline}/useFilter.d.ts +2 -1
  38. package/{hooks → pipeline}/useFilterStateFromEditable.d.ts +2 -1
  39. package/{hooks → pipeline}/useSortedRows.d.ts +2 -1
  40. package/selection/SelectAllHeaderCell.d.ts +2 -1
  41. package/selection/SelectAllHeaderCell.js +7 -6
  42. package/selection/SelectionInput.d.ts +1 -0
  43. package/selection/SelectionInput.js +3 -2
  44. package/selection/types.d.ts +16 -0
  45. package/selection/types.js +4 -0
  46. package/sorting/types.d.ts +13 -0
  47. package/sorting/types.js +1 -0
  48. package/styling/styleModelUnwrappers.d.ts +4 -0
  49. package/styling/styleModelUnwrappers.js +57 -0
  50. package/styling/types.d.ts +44 -0
  51. package/styling/types.js +1 -0
  52. package/types.d.ts +1 -95
  53. package/types.js +1 -30
  54. /package/{hooks → pipeline}/useAugmentedRows.d.ts +0 -0
  55. /package/{hooks → pipeline}/useAugmentedRows.js +0 -0
  56. /package/{hooks → pipeline}/useDisplayRows.d.ts +0 -0
  57. /package/{hooks → pipeline}/useDisplayRows.js +0 -0
  58. /package/{hooks → pipeline}/useEditableFromFilterState.js +0 -0
  59. /package/{hooks → pipeline}/useFilter.js +0 -0
  60. /package/{hooks → pipeline}/useFilterStateFromEditable.js +0 -0
  61. /package/{hooks → pipeline}/useSortedRows.js +0 -0
  62. /package/{icons → selection}/deselectAll.d.ts +0 -0
  63. /package/{icons → selection}/deselectAll.js +0 -0
  64. /package/{icons → selection}/selectAll.d.ts +0 -0
  65. /package/{icons → selection}/selectAll.js +0 -0
  66. /package/{icons → sorting}/arrowPlaceholder.d.ts +0 -0
  67. /package/{icons → sorting}/arrowPlaceholder.js +0 -0
  68. /package/{icons → sorting}/downArrow.d.ts +0 -0
  69. /package/{icons → sorting}/downArrow.js +0 -0
  70. /package/{icons → sorting}/upArrow.d.ts +0 -0
  71. /package/{icons → sorting}/upArrow.js +0 -0
  72. /package/{hooks → util}/useControlledHover.d.ts +0 -0
  73. /package/{hooks → util}/useControlledHover.js +0 -0
@@ -9,10 +9,12 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { stringFilterSchemeNames, stringFilterSchemes, } from "../types";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import FilterRow from "./FilterRow";
14
+ import classNames from "classnames";
15
+ import { stringFilterSchemeNames, } from "./types";
14
16
  var StringFilterRow = function (_a) {
15
- var columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState;
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;
16
18
  var handleOpChange = function (_a) {
17
19
  var target = _a.target;
18
20
  setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
@@ -26,9 +28,8 @@ var StringFilterRow = function (_a) {
26
28
  setFilterState(__assign(__assign({}, filterState), { searchString: target.value }));
27
29
  };
28
30
  var enabled = filterState.enabled, scheme = filterState.scheme, searchString = filterState.searchString;
29
- var checkboxLabel = "".concat(columnLabel, " Column Filter Toggle");
30
- var opSelectLabel = "".concat(columnLabel, " Column Filter Operator Selection");
31
31
  var valueInputLabel = "".concat(columnLabel, " Column Filter Value");
32
- return (_jsxs("tr", { children: [_jsx("td", { children: _jsx("input", { name: checkboxLabel, "aria-label": checkboxLabel, type: "checkbox", checked: enabled, onChange: handleEnabledChange }) }), _jsx("td", { children: columnLabel }), _jsx("td", { children: "String" }), _jsx("td", { children: _jsx("select", { name: opSelectLabel, "aria-label": opSelectLabel, disabled: !enabled, className: "form-select", value: scheme, onChange: handleOpChange, children: stringFilterSchemes.map(function (scheme) { return (_jsx("option", { value: scheme, children: stringFilterSchemeNames[scheme] }, scheme)); }) }) }), _jsx("td", { children: _jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: "form-control", required: enabled, disabled: !enabled, value: searchString, onChange: handleSearchStringChange }) })] }));
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 }));
33
34
  };
34
35
  export default StringFilterRow;
@@ -1,4 +1,55 @@
1
- import { AbstractDateFilterState, AbstractFilterState, DateFilterScheme, NumberFilterScheme, StringFilterState } from "../types";
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
+ }
2
53
  export interface NumberFormFilterState extends AbstractFilterState {
3
54
  type: "number";
4
55
  scheme: NumberFilterScheme;
@@ -1 +1,30 @@
1
- export {};
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,10 @@
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";
9
+ export * from "./util/datetime";
4
10
  export { default } from "./Grid";
package/index.js CHANGED
@@ -1,4 +1,10 @@
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";
9
+ export * from "./util/datetime";
4
10
  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.3.0",
4
+ "version": "1.4.1",
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",
@@ -27,6 +28,6 @@
27
28
  "repository": {
28
29
  "type": "git",
29
30
  "url": "git+https://github.com/absreim/react-bootstrap-data-grid.git",
30
- "directory": "src/grid"
31
+ "directory": "grid"
31
32
  }
32
33
  }
@@ -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
- 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-label": "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 {};
@@ -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>;
@@ -0,0 +1,57 @@
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
+ var unwrapSharedStyleModel = function (sharedStyleModel) { return ({
13
+ table: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.table) || [],
14
+ tbody: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.tbody) || [],
15
+ thead: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.thead) || [],
16
+ theadTr: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.theadTr) || [],
17
+ theadTh: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.theadTh) ? sharedStyleModel.theadTh : function () { return []; },
18
+ caption: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.caption) || [],
19
+ }); };
20
+ export var unwrapTableStyleModel = function (tableStyleModel) { return (__assign(__assign({}, unwrapSharedStyleModel(tableStyleModel)), { tbodyTr: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTr) ? tableStyleModel.tbodyTr : function () { return []; }, tbodyTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd) ? tableStyleModel.tbodyTd : function () { return []; }, tbodyTdInput: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTdInput)
21
+ ? tableStyleModel.tbodyTdInput
22
+ : function () { return []; }, editColTh: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTh) || [], editColTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTd) ? tableStyleModel.editColTd : function () { return []; }, editCancelButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editCancelButton)
23
+ ? tableStyleModel.editCancelButton
24
+ : function () { return []; }, editDeleteButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editDeleteButton)
25
+ ? tableStyleModel.editDeleteButton
26
+ : function () { return []; }, editSaveButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editSaveButton)
27
+ ? tableStyleModel.editSaveButton
28
+ : function () { return []; }, editStartButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editStartButton)
29
+ ? tableStyleModel.editStartButton
30
+ : function () { return []; }, rowSelectColTh: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTh) || [], rowSelectColTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTd)
31
+ ? tableStyleModel.rowSelectColTd
32
+ : function () { return []; }, rowSelectInput: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectInput)
33
+ ? tableStyleModel.rowSelectInput
34
+ : function () { return []; } })); };
35
+ export var unwrapFilterInputTableStyleModel = function (filterTableStyleModel) { return (__assign(__assign({}, unwrapSharedStyleModel(filterTableStyleModel)), { tbodyTr: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.tbodyTr)
36
+ ? filterTableStyleModel.tbodyTr
37
+ : function () { return []; }, tbodyTd: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.tbodyTd)
38
+ ? filterTableStyleModel.tbodyTd
39
+ : function () { return []; }, enablementInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.enablementInput)
40
+ ? filterTableStyleModel.enablementInput
41
+ : function () { return []; }, schemeSelectionInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.schemeSelectionInput)
42
+ ? filterTableStyleModel.schemeSelectionInput
43
+ : function () { return []; }, searchStringInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.searchStringInput)
44
+ ? filterTableStyleModel.searchStringInput
45
+ : function () { return []; }, numberInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.numberInput)
46
+ ? filterTableStyleModel.numberInput
47
+ : function () { return []; }, startDateInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.startDateInput)
48
+ ? filterTableStyleModel.startDateInput
49
+ : function () { return []; }, endDateInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.endDateInput)
50
+ ? filterTableStyleModel.endDateInput
51
+ : function () { return []; }, submitButton: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.submitButton) || [] })); };
52
+ export var unwrapAdditionalComponentsStyleModel = function (styleModel) { return ({
53
+ topLevelDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.topLevelDiv) || [],
54
+ filterInputsDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputsDiv) || [],
55
+ tableAndPaginationDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tableAndPaginationDiv) || [],
56
+ filterUiToggleButton: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterUiToggleButton) || [],
57
+ }); };
@@ -0,0 +1,44 @@
1
+ export interface SharedTableStyleModel {
2
+ table?: string[];
3
+ tbody?: string[];
4
+ thead?: string[];
5
+ theadTr?: string[];
6
+ theadTh?: (colIndex: number) => string[];
7
+ caption?: string[];
8
+ }
9
+ export type TableStyleModel = SharedTableStyleModel & {
10
+ tbodyTr?: (origIndex: number, displayIndex: number) => string[];
11
+ tbodyTd?: (origRowIndex: number, displayRowIndex: number, colIndex: number) => string[];
12
+ tbodyTdInput?: (origRowIndex: number, displayRowIndex: number, colIndex: number) => string[];
13
+ editColTh?: string[];
14
+ editColTd?: (origIndex: number, displayIndex: number) => string[];
15
+ editStartButton?: (origIndex: number, displayIndex: number) => string[];
16
+ editDeleteButton?: (origIndex: number, displayIndex: number) => string[];
17
+ editSaveButton?: (origIndex: number, displayIndex: number) => string[];
18
+ editCancelButton?: (origIndex: number, displayIndex: number) => string[];
19
+ rowSelectColTh?: string[];
20
+ rowSelectColTd?: (origIndex: number, displayIndex: number) => string[];
21
+ rowSelectInput?: (origIndex: number, displayIndex: number) => string[];
22
+ };
23
+ export type FilterInputTableStyleModel = SharedTableStyleModel & {
24
+ tbodyTr?: (rowIndex: number) => string[];
25
+ tbodyTd?: (rowIndex: number, colIndex: number) => string[];
26
+ enablementInput?: (rowIndex: number) => string[];
27
+ schemeSelectionInput?: (rowIndex: number) => string[];
28
+ searchStringInput?: (rowIndex: number) => string[];
29
+ numberInput?: (rowIndex: number) => string[];
30
+ startDateInput?: (rowIndex: number) => string[];
31
+ endDateInput?: (rowIndex: number) => string[];
32
+ submitButton?: string[];
33
+ };
34
+ export interface AdditionalComponentsStyleModel {
35
+ topLevelDiv?: string[];
36
+ filterInputsDiv?: string[];
37
+ tableAndPaginationDiv?: string[];
38
+ filterUiToggleButton?: string[];
39
+ }
40
+ export interface StyleModel {
41
+ mainTableStyleModel?: TableStyleModel;
42
+ filterInputTableStyleModel?: FilterInputTableStyleModel;
43
+ additionalComponentsStyleModel?: AdditionalComponentsStyleModel;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CellData } from "./editing/types";
1
2
  export type ColDataType = string | number | Date;
2
3
  export type ColDataTypeStrings = "string" | "number" | "date" | "datetime";
3
4
  export interface ColDef {
@@ -21,98 +22,3 @@ export interface FormattedRow {
21
22
  }
22
23
  export type JustifyContentSetting = "start" | "end" | "center" | "between" | "around" | "evenly";
23
24
  export type Size = "small" | "medium" | "large";
24
- export type SortOrder = "asc" | "desc";
25
- export interface SortColDef {
26
- name: string;
27
- order: SortOrder;
28
- }
29
- export interface ColSortModel {
30
- sortOrder: SortOrder | null;
31
- setSortOrder: (order: SortOrder | null) => void;
32
- }
33
- export interface TableSortModel {
34
- sortColDef: SortColDef | null;
35
- setSortColDef: (sortColDef: SortColDef | null) => void;
36
- }
37
- export type TableFilterState = Record<string, ColFilterState>;
38
- export type EditableTableFilterState = Record<string, FilterState>;
39
- export interface ColFilterState {
40
- editableState: FilterState;
41
- label: string;
42
- }
43
- export interface AbstractFilterState {
44
- enabled: boolean;
45
- }
46
- export declare const stringFilterSchemes: readonly ["contains", "startsWith", "endsWith"];
47
- export type StringFilterScheme = (typeof stringFilterSchemes)[number];
48
- export declare const stringFilterSchemeNames: Record<StringFilterScheme, string>;
49
- export interface StringFilterState extends AbstractFilterState {
50
- type: "string";
51
- scheme: StringFilterScheme;
52
- searchString: string;
53
- }
54
- export declare const numberFilterSchemes: readonly ["equals", "greaterThan", "lessThan", "greaterOrEqual", "lessOrEqual"];
55
- export type NumberFilterScheme = (typeof numberFilterSchemes)[number];
56
- export declare const numberFilterSchemeNames: Record<NumberFilterScheme, string>;
57
- export interface NumberFilterState extends AbstractFilterState {
58
- type: "number";
59
- scheme: NumberFilterScheme;
60
- numValue: number | null;
61
- }
62
- export declare const dateFilterSchemes: readonly ["startFrom", "endAt", "between"];
63
- export type DateFilterScheme = (typeof dateFilterSchemes)[number];
64
- export declare const dateFilterSchemeNames: Record<DateFilterScheme, string>;
65
- export interface AbstractDateFilterState extends AbstractFilterState {
66
- type: "date" | "datetime";
67
- scheme: DateFilterScheme;
68
- }
69
- export interface StartDateFilterState extends AbstractDateFilterState {
70
- scheme: "startFrom";
71
- startDate: Date | null;
72
- }
73
- export interface EndDateFilterState extends AbstractDateFilterState {
74
- scheme: "endAt";
75
- endDate: Date | null;
76
- }
77
- export interface BetweenDatesFilterState extends AbstractDateFilterState {
78
- scheme: "between";
79
- startDate: Date | null;
80
- endDate: Date | null;
81
- }
82
- export type DateFilterState = StartDateFilterState | EndDateFilterState | BetweenDatesFilterState;
83
- export type FilterState = StringFilterState | NumberFilterState | DateFilterState;
84
- export interface FilterModel {
85
- tableFilterState: EditableTableFilterState;
86
- setTableFilterState: (state: EditableTableFilterState) => void;
87
- }
88
- export type SelectMode = "column" | "row" | "both";
89
- export type SelectType = "single" | "multi";
90
- export interface MultiSelectModel {
91
- mode: SelectMode;
92
- type: "multi";
93
- selected: number[];
94
- setSelected: (selected: number[]) => void;
95
- }
96
- export interface SingleSelectModel {
97
- mode: SelectMode;
98
- type: "single";
99
- selected: number | null;
100
- setSelected: (selected: number | null) => void;
101
- groupName: string;
102
- }
103
- export type SelectModel = SingleSelectModel | MultiSelectModel;
104
- export type MultiSelectModelInitialState = Omit<MultiSelectModel, "setSelected">;
105
- export type SingleSelectModelInitialState = Omit<SingleSelectModel, "setSelected">;
106
- export interface CellData {
107
- fieldName: string;
108
- value: ColDataType;
109
- type: ColDataTypeStrings;
110
- ariaColIndex: number;
111
- formattedValue: string;
112
- label: string;
113
- }
114
- export type UpdateCallbackGenerator = (origIndex: number) => (rowDef: RowDef) => void;
115
- export interface EditModel {
116
- getUpdateCallback: UpdateCallbackGenerator;
117
- getDeleteCallback?: (origIndex: number) => () => void;
118
- }