@synerise/ds-column-manager 1.0.13 → 1.1.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +29 -96
  3. package/dist/ColumnManager.d.ts +4 -6
  4. package/dist/ColumnManager.js +108 -420
  5. package/dist/ColumnManager.styles.d.ts +5 -0
  6. package/dist/ColumnManager.styles.js +15 -0
  7. package/dist/ColumnManager.types.d.ts +15 -45
  8. package/dist/ColumnManagerActions/ColumnManagerActions.d.ts +2 -10
  9. package/dist/ColumnManagerActions/ColumnManagerActions.js +16 -122
  10. package/dist/ColumnManagerActions/ColumnManagerActions.styles.d.ts +0 -2
  11. package/dist/ColumnManagerActions/ColumnManagerActions.styles.js +2 -11
  12. package/dist/ColumnManagerActions/ColumnManagerActions.types.d.ts +3 -17
  13. package/dist/ColumnManagerActions/ColumnManagerActions.types.js +1 -1
  14. package/dist/ColumnManagerItem/ColumManagerItem.types.d.ts +14 -14
  15. package/dist/ColumnManagerItem/ColumnManagerItem.d.ts +3 -14
  16. package/dist/ColumnManagerItem/ColumnManagerItem.js +25 -82
  17. package/dist/ColumnManagerItem/ColumnManagerItem.styles.d.ts +3 -1
  18. package/dist/ColumnManagerItem/ColumnManagerItem.styles.js +6 -2
  19. package/dist/ColumnManagerList/ColumnManager.style.d.ts +5 -0
  20. package/dist/ColumnManagerList/ColumnManager.style.js +14 -7
  21. package/dist/ColumnManagerList/ColumnManagerList.d.ts +5 -3
  22. package/dist/ColumnManagerList/ColumnManagerList.js +86 -53
  23. package/dist/ColumnManagerList/ColumnManagerList.types.d.ts +7 -15
  24. package/dist/ColumnManagerSortableItem/ColumnManagerSortableItem.d.ts +4 -0
  25. package/dist/ColumnManagerSortableItem/ColumnManagerSortableItem.js +36 -0
  26. package/dist/ColumnManagerSortableItem/ColumnManagerSortableItem.types.d.ts +3 -0
  27. package/dist/hooks/useTranslations.d.ts +2 -0
  28. package/dist/hooks/useTranslations.js +43 -0
  29. package/dist/index.d.ts +1 -2
  30. package/dist/index.js +1 -2
  31. package/dist/utils/matchesSearchQuery.d.ts +1 -0
  32. package/dist/utils/matchesSearchQuery.js +3 -0
  33. package/package.json +15 -22
  34. package/dist/ColumnManagerGroupSettings/ColumnManagerGroupSettings.d.ts +0 -4
  35. package/dist/ColumnManagerGroupSettings/ColumnManagerGroupSettings.js +0 -210
  36. package/dist/ColumnManagerGroupSettings/ColumnManagerGroupSettings.types.d.ts +0 -27
  37. package/dist/ColumnManagerGroupSettings/ColumnManagerGroupSettings.types.js +0 -6
  38. package/dist/ColumnManagerGroupSettings/ColumnManangerGroupSettings.styles.d.ts +0 -4
  39. package/dist/ColumnManagerGroupSettings/ColumnManangerGroupSettings.styles.js +0 -19
  40. package/dist/ColumnManagerGroupSettings/RangesForm/RangeInput.d.ts +0 -9
  41. package/dist/ColumnManagerGroupSettings/RangesForm/RangeInput.js +0 -30
  42. package/dist/ColumnManagerGroupSettings/RangesForm/RangeRow.d.ts +0 -16
  43. package/dist/ColumnManagerGroupSettings/RangesForm/RangeRow.js +0 -64
  44. package/dist/ColumnManagerGroupSettings/RangesForm/RangesForm.d.ts +0 -13
  45. package/dist/ColumnManagerGroupSettings/RangesForm/RangesForm.js +0 -37
  46. package/dist/ColumnManagerGroupSettings/RangesForm/RangesForm.styles.d.ts +0 -7
  47. package/dist/ColumnManagerGroupSettings/RangesForm/RangesForm.styles.js +0 -24
  48. package/dist/ColumnManagerSearchResults/ColumManagerResults.types.d.ts +0 -12
  49. package/dist/ColumnManagerSearchResults/ColumnManagerSearchResults.d.ts +0 -4
  50. package/dist/ColumnManagerSearchResults/ColumnManagerSearchResults.js +0 -32
  51. package/dist/ColumnManagerSearchResults/ColumnMangerSearchResults.styles.d.ts +0 -1
  52. package/dist/ColumnManagerSearchResults/ColumnMangerSearchResults.styles.js +0 -7
  53. package/dist/styles/ColumnManager.styles.d.ts +0 -2
  54. package/dist/styles/ColumnManager.styles.js +0 -9
  55. /package/dist/{ColumnManagerSearchResults/ColumManagerResults.types.js → ColumnManagerSortableItem/ColumnManagerSortableItem.types.js} +0 -0
