dtable-ui-component 4.4.0 → 4.4.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 (38) hide show
  1. package/lib/DTableCommonAddTool/index.css +25 -0
  2. package/lib/DTableCommonAddTool/index.js +24 -0
  3. package/lib/DTableFiltersPopover/constants/index.js +65 -0
  4. package/lib/DTableFiltersPopover/index.css +39 -0
  5. package/lib/DTableFiltersPopover/index.js +216 -0
  6. package/lib/DTableFiltersPopover/utils/filter-item-utils.js +145 -0
  7. package/lib/DTableFiltersPopover/utils/index.js +452 -0
  8. package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.css +0 -0
  9. package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +106 -0
  10. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +89 -0
  11. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +89 -0
  12. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +167 -0
  13. package/lib/DTableFiltersPopover/widgets/filter-item.js +677 -0
  14. package/lib/DTableFiltersPopover/widgets/filter-list/index.css +321 -0
  15. package/lib/DTableFiltersPopover/widgets/filter-list/index.js +125 -0
  16. package/lib/DTableFiltersPopover/widgets/rate-item.js +72 -0
  17. package/lib/DTablePopover/index.js +1 -1
  18. package/lib/Department-editor/constants.js +10 -0
  19. package/lib/Department-editor/department-multiple-select/index.css +67 -0
  20. package/lib/Department-editor/department-multiple-select/index.js +143 -0
  21. package/lib/Department-editor/department-single-select.js +263 -0
  22. package/lib/Department-editor/index.css +117 -0
  23. package/lib/Department-editor/index.js +99 -0
  24. package/lib/Department-editor/selected-departments/index.css +26 -0
  25. package/lib/Department-editor/selected-departments/index.js +81 -0
  26. package/lib/Department-editor/utils.js +29 -0
  27. package/lib/constants/index.js +4 -1
  28. package/lib/hooks/common-hooks.js +21 -0
  29. package/lib/index.js +4 -1
  30. package/lib/lang/index.js +67 -3
  31. package/lib/locals/en.js +69 -1
  32. package/lib/locals/zh-CN.js +68 -1
  33. package/lib/select-editor/mb-select-editor-popover/index.css +1 -1
  34. package/lib/select-editor/mb-select-editor-popover/index.js +1 -1
  35. package/lib/utils/dayjs.js +4 -0
  36. package/lib/utils/event-bus.js +28 -0
  37. package/lib/utils/utils.js +5 -0
  38. package/package.json +1 -1
