@uxf/data-grid 11.0.0-beta.2 → 11.0.0-beta.21

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 (53) hide show
  1. package/_generator/cli.js +29 -0
  2. package/_generator/index.js +40 -0
  3. package/_store/reducer.d.ts +2 -2
  4. package/_store/reducer.js +32 -19
  5. package/_story-utils/grid-type.d.ts +2 -0
  6. package/_story-utils/loader.js +1 -1
  7. package/_story-utils/schema.js +12 -0
  8. package/bin/uxf-data-grid-generator.js +8 -0
  9. package/data-grid.js +7 -8
  10. package/data-grid.stories.js +34 -3
  11. package/filter-handler/date.d.ts +3 -0
  12. package/filter-handler/date.js +43 -0
  13. package/filter-handler/index.js +4 -0
  14. package/filter-handler/multi-select.d.ts +3 -0
  15. package/filter-handler/multi-select.js +29 -0
  16. package/hidden-columns/hidden-columns.js +2 -4
  17. package/package.json +8 -3
  18. package/pagination/pagination.d.ts +1 -1
  19. package/pagination/pagination.js +2 -2
  20. package/pagination/pagination.stories.js +1 -1
  21. package/row-counts/row-counts.d.ts +1 -0
  22. package/row-counts/row-counts.js +7 -1
  23. package/row-counts/row-counts.stories.js +1 -1
  24. package/selected-rows-toolbar/selected-rows-toolbar.js +1 -1
  25. package/selected-rows-toolbar/selected-rows-toolbar.stories.js +4 -1
  26. package/styles.css +605 -0
  27. package/table/components/action-cell-wrapper.d.ts +2 -0
  28. package/table/components/{action-cell-base.js → action-cell-wrapper.js} +3 -29
  29. package/table/components/action-cell.d.ts +7 -0
  30. package/table/components/action-cell.js +14 -0
  31. package/{hooks → table/hooks}/use-rdg-visuals.d.ts +2 -2
  32. package/{hooks → table/hooks}/use-rdg-visuals.js +2 -2
  33. package/table/hooks/use-react-data-grid-columns.d.ts +2 -1
  34. package/table/hooks/use-react-data-grid-columns.js +21 -29
  35. package/table/index.d.ts +2 -0
  36. package/table/index.js +2 -0
  37. package/table/table.d.ts +1 -1
  38. package/table/table.js +15 -7
  39. package/table/table.stories.js +1 -1
  40. package/table/types.d.ts +10 -12
  41. package/toolbar-control/toolbar-control.js +2 -2
  42. package/types/components.d.ts +0 -5
  43. package/types/data-grid-props.d.ts +13 -12
  44. package/types/index.d.ts +0 -1
  45. package/types/index.js +0 -1
  46. package/types/state.d.ts +6 -3
  47. package/use-data-grid-control/use-data-grid-control.d.ts +3 -1
  48. package/use-data-grid-control/use-data-grid-control.js +1 -1
  49. package/use-data-grid-fetching/use-data-grid-fetching.d.ts +7 -1
  50. package/use-data-grid-fetching/use-data-grid-fetching.js +3 -1
  51. package/table/components/action-cell-base.d.ts +0 -4
  52. package/types/ui-components.d.ts +0 -18
  53. package/types/ui-components.js +0 -2
@@ -25,20 +25,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.useReactDataGridColumns = void 0;
27
27
  const cx_1 = require("@uxf/core/utils/cx");
28
- const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
29
28
  const react_1 = __importStar(require("react"));
30
29
  const react_data_grid_1 = require("react-data-grid");
