@absreim/react-bootstrap-data-grid-pro 2.4.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/grid/Grid.js +26 -30
  2. package/grid/InternalGrid.d.ts +1 -0
  3. package/grid/InternalGrid.js +17 -18
  4. package/grid/editing/EditControlsCell.js +3 -4
  5. package/grid/editing/EditableRow.js +11 -17
  6. package/grid/editing/inputStrsToRowData.js +4 -4
  7. package/grid/export/ExportForm.js +25 -49
  8. package/grid/export/useExportFn.js +34 -58
  9. package/grid/filtering/DateFilterRow.js +17 -33
  10. package/grid/filtering/FilterOptionsTable.js +60 -96
  11. package/grid/filtering/FilterRow.js +4 -13
  12. package/grid/filtering/NumberFilterRow.js +10 -25
  13. package/grid/filtering/StringFilterRow.js +10 -25
  14. package/grid/filtering/types.js +6 -6
  15. package/grid/filtering/useFilterFormState.js +52 -65
  16. package/grid/main/BodyRows.d.ts +3 -1
  17. package/grid/main/BodyRows.js +6 -13
  18. package/grid/main/ColHeaderCell/index.js +4 -4
  19. package/grid/main/ColHeaderCell/useSortHeaderStates.js +10 -10
  20. package/grid/main/ToggleButton.js +3 -4
  21. package/grid/pagination/PageSelector.js +17 -18
  22. package/grid/pagination/PageSizeSelector.js +5 -6
  23. package/grid/pagination/Pagination.js +6 -7
  24. package/grid/pipeline/useAugFormattedRows.js +5 -20
  25. package/grid/pipeline/useCombinedPipeline/index.d.ts +2 -2
  26. package/grid/pipeline/useCombinedPipeline/index.js +21 -22
  27. package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +3 -3
  28. package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.js +29 -24
  29. package/grid/pipeline/useCombinedPipeline/useDisplayRows.d.ts +2 -2
  30. package/grid/pipeline/useCombinedPipeline/useDisplayRows.js +40 -41
  31. package/grid/pipeline/useCombinedPipeline/useFilter.d.ts +2 -2
  32. package/grid/pipeline/useCombinedPipeline/useFilter.js +9 -9
  33. package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.js +5 -6
  34. package/grid/pipeline/useCombinedPipeline/useFilterStateStore.js +6 -7
  35. package/grid/pipeline/useCombinedPipeline/useSortedRows.d.ts +3 -3
  36. package/grid/pipeline/useCombinedPipeline/useSortedRows.js +22 -27
  37. package/grid/pipeline/useGetInputStrSubmitCallback.js +6 -6
  38. package/grid/pipeline/useGridSelectionFns.js +30 -30
  39. package/grid/pipeline/useUnwrappedGridStyles.js +5 -7
  40. package/grid/selection/SelectAllHeaderCell.d.ts +1 -0
  41. package/grid/selection/SelectAllHeaderCell.js +9 -10
  42. package/grid/selection/SelectionInput.js +4 -6
  43. package/grid/sorting/arrowPlaceholder.js +1 -1
  44. package/grid/sorting/downArrow.js +1 -1
  45. package/grid/sorting/sortOrderToAriaSort.d.ts +4 -0
  46. package/grid/sorting/sortOrderToAriaSort.js +11 -0
  47. package/grid/sorting/upArrow.js +1 -10
  48. package/grid/styling/styleModelUnwrappers.js +22 -33
  49. package/grid/toolbar/Toolbar.js +61 -9
  50. package/grid/toolbar/ToolbarContainer.js +3 -6
  51. package/grid/toolbar/useInterfaces.js +5 -17
  52. package/grid/types.d.ts +9 -5
  53. package/grid/util/datetime.js +2 -4
  54. package/grid/util/getWidthStyle.js +6 -8
  55. package/grid/util/isSubset.js +3 -4
  56. package/grid/util/useControlledHover.js +8 -8
  57. package/grid-pro/ColHeaderCellPro.js +47 -42
  58. package/grid-pro/GridPro.js +42 -32
  59. package/grid-pro/assets/HorizontalGrip.d.ts +6 -0
  60. package/grid-pro/assets/HorizontalGrip.js +3 -0
  61. package/grid-pro/assets/VerticalGrip.d.ts +6 -0
  62. package/grid-pro/assets/VerticalGrip.js +3 -0
  63. package/grid-pro/index.d.ts +3 -0
  64. package/grid-pro/index.js +3 -0
  65. package/grid-pro/reorder/ReorderHandleCell.d.ts +12 -0
  66. package/grid-pro/reorder/ReorderHandleCell.js +220 -0
  67. package/grid-pro/reorder/ReorderHeaderCell.d.ts +3 -0
  68. package/grid-pro/reorder/ReorderHeaderCell.js +4 -0
  69. package/grid-pro/reorder/types.d.ts +12 -0
  70. package/grid-pro/reorder/types.js +1 -0
  71. package/grid-pro/resize/useResizeModel.js +40 -62
  72. package/grid-pro/types.d.ts +9 -2
  73. package/grid-pro/util/index.d.ts +1 -0
  74. package/grid-pro/util/index.js +1 -0
  75. package/grid-pro/util/regDragCleanup.d.ts +3 -0
  76. package/grid-pro/util/regDragCleanup.js +28 -0
  77. package/grid-pro/util/reorderRows.d.ts +3 -0
  78. package/grid-pro/util/reorderRows.js +17 -0
  79. package/grid-pro/util/types.d.ts +10 -0
  80. package/grid-pro/util/types.js +1 -0
  81. package/package.json +1 -1
  82. package/style.css +1 -1
