dtable-ui-component 4.4.3-2 → 4.4.3-alpha1

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 (149) hide show
  1. package/lib/AutoNumberFormatter/index.js +7 -14
  2. package/lib/ButtonFormatter/index.js +9 -16
  3. package/lib/CTimeFormatter/index.js +9 -16
  4. package/lib/CheckboxEditor/index.js +8 -15
  5. package/lib/CheckboxFormatter/index.js +8 -15
  6. package/lib/CollaboratorEditor/index.js +21 -29
  7. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +25 -32
  8. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +18 -25
  9. package/lib/CollaboratorFormatter/index.js +12 -19
  10. package/lib/CollaboratorItem/index.js +10 -17
  11. package/lib/CreatorFormatter/index.js +12 -19
  12. package/lib/DTableCommonAddTool/index.js +6 -13
  13. package/lib/DTableCustomizeCollaboratorSelect/index.js +18 -26
  14. package/lib/DTableCustomizeSelect/index.js +15 -23
  15. package/lib/DTableFiltersPopover/constants/index.js +33 -38
  16. package/lib/DTableFiltersPopover/index.js +31 -38
  17. package/lib/DTableFiltersPopover/utils/filter-item-utils.js +46 -53
  18. package/lib/DTableFiltersPopover/utils/index.js +99 -128
  19. package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +26 -34
  20. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +25 -33
  21. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +26 -34
  22. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +26 -34
  23. package/lib/DTableFiltersPopover/widgets/filter-item.js +120 -128
  24. package/lib/DTableFiltersPopover/widgets/filter-list/index.js +18 -26
  25. package/lib/DTableFiltersPopover/widgets/rate-item.js +8 -15
  26. package/lib/DTablePopover/index.js +8 -15
  27. package/lib/DTablePopover/utils.js +2 -9
  28. package/lib/DTableRadio/index.js +10 -17
  29. package/lib/DTableSearchInput/index.js +13 -21
  30. package/lib/DTableSearchInput/utils.js +2 -9
  31. package/lib/DTableSelect/dtable-select-label.js +6 -13
  32. package/lib/DTableSelect/index.js +10 -18
  33. package/lib/DTableSelect/utils.js +10 -20
  34. package/lib/DTableSwitch/index.js +7 -14
  35. package/lib/DateEditor/index.js +22 -30
  36. package/lib/DateEditor/mb-date-editor-popover/index.js +47 -55
  37. package/lib/DateEditor/pc-date-editor-popover.js +20 -27
  38. package/lib/DateFormatter/index.js +9 -16
  39. package/lib/Department-editor/constants.js +1 -7
  40. package/lib/Department-editor/department-multiple-select/index.js +24 -32
  41. package/lib/Department-editor/department-single-select.js +33 -41
  42. package/lib/Department-editor/index.js +14 -22
  43. package/lib/Department-editor/selected-departments/index.js +25 -32
  44. package/lib/Department-editor/utils.js +3 -11
  45. package/lib/DepartmentSingleSelectFormatter/index.js +9 -16
  46. package/lib/DigitalSignFormatter/index.js +15 -23
  47. package/lib/DigitalSignFormatter/utils.js +3 -11
  48. package/lib/DurationFormatter/index.js +9 -16
  49. package/lib/EditEditorButton/index.js +5 -12
  50. package/lib/EmailFormatter/index.js +7 -14
  51. package/lib/FieldDisplaySetting/field-item.js +14 -21
  52. package/lib/FieldDisplaySetting/index.js +19 -27
  53. package/lib/FileEditor/index.js +8 -15
  54. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  55. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  56. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  57. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  58. package/lib/FileFormatter/index.js +11 -19
  59. package/lib/FileItemFormatter/index.js +6 -14
  60. package/lib/FileItemFormatter/utils.js +2 -9
  61. package/lib/FileUploader/index.js +4 -11
  62. package/lib/FormulaFormatter/cell-value-validator.js +18 -24
  63. package/lib/FormulaFormatter/index.js +32 -39
  64. package/lib/FormulaFormatter/utils.js +13 -29
  65. package/lib/GeolocationFormatter/index.js +9 -16
  66. package/lib/HtmlLongTextFormatter/index.js +9 -17
  67. package/lib/HtmlLongTextFormatter/markdown2html.js +47 -0
  68. package/lib/HtmlLongTextFormatter/unified/index.js +400 -0
  69. package/lib/HtmlLongTextFormatter/vfile/core.js +155 -0
  70. package/lib/HtmlLongTextFormatter/vfile/index.js +40 -0
  71. package/lib/ImageFormatter/images-lazy-load.js +9 -16
  72. package/lib/ImageFormatter/index.js +16 -24
  73. package/lib/ImageFormatter/utils.js +2 -9
  74. package/lib/ImagePreviewerLightbox/index.js +12 -19
  75. package/lib/ImagePreviewerLightbox/utils.js +3 -11
  76. package/lib/LastModifierFormatter/index.js +12 -19
  77. package/lib/LinkEditor/index.js +25 -33
  78. package/lib/LinkEditor/link-editor-option.js +8 -15
  79. package/lib/LinkEditor/mb-link-editor-popover/index.js +23 -30
  80. package/lib/LinkEditor/pc-link-editor-popover/index.js +17 -24
  81. package/lib/LinkFormatter/index.js +13 -20
  82. package/lib/Loading/index.js +4 -11
  83. package/lib/LongTextFormatter/index.js +6 -13
  84. package/lib/MBEditorHeader/index.js +7 -14
  85. package/lib/MTimeFormatter/index.js +9 -16
  86. package/lib/ModalPortal/index.js +5 -12
  87. package/lib/MultipleSelectEditor/index.js +17 -25
  88. package/lib/MultipleSelectFormatter/index.js +10 -17
  89. package/lib/NotificationPopover/index.js +16 -24
  90. package/lib/NumberEditor/index.js +18 -25
  91. package/lib/NumberFormatter/index.js +9 -16
  92. package/lib/RateFormatter/index.js +8 -15
  93. package/lib/RoleStatusEditor/index.js +14 -22
  94. package/lib/RowExpandEmailFormatter/index.js +10 -17
  95. package/lib/RowExpandFileFormatter/index.js +8 -16
  96. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +18 -27
  97. package/lib/RowExpandFormatter/index.js +78 -86
  98. package/lib/RowExpandFormulaFormatter/index.js +34 -42
  99. package/lib/RowExpandImageFormatter/index.js +10 -19
  100. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +18 -27
  101. package/lib/RowExpandImageFormatter/utils.js +2 -9
  102. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +7 -16
  103. package/lib/RowExpandLinkFormatter/index.js +37 -46
  104. package/lib/RowExpandLinkFormatter/utils.js +6 -17
  105. package/lib/RowExpandLinkFormatter/value-display-utils.js +5 -12
  106. package/lib/RowExpandRateFormatter/index.js +8 -15
  107. package/lib/RowExpandUrlFormatter/index.js +14 -21
  108. package/lib/SelectItem/index.js +4 -12
  109. package/lib/SelectOptionGroup/KeyCodes.js +1 -7
  110. package/lib/SelectOptionGroup/index.js +33 -32
  111. package/lib/SelectOptionGroup/option.js +4 -19
  112. package/lib/SimpleLongTextFormatter/index.js +20 -27
  113. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +1 -7
  114. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +8 -15
  115. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +7 -14
  116. package/lib/SingleSelectEditor/index.js +18 -26
  117. package/lib/SingleSelectFormatter/index.js +9 -16
  118. package/lib/TextEditor/index.js +7 -14
  119. package/lib/TextFormatter/index.js +7 -14
  120. package/lib/UrlFormatter/index.js +7 -14
  121. package/lib/cellFormatterFactory/index.js +4 -11
  122. package/lib/common/ClickOutside.js +4 -12
  123. package/lib/common/delete-tip.js +12 -20
  124. package/lib/common/modal-portal.js +5 -13
  125. package/lib/constants/index.js +9 -28
  126. package/lib/data/dtable-value.js +6 -11
  127. package/lib/formatterConfig/base-formatter-config.js +46 -53
  128. package/lib/formatterConfig/index.js +9 -16
  129. package/lib/hooks/common-hooks.js +4 -11
  130. package/lib/index.js +75 -432
  131. package/lib/lang/index.js +13 -24
  132. package/lib/locals/de.js +1 -7
  133. package/lib/locals/en.js +1 -7
  134. package/lib/locals/fr.js +1 -7
  135. package/lib/locals/zh-CN.js +1 -7
  136. package/lib/select-editor/index.js +4 -27
  137. package/lib/select-editor/mb-select-editor-popover/index.js +33 -41
  138. package/lib/select-editor/pc-select-editor-popover/index.js +19 -26
  139. package/lib/select-editor/select-editor-option.js +8 -15
  140. package/lib/toaster/alert.js +11 -18
  141. package/lib/toaster/index.js +3 -10
  142. package/lib/toaster/toast.js +8 -16
  143. package/lib/toaster/toastManager.js +5 -13
  144. package/lib/toaster/toaster.js +7 -15
  145. package/lib/utils/dayjs.js +4 -11
  146. package/lib/utils/editor-utils.js +5 -15
  147. package/lib/utils/event-bus.js +1 -7
  148. package/lib/utils/utils.js +6 -17
  149. package/package.json +77 -63
