dtable-ui-component 0.3.20 → 0.3.21

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 (107) hide show
  1. package/lib/AutoNumberFormatter/index.js +2 -9
  2. package/lib/ButtonFormatter/index.js +4 -17
  3. package/lib/CTimeFormatter/index.js +2 -15
  4. package/lib/CheckboxEditor/index.js +0 -13
  5. package/lib/CheckboxFormatter/index.js +2 -11
  6. package/lib/CollaboratorEditor/index.js +6 -44
  7. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +2 -27
  8. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +2 -20
  9. package/lib/CollaboratorFormatter/index.js +6 -23
  10. package/lib/CollaboratorItem/index.js +2 -14
  11. package/lib/CreatorFormatter/index.js +6 -22
  12. package/lib/DTableCustomizeCollaboratorSelect/index.js +16 -37
  13. package/lib/DTableCustomizeCollaboratorSelect/utils.js +6 -5
  14. package/lib/DTableCustomizeSelect/index.js +14 -37
  15. package/lib/DTablePopover/index.js +8 -26
  16. package/lib/DTableRadio/index.js +0 -2
  17. package/lib/DTableSearchInput/index.js +12 -36
  18. package/lib/DTableSelect/index.js +13 -27
  19. package/lib/DTableSwitch/index.js +4 -6
  20. package/lib/DateEditor/index.js +8 -27
  21. package/lib/DateEditor/mb-date-editor-popover/index.js +8 -42
  22. package/lib/DateEditor/pc-date-editor-popover.js +7 -27
  23. package/lib/DateFormatter/index.js +3 -12
  24. package/lib/DigitalSignFormatter/index.js +8 -26
  25. package/lib/DigitalSignFormatter/utils.js +3 -6
  26. package/lib/DurationFormatter/index.js +3 -10
  27. package/lib/EditEditorButton/index.js +0 -7
  28. package/lib/EmailFormatter/index.js +2 -9
  29. package/lib/FieldDisplaySetting/field-item.js +6 -20
  30. package/lib/FieldDisplaySetting/index.js +8 -13
  31. package/lib/FileEditor/index.js +0 -8
  32. package/lib/FileFormatter/index.js +3 -14
  33. package/lib/FileItemFormatter/index.js +0 -13
  34. package/lib/FileItemFormatter/utils.js +0 -6
  35. package/lib/FileUploader/index.js +0 -16
  36. package/lib/FormulaFormatter/cell-value-validator.js +0 -10
  37. package/lib/FormulaFormatter/index.js +8 -38
  38. package/lib/FormulaFormatter/utils.js +0 -17
  39. package/lib/GeolocationFormatter/index.js +4 -13
  40. package/lib/HtmlLongTextFormatter/index.js +0 -21
  41. package/lib/HtmlLongTextFormatter/markdown2html.js +2 -17
  42. package/lib/HtmlLongTextFormatter/unified/index.js +29 -102
  43. package/lib/HtmlLongTextFormatter/vfile/core.js +13 -32
  44. package/lib/HtmlLongTextFormatter/vfile/index.js +4 -11
  45. package/lib/ImageFormatter/images-lazy-load.js +5 -35
  46. package/lib/ImageFormatter/index.js +7 -34
  47. package/lib/ImageFormatter/utils.js +0 -1
  48. package/lib/ImagePreviewerLightbox/index.js +11 -13
  49. package/lib/LastModifierFormatter/index.js +6 -22
  50. package/lib/LinkEditor/index.js +23 -69
  51. package/lib/LinkEditor/link-editor-option.js +2 -18
  52. package/lib/LinkEditor/mb-link-editor-popover/index.js +2 -27
  53. package/lib/LinkEditor/pc-link-editor-popover/index.js +2 -20
  54. package/lib/LinkFormatter/index.js +12 -35
  55. package/lib/LongTextFormatter/index.js +2 -6
  56. package/lib/MBEditorHeader/index.js +6 -13
  57. package/lib/MTimeFormatter/index.js +2 -15
  58. package/lib/ModalPortal/index.js +0 -8
  59. package/lib/MultipleSelectEditor/index.js +4 -42
  60. package/lib/MultipleSelectFormatter/index.js +4 -17
  61. package/lib/NotificationPopover/index.js +3 -22
  62. package/lib/NumberEditor/index.js +7 -35
  63. package/lib/NumberFormatter/index.js +3 -12
  64. package/lib/RateFormatter/index.js +10 -25
  65. package/lib/RowExpandEmailFormatter/index.js +2 -13
  66. package/lib/RowExpandFileFormatter/index.js +6 -15
  67. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +6 -24
  68. package/lib/RowExpandFormatter/index.js +10 -60
  69. package/lib/RowExpandFormulaFormatter/index.js +10 -41
  70. package/lib/RowExpandImageFormatter/index.js +8 -27
  71. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +11 -27
  72. package/lib/RowExpandImageFormatter/utils.js +0 -1
  73. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +4 -35
  74. package/lib/RowExpandLinkFormatter/index.js +6 -28
  75. package/lib/RowExpandLinkFormatter/utils.js +0 -4
  76. package/lib/RowExpandLinkFormatter/value-display-utils.js +2 -2
  77. package/lib/RowExpandRateFormatter/index.js +8 -23
  78. package/lib/RowExpandUrlFormatter/index.js +2 -14
  79. package/lib/SelectItem/index.js +2 -13
  80. package/lib/SelectOptionGroup/index.js +13 -42
  81. package/lib/SelectOptionGroup/option.js +0 -14
  82. package/lib/SimpleLongTextFormatter/index.js +0 -26
  83. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +2 -12
  84. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +1 -16
  85. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +0 -17
  86. package/lib/SingleSelectEditor/index.js +4 -37
  87. package/lib/SingleSelectFormatter/index.js +5 -17
  88. package/lib/TextEditor/index.js +3 -22
  89. package/lib/TextFormatter/index.js +2 -15
  90. package/lib/UrlFormatter/index.js +2 -9
  91. package/lib/cellFormatterFactory/index.js +0 -5
  92. package/lib/common/delete-tip.js +4 -16
  93. package/lib/common/modal-portal.js +0 -8
  94. package/lib/formatterConfig/base-formatter-config.js +0 -2
  95. package/lib/formatterConfig/index.js +0 -4
  96. package/lib/index.js +12 -6
  97. package/lib/lang/index.js +0 -7
  98. package/lib/select-editor/mb-select-editor-popover/index.js +6 -38
  99. package/lib/select-editor/pc-select-editor-popover/index.js +3 -25
  100. package/lib/select-editor/select-editor-option.js +2 -17
  101. package/lib/toaster/alert.js +0 -12
  102. package/lib/toaster/toast.js +1 -22
  103. package/lib/toaster/toastManager.js +7 -30
  104. package/lib/toaster/toaster.js +4 -15
  105. package/lib/utils/editor-utils.js +0 -20
  106. package/lib/utils/utils.js +2 -5
  107. package/package.json +5 -5