package/grid/Grid.js CHANGED
@@ -9,48 +9,44 @@ import useUnwrappedGridStyles from "./pipeline/useUnwrappedGridStyles";
9
9
  import useGetInputStrSubmitCallback from "./pipeline/useGetInputStrSubmitCallback";
10
10
  import useAugFormattedRows from "./pipeline/useAugFormattedRows";
11
11
  import BodyRows from "./main/BodyRows";
12
- var Grid = function (props) {
13
- var rows = props.rows, cols = props.cols, filterModel = props.filterModel, sortModel = props.sortModel, pagination = props.pagination, selectModel = props.selectModel, styleModel = props.styleModel, editModel = props.editModel;
14
- var combinedPipelineOutput = useCombinedPipeline({
15
- rows: rows,
16
- cols: cols,
17
- filterModel: filterModel,
18
- sortModel: sortModel,
19
- pagination: pagination,
20
- selectModel: selectModel,
12
+ const Grid = (props) => {
13
+ const { rows, cols, filterModel, sortModel, pagination, selectModel, styleModel, editModel, } = props;
14
+ const combinedPipelineOutput = useCombinedPipeline({
15
+ rows,
16
+ cols,
17
+ filterModel,
18
+ sortModel,
19
+ pagination,
20
+ selectModel,
21
21
  });
22
- var _a = combinedPipelineOutput.sortedRowsOutput, sortColDef = _a.sortColDef, setSortColDef = _a.setSortColDef, sortingEnabled = _a.sortingEnabled, showSelectCol = combinedPipelineOutput.showSelectCol, displayRows = combinedPipelineOutput.displayRows;
23
- var gridSelectionFns = useGridSelectionFns(selectModel, rows);
24
- var unwrappedStyles = useUnwrappedGridStyles(styleModel);
25
- var getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
26
- var colNameToWidth = useMemo(function () {
27
- var map = {};
28
- cols.forEach(function (_a) {
29
- var name = _a.name, width = _a.width;
30
- return (map[name] = width);
31
- });
22
+ const { sortedRowsOutput: { sortColDef, setSortColDef, sortingEnabled }, showSelectCol, displayRows, } = combinedPipelineOutput;
23
+ const gridSelectionFns = useGridSelectionFns(selectModel, rows);
24
+ const unwrappedStyles = useUnwrappedGridStyles(styleModel);
25
+ const getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
26
+ const colNameToWidth = useMemo(() => {
27
+ const map = {};
28
+ cols.forEach(({ name, width }) => (map[name] = width));
32
29
  return map;
33
30
  }, [cols]);
34
- var augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
35
- var colHeaderCells = cols.map(function (_a, index) {
36
- var _b;
37
- var name = _a.name, label = _a.label, sortable = _a.sortable, width = _a.width;
38
- var colSortModel = sortingEnabled && sortable
31
+ const augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
32
+ const colHeaderCells = cols.map(({ name, label, sortable, width }, index) => {
33
+ var _a;
34
+ const colSortModel = sortingEnabled && sortable
39
35
  ? {
40
36
  sortOrder: (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === name ? sortColDef.order : null,
41
- setSortOrder: function (order) {
42
- setSortColDef && setSortColDef(order && { name: name, order: order });
37
+ setSortOrder: (order) => {
38
+ setSortColDef && setSortColDef(order && { name, order });
43
39
  },
44
40
  }
45
41
  : undefined;
46
- return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: ((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.theadTh) &&
42
+ return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: ((_a = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _a === void 0 ? void 0 : _a.theadTh) &&
47
43
  styleModel.mainTableStyleModel.theadTh(index), width: width }, name));
48
44
  });
49
- var bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel, unwrappedStyles: unwrappedStyles, combinedPipelineOutput: combinedPipelineOutput, editModel: editModel, getInputStrSubmitCallback: getInputStrSubmitCallback }));
45
+ const bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel, unwrappedStyles: unwrappedStyles, combinedPipelineOutput: combinedPipelineOutput, editModel: editModel, getInputStrSubmitCallback: getInputStrSubmitCallback }));
50
46
  return (_jsx(InternalGrid, { gridProps: props, hooks: {
51
47
  pipelineOutput: combinedPipelineOutput,
52
48
  selectFns: gridSelectionFns,
53
- unwrappedStyles: unwrappedStyles,
54
- }, slots: { colHeaderCells: colHeaderCells, bodyRows: bodyRows } }));
49
+ unwrappedStyles,
50
+ }, slots: { colHeaderCells, bodyRows } }));
55
51
  };
56
52
  export default Grid;
@@ -13,6 +13,7 @@ export interface InternalGridProps {
13
13
  slots: {
14
14
  colHeaderCells: ReactNode;
15
15
  bodyRows: ReactNode;
16
+ prefixHeader?: ReactNode;
16
17
  };
17
18
  }
18
19
  declare const InternalGrid: FC<InternalGridProps>;
@@ -10,18 +10,17 @@ import useInterfaces from "./toolbar/useInterfaces";
10
10
  import ToolbarContainer from "./toolbar/ToolbarContainer";
11
11
  import useExportFn from "./export/useExportFn";
