@uxf/data-grid 11.77.2 → 11.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/data-grid-v2.js CHANGED
@@ -32,7 +32,7 @@ function DataGridV2(props) {
32
32
  react_1.default.createElement(toolbar_customs_1.DataGridToolbarCustoms, { buttons: props.customActions })),
33
33
  react_1.default.createElement(linear_progress_1.DataGridLinearProgress, { isLoading: props.isLoading }),
34
34
  react_1.default.createElement(filter_list_1.DataGridFilterList, { actions: props.actions, filterHandlers: (_b = props.filterHandlers) !== null && _b !== void 0 ? _b : filter_handler_1.defaultFilterHandlers, schema: props.schema, state: props.state }),
35
- react_1.default.createElement(table_v2_1.DataGridTableV2, { NoRowsFallback: props.NoRowsFallback, actionCell: props.actionCell, actions: props.actions, bodyCells: (_c = props.bodyCells) !== null && _c !== void 0 ? _c : body_cell_1.BodyCells, data: (_e = (_d = props.data) === null || _d === void 0 ? void 0 : _d.result) !== null && _e !== void 0 ? _e : empty_array_1.EMPTY_ARRAY, error: props.error, headerRowHeight: props.headerRowHeight, isLoading: props.isLoading, isRowSelectable: props.isRowSelectable, keyExtractor: props.keyExtractor, reload: props.reload, rowAccent: props.rowAccent, rowClassName: props.rowClassName, rowHeight: props.rowHeight, schema: props.schema, state: props.state }),
35
+ react_1.default.createElement(table_v2_1.DataGridTableV2, { NoRowsFallback: props.NoRowsFallback, actionCell: props.actionCell, actions: props.actions, bodyCells: (_c = props.bodyCells) !== null && _c !== void 0 ? _c : body_cell_1.BodyCells, data: (_e = (_d = props.data) === null || _d === void 0 ? void 0 : _d.result) !== null && _e !== void 0 ? _e : empty_array_1.EMPTY_ARRAY, error: props.error, headerRowHeight: props.headerRowHeight, isLoading: props.isLoading, isRowSelectDisabled: props.isRowSelectDisabled, isRowsSelectable: props.isRowsSelectable, keyExtractor: props.keyExtractor, reload: props.reload, rowAccent: props.rowAccent, rowClassName: props.rowClassName, rowHeight: props.rowHeight, schema: props.schema, state: props.state }),
36
36
  react_1.default.createElement(footer_1.DataGridFooter, null,
37
37
  react_1.default.createElement(rows_per_page_select_1.DataGridRowsPerPageSelect, { actions: props.actions, state: props.state }),
38
38
  react_1.default.createElement(row_counts_1.DataGridRowCounts, { count: (_g = (_f = props.data) === null || _f === void 0 ? void 0 : _f.count) !== null && _g !== void 0 ? _g : 0, state: props.state, totalCount: (_j = (_h = props.data) === null || _h === void 0 ? void 0 : _h.totalCount) !== null && _j !== void 0 ? _j : 0 }),
@@ -94,6 +94,6 @@ function Default() {
94
94
  });
95
95
  return (react_1.default.createElement("div", { className: "p-10" },
96
96
  react_1.default.createElement(radio_group_1.RadioGroup, { label: "Chov\u00E1n\u00ED p\u0159ep\u00EDn\u00E1n\u00ED tab\u016F", name: "filterBehavior", onChange: (value) => setFilterBehavior(value), options: FILTER_BEHAVIOR_OPTIONS, value: filterBehavior, variant: "row" }),
97
- react_1.default.createElement(data_grid_v2_1.DataGridV2, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: filterBehavior !== null && filterBehavior !== void 0 ? filterBehavior : "filtersPerTab", data: data, error: error, getCsvDownloadUrl: () => ``, isLoading: isLoading, isRowSelectable: true, reload: reload, rowAccent: (row) => (row.id === 2 ? "success" : undefined), rowClassName: (row) => (row.id === 3 ? "some-custom-classname" : undefined), rowHeight: "auto", schema: schemaWithFrontendConfig, state: state }),
97
+ react_1.default.createElement(data_grid_v2_1.DataGridV2, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: filterBehavior !== null && filterBehavior !== void 0 ? filterBehavior : "filtersPerTab", data: data, error: error, getCsvDownloadUrl: () => ``, isLoading: isLoading, isRowSelectDisabled: (row) => row.id === 6, isRowsSelectable: true, reload: reload, rowAccent: (row) => (row.id === 2 ? "success" : undefined), rowClassName: (row) => (row.id === 3 ? "some-custom-classname" : undefined), rowHeight: "auto", schema: schemaWithFrontendConfig, state: state }),
98
98
  react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