@@ -8,25 +8,17 @@ import { getLocale } from '../../lang';
8
8
  import SelectEditorOption from '../select-editor-option';
9
9
  import MBEditorHeader from '../../MBEditorHeader';
10
10
  import './index.css';
11
-
12
11
  var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
13
12
  _inherits(MBSelectEditorPopover, _React$Component);
14
-
15
13
  var _super = _createSuper(MBSelectEditorPopover);
16
-
17
14
  function MBSelectEditorPopover(props) {
18
15
  var _this;
19
-
20
16
  _classCallCheck(this, MBSelectEditorPopover);
21
-
22
17
  _this = _super.call(this, props);
23
-
24
18
  _this.handleHistaryBack = function (e) {
25
19
  e.preventDefault();
26
-
27
20
  _this.props.onClosePopover();
28
21
  };
29
-
30
22
  _this.onContainerClick = function (event) {
31
23
  if (_this.editorPopover && _this.editorPopover.contains(event.target)) {
32
24
  event.stopPropagation();
@@ -34,35 +26,27 @@ var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
34
26
  return false;
35
27
  }
36
28
  };
37
-
38
29
  _this.onChangeSearch = function (event) {
39
30
  var searchVal = _this.state.searchVal;
40
-
41
31
  if (searchVal === event.target.value) {
42
32
  return;
43
33
  }
44
-
45
34
  searchVal = event.target.value;
46
-
47
35
  _this.setState({
48
36
  searchVal: searchVal
49
37
  });
50
38
  };
51
-
52
39
  _this.getSelectedOptions = function () {
53
40
  var _this$props = _this.props,
54
- value = _this$props.value,
55
- options = _this$props.options;
56
-
41
+ value = _this$props.value,
42
+ options = _this$props.options;
57
43
  if (!Array.isArray(value)) {
58
44
  return [];
59
45
  }
60
-
61
46
  return options.filter(function (option) {
62
47
  return value.indexOf(option.id) > -1;
63
48
  });
64
49
  };
65
-
66
50
  _this.getFilteredOptions = function () {
67
51
  var options = _this.props.options;
68
52
  var searchVal = _this.state.searchVal;
@@ -70,28 +54,21 @@ var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
70
54
  return item.name.indexOf(searchVal) > -1;
71
55
  }) : options;
