dtable-ui-component 0.1.75-beta3 → 0.1.75-beta4

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 (223) hide show
  1. package/lib/AutoNumberFormatter/index.js +27 -38
  2. package/lib/ButtonFormatter/index.js +47 -59
  3. package/lib/CTimeFormatter/index.js +39 -53
  4. package/lib/CheckboxFormatter/index.js +35 -48
  5. package/lib/CollaboratorFormatter/index.js +42 -64
  6. package/lib/CollaboratorItem/index.js +44 -61
  7. package/lib/CreatorFormatter/index.js +42 -62
  8. package/lib/DateFormatter/index.js +40 -55
  9. package/lib/DurationFormatter/index.js +29 -42
  10. package/lib/EmailFormatter/index.js +27 -38
  11. package/lib/FileFormatter/index.js +50 -65
  12. package/lib/FileItemFormatter/index.js +32 -44
  13. package/lib/FileUploader/index.js +34 -44
  14. package/lib/FormulaFormatter/index.js +81 -102
  15. package/lib/GeolocationFormatter/index.js +35 -50
  16. package/lib/ImageFormatter/images-lazy-load.js +73 -81
  17. package/lib/ImageFormatter/index.js +90 -109
  18. package/lib/ImagePreviewerLightbox/index.js +27 -60
  19. package/lib/LastModifierFormatter/index.js +42 -62
  20. package/lib/LinkFormatter/index.js +59 -80
  21. package/lib/Loading/index.js +4 -13
  22. package/lib/LongTextFormatter/html-long-text-formatter.js +49 -60
  23. package/lib/LongTextFormatter/index.js +9 -28
  24. package/lib/LongTextFormatter/simple-long-text-formatter.js +52 -58
  25. package/lib/MTimeFormatter/index.js +39 -53
  26. package/lib/ModalPortal/index.js +30 -37
  27. package/lib/MultipleSelectFormatter/index.js +39 -55
  28. package/lib/NumberFormatter/index.js +35 -50
  29. package/lib/RateFormatter/index.js +37 -52
  30. package/lib/SelectItem/index.js +31 -46
  31. package/lib/SingleSelectFormatter/index.js +38 -54
  32. package/lib/TextFormatter/index.js +31 -44
  33. package/lib/UrlFormatter/index.js +27 -38
  34. package/lib/app.js +75 -80
  35. package/lib/cellFormatterFactory/index.js +17 -20
  36. package/lib/components/cell-editor/checkbox-editor.js +59 -66
  37. package/lib/components/cell-editor/collaborator-editor.js +113 -126
  38. package/lib/components/cell-editor/date-editor.js +99 -119
  39. package/lib/components/cell-editor/index.js +9 -40
  40. package/lib/components/cell-editor/link-editor.js +122 -140
  41. package/lib/components/cell-editor/multiple-select-editor.js +114 -127
  42. package/lib/components/cell-editor/number-editor.js +78 -86
  43. package/lib/components/cell-editor/single-select-editor.js +106 -120
  44. package/lib/components/cell-editor/text-editor.js +65 -72
  45. package/lib/components/cell-editor-dialog/pc-file-editor-dialog.js +31 -51
  46. package/lib/components/cell-editor-dialog/pc-files-addition/index.js +0 -1
  47. package/lib/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -1
  48. package/lib/components/cell-editor-dialog/pc-files-preview/index.js +0 -1
  49. package/lib/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -1
  50. package/lib/components/cell-editor-popover/mb-collaborator-editor-popover.js +105 -111
  51. package/lib/components/cell-editor-popover/mb-date-editor-popover.js +140 -157
  52. package/lib/components/cell-editor-popover/mb-link-editor-popover.js +103 -109
  53. package/lib/components/cell-editor-popover/mb-select-editor-popover.js +142 -155
  54. package/lib/components/cell-editor-popover/pc-collaborator-editor-popover.js +74 -89
  55. package/lib/components/cell-editor-popover/pc-date-editor-popover.js +88 -102
  56. package/lib/components/cell-editor-popover/pc-link-editor-popover.js +77 -91
  57. package/lib/components/cell-editor-popover/pc-select-editor-popover.js +91 -105
  58. package/lib/components/common/collaborator-item.js +43 -59
  59. package/lib/components/common/edit-editor-button.js +28 -39
  60. package/lib/components/common/link-editor-option.js +63 -71
  61. package/lib/components/common/mobile/mb-editor-header.js +39 -52
  62. package/lib/components/common/select-editor-option.js +58 -74
  63. package/lib/constants/cell-types.js +25 -54
  64. package/lib/constants/index.js +5 -28
  65. package/lib/formatterConfig/index.js +28 -59
  66. package/lib/index.js +31 -139
  67. package/lib/lang/index.js +11 -27
  68. package/lib/locals/de.js +1 -6
  69. package/lib/locals/en.js +1 -6
  70. package/lib/locals/fr.js +1 -6
  71. package/lib/locals/zh-CN.js +1 -6
  72. package/lib/toaster/alert.js +92 -106
  73. package/lib/toaster/index.js +3 -12
  74. package/lib/toaster/toast.js +103 -147
  75. package/lib/toaster/toastManager.js +78 -97
  76. package/lib/toaster/toaster.js +36 -52
  77. package/lib/utils/cell-value-validator.js +5 -9
  78. package/lib/utils/column-utils.js +5 -13
  79. package/lib/utils/editor-utils.js +3 -13
  80. package/lib/utils/markdown2html.js +1 -7
  81. package/lib/utils/normalize-long-text-value.js +1 -6
  82. package/lib/utils/number-precision.js +13 -31
  83. package/lib/utils/utils.js +8 -33
  84. package/lib/utils/value-format-utils.js +58 -108
  85. package/package.json +5 -5
  86. package/es/AutoNumberFormatter/index.css +0 -1
  87. package/es/AutoNumberFormatter/index.js +0 -36
  88. package/es/ButtonFormatter/index.css +0 -13
  89. package/es/ButtonFormatter/index.js +0 -56
  90. package/es/CTimeFormatter/index.css +0 -1
  91. package/es/CTimeFormatter/index.js +0 -58
  92. package/es/CheckboxFormatter/index.css +0 -1
  93. package/es/CheckboxFormatter/index.js +0 -45
  94. package/es/CollaboratorFormatter/index.css +0 -1
  95. package/es/CollaboratorFormatter/index.js +0 -91
  96. package/es/CollaboratorItem/index.css +0 -49
  97. package/es/CollaboratorItem/index.js +0 -64
  98. package/es/CreatorFormatter/index.css +0 -1
  99. package/es/CreatorFormatter/index.js +0 -87
  100. package/es/DateFormatter/index.css +0 -1
  101. package/es/DateFormatter/index.js +0 -60
  102. package/es/DurationFormatter/index.css +0 -1
  103. package/es/DurationFormatter/index.js +0 -38
  104. package/es/EmailFormatter/index.css +0 -5
  105. package/es/EmailFormatter/index.js +0 -36
  106. package/es/FileFormatter/index.css +0 -29
  107. package/es/FileFormatter/index.js +0 -64
  108. package/es/FileItemFormatter/index.js +0 -50
  109. package/es/FileUploader/index.js +0 -53
  110. package/es/FormulaFormatter/index.css +0 -19
  111. package/es/FormulaFormatter/index.js +0 -164
  112. package/es/GeolocationFormatter/index.css +0 -1
  113. package/es/GeolocationFormatter/index.js +0 -53
  114. package/es/ImageFormatter/images-lazy-load.js +0 -150
  115. package/es/ImageFormatter/index.css +0 -34
  116. package/es/ImageFormatter/index.js +0 -154
  117. package/es/ImagePreviewerLightbox/index.css +0 -87
  118. package/es/ImagePreviewerLightbox/index.js +0 -119
  119. package/es/LastModifierFormatter/index.css +0 -1
  120. package/es/LastModifierFormatter/index.js +0 -87
  121. package/es/LinkFormatter/index.css +0 -27
  122. package/es/LinkFormatter/index.js +0 -144
  123. package/es/Loading/index.css +0 -54
  124. package/es/Loading/index.js +0 -7
  125. package/es/LongTextFormatter/html-long-text-formatter.js +0 -96
  126. package/es/LongTextFormatter/index.css +0 -63
  127. package/es/LongTextFormatter/index.js +0 -29
  128. package/es/LongTextFormatter/simple-long-text-formatter.js +0 -104
  129. package/es/MTimeFormatter/index.css +0 -1
  130. package/es/MTimeFormatter/index.js +0 -58
  131. package/es/ModalPortal/index.js +0 -44
  132. package/es/MultipleSelectFormatter/index.css +0 -1
  133. package/es/MultipleSelectFormatter/index.js +0 -70
  134. package/es/NumberFormatter/index.css +0 -1
  135. package/es/NumberFormatter/index.js +0 -47
  136. package/es/RateFormatter/index.css +0 -1
  137. package/es/RateFormatter/index.js +0 -80
  138. package/es/SelectItem/index.js +0 -58
  139. package/es/SingleSelectFormatter/index.css +0 -1
  140. package/es/SingleSelectFormatter/index.js +0 -70
  141. package/es/TextFormatter/index.css +0 -1
  142. package/es/TextFormatter/index.js +0 -56
  143. package/es/UrlFormatter/index.css +0 -5
  144. package/es/UrlFormatter/index.js +0 -36
  145. package/es/app.css +0 -20
  146. package/es/app.js +0 -91
  147. package/es/assets/images/avatar/default_avatar.png +0 -0
  148. package/es/assets/images/file/192/excel.png +0 -0
  149. package/es/assets/images/file/192/file.png +0 -0
  150. package/es/assets/images/file/192/music.png +0 -0
  151. package/es/assets/images/file/192/pdf.png +0 -0
  152. package/es/assets/images/file/192/pic.png +0 -0
  153. package/es/assets/images/file/192/ppt.png +0 -0
  154. package/es/assets/images/file/192/txt.png +0 -0
  155. package/es/assets/images/file/192/video.png +0 -0
  156. package/es/assets/images/file/192/word.png +0 -0
  157. package/es/assets/images/file/24/excel.png +0 -0
  158. package/es/assets/images/file/24/file.png +0 -0
  159. package/es/assets/images/file/24/music.png +0 -0
  160. package/es/assets/images/file/24/pdf.png +0 -0
  161. package/es/assets/images/file/24/pic.png +0 -0
  162. package/es/assets/images/file/24/ppt.png +0 -0
  163. package/es/assets/images/file/24/txt.png +0 -0
  164. package/es/assets/images/file/24/video.png +0 -0
  165. package/es/assets/images/file/24/word.png +0 -0
  166. package/es/assets/images/folder/folder-192.png +0 -0
  167. package/es/assets/images/folder/folder-24.png +0 -0
  168. package/es/cellFormatterFactory/index.js +0 -25
  169. package/es/components/cell-editor/checkbox-editor.js +0 -104
  170. package/es/components/cell-editor/collaborator-editor.js +0 -236
  171. package/es/components/cell-editor/date-editor.js +0 -151
  172. package/es/components/cell-editor/index.js +0 -9
  173. package/es/components/cell-editor/link-editor.js +0 -303
  174. package/es/components/cell-editor/multiple-select-editor.js +0 -237
  175. package/es/components/cell-editor/number-editor.js +0 -154
  176. package/es/components/cell-editor/single-select-editor.js +0 -202
  177. package/es/components/cell-editor/text-editor.js +0 -122
  178. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
  179. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  180. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  181. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  182. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  183. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
  184. package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
  185. package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
  186. package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
  187. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
  188. package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
  189. package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
  190. package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
  191. package/es/components/common/collaborator-item.js +0 -63
  192. package/es/components/common/edit-editor-button.js +0 -56
  193. package/es/components/common/link-editor-option.js +0 -113
  194. package/es/components/common/mobile/mb-editor-header.js +0 -48
  195. package/es/components/common/select-editor-option.js +0 -106
  196. package/es/constants/cell-types.js +0 -25
  197. package/es/constants/index.js +0 -49
  198. package/es/css/cell-editor.css +0 -614
  199. package/es/css/cell-formatter.css +0 -4
  200. package/es/css/custom-rc-calendar.css +0 -118
  201. package/es/formatterConfig/index.js +0 -31
  202. package/es/index.js +0 -31
  203. package/es/lang/index.js +0 -50
  204. package/es/locals/de.js +0 -2
  205. package/es/locals/en.js +0 -17
  206. package/es/locals/fr.js +0 -2
  207. package/es/locals/zh-CN.js +0 -17
  208. package/es/toaster/alert.js +0 -150
  209. package/es/toaster/index.js +0 -3
  210. package/es/toaster/toast.js +0 -179
  211. package/es/toaster/toastManager.js +0 -170
  212. package/es/toaster/toaster.js +0 -76
  213. package/es/utils/cell-value-validator.js +0 -31
  214. package/es/utils/column-utils.js +0 -7
  215. package/es/utils/editor-utils.js +0 -71
  216. package/es/utils/markdown2html.js +0 -62
  217. package/es/utils/normalize-long-text-value.js +0 -69
  218. package/es/utils/number-precision.js +0 -164
  219. package/es/utils/unified/index.js +0 -470
  220. package/es/utils/utils.js +0 -116
  221. package/es/utils/value-format-utils.js +0 -497
  222. package/es/utils/vfile/core.js +0 -172
  223. package/es/utils/vfile/index.js +0 -48
