dtable-ui-component 4.3.7 → 4.3.8

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 (120) hide show
  1. package/lib/AutoNumberFormatter/index.js +11 -24
  2. package/lib/ButtonFormatter/index.js +29 -45
  3. package/lib/CTimeFormatter/index.js +17 -32
  4. package/lib/CheckboxEditor/index.js +42 -49
  5. package/lib/CheckboxFormatter/index.js +17 -30
  6. package/lib/CollaboratorEditor/index.js +118 -135
  7. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
  8. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
  9. package/lib/CollaboratorFormatter/index.js +26 -42
  10. package/lib/CollaboratorItem/index.js +31 -44
  11. package/lib/CreatorFormatter/index.js +24 -40
  12. package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
  13. package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
  14. package/lib/DTableCustomizeSelect/index.js +92 -103
  15. package/lib/DTablePopover/index.js +52 -71
  16. package/lib/DTablePopover/utils.js +1 -1
  17. package/lib/DTableRadio/index.js +9 -7
  18. package/lib/DTableSearchInput/index.js +89 -99
  19. package/lib/DTableSearchInput/utils.js +2 -2
  20. package/lib/DTableSelect/dtable-select-label.js +5 -3
  21. package/lib/DTableSelect/index.js +50 -64
  22. package/lib/DTableSelect/utils.js +36 -41
  23. package/lib/DTableSwitch/index.js +7 -5
  24. package/lib/DateEditor/index.js +88 -94
  25. package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
  26. package/lib/DateEditor/pc-date-editor-popover.js +70 -77
  27. package/lib/DateFormatter/index.js +15 -28
  28. package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
  29. package/lib/DigitalSignFormatter/index.js +55 -65
  30. package/lib/DigitalSignFormatter/utils.js +9 -8
  31. package/lib/DurationFormatter/index.js +14 -27
  32. package/lib/EditEditorButton/index.js +10 -22
  33. package/lib/EmailFormatter/index.js +11 -24
  34. package/lib/FieldDisplaySetting/field-item.js +18 -20
  35. package/lib/FieldDisplaySetting/index.js +41 -43
  36. package/lib/FileEditor/index.js +18 -29
  37. package/lib/FileFormatter/index.js +29 -43
  38. package/lib/FileItemFormatter/index.js +17 -32
  39. package/lib/FileItemFormatter/utils.js +5 -5
  40. package/lib/FileUploader/index.js +20 -33
  41. package/lib/FormulaFormatter/cell-value-validator.js +23 -8
  42. package/lib/FormulaFormatter/index.js +77 -83
  43. package/lib/FormulaFormatter/utils.js +27 -21
  44. package/lib/GeolocationFormatter/index.js +19 -32
  45. package/lib/HtmlLongTextFormatter/index.js +43 -52
  46. package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
  47. package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
  48. package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
  49. package/lib/ImageFormatter/images-lazy-load.js +71 -79
  50. package/lib/ImageFormatter/index.js +86 -97
  51. package/lib/ImageFormatter/utils.js +1 -1
  52. package/lib/ImagePreviewerLightbox/index.js +20 -18
  53. package/lib/ImagePreviewerLightbox/utils.js +3 -3
  54. package/lib/LastModifierFormatter/index.js +24 -40
  55. package/lib/LinkEditor/index.js +163 -167
  56. package/lib/LinkEditor/link-editor-option.js +41 -56
  57. package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
  58. package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
  59. package/lib/LinkFormatter/index.js +75 -77
  60. package/lib/LongTextFormatter/index.js +5 -3
  61. package/lib/MBEditorHeader/index.js +25 -38
  62. package/lib/MTimeFormatter/index.js +17 -32
  63. package/lib/ModalPortal/index.js +15 -32
  64. package/lib/MultipleSelectEditor/index.js +118 -136
  65. package/lib/MultipleSelectFormatter/index.js +24 -40
  66. package/lib/NotificationPopover/index.js +68 -95
  67. package/lib/NumberEditor/index.js +75 -82
  68. package/lib/NumberFormatter/index.js +15 -28
  69. package/lib/RateFormatter/index.js +29 -45
  70. package/lib/RoleStatusEditor/index.js +20 -22
  71. package/lib/RowExpandEmailFormatter/index.js +24 -37
  72. package/lib/RowExpandFileFormatter/index.js +28 -42
  73. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
  74. package/lib/RowExpandFormatter/index.js +92 -96
  75. package/lib/RowExpandFormulaFormatter/index.js +85 -91
  76. package/lib/RowExpandImageFormatter/index.js +65 -82
  77. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
  78. package/lib/RowExpandImageFormatter/utils.js +1 -1
  79. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
  80. package/lib/RowExpandLinkFormatter/index.js +131 -137
  81. package/lib/RowExpandLinkFormatter/utils.js +23 -17
  82. package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
  83. package/lib/RowExpandRateFormatter/index.js +27 -42
  84. package/lib/RowExpandUrlFormatter/index.js +27 -40
  85. package/lib/SelectItem/index.js +17 -33
  86. package/lib/SelectOptionGroup/index.js +141 -159
  87. package/lib/SelectOptionGroup/option.js +24 -40
  88. package/lib/SimpleLongTextFormatter/index.js +55 -67
  89. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
  90. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
  91. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
  92. package/lib/SingleSelectEditor/index.js +108 -119
  93. package/lib/SingleSelectFormatter/index.js +21 -37
  94. package/lib/TextEditor/index.js +45 -51
  95. package/lib/TextFormatter/index.js +17 -32
  96. package/lib/UrlFormatter/index.js +11 -24
  97. package/lib/cellFormatterFactory/index.js +8 -17
  98. package/lib/common/ClickOutside.js +22 -43
  99. package/lib/common/delete-tip.js +40 -65
  100. package/lib/common/modal-portal.js +15 -33
  101. package/lib/constants/index.js +5 -5
  102. package/lib/data/dtable-value.js +4 -4
  103. package/lib/formatterConfig/base-formatter-config.js +24 -3
  104. package/lib/formatterConfig/index.js +5 -4
  105. package/lib/lang/index.js +6 -6
  106. package/lib/locals/de.js +1 -1
  107. package/lib/locals/en.js +1 -1
  108. package/lib/locals/fr.js +1 -1
  109. package/lib/locals/zh-CN.js +1 -1
  110. package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
  111. package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
  112. package/lib/select-editor/select-editor-option.js +41 -56
  113. package/lib/toaster/alert.js +73 -88
  114. package/lib/toaster/index.js +1 -1
  115. package/lib/toaster/toast.js +75 -102
  116. package/lib/toaster/toastManager.js +55 -91
  117. package/lib/toaster/toaster.js +58 -57
  118. package/lib/utils/editor-utils.js +17 -19
  119. package/lib/utils/utils.js +14 -14
  120. package/package.json +4 -4