12
12
  import getWidthStyle from "./util/getWidthStyle";
13
- var InternalGrid = function (_a) {
14
- var _b;
15
- var _c = _a.gridProps, rows = _c.rows, cols = _c.cols, pagination = _c.pagination, filterModel = _c.filterModel, selectModel = _c.selectModel, editModel = _c.editModel, caption = _c.caption, styleModel = _c.styleModel, useToolbar = _c.useToolbar, responsive = _c.responsive, displayMode = _c.displayMode, _d = _a.hooks, pipelineOutput = _d.pipelineOutput, selectFns = _d.selectFns, unwrappedStyles = _d.unwrappedStyles, _e = _a.slots, colHeaderCells = _e.colHeaderCells, bodyRows = _e.bodyRows;
16
- var normalizedTableFilterModel = pipelineOutput.normalizedTableFilterModel, filteredRows = pipelineOutput.filteredRows, filterState = pipelineOutput.filterState, sortedRows = pipelineOutput.sortedRowsOutput.sortedRows, _f = pipelineOutput.currentPageRowsOutput, paginatedRows = _f.paginatedRows, normalizedModel = _f.normalizedModel, showSelectCol = pipelineOutput.showSelectCol;
17
- var _g = useState(false), filterOptionsVisible = _g[0], setFilterOptionsVisible = _g[1];
18
- var exportFnInfo = useExportFn({
19
- rows: rows,
20
- cols: cols,
13
+ const InternalGrid = ({ gridProps: { rows, cols, pagination, filterModel, selectModel, editModel, caption, styleModel, useToolbar, responsive, displayMode, }, hooks: { pipelineOutput, selectFns, unwrappedStyles }, slots: { colHeaderCells, bodyRows, prefixHeader }, }) => {
14
+ var _a;
15
+ const { normalizedTableFilterModel, filteredRows, filterState, sortedRowsOutput: { sortedRows }, currentPageRowsOutput: { paginatedRows, normalizedModel }, showSelectCol, } = pipelineOutput;
16
+ const [filterOptionsVisible, setFilterOptionsVisible] = useState(false);
17
+ const exportFnInfo = useExportFn({
18
+ rows,
19
+ cols,
21
20
  filteredRows: filterModel && filteredRows,
22
21
  currentPageRows: pagination && paginatedRows,
23
22
  });
24
- var toolbarInterfaceParams = useMemo(function () { return ({
23
+ const toolbarInterfaceParams = useMemo(() => ({
25
24
  filtering: useToolbar && filterState && filterModel && normalizedTableFilterModel
26
25
  ? {
27
26
  filterState: filterState,
@@ -31,9 +30,9 @@ var InternalGrid = function (_a) {
31
30
  }
32
31
  : undefined,
33
32
  exporting: useToolbar
34
- ? { exportFnInfo: exportFnInfo, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel }
33
+ ? { exportFnInfo, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel }
35
34
  : undefined,
36
- }); }, [
35
+ }), [
37
36
  exportFnInfo,
38
37
  filterModel,
39
38
  filterState,
@@ -42,16 +41,16 @@ var InternalGrid = function (_a) {
42
41
  styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
43
42
  useToolbar,
44
43
  ]);
45
- var toolbarInterfaces = useInterfaces(toolbarInterfaceParams);
46
- var handleToggleFilterOptions = function () {
44
+ const toolbarInterfaces = useInterfaces(toolbarInterfaceParams);
45
+ const handleToggleFilterOptions = () => {
47
46
  setFilterOptionsVisible(!filterOptionsVisible);
48
47
  };
49
- var rowsAreSelectable = selectFns.rowsAreSelectable, selectionInfo = selectFns.selectionInfo, selectAllOnClick = selectFns.selectAllOnClick;
50
- var unwrappedTableModel = unwrappedStyles.unwrappedTableModel, unwrappedAdditionalStyleModel = unwrappedStyles.unwrappedAdditionalStyleModel;
51
- var mainTable = (_jsxs("table", { className: classNames("table", {
48
+ const { rowsAreSelectable, selectionInfo, selectAllOnClick } = selectFns;
49
+ const { unwrappedTableModel, unwrappedAdditionalStyleModel } = unwrappedStyles;
50
+ const mainTable = (_jsxs("table", { className: classNames("table", {
52
51
  "table-hover": rowsAreSelectable,
53
52
  "d-block": displayMode === "block",
54
- }, unwrappedTableModel.table), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames(unwrappedTableModel.caption), children: caption })), _jsx("thead", { className: classNames(unwrappedTableModel.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames(unwrappedTableModel.theadTr), children: [showSelectCol && (_jsx(SelectAllHeaderCell, { style: getWidthStyle(selectModel === null || selectModel === void 0 ? void 0 : selectModel.selectColWidth), selectionInfo: selectionInfo, onClick: selectAllOnClick, totalRows: rows.length, additionalClasses: unwrappedTableModel.rowSelectColTh })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames(unwrappedTableModel.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(unwrappedTableModel.tbody), children: bodyRows })] }));
55
- return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [normalizedTableFilterModel && !useToolbar && (_jsxs("div", { "data-testid": "rbdg-filter-inputs-div", className: classNames(unwrappedAdditionalStyleModel.filterInputsDiv), children: [_jsx(ToggleButton, { isActive: filterOptionsVisible, label: "".concat(filterOptionsVisible ? "Hide" : "Show ", " Filter Options"), onClick: handleToggleFilterOptions, classes: (_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _b === void 0 ? void 0 : _b.filterUiToggleButton }), filterOptionsVisible && (_jsx(FilterOptionsTable, { caption: filterModel.filterTableCaption, filterState: filterState, setFilterState: normalizedTableFilterModel.setTableFilterState, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel }))] })), useToolbar && (_jsx(ToolbarContainer, { interfaces: toolbarInterfaces, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbarStyleModel })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames(unwrappedAdditionalStyleModel.tableAndPaginationDiv), children: [responsive ? (_jsx("div", { "data-testid": "rbdg-table-div", className: "table-responsive", children: mainTable })) : (_jsx(_Fragment, { children: mainTable })), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: unwrappedAdditionalStyleModel.paginationUiDiv }))] })] }));
53
+ }, unwrappedTableModel.table), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames(unwrappedTableModel.caption), children: caption })), _jsx("thead", { className: classNames(unwrappedTableModel.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames(unwrappedTableModel.theadTr), children: [prefixHeader, showSelectCol && (_jsx(SelectAllHeaderCell, { style: getWidthStyle(selectModel === null || selectModel === void 0 ? void 0 : selectModel.selectColWidth), selectionInfo: selectionInfo, onClick: selectAllOnClick, totalRows: rows.length, additionalClasses: unwrappedTableModel.rowSelectColTh, colIndexOffset: prefixHeader ? 1 : 0 })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames(unwrappedTableModel.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(unwrappedTableModel.tbody), children: bodyRows })] }));
54
+ return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [normalizedTableFilterModel && !useToolbar && (_jsxs("div", { "data-testid": "rbdg-filter-inputs-div", className: classNames(unwrappedAdditionalStyleModel.filterInputsDiv), children: [_jsx(ToggleButton, { isActive: filterOptionsVisible, label: `${filterOptionsVisible ? "Hide" : "Show "} Filter Options`, onClick: handleToggleFilterOptions, classes: (_a = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _a === void 0 ? void 0 : _a.filterUiToggleButton }), filterOptionsVisible && (_jsx(FilterOptionsTable, { caption: filterModel.filterTableCaption, filterState: filterState, setFilterState: normalizedTableFilterModel.setTableFilterState, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel }))] })), useToolbar && (_jsx(ToolbarContainer, { interfaces: toolbarInterfaces, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbarStyleModel })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames(unwrappedAdditionalStyleModel.tableAndPaginationDiv), children: [responsive ? (_jsx("div", { "data-testid": "rbdg-table-div", className: "table-responsive", children: mainTable })) : (_jsx(_Fragment, { children: mainTable })), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: unwrappedAdditionalStyleModel.paginationUiDiv }))] })] }));
56
55
  };
