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,17 +1,9 @@
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 { css } from 'glamor';
7
- var Alert = /*#__PURE__*/function (_React$PureComponent) {
8
- _inherits(Alert, _React$PureComponent);
9
- var _super = _createSuper(Alert);
10
- function Alert(props) {
11
- var _this;
12
- _classCallCheck(this, Alert);
13
- _this = _super.call(this, props);
14
- _this.containerStyle = css({
3
+ class Alert extends React.PureComponent {
4
+ constructor(props) {
5
+ super(props);
6
+ this.containerStyle = css({
15
7
  borderRadius: '3px',
16
8
  backgroundColor: '#fff',
17
9
  padding: '10px 16px',
@@ -21,30 +13,30 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
21
13
  justifyContent: 'space-between',
22
14
  flexDirection: 'row'
23
15
  });
24
- _this.containerBorderSuccess = css({
16
+ this.containerBorderSuccess = css({
25
17
  borderLeft: '3px solid rgb(71, 184, 129)'
26
18
  });
27
- _this.containerBorderWarn = css({
19
+ this.containerBorderWarn = css({
28
20
  borderLeft: '3px solid rgb(217, 130, 43)'
29
21
  });
30
- _this.containerBorderDanger = css({
22
+ this.containerBorderDanger = css({
31
23
  borderLeft: '3px solid rgb(236, 76, 71)'
32
24
  });
33
- _this.containerBorderNotify = css({
25
+ this.containerBorderNotify = css({
34
26
  borderLeft: '3px solid rgb(16, 112, 202)'
35
27
  });
36
- _this.toastTextTitle = css({
28
+ this.toastTextTitle = css({
37
29
  fontWeight: '600',
38
30
  fontSize: '14px',
39
31
  color: '#435a6f',
40
32
  margin: '0'
41
33
  });
42
- _this.toastTextChild = css({
34
+ this.toastTextChild = css({
43
35
  fontSize: '14px',
44
36
  color: '#999',
45
37
  margin: '0'
46
38
  });
47
- _this.toastClose = css({
39
+ this.toastClose = css({
48
40
  marginLeft: '15px',
49
41
  height: '24px',
50
42
  width: '24px',
@@ -59,80 +51,73 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
59
51
  opacity: 1
60
52
  }
61
53
  });
62
- _this.toastIcon = css({
54
+ this.toastIcon = css({
63
55
  marginRight: '10px',
64
56
  width: '14px',
65
57
  height: '20px',
66
58
  lineHeight: '20px'
67
59
  });
68
- return _this;
69
60
  }
70
- _createClass(Alert, [{
71
- key: "getContainerStyle",
72
- value: function getContainerStyle(intent) {
73
- switch (intent) {
74
- case 'success':
75
- return {
76
- borderStyle: this.containerBorderSuccess,
77
- iconColor: css({
78
- color: 'rgb(71, 184, 129)'
79
- }),
80
- iconClass: 'dtable-font dtable-icon-check-circle'
81
- };
82
- case 'warning':
83
- return {
84
- borderStyle: this.containerBorderWarn,
85
- iconColor: css({
86
- color: 'rgb(217, 130, 43)'
87
- }),
88
- iconClass: 'dtable-font dtable-icon-exclamation-triangle'
89
- };
90
- case 'none':
91
- return {
92
- borderStyle: this.containerBorderNotify,
93
- iconColor: css({
94
- color: 'rgb(16, 112, 202)'
95
- }),
96
- iconClass: 'dtable-font dtable-icon-exclamation-circle'
97
- };
98
- case 'danger':
99
- return {
100
- borderStyle: this.containerBorderDanger,
101
- iconColor: css({
102
- color: 'rgb(236, 76, 71)'
103
- }),
104
- iconClass: 'dtable-font dtable-icon-exclamation-circle'
105
- };
106
- default:
107
- return {
108
- borderStyle: this.containerBorderSuccess,
109
- iconColor: css({
110
- color: 'rgb(71, 184, 129)'
111
- }),
112
- iconClass: 'dtable-font dtable-icon-check-circle'
113
- };
114
- }
115
- }
116
- }, {
117
- key: "render",
118
- value: function render() {
119
- var toastStyle = this.getContainerStyle(this.props.intent);
120
- return /*#__PURE__*/React.createElement("div", css(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/React.createElement("div", {
121
- className: this.toastIcon
122
- }, /*#__PURE__*/React.createElement("i", Object.assign({
123
- className: toastStyle.iconClass
124
- }, toastStyle.iconColor))), /*#__PURE__*/React.createElement("div", {
125
- className: this.toastTextContainer
126
- }, /*#__PURE__*/React.createElement("p", {
127
- className: this.toastTextTitle
128
- }, this.props.title), this.props.children ? /*#__PURE__*/React.createElement("p", {
129
- className: this.toastTextChild
130
- }, this.props.children) : null), this.props.isRemoveable && /*#__PURE__*/React.createElement("div", {
131
- onClick: this.props.onRemove,
132
- className: this.toastClose
133
- }, /*#__PURE__*/React.createElement("span", null, "\xD7")));
61
+ getContainerStyle(intent) {
62
+ switch (intent) {
63
+ case 'success':
64
+ return {
65
+ borderStyle: this.containerBorderSuccess,
66
+ iconColor: css({
67
+ color: 'rgb(71, 184, 129)'
68
+ }),
69
+ iconClass: 'dtable-font dtable-icon-check-circle'
70
+ };
71
+ case 'warning':
72
+ return {
73
+ borderStyle: this.containerBorderWarn,
74
+ iconColor: css({
75
+ color: 'rgb(217, 130, 43)'
76
+ }),
77
+ iconClass: 'dtable-font dtable-icon-exclamation-triangle'
78
+ };
79
+ case 'none':
80
+ return {
81
+ borderStyle: this.containerBorderNotify,
82
+ iconColor: css({
83
+ color: 'rgb(16, 112, 202)'
84
+ }),
85
+ iconClass: 'dtable-font dtable-icon-exclamation-circle'
86
+ };
87
+ case 'danger':
88
+ return {
89
+ borderStyle: this.containerBorderDanger,
90
+ iconColor: css({
91
+ color: 'rgb(236, 76, 71)'
92
+ }),
93
+ iconClass: 'dtable-font dtable-icon-exclamation-circle'
94
+ };
95
+ default:
96
+ return {
97
+ borderStyle: this.containerBorderSuccess,
98
+ iconColor: css({
99
+ color: 'rgb(71, 184, 129)'
100
+ }),
101
+ iconClass: 'dtable-font dtable-icon-check-circle'
102
+ };
134
103
  }
135
- }]);
136
- return Alert;
137
- }(React.PureComponent);
104
+ }
105
+ render() {
106
+ const toastStyle = this.getContainerStyle(this.props.intent);
107
+ return /*#__PURE__*/React.createElement("div", css(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/React.createElement("div", {
108
+ className: this.toastIcon
109
+ }, /*#__PURE__*/React.createElement("i", Object.assign({
110
+ className: toastStyle.iconClass
111
+ }, toastStyle.iconColor))), /*#__PURE__*/React.createElement("div", {
112
+ className: this.toastTextContainer
113
+ }, /*#__PURE__*/React.createElement("p", {
114
+ className: this.toastTextTitle
115
+ }, this.props.title), this.props.children ? /*#__PURE__*/React.createElement("p", {
116
+ className: this.toastTextChild
117
+ }, this.props.children) : null), this.props.isRemoveable && /*#__PURE__*/React.createElement("div", {
118
+ onClick: this.props.onRemove,
119
+ className: this.toastClose
120
+ }, /*#__PURE__*/React.createElement("span", null, "\xD7")));
121
+ }
122
+ }
138
123
  export default Alert;
@@ -1,3 +1,3 @@
1
1
  import Toaster from './toaster';
2
- var toaster = new Toaster();
2
+ const toaster = new Toaster();
3
3
  export default toaster;
@@ -1,18 +1,14 @@
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 { css } from 'glamor';
7
3
  import Transition from 'react-transition-group/Transition';
8
4
  import Alert from './alert';
9
- var animationEasing = {
5
+ const animationEasing = {
10
6
  deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
11
7
  acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
12
8
  spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
13
9
  };
14
- var ANIMATION_DURATION = 240;
15
- var openAnimation = css.keyframes('openAnimation', {
10
+ const ANIMATION_DURATION = 240;
11
+ const openAnimation = css.keyframes('openAnimation', {
16
12
  from: {
17
13
  opacity: 0,
18
14
  transform: 'translateY(-120%)'
@@ -21,7 +17,7 @@ var openAnimation = css.keyframes('openAnimation', {
21
17
  transform: 'translateY(0)'
22
18
  }
23
19
  });
24
- var closeAnimation = css.keyframes('closeAnimation', {
20
+ const closeAnimation = css.keyframes('closeAnimation', {
25
21
  from: {
26
22
  transform: 'scale(1)',
27
23
  opacity: 1
@@ -31,7 +27,7 @@ var closeAnimation = css.keyframes('closeAnimation', {
31
27
  opacity: 0
32
28
  }
33
29
  });
34
- var animationStyles = css({
30
+ const animationStyles = css({
35
31
  display: 'flex',
36
32
  flexDirection: 'column',
37
33
  alignItems: 'center',
@@ -44,120 +40,97 @@ var animationStyles = css({
44
40
  animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
45
41
  }
46
42
  });
47
- var Toast = /*#__PURE__*/function (_React$PureComponent) {
48
- _inherits(Toast, _React$PureComponent);
49
- var _super = _createSuper(Toast);
50
- function Toast() {
51
- var _this;
52
- _classCallCheck(this, Toast);
53
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
54
- args[_key] = arguments[_key];
55
- }
56
- _this = _super.call.apply(_super, [this].concat(args));
57
- _this.state = {
43
+ export default class Toast extends React.PureComponent {
44
+ constructor() {
45
+ super(...arguments);
46
+ this.state = {
58
47
  isShown: true,
59
48
  height: 0
60
49
  };
61
- _this.close = function (event) {
50
+ this.close = event => {
62
51
  if (event) {
63
52
  event.nativeEvent.stopImmediatePropagation();
64
53
  event.stopPropagation();
65
54
  }
66
- _this.clearCloseTimer();
67
- _this.setState({
55
+ this.clearCloseTimer();
56
+ this.setState({
68
57
  isShown: false
69
58
  });
70
59
  };
71
- _this.startCloseTimer = function () {
72
- if (_this.props.duration) {
73
- _this.closeTimer = setTimeout(function () {
74
- _this.close();
75
- }, _this.props.duration * 1000);
60
+ this.startCloseTimer = () => {
61
+ if (this.props.duration) {
62
+ this.closeTimer = setTimeout(() => {
63
+ this.close();
64
+ }, this.props.duration * 1000);
76
65
  }
77
66
  };
78
- _this.clearCloseTimer = function () {
79
- if (_this.closeTimer) {
80
- clearTimeout(_this.closeTimer);
81
- _this.closeTimer = null;
67
+ this.clearCloseTimer = () => {
68
+ if (this.closeTimer) {
69
+ clearTimeout(this.closeTimer);
70
+ this.closeTimer = null;
82
71
  }
83
72
  };
84
- _this.handleMouseEnter = function () {
85
- _this.clearCloseTimer();
73
+ this.handleMouseEnter = () => {
74
+ this.clearCloseTimer();
86
75
  };
87
- _this.handleMouseLeave = function () {
88
- _this.startCloseTimer();
76
+ this.handleMouseLeave = () => {
77
+ this.startCloseTimer();
89
78
  };
90
- _this.onRef = function (ref) {
79
+ this.onRef = ref => {
91
80
  if (ref === null) return;
92
- var _ref$getBoundingClien = ref.getBoundingClientRect(),
93
- height = _ref$getBoundingClien.height;
94
- _this.setState({
95
- height: height
81
+ const {
82
+ height
83
+ } = ref.getBoundingClientRect();
84
+ this.setState({
85
+ height
96
86
  });
97
87
  };
98
- return _this;
99
88
  }
100
- _createClass(Toast, [{
101
- key: "componentDidUpdate",
102
- value: function componentDidUpdate(prevProps) {
103
- if (prevProps.isShown !== this.props.isShown) {
104
- // eslint-disable-next-line react/no-did-update-set-state
105
- this.setState({
106
- isShown: this.props.isShown
107
- });
108
- }
109
- }
110
- }, {
111
- key: "componentDidMount",
112
- value: function componentDidMount() {
113
- this.startCloseTimer();
114
- }
115
- }, {
116
- key: "componentWillUnmount",
117
- value: function componentWillUnmount() {
118
- this.clearCloseTimer();
119
- }
120
- }, {
121
- key: "render",
122
- value: function render() {
123
- var _this2 = this;
124
- return /*#__PURE__*/React.createElement(Transition, {
125
- appear: true,
126
- unmountOnExit: true,
127
- timeout: ANIMATION_DURATION,
128
- in: this.state.isShown,
129
- onExited: this.props.onRemove
130
- }, function (state) {
131
- return /*#__PURE__*/React.createElement("div", {
132
- "data-state": state,
133
- className: animationStyles,
134
- onMouseEnter: _this2.handleMouseEnter,
135
- onMouseLeave: _this2.handleMouseLeave,
136
- style: {
137
- height: _this2.state.height,
138
- zIndex: _this2.props.zIndex,
139
- marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
140
- }
141
- }, /*#__PURE__*/React.createElement("div", {
142
- ref: _this2.onRef,
143
- style: {
144
- padding: 8
145
- }
146
- }, /*#__PURE__*/React.createElement(Alert, {
147
- intent: _this2.props.intent,
148
- title: _this2.props.title,
149
- children: _this2.props.children || '',
150
- isRemoveable: _this2.props.hasCloseButton,
151
- onRemove: function onRemove(event) {
152
- return _this2.close(event);
153
- }
154
- })));
89
+ componentDidUpdate(prevProps) {
90
+ if (prevProps.isShown !== this.props.isShown) {
91
+ // eslint-disable-next-line react/no-did-update-set-state
92
+ this.setState({
93
+ isShown: this.props.isShown
155
94
  });
156
95
  }
157
- }]);
158
- return Toast;
159
- }(React.PureComponent);
96
+ }
97
+ componentDidMount() {
98
+ this.startCloseTimer();
99
+ }
100
+ componentWillUnmount() {
101
+ this.clearCloseTimer();
102
+ }
103
+ render() {
104
+ return /*#__PURE__*/React.createElement(Transition, {
105
+ appear: true,
106
+ unmountOnExit: true,
107
+ timeout: ANIMATION_DURATION,
108
+ in: this.state.isShown,
109
+ onExited: this.props.onRemove
110
+ }, state => /*#__PURE__*/React.createElement("div", {
111
+ "data-state": state,
112
+ className: animationStyles,
113
+ onMouseEnter: this.handleMouseEnter,
114
+ onMouseLeave: this.handleMouseLeave,
115
+ style: {
116
+ height: this.state.height,
117
+ zIndex: this.props.zIndex,
118
+ marginBottom: this.state.isShown ? 0 : -this.state.height
119
+ }
120
+ }, /*#__PURE__*/React.createElement("div", {
121
+ ref: this.onRef,
122
+ style: {
123
+ padding: 8
124
+ }
125
+ }, /*#__PURE__*/React.createElement(Alert, {
126
+ intent: this.props.intent,
127
+ title: this.props.title,
128
+ children: this.props.children || '',
129
+ isRemoveable: this.props.hasCloseButton,
130
+ onRemove: event => this.close(event)
131
+ }))));
132
+ }
133
+ }
160
134
  Toast.defaultProps = {
161
135
  intent: 'none'
162
- };
163
- export { Toast as default };
136
+ };
@@ -1,16 +1,7 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
5
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
- import _createClass from "@babel/runtime/helpers/esm/createClass";
7
- import _inherits from "@babel/runtime/helpers/esm/inherits";
8
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
9
- var _excluded = ["id", "description"];
10
1
  import React from 'react';
11
2
  import { css } from 'glamor';
12
3
  import Toast from './toast';
13
- var wrapperClass = css({
4
+ const wrapperClass = css({
14
5
  maxWidth: 560,
15
6
  margin: '0 auto',
16
7
  top: 0,
@@ -19,56 +10,39 @@ var wrapperClass = css({
19
10
  position: 'fixed',
20
11
  zIndex: 999999
21
12
  });
22
- var hasCustomId = function hasCustomId(settings) {
23
- return Object.hasOwnProperty.call(settings, 'id');
24
- };
25
- var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
26
- _inherits(ToastManager, _React$PureComponent);
27
- var _super = _createSuper(ToastManager);
28
- function ToastManager(props, context) {
29
- var _this;
30
- _classCallCheck(this, ToastManager);
31
- _this = _super.call(this, props, context);
32
- _this.getToasts = function () {
33
- return _this.state.toasts;
13
+ const hasCustomId = settings => Object.hasOwnProperty.call(settings, 'id');
14
+ export default class ToastManager extends React.PureComponent {
15
+ constructor(props, context) {
16
+ super(props, context);
17
+ this.getToasts = () => {
18
+ return this.state.toasts;
34
19
  };
35
- _this.closeAll = function () {
36
- _this.getToasts().forEach(function (toast) {
37
- return toast.close();
38
- });
20
+ this.closeAll = () => {
21
+ this.getToasts().forEach(toast => toast.close());
39
22
  };
40
- _this.notify = function (title, settings) {
23
+ this.notify = (title, settings) => {
41
24
  // If there's a custom toast ID passed, close existing toasts with the same custom ID
42
25
  if (hasCustomId(settings)) {
43
- var _iterator = _createForOfIteratorHelper(_this.state.toasts),
44
- _step;
45
- try {
46
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
47
- var toast = _step.value;
48
- // Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
49
- if (String(toast.id).startsWith(settings.id)) {
50
- _this.closeToast(toast.id);
51
- }
26
+ for (const toast of this.state.toasts) {
27
+ // Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
28
+ if (String(toast.id).startsWith(settings.id)) {
29
+ this.closeToast(toast.id);
52
30
  }
53
- } catch (err) {
54
- _iterator.e(err);
55
- } finally {
56
- _iterator.f();
57
31
  }
58
32
  }
59
- var instance = _this.createToastInstance(title, settings);
60
- _this.setState(function (previousState) {
33
+ const instance = this.createToastInstance(title, settings);
34
+ this.setState(previousState => {
61
35
  return {
62
- toasts: [instance].concat(_toConsumableArray(previousState.toasts))
36
+ toasts: [instance, ...previousState.toasts]
63
37
  };
64
38
  });
65
39
  return instance;
66
40
  };
67
- _this.createToastInstance = function (title, settings) {
68
- var uniqueId = ++ToastManager.idCounter;
69
- var id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
70
- var hasCloseButton = settings.hasCloseButton || true;
71
- var duration = settings.duration || 2;
41
+ this.createToastInstance = (title, settings) => {
42
+ const uniqueId = ++ToastManager.idCounter;
43
+ const id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
44
+ let hasCloseButton = settings.hasCloseButton || true;
45
+ let duration = settings.duration || 2;
72
46
  if (settings.hasCloseButton !== undefined) {
73
47
  hasCloseButton = settings.hasCloseButton;
74
48
  }
@@ -76,14 +50,12 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
76
50
  duration = settings.duration;
77
51
  }
78
52
  return {
79
- id: id,
80
- title: title,
53
+ id,
54
+ title,
81
55
  description: settings.description,
82
56
  hasCloseButton: hasCloseButton,
83
57
  duration: duration,
84
- close: function close() {
85
- return _this.closeToast(id);
86
- },
58
+ close: () => this.closeToast(id),
87
59
  intent: settings.intent
88
60
  };
89
61
  };
@@ -91,57 +63,49 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
91
63
  * This will set isShown on the Toast which will close the toast.
92
64
  * It won't remove the toast until onExited triggers onRemove.
93
65
  */
94
- _this.closeToast = function (id) {
95
- _this.setState(function (previousState) {
66
+ this.closeToast = id => {
67
+ this.setState(previousState => {
96
68
  return {
97
- toasts: previousState.toasts.map(function (toast) {
69
+ toasts: previousState.toasts.map(toast => {
98
70
  if (toast.id === id) {
99
- return _objectSpread(_objectSpread({}, toast), {}, {
71
+ return {
72
+ ...toast,
100
73
  isShown: false
101
- });
74
+ };
102
75
  }
103
76
  return toast;
104
77
  })
105
78
  };
106
79
  });
107
80
  };
108
- _this.removeToast = function (id) {
109
- _this.setState(function (previousState) {
81
+ this.removeToast = id => {
82
+ this.setState(previousState => {
110
83
  return {
111
- toasts: previousState.toasts.filter(function (toast) {
112
- return toast.id !== id;
113
- })
84
+ toasts: previousState.toasts.filter(toast => toast.id !== id)
114
85
  };
115
86
  });
116
87
  };
117
- props.bindNotify(_this.notify);
118
- props.bindGetToasts(_this.getToasts);
119
- props.bindCloseAll(_this.closeAll);
120
- _this.state = {
88
+ props.bindNotify(this.notify);
89
+ props.bindGetToasts(this.getToasts);
90
+ props.bindCloseAll(this.closeAll);
91
+ this.state = {
121
92
  toasts: []
122
93
  };
123
- return _this;
124
94
  }
125
- _createClass(ToastManager, [{
126
- key: "render",
127
- value: function render() {
128
- var _this2 = this;
129
- return /*#__PURE__*/React.createElement("span", {
130
- className: wrapperClass
131
- }, this.state.toasts.map(function (_ref) {
132
- var id = _ref.id,
133
- description = _ref.description,
134
- props = _objectWithoutProperties(_ref, _excluded);
135
- return /*#__PURE__*/React.createElement(Toast, Object.assign({
136
- key: id,
137
- onRemove: function onRemove() {
138
- return _this2.removeToast(id);
139
- }
140
- }, props), description);
141
- }));
142
- }
143
- }]);
144
- return ToastManager;
145
- }(React.PureComponent);
146
- ToastManager.idCounter = 0;
147
- export { ToastManager as default };
95
+ render() {
96
+ return /*#__PURE__*/React.createElement("span", {
97
+ className: wrapperClass
98
+ }, this.state.toasts.map(_ref => {
99
+ let {
100
+ id,
101
+ description,
102
+ ...props
103
+ } = _ref;
104
+ return /*#__PURE__*/React.createElement(Toast, Object.assign({
105
+ key: id,
106
+ onRemove: () => this.removeToast(id)
107
+ }, props), description);
108
+ }));
109
+ }
110
+ }
111
+ ToastManager.idCounter = 0;