72
56
  };
73
-
74
57
  _this.onSelectOption = function (option) {
75
58
  _this.props.onOptionItemToggle(option);
76
59
  };
77
-
78
60
  _this.onAddNewOption = function (event) {
79
61
  event.stopPropagation();
80
62
  event.nativeEvent.stopImmediatePropagation();
81
-
82
63
  var newOption = _this.state.searchVal.trim();
83
-
84
64
  if (newOption) {
85
65
  _this.props.onAddNewOption(newOption);
86
-
87
66
  _this.props.onClosePopover();
88
67
  }
89
68
  };
90
-
91
69
  _this.onRemoveOption = function (option) {
92
70
  _this.props.onOptionItemToggle(option);
93
71
  };
94
-
95
72
  _this.renderSelectOptions = function (options) {
96
73
  var value = _this.props.value;
97
74
  return options.map(function (option, index) {
@@ -119,22 +96,18 @@ var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
119
96
  })));
120
97
  });
121
98
  };
122
-
123
99
  _this.setEditorPopover = function (editorPopover) {
124
100
  _this.editorPopover = editorPopover;
125
101
  };
126
-
127
102
  _this.state = {
128
103
  searchVal: ''
129
104
  };
130
105
  return _this;
131
106
  }
132
-
133
107
  _createClass(MBSelectEditorPopover, [{
134
108
  key: "componentDidMount",
135
109
  value: function componentDidMount() {
136
110
  history.pushState(null, null, '#'); // eslint-disable-line
137
-
138
111
  window.addEventListener('popstate', this.handleHistaryBack, false);
139
112
  }
140
113
  }, {
@@ -146,22 +119,19 @@ var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
146
119
  key: "render",
147
120
  value: function render() {
148
121
  var _this2 = this;
149
-
150
122
  var _this$props2 = this.props,
151
- isReadOnly = _this$props2.isReadOnly,
152
- column = _this$props2.column,
153
- isSupportNewOption = _this$props2.isSupportNewOption,
154
- isShowRemoveIcon = _this$props2.isShowRemoveIcon;
123
+ isReadOnly = _this$props2.isReadOnly,
124
+ column = _this$props2.column,
125
+ isSupportNewOption = _this$props2.isSupportNewOption,
126
+ isShowRemoveIcon = _this$props2.isShowRemoveIcon;
155
127
  var searchVal = this.state.searchVal;
156
128
  var selectedOptions = this.getSelectedOptions();
157
129
  var filteredOptions = this.getFilteredOptions();
158
130
  var isShowRemoveBtn = !isReadOnly && isShowRemoveIcon;
159
131
  var isShowCreateBtn = !isReadOnly && isSupportNewOption && !!searchVal;
160
-
161
132
  if (isShowCreateBtn) {
162
133
  isShowCreateBtn = filteredOptions.length === 0;
163
134
  }
164
-
165
135
  return /*#__PURE__*/React.createElement("div", {
166
136
  ref: this.setEditorPopover,
167
137
  className: "dtable-ui-mb-editor-popover mb-select-editor-popover",
@@ -219,10 +189,8 @@ var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
219
189
  }, "".concat(getLocale('Add_an_option'), " ").concat(searchVal)))));
220
190
  }
221
191
  }]);
222
-
223
192
  return MBSelectEditorPopover;
224
193
  }(React.Component);