@@ -1,34 +1,18 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.default = void 0;
7
-
8
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
9
-
10
- var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
- var _react = _interopRequireDefault(require("react"));
15
-
16
- var _glamor = require("glamor");
17
-
18
- var _propTypes = _interopRequireDefault(require("prop-types"));
19
-
20
- var _Transition = _interopRequireDefault(require("react-transition-group/Transition"));
21
-
22
- var _alert = _interopRequireDefault(require("./alert"));
23
-
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
+ import React from 'react';
6
+ import { css } from 'glamor';
7
+ import Transition from 'react-transition-group/Transition';
8
+ import Alert from './alert';
24
9
  var animationEasing = {
25
10
  deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
26
11
  acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
27
12
  spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
28
13
  };
29
14
  var ANIMATION_DURATION = 240;
30
-
31
- var openAnimation = _glamor.css.keyframes('openAnimation', {
15
+ var openAnimation = css.keyframes('openAnimation', {
32
16
  from: {
33
17
  opacity: 0,
34
18
  transform: 'translateY(-120%)'
@@ -37,8 +21,7 @@ var openAnimation = _glamor.css.keyframes('openAnimation', {
37
21
  transform: 'translateY(0)'
38
22
  }
39
23
  });
40
-
41
- var closeAnimation = _glamor.css.keyframes('closeAnimation', {
24
+ var closeAnimation = css.keyframes('closeAnimation', {
42
25
  from: {
43
26
  transform: 'scale(1)',
44
27
  opacity: 1
@@ -48,63 +31,72 @@ var closeAnimation = _glamor.css.keyframes('closeAnimation', {
48
31
  opacity: 0
49
32
  }
50
33
  });
51
-
52
- var animationStyles = (0, _glamor.css)({
34
+ var animationStyles = css({
53
35
  display: 'flex',
54
36
  flexDirection: 'column',
55
37
  alignItems: 'center',
56
38
  height: 0,
57
- transition: "all " + ANIMATION_DURATION + "ms " + animationEasing.deceleration,
39
+ transition: "all ".concat(ANIMATION_DURATION, "ms ").concat(animationEasing.deceleration),
58
40
  '&[data-state="entering"], &[data-state="entered"]': {
59
- animation: openAnimation + " " + ANIMATION_DURATION + "ms " + animationEasing.spring + " both"
41
+ animation: "".concat(openAnimation, " ").concat(ANIMATION_DURATION, "ms ").concat(animationEasing.spring, " both")
60
42
  },
61
43
  '&[data-state="exiting"]': {
62
- animation: closeAnimation + " 120ms " + animationEasing.acceleration + " both"
44
+ animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
63
45
  }
64
46
  });
65
47
 
66
48
  var Toast = /*#__PURE__*/function (_React$PureComponent) {
67
- (0, _inheritsLoose2.default)(Toast, _React$PureComponent);
49
+ _inherits(Toast, _React$PureComponent);
50
+
51
+ var _super = _createSuper(Toast);
68
52
 
69
53
  function Toast() {
70
54
  var _this;
71
55
 
56
+ _classCallCheck(this, Toast);
57
+
72
58
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
59
  args[_key] = arguments[_key];
74
60
  }
75
61
 
76
- _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
77
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
62
+ _this = _super.call.apply(_super, [this].concat(args));
63
+ _this.state = {
78
64
  isShown: true,
79
65
  height: 0
80
- });
81
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "close", function () {
66
+ };
67
+
68
+ _this.close = function () {
82
69
  _this.clearCloseTimer();
83
70
 
84
71
  _this.setState({
85
72
  isShown: false
86
73
  });
87
- });
88
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "startCloseTimer", function () {
74
+ };
75
+
76
+ _this.startCloseTimer = function () {
89
77
  if (_this.props.duration) {
90
78
  _this.closeTimer = setTimeout(function () {
91
79
  _this.close();
92
80
  }, _this.props.duration * 1000);
93
81
  }
94
- });
95
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearCloseTimer", function () {
82
+ };
83
+
84
+ _this.clearCloseTimer = function () {
96
85
  if (_this.closeTimer) {
97
86
  clearTimeout(_this.closeTimer);
98
87
  _this.closeTimer = null;
99
88
  }
100
- });
101
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMouseEnter", function () {
89
+ };
90
+
91
+ _this.handleMouseEnter = function () {
102
92
  _this.clearCloseTimer();
103
- });
104
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMouseLeave", function () {
93
+ };
94
+
95
+ _this.handleMouseLeave = function () {
105
96
  _this.startCloseTimer();
106
- });
107
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onRef", function (ref) {
97
+ };
98
+
99
+ _this.onRef = function (ref) {
108
100
  if (ref === null) return;
109
101
 
110
102
  var _ref$getBoundingClien = ref.getBoundingClientRect(),
@@ -113,111 +105,75 @@ var Toast = /*#__PURE__*/function (_React$PureComponent) {
113
105
  _this.setState({
114
106
  height: height
115
107
  });
116
- });
108
+ };
109
+
117
110
  return _this;