31
- const action_cell_base_1 = require("../components/action-cell-base");
32
- function useReactDataGridColumns(props) {
33
- var _a;
34
- const { onReload, actionCellWidth, schema, isRowSelectable, BodyCells, getOpenUrl, onOpen, getEditUrl, onEdit, onRemove, } = props;
35
- const ActionCell = (_a = props.ActionCell) !== null && _a !== void 0 ? _a : action_cell_base_1.ActionCellBase;
30
+ function useReactDataGridColumns(props, state) {
31
+ const { onReload, schema, isRowSelectable, bodyCells, actionCell } = props;
32
+ const columnsConfig = state.userConfig.columns;
36
33
  return (0, react_1.useMemo)(() => {
34
+ var _a;
37
35
  const columns = [];
38
36
  if (isRowSelectable) {
39
37
  columns.push(react_data_grid_1.SelectColumn);
40
38
  }
41
39
  for (const schemaColumn of schema.columns) {
40
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
41
+ if ((_a = columnsConfig === null || columnsConfig === void 0 ? void 0 : columnsConfig[schemaColumn.name]) === null || _a === void 0 ? void 0 : _a.isHidden) {
42
+ continue;
43
+ }
42
44
  columns.push({
43
45
  key: schemaColumn.name,
44
46
  name: schemaColumn.label,
@@ -52,7 +54,7 @@ function useReactDataGridColumns(props) {
52
54
  renderCell: (p) => {
53
55
  var _a;
54
56
  const columnType = schemaColumn.type;
55
- const BodyCell = (_a = BodyCells === null || BodyCells === void 0 ? void 0 : BodyCells[columnType]) !== null && _a !== void 0 ? _a : BodyCells === null || BodyCells === void 0 ? void 0 : BodyCells.default;
57
+ const BodyCell = (_a = bodyCells === null || bodyCells === void 0 ? void 0 : bodyCells[columnType]) !== null && _a !== void 0 ? _a : bodyCells === null || bodyCells === void 0 ? void 0 : bodyCells.default;
56
58
  if (!BodyCell) {
57
59
  return null;
58
60
  }
@@ -65,28 +67,18 @@ function useReactDataGridColumns(props) {
65
67
  },
66
68
  });
67
69
  }
68
- columns.push({
69
- key: "__action_column",
70
- name: "",
71
- resizable: false,
72
- headerCellClass: "uxf-data-grid__action-cell",
73
- cellClass: "uxf-data-grid__action-cell",
74
- width: actionCellWidth,
75
- renderCell: (p) => (0, is_not_nil_1.isNotNil)(ActionCell) ? (react_1.default.createElement(ActionCell, { reload: async () => onReload === null || onReload === void 0 ? void 0 : onReload(), row: p.row, getEditUrl: getEditUrl, onEdit: onEdit, getOpenUrl: getOpenUrl, onOpen: onOpen, onRemove: onRemove })) : null,
76
- });
70
+ if (actionCell) {
71
+ columns.push({
72
+ key: "__action_column",
73
+ name: "",
74
+ resizable: false,
75
+ headerCellClass: "uxf-data-grid__action-cell",
76
+ cellClass: "uxf-data-grid__action-cell",
77
+ width: actionCell.width,
78
+ renderCell: (p) => react_1.default.createElement(actionCell.Component, { reload: async () => onReload === null || onReload === void 0 ? void 0 : onReload(), row: p.row }),
79
+ });
80
+ }
77
81
  return columns;
78
- }, [
79
- ActionCell,
80
- actionCellWidth,
81
- schema.columns,
82
- BodyCells,
83
- isRowSelectable,
84
- onOpen,
85
- getOpenUrl,
86
- onEdit,
87
- getEditUrl,
88
- onRemove,
89
- onReload,
90
- ]);
82
+ }, [columnsConfig, actionCell, schema.columns, bodyCells, isRowSelectable, onReload]);
91
83
  }
92
84
  exports.useReactDataGridColumns = useReactDataGridColumns;
package/table/index.d.ts CHANGED
@@ -1 +1,3 @@
1
+ export * from "./components/action-cell";
2
+ export * from "./components/action-cell-wrapper";
1
3
  export * from "./table";
package/table/index.js CHANGED
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components/action-cell"), exports);
18
+ __exportStar(require("./components/action-cell-wrapper"), exports);
17
19
  __exportStar(require("./table"), exports);
package/table/table.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import { TableProps } from "./types";
3
- export declare function Table(props: TableProps<any>): React.JSX.Element | null;
3
+ export declare function Table(props: TableProps<any>): React.JSX.Element;
package/table/table.js CHANGED
@@ -27,10 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Table = void 0;
30
+ const show_1 = require("@uxf/core/components/show");
30
31
  const useIsMounted_1 = require("@uxf/core/hooks/useIsMounted");
31
32
  const react_1 = __importStar(require("react"));
32
33
  const react_data_grid_1 = __importDefault(require("react-data-grid"));
33
34
  const select_row_checkbox_1 = require("./components/select-row-checkbox");
35
+ const use_rdg_visuals_1 = require("./hooks/use-rdg-visuals");
34
36
  const use_react_data_grid_columns_1 = require("./hooks/use-react-data-grid-columns");
35
37
  const defaultKeyExtractor = (r) => r.id;
36
38
  const DefaultNoRowsFallback = () => react_1.default.createElement("div", null, "no rows");
@@ -41,7 +43,7 @@ function Table(props) {
41
43
  const headerRowHeight = (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36;
42
44
  const keyExtractor = (_c = props.keyExtractor) !== null && _c !== void 0 ? _c : defaultKeyExtractor;
43
45
  const contentHeight = typeof rowHeight === "function"
44
- ? props.data.reduce((prev, curr) => prev + rowHeight({ type: "ROW", row: curr }))
46
+ ? props.data.reduce((prev, curr) => prev + rowHeight(curr))
45
47
  : (rowHeight + 1) * props.data.length;
46
48
  const reactDataGridStyles = {
47
49
  border: 0,
@@ -56,9 +58,12 @@ function Table(props) {
56
58
  renderCheckbox: (args) => react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { ...args }),
57
59
  noRowsFallback: react_1.default.createElement(NoRowsFallback, { error: error, loading: isLoading }),
58
60
  }), [NoRowsFallback, error, isLoading]);
59
- const columns = (0, use_react_data_grid_columns_1.useReactDataGridColumns)(props);
61
+ const columns = (0, use_react_data_grid_columns_1.useReactDataGridColumns)(props, props.state);
60
62
  const onSelectRows = (value) => {
61
- const selectedRows = Array.from(value).map((id) => props.data.find((row) => keyExtractor(row) === id));
63
+ const selectedRows = Array.from(value).map((id) => {
64
+ var _a, _b;
65
+ return (_b = (_a = props.state.selectedRows) === null || _a === void 0 ? void 0 : _a.find((row) => keyExtractor(row) === id)) !== null && _b !== void 0 ? _b : props.data.find((row) => keyExtractor(row) === id);
66
+ });
62
67
  props.actions.setSelectedRows(selectedRows);
63
68
  };
64
69
  const onSortColumnChange = (sortColumns) => {
@@ -72,9 +77,12 @@ function Table(props) {
72
77
  const sortColumns = props.state.request.sort && props.state.request.dir
73
78
  ? [{ columnKey: props.state.request.sort, direction: props.state.request.dir.toUpperCase() }]
74
79
  : [];
75
- if (!isMounted) {
76
- return null;
77
- }
78
- return (react_1.default.createElement(react_data_grid_1.default, { style: reactDataGridStyles, className: "uxf-data-grid__table", columns: columns, rows: props.data, enableVirtualization: false, onSortColumnsChange: onSortColumnChange, sortColumns: sortColumns, rowHeight: rowHeight, headerRowHeight: headerRowHeight, rowClass: props.rowClass, rowKeyGetter: (_e = props.keyExtractor) !== null && _e !== void 0 ? _e : defaultKeyExtractor, selectedRows: new Set((_g = (_f = props.state.selectedRows) === null || _f === void 0 ? void 0 : _f.map(keyExtractor)) !== null && _g !== void 0 ? _g : []), onSelectedRowsChange: onSelectRows, renderers: components }));
80
+ const rdgVisuals = (0, use_rdg_visuals_1.useRdgVisuals)({
81
+ headerRowHeight: props.headerRowHeight,
82
+ rowHeight: props.rowHeight,
83
+ rows: props.data,
84
+ });
85
+ return (react_1.default.createElement(show_1.Show, { when: isMounted },
86
+ react_1.default.createElement(react_data_grid_1.default, { ref: rdgVisuals.ref, style: reactDataGridStyles, className: rdgVisuals.className, columns: columns, rows: props.data, enableVirtualization: false, onSortColumnsChange: onSortColumnChange, sortColumns: sortColumns, rowHeight: rdgVisuals.rowHeight, headerRowHeight: rdgVisuals.headerRowHeight, rowClass: props.rowClass, rowKeyGetter: (_e = props.keyExtractor) !== null && _e !== void 0 ? _e : defaultKeyExtractor, selectedRows: new Set((_g = (_f = props.state.selectedRows) === null || _f === void 0 ? void 0 : _f.map(keyExtractor)) !== null && _g !== void 0 ? _g : []), onSelectedRowsChange: onSelectRows, renderers: components })));
79
87
  }
80
88
  exports.Table = Table;
@@ -14,7 +14,7 @@ const table_1 = require("./table");
14
14
  function Default() {
15
15
  const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
16
16
  return (react_1.default.createElement(react_1.default.Fragment, null,
17
- react_1.default.createElement(table_1.Table, { state: state, actions: actions, data: data_1.data, isLoading: true, error: undefined, schema: schema_1.schema, BodyCells: body_cell_1.BodyCells, isRowSelectable: true, onOpen: console.log, onEdit: console.log, onRemove: console.log }),
17
+ react_1.default.createElement(table_1.Table, { state: state, actions: actions, data: data_1.data, isLoading: true, error: undefined, schema: schema_1.schema, bodyCells: body_cell_1.BodyCells, isRowSelectable: true }),
18
18
  react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
19
19
  }
20
20
  exports.Default = Default;
package/table/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Nullish } from "@uxf/core/types";
2
- import { DataGridProps as RDGProps } from "react-data-grid";
3
- import { ActionCellComponent, BodyCellComponents, KeyExtractor, Schema } from "../types";
2
+ import { ActionCellComponent, BodyCellComponents } from "../types/components";
3
+ import { KeyExtractor } from "../types/core";
4
+ import { Schema } from "../types/schema";
4
5
  import { DataGridControl } from "../use-data-grid-control";
5
6
  import { NoRowsFallbackComponent } from "./no-rows-fallback";
6
7
  export interface TableProps<Row> extends DataGridControl {
@@ -9,18 +10,15 @@ export interface TableProps<Row> extends DataGridControl {
9
10
  isLoading?: boolean;
10
11
  error?: any | Nullish;
11
12
  onReload?: () => void;
12
- rowHeight?: RDGProps<any>["rowHeight"];
13
- headerRowHeight?: RDGProps<any>["headerRowHeight"];
13
+ rowHeight?: number | ((row: Row) => number);
14
+ headerRowHeight?: number;
14
15
  rowClass?: (row: Row) => "success" | "warning" | "error" | "primary" | "secondary" | string | null | undefined;
15
16
  keyExtractor?: KeyExtractor;
16
- BodyCells?: BodyCellComponents<any, any>;
17
- ActionCell?: ActionCellComponent<any>;
18
- actionCellWidth?: number;
17
+ bodyCells?: BodyCellComponents<any, any>;
18
+ actionCell?: {
19
+ width: number;
20
+ Component: ActionCellComponent<any>;
21
+ };
19
22
  NoRowsFallback?: NoRowsFallbackComponent;
20
23
  isRowSelectable?: boolean;
21
- onOpen?: (row: Row) => void;
22
- getOpenUrl?: (row: Row) => string | null | undefined;
23
- onEdit?: (row: Row) => void;
24
- getEditUrl?: (row: Row) => string | null | undefined;
25
- onRemove?: (row: Row, reload: () => void) => void;
26
24
  }
@@ -15,8 +15,8 @@ function ToolbarControl(props) {
15
15
  return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-control" },
16
16
  react_1.default.createElement(hide_1.Hide, { when: !props.schema.fullText },
17
17
  react_1.default.createElement(fulltext_input_1.FulltextInput, { state: props.state, actions: props.actions })),
18
- react_1.default.createElement(filters_button_1.FiltersButton, { state: props.state, actions: props.actions, gridName: props.gridName, schema: props.schema, filterHandlers: props.filterHandlers }),
18
+ (0, is_not_nil_1.isNotNil)(props.onCsvDownload) && (react_1.default.createElement(export_button_1.ExportButton, { state: props.state, actions: props.actions, schema: props.schema, onCsvDownload: props.onCsvDownload })),
19
19
  react_1.default.createElement(hidden_columns_button_1.HiddenColumnsButton, { state: props.state, actions: props.actions, schema: props.schema }),
20
- (0, is_not_nil_1.isNotNil)(props.onCsvDownload) && (react_1.default.createElement(export_button_1.ExportButton, { state: props.state, actions: props.actions, schema: props.schema, onCsvDownload: props.onCsvDownload }))));
20
+ react_1.default.createElement(filters_button_1.FiltersButton, { state: props.state, actions: props.actions, gridName: props.gridName, schema: props.schema, filterHandlers: props.filterHandlers })));
21
21
  }
