dtable-ui-component 4.4.0-alpha2 → 4.4.0-beta1

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 (40) hide show
  1. package/lib/CollaboratorEditor/index.js +4 -26
  2. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +1 -2
  3. package/lib/DTableCommonAddTool/index.css +25 -0
  4. package/lib/DTableCommonAddTool/index.js +24 -0
  5. package/lib/DTableFiltersPopover/constants/index.js +65 -0
  6. package/lib/DTableFiltersPopover/index.css +39 -0
  7. package/lib/DTableFiltersPopover/index.js +216 -0
  8. package/lib/DTableFiltersPopover/utils/filter-item-utils.js +145 -0
  9. package/lib/DTableFiltersPopover/utils/index.js +452 -0
  10. package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.css +0 -0
  11. package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +106 -0
  12. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +89 -0
  13. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +89 -0
  14. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +167 -0
  15. package/lib/DTableFiltersPopover/widgets/filter-item.js +677 -0
  16. package/lib/DTableFiltersPopover/widgets/filter-list/index.css +321 -0
  17. package/lib/DTableFiltersPopover/widgets/filter-list/index.js +125 -0
  18. package/lib/DTableFiltersPopover/widgets/rate-item.js +72 -0
  19. package/lib/DTablePopover/index.js +1 -1
  20. package/lib/Department-editor/constants.js +10 -0
  21. package/lib/Department-editor/department-multiple-select/index.css +67 -0
  22. package/lib/Department-editor/department-multiple-select/index.js +143 -0
  23. package/lib/Department-editor/department-single-select.js +263 -0
  24. package/lib/Department-editor/index.css +117 -0
  25. package/lib/Department-editor/index.js +99 -0
  26. package/lib/Department-editor/selected-departments/index.css +26 -0
  27. package/lib/Department-editor/selected-departments/index.js +81 -0
  28. package/lib/Department-editor/utils.js +29 -0
  29. package/lib/constants/index.js +4 -1
  30. package/lib/hooks/common-hooks.js +21 -0
  31. package/lib/index.js +4 -1
  32. package/lib/lang/index.js +67 -3
  33. package/lib/locals/en.js +40 -1
  34. package/lib/locals/zh-CN.js +6 -1
  35. package/lib/select-editor/mb-select-editor-popover/index.css +1 -1
  36. package/lib/select-editor/mb-select-editor-popover/index.js +1 -1
  37. package/lib/utils/dayjs.js +4 -0
  38. package/lib/utils/event-bus.js +28 -0
  39. package/lib/utils/utils.js +5 -0
  40. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  import React, { Fragment } from 'react';
2
2
  import MediaQuery from 'react-responsive';
3
3
  import { getLocale } from '../lang';
4
- import ModalPortal from '../common/modal-portal';
5
4
  import CollaboratorItem from '../CollaboratorItem';
6
5
  import EditEditorButton from '../EditEditorButton';
7
6
  import PCCollaboratorEditorPopover from './pc-collaborator-editor-popover';
@@ -11,11 +10,6 @@ class CollaboratorEditor extends React.Component {
11
10
  constructor(props) {
12
11
  super(props);
13
12
  this.onMouseDown = e => {
14
- if (this.state.isPopoverShow && this.editorPopoverRef) {
15
- if (this.editorPopoverRef === e.target || this.editorPopoverRef.contains(e.target)) {
16
- return;
17
- }
18
- }
19
13
  if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
20
14
  this.onClosePopover();
21
15
  }
@@ -88,17 +82,6 @@ class CollaboratorEditor extends React.Component {
88
82
  }
89
83
  };
90
84
  this.caculatePopoverPosition = () => {
91
- if (this.props.isInModel) {
92
- const {
93
- top,
94
- left
95
- } = this.editor.getBoundingClientRect();
96
- return {
97
- top: top + 40,
98
- left,
99
- zIndex: 1051
100
- };
101
- }
102
85
  const POPOVER_MAX_HEIGHT = 200;
103
86
  let innerHeight = window.innerHeight;
104
87
  let {
@@ -139,9 +122,6 @@ class CollaboratorEditor extends React.Component {
139
122
  this.setEditorRef = editor => {
140
123
  this.editor = editor;
141
124
  };
142
- this.setPopoverRef = ref => {
143
- this.editorPopoverRef = ref;
144
- };
145
125
  this.state = {
146
126
  newValue: Array.isArray(props.value) ? props.value : [],
147
127
  isPopoverShow: false,
@@ -187,14 +167,13 @@ class CollaboratorEditor extends React.Component {
187
167
  });
188
168
  }))), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