118
111
  }
119
112
 
120
- var _proto = Toast.prototype;
121
-
122
- _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
123
- if (prevProps.isShown !== this.props.isShown) {
124
- // eslint-disable-next-line react/no-did-update-set-state
125
- this.setState({
126
- isShown: this.props.isShown
113
+ _createClass(Toast, [{
114
+ key: "componentDidUpdate",
115
+ value: function componentDidUpdate(prevProps) {
116
+ if (prevProps.isShown !== this.props.isShown) {
117
+ // eslint-disable-next-line react/no-did-update-set-state
118
+ this.setState({
119
+ isShown: this.props.isShown
120
+ });
121
+ }
122
+ }
123
+ }, {
124
+ key: "componentDidMount",
125
+ value: function componentDidMount() {
126
+ this.startCloseTimer();
127
+ }
128
+ }, {
129
+ key: "componentWillUnmount",
130
+ value: function componentWillUnmount() {
131
+ this.clearCloseTimer();
132
+ }
133
+ }, {
134
+ key: "render",
135
+ value: function render() {
136
+ var _this2 = this;
137
+
138
+ return /*#__PURE__*/React.createElement(Transition, {
139
+ appear: true,
140
+ unmountOnExit: true,
141
+ timeout: ANIMATION_DURATION,
142
+ in: this.state.isShown,
143
+ onExited: this.props.onRemove
144
+ }, function (state) {
145
+ return /*#__PURE__*/React.createElement("div", {
146
+ "data-state": state,
147
+ className: animationStyles,
148
+ onMouseEnter: _this2.handleMouseEnter,
149
+ onMouseLeave: _this2.handleMouseLeave,
150
+ style: {
151
+ height: _this2.state.height,
152
+ zIndex: _this2.props.zIndex,
153
+ marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
154
+ }
155
+ }, /*#__PURE__*/React.createElement("div", {
156
+ ref: _this2.onRef,
157
+ style: {
158
+ padding: 8
159
+ }
160
+ }, /*#__PURE__*/React.createElement(Alert, {
161
+ intent: _this2.props.intent,
162
+ title: _this2.props.title,
163
+ children: _this2.props.children || '',
164
+ isRemoveable: _this2.props.hasCloseButton,
165
+ onRemove: function onRemove() {
166
+ return _this2.close();
167
+ }
168
+ })));
127
169
  });
128
170
  }
129
- };
130
-
131
- _proto.componentDidMount = function componentDidMount() {
132
- this.startCloseTimer();
133
- };
134
-
135
- _proto.componentWillUnmount = function componentWillUnmount() {
136
- this.clearCloseTimer();
137
- };
138
-
139
- _proto.render = function render() {
140
- var _this2 = this;
141
-
142
- return /*#__PURE__*/_react.default.createElement(_Transition.default, {
143
- appear: true,
144
- unmountOnExit: true,
145
- timeout: ANIMATION_DURATION,
146
- in: this.state.isShown,
147
- onExited: this.props.onRemove
148
- }, function (state) {
149
- return /*#__PURE__*/_react.default.createElement("div", {
150
- "data-state": state,
151
- className: animationStyles,
152
- onMouseEnter: _this2.handleMouseEnter,
153
- onMouseLeave: _this2.handleMouseLeave,
154
- style: {
155
- height: _this2.state.height,
156
- zIndex: _this2.props.zIndex,
157
- marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
158
- }
159
- }, /*#__PURE__*/_react.default.createElement("div", {
160
- ref: _this2.onRef,
161
- style: {
162
- padding: 8
163
- }
164
- }, /*#__PURE__*/_react.default.createElement(_alert.default, {
165
- intent: _this2.props.intent,
166
- title: _this2.props.title,
167
- children: _this2.props.children || '',
168
- isRemoveable: _this2.props.hasCloseButton,
169
- onRemove: function onRemove() {
170
- return _this2.close();
171
- }
172
- })));
173
- });
174
- };
171
+ }]);
175
172
 
176
173
  return Toast;
177
- }(_react.default.PureComponent);
178
-
179
- exports.default = Toast;
180
- (0, _defineProperty2.default)(Toast, "propTypes", {
181
- /**
182
- * The z-index of the toast.
183
- */
184
- zIndex: _propTypes.default.number,
185
-
186
- /**
187
- * Duration of the toast.
188
- */
189
- duration: _propTypes.default.number,
190
-
191
- /**
192
- * Function called when the toast is all the way closed.
193
- */
194
- onRemove: _propTypes.default.func,
195
-
196
- /**
197
- * The type of the alert.
198
- */
199
- intent: _propTypes.default.oneOf(['none', 'success', 'warning', 'danger']).isRequired,
200
-
201
- /**
202
- * The title of the alert.
203
- */
204
- title: _propTypes.default.node,
205
-
206
- /**
207
- * Description of the alert.
208
- */
209
- children: _propTypes.default.node,
210
-
211
- /**
212
- * When true, show a close icon button inside of the toast.
213
- */
214
- hasCloseButton: _propTypes.default.bool,
215
-
216
- /**
217
- * When false, will close the Toast and call onRemove when finished.
218
- */
219
- isShown: _propTypes.default.bool
220
- });
221
- (0, _defineProperty2.default)(Toast, "defaultProps", {
174
+ }(React.PureComponent);
175
+
176
+ Toast.defaultProps = {
222
177
  intent: 'none'
223
- });
178
+ };
179
+ export { Toast as default };
@@ -1,41 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.default = void 0;
7
-
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
-
10
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
-
12
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
-
14
- var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
15
-
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
- var _react = _interopRequireDefault(require("react"));
19
-
20
- var _glamor = require("glamor");
21
-
22
- var _propTypes = _interopRequireDefault(require("prop-types"));
23
-
24
- var _toast = _interopRequireDefault(require("./toast"));
25
-
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";
26
9
  var _excluded = ["id", "description"];
