dtable-ui-component 6.0.55-beta.2 → 6.0.55-beta.4

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.
@@ -45,13 +45,15 @@ const COLUMN_DISPLAY_TYPE_ICON_CONFIG = {
45
45
  };
46
46
  const DTableColumnIcon = _ref => {
47
47
  let {
48
- columnType,
49
- columnDisplayType,
48
+ column,
50
49
  color,
51
50
  className,
52
51
  ariaHidden = false,
53
52
  getSvg
54
53
  } = _ref;
54
+ if (!column) return null;
55
+ const columnType = (column === null || column === void 0 ? void 0 : column.type) || _dtableUtils.CellType.TEXT;
56
+ const columnDisplayType = (0, _dtableUtils.getColumnDisplayType)(column);
55
57
  let symbol = null;
56
58
  let displayTypeIconConfig = COLUMN_DISPLAY_TYPE_ICON_CONFIG[columnType];
57
59
  if (displayTypeIconConfig && columnDisplayType) {
@@ -14,9 +14,7 @@ class FilterItemUtils {
14
14
  static generatorColumnOption(column) {
15
15
  if (!column) return null;
16
16
  const {
17
- type,
18
- name,
19
- data
17
+ name
20
18
  } = column;
21
19
  return {
22
20
  value: {
@@ -26,8 +24,7 @@ class FilterItemUtils {
26
24
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
27
25
  className: "filter-header-icon",
28
26
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableColumnIcon.default, {
29
- columnType: type,
30
- columnDisplayType: data === null || data === void 0 ? void 0 : data.display_type
27
+ column: column
31
28
  })
32
29
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
33
30
  className: "select-option-name",
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "FilterItemUtils", {
10
10
  return _filterItemUtils.default;
11
11
  }
12
12
  });
13
- exports.isFilterTermArray = exports.getUpdatedFilterBySelectSingle = exports.getUpdatedFilterBySelectMultiple = exports.getUpdatedFilterByRate = exports.getUpdatedFilterByPredicate = exports.getUpdatedFilterByCreator = exports.getUpdatedFilterByColumn = exports.getUpdatedFilterByCollaborator = exports.getSingleSelectUpdatedFilterTerm = exports.getMultipleSelectUpdatedFilterTerm = exports.getFormulaColumnFilter = exports.getFormulaAndLinkFilters = exports.getFilterConfigOptions = exports.getFilterColumns = exports.getFilterByColumn = exports.getDefaultFilterGroup = exports.getDefaultFilter = exports.getCreatorUpdatedFilterTerm = exports.getColumnOptions = exports.getColumnByKey = exports.getCollaboratorUpdatedFilterTerm = exports.generateDefaultUser = exports.checkColumnHasFilterOptions = exports.applyFilterOperation = void 0;
13
+ exports.isFilterTermArray = exports.getUpdatedFilterBySelectSingle = exports.getUpdatedFilterBySelectMultiple = exports.getUpdatedFilterByRate = exports.getUpdatedFilterByPredicate = exports.getUpdatedFilterByCreator = exports.getUpdatedFilterByColumn = exports.getUpdatedFilterByCollaborator = exports.getSingleSelectUpdatedFilterTerm = exports.getMultipleSelectUpdatedFilterTerm = exports.getFormulaColumnFilter = exports.getFormulaAndLinkFilters = exports.getFilterConfigOptions = exports.getFilterColumns = exports.getFilterByColumn = exports.getDefaultFilterGroup = exports.getDefaultFilter = exports.getCreatorUpdatedFilterTerm = exports.getColumnOptions = exports.getColumnByKey = exports.getCollaboratorUpdatedFilterTerm = exports.generateDefaultUser = exports.applyFilterOperation = void 0;
14
14
  var _dtableUtils = require("dtable-utils");
15
15
  var _filterItemUtils = _interopRequireDefault(require("./filter-item-utils"));
16
16
  var _constants = require("../constants");
@@ -138,20 +138,17 @@ const getColumnOptions = column => {
138
138
  } = data || {};
139
139
  if (array_type === _dtableUtils.FORMULA_RESULT_TYPE.BOOL) {
140
140
  return (0, _dtableUtils.getColumnFilterOptions)({
141
- columnType: _dtableUtils.CellType.CHECKBOX
141
+ type: _dtableUtils.CellType.CHECKBOX
142
142
  });
143
143
  }
144
144
  if (array_type === _dtableUtils.FORMULA_RESULT_TYPE.STRING) {
145
145
  return (0, _dtableUtils.getColumnFilterOptions)({
146
- columnType: _dtableUtils.CellType.TEXT
146
+ type: _dtableUtils.CellType.TEXT
147
147
  });
148
148
  }
149
149
  return getFilterOptionsByArrayType(array_type, array_data);
150
150
  }
151
- return (0, _dtableUtils.getColumnFilterOptions)({
152
- columnType: type,
153
- columnDisplayType: data === null || data === void 0 ? void 0 : data.display_type
154
- });
151
+ return (0, _dtableUtils.getColumnFilterOptions)(column);
155
152
  };
156
153
  exports.getColumnOptions = getColumnOptions;
157
154
  const getFormulaColumnFilterOptions = column => {
@@ -165,24 +162,24 @@ const getFormulaColumnFilterOptions = column => {
165
162
  } = data || {};
166
163
  if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.BOOL) {
167
164
  return (0, _dtableUtils.getColumnFilterOptions)({
168
- columnType: _dtableUtils.CellType.CHECKBOX
165
+ type: _dtableUtils.CellType.CHECKBOX
169
166
  });
170
167
  }
171
168
  if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.STRING) {
172
169
  return (0, _dtableUtils.getColumnFilterOptions)({
173
- columnType: _dtableUtils.CellType.TEXT
170
+ type: _dtableUtils.CellType.TEXT
174
171
  });
175
172
  }
176
173
  if ([_dtableUtils.FORMULA_RESULT_TYPE.NUMBER, _dtableUtils.FORMULA_RESULT_TYPE.DATE].includes(result_type)) {
177
174
  return (0, _dtableUtils.getColumnFilterOptions)({
178
- columnType: result_type
175
+ type: result_type
179
176
  });
180
177
  }
181
178
  if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
182
179
  return getFilterOptionsByArrayType(array_type, array_data);
183
180
  }
