@absreim/react-bootstrap-data-grid-pro 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +6 -0
  3. package/grid/Grid.d.ts +5 -0
  4. package/grid/Grid.js +56 -0
  5. package/grid/InternalGrid.d.ts +19 -0
  6. package/grid/InternalGrid.js +57 -0
  7. package/grid/editing/EditControlsCell.d.ts +17 -0
  8. package/grid/editing/EditControlsCell.js +19 -0
  9. package/grid/editing/EditableRow.d.ts +22 -0
  10. package/grid/editing/EditableRow.js +68 -0
  11. package/grid/editing/inputStrsToRowData.d.ts +3 -0
  12. package/grid/editing/inputStrsToRowData.js +18 -0
  13. package/grid/editing/types.d.ts +16 -0
  14. package/grid/editing/types.js +1 -0
  15. package/grid/export/ExportForm.d.ts +9 -0
  16. package/grid/export/ExportForm.js +97 -0
  17. package/grid/export/types.d.ts +5 -0
  18. package/grid/export/types.js +1 -0
  19. package/grid/export/useExportFn.d.ts +23 -0
  20. package/grid/export/useExportFn.js +115 -0
  21. package/grid/filtering/DateFilterRow.d.ts +16 -0
  22. package/grid/filtering/DateFilterRow.js +45 -0
  23. package/grid/filtering/FilterOptionsTable.d.ts +11 -0
  24. package/grid/filtering/FilterOptionsTable.js +117 -0
  25. package/grid/filtering/FilterRow.d.ts +19 -0
  26. package/grid/filtering/FilterRow.js +18 -0
  27. package/grid/filtering/NumberFilterRow.d.ts +14 -0
  28. package/grid/filtering/NumberFilterRow.js +35 -0
  29. package/grid/filtering/StringFilterRow.d.ts +14 -0
  30. package/grid/filtering/StringFilterRow.js +35 -0
  31. package/grid/filtering/types.d.ts +70 -0
  32. package/grid/filtering/types.js +30 -0
  33. package/grid/filtering/useFilterFormState.d.ts +3 -0
  34. package/grid/filtering/useFilterFormState.js +72 -0
  35. package/grid/index.d.ts +10 -0
  36. package/grid/index.js +10 -0
  37. package/grid/main/BodyRows.d.ts +19 -0
  38. package/grid/main/BodyRows.js +18 -0
  39. package/grid/main/ColHeaderCell/index.d.ts +4 -0
  40. package/grid/main/ColHeaderCell/index.js +16 -0
  41. package/grid/main/ColHeaderCell/useSortHeaderStates.d.ts +9 -0
  42. package/grid/main/ColHeaderCell/useSortHeaderStates.js +54 -0
  43. package/grid/main/ToggleButton.d.ts +9 -0
  44. package/grid/main/ToggleButton.js +14 -0
  45. package/grid/pagination/PageSelector.d.ts +24 -0
  46. package/grid/pagination/PageSelector.js +92 -0
  47. package/grid/pagination/PageSizeSelector.d.ts +10 -0
  48. package/grid/pagination/PageSizeSelector.js +15 -0
  49. package/grid/pagination/Pagination.d.ts +9 -0
  50. package/grid/pagination/Pagination.js +24 -0
  51. package/grid/pagination/types.d.ts +22 -0
  52. package/grid/pagination/types.js +1 -0
  53. package/grid/pipeline/types.d.ts +1 -0
  54. package/grid/pipeline/types.js +1 -0
  55. package/grid/pipeline/useAugFormattedRows.d.ts +4 -0
  56. package/grid/pipeline/useAugFormattedRows.js +22 -0
  57. package/grid/pipeline/useCombinedPipeline/index.d.ts +19 -0
  58. package/grid/pipeline/useCombinedPipeline/index.js +31 -0
  59. package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +8 -0
  60. package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.js +52 -0
  61. package/grid/pipeline/useCombinedPipeline/useDisplayRows.d.ts +3 -0
  62. package/grid/pipeline/useCombinedPipeline/useDisplayRows.js +60 -0
  63. package/grid/pipeline/useCombinedPipeline/useFilter.d.ts +4 -0
  64. package/grid/pipeline/useCombinedPipeline/useFilter.js +84 -0
  65. package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +4 -0
  66. package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.js +18 -0
  67. package/grid/pipeline/useCombinedPipeline/useFilterStateStore.d.ts +4 -0
  68. package/grid/pipeline/useCombinedPipeline/useFilterStateStore.js +57 -0
  69. package/grid/pipeline/useCombinedPipeline/useSortedRows.d.ts +10 -0
  70. package/grid/pipeline/useCombinedPipeline/useSortedRows.js +58 -0
  71. package/grid/pipeline/useGetInputStrSubmitCallback.d.ts +5 -0
  72. package/grid/pipeline/useGetInputStrSubmitCallback.js +13 -0
  73. package/grid/pipeline/useGridSelectionFns.d.ts +16 -0
  74. package/grid/pipeline/useGridSelectionFns.js +131 -0
  75. package/grid/pipeline/useUnwrappedGridStyles.d.ts +7 -0
  76. package/grid/pipeline/useUnwrappedGridStyles.js +17 -0
  77. package/grid/selection/SelectAllHeaderCell.d.ts +11 -0
  78. package/grid/selection/SelectAllHeaderCell.js +55 -0
  79. package/grid/selection/SelectionInput.d.ts +19 -0
  80. package/grid/selection/SelectionInput.js +23 -0
  81. package/grid/selection/types.d.ts +30 -0
  82. package/grid/selection/types.js +4 -0
  83. package/grid/sorting/arrowPlaceholder.d.ts +2 -0
  84. package/grid/sorting/arrowPlaceholder.js +7 -0
  85. package/grid/sorting/downArrow.d.ts +2 -0
  86. package/grid/sorting/downArrow.js +3 -0
  87. package/grid/sorting/types.d.ts +19 -0
  88. package/grid/sorting/types.js +1 -0
  89. package/grid/sorting/upArrow.d.ts +2 -0
  90. package/grid/sorting/upArrow.js +13 -0
  91. package/grid/styling/styleModelUnwrappers.d.ts +4 -0
  92. package/grid/styling/styleModelUnwrappers.js +58 -0
  93. package/grid/styling/types.d.ts +62 -0
  94. package/grid/styling/types.js +1 -0
  95. package/grid/toolbar/Toolbar.d.ts +12 -0
  96. package/grid/toolbar/Toolbar.js +26 -0
  97. package/grid/toolbar/ToolbarContainer.d.ts +9 -0
  98. package/grid/toolbar/ToolbarContainer.js +24 -0
  99. package/grid/toolbar/types.d.ts +3 -0
  100. package/grid/toolbar/types.js +1 -0
  101. package/grid/toolbar/useInterfaces.d.ts +9 -0
  102. package/grid/toolbar/useInterfaces.js +23 -0
  103. package/grid/types.d.ts +63 -0
  104. package/grid/types.js +1 -0
  105. package/grid/util/datetime.d.ts +2 -0
  106. package/grid/util/datetime.js +5 -0
  107. package/grid/util/getWidthStyle.d.ts +3 -0
  108. package/grid/util/getWidthStyle.js +9 -0
  109. package/grid/util/isSubset.d.ts +2 -0
  110. package/grid/util/isSubset.js +11 -0
  111. package/grid/util/useControlledHover.d.ts +9 -0
  112. package/grid/util/useControlledHover.js +13 -0
  113. package/grid-pro/ColHeaderCellPro.d.ts +4 -0
  114. package/grid-pro/ColHeaderCellPro.js +140 -0
  115. package/grid-pro/GridPro.d.ts +4 -0
  116. package/grid-pro/GridPro.js +56 -0
  117. package/grid-pro/index.d.ts +3 -0
  118. package/grid-pro/index.js +3 -0
  119. package/grid-pro/resize/types.d.ts +5 -0
  120. package/grid-pro/resize/types.js +1 -0
  121. package/grid-pro/resize/useResizeModel.d.ts +5 -0
  122. package/grid-pro/resize/useResizeModel.js +65 -0
  123. package/grid-pro/types.d.ts +18 -0
  124. package/grid-pro/types.js +1 -0
  125. package/package.json +34 -0
  126. package/style.css +1 -0
