dtable-ui-component 4.3.6 → 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 (122) 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.css +22 -59
  15. package/lib/DTableCustomizeSelect/index.js +99 -95
  16. package/lib/DTablePopover/index.js +52 -71
  17. package/lib/DTablePopover/utils.js +1 -1
  18. package/lib/DTableRadio/index.js +9 -7
  19. package/lib/DTableSearchInput/index.js +89 -99
  20. package/lib/DTableSearchInput/utils.js +2 -2
  21. package/lib/DTableSelect/dtable-select-label.js +5 -3
  22. package/lib/DTableSelect/index.js +50 -64
  23. package/lib/DTableSelect/utils.js +36 -41
  24. package/lib/DTableSwitch/index.js +7 -5
  25. package/lib/DateEditor/index.js +88 -94
  26. package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
  27. package/lib/DateEditor/pc-date-editor-popover.js +70 -77
  28. package/lib/DateFormatter/index.js +15 -28
  29. package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
  30. package/lib/DigitalSignFormatter/index.js +55 -65
  31. package/lib/DigitalSignFormatter/utils.js +9 -8
  32. package/lib/DurationFormatter/index.js +14 -27
  33. package/lib/EditEditorButton/index.js +10 -22
  34. package/lib/EmailFormatter/index.js +11 -24
  35. package/lib/FieldDisplaySetting/field-item.js +18 -20
  36. package/lib/FieldDisplaySetting/index.js +41 -43
  37. package/lib/FileEditor/index.js +18 -29
  38. package/lib/FileFormatter/index.js +29 -43
  39. package/lib/FileItemFormatter/index.js +17 -32
  40. package/lib/FileItemFormatter/utils.js +5 -5
  41. package/lib/FileUploader/index.js +20 -33
  42. package/lib/FormulaFormatter/cell-value-validator.js +23 -8
  43. package/lib/FormulaFormatter/index.js +77 -83
  44. package/lib/FormulaFormatter/utils.js +27 -21
  45. package/lib/GeolocationFormatter/index.js +19 -32
  46. package/lib/HtmlLongTextFormatter/index.js +43 -52
  47. package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
  48. package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
  49. package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
  50. package/lib/ImageFormatter/images-lazy-load.js +71 -79
  51. package/lib/ImageFormatter/index.js +86 -97
  52. package/lib/ImageFormatter/utils.js +1 -1
  53. package/lib/ImagePreviewerLightbox/index.js +20 -18
  54. package/lib/ImagePreviewerLightbox/utils.js +3 -3
  55. package/lib/LastModifierFormatter/index.js +24 -40
  56. package/lib/LinkEditor/index.js +163 -167
  57. package/lib/LinkEditor/link-editor-option.js +41 -56
  58. package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
  59. package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
  60. package/lib/LinkFormatter/index.js +75 -77
  61. package/lib/LongTextFormatter/index.js +5 -3
  62. package/lib/MBEditorHeader/index.js +25 -38
  63. package/lib/MTimeFormatter/index.js +17 -32
  64. package/lib/ModalPortal/index.js +15 -32
  65. package/lib/MultipleSelectEditor/index.js +118 -136
  66. package/lib/MultipleSelectFormatter/index.js +24 -40
  67. package/lib/NotificationPopover/index.js +68 -95
  68. package/lib/NumberEditor/index.js +75 -82
  69. package/lib/NumberFormatter/index.js +15 -28
  70. package/lib/RateFormatter/index.js +29 -45
  71. package/lib/RoleStatusEditor/index.js +20 -22
  72. package/lib/RowExpandEmailFormatter/index.js +24 -37
  73. package/lib/RowExpandFileFormatter/index.js +28 -42
  74. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
  75. package/lib/RowExpandFormatter/index.js +92 -96
  76. package/lib/RowExpandFormulaFormatter/index.js +85 -91
  77. package/lib/RowExpandImageFormatter/index.js +65 -82
  78. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
  79. package/lib/RowExpandImageFormatter/utils.js +1 -1
  80. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
  81. package/lib/RowExpandLinkFormatter/index.js +131 -137
  82. package/lib/RowExpandLinkFormatter/utils.js +23 -17
  83. package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
  84. package/lib/RowExpandRateFormatter/index.js +27 -42
  85. package/lib/RowExpandUrlFormatter/index.js +27 -40
  86. package/lib/SelectItem/index.js +17 -33
  87. package/lib/SelectOptionGroup/index.css +103 -0
  88. package/lib/SelectOptionGroup/index.js +157 -135
  89. package/lib/SelectOptionGroup/option.js +31 -38
  90. package/lib/SimpleLongTextFormatter/index.js +55 -67
  91. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
  92. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
  93. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
  94. package/lib/SingleSelectEditor/index.js +108 -119
  95. package/lib/SingleSelectFormatter/index.js +21 -37
  96. package/lib/TextEditor/index.js +45 -51
  97. package/lib/TextFormatter/index.js +17 -32
  98. package/lib/UrlFormatter/index.js +11 -24
  99. package/lib/cellFormatterFactory/index.js +8 -17
  100. package/lib/common/ClickOutside.js +28 -0
  101. package/lib/common/delete-tip.js +40 -65
  102. package/lib/common/modal-portal.js +15 -33
  103. package/lib/constants/index.js +5 -5
  104. package/lib/data/dtable-value.js +4 -4
  105. package/lib/formatterConfig/base-formatter-config.js +24 -3
  106. package/lib/formatterConfig/index.js +5 -4
  107. package/lib/lang/index.js +6 -6
  108. package/lib/locals/de.js +1 -1
  109. package/lib/locals/en.js +1 -1
  110. package/lib/locals/fr.js +1 -1
  111. package/lib/locals/zh-CN.js +1 -1
  112. package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
  113. package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
  114. package/lib/select-editor/select-editor-option.js +41 -56
  115. package/lib/toaster/alert.js +73 -88
  116. package/lib/toaster/index.js +1 -1
  117. package/lib/toaster/toast.js +75 -102
  118. package/lib/toaster/toastManager.js +55 -91
  119. package/lib/toaster/toaster.js +58 -57
  120. package/lib/utils/editor-utils.js +17 -19
  121. package/lib/utils/utils.js +14 -14
  122. package/package.json +4 -4