99
99
  }
package/data-grid.js CHANGED
@@ -33,7 +33,7 @@ function DataGrid(props) {
33
33
  react_1.default.createElement(toolbar_customs_1.DataGridToolbarCustoms, { buttons: props.customActions })),
34
34
  react_1.default.createElement(linear_progress_1.DataGridLinearProgress, { isLoading: props.isLoading }),
35
35
  react_1.default.createElement(filter_list_1.DataGridFilterList, { actions: props.actions, filterHandlers: (_b = props.filterHandlers) !== null && _b !== void 0 ? _b : filter_handler_1.defaultFilterHandlers, schema: props.schema, state: props.state }),
36
- react_1.default.createElement(table_1.DataGridTable, { NoRowsFallback: (_c = props.NoRowsFallback) !== null && _c !== void 0 ? _c : no_rows_fallback_1.NoRowsFallback, actionCell: props.actionCell, actions: props.actions, bodyCells: (_d = props.bodyCells) !== null && _d !== void 0 ? _d : body_cell_1.BodyCells, data: (_f = (_e = props.data) === null || _e === void 0 ? void 0 : _e.result) !== null && _f !== void 0 ? _f : empty_array_1.EMPTY_ARRAY, error: props.error, headerRowHeight: props.headerRowHeight, isLoading: props.isLoading, isRowSelectable: props.isRowSelectable, keyExtractor: props.keyExtractor, reload: props.reload, rowClass: props.rowAccent, rowHeight: props.rowHeight === "auto" ? undefined : props.rowHeight, schema: props.schema, state: props.state }),
36
+ react_1.default.createElement(table_1.DataGridTable, { NoRowsFallback: (_c = props.NoRowsFallback) !== null && _c !== void 0 ? _c : no_rows_fallback_1.NoRowsFallback, actionCell: props.actionCell, actions: props.actions, bodyCells: (_d = props.bodyCells) !== null && _d !== void 0 ? _d : body_cell_1.BodyCells, data: (_f = (_e = props.data) === null || _e === void 0 ? void 0 : _e.result) !== null && _f !== void 0 ? _f : empty_array_1.EMPTY_ARRAY, error: props.error, headerRowHeight: props.headerRowHeight, isLoading: props.isLoading, isRowSelectable: props.isRowsSelectable, keyExtractor: props.keyExtractor, reload: props.reload, rowClass: props.rowAccent, rowHeight: props.rowHeight === "auto" ? undefined : props.rowHeight, schema: props.schema, state: props.state }),
37
37
  react_1.default.createElement(footer_1.DataGridFooter, null,
38
38
  react_1.default.createElement(rows_per_page_select_1.DataGridRowsPerPageSelect, { actions: props.actions, state: props.state }),
39
39
  react_1.default.createElement(row_counts_1.DataGridRowCounts, { count: (_h = (_g = props.data) === null || _g === void 0 ? void 0 : _g.count) !== null && _h !== void 0 ? _h : 0, state: props.state, totalCount: (_k = (_j = props.data) === null || _j === void 0 ? void 0 : _j.totalCount) !== null && _k !== void 0 ? _k : 0 }),
@@ -101,6 +101,6 @@ function Default() {
101
101
  });