189
169
  query: '(min-width: 768px)'
190
- }, /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(PCCollaboratorEditorPopover, {
170
+ }, /*#__PURE__*/React.createElement(PCCollaboratorEditorPopover, {
191
171
  popoverPosition: popoverPosition,
192
172
  isReadOnly: this.props.isReadOnly,
193
173
  selectedCollaborators: selectedCollaborators,
194
174
  collaborators: collaborators,
195
- onCollaboratorItemToggle: this.onCollaboratorItemToggle,
196
- setPopoverRef: this.setPopoverRef
197
- }))), /*#__PURE__*/React.createElement(MediaQuery, {
175
+ onCollaboratorItemToggle: this.onCollaboratorItemToggle
176
+ })), /*#__PURE__*/React.createElement(MediaQuery, {
198
177
  query: '(max-width: 767.8px)'
199
178
  }, /*#__PURE__*/React.createElement(MBCollaboratorEditorPopover, {
200
179
  isReadOnly: this.props.isReadOnly,
@@ -209,7 +188,6 @@ class CollaboratorEditor extends React.Component {
209
188
  CollaboratorEditor.defaultProps = {
210
189
  isShowEditButton: true,
211
190
  isReadOnly: false,
212
- value: [],
213
- isInModel: false
191
+ value: []
214
192
  };
215
193
  export default CollaboratorEditor;
@@ -54,8 +54,7 @@ class PCCollaboratorEditorPopover extends React.Component {
54
54
  });
55
55
  return /*#__PURE__*/React.createElement("div", {
56
56
  className: "dtable-ui-editor-popover dtable-ui-collaborator-editor-popover",
57
- style: popoverStyle,
58
- ref: this.props.setPopoverRef
57
+ style: popoverStyle
59
58
  }, /*#__PURE__*/React.createElement("div", {
60
59
  className: "collaborator-search-container"
61
60
  }, /*#__PURE__*/React.createElement("input", {
@@ -0,0 +1,25 @@
1
+ .dtable-ui.add-item-btn {
2
+ display: flex;
3
+ align-items: center;
4
+ height: 40px;
5
+ font-size: 14px;
6
+ font-weight: 500;
7
+ border-top: 1px solid #dedede;
8
+ background: #fff;
9
+ padding: 0 1rem;
10
+ border-bottom-left-radius: 3px;
11
+ border-bottom-right-radius: 3px;
12
+ position: relative;
13
+ }
14
+
15
+ .dtable-ui.add-item-btn:hover {
16
+ cursor: pointer;
17
+ background: #f5f5f5;
18
+ }
19
+
20
+ .dtable-ui.add-item-btn .dtable-icon-add-table {
21
+ margin-right: 10px;
22
+ font-size: 12px;
23
+ font-weight: 600;
24
+ transform: none;
25
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import './index.css';
3
+ function DTableCommonAddTool(_ref) {
4
+ let {
5
+ callBack,
6
+ footerName,
7
+ className,
8
+ addIconClassName,
9
+ hideIcon,
10
+ style
11
+ } = _ref;
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ className: "dtable-ui add-item-btn ".concat(className ? className : ''),
14
+ style: style,
15
+ onClick: e => {
16
+ callBack(e);
17
+ }
18
+ }, !hideIcon && /*#__PURE__*/React.createElement("span", {
19
+ className: "dtable-font dtable-icon-add-table ".concat(addIconClassName || '')
20
+ }), /*#__PURE__*/React.createElement("span", {
21
+ className: "text-truncate"
22
+ }, footerName));
23
+ }
24
+ export default DTableCommonAddTool;
@@ -0,0 +1,65 @@
1
+ import { FILTER_PREDICATE_TYPE, FILTER_TERM_MODIFIER_TYPE, CellType, FORMULA_RESULT_TYPE } from 'dtable-utils';
2
+ const FORMULA_COLUMN_TYPES = [CellType.FORMULA, CellType.LINK_FORMULA];
3
+ const SPECIAL_TERM_TYPE = {
4
+ CREATOR: 'creator',
5
+ SINGLE_SELECT: 'single_select',
6
+ MULTIPLE_SELECT: 'multiple_select',
7
+ COLLABORATOR: 'collaborator',
8
+ RATE: 'rate'
9
+ };
10
+ const SIMPLE_TEXT_INPUT_COLUMNS_MAP = {
11
+ [CellType.TEXT]: true,
12
+ [CellType.LONG_TEXT]: true,
13
+ [CellType.GEOLOCATION]: true,
14
+ [CellType.AUTO_NUMBER]: true,
15
+ [CellType.EMAIL]: true,
16
+ [CellType.URL]: true,
17
+ [CellType.IMAGE]: true,
18
+ [CellType.FILE]: true,
19
+ [FORMULA_RESULT_TYPE.STRING]: true,
20
+ [FORMULA_RESULT_TYPE.BOOL]: true
21
+ };
22
+ const DATE_LABEL_MAP = {
23
+ [FILTER_TERM_MODIFIER_TYPE.EXACT_DATE]: true,
24
+ [FILTER_TERM_MODIFIER_TYPE.NUMBER_OF_DAYS_AGO]: true,
25
+ [FILTER_TERM_MODIFIER_TYPE.NUMBER_OF_DAYS_FROM_NOW]: true,
26
+ [FILTER_TERM_MODIFIER_TYPE.THE_NEXT_NUMBERS_OF_DAYS]: true,
27
+ [FILTER_TERM_MODIFIER_TYPE.THE_PAST_NUMBERS_OF_DAYS]: true
28
+ };
29
+ const ARRAY_PREDICATE = {
30
+ [FILTER_PREDICATE_TYPE.IS_ANY_OF]: true,
31
+ [FILTER_PREDICATE_TYPE.IS_NONE_OF]: true
32
+ };
33
+ const STRING_PREDICATE = {
34
+ [FILTER_PREDICATE_TYPE.IS]: true,
35
+ [FILTER_PREDICATE_TYPE.IS_NOT]: true
36
+ };
37
+ const DATE_EMPTY_LABEL_MAP = {
38
+ [FILTER_PREDICATE_TYPE.EMPTY]: true,
39
+ [FILTER_PREDICATE_TYPE.NOT_EMPTY]: true
40
+ };
41
+ const MULTIPLE_SELECTOR_COLUMNS = [CellType.MULTIPLE_SELECT, CellType.COLLABORATOR, CellType.CREATOR, CellType.LAST_MODIFIER];
42
+ const FILTER_TERM_MODIFIER_SHOW = {
43
+ 'today': 'Today',
44
+ 'tomorrow': 'Tomorrow',
45
+ 'yesterday': 'Yesterday',
46
+ 'one_week_ago': 'One_week_ago',
47
+ 'one_week_from_now': 'One_week_from_now',
48
+ 'one_month_ago': 'One_month_ago',
49
+ 'one_month_from_now': 'One_month_from_now',
50
+ 'number_of_days_ago': 'Number_of_days_ago',
51
+ 'number_of_days_from_now': 'Number_of_days_from_now',
52
+ 'exact_date': 'Exact_date',
53
+ 'the_past_week': 'Last_week',
54
+ 'the_past_month': 'Last_month',
55
+ 'the_past_year': 'Last_year',
56
+ 'the_next_week': 'The_next_week',
57
+ 'the_next_month': 'The_next_month',
58
+ 'the_next_year': 'The_next_year',
59
+ 'the_next_numbers_of_days': 'The_next_numbers_of_days',
60
+ 'the_past_numbers_of_days': 'The_past_numbers_of_days',
61
+ 'this_week': 'This_week',
62
+ 'this_month': 'This_month',
63
+ 'this_year': 'This_year'
64
+ };
65
+ export { FORMULA_COLUMN_TYPES, SPECIAL_TERM_TYPE, SIMPLE_TEXT_INPUT_COLUMNS_MAP, DATE_LABEL_MAP, ARRAY_PREDICATE, STRING_PREDICATE, DATE_EMPTY_LABEL_MAP, MULTIPLE_SELECTOR_COLUMNS, FILTER_TERM_MODIFIER_SHOW };
@@ -0,0 +1,39 @@
1
+ .dtable-filter-popover .popover {
2
+ max-width: none;
3
+ min-width: 300px;
4
+ }
5
+
6
+ .dtable-filter-popover .dtable-filter-popover-footer {
7
+ display: flex;
8
+ align-items: center;
9
+ justify-content: flex-end;
10
+ padding: 1rem;
11
+ border-top: 1px solid #e9ecef;
12
+ }
13
+
14
+ /* */
15
+ .dtable-filter-popover .popover-add-tool {
16
+ border-top: none;
17
+ color: #555555;
18
+ }
19
+
20
+ .dtable-filter-popover .popover-add-tool.disabled {
21
+ color: #c2c2c2;
22
+ }
23
+
24
+ .dtable-filter-popover .popover-add-tool.disabled:hover {
25
+ cursor: not-allowed;
26
+ background: #fff;
27
+ }
28
+
29
+ .dtable-filter-popover .popover-add-tool .popover-add-icon {
30
+ margin-right: 14px;
31
+ }
32
+
33
+ .dtable-filter-popover .dtable-filter-popover-footer {
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: flex-end;
37
+ padding: 1rem;
38
+ border-top: 1px solid #e9ecef;
39
+ }
@@ -0,0 +1,216 @@
1
+ import React, { Component } from 'react';
2
+ import isHotkey from 'is-hotkey';
3
+ import { Button, UncontrolledPopover } from 'reactstrap';
4
+ import { FILTER_COLUMN_OPTIONS, getValidFilters } from 'dtable-utils';
5
+ import CommonAddTool from '../DTableCommonAddTool';
6
+ import { getEventClassName } from '../utils/utils';
7
+ import { getFilterByColumn } from './utils';
8
+ import FiltersList from './widgets/filter-list';
9
+ import eventBus from '../utils/event-bus';
10
+ import { EVENT_BUS_TYPE } from '../constants';
11
+ import { getLocale } from '../lang';
12
+ import './index.css';
13
+
14
+ /**
15
+ * filter = {
16
+ * column_key: '',
17
+ * filter_predicate: '',
18
+ * filter_term: '',
19
+ * filter_term_modifier: '',
20
+ * }
21
+ */
22
+ class DTableFiltersPopover extends Component {
23
+ constructor(props) {
24
+ super(props);
25
+ this.onHotKey = e => {
26
+ if (isHotkey('esc', e) && !this.isSelectOpen) {
27
+ e.preventDefault();
28
+ this.props.hidePopover();
29
+ }
30
+ };
31
+ this.setSelectStatus = status => {
32
+ this.isSelectOpen = status;
33
+ };
34
+ this.hideDTablePopover = e => {
35
+ if (this.dtablePopoverRef && !getEventClassName(e).includes('popover') && !this.dtablePopoverRef.contains(e.target)) {
36
+ this.props.hidePopover(e);
37
+ e.preventDefault();
38
+ e.stopPropagation();
39
+ return false;
40
+ }
41
+ };
42
+ this.isNeedSubmit = () => {
43
+ return this.props.isNeedSubmit;
44
+ };
45
+ this.update = filters => {
46
+ if (this.isNeedSubmit()) {
47
+ const isSubmitDisabled = false;
48
+ this.setState({
49
+ filters,
50
+ isSubmitDisabled
51
+ });
52
+ return;
53
+ }
54
+ this.setState({
55
+ filters
56
+ }, () => {
57
+ const update = {
58
+ filters,
59
+ filter_conjunction: this.state.filterConjunction
60
+ };
61
+ this.props.update(update);
62
+ });
63
+ };
64
+ this.deleteFilter = (filterIndex, scheduleUpdate) => {
65
+ const filters = this.state.filters.slice(0);
66
+ filters.splice(filterIndex, 1);
67
+ if (filters.length === 0) {
68
+ scheduleUpdate();
69
+ }
70
+ this.update(filters);
71
+ };
72
+ this.updateFilter = (filterIndex, updated) => {
73
+ const filters = this.state.filters.slice(0);
74
+ filters[filterIndex] = updated;
75
+ this.update(filters);
76
+ };
77
+ this.updateFilterConjunction = conjunction => {
78
+ if (this.isNeedSubmit()) {
79
+ const isSubmitDisabled = false;
80
+ this.setState({
81
+ filterConjunction: conjunction,
82
+ isSubmitDisabled
83
+ });
84
+ return;
85
+ }
86
+ this.setState({
87
+ filterConjunction: conjunction
88
+ }, () => {
89
+ const update = {
90
+ filters: this.state.filters,
91
+ filter_conjunction: conjunction
92
+ };
93
+ this.props.update(update);
94
+ });
95
+ };
96
+ this.addFilter = scheduleUpdate => {
97
+ let {
98
+ columns
99
+ } = this.props;
100
+ let defaultColumn = columns[0];
101
+ if (!FILTER_COLUMN_OPTIONS[defaultColumn.type]) {
102
+ defaultColumn = columns.find(c => FILTER_COLUMN_OPTIONS[c.type]);
103
+ }
104
+ if (!defaultColumn) return;
105
+ let filter = getFilterByColumn(defaultColumn);
106
+ const filters = this.state.filters.slice(0);
107
+ if (filters.length === 0) {
108
+ scheduleUpdate();
109
+ }
110
+ filters.push(filter);
111
+ this.update(filters);
112
+ };
113
+ this.onClosePopover = () => {
114
+ this.props.hidePopover();
115
+ };
116
+ this.onSubmitFilters = () => {
117
+ const {
118
+ filters,
119
+ filterConjunction
120
+ } = this.state;
121
+ const update = {
122
+ filters,
123
+ filter_conjunction: filterConjunction
124
+ };
125
+ this.props.update(update);
126
+ this.props.hidePopover();
127
+ };
128
+ this.onPopoverInsideClick = e => {
129
+ e.stopPropagation();
130
+ };
131
+ this.state = {
132
+ filters: getValidFilters(props.filters, props.columns),
133
+ filterConjunction: props.filterConjunction || 'And'
134
+ };
135
+ this.isSelectOpen = false;
136
+ }
137
+ componentDidMount() {
138
+ document.addEventListener('mousedown', this.hideDTablePopover, true);
139
+ document.addEventListener('keydown', this.onHotKey);
140
+ this.unsubscribeOpenSelect = eventBus.subscribe(EVENT_BUS_TYPE.OPEN_SELECT, this.setSelectStatus);
141
+ }
142
+ componentWillUnmount() {
143
+ document.removeEventListener('mousedown', this.hideDTablePopover, true);
144
+ document.removeEventListener('keydown', this.onHotKey);
145
+ this.unsubscribeOpenSelect();
146
+ }
147
+ render() {
148
+ const {
149
+ target,
150
+ columns,
151
+ className,
152
+ roleId,
153
+ userDepartmentIdsMap,
154
+ departments,
155
+ lang,
156
+ readOnly
157
+ } = this.props;
158
+ const {
159
+ filters,
160
+ filterConjunction
161
+ } = this.state;
162
+ const canAddFilter = columns.length > 0;
163
+ return /*#__PURE__*/React.createElement(UncontrolledPopover, {
164
+ placement: "auto-start",
165
+ isOpen: true,
166
+ target: target,
167
+ fade: false,
168
+ hideArrow: true,
169
+ className: "dtable-filter-popover",
170
+ boundariesElement: document.body
171
+ }, _ref => {
172
+ let {
173
+ scheduleUpdate
174
+ } = _ref;
175
+ return /*#__PURE__*/React.createElement("div", {
176
+ ref: ref => this.dtablePopoverRef = ref,
177
+ onClick: this.onPopoverInsideClick,
178
+ className: className
179
+ }, /*#__PURE__*/React.createElement(FiltersList, {
180
+ filterConjunction: filterConjunction,
181
+ filters: filters,
182
+ roleId: roleId,
183
+ columns: columns,
184
+ emptyPlaceholder: getLocale('No_filters'),
185
+ collaborators: this.props.collaborators,
186
+ readOnly: readOnly,
187
+ scheduleUpdate: scheduleUpdate,
188
+ userDepartmentIdsMap: userDepartmentIdsMap,
189
+ departments: departments,
190
+ lang: lang,
191
+ updateFilter: this.updateFilter,
192
+ deleteFilter: this.deleteFilter,
193
+ updateFilterConjunction: this.updateFilterConjunction
194
+ }), /*#__PURE__*/React.createElement(CommonAddTool, {
195
+ className: "popover-add-tool ".concat(canAddFilter ? '' : 'disabled'),
196
+ callBack: canAddFilter ? () => this.addFilter(scheduleUpdate) : () => {},
197
+ footerName: getLocale('Add_filter'),
198
+ addIconClassName: "popover-add-icon"
199
+ }), this.isNeedSubmit() && /*#__PURE__*/React.createElement("div", {
200
+ className: "dtable-filter-popover-footer"
201
+ }, /*#__PURE__*/React.createElement(Button, {
202
+ className: "mr-2",
203
+ onClick: this.onClosePopover
204
+ }, getLocale('Cancel')), /*#__PURE__*/React.createElement(Button, {
205
+ color: "primary",
206
+ disabled: this.state.isSubmitDisabled,
207
+ onClick: this.onSubmitFilters
208
+ }, getLocale('Submit'))));
209
+ });
210
+ }
211
+ }
212
+ DTableFiltersPopover.defaultProps = {
213
+ className: '',
214
+ readOnly: false
215
+ };
216
+ export default DTableFiltersPopover;
@@ -0,0 +1,145 @@
1
+ import React, { Fragment } from 'react';
2
+ import { COLUMNS_ICON_CONFIG } from 'dtable-utils';
3
+ import { getLocale } from '../../lang';
4
+ class FilterItemUtils {
5
+ static generatorColumnOption(column) {
6
+ if (!column) return null;
7
+ const {
8
+ type,
9
+ name
10
+ } = column;
11
+ return {
12
+ value: {
13
+ column
14
+ },
15
+ label: /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
16
+ className: "filter-header-icon"
17
+ }, /*#__PURE__*/React.createElement("i", {
18
+ className: COLUMNS_ICON_CONFIG[type]
19
+ })), /*#__PURE__*/React.createElement("span", {
20
+ className: "select-option-name"
21
+ }, name))
22
+ };
23
+ }
24
+ static generatorPredicateOption(filterPredicate) {
25
+ return {
26
+ value: {
27
+ filterPredicate
28
+ },
29
+ label: /*#__PURE__*/React.createElement("span", {
30
+ className: "select-option-name"
31
+ }, getLocale(filterPredicate))
32
+ };
33
+ }
34
+ static generatorTermModifierOption(filterTermModifier) {
35
+ const FILTER_TERM_MODIFIER_SHOW = {
36
+ 'today': getLocale('today'),
37
+ 'tomorrow': getLocale('tomorrow'),
38
+ 'yesterday': getLocale('yesterday'),
39
+ 'one_week_ago': getLocale('one_week_ago'),
40
+ 'one_week_from_now': getLocale('one_week_from_now'),
41
+ 'one_month_ago': getLocale('one_month_ago'),
42
+ 'one_month_from_now': getLocale('one_month_from_now'),
43
+ 'number_of_days_ago': getLocale('number_of_days_ago'),
44
+ 'number_of_days_from_now': getLocale('number_of_days_from_now'),
45
+ 'exact_date': getLocale('exact_date'),
46
+ 'the_past_week': getLocale('last_week'),
47
+ 'the_past_month': getLocale('last_month'),
48
+ 'the_past_year': getLocale('last_year'),
49
+ 'the_next_week': getLocale('the_next_week'),
50
+ 'the_next_month': getLocale('the_next_month'),
51
+ 'the_next_year': getLocale('the_next_year'),
52
+ 'the_next_numbers_of_days': getLocale('the_next_numbers_of_days'),
53
+ 'the_past_numbers_of_days': getLocale('the_past_numbers_of_days'),
54
+ 'this_week': getLocale('this_week'),
55
+ 'this_month': getLocale('this_month'),
56
+ 'this_year': getLocale('this_year')
57
+ };
58
+ return {
59
+ value: {
60
+ filterTermModifier
61
+ },
62
+ label: /*#__PURE__*/React.createElement("span", {
63
+ className: "select-option-name"
64
+ }, FILTER_TERM_MODIFIER_SHOW[filterTermModifier])
65
+ };
66
+ }
67
+ static generatorSingleSelectOption(option) {
68
+ return {
69
+ value: {
70
+ columnOption: option
71
+ },
72
+ label: /*#__PURE__*/React.createElement("div", {
73
+ className: "select-option-name"
74
+ }, /*#__PURE__*/React.createElement("div", {
75
+ className: "single-select-option",
76
+ style: {
77
+ background: option.color,
78
+ color: option.textColor || null
79
+ },
80
+ title: option.name,
81
+ "aria-label": option.name
82
+ }, option.name))
83
+ };
84
+ }
85
+ static generatorMultipleSelectOption(option, filterTerm) {
86
+ return {
87
+ value: {
88
+ columnOption: option
89
+ },
90
+ label: /*#__PURE__*/React.createElement("div", {
91
+ className: "select-option-name multiple-option-name"
92
+ }, /*#__PURE__*/React.createElement("div", {
93
+ className: "multiple-select-option",
94
+ style: {
95
+ background: option.color,
96
+ color: option.textColor
97
+ },
98
+ title: option.name,
99
+ "aria-label": option.name
100
+ }, option.name), /*#__PURE__*/React.createElement("div", {
101
+ className: "multiple-check-icon"
102
+ }, filterTerm.indexOf(option.id) > -1 && /*#__PURE__*/React.createElement("i", {
103
+ className: "option-edit dtable-font dtable-icon-check-mark"
104
+ })))
105
+ };
106
+ }
107
+ static generatorConjunctionOptions() {
108
+ return [{
109
+ value: {
110
+ filterConjunction: 'And'
111
+ },
112
+ label: /*#__PURE__*/React.createElement("span", {
113
+ className: "select-option-name"
114
+ }, getLocale('And'))
115
+ }, {
116
+ value: {
117
+ filterConjunction: 'Or'
118
+ },
119
+ label: /*#__PURE__*/React.createElement("span", {
120
+ className: "select-option-name"
121
+ }, getLocale('Or'))
122
+ }];
123
+ }
124
+ static getActiveConjunctionOption(conjunction) {
125
+ if (conjunction === 'And') {
126
+ return {
127
+ value: {
128
+ filterConjunction: 'And'
129
+ },
130
+ label: /*#__PURE__*/React.createElement("span", {
131
+ className: "select-option-name"
132
+ }, getLocale('And'))
133
+ };
134
+ }
135
+ return {
136
+ value: {
137
+ filterConjunction: 'Or'
138
+ },
139
+ label: /*#__PURE__*/React.createElement("span", {
140
+ className: "select-option-name"
141
+ }, getLocale('Or'))
142
+ };
143
+ }
144
+ }
145
+ export default FilterItemUtils;