@@ -0,0 +1,45 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useId } from "react";
14
+ import { dateFilterSchemeNames, } from "./types";
15
+ import FilterRow from "./FilterRow";
16
+ import classNames from "classnames";
17
+ var DateFilterRow = function (_a) {
18
+ var ariaRowIndex = _a.ariaRowIndex, includeTime = _a.includeTime, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState, schemeSelectClasses = _a.schemeSelectClasses, enableInputClasses = _a.enableInputClasses, startDateInputClasses = _a.startDateInputClasses, endDateInputClasses = _a.endDateInputClasses, tdClasses = _a.tdClasses, trClasses = _a.trClasses;
19
+ var handleOpChange = function (_a) {
20
+ var target = _a.target;
21
+ setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
22
+ };
23
+ var handleEnabledChange = function (_a) {
24
+ var target = _a.target;
25
+ setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
26
+ };
27
+ var handleStartValueChange = function (_a) {
28
+ var target = _a.target;
29
+ setFilterState(__assign(__assign({}, filterState), { startDate: target.value }));
30
+ };
31
+ var handleEndValueChange = function (_a) {
32
+ var target = _a.target;
33
+ setFilterState(__assign(__assign({}, filterState), { endDate: target.value }));
34
+ };
35
+ var enabled = filterState.enabled, scheme = filterState.scheme, startDate = filterState.startDate, endDate = filterState.endDate;
36
+ var inputType = includeTime ? "datetime-local" : "date";
37
+ var inputId = useId();
38
+ var startDateInputId = "$startDate-".concat(inputId);
39
+ var endDateInputId = "$endDate-".concat(inputId);
40
+ var startDateInputLabel = "".concat(columnLabel, " Column Filter Start Date");
41
+ var endDateInputLabel = "".concat(columnLabel, " Column Filter End Date");
42
+ var searchStringInputCellContents = (_jsxs(_Fragment, { children: [scheme !== "endAt" && (_jsxs(_Fragment, { children: [scheme === "between" && (_jsx("label", { htmlFor: startDateInputId, children: "Start Date" })), _jsx("input", { id: startDateInputId, className: classNames("form-control", startDateInputClasses), type: inputType, required: enabled, disabled: !enabled, value: startDate, onChange: handleStartValueChange, "aria-label": startDateInputLabel })] })), scheme !== "startFrom" && (_jsxs(_Fragment, { children: [scheme === "between" && (_jsx("label", { htmlFor: endDateInputId, children: "End Date" })), _jsx("input", { id: endDateInputId, className: classNames("form-control", endDateInputClasses), type: inputType, required: enabled, disabled: !enabled, value: endDate, onChange: handleEndValueChange, "aria-label": endDateInputLabel })] }))] }));
43
+ return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: filterState.type === "date" ? "Date" : "Datetime", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: dateFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
44
+ };
45
+ export default DateFilterRow;
@@ -0,0 +1,11 @@
1
+ import { FC } from "react";
2
+ import { EditableTableFilterState, TableFilterState } from "./types";
3
+ import { FilterInputTableStyleModel } from "../styling/types";
4
+ export interface FilterOptionsTableProps {
5
+ filterState: TableFilterState;
6
+ setFilterState: (filterState: EditableTableFilterState) => void;
7
+ caption?: string;
8
+ styleModel?: FilterInputTableStyleModel;
9
+ }
10
+ declare const FilterOptionsTable: FC<FilterOptionsTableProps>;
11
+ export default FilterOptionsTable;
@@ -0,0 +1,117 @@
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ import { useMemo, useState } from "react";
23
+ import StringFilterRow from "./StringFilterRow";
24
+ import NumberFilterRow from "./NumberFilterRow";
25
+ import useFilterFormState from "./useFilterFormState";
26
+ import DateFilterRow from "./DateFilterRow";
27
+ import classNames from "classnames";
28
+ import { unwrapFilterInputTableStyleModel } from "../styling/styleModelUnwrappers";
29
+ var convertFilterFormStateToEditableState = function (filterFormState) {
30
+ return Object.keys(filterFormState).reduce(function (editableState, colName) {
31
+ var rowFilterFormState = filterFormState[colName];
32
+ switch (rowFilterFormState.type) {
33
+ case "string": {
34
+ editableState[colName] = __assign({}, rowFilterFormState);
35
+ break;
36
+ }
37
+ case "number": {
38
+ editableState[colName] = {
39
+ type: rowFilterFormState.type,
40
+ enabled: rowFilterFormState.enabled,
41
+ scheme: rowFilterFormState.scheme,
42
+ numValue: rowFilterFormState.inputValue === ""
43
+ ? null
44
+ : Number(rowFilterFormState.inputValue),
45
+ };
46
+ break;
47
+ }
48
+ default: {
49
+ // date or datetime
50
+ var partialFilterState = {
51
+ type: rowFilterFormState.type,
52
+ enabled: rowFilterFormState.enabled,
53
+ };
54
+ var inputStrToDate = function (str) {
55
+ return str === "" ? null : new Date(str);
56
+ };
57
+ switch (rowFilterFormState.scheme) {
58
+ case "startFrom": {
59
+ editableState[colName] = __assign(__assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, startDate: inputStrToDate(rowFilterFormState.startDate) });
60
+ break;
61
+ }
62
+ case "endAt": {
63
+ editableState[colName] = __assign(__assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, endDate: inputStrToDate(rowFilterFormState.endDate) });
64
+ break;
65
+ }
66
+ default: {
67
+ editableState[colName] = __assign(__assign({}, partialFilterState), { scheme: rowFilterFormState.scheme, startDate: inputStrToDate(rowFilterFormState.startDate), endDate: inputStrToDate(rowFilterFormState.endDate) });
68
+ }
69
+ }
70
+ }
71
+ }
72
+ return editableState;
73
+ }, {});
74
+ };
75
+ var FilterOptionsTable = function (_a) {
76
+ var filterState = _a.filterState, setFilterState = _a.setFilterState, caption = _a.caption, styleModel = _a.styleModel;
77
+ var formFilterState = useFilterFormState(filterState);
78
+ var _b = useState(formFilterState), formState = _b[0], setFormState = _b[1];
79
+ var unwrappedStyleModel = useMemo(function () { return unwrapFilterInputTableStyleModel(styleModel); }, [styleModel]);
80
+ var getRows = function () {
81
+ return Object.keys(formState).map(function (colName, index) {
82
+ function getColStateSetter(colName) {
83
+ return function (rowState) {
84
+ var _a;
85
+ return setFormState(__assign(__assign({}, formState), (_a = {}, _a[colName] = rowState, _a)));
86
+ };
87
+ }
88
+ var colLabel = filterState[colName].label;
89
+ var colFilterState = formState[colName];
90
+ switch (colFilterState.type) {
91
+ case "string": {
92
+ return (_jsx(StringFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), searchStringInputClasses: unwrappedStyleModel.searchStringInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: function (colIndex) {
93
+ return unwrappedStyleModel.tbodyTd(index, colIndex);
94
+ } }, colName));
95
+ }
96
+ case "number": {
97
+ return (_jsx(NumberFilterRow, { ariaRowIndex: index + 2, columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), numberInputClasses: unwrappedStyleModel.numberInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: function (colIndex) {
98
+ return unwrappedStyleModel.tbodyTd(index, colIndex);
99
+ } }, colName));
100
+ }
101
+ default: {
102
+ // date or datetime
103
+ return (_jsx(DateFilterRow, { ariaRowIndex: index + 2, includeTime: colFilterState.type === "datetime", columnLabel: colLabel, filterState: colFilterState, setFilterState: getColStateSetter(colName), schemeSelectClasses: unwrappedStyleModel.schemeSelectionInput(index), enableInputClasses: unwrappedStyleModel.enablementInput(index), startDateInputClasses: unwrappedStyleModel.startDateInput(index), endDateInputClasses: unwrappedStyleModel.endDateInput(index), trClasses: unwrappedStyleModel.tbodyTr(index), tdClasses: function (colIndex) {
104
+ return unwrappedStyleModel.tbodyTd(index, colIndex);
105
+ } }, colName));
106
+ }
107
+ }
108
+ });
109
+ };
110
+ var onSubmit = function (event) {
111
+ event.preventDefault();
112
+ var editableTableFilterState = convertFilterFormStateToEditableState(formState);
113
+ setFilterState(editableTableFilterState);
114
+ };
115
+ return (_jsxs("form", { onSubmit: onSubmit, className: classNames(styleModel === null || styleModel === void 0 ? void 0 : styleModel.form), children: [_jsxs("table", { className: classNames.apply(void 0, __spreadArray(["table"], unwrappedStyleModel.table, false)), children: [caption && (_jsx("caption", { className: classNames(unwrappedStyleModel.caption), children: caption })), _jsx("thead", { className: classNames.apply(void 0, unwrappedStyleModel.thead), children: _jsx("tr", { className: classNames.apply(void 0, unwrappedStyleModel.theadTr), children: ["Enabled", "Column", "Type", "Operator", "Value"].map(function (colName, index) { return (_jsx("th", { className: classNames.apply(void 0, unwrappedStyleModel.theadTh(index)), children: colName }, index)); }) }) }), _jsx("tbody", { className: classNames.apply(void 0, unwrappedStyleModel.tbody), children: getRows() })] }), _jsx("button", { className: classNames("btn", { "btn-secondary": unwrappedStyleModel.submitButton.length === 0 }, unwrappedStyleModel.submitButton), type: "submit", children: "Submit" })] }));
116
+ };
117
+ export default FilterOptionsTable;
@@ -0,0 +1,19 @@
1
+ import { ChangeEventHandler, ReactNode } from "react";
2
+ export interface FilterRowProps<FilterScheme extends string> {
3
+ ariaRowIndex: number;
4
+ columnLabel: string;
5
+ typeLabel: string;
6
+ enabled: boolean;
7
+ enabledChangeHandler: ChangeEventHandler<HTMLInputElement>;
8
+ currentScheme: string;
9
+ handleSchemeChange: ChangeEventHandler<HTMLSelectElement>;
10
+ schemesToLabels: Record<FilterScheme, string>;
11
+ searchStringInputCellContents: ReactNode;
12
+ trClasses: string[];
13
+ tdClasses: (colIndex: number) => string[];
14
+ inputClasses: string[];
15
+ selectClasses: string[];
16
+ }
17
+ export type CommonFilterRowStyleProps = Pick<FilterRowProps<string>, "trClasses" | "tdClasses">;
18
+ export declare function FilterRow<FilterScheme extends string = string>(props: FilterRowProps<FilterScheme>): ReactNode;
19
+ export default FilterRow;
@@ -0,0 +1,18 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import classNames from "classnames";
12
+ export function FilterRow(props) {
13
+ var ariaRowIndex = props.ariaRowIndex, columnLabel = props.columnLabel, typeLabel = props.typeLabel, enabled = props.enabled, enabledChangeHandler = props.enabledChangeHandler, currentScheme = props.currentScheme, handleSchemeChange = props.handleSchemeChange, schemesToLabels = props.schemesToLabels, searchStringInputCellContents = props.searchStringInputCellContents, trClasses = props.trClasses, tdClasses = props.tdClasses, inputClasses = props.inputClasses, selectClasses = props.selectClasses;
14
+ var checkboxLabel = "".concat(columnLabel, " Column Filter Toggle");
15
+ var opSelectLabel = "".concat(columnLabel, " Column Filter Operator Selection");
16
+ return (_jsxs("tr", { className: classNames(trClasses), "aria-rowindex": ariaRowIndex, children: [_jsx("td", { className: classNames(tdClasses(0)), "aria-colindex": 1, children: _jsx("input", { className: classNames(inputClasses), name: checkboxLabel, "aria-label": checkboxLabel, type: "checkbox", checked: enabled, onChange: enabledChangeHandler }) }), _jsx("td", { className: classNames(tdClasses(1)), "aria-colindex": 2, children: columnLabel }), _jsx("td", { className: classNames(tdClasses(2)), "aria-colindex": 3, children: typeLabel }), _jsx("td", { className: classNames(tdClasses(3)), "aria-colindex": 4, children: _jsx("select", { name: opSelectLabel, "aria-label": opSelectLabel, disabled: !enabled, className: classNames.apply(void 0, __spreadArray(["form-select"], selectClasses, false)), value: currentScheme, onChange: handleSchemeChange, children: Object.keys(schemesToLabels).map(function (scheme) { return (_jsx("option", { value: scheme, children: schemesToLabels[scheme] }, scheme)); }) }) }), _jsx("td", { className: classNames(tdClasses(4)), "aria-colindex": 5, children: searchStringInputCellContents })] }));
17
+ }
18
+ export default FilterRow;
@@ -0,0 +1,14 @@
1
+ import { FC } from "react";
2
+ import { NumberFormFilterState } from "./types";
3
+ import { CommonFilterRowStyleProps } from "./FilterRow";
4
+ export type NumberFilterRowProps = {
5
+ ariaRowIndex: number;
6
+ columnLabel: string;
7
+ filterState: NumberFormFilterState;
8
+ setFilterState: (filterState: NumberFormFilterState) => void;
9
+ schemeSelectClasses: string[];
10
+ enableInputClasses: string[];
11
+ numberInputClasses: string[];
12
+ } & CommonFilterRowStyleProps;
13
+ declare const NumberFilterRow: FC<NumberFilterRowProps>;
14
+ export default NumberFilterRow;
@@ -0,0 +1,35 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { numberFilterSchemeNames, } from "./types";
14
+ import FilterRow from "./FilterRow";
15
+ import classNames from "classnames";
16
+ var NumberFilterRow = function (_a) {
17
+ var ariaRowIndex = _a.ariaRowIndex, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState, schemeSelectClasses = _a.schemeSelectClasses, enableInputClasses = _a.enableInputClasses, numberInputClasses = _a.numberInputClasses, tdClasses = _a.tdClasses, trClasses = _a.trClasses;
18
+ var handleOpChange = function (_a) {
19
+ var target = _a.target;
20
+ setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
21
+ };
22
+ var handleEnabledChange = function (_a) {
23
+ var target = _a.target;
24
+ setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
25
+ };
26
+ var handleNumInputValueChange = function (_a) {
27
+ var target = _a.target;
28
+ setFilterState(__assign(__assign({}, filterState), { inputValue: target.value }));
29
+ };
30
+ var enabled = filterState.enabled, scheme = filterState.scheme, inputValue = filterState.inputValue;
31
+ var valueInputLabel = "".concat(columnLabel, " Column Filter Value");
32
+ var searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control", numberInputClasses), type: "number", required: enabled, disabled: !enabled, value: inputValue, onChange: handleNumInputValueChange }));
33
+ return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: "Number", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: numberFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
34
+ };
35
+ export default NumberFilterRow;
@@ -0,0 +1,14 @@
1
+ import { FC } from "react";
2
+ import { CommonFilterRowStyleProps } from "./FilterRow";
3
+ import { StringFilterState } from "./types";
4
+ type StringFilterRowProps = {
5
+ ariaRowIndex: number;
6
+ columnLabel: string;
7
+ filterState: StringFilterState;
8
+ setFilterState: (filterState: StringFilterState) => void;
9
+ schemeSelectClasses: string[];
10
+ enableInputClasses: string[];
11
+ searchStringInputClasses: string[];
12
+ } & CommonFilterRowStyleProps;
13
+ declare const StringFilterRow: FC<StringFilterRowProps>;
14
+ export default StringFilterRow;
@@ -0,0 +1,35 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import FilterRow from "./FilterRow";
14
+ import classNames from "classnames";
15
+ import { stringFilterSchemeNames, } from "./types";
16
+ var StringFilterRow = function (_a) {
17
+ var ariaRowIndex = _a.ariaRowIndex, columnLabel = _a.columnLabel, filterState = _a.filterState, setFilterState = _a.setFilterState, schemeSelectClasses = _a.schemeSelectClasses, enableInputClasses = _a.enableInputClasses, searchStringInputClasses = _a.searchStringInputClasses, tdClasses = _a.tdClasses, trClasses = _a.trClasses;
18
+ var handleOpChange = function (_a) {
19
+ var target = _a.target;
20
+ setFilterState(__assign(__assign({}, filterState), { scheme: target.value }));
21
+ };
22
+ var handleEnabledChange = function (_a) {
23
+ var target = _a.target;
24
+ setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
25
+ };
26
+ var handleSearchStringChange = function (_a) {
27
+ var target = _a.target;
28
+ setFilterState(__assign(__assign({}, filterState), { searchString: target.value }));
29
+ };
30
+ var enabled = filterState.enabled, scheme = filterState.scheme, searchString = filterState.searchString;
31
+ var valueInputLabel = "".concat(columnLabel, " Column Filter Value");
32
+ var searchStringInputCellContents = (_jsx("input", { name: valueInputLabel, "aria-label": valueInputLabel, className: classNames("form-control", searchStringInputClasses), required: enabled, disabled: !enabled, value: searchString, onChange: handleSearchStringChange }));
33
+ return (_jsx(FilterRow, { ariaRowIndex: ariaRowIndex, columnLabel: columnLabel, typeLabel: "String", enabled: enabled, enabledChangeHandler: handleEnabledChange, currentScheme: scheme, handleSchemeChange: handleOpChange, schemesToLabels: stringFilterSchemeNames, searchStringInputCellContents: searchStringInputCellContents, trClasses: trClasses, tdClasses: tdClasses, inputClasses: enableInputClasses, selectClasses: schemeSelectClasses }));
34
+ };
35
+ export default StringFilterRow;
@@ -0,0 +1,70 @@
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 ControlledFilterModel {
49
+ type?: "controlled";
50
+ tableFilterState: EditableTableFilterState;
51
+ setTableFilterState: (state: EditableTableFilterState) => void;
52
+ filterTableCaption?: string;
53
+ }
54
+ export type UncontrolledFilterModel = Partial<Pick<ControlledFilterModel, "tableFilterState" | "filterTableCaption">> & {
55
+ type: "uncontrolled";
56
+ };
57
+ export type NormalizedTableFilterModel = Pick<ControlledFilterModel, "tableFilterState" | "setTableFilterState">;
58
+ export interface NumberFormFilterState extends AbstractFilterState {
59
+ type: "number";
60
+ scheme: NumberFilterScheme;
61
+ inputValue: string;
62
+ }
63
+ export type FilterModel = ControlledFilterModel | UncontrolledFilterModel;
64
+ export interface DateFormFilterState extends AbstractDateFilterState {
65
+ scheme: DateFilterScheme;
66
+ startDate: string;
67
+ endDate: string;
68
+ }
69
+ export type FilterFormRowState = StringFilterState | NumberFormFilterState | DateFormFilterState;
70
+ export type FilterFormState = Record<string, FilterFormRowState>;
@@ -0,0 +1,30 @@
1
+ export var stringFilterSchemes = [
2
+ "contains",
3
+ "startsWith",
4
+ "endsWith",
5
+ ];
6
+ export var stringFilterSchemeNames = {
7
+ contains: "Contains",
8
+ startsWith: "Starts With",
9
+ endsWith: "Ends With",
10
+ };
11
+ export var numberFilterSchemes = [
12
+ "equals",
13
+ "greaterThan",
14
+ "lessThan",
15
+ "greaterOrEqual",
16
+ "lessOrEqual",
17
+ ];
18
+ export var numberFilterSchemeNames = {
19
+ equals: "=",
20
+ greaterThan: ">",
21
+ lessThan: "<",
22
+ greaterOrEqual: ">=",
23
+ lessOrEqual: "<=",
24
+ };
25
+ export var dateFilterSchemes = ["startFrom", "endAt", "between"];
26
+ export var dateFilterSchemeNames = {
27
+ startFrom: "Start Form",
28
+ endAt: "End At",
29
+ between: "Between",
30
+ };
@@ -0,0 +1,3 @@
1
+ import { FilterFormState, TableFilterState } from "./types";
2
+ declare const useFilterFormState: (tableFilterState: TableFilterState) => FilterFormState;
3
+ export default useFilterFormState;
@@ -0,0 +1,72 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { useMemo } from "react";
13
+ import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
14
+ var useFilterFormState = function (tableFilterState) {
15
+ return useMemo(function () {
16
+ return Object.keys(tableFilterState).reduce(function (filterFormState, colName) {
17
+ var editableState = tableFilterState[colName].editableState;
18
+ switch (editableState.type) {
19
+ case "string": {
20
+ filterFormState[colName] = __assign({}, editableState);
21
+ break;
22
+ }
23
+ case "number": {
24
+ filterFormState[colName] = {
25
+ type: "number",
26
+ scheme: editableState.scheme,
27
+ enabled: editableState.enabled,
28
+ inputValue: editableState.numValue === null
29
+ ? ""
30
+ : String(editableState.numValue),
31
+ };
32
+ break;
33
+ }
34
+ default: {
35
+ // date or datetime
36
+ var partialFormState = {
37
+ type: editableState.type,
38
+ enabled: editableState.enabled,
39
+ };
40
+ var dateToStrConverter = editableState.type === "date"
41
+ ? dateToInputStr
42
+ : dateToDatetimeInputStr;
43
+ switch (editableState.scheme) {
44
+ case "startFrom": {
45
+ filterFormState[colName] = __assign(__assign({}, partialFormState), { scheme: "startFrom", startDate: editableState.startDate === null
46
+ ? ""
47
+ : dateToStrConverter(editableState.startDate), endDate: "" });
48
+ break;
49
+ }
50
+ case "endAt": {
51
+ filterFormState[colName] = __assign(__assign({}, partialFormState), { scheme: "endAt", startDate: "", endDate: editableState.endDate === null
52
+ ? ""
53
+ : dateToStrConverter(editableState.endDate) });
54
+ break;
55
+ }
56
+ default: {
57
+ // between
58
+ filterFormState[colName] = __assign(__assign({}, partialFormState), { scheme: "between", startDate: editableState.startDate === null
59
+ ? ""
60
+ : dateToStrConverter(editableState.startDate), endDate: editableState.endDate === null
61
+ ? ""
62
+ : dateToStrConverter(editableState.endDate) });
63
+ break;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ return filterFormState;
69
+ }, {});
70
+ }, [tableFilterState]);
71
+ };
72
+ export default useFilterFormState;
@@ -0,0 +1,10 @@
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";
8
+ export * from "./Grid";
9
+ export * from "./util/datetime";
10
+ export { default } from "./Grid";
package/grid/index.js ADDED
@@ -0,0 +1,10 @@
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";
8
+ export * from "./Grid";
9
+ export * from "./util/datetime";
10
+ export { default } from "./Grid";
@@ -0,0 +1,19 @@
1
+ import { AugFormattedRow } from "../types";
2
+ import { FC } from "react";
3
+ import { UseGridSelectionFnsHook } from "../pipeline/useGridSelectionFns";
4
+ import { UseUnwrappedGridStylesHook } from "../pipeline/useUnwrappedGridStyles";
5
+ import { UseCombinedPipelineHook } from "../pipeline/useCombinedPipeline";
6
+ import { SelectModel } from "../selection/types";
7
+ import { EditModel } from "../editing/types";
8
+ import { UseGetInputStrSubmitCallbackHook } from "../pipeline/useGetInputStrSubmitCallback";
9
+ interface BodyRowsProps {
10
+ augFormattedRows: AugFormattedRow[];
11
+ gridSelectionFns: UseGridSelectionFnsHook;
12
+ unwrappedStyles: UseUnwrappedGridStylesHook;
13
+ combinedPipelineOutput: UseCombinedPipelineHook;
14
+ selectModel: SelectModel | undefined;
15
+ editModel: EditModel | undefined;
16
+ getInputStrSubmitCallback: UseGetInputStrSubmitCallbackHook;
17
+ }
18
+ declare const BodyRows: FC<BodyRowsProps>;
19
+ export default BodyRows;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import EditableRow from "../editing/EditableRow";
3
+ import classNames from "classnames";
4
+ import getWidthStyle from "../util/getWidthStyle";
5
+ import SelectionInput from "../selection/SelectionInput";
6
+ var BodyRows = function (_a) {
7
+ var augFormattedRows = _a.augFormattedRows, _b = _a.gridSelectionFns, selectedSet = _b.selectedSet, getSelectInputModel = _b.getSelectInputModel, getSelectHandler = _b.getSelectHandler, getRowClickHandler = _b.getRowClickHandler, getAriaSelectedValue = _b.getAriaSelectedValue, unwrappedTableModel = _a.unwrappedStyles.unwrappedTableModel, _c = _a.combinedPipelineOutput, showSelectCol = _c.showSelectCol, ariaColIndexOffset = _c.ariaColIndexOffset, selectModel = _a.selectModel, editModel = _a.editModel, getInputStrSubmitCallback = _a.getInputStrSubmitCallback;
8
+ return augFormattedRows.map(function (row, index) {
9
+ return (_jsx(EditableRow, { onClick: getRowClickHandler(row.id), className: classNames({
10
+ "table-active": selectedSet.has(row.id),
11
+ }, unwrappedTableModel.tbodyTr(row.id, index)), "aria-rowindex": index + 2, dataRowId: row.id, "aria-selected": getAriaSelectedValue(row.id), ariaColIndexOffset: ariaColIndexOffset, cellData: row.contents, updateCallback: getInputStrSubmitCallback && getInputStrSubmitCallback(row.id), deleteCallback: (editModel === null || editModel === void 0 ? void 0 : editModel.getDeleteCallback) && editModel.getDeleteCallback(row.id), dataCellClasses: function (colIndex) {
12
+ return unwrappedTableModel.tbodyTd(row.id, index, colIndex);
13
+ }, dataCellInputClasses: function (colIndex) {
14
+ return unwrappedTableModel.tbodyTdInput(row.id, index, colIndex);
15
+ }, editCellClasses: unwrappedTableModel.editColTd(row.id, index), saveButtonClasses: unwrappedTableModel.editSaveButton(row.id, index), deleteButtonClasses: unwrappedTableModel.editDeleteButton(row.id, index), startButtonClasses: unwrappedTableModel.editStartButton(row.id, index), cancelButtonClasses: unwrappedTableModel.editCancelButton(row.id, index), children: showSelectCol && (_jsx("td", { className: classNames(unwrappedTableModel.rowSelectColTd(row.id, index)), "aria-colindex": 1, style: getWidthStyle(selectModel.selectColWidth), children: _jsx(SelectionInput, { selected: selectedSet.has(row.id), selectionInputModel: getSelectInputModel(row.id, selectModel), selectCallback: getSelectHandler(row.id), additionalClasses: unwrappedTableModel.rowSelectInput(row.id, index) }) })) }, row.id));
16
+ });
17
+ };
18
+ export default BodyRows;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { ColHeaderCellProps } from "../../types";
3
+ declare const ColHeaderCell: FC<ColHeaderCellProps>;
4
+ export default ColHeaderCell;
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsxs as _jsxs } from "react/jsx-runtime";
3
+ import classNames from "classnames";
4
+ import getWidthStyle from "../../util/getWidthStyle";
5
+ import useSortHeaderStates from "./useSortHeaderStates";
6
+ var ColHeaderCell = function (_a) {
7
+ var label = _a.label, sortModel = _a.sortModel, ariaColIndex = _a.ariaColIndex, additionalClasses = _a.additionalClasses, width = _a.width;
8
+ var _b = useSortHeaderStates(sortModel), handleClick = _b.handleClick, handleMouseOver = _b.handleMouseOver, handleMouseOut = _b.handleMouseOut, sortSymbol = _b.sortSymbol;
9
+ return (_jsxs("th", { className: classNames({
10
+ "rbdg-clickable-grid-header-cell": sortModel,
11
+ "table-active": sortModel === null || sortModel === void 0 ? void 0 : sortModel.sortOrder,
12
+ }, additionalClasses || []), onClick: sortModel && handleClick, onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, "aria-description": sortModel
13
+ ? "Column header"
14
+ : "Column header that can be clicked to change the sorting mode", "aria-colindex": ariaColIndex, style: getWidthStyle(width), children: [label, sortSymbol] }));
15
+ };
16
+ export default ColHeaderCell;
@@ -0,0 +1,9 @@
1
+ import { UseControlledHoverHook } from "../../util/useControlledHover";
2
+ import { ReactNode } from "react";
3
+ import { ColSortModel } from "../../sorting/types";
4
+ export type UseSortHeaderStatesHook = UseControlledHoverHook<HTMLTableCellElement> & {
5
+ handleClick: () => void;
6
+ sortSymbol: ReactNode;
7
+ };
8
+ declare const useSortHeaderStates: (sortModel: ColSortModel | undefined) => UseSortHeaderStatesHook;
9
+ export default useSortHeaderStates;