@@ -1,79 +1,74 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React, { Fragment } from 'react';
6
2
  import MediaQuery from 'react-responsive';
7
3
  import { getLocale } from '../lang';
8
4
  import EditEditorButton from '../EditEditorButton';
9
5
  import { SelectEditorOption, PCSelectEditorPopover, MBSelectEditorPopover } from '../select-editor';
10
6
  import './index.css';
11
- var SingleSelectEditor = /*#__PURE__*/function (_React$Component) {
12
- _inherits(SingleSelectEditor, _React$Component);
13
- var _super = _createSuper(SingleSelectEditor);
14
- function SingleSelectEditor(props) {
15
- var _this;
16
- _classCallCheck(this, SingleSelectEditor);
17
- _this = _super.call(this, props);
18
- _this.onDocumentToggle = function (e) {
19
- if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
20
- _this.onClosePopover();
7
+ class SingleSelectEditor extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.onDocumentToggle = e => {
11
+ if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
12
+ this.onClosePopover();
21
13
  }
22
14
  };
23
- _this.formatOption = function () {
24
- var newValue = _this.state.newValue;
25
- var option = _this.options.find(function (option) {
26
- return option.name === newValue;
27
- });
15
+ this.formatOption = () => {
16
+ let {
17
+ newValue
18
+ } = this.state;
19
+ let option = this.options.find(option => option.name === newValue);
28
20
  return option;
29
21
  };
30
- _this.onAddOptionToggle = function (event) {
22
+ this.onAddOptionToggle = event => {
31
23
  event.nativeEvent.stopImmediatePropagation();
32
24
  event.stopPropagation();
33
- if (_this.props.isReadOnly) {
25
+ if (this.props.isReadOnly) {
34
26
  return;
35
27
  }
36
- var isPopoverShow = !_this.state.isPopoverShow;
28
+ let isPopoverShow = !this.state.isPopoverShow;
37
29
  if (isPopoverShow) {
38
- var popoverPosition = _this.caculatePopoverPosition();
39
- _this.setState({
40
- isPopoverShow: isPopoverShow,
41
- popoverPosition: popoverPosition
30
+ let popoverPosition = this.caculatePopoverPosition();
31
+ this.setState({
32
+ isPopoverShow,
33
+ popoverPosition
42
34
  });
43
35
  } else {
44
- _this.setState({
45
- isPopoverShow: isPopoverShow
36
+ this.setState({
37
+ isPopoverShow
46
38
  });
47
39
  }
48
40
  };
49
- _this.onCommit = function (newValue) {
50
- var updated = {};
51
- var column = _this.props.column;
41
+ this.onCommit = newValue => {
42
+ let updated = {};
43
+ let {
44
+ column
45
+ } = this.props;
52
46
  updated[column.name] = newValue;
53
- _this.props.onCommit(updated);
47
+ this.props.onCommit(updated);
54
48
  };
55
- _this.onOptionItemToggle = function (option) {
56
- var newValue = _this.state.newValue === option.name ? '' : option.name;
57
- _this.setState({
58
- newValue: newValue
59
- }, function () {
60
- _this.onCommit(newValue);
61
- _this.onClosePopover();
49
+ this.onOptionItemToggle = option => {
50
+ let newValue = this.state.newValue === option.name ? '' : option.name;
51
+ this.setState({
52
+ newValue
53
+ }, () => {
54
+ this.onCommit(newValue);
55
+ this.onClosePopover();
62
56
  });
63
57
  };
64
- _this.caculatePopoverPosition = function () {
65
- var POPOVER_MAX_HEIGHT = 200;
66
- var innerHeight = window.innerHeight;
67
- var _this$editor$getClien = _this.editor.getClientRects()[0],
68
- top = _this$editor$getClien.top,
69
- height = _this$editor$getClien.height;
70
- var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
71
- var position = {
58
+ this.caculatePopoverPosition = () => {
59
+ const POPOVER_MAX_HEIGHT = 200;
60
+ let innerHeight = window.innerHeight;
61
+ let {
62
+ top,
63
+ height
64
+ } = this.editor.getClientRects()[0];
65
+ let isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
66
+ let position = {
72
67
  top: height + 1,
73
68
  left: 0
74
69
  };
75
70
  if (!isBelow) {
76
- var bottom = height + 1;
71
+ let bottom = height + 1;
77
72
  position = {
78
73
  bottom: bottom,
79
74
  left: 0
@@ -81,88 +76,82 @@ var SingleSelectEditor = /*#__PURE__*/function (_React$Component) {
81
76
  }
82
77
  return position;
83
78
  };
84
- _this.onAddNewOption = function (optionName) {
85
- _this.props.onAddNewOption(optionName);
86
- _this.onClosePopover();
79
+ this.onAddNewOption = optionName => {
80
+ this.props.onAddNewOption(optionName);
81
+ this.onClosePopover();
87
82
  };
88
- _this.onClosePopover = function () {
89
- _this.setState({
83
+ this.onClosePopover = () => {
84
+ this.setState({
90
85
  isPopoverShow: false
91
86
  });
92
87
  };
93
- _this.setEditorContainerRef = function (editorContainer) {
94
- _this.editorContainer = editorContainer;
88
+ this.setEditorContainerRef = editorContainer => {
89
+ this.editorContainer = editorContainer;
95
90
  };
96
- _this.setEditorRef = function (editor) {
97
- _this.editor = editor;
91
+ this.setEditorRef = editor => {
92
+ this.editor = editor;
98
93
  };
99
- _this.state = {
94
+ this.state = {
100
95
  newValue: props.value,
101
96
  isPopoverShow: false,
102
97
  popoverPosition: {}
103
98
  };
104
- var _column = _this.props.column;
105
- _this.options = _column.data && (_column.data.options || []);
106
- return _this;
99
+ let {
100
+ column: _column
101
+ } = this.props;
102
+ this.options = _column.data && (_column.data.options || []);
103
+ }
104
+ componentDidMount() {
105
+ document.addEventListener('click', this.onDocumentToggle);
106
+ }
107
+ componentWillUnmount() {
108
+ document.removeEventListener('click', this.onDocumentToggle);
109
+ }
110
+ render() {
111
+ let {
112
+ isPopoverShow,
113
+ popoverPosition
114
+ } = this.state;
115
+ let option = this.formatOption();
116
+ let options = this.options;
117
+ let selectedOptions = option ? [option] : [];
118
+ return /*#__PURE__*/React.createElement("div", {
119
+ ref: this.setEditorContainerRef,
120
+ className: "dtable-ui-single-select-editor"
121
+ }, /*#__PURE__*/React.createElement("div", {
122
+ ref: this.setEditorRef,
123
+ className: option ? '' : 'd-inline-block',
124
+ onClick: this.onAddOptionToggle
125
+ }, option ? /*#__PURE__*/React.createElement("div", {
126
+ className: "dtable-ui-single-select-option-container"
127
+ }, /*#__PURE__*/React.createElement(SelectEditorOption, {
128
+ option: option
129
+ })) : /*#__PURE__*/React.createElement(EditEditorButton, {
130
+ text: getLocale('Add_an_option')
131
+ })), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
132
+ query: "(min-width: 768px)"
133
+ }, /*#__PURE__*/React.createElement(PCSelectEditorPopover, {
134
+ popoverPosition: popoverPosition,
135
+ options: options,
136
+ selectedOptions: selectedOptions,
137
+ onOptionItemToggle: this.onOptionItemToggle,
138
+ isSupportNewOption: this.props.isSupportNewOption,
139
+ onAddNewOption: this.onAddNewOption
140
+ })), /*#__PURE__*/React.createElement(MediaQuery, {
141
+ query: "(max-width: 767.8px)"
142
+ }, /*#__PURE__*/React.createElement(MBSelectEditorPopover, {
143
+ isReadOnly: this.props.isReadOnly,
144
+ value: [this.state.newValue],
145
+ column: this.props.column,
146
+ options: options,
147
+ onOptionItemToggle: this.onOptionItemToggle,
148
+ isShowRemoveIcon: true,
149
+ isSupportNewOption: this.props.isSupportNewOption,
150
+ onAddNewOption: this.onAddNewOption,
151
+ onClosePopover: this.onClosePopover
152
+ }))));
107
153
  }
108
- _createClass(SingleSelectEditor, [{
109
- key: "componentDidMount",
110
- value: function componentDidMount() {
111
- document.addEventListener('click', this.onDocumentToggle);
112
- }
113
- }, {
114
- key: "componentWillUnmount",
115
- value: function componentWillUnmount() {
116
- document.removeEventListener('click', this.onDocumentToggle);
117
- }
118
- }, {
119
- key: "render",
120
- value: function render() {
121
- var _this$state = this.state,
122
- isPopoverShow = _this$state.isPopoverShow,
123
- popoverPosition = _this$state.popoverPosition;
124
- var option = this.formatOption();
125
- var options = this.options;
126
- var selectedOptions = option ? [option] : [];
127
- return /*#__PURE__*/React.createElement("div", {
128
- ref: this.setEditorContainerRef,
129
- className: "dtable-ui-single-select-editor"
130
- }, /*#__PURE__*/React.createElement("div", {
131
- ref: this.setEditorRef,
132
- className: option ? '' : 'd-inline-block',
133
- onClick: this.onAddOptionToggle
134
- }, option ? /*#__PURE__*/React.createElement("div", {
135
- className: "dtable-ui-single-select-option-container"
136
- }, /*#__PURE__*/React.createElement(SelectEditorOption, {
137
- option: option
138
- })) : /*#__PURE__*/React.createElement(EditEditorButton, {
139
- text: getLocale('Add_an_option')
140
- })), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
141
- query: "(min-width: 768px)"
142
- }, /*#__PURE__*/React.createElement(PCSelectEditorPopover, {
143
- popoverPosition: popoverPosition,
144
- options: options,
145
- selectedOptions: selectedOptions,
146
- onOptionItemToggle: this.onOptionItemToggle,
147
- isSupportNewOption: this.props.isSupportNewOption,
148
- onAddNewOption: this.onAddNewOption
149
- })), /*#__PURE__*/React.createElement(MediaQuery, {
150
- query: "(max-width: 767.8px)"
151
- }, /*#__PURE__*/React.createElement(MBSelectEditorPopover, {
152
- isReadOnly: this.props.isReadOnly,
153
- value: [this.state.newValue],
154
- column: this.props.column,
155
- options: options,
156
- onOptionItemToggle: this.onOptionItemToggle,
157
- isShowRemoveIcon: true,
158
- isSupportNewOption: this.props.isSupportNewOption,
159
- onAddNewOption: this.onAddNewOption,
160
- onClosePopover: this.onClosePopover
161
- }))));
162
- }
163
- }]);
164
- return SingleSelectEditor;
165
- }(React.Component);
154
+ }
166
155
  SingleSelectEditor.defaultProps = {
167
156
  isReadOnly: false,
168
157
  value: ''
@@ -1,29 +1,17 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React from 'react';
6
2
  import classnames from 'classnames';
7
3
  import SelectItem from '../SelectItem';
8
4
  import './index.css';
9
- var SingleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
10
- _inherits(SingleSelectFormatter, _React$PureComponent);
11
- var _super = _createSuper(SingleSelectFormatter);
12
- function SingleSelectFormatter() {
13
- var _this;
14
- _classCallCheck(this, SingleSelectFormatter);
15
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
16
- args[_key] = arguments[_key];
17
- }
18
- _this = _super.call.apply(_super, [this].concat(args));
19
- _this.getOption = function () {
20
- var _this$props = _this.props,
21
- value = _this$props.value,
22
- options = _this$props.options,
23
- fontSize = _this$props.fontSize;
24
- var option = options.find(function (item) {
25
- return item.id === value || item.name === value;
26
- });
5
+ class SingleSelectFormatter extends React.PureComponent {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.getOption = () => {
9
+ let {
10
+ value,
11
+ options,
12
+ fontSize
13
+ } = this.props;
14
+ let option = options.find(item => item.id === value || item.name === value);
27
15
  if (option) {
28
16
  return /*#__PURE__*/React.createElement(SelectItem, {
29
17
  option: option,
@@ -31,22 +19,18 @@ var SingleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
31
19
  });
32
20
  }
33
21
  };
34
- return _this;
35
22
  }
36
- _createClass(SingleSelectFormatter, [{
37
- key: "render",
38
- value: function render() {
39
- var _this$props2 = this.props,
40
- containerClassName = _this$props2.containerClassName,
41
- value = _this$props2.value;
42
- var classname = classnames('dtable-ui cell-formatter-container single-select-formatter', containerClassName);
43
- return /*#__PURE__*/React.createElement("div", {
44
- className: classname
45
- }, value ? this.getOption() : '');
46
- }
47
- }]);
48
- return SingleSelectFormatter;
49
- }(React.PureComponent);
23
+ render() {
24
+ const {
25
+ containerClassName,
26
+ value
27
+ } = this.props;
28
+ let classname = classnames('dtable-ui cell-formatter-container single-select-formatter', containerClassName);
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ className: classname
31
+ }, value ? this.getOption() : '');
32
+ }
33
+ }
50
34
  SingleSelectFormatter.defaultProps = {
51
35
  options: []
52
36
  };
@@ -1,38 +1,35 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React from 'react';
6
2
  import isHotkey from 'is-hotkey';
7
3
  import { Input } from 'reactstrap';
8
- var TextEditor = /*#__PURE__*/function (_React$Component) {
9
- _inherits(TextEditor, _React$Component);
10
- var _super = _createSuper(TextEditor);
11
- function TextEditor(props) {
12
- var _this;
13
- _classCallCheck(this, TextEditor);
14
- _this = _super.call(this, props);
15
- _this.onCommit = function () {
16
- var updated = {};
17
- var column = _this.props.column;
18
- var newValue = _this.state.newValue;
4
+ class TextEditor extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.onCommit = () => {
8
+ let updated = {};
9
+ let {
10
+ column
11
+ } = this.props;
12
+ let {
13
+ newValue
14
+ } = this.state;
19
15
  updated[column.name] = newValue ? newValue.trim() : '';
20
- _this.props.onCommit(updated);
16
+ this.props.onCommit(updated);
21
17
  };
22
- _this.onBlur = function () {
23
- _this.onCommit();
18
+ this.onBlur = () => {
19
+ this.onCommit();
24
20
  };
25
- _this.onChange = function (event) {
26
- var value = event.target.value;
27
- _this.setState({
21
+ this.onChange = event => {
22
+ let value = event.target.value;
23
+ this.setState({
28
24
  newValue: value
29
25
  });
30
26
  };
31
- _this.onKeyDown = function (event) {
32
- var _event$currentTarget = event.currentTarget,
33
- selectionStart = _event$currentTarget.selectionStart,
34
- selectionEnd = _event$currentTarget.selectionEnd,
35
- value = _event$currentTarget.value;
27
+ this.onKeyDown = event => {
28
+ let {
29
+ selectionStart,
30
+ selectionEnd,
31
+ value
32
+ } = event.currentTarget;
36
33
  if (isHotkey('enter', event)) {
37
34
  event.preventDefault();
38
35
  event.target.blur();
@@ -40,39 +37,36 @@ var TextEditor = /*#__PURE__*/function (_React$Component) {
40
37
  event.stopPropagation();
41
38
  }
42
39
  };
43
- _this.onPaste = function (e) {
40
+ this.onPaste = e => {
44
41
  e.stopPropagation();
45
42
  };
46
- _this.onCut = function (e) {
43
+ this.onCut = e => {
47
44
  e.stopPropagation();
48
45
  };
49
- _this.setInputRef = function (input) {
50
- _this.input = input;
46
+ this.setInputRef = input => {
47
+ this.input = input;
51
48
  };
52
- _this.state = {
49
+ this.state = {
53
50
  newValue: props.value
54
51
  };
55
- return _this;
56
52
  }
57
- _createClass(TextEditor, [{
58
- key: "render",
59
- value: function render() {
60
- var isReadOnly = this.props.isReadOnly;
61
- return /*#__PURE__*/React.createElement(Input, {
62
- ref: this.setInputRef,
63
- type: "text",
64
- value: this.state.newValue,
65
- readOnly: isReadOnly,
66
- onChange: this.onChange,
67
- onKeyDown: this.onKeyDown,
68
- onBlur: this.onBlur,
69
- onCut: this.onCut,
70
- onPaste: this.onPaste
71
- });
72
- }
73
- }]);
74
- return TextEditor;
75
- }(React.Component);
53
+ render() {
54
+ const {
55
+ isReadOnly
56
+ } = this.props;
57
+ return /*#__PURE__*/React.createElement(Input, {
58
+ ref: this.setInputRef,
59
+ type: "text",
60
+ value: this.state.newValue,
61
+ readOnly: isReadOnly,
62
+ onChange: this.onChange,
63
+ onKeyDown: this.onKeyDown,
64
+ onBlur: this.onBlur,
65
+ onCut: this.onCut,
66
+ onPaste: this.onPaste
67
+ });
68
+ }
69
+ }
76
70
  TextEditor.defaultProps = {
77
71
  isReadOnly: false,
78
72
  value: ''
@@ -1,21 +1,10 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React from 'react';
6
2
  import classnames from 'classnames';
7
3
  import './index.css';
8
- var TextFormatter = /*#__PURE__*/function (_React$Component) {
9
- _inherits(TextFormatter, _React$Component);
10
- var _super = _createSuper(TextFormatter);
11
- function TextFormatter() {
12
- var _this;
13
- _classCallCheck(this, TextFormatter);
14
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15
- args[_key] = arguments[_key];
16
- }
17
- _this = _super.call.apply(_super, [this].concat(args));
18
- _this.getFormattedValue = function (val) {
4
+ class TextFormatter extends React.Component {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.getFormattedValue = val => {
19
8
  if (typeof val === 'object') {
20
9
  return null;
21
10
  }
@@ -24,22 +13,18 @@ var TextFormatter = /*#__PURE__*/function (_React$Component) {
24
13
  }
25
14
  return val;
26
15
  };
27
- return _this;
28
16
  }
29
- _createClass(TextFormatter, [{
30
- key: "render",
31
- value: function render() {
32
- var _this$props = this.props,
33
- containerClassName = _this$props.containerClassName,
34
- value = _this$props.value;
35
- var classname = classnames('dtable-ui cell-formatter-container text-formatter', containerClassName);
36
- var formattedValue = this.getFormattedValue(value);
37
- return /*#__PURE__*/React.createElement("div", {
38
- className: classname,
39
- title: formattedValue
40
- }, formattedValue);
41
- }
42
- }]);
43
- return TextFormatter;
44
- }(React.Component);
17
+ render() {
18
+ const {
19
+ containerClassName,
20
+ value
21
+ } = this.props;
22
+ const classname = classnames('dtable-ui cell-formatter-container text-formatter', containerClassName);
23
+ const formattedValue = this.getFormattedValue(value);
24
+ return /*#__PURE__*/React.createElement("div", {
25
+ className: classname,
26
+ title: formattedValue
27
+ }, formattedValue);
28
+ }
29
+ }
45
30
  export default TextFormatter;
@@ -1,29 +1,16 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React from 'react';
6
2
  import classnames from 'classnames';
7
3
  import './index.css';
8
- var UrlFormatter = /*#__PURE__*/function (_React$Component) {
9
- _inherits(UrlFormatter, _React$Component);
10
- var _super = _createSuper(UrlFormatter);
11
- function UrlFormatter() {
12
- _classCallCheck(this, UrlFormatter);
13
- return _super.apply(this, arguments);
4
+ class UrlFormatter extends React.Component {
5
+ render() {
6
+ const {
7
+ containerClassName,
8
+ value
9
+ } = this.props;
10
+ let classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: classname
13
+ }, value);
14
14
  }
15
- _createClass(UrlFormatter, [{
16
- key: "render",
17
- value: function render() {
18
- var _this$props = this.props,
19
- containerClassName = _this$props.containerClassName,
20
- value = _this$props.value;
21
- var classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
22
- return /*#__PURE__*/React.createElement("div", {
23
- className: classname
24
- }, value);
25
- }
26
- }]);
27
- return UrlFormatter;
28
- }(React.Component);
15
+ }
29
16
  export default UrlFormatter;
@@ -1,20 +1,11 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
1
  import FormatterConfig from '../formatterConfig';
4
- var CellFormatterFactory = /*#__PURE__*/function () {
5
- function CellFormatterFactory() {
6
- _classCallCheck(this, CellFormatterFactory);
7
- }
8
- _createClass(CellFormatterFactory, [{
9
- key: "createFormatter",
10
- value: function createFormatter(formatterType) {
11
- if (FormatterConfig[formatterType]) {
12
- return FormatterConfig[formatterType];
13
- }
14
- return null;
2
+ class CellFormatterFactory {
3
+ createFormatter(formatterType) {
4
+ if (FormatterConfig[formatterType]) {
5
+ return FormatterConfig[formatterType];
15
6
  }
16
- }]);
17
- return CellFormatterFactory;
18
- }();
19
- var cellFormatterFactory = new CellFormatterFactory();
7
+ return null;
8
+ }
9
+ }
10
+ const cellFormatterFactory = new CellFormatterFactory();
20
11
  export default cellFormatterFactory;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ export default class ClickOutside extends React.Component {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.isClickedInside = false;
6
+ this.handleDocumentClick = e => {
7
+ if (this.isClickedInside) {
8
+ this.isClickedInside = false;
9
+ return;
10
+ }
11
+ this.props.onClickOutside(e);
12
+ };
13
+ this.handleMouseDown = () => {
14
+ this.isClickedInside = true;
15
+ };
16
+ }
17
+ componentDidMount() {
18
+ document.addEventListener('mousedown', this.handleDocumentClick);
19
+ }
20
+ componentWillUnmount() {
21
+ document.removeEventListener('mousedown', this.handleDocumentClick);
22
+ }
23
+ render() {
24
+ return React.cloneElement(React.Children.only(this.props.children), {
25
+ onMouseDownCapture: this.handleMouseDown
26
+ });
27
+ }
28
+ }