225
-
226
194
  MBSelectEditorPopover.defaultProps = {
227
195
  isReadOnly: false,
228
196
  isShowRemoveIcon: false,
@@ -6,56 +6,40 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import React from 'react';
7
7
  import { getLocale } from '../../lang';
8
8
  import './index.css';
9
-
10
9
  var PCSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
11
10
  _inherits(PCSelectEditorPopover, _React$Component);
12
-
13
11
  var _super = _createSuper(PCSelectEditorPopover);
14
-
15
12
  function PCSelectEditorPopover(props) {
16
13
  var _this;
17
-
18
14
  _classCallCheck(this, PCSelectEditorPopover);
19
-
20
15
  _this = _super.call(this, props);
21
-
22
16
  _this.onValueChanged = function (event) {
23
17
  var value = event.target.value;
24
-
25
18
  _this.setState({
26
19
  searchValue: value
27
20
  });
28
21
  };
29
-
30
22
  _this.onInputClick = function (event) {
31
23
  event.nativeEvent.stopImmediatePropagation();
32
24
  event.stopPropagation();
33
25
  };
34
-
35
26
  _this.onAddNewOption = function () {
36
27
  var name = _this.state.searchValue.trim();
37
-
38
28
  _this.props.onAddNewOption(name);
39
29
  };
40
-
41
30
  _this.onOptionItemToggle = function (item) {
42
31
  _this.props.onOptionItemToggle(item);
43
32
  };
44
-
45
33
  _this.getFilterOptions = function () {
46
34
  var options = _this.props.options;
47
-
48
35
  var filter = _this.state.searchValue.toLowerCase();
49
-
50
36
  if (!filter) {
51
37
  return options;
52
38
  }
53
-
54
39
  return options.filter(function (option) {
55
40
  return option.name.toString().toLowerCase().indexOf(filter) > -1;
56
41
  });
57
42
  };
58
-
59
43
  _this.getOptionStyle = function (option) {
60
44
  var textColor = option.textColor || null;
61
45
  return {
@@ -69,23 +53,20 @@ var PCSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
69
53
  color: textColor
70
54
  };
71
55
  };
72
-
73
56
  _this.state = {
74
57
  searchValue: ''
75
58
  };
76
59
  return _this;
77
60
  }
78
-
79
61
  _createClass(PCSelectEditorPopover, [{
80
62
  key: "render",
81
63
  value: function render() {
82
64
  var _this2 = this;
83
-
84
65
  var options = this.getFilterOptions();
85
66
  var _this$props = this.props,
86
- popoverPosition = _this$props.popoverPosition,
87
- selectedOptions = _this$props.selectedOptions,
88
- isSupportNewOption = _this$props.isSupportNewOption;
67
+ popoverPosition = _this$props.popoverPosition,
68
+ selectedOptions = _this$props.selectedOptions,
69
+ isSupportNewOption = _this$props.isSupportNewOption;
89
70
  var searchValue = this.state.searchValue;
90
71
  var popoverStyle = Object.assign({}, _objectSpread({}, popoverPosition), {
91
72
  position: 'absolute'
@@ -104,7 +85,6 @@ var PCSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
104
85
  className: "select-options-container"
105
86
  }, options.length > 0 && options.map(function (option, index) {
106
87
  var optionStyle = _this2.getOptionStyle(option);
107
-
108
88
  var isSelect = selectedOptions.some(function (selectedOption) {
109
89
  return selectedOption.id === option.id;
110
90
  });
@@ -133,10 +113,8 @@ var PCSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
133
113
  }), /*#__PURE__*/React.createElement("span", null, getLocale('Add_an_option'), ' ', searchValue)));
134
114
  }
135
115
  }]);
136
-
137
116
  return PCSelectEditorPopover;
138
117
  }(React.Component);