22
22
  exports.ToolbarControl = ToolbarControl;
@@ -3,11 +3,6 @@ import { RequestFilter } from "./api";
3
3
  import { BaseGridType, Columns, Filter } from "./schema";
4
4
  export interface ActionCellProps<R> {
5
5
  row: R;
6
- onOpen?: (row: R) => void;
7
- getOpenUrl?: (row: R) => string | null | undefined;
8
- onEdit?: (row: R) => void;
9
- getEditUrl?: (row: R) => string | null | undefined;
10
- onRemove?: (row: R, reload: () => void) => void;
11
6
  reload: () => void;
12
7
  }
13
8
  export type ActionCellComponent<R> = FC<ActionCellProps<R>>;
@@ -1,10 +1,13 @@
1
- import { DataGridProps as RDGProps } from "react-data-grid";
1
+ import { FilterHandlers } from "../filter-handler";
2
+ import { SelectedRowsToolbarActionsComponent } from "../selected-rows-toolbar";
3
+ import { NoRowsFallbackComponent } from "../table/no-rows-fallback";
4
+ import { TableProps } from "../table/types";
2
5
  import { ToolbarCustomsProps } from "../toolbar-customs";
3
6
  import { DataGridControl } from "../use-data-grid-control";
4
7
  import { DataGridFetchingResult } from "../use-data-grid-fetching";