27
-
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
-
32
- function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33
-
34
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
35
-
36
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37
-
38
- var wrapperClass = (0, _glamor.css)({
10
+ import React from 'react';
11
+ import { css } from 'glamor';
12
+ import Toast from './toast';
13
+ var wrapperClass = css({
39
14
  maxWidth: 560,
40
15
  margin: '0 auto',
41
16
  top: 0,
@@ -50,30 +25,46 @@ var hasCustomId = function hasCustomId(settings) {
50
25
  };
51
26
 
52
27
  var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
53
- (0, _inheritsLoose2.default)(ToastManager, _React$PureComponent);
28
+ _inherits(ToastManager, _React$PureComponent);
29
+
30
+ var _super = _createSuper(ToastManager);
54
31
 
55
32
  function ToastManager(props, context) {
56
33
  var _this;
57
34
 
58
- _this = _React$PureComponent.call(this, props, context) || this;
59
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getToasts", function () {
35
+ _classCallCheck(this, ToastManager);
36
+
37
+ _this = _super.call(this, props, context);
38
+
39
+ _this.getToasts = function () {
60
40
  return _this.state.toasts;
61
- });
62
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "closeAll", function () {
41
+ };
42
+
43
+ _this.closeAll = function () {
63
44
  _this.getToasts().forEach(function (toast) {
64
45
  return toast.close();
65
46
  });
66
- });
67
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "notify", function (title, settings) {
47
+ };
48
+
49
+ _this.notify = function (title, settings) {
68
50
  // If there's a custom toast ID passed, close existing toasts with the same custom ID
69
51
  if (hasCustomId(settings)) {
70
- for (var _iterator = _createForOfIteratorHelperLoose(_this.state.toasts), _step; !(_step = _iterator()).done;) {
71
- var toast = _step.value;
52
+ var _iterator = _createForOfIteratorHelper(_this.state.toasts),
53
+ _step;
72
54
 
73
- // Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
74
- if (String(toast.id).startsWith(settings.id)) {
75
- _this.closeToast(toast.id);
55
+ try {
56
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
57
+ var toast = _step.value;
58
+
59
+ // Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
60
+ if (String(toast.id).startsWith(settings.id)) {
61
+ _this.closeToast(toast.id);
62
+ }
76
63
  }
64
+ } catch (err) {
65
+ _iterator.e(err);
66
+ } finally {
67
+ _iterator.f();
77
68
  }
78
69
  }
79
70
 
@@ -81,15 +72,16 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
81
72
 
82
73
  _this.setState(function (previousState) {
83
74
  return {
84
- toasts: [instance].concat(previousState.toasts)
75
+ toasts: [instance].concat(_toConsumableArray(previousState.toasts))
85
76
  };
86
77
  });
87
78
 
88
79
  return instance;
89
- });
90
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createToastInstance", function (title, settings) {
80
+ };
81
+
82
+ _this.createToastInstance = function (title, settings) {
91
83
  var uniqueId = ++ToastManager.idCounter;
92
- var id = hasCustomId(settings) ? settings.id + "-" + uniqueId : uniqueId;
84
+ var id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
93
85
  var hasCloseButton = settings.hasCloseButton || true;
94
86
  var duration = settings.duration || 2;
95
87
 
@@ -112,8 +104,9 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
112
104
  },
113
105
  intent: settings.intent
114
106
  };
115
- });
116
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "closeToast", function (id) {
107
+ };
108
+
109
+ _this.closeToast = function (id) {
117
110
  _this.setState(function (previousState) {
118
111
  return {
119
112
  toasts: previousState.toasts.map(function (toast) {
@@ -127,8 +120,9 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
127
120
  })
128
121
  };
129
122
  });
130
- });
131
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "removeToast", function (id) {
123
+ };
124
+
125
+ _this.removeToast = function (id) {
132
126
  _this.setState(function (previousState) {
133
127
  return {
134
128
  toasts: previousState.toasts.filter(function (toast) {
@@ -136,7 +130,8 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
136
130
  })
137
131
  };
138
132
  });
139
- });
133
+ };
134
+
140
135
  props.bindNotify(_this.notify);