139
-
140
118
  PCSelectEditorPopover.defaultProps = {
141
119
  popoverPosition: {},
142
120
  options: [],
@@ -3,30 +3,21 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
-
7
6
  var SelectEditorOption = /*#__PURE__*/function (_React$Component) {
8
7
  _inherits(SelectEditorOption, _React$Component);
9
-
10
8
  var _super = _createSuper(SelectEditorOption);
11
-
12
9
  function SelectEditorOption() {
13
10
  var _this;
14
-
15
11
  _classCallCheck(this, SelectEditorOption);
16
-
17
12
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
18
13
  args[_key] = arguments[_key];
19
14
  }
20
-
21
15
  _this = _super.call.apply(_super, [this].concat(args));
22
-
23
16
  _this.onDeleteOption = function (event) {
24
17
  event.nativeEvent.stopImmediatePropagation();
25
18
  event.stopPropagation();
26
-
27
19
  _this.props.onDeleteSelectOption(_this.props.option);
28
20
  };
29
-
30
21
  _this.getContainerStyle = function () {
31
22
  var option = _this.props.option;
32
23
  return {
@@ -40,7 +31,6 @@ var SelectEditorOption = /*#__PURE__*/function (_React$Component) {
40
31
  backgroundColor: option.color
41
32
  };
42
33
  };
43
-
44
34
  _this.getOptionStyle = function (option) {
45
35
  var textColor = option.textColor || null;
46
36
  return {
@@ -51,7 +41,6 @@ var SelectEditorOption = /*#__PURE__*/function (_React$Component) {
51
41
  color: textColor
52
42
  };
53
43
  };
54
-
55
44
  _this.getOperationStyle = function (option) {
56
45
  var textColor = option.textColor || null;
57
46
  return {
@@ -62,16 +51,14 @@ var SelectEditorOption = /*#__PURE__*/function (_React$Component) {
62
51
  transform: 'scale(.8)'
63
52
  };
64
53
  };
65
-
66
54
  return _this;
67
55
  }
68
-
69
56
  _createClass(SelectEditorOption, [{
70
57
  key: "render",
71
58
  value: function render() {
72
59
  var _this$props = this.props,
73
- option = _this$props.option,
74
- isShowRemoveIcon = _this$props.isShowRemoveIcon;
60
+ option = _this$props.option,
61
+ isShowRemoveIcon = _this$props.isShowRemoveIcon;
75
62
  var containerStyle = this.getContainerStyle();
76
63
  var optionStyle = this.getOptionStyle(option);
77
64
  var operationStyle = this.getOperationStyle(option);
@@ -97,10 +84,8 @@ var SelectEditorOption = /*#__PURE__*/function (_React$Component) {
97
84
  })));
98
85
  }
99
86
  }]);
100
-
101
87
  return SelectEditorOption;
102
88
  }(React.Component);
103
-
104
89
  SelectEditorOption.defaultProps = {
105
90
  isShowRemoveIcon: false
106
91
  };
@@ -4,17 +4,12 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import { css } from 'glamor';
7
-
8
7
  var Alert = /*#__PURE__*/function (_React$PureComponent) {
9
8
  _inherits(Alert, _React$PureComponent);
10
-
11
9
  var _super = _createSuper(Alert);
12
-
13
10
  function Alert(props) {
14
11
  var _this;
15
-
16
12
  _classCallCheck(this, Alert);
17
-
18
13
  _this = _super.call(this, props);
19
14
  _this.containerStyle = css({
20
15
  borderRadius: '3px',
@@ -72,7 +67,6 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
72
67
  });
73
68
  return _this;
74
69
  }
75
-
76
70
  _createClass(Alert, [{
77
71
  key: "getContainerStyle",
78
72
  value: function getContainerStyle(intent) {
@@ -85,7 +79,6 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
85
79
  }),
86
80
  iconClass: 'dtable-font dtable-icon-check-circle'
87
81
  };
88
-
89
82
  case 'warning':
90
83
  return {
91
84
  borderStyle: this.containerBorderWarn,
@@ -94,7 +87,6 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
94
87
  }),
95
88
  iconClass: 'dtable-font dtable-icon-exclamation-triangle'
96
89
  };
97
-
98
90
  case 'none':
99
91
  return {
100
92
  borderStyle: this.containerBorderNotify,
@@ -103,7 +95,6 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
103
95
  }),
104
96
  iconClass: 'dtable-font dtable-icon-exclamation-circle'
105
97
  };
106
-
107
98
  case 'danger':
108
99
  return {
109
100
  borderStyle: this.containerBorderDanger,
@@ -112,7 +103,6 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
112
103
  }),