@@ -1,430 +1,118 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
3
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
7
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
8
- import React from 'react';
9
- import { injectIntl } from 'react-intl';
10
- import Typography from 'antd/lib/typography';
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
+ import { Title } from '@synerise/ds-typography';
11
4
  import Drawer from '@synerise/ds-drawer';
12
5
  import Button from '@synerise/ds-button';
13
- import Icon, { CloseM, FolderM, SearchM } from '@synerise/ds-icon';
14
- import ItemFilter from '@synerise/ds-item-filter';
15
- import Scrollbar from '@synerise/ds-scrollbar';
16
- import SearchBar from '@synerise/ds-search-bar';
17
- import { theme } from '@synerise/ds-core';
18
- import Tooltip from '@synerise/ds-tooltip';
19
- import ColumnManagerActions from './ColumnManagerActions/ColumnManagerActions';
6
+ import Icon, { CloseM, SearchM } from '@synerise/ds-icon';
7
+ import { useTheme } from '@synerise/ds-core';
8
+ import { ColumnManagerActions } from './ColumnManagerActions/ColumnManagerActions';
20
9
  import ColumnManagerList from './ColumnManagerList/ColumnManagerList';
21
- import * as S from './styles/ColumnManager.styles';
22
- import ColumnManagerGroupSettings from './ColumnManagerGroupSettings/ColumnManagerGroupSettings';
23
- var DEFAULT_STATE = {
24
- searchQuery: '',
25
- visibleList: [],
26
- hiddenList: [],
27
- itemFilterVisible: false,
28
- selectedFilterId: undefined,
29
- activeColumn: undefined,
30
- groupSettings: undefined
31
- };
32
- var ColumnManager = /*#__PURE__*/function (_React$Component) {
33
- function ColumnManager(props) {
34
- var _this;
35
- _this = _React$Component.call(this, props) || this;
36
- // eslint-disable-next-line react/state-in-constructor
37
- _this.updateVisibleColumns = function (newVisibleList) {
38
- _this.setState({
39
- visibleList: newVisibleList.map(function (column) {
40
- return _extends({}, column, {
41
- visible: true
42
- });
43
- })
44
- });
45
- };
46
- _this.updateHiddenColumns = function (newHiddenList) {
47
- _this.setState({
48
- hiddenList: newHiddenList.map(function (column) {
49
- return _extends({}, column, {
50
- visible: false
51
- });
52
- })
53
- });
54
- };
55
- _this.hideColumn = function (id) {
56
- var _this$state = _this.state,
57
- visibleList = _this$state.visibleList,
58
- hiddenList = _this$state.hiddenList;
59
- var column = visibleList.find(function (col) {
60
- return col.id === id;
61
- });
62
- column && _this.setState({
63
- visibleList: visibleList.filter(function (visibleColumn) {
64
- return visibleColumn.id !== column.id;
65
- }),
66
- hiddenList: [].concat(hiddenList, [_extends({}, column, {
67
- visible: false
68
- })])
69
- });
70
- };
71
- _this.showColumn = function (id) {
72
- var _this$state2 = _this.state,
73
- visibleList = _this$state2.visibleList,
74
- hiddenList = _this$state2.hiddenList;
75
- var column = hiddenList.find(function (col) {
76
- return col.id === id;
77
- });
78
- column && _this.setState({
79
- hiddenList: hiddenList.filter(function (hiddenColumn) {
80
- return hiddenColumn.id !== column.id;
81
- }),
82
- visibleList: [].concat(visibleList, [_extends({}, column, {
83
- visible: true
84
- })])
85
- });
86
- };
87
- _this.toggleColumn = function (id, columnVisible) {
88
- if (columnVisible) {
89
- _this.hideColumn(id);
90
- } else {
91
- _this.showColumn(id);
92
- }
93
- };
94
- _this.setFixed = function (id, fixed) {
95
- var visibleList = _this.state.visibleList;
96
- _this.setState({
97
- visibleList: visibleList.map(function (visibleColumn) {
98
- if (visibleColumn.id === id) {
99
- return visibleColumn.fixed === fixed ? _extends({}, visibleColumn, {
100
- fixed: undefined
101
- }) : _extends({}, visibleColumn, {
102
- fixed: fixed
103
- });
104
- }
105
- return visibleColumn;
106
- })
107
- });
108
- };
109
- _this.showGroupSettings = function (column) {
110
- _this.setState({
111
- activeColumn: column
112
- });
113
- };
114
- _this.hideItemFilter = function () {
115
- var hideSavedViews = _this.props.hideSavedViews;
116
- hideSavedViews && hideSavedViews();
117
- _this.setState({
118
- itemFilterVisible: false
119
- });
120
- };
121
- _this.handleShowItemFilter = function () {
122
- _this.setState({
123
- itemFilterVisible: true
124
- });
125
- };
126
- _this.handleSearchChange = function (query) {
127
- _this.setState({
128
- searchQuery: query
129
- });
130
- };
131
- _this.handleSave = function (viewMeta) {
132
- var onSave = _this.props.onSave;
133
- var _this$state3 = _this.state,
134
- visibleList = _this$state3.visibleList,
135
- hiddenList = _this$state3.hiddenList,
136
- groupSettings = _this$state3.groupSettings;
137
- onSave({
138
- meta: viewMeta,
139
- groupSettings: groupSettings,
140
- columns: [].concat(visibleList, hiddenList)
141
- });
142
- };
143
- _this.handleApply = function () {
144
- var onApply = _this.props.onApply;
145
- var _this$state4 = _this.state,
146
- visibleList = _this$state4.visibleList,
147
- hiddenList = _this$state4.hiddenList,
148
- groupSettings = _this$state4.groupSettings;
149
- onApply([].concat(visibleList, hiddenList), groupSettings);
150
- };
151
- _this.state = _extends({}, DEFAULT_STATE, {
152
- groupSettings: props.groupSettings || undefined,
153
- visibleList: props.columns.filter(function (column) {
154
- return column.visible;
155
- }),
156
- hiddenList: props.columns.filter(function (column) {
157
- return !column.visible;
158
- }),
159
- selectedFilterId: props.itemFilterConfig && props.itemFilterConfig.selectedItemId
160
- });
161
- return _this;
162
- }
163
- _inheritsLoose(ColumnManager, _React$Component);
164
- ColumnManager.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
165
- if (props.itemFilterConfig && props.itemFilterConfig.selectedItemId !== state.selectedFilterId) {
166
- var visible = props.columns.filter(function (column) {
167
- return column.visible;
168
- });
169
- var hidden = props.columns.filter(function (column) {
170
- return !column.visible;
171
- });
172
- return {
173
- visibleList: visible,
174
- hiddenList: hidden,
175
- selectedFilterId: props.itemFilterConfig && props.itemFilterConfig.selectedItemId || undefined,
176
- groupSettings: props.groupSettings
177
- };
10
+ import * as S from './ColumnManager.styles';
11
+ import { useTranslations } from './hooks/useTranslations';
12
+ import { matchesSearchQuery } from './utils/matchesSearchQuery';
13
+ var ColumnManager = function ColumnManager(_ref) {
14
+ var columns = _ref.columns,
15
+ customTexts = _ref.texts,
16
+ onApply = _ref.onApply,
17
+ visible = _ref.visible,
18
+ hide = _ref.hide,
19
+ _ref$draggable = _ref.draggable,
20
+ draggable = _ref$draggable === void 0 ? true : _ref$draggable;
21
+ var _useState = useState(''),
22
+ searchQuery = _useState[0],
23
+ setSearchQuery = _useState[1];
24
+ var _useState2 = useState(columns),
25
+ currentColumns = _useState2[0],
26
+ setCurrentColumns = _useState2[1];
27
+ var texts = useTranslations(customTexts);
28
+ var theme = useTheme();
29
+ useEffect(function () {
30
+ setCurrentColumns(columns);
31
+ }, [columns]);
32
+ useEffect(function () {
33
+ if (!visible) {
34
+ setCurrentColumns(columns);
178
35
  }
179
- return null;
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, [visible]);
38
+ var handleApply = function handleApply() {
39
+ onApply(currentColumns);
40
+ };
41
+ var handleCancel = function handleCancel() {
42
+ hide();
43
+ };
44
+ var handleToggleColumn = function handleToggleColumn(id, updatedVisible) {
45
+ setCurrentColumns(currentColumns.map(function (column) {
46
+ return column.id === id ? _extends({}, column, {
47
+ visible: updatedVisible
48
+ }) : column;
49
+ }));
180
50
  };
181
- var _proto = ColumnManager.prototype;
182
- _proto.render = function render() {
183
- var _this2 = this,
184
- _groupSettings$column2;
185
- var _this$props = this.props,
186
- visible = _this$props.visible,
187
- hide = _this$props.hide,
188
- itemFilterConfig = _this$props.itemFilterConfig,
189
- savedViewsVisible = _this$props.savedViewsVisible;
190
- var _this$state5 = this.state,
191
- visibleList = _this$state5.visibleList,
192
- hiddenList = _this$state5.hiddenList,
193
- searchQuery = _this$state5.searchQuery,
194
- itemFilterVisible = _this$state5.itemFilterVisible,
195
- activeColumn = _this$state5.activeColumn,
196
- groupSettings = _this$state5.groupSettings;
197
- var searchResults = [].concat(visibleList, hiddenList).filter(function (column) {
198
- return column.name.toLowerCase().includes(searchQuery.toLowerCase());
51
+ var handleOrderChange = function handleOrderChange(newOrder) {
52
+ var idOrder = newOrder.map(function (item) {
53
+ return item.id;
199
54
  });
200
- var visibleListWithGroup = visibleList.map(function (column) {
201
- var _groupSettings$column;
202
- if (column.id === (groupSettings == null || (_groupSettings$column = groupSettings.column) == null ? void 0 : _groupSettings$column.id)) {
203
- return _extends({}, column, {
204
- group: true
205
- });
206
- }
207
- return column;
55
+ var updatedColumns = [].concat(currentColumns).sort(function (a, b) {
56
+ return idOrder.indexOf(a.id) - idOrder.indexOf(b.id);
208
57
  });
209
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.ColumnManager, {
210
- visible: visible || savedViewsVisible,
211
- width: 338,
212
- onClose: hide
213
- }, /*#__PURE__*/React.createElement(Drawer.DrawerHeader, null, /*#__PURE__*/React.createElement(Drawer.DrawerHeaderBar, null, /*#__PURE__*/React.createElement(Typography.Title, {
214
- style: {
215
- flex: 1,
216
- margin: 0
217
- },
218
- level: 4
219
- }, this.texts.title), /*#__PURE__*/React.createElement(Tooltip, {
220
- title: this.texts.savedViews,
221
- placement: "bottom"
222
- }, /*#__PURE__*/React.createElement(Button, {
223
- "data-testid": "ds-column-manager-show-filters",
224
- type: "ghost",
225
- mode: "single-icon",
226
- onClick: this.handleShowItemFilter
227
- }, /*#__PURE__*/React.createElement(Icon, {
228
- component: /*#__PURE__*/React.createElement(FolderM, null)
229
- }))), /*#__PURE__*/React.createElement(Button, {
230
- "data-testid": "ds-column-manager-close",
231
- style: {
232
- marginLeft: '8px'
233
- },
234
- mode: "single-icon",
235
- type: "ghost",
236
- onClick: hide
237
- }, /*#__PURE__*/React.createElement(Icon, {
238
- component: /*#__PURE__*/React.createElement(CloseM, null)
239
- })))), /*#__PURE__*/React.createElement(SearchBar, {
240
- onSearchChange: this.handleSearchChange,
241
- placeholder: this.texts.searchPlaceholder,
242
- value: searchQuery,
243
- onClearInput: function onClearInput() {
244
- return _this2.handleSearchChange('');
245
- },
246
- iconLeft: /*#__PURE__*/React.createElement(Icon, {
247
- component: /*#__PURE__*/React.createElement(SearchM, null),
248
- color: theme.palette['grey-600']
249
- }),
250
- clearTooltip: this.texts.searchClearTooltip || ''
251
- }), /*#__PURE__*/React.createElement(Scrollbar, {
252
- absolute: true
253
- }, /*#__PURE__*/React.createElement(Drawer.DrawerContent, {
254
- style: {
255
- padding: '0 0 80px'
256
- }
257
- }, /*#__PURE__*/React.createElement(ColumnManagerList, {
258
- texts: this.texts,
259
- searchQuery: searchQuery,
260
- searchResults: searchResults,
261
- visibleList: visibleListWithGroup,
262
- hiddenList: hiddenList,
263
- setFixed: this.setFixed,
264
- showGroupSettings: this.showGroupSettings,
265
- groupSettings: groupSettings,
266
- toggleColumn: this.toggleColumn,
267
- updateVisibleList: this.updateVisibleColumns,
268
- updateHiddenList: this.updateHiddenColumns
269
- }))), /*#__PURE__*/React.createElement(ColumnManagerActions, {
270
- onSave: this.handleSave,
271
- onApply: this.handleApply,
272
- onCancel: hide,
273
- texts: this.texts
274
- }), itemFilterConfig && /*#__PURE__*/React.createElement(ItemFilter, _extends({}, itemFilterConfig, {
275
- visible: itemFilterVisible || Boolean(savedViewsVisible),
276
- hide: this.hideItemFilter
277
- }))), /*#__PURE__*/React.createElement(ColumnManagerGroupSettings, {
278
- texts: this.texts,
279
- hide: function hide() {
280
- _this2.setState({
281
- activeColumn: undefined
282
- });
283
- },
284
- visible: activeColumn !== undefined,
285
- column: activeColumn,
286
- settings: (activeColumn == null ? void 0 : activeColumn.key) === (groupSettings == null || (_groupSettings$column2 = groupSettings.column) == null ? void 0 : _groupSettings$column2.key) ? groupSettings : undefined,
287
- onOk: function onOk(settings) {
288
- _this2.setState({
289
- groupSettings: settings,
290
- activeColumn: undefined
291
- });
292
- }
293
- }));
58
+ setCurrentColumns(updatedColumns);
294
59
  };
295
- return _createClass(ColumnManager, [{
296
- key: "texts",
297
- get: function get() {
298
- var _this$props2 = this.props,
299
- texts = _this$props2.texts,
300
- intl = _this$props2.intl;
301
- return _extends({
302
- title: intl.formatMessage({
303
- id: 'DS.COLUMN-MANAGER.TITLE'
304
- }),
305
- savedViews: intl.formatMessage({
306
- id: 'DS.COLUMN-MANAGER.SAVED-VIEWS',
307
- defaultMessage: 'Saved views'
308
- }),
309
- searchPlaceholder: intl.formatMessage({
310
- id: 'DS.COLUMN-MANAGER.SEARCH-PLACEHOLDER'
311
- }),
312
- searchClearTooltip: intl.formatMessage({
313
- id: 'DS.ITEM-FILTER.SEARCH-CLEAR'
314
- }),
315
- noResults: intl.formatMessage({
316
- id: 'DS.COLUMN-MANAGER.NO-RESULTS'
317
- }),
318
- searchResults: intl.formatMessage({
319
- id: 'DS.COLUMN-MANAGER.SEARCH-RESULTS'
320
- }),
321
- visible: intl.formatMessage({
322
- id: 'DS.COLUMN-MANAGER.VISIBLE'
323
- }),
324
- hidden: intl.formatMessage({
325
- id: 'DS.COLUMN-MANAGER.HIDDEN'
326
- }),
327
- saveView: intl.formatMessage({
328
- id: 'DS.COLUMN-MANAGER.SAVE-VIEW'
329
- }),
330
- cancel: intl.formatMessage({
331
- id: 'DS.COLUMN-MANAGER.CANCEL'
332
- }),
333
- apply: intl.formatMessage({
334
- id: 'DS.COLUMN-MANAGER.APPLY'
335
- }),
336
- fixedLeft: intl.formatMessage({
337
- id: 'DS.COLUMN-MANAGER.FIXED-LEFT'
338
- }),
339
- fixedRight: intl.formatMessage({
340
- id: 'DS.COLUMN-MANAGER.FIXED-RIGHT'
341
- }),
342
- group: intl.formatMessage({
343
- id: 'DS.COLUMN-MANAGER.GROUP'
344
- }),
345
- clear: intl.formatMessage({
346
- id: 'DS.COLUMN-MANAGER.CLEAR'
347
- }),
348
- viewName: intl.formatMessage({
349
- id: 'DS.COLUMN-MANAGER.VIEW-NAME'
350
- }),
351
- viewDescription: intl.formatMessage({
352
- id: 'DS.COLUMN-MANAGER.VIEW-DESCRIPTION'
353
- }),
354
- viewNamePlaceholder: intl.formatMessage({
355
- id: 'DS.COLUMN-MANAGER.VIEW-NAME-PLACEHOLDER'
356
- }),
357
- viewDescriptionPlaceholder: intl.formatMessage({
358
- id: 'DS.COLUMN-MANAGER.VIEW-DESCRIPTION-PLACEHOLDER'
359
- }),
360
- mustNotBeEmpty: intl.formatMessage({
361
- id: 'DS.COLUMN-MANAGER.MUST-NOT-BE-EMPTY'
362
- }),
363
- switchOn: intl.formatMessage({
364
- id: 'DS.COLUMN-MANAGER.SWITCH-ON'
365
- }),
366
- switchOff: intl.formatMessage({
367
- id: 'DS.COLUMN-MANAGER.SWITCH-OFF'
368
- }),
369
- groupByValue: intl.formatMessage({
370
- id: 'DS.COLUMN-MANAGER.GROUP_BY_VALUE'
371
- }),
372
- groupByRanges: intl.formatMessage({
373
- id: 'DS.COLUMN-MANAGER.GROUP_BY_RANGERS'
374
- }),
375
- groupByIntervals: intl.formatMessage({
376
- id: 'DS.COLUMN-MANAGER.GROUP_BY_INTERVALS'
377
- }),
378
- groupDisabled: intl.formatMessage({
379
- id: 'DS.COLUMN-MANAGER.GROUP_DISABLED'
380
- }),
381
- groupTitle: intl.formatMessage({
382
- id: 'DS.COLUMN-MANAGER.GROUP_TITLE'
383
- }),
384
- selectPlaceholder: intl.formatMessage({
385
- id: 'DS.COLUMN-MANAGER.SELECT_PLACEHOLDER'
386
- }),
387
- intervalPlaceholder: intl.formatMessage({
388
- id: 'DS.COLUMN-MANAGER.INTERVAL_PLACEHOLDER'
389
- }),
390
- groupingType: intl.formatMessage({
391
- id: 'DS.COLUMN-MANAGER.SET_GROUPING_TYPE'
392
- }),
393
- groupingTypeTooltip: intl.formatMessage({
394
- id: 'DS.COLUMN-MANAGER.GROUPING_TYPE_TOOLTIP'
395
- }),
396
- from: intl.formatMessage({
397
- id: 'DS.COLUMN-MANAGER.FROM'
398
- }),
399
- to: intl.formatMessage({
400
- id: 'DS.COLUMN-MANAGER.TO'
401
- }),
402
- remove: intl.formatMessage({
403
- id: 'DS.COLUMN-MANAGER.REMOVE'
404
- }),
405
- addRange: intl.formatMessage({
406
- id: 'DS.COLUMN-MANAGER.ADD_RANGE'
407
- }),
408
- errorEmptyRange: intl.formatMessage({
409
- id: 'DS.COLUMN-MANAGER.ERROR_EMPTY_RANGE'
410
- }),
411
- errorEmptyFromField: intl.formatMessage({
412
- id: 'DS.COLUMN-MANAGER.ERROR_EMPTY_FROM_FIELD'
413
- }),
414
- errorEmptyToField: intl.formatMessage({
415
- id: 'DS.COLUMN-MANAGER.ERROR_EMPTY_TO_FIELD'
416
- }),
417
- errorChooseGrouping: intl.formatMessage({
418
- id: 'DS.COLUMN-MANAGER.ERROR_CHOOSE_GROUPING'
419
- }),
420
- errorInterval: intl.formatMessage({
421
- id: 'DS.COLUMN-MANAGER.ERROR_INTERVAL'
422
- }),
423
- errorRange: intl.formatMessage({
424
- id: 'DS.COLUMN-MANAGER.ERROR_RANGE'
425
- })
426
- }, texts);
60
+ var handleSearchChange = function handleSearchChange(query) {
61
+ setSearchQuery(query);
62
+ };
63
+ var filteredColumns = useMemo(function () {
64
+ return searchQuery ? currentColumns.filter(function (column) {
65
+ return matchesSearchQuery(column.name, searchQuery);
66
+ }) : currentColumns;
67
+ }, [currentColumns, searchQuery]);
68
+ return /*#__PURE__*/React.createElement(S.ColumnManager, {
69
+ visible: visible,
70
+ width: 338,
71
+ onClose: hide
72
+ }, /*#__PURE__*/React.createElement(Drawer.DrawerHeader, null, /*#__PURE__*/React.createElement(Drawer.DrawerHeaderBar, null, /*#__PURE__*/React.createElement(Title, {
73
+ style: {
74
+ flex: 1,
75
+ margin: 0
76
+ },
77
+ level: 4
78
+ }, texts.title), /*#__PURE__*/React.createElement(Button, {
79
+ "data-testid": "ds-column-manager-close",
80
+ style: {
81
+ marginLeft: '8px'
82
+ },
83
+ mode: "single-icon",
84
+ type: "ghost",
85
+ onClick: hide
86
+ }, /*#__PURE__*/React.createElement(Icon, {
87
+ component: /*#__PURE__*/React.createElement(CloseM, null)
88
+ })))), /*#__PURE__*/React.createElement(S.SearchBar, {
89
+ onSearchChange: handleSearchChange,
90
+ placeholder: texts.searchPlaceholder,
91
+ value: searchQuery,
92
+ onClearInput: function onClearInput() {
93
+ return handleSearchChange('');
94
+ },
95
+ iconLeft: /*#__PURE__*/React.createElement(Icon, {
96
+ component: /*#__PURE__*/React.createElement(SearchM, null),
97
+ color: theme.palette['grey-600']
98
+ }),
99
+ clearTooltip: texts.searchClearTooltip || ''
100
+ }), /*#__PURE__*/React.createElement(S.ColumnManagerListWrapper, null, /*#__PURE__*/React.createElement(Drawer.DrawerContent, {
101
+ style: {
102
+ padding: '0',
103
+ height: '100%'
427
104
  }
428
- }]);
429
- }(React.Component); // @ts-ignore
430
- export default injectIntl(ColumnManager);
105
+ }, /*#__PURE__*/React.createElement(ColumnManagerList, {
106
+ texts: texts,
107
+ draggable: draggable,
108
+ handleOrderChange: handleOrderChange,
109
+ searchQuery: searchQuery,
110
+ columns: filteredColumns,
111
+ toggleColumn: handleToggleColumn
112
+ }))), /*#__PURE__*/React.createElement(ColumnManagerActions, {
113
+ onApply: handleApply,
114
+ onCancel: handleCancel,
115
+ texts: texts
116
+ }));
117
+ };
118
+ export default ColumnManager;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import Drawer from '@synerise/ds-drawer';
3
+ export declare const ColumnManager: import("styled-components").StyledComponent<typeof Drawer, any, {}, never>;
4
+ export declare const SearchBar: import("styled-components").StyledComponent<({ value, className, onSearchChange, onClearInput, placeholder, iconLeft, autofocus, clearTooltip, disabled, borderRadius, handleInputRef, autofocusDelay, clearTooltipProps, valuePrefix, ...htmlAttributes }: import("@synerise/ds-search-bar").SearchBarProps) => import("react").JSX.Element, any, {}, never>;
5
+ export declare const ColumnManagerListWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,15 @@
1
+ import styled from 'styled-components';
2
+ import Drawer from '@synerise/ds-drawer';
3
+ import SearchBarBase from '@synerise/ds-search-bar';
4
+ export var ColumnManager = styled(Drawer).withConfig({
5
+ displayName: "ColumnManagerstyles__ColumnManager",
6
+ componentId: "sc-4cxi70-0"
7
+ })([""]);
8
+ export var SearchBar = styled(SearchBarBase).withConfig({
9
+ displayName: "ColumnManagerstyles__SearchBar",
10
+ componentId: "sc-4cxi70-1"
11
+ })(["min-height:52px;height:52px;"]);
12
+ export var ColumnManagerListWrapper = styled.div.withConfig({
13
+ displayName: "ColumnManagerstyles__ColumnManagerListWrapper",
14
+ componentId: "sc-4cxi70-2"
15
+ })(["flex:1 1 auto;min-height:0;"]);
@@ -1,48 +1,18 @@
1
- import { ItemFilterProps } from '@synerise/ds-item-filter/dist/ItemFilter.types';
2
- import React from 'react';
3
- import { IntlFormatters } from 'react-intl';
4
- import { Column } from './ColumnManagerItem/ColumManagerItem.types';
5
- import { Range, GroupSettingsTexts } from './ColumnManagerGroupSettings/ColumnManagerGroupSettings.types';
6
- export type Texts = GroupSettingsTexts | 'title' | 'savedViews' | 'searchPlaceholder' | 'searchClearTooltip' | 'noResults' | 'searchResults' | 'visible' | 'hidden' | 'saveView' | 'cancel' | 'apply' | 'fixedLeft' | 'fixedRight' | 'group' | 'clear' | 'viewName' | 'viewDescription' | 'viewNamePlaceholder' | 'viewDescriptionPlaceholder' | 'switchOn' | 'switchOff' | 'mustNotBeEmpty';
7
- export type ColumnManagerProps = {
1
+ import type { ReactNode } from 'react';
2
+ import type { Column } from './ColumnManagerItem/ColumManagerItem.types';
3
+ type TextsString = 'searchPlaceholder';
4
+ type TextsReactNode = 'title' | 'searchClearTooltip' | 'noResults' | 'cancel' | 'apply' | 'clear' | 'switchOn' | 'switchOff';
5
+ export type ColumnManagerTexts = {
6
+ [k in TextsReactNode]: ReactNode;
7
+ } & {
8
+ [k in TextsString]: string;
9
+ };
10
+ export type ColumnManagerProps<ColumnType extends Column> = {
8
11
  hide: () => void;
9
12
  visible: boolean;
10
- onSave: (savedView: SavedView) => void;
11
- onApply: (columns: Column[], groupSettings?: GroupSettings | undefined) => void;
12
- columns: Column[];
13
- texts?: {
14
- [k in Texts]: string | React.ReactNode;
15
- };
16
- itemFilterConfig?: Omit<ItemFilterProps, 'visible' | 'hide' | 'theme'>;
17
- savedViewsVisible?: boolean;
18
- hideSavedViews?: () => void;
19
- intl: IntlFormatters;
20
- groupSettings?: GroupSettings;
21
- };
22
- export type SavedView = {
23
- meta: ViewMeta;
24
- groupSettings?: GroupSettings;
25
- columns: Column[];
26
- };
27
- export type ViewMeta = {
28
- name: string;
29
- description: string;
30
- };
31
- export type GroupType = 'value' | 'ranges' | 'interval' | string | undefined;
32
- export type GroupSettings = {
33
- column?: Column;
34
- settings: {
35
- type: GroupType;
36
- ranges: Range[] | false;
37
- interval: number | false;
38
- };
39
- };
40
- export type State = {
41
- searchQuery: string;
42
- visibleList: Column[];
43
- hiddenList: Column[];
44
- itemFilterVisible: boolean;
45
- selectedFilterId: string | undefined;
46
- activeColumn: Column | undefined;
47
- groupSettings: GroupSettings | undefined;
13
+ onApply: (columns: ColumnType[]) => void;
14
+ columns: ColumnType[];
15
+ texts?: Partial<ColumnManagerTexts>;
16
+ draggable?: boolean;
48
17
  };
18
+ export {};
@@ -1,11 +1,3 @@
1
1
  import React from 'react';
2
- import { Props, State } from './ColumnManagerActions.types';
3
- declare class ColumnManagerActions extends React.Component<Props, State> {
4
- state: State;
5
- handleCancel: () => void;
6
- handleShowModal: () => void;
7
- handleChange: (event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
8
- handleSubmit: () => void;
9
- render(): React.ReactElement;
10
- }
11
- export default ColumnManagerActions;
2
+ import { ColumnManagerActionsProps } from './ColumnManagerActions.types';
3
+ export declare const ColumnManagerActions: ({ texts, onApply, onCancel }: ColumnManagerActionsProps) => React.JSX.Element;