57
56
  export default InternalGrid;
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import classNames from "classnames";
3
- var stopPropagationWrapper = function (fn) { return function (event) {
3
+ const stopPropagationWrapper = (fn) => (event) => {
4
4
  event.stopPropagation();
5
5
  fn();
6
- }; };
7
- var EditControlsCell = function (_a) {
8
- var ariaColIndex = _a.ariaColIndex, beginEditingCallback = _a.beginEditingCallback, cancelEditingCallback = _a.cancelEditingCallback, isEditing = _a.isEditing, saveCallback = _a.saveCallback, deleteCallback = _a.deleteCallback, editControlsCellClasses = _a.editControlsCellClasses, saveButtonClasses = _a.saveButtonClasses, deleteButtonClasses = _a.deleteButtonClasses, startButtonClasses = _a.startButtonClasses, cancelButtonClasses = _a.cancelButtonClasses;
6
+ };
7
+ const EditControlsCell = ({ ariaColIndex, beginEditingCallback, cancelEditingCallback, isEditing, saveCallback, deleteCallback, editControlsCellClasses, saveButtonClasses, deleteButtonClasses, startButtonClasses, cancelButtonClasses, }) => {
9
8
  return (_jsx("td", { "aria-colindex": ariaColIndex, className: classNames(editControlsCellClasses), children: _jsx("div", { className: "hstack gap-2", children: isEditing ? (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": "Cancel", className: classNames("btn", cancelButtonClasses.length === 0
10
9
  ? ["btn-secondary"]
11
10
  : cancelButtonClasses), onClick: stopPropagationWrapper(cancelEditingCallback), title: "Cancel", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: _jsx("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293z" }) }) }), _jsx("button", { "aria-label": "Save", className: classNames("btn", saveButtonClasses.length === 0
@@ -5,7 +5,7 @@ import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
5
5
  import EditControlsCell from "./EditControlsCell";
6
6
  import classNames from "classnames";
7
7
  import getWidthStyle from "../util/getWidthStyle";
8
- var initValueToFormValue = function (value, type) {
8
+ const initValueToFormValue = (value, type) => {
9
9
  switch (type) {
10
10
  case "date":
11
11
  return dateToInputStr(value);
@@ -17,7 +17,7 @@ var initValueToFormValue = function (value, type) {
17
17
  return value;
18
18
  }
19
19
  };
20
- var colDataTypeToInputType = function (colDataType) {
20
+ const colDataTypeToInputType = (colDataType) => {
21
21
  switch (colDataType) {
22
22
  case "date":
23
23
  return "date";
@@ -29,21 +29,18 @@ var colDataTypeToInputType = function (colDataType) {
29
29
  return "text";
30
30
  }
31
31
  };
32
- var EditableRow = function (_a) {
33
- var ariaColIndexOffset = _a.ariaColIndexOffset, cellData = _a.cellData, children = _a.children, updateCallback = _a.updateCallback, deleteCallback = _a.deleteCallback, onClick = _a.onClick, className = _a.className, ariaRowIndex = _a["aria-rowindex"], ariaSelected = _a["aria-selected"], dataRowId = _a.dataRowId, dataCellClasses = _a.dataCellClasses, dataCellInputClasses = _a.dataCellInputClasses, editCellClasses = _a.editCellClasses, saveButtonClasses = _a.saveButtonClasses, startButtonClasses = _a.startButtonClasses, cancelButtonClasses = _a.cancelButtonClasses, deleteButtonClasses = _a.deleteButtonClasses, editControlCellStyles = _a.editControlCellStyles;
34
- var trRef = useRef(null);
35
- var _b = useState(false), isEditing = _b[0], setIsEditing = _b[1];
36
- var handleSave = function () {
37
- var failedValidationFound = false;
38
- var formValues = [];
39
- for (var _i = 0, _a = Array.from(trRef.current.children); _i < _a.length; _i++) {
40
- var rowChild = _a[_i];
32
+ const EditableRow = ({ ariaColIndexOffset, cellData, children, updateCallback, deleteCallback, onClick, className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, dataRowId, dataCellClasses, dataCellInputClasses, editCellClasses, saveButtonClasses, startButtonClasses, cancelButtonClasses, deleteButtonClasses, editControlCellStyles, }) => {
33
+ const trRef = useRef(null);
34
+ const [isEditing, setIsEditing] = useState(false);
35
+ const handleSave = () => {
36
+ let failedValidationFound = false;
37
+ const formValues = [];
38
+ for (const rowChild of Array.from(trRef.current.children)) {
41
39
  if (!(rowChild instanceof HTMLTableCellElement)) {
42
40
  console.warn("Found non-td element inside EditableRow");
43
41
  continue;
44
42
  }
45
- for (var _b = 0, _c = Array.from(rowChild.children); _b < _c.length; _b++) {
46
- var cellChild = _c[_b];
43
+ for (const cellChild of Array.from(rowChild.children)) {
47
44
  if (!(cellChild instanceof HTMLInputElement) ||
48
45
  cellChild.type === "checkbox" ||
49
46
  cellChild.type === "radio") {
@@ -60,9 +57,6 @@ var EditableRow = function (_a) {
60
57
  setIsEditing(false);
61
58
  }
62
59
  };
63
- return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-rowid": dataRowId, children: [children, cellData.map(function (_a, index) {
64
- var type = _a.type, value = _a.value, formattedValue = _a.formattedValue, label = _a.label, width = _a.width;
65
- return (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, className: classNames(dataCellClasses(index)), style: getWidthStyle(width), children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: "editable-cell-input-".concat(dataRowId, "-").concat(index), className: classNames("form-control", dataCellInputClasses(index)), type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index));
66
- }), updateCallback && (_jsx(EditControlsCell, { ariaColIndex: ariaColIndexOffset + cellData.length + 1, beginEditingCallback: function () { return setIsEditing(true); }, cancelEditingCallback: function () { return setIsEditing(false); }, isEditing: isEditing, saveCallback: handleSave, deleteCallback: deleteCallback, editControlsCellClasses: editCellClasses, startButtonClasses: startButtonClasses, deleteButtonClasses: deleteButtonClasses, cancelButtonClasses: cancelButtonClasses, saveButtonClasses: saveButtonClasses, style: editControlCellStyles }))] }));
60
+ return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-rowid": dataRowId, children: [children, cellData.map(({ type, value, formattedValue, label, width }, index) => (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, className: classNames(dataCellClasses(index)), style: getWidthStyle(width), children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: `editable-cell-input-${dataRowId}-${index}`, className: classNames("form-control", dataCellInputClasses(index)), type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index))), updateCallback && (_jsx(EditControlsCell, { ariaColIndex: ariaColIndexOffset + cellData.length + 1, beginEditingCallback: () => setIsEditing(true), cancelEditingCallback: () => setIsEditing(false), isEditing: isEditing, saveCallback: handleSave, deleteCallback: deleteCallback, editControlsCellClasses: editCellClasses, startButtonClasses: startButtonClasses, deleteButtonClasses: deleteButtonClasses, cancelButtonClasses: cancelButtonClasses, saveButtonClasses: saveButtonClasses, style: editControlCellStyles }))] }));
67
61
  };
68
62
  export default EditableRow;
@@ -1,7 +1,7 @@
1
- var inputStrsToRowData = function (cols, inputStrs) {
2
- var newRow = {};
3
- inputStrs.forEach(function (value, index) {
4
- var col = cols[index];
1
+ const inputStrsToRowData = (cols, inputStrs) => {
2
+ const newRow = {};
3
+ inputStrs.forEach((value, index) => {
4
+ const col = cols[index];
5
5
  switch (col.type) {
6
6
  case "string":
7
7
  newRow[col.name] = value;
@@ -1,57 +1,42 @@
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
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
2
  import { useId, useState } from "react";
14
3
  import classNames from "classnames";
15
- var ExportForm = function (_a) {
16
- var _b = _a.exportFnInfo, exportFn = _b.exportFn, formattersExist = _b.formattersExist, paginationEnabled = _b.paginationEnabled, filteringEnabled = _b.filteringEnabled, rowCounts = _b.rowCounts, styleModel = _a.styleModel;
17
- var formId = useId();
18
- var _c = useState({
4
+ const ExportForm = ({ exportFnInfo: { exportFn, formattersExist, paginationEnabled, filteringEnabled, rowCounts, }, styleModel, }) => {
5
+ const formId = useId();
6
+ const [formState, setFormState] = useState({
19
7
  stage: "original",
20
8
  formatted: false,
21
9
  fileType: "json",
22
- }), formState = _c[0], setFormState = _c[1];
23
- var getChangeHandler = function (field, value) {
24
- return function () {
25
- setFormState(function (prev) {
26
- var _a;
27
- return (__assign(__assign({}, prev), (_a = {}, _a[field] = value, _a)));
28
- });
10
+ });
11
+ const getChangeHandler = (field, value) => {
12
+ return () => {
13
+ setFormState((prev) => (Object.assign(Object.assign({}, prev), { [field]: value })));
29
14
  };
30
15
  };
31
- var getRowCountLabel = function (featureType, count) {
16
+ const getRowCountLabel = (featureType, count) => {
32
17
  if (count === undefined) {
33
- return "".concat(featureType, " disabled");
18
+ return `${featureType} disabled`;
34
19
  }
35
- return "".concat(count, " ").concat(count === 1 ? "row" : "rows");
20
+ return `${count} ${count === 1 ? "row" : "rows"}`;
36
21
  };
37
- var stageOptions = [
22
+ const stageOptions = [
38
23
  {
39
24
  value: "original",
40
- label: "Original rows (total ".concat(rowCounts.total, " ").concat(rowCounts.total === 1 ? "row" : "rows", ")"),
25
+ label: `Original rows (total ${rowCounts.total} ${rowCounts.total === 1 ? "row" : "rows"})`,
41
26
  disabled: false,
42
27
  },
43
28
  {
44
29
  value: "filtered",
45
- label: "After filters applied (".concat(getRowCountLabel("filtering", rowCounts.filtered), ")"),
30
+ label: `After filters applied (${getRowCountLabel("filtering", rowCounts.filtered)})`,
46
31
  disabled: !filteringEnabled,
47
32
  },
48
33
  {
49
34
  value: "paged",
50
- label: "Current page only (".concat(getRowCountLabel("pagination", rowCounts.currentPage), ")"),
35
+ label: `Current page only (${getRowCountLabel("pagination", rowCounts.currentPage)})`,
51
36
  disabled: !paginationEnabled,
52
37
  },
53
38
  ];
54
- var formatOptions = [
39
+ const formatOptions = [
55
40
  {
56
41
  formatted: false,
57
42
  label: "Use original data",
@@ -59,11 +44,11 @@ var ExportForm = function (_a) {
59
44
  },
60
45
  {
61
46
  formatted: true,
62
- label: "Apply formatters to data".concat(formattersExist ? "" : " (no formatters defined)"),
47
+ label: `Apply formatters to data${formattersExist ? "" : " (no formatters defined)"}`,
63
48
  disabled: !formattersExist,
64
49
  },
65
50
  ];
66
- var fileTypeOptions = [
51
+ const fileTypeOptions = [
67
52
  {
68
53
  fileType: "json",
69
54
  label: "JSON",
@@ -73,25 +58,16 @@ var ExportForm = function (_a) {
73
58
  label: "CSV",
74
59
  },
75
60
  ];
76
- var handleSubmit = function (event) {
61
+ const handleSubmit = (event) => {
77
62
  event.preventDefault();
78
- var stage = formState.stage, fileType = formState.fileType, formatted = formState.formatted;
63
+ const { stage, fileType, formatted } = formState;
79
64
  exportFn(stage, fileType, formatted);
80
65
  };
81
- var legendClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.legend) || []);
82
- var radioContainerClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioContainer) || ["form-check"]);
83
- var radioInputClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioInput) || ["form-check-input"]);
84
- var radioLabelClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioLabel) || ["form-check-label"]);
85
- var submitButtonClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.submitButton) || ["btn", "btn-secondary"]);
86
- return (_jsxs("form", { onSubmit: handleSubmit, children: [_jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose data to export" }), stageOptions.map(function (_a) {
87
- var value = _a.value, label = _a.label, disabled = _a.disabled;
88
- return (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: "".concat(formId, "-").concat(value), value: value, checked: formState.stage === value, onChange: getChangeHandler("stage", value), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: "".concat(formId, "-").concat(value), children: label })] }, value));
89
- })] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose whether to apply formatters" }), formatOptions.map(function (_a) {
90
- var formatted = _a.formatted, label = _a.label, disabled = _a.disabled;
91
- return (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: "".concat(formId, "-").concat(formatted), value: String(formatted), checked: formState.formatted === formatted, onChange: getChangeHandler("formatted", formatted), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: "".concat(formId, "-").concat(formatted), children: label })] }, String(formatted)));
92
- })] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose the file type" }), fileTypeOptions.map(function (_a) {
93
- var fileType = _a.fileType, label = _a.label;
94
- return (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: "".concat(formId, "-").concat(fileType), value: fileType, checked: formState.fileType === fileType, onChange: getChangeHandler("fileType", fileType) }), _jsx("label", { className: radioLabelClasses, htmlFor: "".concat(formId, "-").concat(fileType), children: label })] }, fileType));
95
- })] }), _jsx("button", { type: "submit", className: submitButtonClasses, children: "Submit" })] }));
66
+ const legendClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.legend) || []);
67
+ const radioContainerClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioContainer) || ["form-check"]);
68
+ const radioInputClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioInput) || ["form-check-input"]);
69
+ const radioLabelClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.radioLabel) || ["form-check-label"]);
70
+ const submitButtonClasses = classNames((styleModel === null || styleModel === void 0 ? void 0 : styleModel.submitButton) || ["btn", "btn-secondary"]);
71
+ return (_jsxs("form", { onSubmit: handleSubmit, children: [_jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose data to export" }), stageOptions.map(({ value, label, disabled }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${value}`, value: value, checked: formState.stage === value, onChange: getChangeHandler("stage", value), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${value}`, children: label })] }, value)))] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose whether to apply formatters" }), formatOptions.map(({ formatted, label, disabled }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${formatted}`, value: String(formatted), checked: formState.formatted === formatted, onChange: getChangeHandler("formatted", formatted), disabled: disabled }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${formatted}`, children: label })] }, String(formatted))))] }), _jsxs("fieldset", { children: [_jsx("legend", { className: legendClasses, children: "Choose the file type" }), fileTypeOptions.map(({ fileType, label }) => (_jsxs("div", { className: radioContainerClasses, children: [_jsx("input", { className: radioInputClasses, type: "radio", id: `${formId}-${fileType}`, value: fileType, checked: formState.fileType === fileType, onChange: getChangeHandler("fileType", fileType) }), _jsx("label", { className: radioLabelClasses, htmlFor: `${formId}-${fileType}`, children: label })] }, fileType)))] }), _jsx("button", { type: "submit", className: submitButtonClasses, children: "Submit" })] }));
96
72
  };