8
+ import { BodyCellComponents } from "./components";
5
9
  import { CsvDownloadHandler, KeyExtractor } from "./core";
6
10
  import { BaseGridType, Schema } from "./schema";
7
- import { UIComponents } from "./ui-components";
8
11
  export type DataGridControlProps = DataGridControl;
9
12
  export type DataGridDataProps<Row> = DataGridFetchingResult<Row>;
10
13
  export type DataGridBaseProps<GridType extends BaseGridType, Row> = {
@@ -12,20 +15,18 @@ export type DataGridBaseProps<GridType extends BaseGridType, Row> = {
12
15
  gridName?: string;
13
16
  keyExtractor?: KeyExtractor;
14
17
  onCsvDownload?: CsvDownloadHandler;
15
- onOpen?: (row: Row) => void;
16
- getOpenUrl?: (row: Row) => string | null | undefined;
17
- onEdit?: (row: Row) => void;
18
- getEditUrl?: (row: Row) => string | null | undefined;
19
- onRemove?: (row: Row, reload: () => void) => void;
20
18
  noBorder?: boolean;
21
- rowHeight?: RDGProps<any>["rowHeight"];
22
- headerRowHeight?: RDGProps<any>["headerRowHeight"];
19
+ rowHeight?: number | ((row: Row) => number);
20
+ headerRowHeight?: number;
23
21
  rowClass?: (row: Row) => "success" | "warning" | "error" | "primary" | "secondary" | string | null | undefined;
24
- debug?: boolean;
25
22
  className?: string;
26
23
  customActions?: ToolbarCustomsProps["buttons"];
27
- mode?: "light" | "dark";
28
- ui?: UIComponents<GridType, Row>;
24
+ actionCell?: TableProps<Row>["actionCell"];
25
+ bodyCells?: BodyCellComponents<GridType["columns"], Row>;
26
+ filterHandlers?: FilterHandlers;
27
+ NoRowsFallback?: NoRowsFallbackComponent;
28
+ SelectedRowsToolbarActions?: SelectedRowsToolbarActionsComponent;
29
29
  isRowSelectable?: boolean;
30
+ isDebug?: boolean;
30
31
  };
31
32
  export type DataGridProps<GridType extends BaseGridType, Row> = DataGridBaseProps<GridType, Row> & DataGridDataProps<Row> & DataGridControlProps;
package/types/index.d.ts CHANGED
@@ -4,4 +4,3 @@ export * from "./core";
4
4
  export * from "./data-grid-props";
5
5
  export * from "./schema";
6
6
  export * from "./state";
7
- export * from "./ui-components";
package/types/index.js CHANGED
@@ -20,4 +20,3 @@ __exportStar(require("./core"), exports);
20
20
  __exportStar(require("./data-grid-props"), exports);
21
21
  __exportStar(require("./schema"), exports);
22
22
  __exportStar(require("./state"), exports);
23
- __exportStar(require("./ui-components"), exports);
package/types/state.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RequestFilter, Response } from "./api";
1
+ import { RequestFilter } from "./api";
2
2
  import { DataGridSortDir } from "./schema";