@@ -0,0 +1,321 @@
1
+ .filters-list {
2
+ min-height: 120px;
3
+ max-height: 100%;
4
+ padding: 15px;
5
+ }
6
+
7
+ .filters-list.empty-filters-container {
8
+ min-height: 80px;
9
+ padding: 16px;
10
+ }
11
+
12
+ .filters-list.empty-filters-container .empty-filters-list {
13
+ padding-left: 0;
14
+ }
15
+
16
+ .filters-list .empty-filters-list {
17
+ padding: 0.25rem;
18
+ font-size: 14px;
19
+ opacity: 0.5;
20
+ }
21
+
22
+ .filters-list .filter-item {
23
+ display: flex;
24
+ align-items: center;
25
+ padding: 0.25rem 0;
26
+ }
27
+
28
+ .filters-list .filter-item .condition {
29
+ display: flex;
30
+ flex: 1;
31
+ }
32
+
33
+ .filters-list .filter-item .condition > div {
34
+ height: 38px;
35
+ line-height: 38px;
36
+ margin-left: 0.5rem;
37
+ }
38
+
39
+ .filters-list .filter-item .condition > div:first-child {
40
+ margin-left: 0;
41
+ }
42
+
43
+ .filters-list .filter-item .filter-term {
44
+ max-width: 300px;
45
+ }
46
+
47
+ .filters-list .filter-item .filter-term .option-group-content .option.option-active .dtable-font {
48
+ color: #798d99;
49
+ }
50
+
51
+ .filters-list .filter-conjunction {
52
+ width: 72px;
53
+ }
54
+
55
+ .filters-list .filter-conjunction-readonly {
56
+ width: 52px;
57
+ }
58
+
59
+ .filters-list .filter-container {
60
+ width: calc(100% - 72px);
61
+ display: flex;
62
+ }
63
+
64
+ .filters-list .dtable-select .selected-option-show {
65
+ width: calc(100% - 20px);
66
+ height: 20px;
67
+ }
68
+
69
+ .filters-list .dtable-select .selected-option {
70
+ width: auto;
71
+ overflow-x: auto;
72
+ }
73
+
74
+ .filters-list .dtable-select .dtable-icon-drop-down {
75
+ margin-left: 0.5rem;
76
+ }
77
+
78
+ .filters-list .selected-conjunction-show {
79
+ padding: 0 10px;
80
+ color: #999;
81
+ }
82
+
83
+ .filters-list .filter-column {
84
+ max-width: 150px;
85
+ }
86
+
87
+ .filter-term .selector-multiple-select .option,
88
+ .filter-term .selector-single-select .option {
89
+ height: 30px;
90
+ padding: 0 10px;
91
+ }
92
+
93
+ .filter-term .selector-multiple-select .select-option-name,
94
+ .filter-term .selector-single-select .select-option-name {
95
+ margin-top: 5px;
96
+ }
97
+
98
+ .filter-term .selector-single-select .option:hover {
99
+ color: #212529;
100
+ background-color: #f7f7f7;
101
+ }
102
+
103
+ .filter-term .selector-single-select .option:hover .select-option-name,
104
+ .filter-term .selector-multiple-select .option:hover .select-option-name,
105
+ .filter-term .selector-collaborator .option:hover .select-option-name {
106
+ color: unset;
107
+ }
108
+
109
+ .filter-term .selector-collaborator .dtable-icon-drop-down {
110
+ padding-left: 5px;
111
+ }
112
+
113
+ .filters-list .selector-collaborator .selected-option-show {
114
+ text-overflow: unset;
115
+ }
116
+
117
+ .filters-list .selector-multiple-select .option:hover,
118
+ .filters-list .selector-multiple-select .option.option-active,
119
+ .filters-list .selector-collaborator .option:hover,
120
+ .filters-list .selector-collaborator .option.option-active {
121
+ color: #212529;
122
+ background-color: #f7f7f7;
123
+ }
124
+
125
+ .filters-list .selector-multiple-select .option.option-active .select-option-name,
126
+ .filters-list .selector-collaborator .option.option-active .select-option-name {
127
+ color: #212529;
128
+ }
129
+
130
+ .filters-list .selected-option .multiple-select-option,
131
+ .filters-list .selected-option .single-select-option {
132
+ margin: 0;
133
+ display: inline-block;
134
+ }
135
+
136
+ .filters-list .filter-term input {
137
+ display: flex;
138
+ width: 100%;
139
+ height: 38px;
140
+ background-color: #ffffff;
141
+ padding-left: 8px;
142
+ padding-right: 8px;
143
+ outline: none;
144
+ border-radius: 3px;
145
+ font-size: 0.875rem;
146
+ }
147
+
148
+ .filters-list .filter-term input:hover {
149
+ border-color: rgb(179, 179, 179);
150
+ }
151
+
152
+ .filters-list .filter-term input.disabled:hover {
153
+ border-color: rgba(0, 40, 100, 0.12);
154
+ }
155
+
156
+ .filters-list .filter-term input:hover:focus {
157
+ border-color: #1991eb;
158
+ }
159
+
160
+ .filters-list .filter-term input:focus {
161
+ color: #495057;
162
+ background-color: #fff;
163
+ border-color: #1991eb;
164
+ outline: 0;
165
+ box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.25);
166
+ }
167
+
168
+ .filters-list .filter-term .date-picker-container input:focus {
169
+ color: #495057;
170
+ background-color: #fff;
171
+ border: 1px solid #fff;
172
+ outline: 0;
173
+ }
174
+
175
+ .filters-list .filter-term .date-picker-container table tr {
176
+ height: 30px;
177
+ }
178
+
179
+ .filters-list .filter-term input[type='checkbox'] {
180
+ width: inherit;
181
+ }
182
+
183
+ .filters-list .filter-term input[type='checkbox']:focus {
184
+ border: 0;
185
+ box-shadow: none;
186
+ }
187
+
188
+ .filter-term .filter-rate-list {
189
+ display: flex;
190
+ padding: 0 5px;
191
+ border: 1px solid rgba(0, 40, 100, 0.12);
192
+ }
193
+
194
+ .filters-list .delete-filter {
195
+ width: 12px;
196
+ height: 20px;
197
+ margin-right: 14px;
198
+ text-align: center;
199
+ }
200
+
201
+ .filters-list .delete-filter:hover {
202
+ cursor: pointer;
203
+ }
204
+
205
+ .filters-list .delete-filter .dtable-icon-fork-number {
206
+ display: inline-block;
207
+ font-size: 12px;
208
+ color: #949494;
209
+ }
210
+
211
+ .filters-list .multiple-option-name {
212
+ display: flex;
213
+ align-items: center;
214
+ }
215
+
216
+ .filters-list .multiple-check-icon,
217
+ .filters-list .collaborator-check-icon {
218
+ display: inline-flex;
219
+ width: 20px;
220
+ height: 20px;
221
+ align-items: center;
222
+ text-align: center;
223
+ }
224
+
225
+ .filters-list .multiple-check-icon .dtable-icon-check-mark,
226
+ .filters-list .collaborator-check-icon .dtable-icon-check-mark {
227
+ font-size: 12px;
228
+ color: #798d99;
229
+ }
230
+
231
+ .user-select-item,
232
+ .collaborator {
233
+ display: inline-flex;
234
+ align-items: center;
235
+ height: 20px;
236
+ margin-right: 10px;
237
+ padding: 0 8px 0 2px;
238
+ font-size: 13px;
239
+ border-radius: 10px;
240
+ background: #eaeaea;
241
+ }
242
+
243
+ .filters-list .collaborator-show {
244
+ flex: 1;
245
+ }
246
+
247
+ .filters-list .collaborator-avatar-container {
248
+ width: 16px;
249
+ }
250
+
251
+ .filters-list .collaborator-avatar {
252
+ width: 16px;
253
+ height: 16px;
254
+ transform: translateY(-1px);
255
+ border-radius: 50%;
256
+ }
257
+
258
+ .filters-list .option .collaborator-avatar {
259
+ transform: translateY(-2px);
260
+ }
261
+
262
+ .filters-list .collaborator-name {
263
+ margin-left: 5px;
264
+ max-width: 200px;
265
+ }
266
+
267
+ .filters-list .option-collaborator {
268
+ display: flex;
269
+ }
270
+
271
+ .filters-list .collaborator-container {
272
+ flex: 1;
273
+ }
274
+
275
+ .filters-list .popover-add-tool {
276
+ border-top: none;
277
+ color: #555555;
278
+ }
279
+
280
+ .filters-list .popover-add-tool .popover-add-icon {
281
+ margin-right: 14px;
282
+ }
283
+
284
+ .filters-list .option-group {
285
+ max-height: 360px;
286
+ overflow: auto;
287
+ }
288
+
289
+ .filters-list .filter-item .dtable-icon-fork-number:hover {
290
+ color: #5a5a5a;
291
+ }
292
+
293
+ .filters-list .filter-container-readonly .dtable-select .selected-option-show,
294
+ .filters-list .filter-conjunction-readonly .dtable-select .selected-option-show {
295
+ width: 100%;
296
+ }
297
+
298
+ .filters-list .filter-checkbox-predicate .dtable-select .selected-option-show {
299
+ width: 100%;
300
+ }
301
+
302
+ .dropdown-item .collaborator,
303
+ .filters-list .option-group .option-group-content .collaborator {
304
+ background-color: unset;
305
+ }
306
+
307
+ .filters-list .dtable-select .selected-option-show .remove-container {
308
+ display: none;
309
+ }
310
+
311
+ .filter-header-icon {
312
+ display: inline-block;
313
+ padding: 0 0.3125rem;
314
+ margin-left: -0.3125rem;
315
+ }
316
+
317
+ .filter-header-icon .dtable-font {
318
+ font-size: 14px;
319
+ color: #aaa;
320
+ cursor: default;
321
+ }
@@ -0,0 +1,125 @@
1
+ import React, { Component } from 'react';
2
+ import classnames from 'classnames';
3
+ import { CellType, FILTER_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, ValidateFilter } from 'dtable-utils';
4
+ import FilterItem from '../filter-item';
5
+ import { getColumnByKey, FilterItemUtils } from '../../utils';
6
+ import './index.css';
7
+ class FiltersList extends Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.updateFilter = (filterIndex, updatedFilter) => {
11
+ if (!updatedFilter) return;
12
+ this.props.updateFilter(filterIndex, updatedFilter);
13
+ };
14
+ this.deleteFilter = index => {
15
+ const {
16
+ scheduleUpdate
17
+ } = this.props;
18
+ this.props.deleteFilter(index, scheduleUpdate);
19
+ };
20
+ this.updateConjunction = filterConjunction => {
21
+ this.props.updateFilterConjunction(filterConjunction);
22
+ };
23
+ this.getConjunctionOptions = () => {
24
+ if (!this.conjunctionOptions) {
25
+ this.conjunctionOptions = FilterItemUtils.generatorConjunctionOptions();
26
+ }
27
+ return this.conjunctionOptions;
28
+ };
29
+ this.getFilterColumns = () => {
30
+ const {
31
+ columns
32
+ } = this.props;
33
+ return columns.filter(column => {
34
+ const {
35
+ data
36
+ } = column;
37
+ let {
38
+ type
39
+ } = column;
40
+ if (data && (type === CellType.LINK || FORMULA_COLUMN_TYPES_MAP[type] && data.result_type === FORMULA_RESULT_TYPE.ARRAY)) {
41
+ type = data.array_type;
42
+ }
43
+ return Object.prototype.hasOwnProperty.call(FILTER_COLUMN_OPTIONS, type);
44
+ });
45
+ };
46
+ this.getColumnOptions = () => {
47
+ if (!this.columnOptions) {
48
+ const filterColumns = this.getFilterColumns();
49
+ this.columnOptions = filterColumns.map(column => {
50
+ return FilterItemUtils.generatorColumnOption(column);
51
+ });
52
+ }
53
+ return this.columnOptions;
54
+ };
55
+ this.renderFilterItem = (filter, index, errMsg, filterColumn) => {
56
+ const {
57
+ filterConjunction,
58
+ value,
59
+ roleId,
60
+ isLocked,
61
+ collaborators,
62
+ userDepartmentIdsMap,
63
+ departments,
64
+ lang
65
+ } = this.props;
66
+ const conjunctionOptions = this.getConjunctionOptions();
67
+ const columnOptions = this.getColumnOptions();
68
+ return /*#__PURE__*/React.createElement(FilterItem, {
69
+ key: index,
70
+ isLocked: isLocked,
71
+ roleId: roleId,
72
+ index: index,
73
+ filter: filter,
74
+ errMsg: errMsg,
75
+ filterColumn: filterColumn,
76
+ filterConjunction: filterConjunction,
77
+ conjunctionOptions: conjunctionOptions,
78
+ filterColumnOptions: columnOptions,
79
+ value: value,
80
+ collaborators: collaborators,
81
+ userDepartmentIdsMap: userDepartmentIdsMap,
82
+ departments: departments,
83
+ lang: lang,
84
+ deleteFilter: this.deleteFilter,
85
+ updateFilter: this.updateFilter,
86
+ updateConjunction: this.updateConjunction
87
+ });
88
+ };
89
+ this.conjunctionOptions = null;
90
+ this.columnOptions = null;
91
+ }
92
+ UNSAFE_componentWillReceiveProps(nextProps) {
93
+ if (nextProps.columns !== this.props.columns) {
94
+ this.columnOptions = null;
95
+ }
96
+ }
97
+ render() {
98
+ let {
99
+ filters,
100
+ className,
101
+ emptyPlaceholder,
102
+ columns
103
+ } = this.props;
104
+ const isEmpty = filters.length === 0;
105
+ return /*#__PURE__*/React.createElement("div", {
106
+ className: classnames('filters-list', {
107
+ 'empty-filters-container': isEmpty
108
+ }, {
109
+ [className]: className
110
+ })
111
+ }, isEmpty && /*#__PURE__*/React.createElement("div", {
112
+ className: "empty-filters-list"
113
+ }, emptyPlaceholder), !isEmpty && filters.map((filter, index) => {
114
+ const {
115
+ column_key
116
+ } = filter;
117
+ const {
118
+ error_message
119
+ } = ValidateFilter.validateColumn(column_key, columns);
120
+ const filterColumn = getColumnByKey(columns, column_key) || {};
121
+ return this.renderFilterItem(filter, index, error_message, filterColumn);
122
+ }));
123
+ }
124
+ }
125
+ export default FiltersList;
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import { UncontrolledTooltip } from 'reactstrap';
3
+ class RateItem extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this.onMouseEnterRateItem = () => {
7
+ const {
8
+ rateItemIndex
9
+ } = this.props;
10
+ this.props.onMouseEnterRateItem(rateItemIndex);
11
+ };
12
+ this.onMouseLeaveRateItem = () => {
13
+ this.props.onMouseLeaveRateItem();
14
+ };
15
+ this.onChangeRateNumber = () => {
16
+ const {
17
+ onChangeRateNumber,
18
+ rateItemIndex,
19
+ editable
20
+ } = this.props;
21
+ if (onChangeRateNumber && editable) {
22
+ onChangeRateNumber(rateItemIndex);
23
+ }
24
+ };
25
+ this.tooltipRef = React.createRef();
26
+ this.state = {
27
+ isOpen: false
28
+ };
29
+ }
30
+ render() {
31
+ const {
32
+ enterRateItemIndex,
33
+ rateItemIndex,
34
+ value,
35
+ column,
36
+ isShowRateItem,
37
+ editable
38
+ } = this.props;
39
+ const {
40
+ rate_style_color,
41
+ rate_style_type
42
+ } = column.data || {};
43
+ const rateShowType = rate_style_type ? rate_style_type : 'dtable-icon-rate';
44
+ if (!isShowRateItem && rateItemIndex > value) return null;
45
+ let itemStyle = {
46
+ cursor: editable ? 'pointer' : 'default',
47
+ color: value >= rateItemIndex ? rate_style_color : '#e5e5e5'
48
+ };
49
+ let style = itemStyle;
50
+ if (enterRateItemIndex >= rateItemIndex) {
51
+ style = {
52
+ ...itemStyle,
53
+ color: rate_style_color,
54
+ opacity: 0.4
55
+ };
56
+ }
57
+ return /*#__PURE__*/React.createElement("div", {
58
+ onMouseEnter: this.onMouseEnterRateItem,
59
+ onMouseLeave: this.onMouseLeaveRateItem,
60
+ style: style,
61
+ onClick: this.onChangeRateNumber,
62
+ className: "rate-item ".concat(value >= rateItemIndex ? 'rate-item-active' : '')
63
+ }, /*#__PURE__*/React.createElement("span", {
64
+ className: "dtable-font ".concat(rateShowType),
65
+ ref: this.tooltipRef
66
+ }), editable && /*#__PURE__*/React.createElement(UncontrolledTooltip, {
67
+ placement: "bottom",
68
+ target: this.tooltipRef
69
+ }, rateItemIndex));
70
+ }
71
+ }
72
+ export default RateItem;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Popover } from 'reactstrap';
3
- import { getEventClassName } from './utils';
3
+ import { getEventClassName } from '../utils/utils';
4
4
  class DTablePopover extends React.Component {
5
5
  constructor() {
6
6
  super(...arguments);
@@ -0,0 +1,10 @@
1
+ export const DEPARTMENT_SELECT_RANGE_OPTIONS = [{
2
+ name: 'Current_user_department',
3
+ type: 'current_user_department'
4
+ }, {
5
+ name: 'Current_user_department_and_sub',
6
+ type: 'current_user_department_and_sub'
7
+ }, {
8
+ name: 'Specific_departments',
9
+ type: 'specific_departments'
10
+ }];
@@ -0,0 +1,67 @@
1
+ .departments-container.dtable-ui {
2
+ top: -4px;
3
+ left: -3px;
4
+ width: calc(100% + 8px);
5
+ z-index: 1100;
6
+ min-height: 260px;
7
+ padding-top: 0;
8
+ cursor: default;
9
+ }
10
+
11
+ .departments-container.dtable-ui.filter {
12
+ top: 42px;
13
+ left: 0px;
14
+ width: 300px;
15
+ height: 285px;
16
+ }
17
+
18
+ .departments-container.dtable-ui .search-departments {
19
+ padding: 10px 10px 0px;
20
+ }
21
+
22
+ .departments-container.dtable-ui .search-departments input {
23
+ height: 30px !important;
24
+ font-size: 14px;
25
+ display: initial !important;
26
+ }
27
+
28
+ .departments-container.dtable-ui .department-item-container {
29
+ background-color: #fff;
30
+ max-height: 240px;
31
+ overflow: auto;
32
+ cursor: pointer;
33
+ padding: 10px 0;
34
+ }
35
+
36
+ .departments-container.dtable-ui .expand {
37
+ color: #b5b5b5;
38
+ font-size: 12px;
39
+ transform: scale(0.8);
40
+ cursor: pointer;
41
+ margin-left: 0px !important;
42
+ }
43
+
44
+ .departments-container.dtable-ui .expand:hover {
45
+ color: #555;
46
+ }
47
+
48
+ .departments-container.dtable-ui .department-select-input {
49
+ width: 15px !important;
50
+ height: 15px !important;
51
+ margin-right: 5px;
52
+ cursor: pointer;
53
+ }
54
+
55
+ .departments-container.dtable-ui .dropdown-item {
56
+ padding-left: 10px;
57
+ cursor: pointer;
58
+ }
59
+
60
+ .departments-container.dtable-ui .dropdown-item:hover {
61
+ background: #f5f5f5;
62
+ color: #212529;
63
+ }
64
+
65
+ .departments-container.dtable-ui .selected-option-show {
66
+ width: 95%;
67
+ }