@uxf/data-grid 11.38.3 → 11.39.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/_store/reducer.js CHANGED
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.debugReducer = exports.reducer = void 0;
7
7
  exports.getInitialState = getInitialState;
8
+ const empty_array_1 = require("@uxf/core/constants/empty-array");
9
+ const empty_object_1 = require("@uxf/core/constants/empty-object");
8
10
  const is_nil_1 = require("@uxf/core/utils/is-nil");
9
11
  const deepmerge_1 = __importDefault(require("deepmerge"));
10
12
  const utils_1 = require("../utils");
@@ -28,7 +30,7 @@ function getInitialState(schema, init, initialUserConfig) {
28
30
  }
29
31
  // eslint-disable-next-line complexity
30
32
  const reducer = (state, action) => {
31
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
33
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
32
34
  switch (action.type) {
33
35
  case "CHANGE_PAGE":
34
36
  return {
@@ -120,26 +122,34 @@ const reducer = (state, action) => {
120
122
  };
121
123
  case "CHANGE_TAB": {
122
124
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
123
- const tabHistory = (_d = state.tabRequests[action.tab.name]) !== null && _d !== void 0 ? _d : {};
125
+ const tabHistory = (_d = state.tabRequests[action.tab.name]) !== null && _d !== void 0 ? _d : empty_object_1.EMPTY_OBJECT;
124
126
  return {
125
127
  ...state,
126
- request: action.filterBehavior === "sharedFilters"
127
- ? { ...state.request, tab: action.tab.name }
128
- : {
129
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
130
- f: (_e = tabHistory.f) !== null && _e !== void 0 ? _e : [],
131
- s: (_g = (_f = tabHistory.s) !== null && _f !== void 0 ? _f : action.tab.s) !== null && _g !== void 0 ? _g : state.request.s,
132
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
133
- search: (_h = tabHistory.search) !== null && _h !== void 0 ? _h : "",
128
+ request: {
129
+ ...state.request,
130
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
131
+ page: (_e = tabHistory.page) !== null && _e !== void 0 ? _e : 0,
132
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
133
+ perPage: (_f = tabHistory.perPage) !== null && _f !== void 0 ? _f : state.request.perPage,
134
+ tab: action.tab.name,
135
+ // when sharedFiltersAndSearchAndSort, f, s and search is in common state.request, i.e. same like
136
+ //...(action.filterBehavior === "sharedFiltersAndSearchAndSort" && {}),
137
+ // sort is handled separately for each tab
138
+ ...(action.filterBehavior === "sharedFiltersAndSearch" && {
139
+ s: (_h = (_g = tabHistory.s) !== null && _g !== void 0 ? _g : action.tab.s) !== null && _h !== void 0 ? _h : state.request.s,
140
+ }),
141
+ // filter, search and sort are all handled separately for each tab
142
+ ...(action.filterBehavior === "filtersPerTab" && {
134
143
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
135
- page: (_j = tabHistory.page) !== null && _j !== void 0 ? _j : 0,
144
+ f: (_j = tabHistory.f) !== null && _j !== void 0 ? _j : empty_array_1.EMPTY_ARRAY,
145
+ s: (_l = (_k = tabHistory.s) !== null && _k !== void 0 ? _k : action.tab.s) !== null && _l !== void 0 ? _l : state.request.s,
136
146
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
137
- perPage: (_k = tabHistory.perPage) !== null && _k !== void 0 ? _k : state.request.perPage,
138
- tab: action.tab.name,
139
- },
147
+ search: (_m = tabHistory.search) !== null && _m !== void 0 ? _m : "",
148
+ }),
149
+ },
140
150
  tabRequests: {
141
151
  ...state.tabRequests,
142
- [(_l = state.request.tab) !== null && _l !== void 0 ? _l : "__DEFAULT_TAB__"]: state.request,
152
+ [(_o = state.request.tab) !== null && _o !== void 0 ? _o : "__DEFAULT_TAB__"]: state.request,
143
153
  },
144
154
  };
145
155
  }
@@ -156,7 +166,7 @@ const reducer = (state, action) => {
156
166
  columns: {
157
167
  ...state.userConfig.columns,
158
168
  [action.name]: {
159
- ...(_m = state.userConfig.columns) === null || _m === void 0 ? void 0 : _m[action.name],
169
+ ...(_p = state.userConfig.columns) === null || _p === void 0 ? void 0 : _p[action.name],
160
170
  isHidden: true,
161
171
  },
162
172
  },
@@ -170,7 +180,7 @@ const reducer = (state, action) => {
170
180
  columns: {
171
181
  ...state.userConfig.columns,
172
182
  [action.name]: {
173
- ...(_o = state.userConfig.columns) === null || _o === void 0 ? void 0 : _o[action.name],
183
+ ...(_q = state.userConfig.columns) === null || _q === void 0 ? void 0 : _q[action.name],
174
184
  isHidden: false,
175
185
  },
176
186
  },
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Default = Default;
27
27
  const buildArray_1 = require("@uxf/core/utils/buildArray");
28
- const toggle_1 = require("@uxf/ui/toggle");
28
+ const radio_group_1 = require("@uxf/ui/radio-group");
29
29
  const react_1 = __importStar(require("react"));
30
30
  const json_renderer_1 = require("./_story-utils/json-renderer");
31
31
  const loader_1 = require("./_story-utils/loader");
@@ -67,8 +67,13 @@ const schemaWithFrontendConfig = (0, merge_schema_with_config_1.mergeSchemaWithC
67
67
  text: { placeholder: "Custom placeholder ..." },
68
68
  },
69
69
  });
70
+ const FILTER_BEHAVIOR_OPTIONS = [
71
+ { id: "filtersPerTab", label: "filterPerTab" },
72
+ { id: "sharedFiltersAndSearch", label: "sharedFiltersAndSearch" },
73
+ { id: "sharedFiltersAndSearchAndSort", label: "sharedFiltersAndSearchAndSort" },
74
+ ];
70
75
  function Default() {
71
- const [hasSharedFilters, setHasSharedFilters] = (0, react_1.useState)(false);
76
+ const [filterBehavior, setFilterBehavior] = (0, react_1.useState)("filtersPerTab");
72
77
  const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
73
78
  schema: schema_1.schema,
74
79
  initialUserConfig: {
@@ -86,7 +91,7 @@ function Default() {
86
91
  state,
87
92
  });
88
93
  return (react_1.default.createElement("div", { className: "p-10" },
89
- react_1.default.createElement(toggle_1.Toggle, { label: "Has shared Filters for all Tabs", name: "hasSharedFilters", onChange: (value) => setHasSharedFilters(Boolean(value)), value: hasSharedFilters }),
90
- react_1.default.createElement(data_grid_v2_1.DataGridV2, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: hasSharedFilters ? "sharedFilters" : "filtersPerTab", data: data, error: error, isLoading: isLoading, isRowSelectable: true, onCsvDownload: console.log, onReload: onReload, schema: schemaWithFrontendConfig, state: state }),
94
+ 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 }),
95
+ 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, isLoading: isLoading, isRowSelectable: true, onCsvDownload: console.log, onReload: onReload, schema: schemaWithFrontendConfig, state: state }),
91
96
  react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
92
97
  }
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Default = Default;
27
27
  const buildArray_1 = require("@uxf/core/utils/buildArray");