102
102
  return (react_1.default.createElement("div", { className: "p-10" },
103
103
  react_1.default.createElement(radio_group_1.RadioGroup, { label: "Chov\u00E1n\u00ED p\u0159ep\u00EDn\u00E1n\u00ED tab\u016F", name: "filterBehavior", onChange: (value) => setFilterBehavior(value), options: FILTER_BEHAVIOR_OPTIONS, value: filterBehavior, variant: "row" }),
104
- react_1.default.createElement(data_grid_1.DataGrid, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: filterBehavior !== null && filterBehavior !== void 0 ? filterBehavior : "filtersPerTab", data: data, error: error, getCsvDownloadUrl: () => "", isLoading: isLoading, isRowSelectable: true, reload: reload, schema: schemaWithFrontendConfig, state: state }),
104
+ react_1.default.createElement(data_grid_1.DataGrid, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: filterBehavior !== null && filterBehavior !== void 0 ? filterBehavior : "filtersPerTab", data: data, error: error, getCsvDownloadUrl: () => "", isLoading: isLoading, isRowsSelectable: true, reload: reload, schema: schemaWithFrontendConfig, state: state }),
105
105
  react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
106
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/data-grid",
3
- "version": "11.77.2",
3
+ "version": "11.79.0",
4
4
  "description": "UXF DataGrid",
5
5
  "homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
6
6
  "main": "index.js",
@@ -31,9 +31,9 @@
31
31
  "typecheck": "tsc --noEmit --skipLibCheck"
32
32
  },
33
33
  "dependencies": {
34
- "@uxf/core": "11.72.3",
35
- "@uxf/core-react": "11.74.4",
36
- "@uxf/ui": "11.77.2",
34
+ "@uxf/core": "11.78.0",
35
+ "@uxf/core-react": "11.78.0",
36
+ "@uxf/ui": "11.79.0",
37
37
  "dayjs": "1.11.13",
38
38
  "deepmerge": "4.3.1",
39
39
  "fast-glob": "3.3.2",
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { KeyExtractor } from "../../types";
3
3
  import { DataGridTableProps } from "../types";
4
- interface SelectRowCheckboxProps extends Pick<DataGridTableProps<any>, "state" | "data" | "actions"> {
4
+ interface SelectRowCheckboxProps extends Pick<DataGridTableProps<any>, "state" | "data" | "actions" | "isRowSelectDisabled"> {
5
5
  keyExtractor: KeyExtractor;
6
6
  }
7
7
  export declare function HeaderSelectAllRowsCheckbox(props: SelectRowCheckboxProps): React.JSX.Element;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HeaderSelectAllRowsCheckbox = HeaderSelectAllRowsCheckbox;
7
7
  const translations_1 = require("@uxf/core-react/translations");
8
8
  const empty_array_1 = require("@uxf/core/constants/empty-array");
9
+ const is_nil_1 = require("@uxf/core/utils/is-nil");
9
10
  const is_not_empty_1 = require("@uxf/core/utils/is-not-empty");
10
11
  const checkbox_input_1 = require("@uxf/ui/checkbox-input");
11
12
  const react_1 = __importDefault(require("react"));
@@ -17,8 +18,10 @@ function HeaderSelectAllRowsCheckbox(props) {
17
18
  props.data.every((row) => selectedRows.find((selectedRow) => props.keyExtractor(row) === props.keyExtractor(selectedRow)));
18
19
  const isIndeterminate = !isAllRowsSelected && (0, is_not_empty_1.isNotEmpty)(selectedRows);
19
20
  const selectAllRowsHandler = () => {
20
- props.actions.setSelectedRows(isAllRowsSelected ? [] : props.data);
21
+ props.actions.setSelectedRows(isAllRowsSelected || isIndeterminate
22
+ ? []
23
+ : props.data.filter((row) => (0, is_nil_1.isNil)(props.isRowSelectDisabled) || !props.isRowSelectDisabled(row)));
21
24
  };
22
25
  return (react_1.default.createElement("div", { className: "uxf-dg-table__cell uxf-dg-table__cell--header uxf-dg-table__select-all-rows-cell" },
23
- react_1.default.createElement(checkbox_input_1.CheckboxInput, { hiddenLabel: true, indeterminate: isIndeterminate, label: t("uxf-data-grid-checkboxes:select-all"), name: "select-all-rows", onChange: selectAllRowsHandler, value: isAllRowsSelected })));
26
+ react_1.default.createElement(checkbox_input_1.CheckboxInput, { hiddenLabel: true, indeterminate: isIndeterminate, label: t("uxf-data-grid-checkboxes:select-all"), name: "select-all-rows", onChange: selectAllRowsHandler, value: isAllRowsSelected || isIndeterminate })));
24
27
  }
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  interface SelectRowCheckboxProps {
3
+ isRowSelectDisabled: boolean;
3
4
  isRowSelected: boolean;
4
5
  onSelectRowChange: () => void;
5
6
  }
@@ -10,5 +10,5 @@ const react_1 = __importDefault(require("react"));
10
10
  function SelectRowCheckbox(props) {
11
11
  const t = (0, translations_1.useUxfTranslation)();
12
12
  return (react_1.default.createElement("div", { className: "uxf-dg-table__cell uxf-dg-table__select-row-cell" },
13
- react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: "*:mt-0", hiddenLabel: true, label: t("uxf-data-grid-checkboxes:select"), name: "select-row", onChange: props.onSelectRowChange, value: props.isRowSelected })));
13
+ react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: "*:mt-0", hiddenLabel: true, isDisabled: props.isRowSelectDisabled, label: t("uxf-data-grid-checkboxes:select"), name: "select-row", onChange: props.onSelectRowChange, value: props.isRowSelected })));
14
14
  }
@@ -28,7 +28,7 @@ function DataGridTableV2(props) {
28
28
  const visibleColumns = props.schema.columns
29
29
  .filter((column) => !column.hidden)
30
30
  .filter((column) => { var _a, _b, _c, _d; return !((_c = (_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b.isHidden) !== null && _c !== void 0 ? _c : (_d = column.config) === null || _d === void 0 ? void 0 : _d.isHidden); });
31
- const selectedRowColumnWidth = props.isRowSelectable ? SELECT_ROWS_CELL_WIDTH : null;
31
+ const selectedRowColumnWidth = props.isRowsSelectable ? SELECT_ROWS_CELL_WIDTH : null;
32
32
  const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions, selectedRowColumnWidth);
33
33
  const gridTemplateRows = (0, get_grid_template_rows_1.getGridTemplateRows)(props.data, (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36, (_c = props.rowHeight) !== null && _c !== void 0 ? _c : 44);
34
34
  const gridTemplateBasicColumns = visibleColumns
@@ -62,8 +62,8 @@ function DataGridTableV2(props) {
62
62
  return (react_1.default.createElement(components_1.Table, { gridTemplateColumns: gridTemplateColumns, gridTemplateRows: gridTemplateRows, ref: tableRef },
63
63
  react_1.default.createElement(components_1.Table.Header, null,
64
64
  react_1.default.createElement(components_1.Table.Row, null,
65
- react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
66
- react_1.default.createElement(header_select_all_rows_checkbox_1.HeaderSelectAllRowsCheckbox, { actions: props.actions, data: props.data, keyExtractor: keyExtractor, state: props.state })),
65
+ react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowsSelectable) },
66
+ react_1.default.createElement(header_select_all_rows_checkbox_1.HeaderSelectAllRowsCheckbox, { actions: props.actions, data: props.data, isRowSelectDisabled: props.isRowSelectDisabled, keyExtractor: keyExtractor, state: props.state })),
67
67
  visibleColumns.map((column, index) => {
68
68
  var _a;
69
69
  return (react_1.default.createElement(components_1.Table.HeaderCell, { column: column, key: column.name, onClick: column.sort ? () => props.actions.sort(column.name) : undefined, onResizeStart: () => onResizeStart(index), ref: (el) => {
@@ -75,8 +75,8 @@ function DataGridTableV2(props) {
75
75
  react_1.default.createElement(components_1.Table.Body, null, (0, is_empty_1.isEmpty)(props.data) ? (react_1.default.createElement(NoRowsFallback, { error: props.error, isLoading: Boolean(props.isLoading) })) : (props.data.map((row) => {
76
76
  var _a, _b;
77
77
  return (react_1.default.createElement(components_1.Table.Row, { className: `${(0, is_not_nil_1.isNotNil)(props.rowAccent) ? "uxf-dg-table__row--" + props.rowAccent(row) : ""} ${(_b = (_a = props.rowClassName) === null || _a === void 0 ? void 0 : _a.call(props, row)) !== null && _b !== void 0 ? _b : ""}`, key: keyExtractor(row) },
78
- react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
79
- react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { isRowSelected: selectedRows.find((r) => keyExtractor(r) === keyExtractor(row)), onSelectRowChange: selectRowHandler(keyExtractor(row)) })),
78
+ react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowsSelectable) },
79
+ react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { isRowSelectDisabled: props.isRowSelectDisabled ? props.isRowSelectDisabled(row) : false, isRowSelected: selectedRows.find((r) => keyExtractor(r) === keyExtractor(row)), onSelectRowChange: selectRowHandler(keyExtractor(row)) })),
80
80
  visibleColumns.map((column) => {
81
81
  var _a, _b, _c, _d;
82
82
  const BodyCell =
@@ -18,6 +18,6 @@ function Default() {
18
18
  const reload = () => new Promise(() => null);
19
19
  return (react_1.default.createElement(react_1.default.Fragment, null,
20
20
  react_1.default.createElement(hidden_columns_button_1.DataGridHiddenColumnsButton, { actions: actions, schema: schema_1.schema, state: state }),
21
- react_1.default.createElement(table_v2_1.DataGridTableV2, { actionCell: { width: 150, Component: () => react_1.default.createElement(action_cell_1.ActionCell, null, "Action cell") }, actions: actions, bodyCells: body_cell_1.BodyCells, data: data_1.data, error: undefined, isLoading: true, isRowSelectable: true, reload: reload, rowAccent: (row) => (row.id === 2 ? "success" : undefined), rowClassName: (row) => (row.id === 3 ? "some-custom-classname" : undefined), schema: schema_1.schema, state: state }),
21
+ react_1.default.createElement(table_v2_1.DataGridTableV2, { actionCell: { width: 150, Component: () => react_1.default.createElement(action_cell_1.ActionCell, null, "Action cell") }, actions: actions, bodyCells: body_cell_1.BodyCells, data: data_1.data, error: undefined, isLoading: true, isRowsSelectable: true, reload: reload, rowAccent: (row) => (row.id === 2 ? "success" : undefined), rowClassName: (row) => (row.id === 3 ? "some-custom-classname" : undefined), schema: schema_1.schema, state: state }),
22
22
  react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
23
23
  }
@@ -19,5 +19,6 @@ export interface DataGridTableProps<Row> extends DataGridControl {
19
19
  Component: ActionCellComponent<Row>;
20
20
  };
21
21
  NoRowsFallback?: NoRowsFallbackComponent;
22
- isRowSelectable?: boolean;
22
+ isRowSelectDisabled?: (row: Row) => boolean;
23
+ isRowsSelectable?: boolean;
23
24
  }
@@ -27,7 +27,8 @@ export type DataGridBaseProps<GridType extends BaseGridType, Row> = {
27
27
  filterHandlers?: FilterHandlers;
28
28
  NoRowsFallback?: NoRowsFallbackComponent;
29
29
  SelectedRowsToolbarActions?: SelectedRowsToolbarActionsComponent;
30
- isRowSelectable?: boolean;
30
+ isRowsSelectable?: boolean;
31
+ isRowSelectDisabled?: (row: Row) => boolean;
31
32
  isDebug?: boolean;
32
33
  changeTabFilterBehavior?: ChangeTabFilterBehavior;
33
34
  };