97
73
  export default ExportForm;
@@ -1,80 +1,56 @@
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
1
  import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
13
2
  import Papa from "papaparse";
14
3
  import { useCallback, useMemo } from "react";
15
- var downloadFile = function (data, filename, type) {
16
- var blob = new Blob([data], { type: type });
17
- var url = URL.createObjectURL(blob);
18
- var a = document.createElement("a");
4
+ const downloadFile = (data, filename, type) => {
5
+ const blob = new Blob([data], { type });
6
+ const url = URL.createObjectURL(blob);
7
+ const a = document.createElement("a");
19
8
  a.href = url;
20
9
  a.download = filename;
21
10
  a.click();
22
11
  a.remove();
23
- setTimeout(function () { return URL.revokeObjectURL(url); }, 0);
12
+ setTimeout(() => URL.revokeObjectURL(url), 0);
24
13
  };
25
- var getDefaultFormatter = function (type) {
14
+ const getDefaultFormatter = (type) => {
26
15
  switch (type) {
27
16
  case "date":
28
17
  return dateToInputStr;
29
18
  case "datetime":
30
19
  return dateToDatetimeInputStr;
31
20
  default:
32
- return function (a) { return a; };
21
+ return (a) => a;
33
22
  }
34
23
  };
35
- var applyFormatters = function (rows, cols, defaultOnly) {
36
- var colToFormatter = cols.reduce(function (map, _a) {
37
- var name = _a.name, formatter = _a.formatter, type = _a.type;
38
- var normalizedFormatter = (!defaultOnly && formatter) || getDefaultFormatter(type);
24
+ const applyFormatters = (rows, cols, defaultOnly) => {
25
+ const colToFormatter = cols.reduce((map, { name, formatter, type }) => {
26
+ const normalizedFormatter = (!defaultOnly && formatter) || getDefaultFormatter(type);
39
27
  map.set(name, normalizedFormatter);
40
28
  return map;
41
29
  }, new Map());
42
- return rows.map(function (_a) {
43
- var id = _a.id, data = _a.data;
44
- return ({
45
- id: id,
46
- data: Object.keys(data).reduce(function (newData, name) {
47
- var formatter = colToFormatter.get(name);
48
- newData[name] = formatter(data[name]);
49
- return newData;
50
- }, {}),
51
- });
52
- });
53
- };
54
- var flattenExportRows = function (rows) {
55
- return rows.map(function (_a) {
56
- var id = _a.id, data = _a.data;
57
- return (__assign({ id: id }, data));
58
- });
30
+ return rows.map(({ id, data }) => ({
31
+ id,
32
+ data: Object.keys(data).reduce((newData, name) => {
33
+ const formatter = colToFormatter.get(name);
34
+ newData[name] = formatter(data[name]);
35
+ return newData;
36
+ }, {}),
37
+ }));
59
38
  };
60
- var exportJson = function (rows, cols, useDefaultFormatters) {
61
- var formattedRows = applyFormatters(rows, cols, useDefaultFormatters);
62
- var json = JSON.stringify(formattedRows, null, 2);
39
+ const flattenExportRows = (rows) => rows.map(({ id, data }) => (Object.assign({ id }, data)));
40
+ const exportJson = (rows, cols, useDefaultFormatters) => {
41
+ const formattedRows = applyFormatters(rows, cols, useDefaultFormatters);
42
+ const json = JSON.stringify(formattedRows, null, 2);
63
43
  downloadFile(json, "export.json", "application/json");
64
44
  };
65
- var exportCsv = function (rows, cols, useDefaultFormatters) {
66
- var formattedRows = applyFormatters(rows, cols, useDefaultFormatters);
67
- var flattenedRows = flattenExportRows(formattedRows);
68
- var csv = Papa.unparse(flattenedRows, { header: true });
45
+ const exportCsv = (rows, cols, useDefaultFormatters) => {
46
+ const formattedRows = applyFormatters(rows, cols, useDefaultFormatters);
47
+ const flattenedRows = flattenExportRows(formattedRows);
48
+ const csv = Papa.unparse(flattenedRows, { header: true });
69
49
  downloadFile(csv, "export.csv", "text/csv");
70
50
  };
71
- var useExportFn = function (_a) {
72
- var rows = _a.rows, cols = _a.cols, filteredRows = _a.filteredRows, currentPageRows = _a.currentPageRows;
73
- var formattersExist = useMemo(function () { return cols.reduce(function (prev, _a) {
74
- var formatter = _a.formatter;
75
- return prev || !!formatter;
76
- }, false); }, [cols]);
77
- var exportFn = useCallback(function (stage, fileType, formatted) {
51
+ const useExportFn = ({ rows, cols, filteredRows, currentPageRows, }) => {
52
+ const formattersExist = useMemo(() => cols.reduce((prev, { formatter }) => prev || !!formatter, false), [cols]);
53
+ const exportFn = useCallback((stage, fileType, formatted) => {
78
54
  if (stage === "filtered" && !filteredRows) {
79
55
  throw Error("Cannot export filtered rows because filtering is not enabled for this grid");
80
56
  }
@@ -84,7 +60,7 @@ var useExportFn = function (_a) {
84
60
  if (formatted && !formattersExist) {
85
61
  throw Error("Cannot export formatted rows because formatters are not defined for this grid");
86
62
  }
87
- var exportRows = (function () {
63
+ const exportRows = (() => {
88
64
  switch (stage) {
89
65
  case "filtered":
90
66
  return filteredRows;
@@ -100,9 +76,9 @@ var useExportFn = function (_a) {
100
76
  }
101
77
  exportJson(exportRows, cols, !formatted);
102
78
  }, [cols, currentPageRows, filteredRows, formattersExist, rows]);
103
- return useMemo(function () { return ({
104
- exportFn: exportFn,
105
- formattersExist: formattersExist,
79
+ return useMemo(() => ({
80
+ exportFn,
81
+ formattersExist,
106
82
  paginationEnabled: !!currentPageRows,
107
83
  filteringEnabled: !!filteredRows,
108
84
  rowCounts: {
@@ -110,6 +86,6 @@ var useExportFn = function (_a) {
110
86
  filtered: filteredRows === null || filteredRows === void 0 ? void 0 : filteredRows.length,
111
87
  currentPage: currentPageRows === null || currentPageRows === void 0 ? void 0 : currentPageRows.length,
112
88
  },
113
- }); }, [currentPageRows, exportFn, filteredRows, formattersExist, rows.length]);
89
+ }), [currentPageRows, exportFn, filteredRows, formattersExist, rows.length]);
114
90
  };
115
91
  export default useExportFn;
@@ -1,45 +1,29 @@
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
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
2
  import { useId } from "react";
14
3
  import { dateFilterSchemeNames, } from "./types";
15
4
  import FilterRow from "./FilterRow";
16
5
  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 }));
6
+ const DateFilterRow = ({ ariaRowIndex, includeTime, columnLabel, filterState, setFilterState, schemeSelectClasses, enableInputClasses, startDateInputClasses, endDateInputClasses, tdClasses, trClasses, }) => {
7
+ const handleOpChange = ({ target, }) => {
8
+ setFilterState(Object.assign(Object.assign({}, filterState), { scheme: target.value }));
22
9
  };
23
- var handleEnabledChange = function (_a) {
24
- var target = _a.target;
25
- setFilterState(__assign(__assign({}, filterState), { enabled: target.checked }));
10
+ const handleEnabledChange = ({ target, }) => {
11
+ setFilterState(Object.assign(Object.assign({}, filterState), { enabled: target.checked }));
26
12
  };
27
- var handleStartValueChange = function (_a) {
28
- var target = _a.target;
29
- setFilterState(__assign(__assign({}, filterState), { startDate: target.value }));
13
+ const handleStartValueChange = ({ target, }) => {
14
+ setFilterState(Object.assign(Object.assign({}, filterState), { startDate: target.value }));
30
15
  };
31
- var handleEndValueChange = function (_a) {
32
- var target = _a.target;
33
- setFilterState(__assign(__assign({}, filterState), { endDate: target.value }));
16
+ const handleEndValueChange = ({ target, }) => {
17
+ setFilterState(Object.assign(Object.assign({}, filterState), { endDate: target.value }));
34
18
  };
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 })] }))] }));
19
+ const { enabled, scheme, startDate, endDate } = filterState;
20
+ const inputType = includeTime ? "datetime-local" : "date";
21
+ const inputId = useId();
22
+ const startDateInputId = `$startDate-${inputId}`;
23
+ const endDateInputId = `$endDate-${inputId}`;
24
+ const startDateInputLabel = `${columnLabel} Column Filter Start Date`;
25
+ const endDateInputLabel = `${columnLabel} Column Filter End Date`;
26
+ const 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
27
  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
28
  };
45
29
  export default DateFilterRow;