28
- const toggle_1 = require("@uxf/ui/toggle");
28
+ const radio_group_1 = require("@uxf/ui/radio-group");
29
29
  const react_1 = __importStar(require("react"));
30
30
  const json_renderer_1 = require("./_story-utils/json-renderer");
31
31
  const loader_1 = require("./_story-utils/loader");
@@ -67,8 +67,13 @@ const schemaWithFrontendConfig = (0, merge_schema_with_config_1.mergeSchemaWithC
67
67
  text: { placeholder: "Custom placeholder ..." },
68
68
  },
69
69
  });
70
+ const FILTER_BEHAVIOR_OPTIONS = [
71
+ { id: "filtersPerTab", label: "filterPerTab" },
72
+ { id: "sharedFiltersAndSearch", label: "sharedFiltersAndSearch" },
73
+ { id: "sharedFiltersAndSearchAndSort", label: "sharedFiltersAndSearchAndSort" },
74
+ ];
70
75
  function Default() {
71
- const [hasSharedFilters, setHasSharedFilters] = (0, react_1.useState)(false);
76
+ const [filterBehavior, setFilterBehavior] = (0, react_1.useState)("filtersPerTab");
72
77
  const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
73
78
  schema: schema_1.schema,
74
79
  initialUserConfig: {
@@ -86,7 +91,7 @@ function Default() {
86
91
  state,
87
92
  });
88
93
  return (react_1.default.createElement("div", { className: "p-10" },
89
- react_1.default.createElement(toggle_1.Toggle, { label: "Has shared Filters for all Tabs", name: "hasSharedFilters", onChange: (value) => setHasSharedFilters(Boolean(value)), value: hasSharedFilters }),
90
- react_1.default.createElement(data_grid_1.DataGrid, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: hasSharedFilters ? "sharedFilters" : "filtersPerTab", data: data, error: error, isLoading: isLoading, isRowSelectable: true, onCsvDownload: console.log, onReload: onReload, schema: schemaWithFrontendConfig, state: state }),
94
+ 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" }),
95
+ react_1.default.createElement(data_grid_1.DataGrid, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: filterBehavior !== null && filterBehavior !== void 0 ? filterBehavior : "filtersPerTab", data: data, error: error, isLoading: isLoading, isRowSelectable: true, onCsvDownload: console.log, onReload: onReload, schema: schemaWithFrontendConfig, state: state }),
91
96
  react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
92
97
  }
