@uxf/data-grid 11.0.0-beta.13 → 11.0.0-beta.15

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.
@@ -19,5 +19,6 @@ export type GridType = {
19
19
  link: "string";
20
20
  sele: "select";
21
21
  seleBool: "select";
22
+ multiSelect: "multiSelect";
22
23
  };
23
24
  };
@@ -29,7 +29,7 @@ const loader = async (_, request) => {
29
29
  await new Promise((resolve) => setTimeout(resolve, 1000));
30
30
  return {
31
31
  count: filteredData.length,
32
- totalCount: filteredData.length,
32
+ totalCount: data_1.data.length,
33
33
  result: filteredData.slice(page * perPage, page * perPage + perPage),
34
34
  };
35
35
  };
@@ -31,6 +31,17 @@ exports.schema = {
31
31
  { id: 2, label: "B" },
32
32
  ],
33
33
  },
34
+ {
35
+ name: "multiSelect",
36
+ label: "Multi select",
37
+ type: "multiSelect",
38
+ options: [
39
+ { label: "Option 1", id: "option-1" },
40
+ { label: "Option 2", id: "option-2" },
41
+ { label: "Option 3", id: "option-3" },
42
+ { label: "Option 4", id: "option-4" },
43
+ ],
44
+ },
34
45
  {
35
46
  name: "seleBool",
36
47
  type: "select",
package/data-grid.js CHANGED
@@ -23,7 +23,7 @@ const toolbar_tabs_1 = require("./toolbar-tabs");
23
23
  const classes_1 = require("./utils/classes");
24
24
  const DefaultSelectedRowsToolbarActions = () => null;
25
25
  function DataGrid(props) {
26
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
27
27
  return (react_1.default.createElement(react_1.default.Fragment, null,
28
28
  react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid", props.noBorder && classes_1.NO_BORDER_CLASS, props.className) },
29
29
  react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid__toolbar", props.noBorder && classes_1.NO_BORDER_CLASS) },
@@ -35,8 +35,8 @@ function DataGrid(props) {
35
35
  react_1.default.createElement(table_1.Table, { state: props.state, actions: props.actions, schema: props.schema, data: (_f = (_e = props.data) === null || _e === void 0 ? void 0 : _e.result) !== null && _f !== void 0 ? _f : [], isLoading: props.isLoading, error: props.error, rowClass: props.rowClass, keyExtractor: props.keyExtractor, rowHeight: props.rowHeight, headerRowHeight: props.headerRowHeight, BodyCells: (_h = (_g = props.ui) === null || _g === void 0 ? void 0 : _g.BodyCells) !== null && _h !== void 0 ? _h : body_cell_1.BodyCells, NoRowsFallback: (_k = (_j = props.ui) === null || _j === void 0 ? void 0 : _j.NoRowsFallback) !== null && _k !== void 0 ? _k : no_rows_fallback_1.NoRowsFallback, ActionCell: (_m = (_l = props.ui) === null || _l === void 0 ? void 0 : _l.ActionCell) !== null && _m !== void 0 ? _m : action_cell_base_1.ActionCellBase, onRemove: props.onRemove, onEdit: props.onEdit, getEditUrl: props.getEditUrl, onOpen: props.onOpen, getOpenUrl: props.getOpenUrl, onReload: props.onReload, isRowSelectable: props.isRowSelectable }),
36
36
  react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid__footer", props.noBorder && classes_1.NO_BORDER_CLASS) },
37
37
  react_1.default.createElement(rows_per_page_select_1.RowsPerPageSelect, { state: props.state, actions: props.actions }),
38
- react_1.default.createElement(row_counts_1.RowCounts, { state: props.state, totalCount: (_p = (_o = props.data) === null || _o === void 0 ? void 0 : _o.totalCount) !== null && _p !== void 0 ? _p : 0 }),
39
- react_1.default.createElement(pagination_1.Pagination, { state: props.state, actions: props.actions, count: (_r = (_q = props.data) === null || _q === void 0 ? void 0 : _q.count) !== null && _r !== void 0 ? _r : 0 }))),
40
- react_1.default.createElement(selected_rows_toolbar_1.SelectedRowsToolbar, { state: props.state, actions: props.actions, Actions: (_t = (_s = props.ui) === null || _s === void 0 ? void 0 : _s.SelectedRowsToolbarActions) !== null && _t !== void 0 ? _t : DefaultSelectedRowsToolbarActions })));
38
+ react_1.default.createElement(row_counts_1.RowCounts, { state: props.state, count: (_p = (_o = props.data) === null || _o === void 0 ? void 0 : _o.count) !== null && _p !== void 0 ? _p : 0, totalCount: (_r = (_q = props.data) === null || _q === void 0 ? void 0 : _q.totalCount) !== null && _r !== void 0 ? _r : 0 }),
39
+ react_1.default.createElement(pagination_1.Pagination, { state: props.state, actions: props.actions, count: (_t = (_s = props.data) === null || _s === void 0 ? void 0 : _s.count) !== null && _t !== void 0 ? _t : 0 }))),
40
+ react_1.default.createElement(selected_rows_toolbar_1.SelectedRowsToolbar, { state: props.state, actions: props.actions, Actions: (_v = (_u = props.ui) === null || _u === void 0 ? void 0 : _u.SelectedRowsToolbarActions) !== null && _v !== void 0 ? _v : DefaultSelectedRowsToolbarActions })));
41
41
  }