141
136
  props.bindGetToasts(_this.getToasts);
142
137
  props.bindCloseAll(_this.closeAll);
@@ -146,44 +141,30 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
146
141
  return _this;
147
142
  }
148
143
 
149
- var _proto = ToastManager.prototype;
150
-
151
- _proto.render = function render() {
152
- var _this2 = this;
153
-
154
- return /*#__PURE__*/_react.default.createElement("span", {
155
- className: wrapperClass
156
- }, this.state.toasts.map(function (_ref) {
157
- var id = _ref.id,
158
- description = _ref.description,
159
- props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
160
- return /*#__PURE__*/_react.default.createElement(_toast.default, (0, _extends2.default)({
161
- key: id,
162
- onRemove: function onRemove() {
163
- return _this2.removeToast(id);
164
- }
165
- }, props), description);
166
- }));
167
- };
144
+ _createClass(ToastManager, [{
145
+ key: "render",
146
+ value: function render() {
147
+ var _this2 = this;
148
+
149
+ return /*#__PURE__*/React.createElement("span", {
150
+ className: wrapperClass
151
+ }, this.state.toasts.map(function (_ref) {
152
+ var id = _ref.id,
153
+ description = _ref.description,
154
+ props = _objectWithoutProperties(_ref, _excluded);
155
+
156
+ return /*#__PURE__*/React.createElement(Toast, Object.assign({
157
+ key: id,
158
+ onRemove: function onRemove() {
159
+ return _this2.removeToast(id);
160
+ }
161
+ }, props), description);
162
+ }));
163
+ }
164
+ }]);
168
165
 
169
166
  return ToastManager;
170
- }(_react.default.PureComponent);
171
-
172
- exports.default = ToastManager;
173
- (0, _defineProperty2.default)(ToastManager, "propTypes", {
174
- /**
175
- * Function called with the `this.notify` function.
176
- */
177
- bindNotify: _propTypes.default.func.isRequired,
178
-
179
- /**
180
- * Function called with the `this.getToasts` function.
181
- */
182
- bindGetToasts: _propTypes.default.func.isRequired,
183
-
184
- /**
185
- * Function called with the `this.closeAll` function.
186
- */
187
- bindCloseAll: _propTypes.default.func.isRequired
188
- });
189
- (0, _defineProperty2.default)(ToastManager, "idCounter", 0);
167
+ }(React.PureComponent);
168
+
169
+ ToastManager.idCounter = 0;
170
+ export { ToastManager as default };