@@ -1,74 +1,70 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
1
  import React from 'react';
7
2
  import { getLocale } from '../../lang';
8
3
  import MBEditorHeader from '../../MBEditorHeader';
9
4
  import './index.css';
10
- var MBLinkEditorPopover = /*#__PURE__*/function (_React$Component) {
11
- _inherits(MBLinkEditorPopover, _React$Component);
12
- var _super = _createSuper(MBLinkEditorPopover);
13
- function MBLinkEditorPopover(props) {
14
- var _this;
15
- _classCallCheck(this, MBLinkEditorPopover);
16
- _this = _super.call(this, props);
17
- _this.handleHistaryBack = function (e) {
5
+ class MBLinkEditorPopover extends React.Component {
6
+ constructor(props) {
7
+ super(props);
8
+ this.handleHistaryBack = e => {
18
9
  e.preventDefault();
19
- _this.props.onClosePopover();
10
+ this.props.onClosePopover();
20
11
  };
21
- _this.onContainerClick = function (event) {
22
- if (_this.editorPopover && _this.editorPopover.contains(event.target)) {
12
+ this.onContainerClick = event => {
13
+ if (this.editorPopover && this.editorPopover.contains(event.target)) {
23
14
  event.stopPropagation();
24
15
  event.nativeEvent.stopImmediatePropagation();
25
16
  return false;
26
17
  }
27
18
  };
28
- _this.onChangeSearch = function (event) {
29
- var searchVal = _this.state.searchVal;
19
+ this.onChangeSearch = event => {
20
+ let {
21
+ searchVal
22
+ } = this.state;
30
23
  if (searchVal === event.target.value) {
31
24
  return;
32
25
  }
33
26
  searchVal = event.target.value;
34
- _this.setState({
35
- searchVal: searchVal
27
+ this.setState({
28
+ searchVal
36
29
  });
37
30
  };
38
- _this.getSelectedOptions = function () {
39
- var _this$props = _this.props,
40
- value = _this$props.value,
41
- options = _this$props.options;
31
+ this.getSelectedOptions = () => {
32
+ let {
33
+ value,
34
+ options
35
+ } = this.props;
42
36
  if (!Array.isArray(value)) {
43
37
  return [];
44
38
  }
45
- return options.filter(function (option) {
39
+ return options.filter(option => {
46
40
  return value.indexOf(option.email) > -1;
47
41
  });
48
42
  };
49
- _this.getFilterOptions = function () {
50
- var options = _this.props.options;
51
- var searchVal = _this.state.searchVal;
52
- return searchVal ? options.filter(function (item) {
53
- return item.name.indexOf(searchVal) > -1;
54
- }) : options;
43
+ this.getFilterOptions = () => {
44
+ let {
45
+ options
46
+ } = this.props;
47
+ let {
48
+ searchVal
49
+ } = this.state;
50
+ return searchVal ? options.filter(item => item.name.indexOf(searchVal) > -1) : options;
55
51
  };
56
- _this.onSelectOption = function (option) {
57
- _this.props.onOptionItemToggle(option);
52
+ this.onSelectOption = option => {
53
+ this.props.onOptionItemToggle(option);
58
54
  };
59
- _this.onRemoveOption = function (option) {
60
- _this.props.onOptionItemToggle(option);
55
+ this.onRemoveOption = option => {
56
+ this.props.onOptionItemToggle(option);
61
57
  };
62
- _this.renderFilteredOptions = function (options) {
63
- var value = _this.props.value;
64
- return options.map(function (option, index) {
65
- var isSelect = value.some(function (item) {
66
- return item === option.id;
67
- });
58
+ this.renderFilteredOptions = options => {
59
+ let {
60
+ value
61
+ } = this.props;
62
+ return options.map((option, index) => {
63
+ let isSelect = value.some(item => item === option.id);
68
64
  return /*#__PURE__*/React.createElement("div", {
69
65
  className: "mb-link-option-item",
70
66
  key: index,
71
- onMouseDown: _this.onSelectOption.bind(_assertThisInitialized(_this), option)
67
+ onMouseDown: this.onSelectOption.bind(this, option)
72
68
  }, /*#__PURE__*/React.createElement("span", {
73
69
  className: "mb-option-info"
74
70
  }, /*#__PURE__*/React.createElement("span", {
@@ -79,67 +75,62 @@ var MBLinkEditorPopover = /*#__PURE__*/function (_React$Component) {
79
75
  }));
80
76
  });
81
77
  };
82
- _this.setEditorPopover = function (editorPopover) {
83
- _this.editorPopover = editorPopover;
78
+ this.setEditorPopover = editorPopover => {
79
+ this.editorPopover = editorPopover;
84
80
  };
85
- _this.state = {
81
+ this.state = {
86
82
  searchVal: ''
87
83
  };
88
- return _this;
89
84
  }
90
- _createClass(MBLinkEditorPopover, [{
91
- key: "componentDidMount",
92
- value: function componentDidMount() {
93
- history.pushState(null, null, '#'); // eslint-disable-line
94
- window.addEventListener('popstate', this.handleHistaryBack, false);
95
- }
96
- }, {
97
- key: "componentWillUnmount",
98
- value: function componentWillUnmount() {
99
- window.removeEventListener('popstate', this.handleHistaryBack, false);
100
- }
101
- }, {
102
- key: "render",
103
- value: function render() {
104
- var column = this.props.column;
105
- var searchVal = this.state.searchVal;
106
- var filterOptions = this.getFilterOptions();
107
- return /*#__PURE__*/React.createElement("div", {
108
- ref: this.setEditorPopover,
109
- className: "dtable-ui-mb-editor-popover mb-link-editor-popover",
110
- onClick: this.onContainerClick
111
- }, /*#__PURE__*/React.createElement(MBEditorHeader, {
112
- title: column.name,
113
- leftContent: /*#__PURE__*/React.createElement("i", {
114
- className: "dtable-font dtable-icon-return"
115
- }),
116
- rightContent: /*#__PURE__*/React.createElement("span", null, getLocale('Done')),
117
- onLeftClick: this.props.onClosePopover,
118
- onRightClick: this.props.onClosePopover
119
- }), /*#__PURE__*/React.createElement("div", {
120
- className: "dtable-ui-mb-editor-body dtable-ui-mb-link-editor-body"
121
- }, /*#__PURE__*/React.createElement("div", {
122
- className: "mb-search-link-items"
123
- }, /*#__PURE__*/React.createElement("input", {
124
- className: "form-control",
125
- type: "text",
126
- placeholder: getLocale('Find_an_option'),
127
- value: searchVal,
128
- onChange: this.onChangeSearch,
129
- onClick: this.onInputClick
130
- })), /*#__PURE__*/React.createElement("div", {
131
- className: "mb-link-container"
132
- }, /*#__PURE__*/React.createElement("div", {
133
- className: "title"
134
- }, getLocale('Choose_an_option')), /*#__PURE__*/React.createElement("div", {
135
- className: "content"
136
- }, filterOptions.length === 0 && /*#__PURE__*/React.createElement("div", {
137
- className: "search-result-none"
138
- }, getLocale('No_options_available')), filterOptions.length > 0 && this.renderFilteredOptions(filterOptions)))));
139
- }
140
- }]);
141
- return MBLinkEditorPopover;
142
- }(React.Component);
85
+ componentDidMount() {
86
+ history.pushState(null, null, '#'); // eslint-disable-line
87
+ window.addEventListener('popstate', this.handleHistaryBack, false);
88
+ }
89
+ componentWillUnmount() {
90
+ window.removeEventListener('popstate', this.handleHistaryBack, false);
91
+ }
92
+ render() {
93
+ const {
94
+ column
95
+ } = this.props;
96
+ const {
97
+ searchVal
98
+ } = this.state;
99
+ let filterOptions = this.getFilterOptions();
100
+ return /*#__PURE__*/React.createElement("div", {
101
+ ref: this.setEditorPopover,
102
+ className: "dtable-ui-mb-editor-popover mb-link-editor-popover",
103
+ onClick: this.onContainerClick
104
+ }, /*#__PURE__*/React.createElement(MBEditorHeader, {
105
+ title: column.name,
106
+ leftContent: /*#__PURE__*/React.createElement("i", {
107
+ className: "dtable-font dtable-icon-return"
108
+ }),
109
+ rightContent: /*#__PURE__*/React.createElement("span", null, getLocale('Done')),
110
+ onLeftClick: this.props.onClosePopover,
111
+ onRightClick: this.props.onClosePopover
112
+ }), /*#__PURE__*/React.createElement("div", {
113
+ className: "dtable-ui-mb-editor-body dtable-ui-mb-link-editor-body"
114
+ }, /*#__PURE__*/React.createElement("div", {
115
+ className: "mb-search-link-items"
116
+ }, /*#__PURE__*/React.createElement("input", {
117
+ className: "form-control",
118
+ type: "text",
119
+ placeholder: getLocale('Find_an_option'),
120
+ value: searchVal,
121
+ onChange: this.onChangeSearch,
122
+ onClick: this.onInputClick
123
+ })), /*#__PURE__*/React.createElement("div", {
124
+ className: "mb-link-container"
125
+ }, /*#__PURE__*/React.createElement("div", {
126
+ className: "title"
127
+ }, getLocale('Choose_an_option')), /*#__PURE__*/React.createElement("div", {
128
+ className: "content"
129
+ }, filterOptions.length === 0 && /*#__PURE__*/React.createElement("div", {
130
+ className: "search-result-none"
131
+ }, getLocale('No_options_available')), filterOptions.length > 0 && this.renderFilteredOptions(filterOptions)))));
132
+ }
133
+ }
143
134
  MBLinkEditorPopover.defaultProps = {
144
135
  isReadOnly: false,
145
136
  value: []
@@ -1,96 +1,88 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
1
  import React from 'react';
7
2
  import { getLocale } from '../../lang';
8
3
  import './index.css';
9
- var PCLinkEditorPopover = /*#__PURE__*/function (_React$Component) {
10
- _inherits(PCLinkEditorPopover, _React$Component);
11
- var _super = _createSuper(PCLinkEditorPopover);
12
- function PCLinkEditorPopover(props) {
13
- var _this;
14
- _classCallCheck(this, PCLinkEditorPopover);
15
- _this = _super.call(this, props);
16
- _this.onValueChanged = function (event) {
17
- var value = event.target.value;
18
- _this.setState({
4
+ class PCLinkEditorPopover extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.onValueChanged = event => {
8
+ let value = event.target.value;
9
+ this.setState({
19
10
  searchValue: value
20
11
  });
21
12
  };
22
- _this.onInputClick = function (event) {
13
+ this.onInputClick = event => {
23
14
  event.nativeEvent.stopImmediatePropagation();
24
15
  event.stopPropagation();
25
16
  };
26
- _this.onOptionItemToggle = function (item) {
27
- _this.props.onOptionItemToggle(item);
17
+ this.onOptionItemToggle = item => {
18
+ this.props.onOptionItemToggle(item);
28
19
  };
29
- _this.getFilterOptions = function () {
30
- var options = _this.props.options;
31
- var filter = _this.state.searchValue.toLowerCase();
20
+ this.getFilterOptions = () => {
21
+ let {
22
+ options
23
+ } = this.props;
24
+ let filter = this.state.searchValue.toLowerCase();
32
25
  if (!filter) {
33
26
  return options;
34
27
  }
35
- return options.filter(function (option) {
28
+ return options.filter(option => {
36
29
  return option.name.toString().toLowerCase().indexOf(filter) > -1;
37
30
  });
38
31
  };
39
- _this.state = {
32
+ this.state = {
40
33
  searchValue: ''
41
34
  };
42
- return _this;
43
35
  }
44
- _createClass(PCLinkEditorPopover, [{
45
- key: "render",
46
- value: function render() {
47
- var _this2 = this;
48
- var options = this.getFilterOptions();
49
- var _this$props = this.props,
50
- popoverPosition = _this$props.popoverPosition,
51
- selectedOptions = _this$props.selectedOptions;
52
- var searchValue = this.state.searchValue;
53
- var popoverStyle = Object.assign({}, _objectSpread({}, popoverPosition), {
54
- position: 'absolute'
36
+ render() {
37
+ let options = this.getFilterOptions();
38
+ let {
39
+ popoverPosition,
40
+ selectedOptions
41
+ } = this.props;
42
+ let {
43
+ searchValue
44
+ } = this.state;
45
+ let popoverStyle = Object.assign({}, {
46
+ ...popoverPosition
47
+ }, {
48
+ position: 'absolute'
49
+ });
50
+ return /*#__PURE__*/React.createElement("div", {
51
+ className: "dtable-ui-editor-popover dtable-ui-link-editor-popover",
52
+ style: popoverStyle
53
+ }, /*#__PURE__*/React.createElement("div", {
54
+ className: "link-options-search"
55
+ }, /*#__PURE__*/React.createElement("input", {
56
+ className: "form-control",
57
+ value: searchValue,
58
+ onChange: this.onValueChanged,
59
+ onClick: this.onInputClick,
60
+ placeholder: getLocale('Find_an_option')
61
+ })), /*#__PURE__*/React.createElement("div", {
62
+ className: "link-options-container"
63
+ }, options.length > 0 && options.map((option, index) => {
64
+ let isSelect = selectedOptions.some(selectedOption => {
65
+ return selectedOption.id === option.id;
55
66
  });
56
67
  return /*#__PURE__*/React.createElement("div", {
57
- className: "dtable-ui-editor-popover dtable-ui-link-editor-popover",
58
- style: popoverStyle
68
+ key: index,
69
+ className: "link-option-item",
70
+ onClick: this.onOptionItemToggle.bind(this, option)
59
71
  }, /*#__PURE__*/React.createElement("div", {
60
- className: "link-options-search"
61
- }, /*#__PURE__*/React.createElement("input", {
62
- className: "form-control",
63
- value: searchValue,
64
- onChange: this.onValueChanged,
65
- onClick: this.onInputClick,
66
- placeholder: getLocale('Find_an_option')
67
- })), /*#__PURE__*/React.createElement("div", {
68
- className: "link-options-container"
69
- }, options.length > 0 && options.map(function (option, index) {
70
- var isSelect = selectedOptions.some(function (selectedOption) {
71
- return selectedOption.id === option.id;
72
- });
73
- return /*#__PURE__*/React.createElement("div", {
74
- key: index,
75
- className: "link-option-item",
76
- onClick: _this2.onOptionItemToggle.bind(_this2, option)
77
- }, /*#__PURE__*/React.createElement("div", {
78
- className: "option-info"
79
- }, /*#__PURE__*/React.createElement("div", {
80
- className: "option-name",
81
- title: option.name
82
- }, option.name)), /*#__PURE__*/React.createElement("div", {
83
- className: "option-checked"
84
- }, isSelect && /*#__PURE__*/React.createElement("i", {
85
- className: "dtable-font dtable-icon-check-mark"
86
- })));
87
- }), options.length === 0 && /*#__PURE__*/React.createElement("div", {
88
- className: "link-option-null"
89
- }, getLocale('No_options_available'))));
90
- }
91
- }]);
92
- return PCLinkEditorPopover;
93
- }(React.Component);
72
+ className: "option-info"
73
+ }, /*#__PURE__*/React.createElement("div", {
74
+ className: "option-name",
75
+ title: option.name
76
+ }, option.name)), /*#__PURE__*/React.createElement("div", {
77
+ className: "option-checked"
78
+ }, isSelect && /*#__PURE__*/React.createElement("i", {
79
+ className: "dtable-font dtable-icon-check-mark"
80
+ })));
81
+ }), options.length === 0 && /*#__PURE__*/React.createElement("div", {
82
+ className: "link-option-null"
83
+ }, getLocale('No_options_available'))));
84
+ }
85
+ }
94
86
  PCLinkEditorPopover.defaultProps = {
95
87
  popoverPosition: {},
96
88
  options: []
@@ -1,57 +1,56 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
1
  import React from 'react';
7
2
  import classnames from 'classnames';
8
3
  import { CellType, getNumberDisplayString, getDateDisplayString } from 'dtable-utils';
9
4
  // link value is get form parant's interface
10
- var LinkFormatter = /*#__PURE__*/function (_React$Component) {
11
- _inherits(LinkFormatter, _React$Component);
12
- var _super = _createSuper(LinkFormatter);
13
- function LinkFormatter(props) {
14
- var _this;
15
- _classCallCheck(this, LinkFormatter);
16
- _this = _super.call(this, props);
17
- _this.getLinkedCellValue = function (row) {
5
+ class LinkFormatter extends React.Component {
6
+ constructor(props) {
7
+ super(props);
8
+ this.getLinkedCellValue = row => {
18
9
  if (!row) return [];
19
- var _this$props = _this.props,
20
- column = _this$props.column,
21
- currentTableId = _this$props.currentTableId,
22
- linkMetaData = _this$props.linkMetaData;
23
- var _ref = column.data || {},
24
- link_id = _ref.link_id,
25
- table_id = _ref.table_id,
26
- other_table_id = _ref.other_table_id;
27
- _this.linkID = link_id;
28
- _this.tableID = currentTableId === table_id ? table_id : other_table_id;
29
- _this.otherTableID = _this.tableID === table_id ? other_table_id : table_id;
30
- return linkMetaData.getLinkedCellValue(_this.linkID, _this.tableID, _this.otherTableID, row._id);
10
+ const {
11
+ column,
12
+ currentTableId,
13
+ linkMetaData
14
+ } = this.props;
15
+ const {
16
+ link_id,
17
+ table_id,
18
+ other_table_id
19
+ } = column.data || {};
20
+ this.linkID = link_id;
21
+ this.tableID = currentTableId === table_id ? table_id : other_table_id;
22
+ this.otherTableID = this.tableID === table_id ? other_table_id : table_id;
23
+ return linkMetaData.getLinkedCellValue(this.linkID, this.tableID, this.otherTableID, row._id);
31
24
  };
32
- _this.expandLinkedTableRow = function (row) {
33
- var _this$props2 = _this.props,
34
- enableOpenLinkedRow = _this$props2.enableOpenLinkedRow,
35
- linkMetaData = _this$props2.linkMetaData;
25
+ this.expandLinkedTableRow = row => {
26
+ let {
27
+ enableOpenLinkedRow,
28
+ linkMetaData
29
+ } = this.props;
36
30
  if (enableOpenLinkedRow) {
37
- linkMetaData.expandLinkedTableRow(row, _this.otherTableID);
31
+ linkMetaData.expandLinkedTableRow(row, this.otherTableID);
38
32
  }
39
33
  };
40
- _this.getDisplayValues = function () {
41
- var _this$props3 = _this.props,
42
- column = _this$props3.column,
43
- linkMetaData = _this$props3.linkMetaData;
44
- var rowIds = _this.state.value;
34
+ this.getDisplayValues = () => {
35
+ let {
36
+ column,
37
+ linkMetaData
38
+ } = this.props;
39
+ let {
40
+ value: rowIds
41
+ } = this.state;
45
42
  if (rowIds && Array.isArray(rowIds) && rowIds.length > 0) {
46
- var linkedTable = linkMetaData.getLinkedTable(_this.otherTableID);
47
- var linkedRows = linkMetaData.getLinkedRows(_this.otherTableID, rowIds);
48
- var result = linkedRows.map(function (row, index) {
49
- var displayColumnKey = column.data.display_column_key;
50
- var displayValue = _this.getDisplayValue(linkedTable, row, displayColumnKey);
43
+ let linkedTable = linkMetaData.getLinkedTable(this.otherTableID);
44
+ let linkedRows = linkMetaData.getLinkedRows(this.otherTableID, rowIds);
45
+ let result = linkedRows.map((row, index) => {
46
+ let {
47
+ display_column_key: displayColumnKey
48
+ } = column.data;
49
+ let displayValue = this.getDisplayValue(linkedTable, row, displayColumnKey);
51
50
  return /*#__PURE__*/React.createElement("div", {
52
51
  key: index,
53
52
  className: "link-item",
54
- onClick: _this.expandLinkedTableRow.bind(_assertThisInitialized(_this), row)
53
+ onClick: this.expandLinkedTableRow.bind(this, row)
55
54
  }, /*#__PURE__*/React.createElement("div", {
56
55
  className: "link-name",
57
56
  title: displayValue
@@ -61,13 +60,13 @@ var LinkFormatter = /*#__PURE__*/function (_React$Component) {
61
60
  }
62
61
  return null;
63
62
  };
64
- _this.getDisplayValue = function (linkedTable, row, displayColumnKey) {
65
- var value = row[displayColumnKey];
66
- var linkedColumn = linkedTable.columns.find(function (column) {
67
- return column.key === displayColumnKey;
68
- });
69
- var type = linkedColumn.type,
70
- data = linkedColumn.data;
63
+ this.getDisplayValue = (linkedTable, row, displayColumnKey) => {
64
+ let value = row[displayColumnKey];
65
+ let linkedColumn = linkedTable.columns.find(column => column.key === displayColumnKey);
66
+ let {
67
+ type,
68
+ data
69
+ } = linkedColumn;
71
70
  // todo: improve
72
71
  switch (type) {
73
72
  case CellType.NUMBER:
@@ -76,44 +75,43 @@ var LinkFormatter = /*#__PURE__*/function (_React$Component) {
76
75
  }
77
76
  case CellType.DATE:
78
77
  {
79
- var format = data.format;
78
+ let {
79
+ format
80
+ } = data;
80
81
  return getDateDisplayString(value, format);
81
82
  }
82
83
  default:
83
84
  return value;
84
85
  }
85
86
  };
86
- _this.linkID = '';
87
- _this.tableID = '';
88
- _this.otherTableID = '';
89
- _this.state = {
90
- value: _this.getLinkedCellValue(props.row)
87
+ this.linkID = '';
88
+ this.tableID = '';
89
+ this.otherTableID = '';
90
+ this.state = {
91
+ value: this.getLinkedCellValue(props.row)
91
92
  };
92
- return _this;
93
93
  }
94
- _createClass(LinkFormatter, [{
95
- key: "UNSAFE_componentWillReceiveProps",
96
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
97
- var nextRow = nextProps.row;
98
- if (nextRow._id !== this.props.row._id) {
99
- this.setState({
100
- value: this.getLinkedCellValue(nextRow)
101
- });
102
- }
103
- }
104
- }, {
105
- key: "render",
106
- value: function render() {
107
- var containerClassName = this.props.containerClassName;
108
- var classname = classnames('dtable-ui cell-formatter-container link-formatter', containerClassName);
109
- var displayValues = this.getDisplayValues();
110
- return /*#__PURE__*/React.createElement("div", {
111
- className: classname
112
- }, displayValues);
94
+ UNSAFE_componentWillReceiveProps(nextProps) {
95
+ const {
96
+ row: nextRow
97
+ } = nextProps;
98
+ if (nextRow._id !== this.props.row._id) {
99
+ this.setState({
100
+ value: this.getLinkedCellValue(nextRow)
101
+ });
113
102
  }
114
- }]);
115
- return LinkFormatter;
116
- }(React.Component);
103
+ }
104
+ render() {
105
+ const {
106
+ containerClassName
107
+ } = this.props;
108
+ const classname = classnames('dtable-ui cell-formatter-container link-formatter', containerClassName);
109
+ let displayValues = this.getDisplayValues();
110
+ return /*#__PURE__*/React.createElement("div", {
111
+ className: classname
112
+ }, displayValues);
113
+ }
114
+ }
117
115
  LinkFormatter.defaultProps = {
118
116
  enableOpenLinkedRow: false,
119
117
  currentTableId: '',
@@ -2,9 +2,11 @@ import React from 'react';
2
2
  import HtmlLongTextFormatter from '../HtmlLongTextFormatter';
3
3
  import SimpleLongTextFormatter from '../SimpleLongTextFormatter';
4
4
  function LongTextFormatter(props) {
5
- var isSample = props.isSample,
6
- value = props.value,
7
- containerClassName = props.containerClassName;
5
+ const {
6
+ isSample,
7
+ value,
8
+ containerClassName
9
+ } = props;
8
10
  if (isSample) {
9
11
  return /*#__PURE__*/React.createElement(SimpleLongTextFormatter, {
10
12
  value: value,