113
104
  iconClass: 'dtable-font dtable-icon-exclamation-circle'
114
105
  };
115
-
116
106
  default:
117
107
  return {
118
108
  borderStyle: this.containerBorderSuccess,
@@ -143,8 +133,6 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
143
133
  }, /*#__PURE__*/React.createElement("span", null, "\xD7")));
144
134
  }
145
135
  }]);
146
-
147
136
  return Alert;
148
137
  }(React.PureComponent);
149
-
150
138
  export default Alert;
@@ -44,40 +44,30 @@ var animationStyles = css({
44
44
  animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
45
45
  }
46
46
  });
47
-
48
47
  var Toast = /*#__PURE__*/function (_React$PureComponent) {
49
48
  _inherits(Toast, _React$PureComponent);
50
-
51
49
  var _super = _createSuper(Toast);
52
-
53
50
  function Toast() {
54
51
  var _this;
55
-
56
52
  _classCallCheck(this, Toast);
57
-
58
53
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
59
54
  args[_key] = arguments[_key];
60
55
  }
61
-
62
56
  _this = _super.call.apply(_super, [this].concat(args));
63
57
  _this.state = {
64
58
  isShown: true,
65
59
  height: 0
66
60
  };
67
-
68
61
  _this.close = function (event) {
69
62
  if (event) {
70
63
  event.nativeEvent.stopImmediatePropagation();
71
64
  event.stopPropagation();
72
65
  }
73
-
74
66
  _this.clearCloseTimer();
75
-
76
67
  _this.setState({
77
68
  isShown: false
78
69
  });
79
70
  };
80
-
81
71
  _this.startCloseTimer = function () {
82
72
  if (_this.props.duration) {
83
73
  _this.closeTimer = setTimeout(function () {
@@ -85,36 +75,28 @@ var Toast = /*#__PURE__*/function (_React$PureComponent) {
85
75
  }, _this.props.duration * 1000);
86
76
  }
87
77
  };
88
-
89
78
  _this.clearCloseTimer = function () {
90
79
  if (_this.closeTimer) {
91
80
  clearTimeout(_this.closeTimer);
92
81
  _this.closeTimer = null;
93
82
  }
94
83
  };
95
-
96
84
  _this.handleMouseEnter = function () {
97
85
  _this.clearCloseTimer();
98
86
  };
99
-
100
87
  _this.handleMouseLeave = function () {
101
88
  _this.startCloseTimer();
102
89
  };
103
-
104
90
  _this.onRef = function (ref) {
105
91
  if (ref === null) return;
106
-
107
92
  var _ref$getBoundingClien = ref.getBoundingClientRect(),
108
- height = _ref$getBoundingClien.height;
109
-
93
+ height = _ref$getBoundingClien.height;
110
94
  _this.setState({
111
95
  height: height
112
96
  });
113
97
  };
114
-
115
98
  return _this;
116
99
  }
117
-
118
100
  _createClass(Toast, [{
119
101
  key: "componentDidUpdate",
120
102
  value: function componentDidUpdate(prevProps) {
@@ -139,7 +121,6 @@ var Toast = /*#__PURE__*/function (_React$PureComponent) {
139
121
  key: "render",
140
122
  value: function render() {
141
123
  var _this2 = this;
142
-
143
124
  return /*#__PURE__*/React.createElement(Transition, {
144
125
  appear: true,
145
126
  unmountOnExit: true,
@@ -174,10 +155,8 @@ var Toast = /*#__PURE__*/function (_React$PureComponent) {
174
155
  });
175
156
  }
176
157
  }]);
177
-
178
158
  return Toast;
179
159
  }(React.PureComponent);
180
-
181
160
  Toast.defaultProps = {
182
161
  intent: 'none'
183
162
  };
@@ -19,43 +19,32 @@ var wrapperClass = css({
19
19
  position: 'fixed',
20
20
  zIndex: 999999
21
21
  });
22
-
23
22
  var hasCustomId = function hasCustomId(settings) {
24
23
  return Object.hasOwnProperty.call(settings, 'id');
25
24
  };
26
-
27
25
  var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
28
26
  _inherits(ToastManager, _React$PureComponent);
29
-
30
27
  var _super = _createSuper(ToastManager);
31
-
32
28
  function ToastManager(props, context) {
33
29
  var _this;
34
-
35
30
  _classCallCheck(this, ToastManager);
36
-
37
31
  _this = _super.call(this, props, context);
38
-
39
32
  _this.getToasts = function () {
40
33
  return _this.state.toasts;
41
34
  };
42
-
43
35
  _this.closeAll = function () {
44
36
  _this.getToasts().forEach(function (toast) {
45
37
  return toast.close();
46
38
  });
47
39
  };
48
-
49
40
  _this.notify = function (title, settings) {
50
41
  // If there's a custom toast ID passed, close existing toasts with the same custom ID
51
42
  if (hasCustomId(settings)) {
52
43
  var _iterator = _createForOfIteratorHelper(_this.state.toasts),
53
- _step;
54
-
44
+ _step;
55
45
  try {
56
46
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
57
47
  var toast = _step.value;
58
-
59
48
  // Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
60
49
  if (String(toast.id).startsWith(settings.id)) {
61
50
  _this.closeToast(toast.id);
@@ -67,32 +56,25 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
67
56
  _iterator.f();
68
57
  }
69
58
  }
70
-
71
59
  var instance = _this.createToastInstance(title, settings);
72
-
73
60
  _this.setState(function (previousState) {
74
61
  return {
75
62
  toasts: [instance].concat(_toConsumableArray(previousState.toasts))
76
63
  };
77
64
  });
78
-
79
65
  return instance;
80
66
  };
81
-
82
67
  _this.createToastInstance = function (title, settings) {
83
68
  var uniqueId = ++ToastManager.idCounter;
84
69
  var id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
85
70
  var hasCloseButton = settings.hasCloseButton || true;
86
71
  var duration = settings.duration || 2;
87
-
88
72
  if (settings.hasCloseButton !== undefined) {
89
73
  hasCloseButton = settings.hasCloseButton;
90
74
  }
91
-
92
75
  if (settings.duration !== undefined) {
93
76
  duration = settings.duration;
94
77
  }
95
-
96
78
  return {
97
79
  id: id,
98
80
  title: title,
@@ -105,7 +87,10 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
105
87
  intent: settings.intent
106
88
  };
107
89
  };
108
-
90
+ /**
91
+ * This will set isShown on the Toast which will close the toast.
92
+ * It won't remove the toast until onExited triggers onRemove.
93
+ */
109
94
  _this.closeToast = function (id) {
110
95
  _this.setState(function (previousState) {
111
96
  return {
@@ -115,13 +100,11 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
115
100
  isShown: false
116
101
  });
117
102
  }
118
-
119
103
  return toast;
120
104
  })
121
105
  };
122
106
  });
123
107
  };