@@ -1,21 +1,14 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var _CollaboratorItem = _interopRequireDefault(require("../CollaboratorItem"));
11
- var _default_avatar = _interopRequireDefault(require("../assets/images/avatar/default_avatar.png"));
12
- require("./index.css");
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import CollaboratorItem from '../CollaboratorItem';
4
+ import DefaultAvatar from '../assets/images/avatar/default_avatar.png';
5
+ import './index.css';
13
6
  // there will be there conditions
14
7
  // 1 value is not exist, typeof value is array, but it's length is 0
15
8
  // 2 value is exist, but can't find in collaborators
16
9
  // 3 value is exist, typeof value is a string
17
10
  // 4 value is exist, typeof value is array
18
- class CreatorFormatter extends _react.default.PureComponent {
11
+ class CreatorFormatter extends React.PureComponent {
19
12
  constructor() {
20
13
  super(...arguments);
21
14
  this.getCollaborators = () => {
@@ -32,10 +25,10 @@ class CreatorFormatter extends _react.default.PureComponent {
32
25
  if (!collaborator) {
33
26
  collaborator = {
34
27
  name: item,
35
- avatar_url: _default_avatar.default
28
+ avatar_url: DefaultAvatar
36
29
  };
37
30
  }
38
- return /*#__PURE__*/_react.default.createElement(_CollaboratorItem.default, {
31
+ return /*#__PURE__*/React.createElement(CollaboratorItem, {
39
32
  key: index,
40
33
  collaborator: collaborator
41
34
  });
@@ -47,14 +40,14 @@ class CreatorFormatter extends _react.default.PureComponent {
47
40
  containerClassName,
48
41
  value
49
42
  } = this.props;
50
- const classname = (0, _classnames.default)('dtable-ui cell-formatter-container creator-formatter', containerClassName);
43
+ const classname = classnames('dtable-ui cell-formatter-container creator-formatter', containerClassName);
51
44
  if (!value || Array.isArray(value) && value.length === 0) {
52
- return /*#__PURE__*/_react.default.createElement("div", {
45
+ return /*#__PURE__*/React.createElement("div", {
53
46
  className: classname
54
47
  });
55
48
  }
56
49
  const collaborators = this.getCollaborators();
57
- return /*#__PURE__*/_react.default.createElement("div", {
50
+ return /*#__PURE__*/React.createElement("div", {
58
51
  className: classname
59
52
  }, collaborators);
60
53
  }
@@ -62,4 +55,4 @@ class CreatorFormatter extends _react.default.PureComponent {
62
55
  CreatorFormatter.defaultProps = {
63
56
  value: ''
64
57
  };
65
- var _default = exports.default = CreatorFormatter;
58
+ export default CreatorFormatter;
@@ -1,12 +1,5 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- require("./index.css");
1
+ import React from 'react';
2
+ import './index.css';
10
3
  function DTableCommonAddTool(_ref) {
11
4
  let {
12
5
  callBack,
@@ -16,16 +9,16 @@ function DTableCommonAddTool(_ref) {
16
9
  hideIcon,
17
10
  style
18
11
  } = _ref;
19
- return /*#__PURE__*/_react.default.createElement("div", {
12
+ return /*#__PURE__*/React.createElement("div", {
20
13
  className: "dtable-ui add-item-btn ".concat(className ? className : ''),
21
14
  style: style,
22
15
  onClick: e => {
23
16
  callBack(e);
24
17
  }
25
- }, !hideIcon && /*#__PURE__*/_react.default.createElement("span", {
18
+ }, !hideIcon && /*#__PURE__*/React.createElement("span", {
26
19
  className: "dtable-font dtable-icon-add-table ".concat(addIconClassName || '')
27
- }), /*#__PURE__*/_react.default.createElement("span", {
20
+ }), /*#__PURE__*/React.createElement("span", {
28
21
  className: "text-truncate"
29
22
  }, footerName));
30
23
  }
31
- var _default = exports.default = DTableCommonAddTool;
24
+ export default DTableCommonAddTool;
@@ -1,18 +1,10 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _reactstrap = require("reactstrap");
12
- var _dtableUtils = require("dtable-utils");
13
- var _SelectOptionGroup = _interopRequireDefault(require("../SelectOptionGroup"));
14
- require("./index.css");
15
- class CollaboratorSelect extends _react.Component {
1
+ import React, { Component } from 'react';
2
+ import classnames from 'classnames';
3
+ import { Popover } from 'reactstrap';
4
+ import { searchCollaborators } from 'dtable-utils';
5
+ import SelectOptionGroup from '../SelectOptionGroup';
6
+ import './index.css';
7
+ class CollaboratorSelect extends Component {
16
8
  constructor(props) {
17
9
  super(props);
18
10
  this.onSelectToggle = event => {
@@ -51,7 +43,7 @@ class CollaboratorSelect extends _react.Component {
51
43
  searchable
52
44
  } = this.props;
53
45
  if (!searchable) return options || [];
54
- return (0, _dtableUtils.searchCollaborators)(options, searchValue);
46
+ return searchCollaborators(options, searchValue);
55
47
  };
56
48
  this.renderOptionGroup = () => {
57
49
  const {
@@ -65,7 +57,7 @@ class CollaboratorSelect extends _react.Component {
65
57
  isUsePopover
66
58
  } = this.props;
67
59
  if (!isUsePopover) {
68
- return /*#__PURE__*/_react.default.createElement(_SelectOptionGroup.default, {
60
+ return /*#__PURE__*/React.createElement(SelectOptionGroup, {
69
61
  value: value,
70
62
  top: top,
71
63
  left: left,
@@ -83,14 +75,14 @@ class CollaboratorSelect extends _react.Component {
83
75
  isShowSelected: true
84
76
  });
85
77
  }
86
- return /*#__PURE__*/_react.default.createElement(_reactstrap.Popover, {
78
+ return /*#__PURE__*/React.createElement(Popover, {
87
79
  placement: "bottom",
88
80
  isOpen: true,
89
81
  target: this.id,
90
82
  fade: false,
91
83
  hideArrow: true,
92
84
  className: "dtable-customize-collaborator-select dtable-select"
93
- }, /*#__PURE__*/_react.default.createElement(_SelectOptionGroup.default, {
85
+ }, /*#__PURE__*/React.createElement(SelectOptionGroup, {
94
86
  value: value,
95
87
  top: top,
96
88
  left: left,
@@ -127,23 +119,23 @@ class CollaboratorSelect extends _react.Component {
127
119
  placeholder,
128
120
  isLocked
129
121
  } = this.props;
130
- return /*#__PURE__*/_react.default.createElement("button", {
122
+ return /*#__PURE__*/React.createElement("button", {
131
123
  ref: node => this.selector = node,
132
- className: (0, _classnames.default)('dtable-select custom-select collaborator-select', {
124
+ className: classnames('dtable-select custom-select collaborator-select', {
133
125
  'focus': this.state.isShowSelectOptions
134
126
  }, {
135
127
  'disabled': isLocked
136
128
  }, className),
137
129
  id: this.id,
138
130
  onClick: this.onSelectToggle
139
- }, /*#__PURE__*/_react.default.createElement("div", {
131
+ }, /*#__PURE__*/React.createElement("div", {
140
132
  className: "selected-option",
141
133
  ref: node => this.selectedOptionRef = node
142
- }, value.label ? /*#__PURE__*/_react.default.createElement("span", {
134
+ }, value.label ? /*#__PURE__*/React.createElement("span", {
143
135
  className: "selected-option-show"
144
- }, value.label) : /*#__PURE__*/_react.default.createElement("span", {
136
+ }, value.label) : /*#__PURE__*/React.createElement("span", {
145
137
  className: "select-placeholder"
146
- }, placeholder), !isLocked && /*#__PURE__*/_react.default.createElement("i", {
138
+ }, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
147
139
  className: "dtable-font dtable-icon-drop-down"
148
140
  })), this.state.isShowSelectOptions && this.renderOptionGroup());
149
141
  }
@@ -152,4 +144,4 @@ CollaboratorSelect.defaultProps = {
152
144
  top: -3,
153
145
  left: -3
154
146
  };
155
- var _default = exports.default = CollaboratorSelect;
147
+ export default CollaboratorSelect;
@@ -1,17 +1,9 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _SelectOptionGroup = _interopRequireDefault(require("../SelectOptionGroup"));
11
- var _classnames = _interopRequireDefault(require("classnames"));
12
- var _modalPortal = _interopRequireDefault(require("../common/modal-portal"));
13
- require("./index.css");
14
- class DTableCustomizeSelect extends _react.Component {
1
+ import React, { Component } from 'react';
2
+ import SelectOptionGroup from '../SelectOptionGroup';
3
+ import classnames from 'classnames';
4
+ import ModalPortal from '../common/modal-portal';
5
+ import './index.css';
6
+ class DTableCustomizeSelect extends Component {
15
7
  constructor(props) {
16
8
  super(props);
17
9
  this.onSelectToggle = event => {
@@ -93,23 +85,23 @@ class DTableCustomizeSelect extends _react.Component {
93
85
  isLocked,
94
86
  isInModal
95
87
  } = this.props;
96
- return /*#__PURE__*/_react.default.createElement("div", {
88
+ return /*#__PURE__*/React.createElement("div", {
97
89
  ref: node => this.selector = node,
98
- className: (0, _classnames.default)('dtable-select custom-select', {
90
+ className: classnames('dtable-select custom-select', {
99
91
  'focus': this.state.isShowSelectOptions
100
92
  }, {
101
93
  'disabled': isLocked
102
94
  }, className),
103
95
  onClick: this.onSelectToggle
104
- }, /*#__PURE__*/_react.default.createElement("div", {
96
+ }, /*#__PURE__*/React.createElement("div", {
105
97
  className: "selected-option"
106
- }, value && value.label ? /*#__PURE__*/_react.default.createElement("span", {
98
+ }, value && value.label ? /*#__PURE__*/React.createElement("span", {
107
99
  className: "selected-option-show"
108
- }, value.label) : /*#__PURE__*/_react.default.createElement("span", {
100
+ }, value.label) : /*#__PURE__*/React.createElement("span", {
109
101
  className: "select-placeholder"
110
- }, placeholder), !isLocked && /*#__PURE__*/_react.default.createElement("i", {
102
+ }, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
111
103
  className: "dtable-font dtable-icon-drop-down"
112
- })), this.state.isShowSelectOptions && !isInModal && /*#__PURE__*/_react.default.createElement(_SelectOptionGroup.default, {
104
+ })), this.state.isShowSelectOptions && !isInModal && /*#__PURE__*/React.createElement(SelectOptionGroup, {
113
105
  value: value,
114
106
  isShowSelected: this.props.isShowSelected,
115
107
  top: this.getSelectedOptionTop(),
@@ -122,7 +114,7 @@ class DTableCustomizeSelect extends _react.Component {
122
114
  closeSelect: this.closeSelect,
123
115
  getFilterOptions: this.getFilterOptions,
124
116
  supportMultipleSelect: this.props.supportMultipleSelect
125
- }), this.state.isShowSelectOptions && isInModal && /*#__PURE__*/_react.default.createElement(_modalPortal.default, null, /*#__PURE__*/_react.default.createElement(_SelectOptionGroup.default, {
117
+ }), this.state.isShowSelectOptions && isInModal && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(SelectOptionGroup, {
126
118
  className: className,
127
119
  value: value,
128
120
  isShowSelected: this.props.isShowSelected,
@@ -141,4 +133,4 @@ class DTableCustomizeSelect extends _react.Component {
141
133
  })));
142
134
  }
143
135
  }
144
- var _default = exports.default = DTableCustomizeSelect;
136
+ export default DTableCustomizeSelect;
@@ -1,51 +1,45 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.STRING_PREDICATE = exports.SPECIAL_TERM_TYPE = exports.SIMPLE_TEXT_INPUT_COLUMNS_MAP = exports.MULTIPLE_SELECTOR_COLUMNS = exports.FORMULA_COLUMN_TYPES = exports.FILTER_TERM_MODIFIER_SHOW = exports.DATE_LABEL_MAP = exports.DATE_EMPTY_LABEL_MAP = exports.ARRAY_PREDICATE = void 0;
7
- var _dtableUtils = require("dtable-utils");
8
- const FORMULA_COLUMN_TYPES = exports.FORMULA_COLUMN_TYPES = [_dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA];
9
- const SPECIAL_TERM_TYPE = exports.SPECIAL_TERM_TYPE = {
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 = {
10
4
  CREATOR: 'creator',
11
5
  SINGLE_SELECT: 'single_select',
12
6
  MULTIPLE_SELECT: 'multiple_select',
13
7
  COLLABORATOR: 'collaborator',
14
8
  RATE: 'rate'
15
9
  };
16
- const SIMPLE_TEXT_INPUT_COLUMNS_MAP = exports.SIMPLE_TEXT_INPUT_COLUMNS_MAP = {
17
- [_dtableUtils.CellType.TEXT]: true,
18
- [_dtableUtils.CellType.LONG_TEXT]: true,
19
- [_dtableUtils.CellType.GEOLOCATION]: true,
20
- [_dtableUtils.CellType.AUTO_NUMBER]: true,
21
- [_dtableUtils.CellType.EMAIL]: true,
22
- [_dtableUtils.CellType.URL]: true,
23
- [_dtableUtils.CellType.IMAGE]: true,
24
- [_dtableUtils.CellType.FILE]: true,
25
- [_dtableUtils.FORMULA_RESULT_TYPE.STRING]: true,
26
- [_dtableUtils.FORMULA_RESULT_TYPE.BOOL]: true
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
27
21
  };
28
- const DATE_LABEL_MAP = exports.DATE_LABEL_MAP = {
29
- [_dtableUtils.FILTER_TERM_MODIFIER_TYPE.EXACT_DATE]: true,
30
- [_dtableUtils.FILTER_TERM_MODIFIER_TYPE.NUMBER_OF_DAYS_AGO]: true,
31
- [_dtableUtils.FILTER_TERM_MODIFIER_TYPE.NUMBER_OF_DAYS_FROM_NOW]: true,
32
- [_dtableUtils.FILTER_TERM_MODIFIER_TYPE.THE_NEXT_NUMBERS_OF_DAYS]: true,
33
- [_dtableUtils.FILTER_TERM_MODIFIER_TYPE.THE_PAST_NUMBERS_OF_DAYS]: true
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
34
28
  };
35
- const ARRAY_PREDICATE = exports.ARRAY_PREDICATE = {
36
- [_dtableUtils.FILTER_PREDICATE_TYPE.IS_ANY_OF]: true,
37
- [_dtableUtils.FILTER_PREDICATE_TYPE.IS_NONE_OF]: true
29
+ const ARRAY_PREDICATE = {
30
+ [FILTER_PREDICATE_TYPE.IS_ANY_OF]: true,
31
+ [FILTER_PREDICATE_TYPE.IS_NONE_OF]: true
38
32
  };
39
- const STRING_PREDICATE = exports.STRING_PREDICATE = {
40
- [_dtableUtils.FILTER_PREDICATE_TYPE.IS]: true,
41
- [_dtableUtils.FILTER_PREDICATE_TYPE.IS_NOT]: true
33
+ const STRING_PREDICATE = {
34
+ [FILTER_PREDICATE_TYPE.IS]: true,
35
+ [FILTER_PREDICATE_TYPE.IS_NOT]: true
42
36
  };
43
- const DATE_EMPTY_LABEL_MAP = exports.DATE_EMPTY_LABEL_MAP = {
44
- [_dtableUtils.FILTER_PREDICATE_TYPE.EMPTY]: true,
45
- [_dtableUtils.FILTER_PREDICATE_TYPE.NOT_EMPTY]: true
37
+ const DATE_EMPTY_LABEL_MAP = {
38
+ [FILTER_PREDICATE_TYPE.EMPTY]: true,
39
+ [FILTER_PREDICATE_TYPE.NOT_EMPTY]: true
46
40
  };
47
- const MULTIPLE_SELECTOR_COLUMNS = exports.MULTIPLE_SELECTOR_COLUMNS = [_dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.COLLABORATOR, _dtableUtils.CellType.CREATOR, _dtableUtils.CellType.LAST_MODIFIER];
48
- const FILTER_TERM_MODIFIER_SHOW = exports.FILTER_TERM_MODIFIER_SHOW = {
41
+ const MULTIPLE_SELECTOR_COLUMNS = [CellType.MULTIPLE_SELECT, CellType.COLLABORATOR, CellType.CREATOR, CellType.LAST_MODIFIER];
42
+ const FILTER_TERM_MODIFIER_SHOW = {
49
43
  'today': 'Today',
50
44
  'tomorrow': 'Tomorrow',
51
45
  'yesterday': 'Yesterday',
@@ -67,4 +61,5 @@ const FILTER_TERM_MODIFIER_SHOW = exports.FILTER_TERM_MODIFIER_SHOW = {
67
61
  'this_week': 'This_week',
68
62
  'this_month': 'This_month',
69
63
  'this_year': 'This_year'
70
- };
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 };
@@ -1,23 +1,16 @@
1
- "use strict";
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';
2
13
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _isHotkey = _interopRequireDefault(require("is-hotkey"));
11
- var _reactstrap = require("reactstrap");
12
- var _dtableUtils = require("dtable-utils");
13
- var _DTableCommonAddTool = _interopRequireDefault(require("../DTableCommonAddTool"));
14
- var _utils = require("../utils/utils");
15
- var _utils2 = require("./utils");
16
- var _filterList = _interopRequireDefault(require("./widgets/filter-list"));
17
- var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
18
- var _constants = require("../constants");
19
- var _lang = require("../lang");
20
- require("./index.css");
21
14
  /**
22
15
  * filter = {
23
16
  * column_key: '',
@@ -26,11 +19,11 @@ require("./index.css");
26
19
  * filter_term_modifier: '',
27
20
  * }
28
21
  */
29
- class DTableFiltersPopover extends _react.Component {
22
+ class DTableFiltersPopover extends Component {
30
23
  constructor(props) {
31
24
  super(props);
32
25
  this.onHotKey = e => {
33
- if ((0, _isHotkey.default)('esc', e) && !this.isSelectOpen) {
26
+ if (isHotkey('esc', e) && !this.isSelectOpen) {
34
27
  e.preventDefault();
35
28
  this.props.hidePopover();
36
29
  }
@@ -39,7 +32,7 @@ class DTableFiltersPopover extends _react.Component {
39
32
  this.isSelectOpen = status;
40
33
  };
41
34
  this.hideDTablePopover = e => {
42
- if (this.dtablePopoverRef && !(0, _utils.getEventClassName)(e).includes('popover') && !this.dtablePopoverRef.contains(e.target)) {
35
+ if (this.dtablePopoverRef && !getEventClassName(e).includes('popover') && !this.dtablePopoverRef.contains(e.target)) {
43
36
  this.props.hidePopover(e);
44
37
  e.preventDefault();
45
38
  e.stopPropagation();
@@ -105,11 +98,11 @@ class DTableFiltersPopover extends _react.Component {
105
98
  columns
106
99
  } = this.props;
107
100
  let defaultColumn = columns[0];
108
- if (!_dtableUtils.FILTER_COLUMN_OPTIONS[defaultColumn.type]) {
109
- defaultColumn = columns.find(c => _dtableUtils.FILTER_COLUMN_OPTIONS[c.type]);
101
+ if (!FILTER_COLUMN_OPTIONS[defaultColumn.type]) {
102
+ defaultColumn = columns.find(c => FILTER_COLUMN_OPTIONS[c.type]);
110
103
  }
111
104
  if (!defaultColumn) return;
112
- let filter = (0, _utils2.getFilterByColumn)(defaultColumn);
105
+ let filter = getFilterByColumn(defaultColumn);
113
106
  const filters = this.state.filters.slice(0);
114
107
  if (filters.length === 0) {
115
108
  scheduleUpdate();
@@ -136,7 +129,7 @@ class DTableFiltersPopover extends _react.Component {
136
129
  e.stopPropagation();
137
130
  };
138
131
  this.state = {
139
- filters: (0, _dtableUtils.getValidFilters)(props.filters, props.columns),
132
+ filters: getValidFilters(props.filters, props.columns),
140
133
  filterConjunction: props.filterConjunction || 'And'
141
134
  };
142
135
  this.isSelectOpen = false;
@@ -144,7 +137,7 @@ class DTableFiltersPopover extends _react.Component {
144
137
  componentDidMount() {
145
138
  document.addEventListener('mousedown', this.hideDTablePopover, true);
146
139
  document.addEventListener('keydown', this.onHotKey);
147
- this.unsubscribeOpenSelect = _eventBus.default.subscribe(_constants.EVENT_BUS_TYPE.OPEN_SELECT, this.setSelectStatus);
140
+ this.unsubscribeOpenSelect = eventBus.subscribe(EVENT_BUS_TYPE.OPEN_SELECT, this.setSelectStatus);
148
141
  }
149
142
  componentWillUnmount() {
150
143
  document.removeEventListener('mousedown', this.hideDTablePopover, true);
@@ -167,7 +160,7 @@ class DTableFiltersPopover extends _react.Component {
167
160
  filterConjunction
168
161
  } = this.state;
169
162
  const canAddFilter = columns.length > 0;
170
- return /*#__PURE__*/_react.default.createElement(_reactstrap.UncontrolledPopover, {
163
+ return /*#__PURE__*/React.createElement(UncontrolledPopover, {
171
164
  placement: "auto-start",
172
165
  isOpen: true,
173
166
  target: target,
@@ -179,16 +172,16 @@ class DTableFiltersPopover extends _react.Component {
179
172
  let {
180
173
  scheduleUpdate
181
174
  } = _ref;
182
- return /*#__PURE__*/_react.default.createElement("div", {
175
+ return /*#__PURE__*/React.createElement("div", {
183
176
  ref: ref => this.dtablePopoverRef = ref,
184
177
  onClick: this.onPopoverInsideClick,
185
178
  className: className
186
- }, /*#__PURE__*/_react.default.createElement(_filterList.default, {
179
+ }, /*#__PURE__*/React.createElement(FiltersList, {
187
180
  filterConjunction: filterConjunction,
188
181
  filters: filters,
189
182
  roleId: roleId,
190
183
  columns: columns,
191
- emptyPlaceholder: (0, _lang.getLocale)('No_filters'),
184
+ emptyPlaceholder: getLocale('No_filters'),
192
185
  collaborators: this.props.collaborators,
193
186
  readOnly: readOnly,
194
187
  scheduleUpdate: scheduleUpdate,
@@ -198,21 +191,21 @@ class DTableFiltersPopover extends _react.Component {
198
191
  updateFilter: this.updateFilter,
199
192
  deleteFilter: this.deleteFilter,
200
193
  updateFilterConjunction: this.updateFilterConjunction
201
- }), /*#__PURE__*/_react.default.createElement(_DTableCommonAddTool.default, {
194
+ }), /*#__PURE__*/React.createElement(CommonAddTool, {
202
195
  className: "popover-add-tool ".concat(canAddFilter ? '' : 'disabled'),
203
196
  callBack: canAddFilter ? () => this.addFilter(scheduleUpdate) : () => {},
204
- footerName: (0, _lang.getLocale)('Add_filter'),
197
+ footerName: getLocale('Add_filter'),
205
198
  addIconClassName: "popover-add-icon"
206
- }), this.isNeedSubmit() && /*#__PURE__*/_react.default.createElement("div", {
199
+ }), this.isNeedSubmit() && /*#__PURE__*/React.createElement("div", {
207
200
  className: "dtable-filter-popover-footer"
208
- }, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
201
+ }, /*#__PURE__*/React.createElement(Button, {
209
202
  className: "mr-2",
210
203
  onClick: this.onClosePopover
211
- }, (0, _lang.getLocale)('Cancel')), /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
204
+ }, getLocale('Cancel')), /*#__PURE__*/React.createElement(Button, {
212
205
  color: "primary",
213
206
  disabled: this.state.isSubmitDisabled,
214
207
  onClick: this.onSubmitFilters
215
- }, (0, _lang.getLocale)('Submit'))));
208
+ }, getLocale('Submit'))));
216
209
  });
217
210
  }
218
211
  }
@@ -220,4 +213,4 @@ DTableFiltersPopover.defaultProps = {
220
213
  className: '',
221
214
  readOnly: false
222
215
  };
223
- var _default = exports.default = DTableFiltersPopover;
216
+ export default DTableFiltersPopover;