@@ -1,4 +1,6 @@
1
1
  import React from "react";
2
2
  import { DataGridControl } from "../use-data-grid-control";
3
- export type DataGridFulltextInputProps = DataGridControl;
3
+ export type DataGridFulltextInputProps = DataGridControl & {
4
+ placeholder?: string;
5
+ };
4
6
  export declare function DataGridFulltextInput(props: DataGridFulltextInputProps): React.JSX.Element;
@@ -8,5 +8,6 @@ const icon_1 = require("@uxf/ui/icon");
8
8
  const text_input_1 = require("@uxf/ui/text-input");
9
9
  const react_1 = __importDefault(require("react"));
10
10
  function DataGridFulltextInput(props) {
11
- return (react_1.default.createElement(text_input_1.TextInput, { className: "uxf-data-grid__plugin-fulltext", hiddenLabel: true, label: "Vyhled\u00E1v\u00E1n\u00ED", leftElement: react_1.default.createElement(icon_1.Icon, { name: "search", size: 16 }), name: "fulltext", onChange: props.actions.search, placeholder: "Pi\u0161te pro hled\u00E1n\u00ED", size: "small", value: props.state.request.search }));
11
+ var _a;
12
+ return (react_1.default.createElement(text_input_1.TextInput, { className: "uxf-data-grid__plugin-fulltext", hiddenLabel: true, label: "Vyhled\u00E1v\u00E1n\u00ED", leftElement: react_1.default.createElement(icon_1.Icon, { name: "search", size: 16 }), name: "fulltext", onChange: props.actions.search, placeholder: (_a = props.placeholder) !== null && _a !== void 0 ? _a : "Pište pro hledání", size: "small", value: props.state.request.search }));
12
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/data-grid",
3
- "version": "11.38.3",
3
+ "version": "11.39.0",
4
4
  "description": "UXF DataGrid",
5
5
  "homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
6
6
  "main": "index.js",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@uxf/core": "11.35.0",
35
35
  "@uxf/core-react": "11.38.3",
36
- "@uxf/ui": "11.38.3",
36
+ "@uxf/ui": "11.39.0",
37
37
  "dayjs": "1.11.13",
38
38
  "deepmerge": "4.3.1",
39
39
  "fast-glob": "3.3.2",
@@ -8,5 +8,6 @@ export interface DataGridToolbarControlProps extends DataGridControl {
8
8
  filterHandlers: FilterHandlers;
9
9
  onCsvDownload?: CsvDownloadHandler;
10
10
  isBorderHidden?: boolean | Nullish;
11
+ fulltextInputPlaceholder?: string;
11
12
  }
12
13
  export declare function DataGridToolbarControl(props: DataGridToolbarControlProps): React.JSX.Element;
@@ -14,7 +14,7 @@ const hidden_columns_button_1 = require("../hidden-columns-button");
14
14
  function DataGridToolbarControl(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
- react_1.default.createElement(fulltext_input_1.DataGridFulltextInput, { actions: props.actions, state: props.state })),
17
+ react_1.default.createElement(fulltext_input_1.DataGridFulltextInput, { actions: props.actions, placeholder: props.fulltextInputPlaceholder, state: props.state })),
18
18
  (0, is_not_nil_1.isNotNil)(props.onCsvDownload) && (react_1.default.createElement(export_button_1.DataGridExportButton, { actions: props.actions, onCsvDownload: props.onCsvDownload, schema: props.schema, state: props.state })),
19
19
  react_1.default.createElement(hidden_columns_button_1.DataGridHiddenColumnsButton, { actions: props.actions, schema: props.schema, state: props.state }),
20
20
  react_1.default.createElement(filters_button_1.DataGridFiltersButton, { actions: props.actions, filterHandlers: props.filterHandlers, schema: props.schema, state: props.state })));
@@ -28,4 +28,4 @@ export interface FilterProps<StateValue> {
28
28
  onChange: (value: StateValue | undefined, op?: string) => void;
29
29
  onClear: () => void;
30
30
  }
31
- export type ChangeTabFilterBehavior = "sharedFilters" | "filtersPerTab";
31
+ export type ChangeTabFilterBehavior = "sharedFiltersAndSearch" | "sharedFiltersAndSearchAndSort" | "filtersPerTab";