42
42
  exports.DataGrid = DataGrid;
@@ -22,6 +22,7 @@ const bool_filter_1 = __importDefault(require("./bool-filter"));
22
22
  const boolean_filter_1 = __importDefault(require("./boolean-filter"));
23
23
  const date_1 = __importDefault(require("./date"));
24
24
  const interval_filter_1 = __importDefault(require("./interval-filter"));
25
+ const multi_select_1 = __importDefault(require("./multi-select"));
25
26
  const select_filter_1 = __importDefault(require("./select-filter"));
26
27
  const text_filter_1 = __importDefault(require("./text-filter"));
27
28
  __exportStar(require("./types"), exports);
@@ -33,5 +34,6 @@ exports.defaultFilterHandlers = {
33
34
  boolean: boolean_filter_1.default,
34
35
  checkbox: boolean_filter_1.default,
35
36
  interval: interval_filter_1.default,
37
+ multiSelect: multi_select_1.default,
36
38
  select: select_filter_1.default,
37
39
  };
@@ -0,0 +1,3 @@
1
+ import { FilterHandler } from "./types";
2
+ declare const multiSelect: FilterHandler;
3
+ export default multiSelect;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const is_nil_1 = require("@uxf/core/utils/is-nil");
7
+ const chip_1 = require("@uxf/ui/chip");
8
+ const multi_select_1 = require("@uxf/ui/multi-select");
9
+ const react_1 = __importDefault(require("react"));
10
+ const multiSelect = {
11
+ input: (props) => {
12
+ var _a, _b;
13
+ return (react_1.default.createElement(multi_select_1.MultiSelect, { options: (_a = props.filter.options) !== null && _a !== void 0 ? _a : [], label: props.filter.label, value: (_b = props.value.value) === null || _b === void 0 ? void 0 : _b.map((id) => { var _a; return (_a = props.filter.options) === null || _a === void 0 ? void 0 : _a.find((option) => option.id === id); }), onChange: (value) => {
14
+ props.onFilter({
15
+ ...props.value,
16
+ value: (0, is_nil_1.isNil)(value) || value.length === 0 ? null : value.map((item) => item.id),
17
+ });
18
+ } }));
19
+ },
20
+ listItem: (props) => {
21
+ return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
22
+ props.filter.label,
23
+ ":\u00A0",
24
+ props.value.value
25
+ .map((id) => { var _a, _b; return (_b = (_a = props.filter.options) === null || _a === void 0 ? void 0 : _a.find((option) => option.id === id)) === null || _b === void 0 ? void 0 : _b.label; })
26
+ .join(", ")));
27
+ },
28
+ };
29
+ exports.default = multiSelect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/data-grid",
3
- "version": "11.0.0-beta.13",
3
+ "version": "11.0.0-beta.15",
4
4
  "description": "UXF DataGrid",
5
5
  "homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
6
6
  "main": "index.js",
@@ -3,5 +3,6 @@ import { DataGridControl } from "../use-data-grid-control";
3
3
  export interface RowCountsProps {
4
4
  state: DataGridControl["state"];
5
5
  totalCount: number;
6
+ count: number;
6
7
  }
7
8
  export declare function RowCounts(props: RowCountsProps): React.JSX.Element;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RowCounts = void 0;
7
+ const show_1 = require("@uxf/core/components/show");
7
8
  const react_1 = __importDefault(require("react"));
8
9
  function RowCounts(props) {
9
10
  const fromNumber = props.state.request.page * props.state.request.perPage + 1;
@@ -13,6 +14,11 @@ function RowCounts(props) {
13
14
  "-",
14
15
  toNumber,
15
16
  " z ",
16
- props.totalCount));
17
+ props.count,
18
+ " ",
19
+ react_1.default.createElement(show_1.Show, { when: props.count !== props.totalCount },
20
+ "(celkem ",
21
+ props.totalCount,
22
+ ")")));
17
23
  }
18
24
  exports.RowCounts = RowCounts;
@@ -10,6 +10,6 @@ const use_data_grid_control_1 = require("../use-data-grid-control");
10
10
  const row_counts_1 = require("./row-counts");
11
11
  function Default() {
12
12
  const { state } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
13
- return react_1.default.createElement(row_counts_1.RowCounts, { state: state, totalCount: 150 });
13
+ return react_1.default.createElement(row_counts_1.RowCounts, { state: state, totalCount: 150, count: 100 });
14
14
  }
15
15
  exports.Default = Default;