184
181
  return (0, _dtableUtils.getColumnFilterOptions)({
185
- columnType: _dtableUtils.CellType.TEXT
182
+ type: _dtableUtils.CellType.TEXT
186
183
  });
187
184
  };
188
185
  const getFilterOptionsByArrayType = (array_type, array_data) => {
@@ -205,18 +202,18 @@ const getFilterOptionsByArrayType = (array_type, array_data) => {
205
202
  // only support: is
206
203
  if (checkType === _dtableUtils.CellType.CHECKBOX || checkType === _dtableUtils.CellType.BOOL) {
207
204
  return (0, _dtableUtils.getColumnFilterOptions)({
208
- columnType: _dtableUtils.CellType.CHECKBOX
205
+ type: _dtableUtils.CellType.CHECKBOX
209
206
  });
210
207
  }
211
- const filterOptions = checkColumnHasFilterOptions({
212
- columnType: checkType,
213
- columnDisplayType: array_data === null || array_data === void 0 ? void 0 : array_data.display_type
208
+ const filterOptions = (0, _dtableUtils.checkColumnHasFilterOptions)({
209
+ type: checkType,
210
+ data: array_data
214
211
  }) ? (0, _dtableUtils.getColumnFilterOptions)({
215
- columnType: checkType,
216
- columnDisplayType: array_data === null || array_data === void 0 ? void 0 : array_data.display_type
212
+ type: checkType,
213
+ data: array_data
217
214
  }) : (0, _dtableUtils.getColumnFilterOptions)({
218
- columnType: _dtableUtils.CellType.TEXT,
219
- columnDisplayType: array_data === null || array_data === void 0 ? void 0 : array_data.display_type
215
+ type: _dtableUtils.CellType.TEXT,
216
+ data: array_data
220
217
  });
221
218
  const {
222
219
  filterPredicateList
@@ -418,33 +415,11 @@ const generateDefaultUser = name => {
418
415
  };
419
416
  };
420
417
  exports.generateDefaultUser = generateDefaultUser;
421
- const checkColumnHasFilterOptions = _ref => {
422
- let {
423
- columnType,
424
- columnDisplayType
425
- } = _ref;
426
- const filterOptions = (0, _dtableUtils.getColumnFilterOptions)({
427
- columnType,
428
- columnDisplayType
429
- });
430
- return filterOptions ? Object.keys(filterOptions).length > 0 : false;
431
- };
432
- exports.checkColumnHasFilterOptions = checkColumnHasFilterOptions;
433
418
  const getDefaultFilter = columns => {
434
- var _defaultColumn$data;
435
419
  if (!columns) return null;
436
420
  let defaultColumn = columns[0];
437
- if (!checkColumnHasFilterOptions({
438
- columnType: defaultColumn.type,
439
- columnDisplayType: (_defaultColumn$data = defaultColumn.data) === null || _defaultColumn$data === void 0 ? void 0 : _defaultColumn$data.display_type
440
- })) {
441
- defaultColumn = columns.find(c => {
442
- var _c$data;
443
- return checkColumnHasFilterOptions({
444
- columnType: c.type,
445
- columnDisplayType: (_c$data = c.data) === null || _c$data === void 0 ? void 0 : _c$data.display_type
446
- });
447
- });
421
+ if (!(0, _dtableUtils.checkColumnHasFilterOptions)(defaultColumn)) {
422
+ defaultColumn = columns.find(c => (0, _dtableUtils.checkColumnHasFilterOptions)(c));
448
423
  }
449
424
  if (!defaultColumn) return null;
450
425
  return getFilterByColumn(defaultColumn);
@@ -483,16 +458,12 @@ const getFilterColumns = columns => {
483
458
  type
484
459
  } = column;
485
460
  if (data && (type === _dtableUtils.CellType.LINK || _dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] && data.result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY)) {
486
- var _data$array_data;
487
- return checkColumnHasFilterOptions({
488
- columnType: data.array_type,
489
- columnDisplayType: (_data$array_data = data.array_data) === null || _data$array_data === void 0 ? void 0 : _data$array_data.display_type
461
+ return (0, _dtableUtils.checkColumnHasFilterOptions)({
462
+ type: data.array_type,
463
+ data: data.array_data
490
464
  });
491
465
  }
492
- return checkColumnHasFilterOptions({
493
- columnType: type,
494
- columnDisplayType: data === null || data === void 0 ? void 0 : data.display_type
495
- });
466
+ return (0, _dtableUtils.checkColumnHasFilterOptions)(column);
496
467
  });
497
468
  };
498
469
  exports.getFilterColumns = getFilterColumns;
@@ -764,20 +735,17 @@ const getFilterConfigOptions = column => {
764
735
  } = data || {};
765
736
  if (array_type === _dtableUtils.FORMULA_RESULT_TYPE.BOOL) {
766
737
  return (0, _dtableUtils.getColumnFilterOptions)({
767
- columnType: _dtableUtils.CellType.CHECKBOX
738
+ type: _dtableUtils.CellType.CHECKBOX
768
739
  });
769
740
  }
770
741
  if (array_type === _dtableUtils.FORMULA_RESULT_TYPE.STRING) {
771
742
  return (0, _dtableUtils.getColumnFilterOptions)({
772
- columnType: _dtableUtils.CellType.TEXT
743
+ type: _dtableUtils.CellType.TEXT
773
744
  });
774
745
  }
775
746
  return getFilterOptionsByArrayType(array_type, array_data);
776
747
  }
777
- return (0, _dtableUtils.getColumnFilterOptions)({
778
- columnType: type,
779
- columnDisplayType: data === null || data === void 0 ? void 0 : data.display_type
780
- }) || {};
748
+ return (0, _dtableUtils.getColumnFilterOptions)(column) || {};
781
749
  };
782
750
  exports.getFilterConfigOptions = getFilterConfigOptions;
783
751
  const getMultipleSelectUpdatedFilterTerm = (filterTerm, option) => {
@@ -70,8 +70,10 @@ function FieldItem(_ref) {
70
70
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
71
71
  className: "field-switch",
72
72
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableColumnIcon.default, {
73
- columnType: type,
74
- columnDisplayType: data === null || data === void 0 ? void 0 : data.display_type
73
+ column: {
74
+ type,
75
+ data
76
+ }
75
77
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
76
78
  children: field.name
77
79
  })]
@@ -19,9 +19,7 @@ const ColumnContent = _ref => {
19
19
  const descriptionRef = (0, _react.useRef)(null);
20
20
  const {
21
21
  name,
22
- type,
23
22
  key,
24
- data,
25
23
  description
26
24
  } = column;
27
25
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactstrap.Row, {
@@ -33,8 +31,7 @@ const ColumnContent = _ref => {
33
31
  className: "dtable-ui-header-icon",
34
32
  id: `header-icon-${key}`,
35
33
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableColumnIcon.default, {
36
- columnType: type,
37
- columnDisplayType: data === null || data === void 0 ? void 0 : data.display_type
34
+ column: column
38
35
  })
39
36
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
40
37
  className: "dtable-ui-row-expand-column-name",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.55-beta.2",
3
+ "version": "6.0.55-beta.4",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",
@@ -8,7 +8,7 @@
8
8
  "@seafile/seafile-editor": "~2.0.14",
9
9
  "classnames": "~2.5.*",
10
10
  "dayjs": "1.10.7",
11
- "dtable-utils": "~5.0.26-beta.1",
11
+ "dtable-utils": "~5.0.26-beta.3",
12
12
  "is-hotkey": "0.2.0",
13
13
  "rc-checkbox": "3.5.0",
14
14
  "react-color": "2.19.3",