124
-
125
108
  _this.removeToast = function (id) {
126
109
  _this.setState(function (previousState) {
127
110
  return {
@@ -131,7 +114,6 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
131
114
  };
132
115
  });
133
116
  };
134
-
135
117
  props.bindNotify(_this.notify);
136
118
  props.bindGetToasts(_this.getToasts);
137
119
  props.bindCloseAll(_this.closeAll);
@@ -140,19 +122,16 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
140
122
  };
141
123
  return _this;
142
124
  }
143
-
144
125
  _createClass(ToastManager, [{
145
126
  key: "render",
146
127
  value: function render() {
147
128
  var _this2 = this;
148
-
149
129
  return /*#__PURE__*/React.createElement("span", {
150
130
  className: wrapperClass
151
131
  }, this.state.toasts.map(function (_ref) {
152
132
  var id = _ref.id,
153
- description = _ref.description,
154
- props = _objectWithoutProperties(_ref, _excluded);
155
-
133
+ description = _ref.description,
134
+ props = _objectWithoutProperties(_ref, _excluded);
156
135
  return /*#__PURE__*/React.createElement(Toast, Object.assign({
157
136
  key: id,
158
137
  onRemove: function onRemove() {
@@ -162,9 +141,7 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
162
141
  }));
163
142
  }
164
143
  }]);
165
-
166
144
  return ToastManager;
167
145
  }(React.PureComponent);
168
-
169
146
  ToastManager.idCounter = 0;
170
147
  export { ToastManager as default };