3
3
  export type GridRequest = {
4
4
  f: RequestFilter[];
@@ -13,11 +13,14 @@ interface ColumnConfig {
13
13
  isHidden: boolean;
14
14
  width?: number;
15
15
  }
16
+ export interface DataGridUserConfig {
17
+ columns?: Record<string, ColumnConfig>;
18
+ perPage?: number;
19
+ }
16
20
  export interface DataGridState {
17
- response?: Response;
18
21
  request: GridRequest;
19
22
  selectedRows?: any[];
20
- columnConfig: Record<string, ColumnConfig>;
23
+ userConfig: DataGridUserConfig;
21
24
  tabRequests: {
22
25
  [tab: string]: GridRequest;
23
26
  };
@@ -1,13 +1,15 @@
1
1
  import { Nullish } from "@uxf/core/types";
2
2
  import { Request } from "../types/api";
3
3
  import { Schema } from "../types/schema";
4
+ import { DataGridUserConfig } from "../types/state";
4
5
  interface Config {
5
6
  schema: Schema<any>;
6
7
  initialState?: Request | string | Nullish;
7
8
  isDebug?: boolean;
9
+ initialUserConfig?: DataGridUserConfig | Nullish;
8
10
  }
9
11
  export declare function useDataGridControl(config: Config): {
10
- state: import("..").DataGridState;
12
+ state: import("../types/state").DataGridState;
11
13
  actions: {
12
14
  changePage: (page: number) => void;
13
15
  changePerPage: (perPage: number) => void;
@@ -5,7 +5,7 @@ const react_1 = require("react");
5
5
  const reducer_1 = require("../_store/reducer");
6
6
  const actions_factory_1 = require("./actions-factory");
7
7
  function useDataGridControl(config) {
8
- const [state, dispatch] = (0, react_1.useReducer)(config.isDebug ? reducer_1.debugReducer : reducer_1.reducer, (0, reducer_1.getInitialState)(config.schema, config.initialState));
8
+ const [state, dispatch] = (0, react_1.useReducer)(config.isDebug ? reducer_1.debugReducer : reducer_1.reducer, (0, reducer_1.getInitialState)(config.schema, config.initialState, config.initialUserConfig));
9
9
  const actions = (0, react_1.useMemo)(() => (0, actions_factory_1.createActions)(dispatch), [dispatch]);
10
10
  return { state, actions };
11
11
  }
@@ -12,5 +12,11 @@ export interface DataGridFetchingResult<Row> {
12
12
  data: Response<Row> | null;
13
13
  onReload: () => void;
14
14
  }
15
- export declare function useDataGridFetching(loader: Loader, schema: Schema<any>, gridName: string, state: DataGridControl["state"]): DataGridFetchingResult<any>;
15
+ interface Config {
16
+ loader: Loader;
17
+ schema: Schema<any>;
18
+ gridName: string;
19
+ state: DataGridControl["state"];
20
+ }
21
+ export declare function useDataGridFetching(config: Config): DataGridFetchingResult<any>;
16
22
  export {};
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDataGridFetching = void 0;
4
4
  const react_1 = require("react");
5
5
  const utils_1 = require("../utils");
6
- function useDataGridFetching(loader, schema, gridName, state) {
6
+ function useDataGridFetching(config) {
7
+ const { state, schema, loader, gridName } = config;
7
8
  const [isLoading, setIsLoading] = (0, react_1.useState)(false);
8
9
  const [error, setError] = (0, react_1.useState)(null);
9
10
  const [data, setData] = (0, react_1.useState)(null);
@@ -11,6 +12,7 @@ function useDataGridFetching(loader, schema, gridName, state) {
11
12
  const reload = (0, react_1.useCallback)(() => {
12
13
  const stateRequest = JSON.parse(stringStateRequest);
13
14
  const request = (0, utils_1.createRequest)(stateRequest, schema.sort, schema.dir);
15
+ setIsLoading(true);
14
16
  loader(gridName, request, (0, utils_1.encodeFilter)(request))
15
17
  .then((response) => {
16
18
  setData(response);
@@ -1,4 +0,0 @@
1
- import { FC, PropsWithChildren } from "react";
2
- import { ActionCellComponent } from "../../types";
3
- export declare const ActionCellWrapper: FC<PropsWithChildren>;
4
- export declare const ActionCellBase: ActionCellComponent<any>;
@@ -1,18 +0,0 @@
1
- import { FilterHandlers } from "../filter-handler";
2
- import { SelectedRowsToolbarActionsComponent } from "../selected-rows-toolbar";
3
- import { NoRowsFallbackComponent } from "../table/no-rows-fallback";
4
- import { ActionCellComponent, BodyCellComponents } from "./components";
5
- import { BaseGridType } from "./schema";
6
- export type ActionCellWithRequiredWidth<R> = {
7
- ActionCell?: ActionCellComponent<R>;
8
- actionCellWidth: number;
9
- } | {
10
- ActionCell?: never;
11
- actionCellWidth?: never;
12
- };
13
- export type UIComponents<GridType extends BaseGridType, R> = {
14
- BodyCells?: BodyCellComponents<GridType["columns"], R>;
15
- FilterHandlers?: FilterHandlers;
16
- NoRowsFallback?: NoRowsFallbackComponent;
17
- SelectedRowsToolbarActions?: SelectedRowsToolbarActionsComponent;
18
- } & ActionCellWithRequiredWidth<R>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });