@uxf/data-grid 11.16.0 → 11.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.schema = void 0;
4
4
  exports.schema = {
5
5
  columns: [
6
- { name: "id", type: "number", label: "Id", sort: true, config: { width: 50 } },
6
+ { name: "id", type: "number", label: "Id", sort: true, config: { width: 50, isHidden: true } },
7
7
  { name: "text", type: "string", label: "Text", sort: true },
8
8
  { name: "bool", type: "boolean", label: "Boolean" },
9
9
  { name: "mail", type: "email", label: "E-mail" },
@@ -8,8 +8,8 @@ const toggle_1 = require("@uxf/ui/toggle");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  function HiddenColumns(props) {
10
10
  return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-control-columns" }, props.schema.columns.map((column) => {
11
- var _a, _b;
12
- return (react_1.default.createElement(toggle_1.Toggle, { key: column.name, label: typeof column.label === "string" ? column.label : "", value: !((_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b.isHidden), onChange: (value) => value ? props.actions.showColumn(column.name) : props.actions.hideColumn(column.name), name: column.name }));
11
+ var _a, _b, _c, _d;
12
+ return (react_1.default.createElement(toggle_1.Toggle, { key: column.name, label: typeof column.label === "string" ? column.label : "", value: !((_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), onChange: (value) => value ? props.actions.showColumn(column.name) : props.actions.hideColumn(column.name), name: column.name }));
13
13
  })));
14
14
  }
15
15
  exports.HiddenColumns = HiddenColumns;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/data-grid",
3
- "version": "11.16.0",
3
+ "version": "11.17.1",
4
4
  "description": "UXF DataGrid",
5
5
  "homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
6
6
  "main": "index.js",
@@ -21,16 +21,17 @@ function useResizableColumns(columns, actionCell, actions) {
21
21
  let tempColumnSizes = [];
22
22
  const onMouseMove = (e) => {
23
23
  const gridColumns = columns.map((_, i) => {
24
- var _a, _b, _c, _d;
24
+ var _a, _b, _c, _d, _e, _f;
25
25
  const columnRef = columnRefs.current[i];
26
26
  if (i === activeIndex) {
27
- const tableScrollLeft = (_b = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) !== null && _b !== void 0 ? _b : 0;
28
- const columnOffsetLeft = (_c = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetLeft) !== null && _c !== void 0 ? _c : 0;
27
+ const tableLeft = (_b = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left) !== null && _b !== void 0 ? _b : 0;
28
+ const tableScrollLeft = (_d = (_c = tableRef.current) === null || _c === void 0 ? void 0 : _c.scrollLeft) !== null && _d !== void 0 ? _d : 0;
29
+ const columnOffsetLeft = (_e = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetLeft) !== null && _e !== void 0 ? _e : 0;
29
30
  const clickPositionX = e.clientX + tableScrollLeft;
30
- const width = clickPositionX - columnOffsetLeft;
31
+ const width = clickPositionX - columnOffsetLeft - tableLeft;
31
32
  return width >= 50 ? width : 50;
32
33
  }
33
- return (_d = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetWidth) !== null && _d !== void 0 ? _d : 50;
34
+ return (_f = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetWidth) !== null && _f !== void 0 ? _f : 50;
34
35
  });
35
36
  // TODO @vejvis - jak tohle udělat lépe??
36
37
  tempColumnSizes = gridColumns;
@@ -13,11 +13,11 @@ const components_1 = require("./components");
13
13
  const use_resizable_columns_1 = require("./hooks/use-resizable-columns");
14
14
  const get_grid_template_rows_1 = require("./utils/get-grid-template-rows");
15
15
  const defaultKeyExtractor = (r) => r.id;
16
- const DefaultBodyCell = () => null;
16
+ const DefaultBodyCell = () => "Unknown body cell.";
17
17
  function TableV2(props) {
18
18
  var _a, _b, _c, _d;
19
19
  const keyExtractor = (_a = props.keyExtractor) !== null && _a !== void 0 ? _a : defaultKeyExtractor;
20
- const visibleColumns = props.schema.columns.filter((column) => { var _a, _b; return !((_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b.isHidden); });
20
+ const visibleColumns = props.schema.columns.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); });
21
21
  const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions);
22
22
  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);
23
23
  const gridTemplateColumnsWithoutAction = visibleColumns
@@ -39,7 +39,9 @@ function TableV2(props) {
39
39
  react_1.default.createElement(components_1.Table.Body, null, props.data.map((row) => (react_1.default.createElement(components_1.Table.Row, { key: keyExtractor(row) },
40
40
  visibleColumns.map((column) => {
41
41
  var _a, _b, _c, _d;
42
- const BodyCell = (_d = (_b = (_a = props.bodyCells) === null || _a === void 0 ? void 0 : _a[column.type]) !== null && _b !== void 0 ? _b : (_c = props.bodyCells) === null || _c === void 0 ? void 0 : _c.default) !== null && _d !== void 0 ? _d : DefaultBodyCell;
42
+ const BodyCell =
43
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
44
+ (_d = (_b = (_a = props.bodyCells) === null || _a === void 0 ? void 0 : _a[column.type]) !== null && _b !== void 0 ? _b : (_c = props.bodyCells) === null || _c === void 0 ? void 0 : _c.default) !== null && _d !== void 0 ? _d : DefaultBodyCell;
43
45
  return (react_1.default.createElement(components_1.Table.Cell, { key: column.name },
44
46
  react_1.default.createElement(BodyCell, { column: column, row: row, value: row[column.name], reload: () => { var _a; return (_a = props.onReload) === null || _a === void 0 ? void 0 : _a.call(props); } })));
45
47
  }),