@elliemae/ds-toast 2.3.0-alpha.8 → 2.3.0-next.2

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 (50) hide show
  1. package/cjs/DSToast.js +102 -0
  2. package/cjs/ToastAction.js +67 -0
  3. package/cjs/ToastPosition.js +16 -0
  4. package/cjs/ToastRender.js +42 -0
  5. package/cjs/ToastType.js +16 -0
  6. package/cjs/index.js +24 -0
  7. package/cjs/toast.js +47 -0
  8. package/esm/DSToast.js +90 -0
  9. package/esm/ToastAction.js +55 -0
  10. package/esm/ToastPosition.js +11 -0
  11. package/esm/ToastRender.js +36 -0
  12. package/esm/ToastType.js +11 -0
  13. package/esm/index.js +5 -0
  14. package/esm/toast.js +37 -0
  15. package/package.json +32 -34
  16. package/types/DSToast.d.ts +79 -0
  17. package/types/ToastAction.d.ts +52 -0
  18. package/types/ToastPosition.d.ts +9 -0
  19. package/types/ToastRender.d.ts +24 -0
  20. package/types/ToastType.d.ts +8 -0
  21. package/types/index.d.ts +6 -0
  22. package/types/toast.d.ts +38 -0
  23. package/dist/cjs/DSToast.js +0 -86
  24. package/dist/cjs/DSToast.js.map +0 -7
  25. package/dist/cjs/ToastAction.js +0 -67
  26. package/dist/cjs/ToastAction.js.map +0 -7
  27. package/dist/cjs/ToastPosition.js +0 -44
  28. package/dist/cjs/ToastPosition.js.map +0 -7
  29. package/dist/cjs/ToastRender.js +0 -66
  30. package/dist/cjs/ToastRender.js.map +0 -7
  31. package/dist/cjs/ToastType.js +0 -43
  32. package/dist/cjs/ToastType.js.map +0 -7
  33. package/dist/cjs/index.js +0 -40
  34. package/dist/cjs/index.js.map +0 -7
  35. package/dist/cjs/toast.js +0 -46
  36. package/dist/cjs/toast.js.map +0 -7
  37. package/dist/esm/DSToast.js +0 -57
  38. package/dist/esm/DSToast.js.map +0 -7
  39. package/dist/esm/ToastAction.js +0 -38
  40. package/dist/esm/ToastAction.js.map +0 -7
  41. package/dist/esm/ToastPosition.js +0 -15
  42. package/dist/esm/ToastPosition.js.map +0 -7
  43. package/dist/esm/ToastRender.js +0 -37
  44. package/dist/esm/ToastRender.js.map +0 -7
  45. package/dist/esm/ToastType.js +0 -14
  46. package/dist/esm/ToastType.js.map +0 -7
  47. package/dist/esm/index.js +0 -11
  48. package/dist/esm/index.js.map +0 -7
  49. package/dist/esm/toast.js +0 -17
  50. package/dist/esm/toast.js.map +0 -7
package/cjs/DSToast.js ADDED
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('core-js/modules/esnext.async-iterator.filter.js');
6
+ require('core-js/modules/esnext.iterator.constructor.js');
7
+ require('core-js/modules/esnext.iterator.filter.js');
8
+ require('core-js/modules/esnext.async-iterator.for-each.js');
9
+ require('core-js/modules/esnext.iterator.for-each.js');
10
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
+ var _jsx = require('@babel/runtime/helpers/jsx');
12
+ require('react');
13
+ var reactDesc = require('react-desc');
14
+ var reactToastify = require('react-toastify');
15
+ var dsIcons = require('@elliemae/ds-icons');
16
+ var DSButton = require('@elliemae/ds-button');
17
+ var ToastPosition = require('./ToastPosition.js');
18
+ var jsxRuntime = require('react/jsx-runtime');
19
+
20
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
+
22
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
23
+ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
24
+ var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
25
+
26
+ var _CloseSmall, _CloseButton;
27
+
28
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
+
32
+ const CloseButton = _ref => {
33
+ let {
34
+ closeToast
35
+ } = _ref;
36
+ return /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
37
+ buttonType: "text",
38
+ className: "toast-close-button",
39
+ icon: _CloseSmall || (_CloseSmall = /*#__PURE__*/_jsx__default["default"](dsIcons.CloseSmall, {})),
40
+ onClick: closeToast,
41
+ size: "m"
42
+ });
43
+ };
44
+
45
+ const DSToast = _ref2 => {
46
+ let {
47
+ containerProps = {},
48
+ position = 'bottom-left',
49
+ autoClose = 5000,
50
+ // can be false or a number in milliseconds
51
+ showProgressBar = false,
52
+ closeOnClick = false,
53
+ enableMultiContainer = false,
54
+ containerId = undefined,
55
+ toastId = undefined
56
+ } = _ref2;
57
+ return /*#__PURE__*/jsxRuntime.jsx(reactToastify.ToastContainer, _objectSpread(_objectSpread({}, containerProps), {}, {
58
+ autoClose: autoClose,
59
+ className: showProgressBar && 'with-progressbar' || '',
60
+ closeButton: _CloseButton || (_CloseButton = /*#__PURE__*/_jsx__default["default"](CloseButton, {})),
61
+ closeOnClick: closeOnClick,
62
+ containerId: containerId,
63
+ enableMultiContainer: enableMultiContainer,
64
+ hideProgressBar: !showProgressBar,
65
+ newestOnTop: true,
66
+ position: position,
67
+ toastId: toastId,
68
+ transition: reactToastify.Slide
69
+ }));
70
+ };
71
+
72
+ const props = {
73
+ /** inject props to wrapper */
74
+ containerProps: reactDesc.PropTypes.object.description('inject props to wrapper'),
75
+
76
+ /** Position on the screen to show the toast */
77
+ position: reactDesc.PropTypes.oneOf(ToastPosition.toastsPositions).description('Position on the screen to show the toast'),
78
+
79
+ /** ms to autoclose the toast */
80
+ autoClose: reactDesc.PropTypes.number.description('ms to autoclose the toast'),
81
+
82
+ /** Whether to show a progress bar indicating when the toast is going to be closed */
83
+ showProgressBar: reactDesc.PropTypes.bool.description('Whether to show a progress bar indicating when the toast is going to be closed'),
84
+
85
+ /** Close toast handler */
86
+ closeOnClick: reactDesc.PropTypes.bool.description('Close toast handler'),
87
+
88
+ /** Allows instantiating multiple Toast containers */
89
+ enableMultiContainer: reactDesc.PropTypes.bool.description('Allows instantiating multiple Toast containers'),
90
+
91
+ /** unique id for multi container */
92
+ containerId: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number]).description('unique id for multi container'),
93
+
94
+ /** id for the toast */
95
+ toastId: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number]).description('id for the toast')
96
+ };
97
+ const DSToastWithSchema = reactDesc.describe(DSToast);
98
+ DSToastWithSchema.propTypes = props;
99
+
100
+ exports.DSToast = DSToast;
101
+ exports.DSToastWithSchema = DSToastWithSchema;
102
+ exports["default"] = DSToast;
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _jsx = require('@babel/runtime/helpers/jsx');
6
+ require('react');
7
+ var reactDesc = require('react-desc');
8
+ var styled = require('styled-components');
9
+ var dsSystem = require('@elliemae/ds-system');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
14
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
15
+
16
+ const Link = /*#__PURE__*/styled__default["default"].span.withConfig({
17
+ componentId: "sc-1bs5g4c-0"
18
+ })(["", ""], dsSystem.color('brand', '600'));
19
+
20
+ const DSToastAction = _ref => {
21
+ let {
22
+ children,
23
+ onClick,
24
+ onKeyDown
25
+ } = _ref;
26
+ return (
27
+ /*#__PURE__*/
28
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
29
+ _jsx__default["default"]("div", {
30
+ onKeyDown: onKeyDown,
31
+ onClick: onClick,
32
+ role: onClick ? 'button' : 'textbox'
33
+ }, void 0, children)
34
+ );
35
+ }; // eslint-disable-next-line jsx-a11y/anchor-is-valid
36
+
37
+
38
+ const DSToastActionLink = _ref2 => {
39
+ let {
40
+ children
41
+ } = _ref2;
42
+ return /*#__PURE__*/_jsx__default["default"](Link, {}, void 0, children);
43
+ };
44
+
45
+ const actionprops = {
46
+ /** DSToastActionLink component or text string */
47
+ children: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.element]).description('DSToastActionLink component or text string'),
48
+
49
+ /** click handler */
50
+ onClick: reactDesc.PropTypes.func.description('click handler'),
51
+
52
+ /** key down handler */
53
+ onKeyDown: reactDesc.PropTypes.func.description('key down handler')
54
+ };
55
+ const linkprops = {
56
+ /** link text */
57
+ children: reactDesc.PropTypes.string.isRequired.description('link text')
58
+ };
59
+ const DSToastActionWithSchema = reactDesc.describe(DSToastAction);
60
+ const DSToastActionLinkWithSchema = reactDesc.describe(DSToastActionLink);
61
+ DSToastActionLinkWithSchema.propTypes = linkprops;
62
+ DSToastActionWithSchema.propTypes = actionprops;
63
+
64
+ exports.DSToastAction = DSToastAction;
65
+ exports.DSToastActionLink = DSToastActionLink;
66
+ exports.DSToastActionLinkWithSchema = DSToastActionLinkWithSchema;
67
+ exports.DSToastActionWithSchema = DSToastActionWithSchema;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const ToastPosition = {
6
+ TOP_RIGHT: 'top-right',
7
+ TOP_CENTER: 'top-center',
8
+ TOP_LEFT: 'top-left',
9
+ BOTTOM_RIGHT: 'bottom-right',
10
+ BOTTOM_CENTER: 'bottom-center',
11
+ BOTTOM_LEFT: 'bottom-left'
12
+ };
13
+ const toastsPositions = Object.values(ToastPosition);
14
+
15
+ exports.ToastPosition = ToastPosition;
16
+ exports.toastsPositions = toastsPositions;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var _jsx = require('@babel/runtime/helpers/jsx');
4
+ require('react');
5
+ var dsClassnames = require('@elliemae/ds-classnames');
6
+ var dsIcons = require('@elliemae/ds-icons');
7
+ var ToastType = require('./ToastType.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
12
+
13
+ const blockName = 'toast-content';
14
+ const Container = dsClassnames.aggregatedClasses('div')(blockName);
15
+ const IconContainer = dsClassnames.aggregatedClasses('div')(blockName, 'icon-container');
16
+ const MessageContent = dsClassnames.aggregatedClasses('div')(blockName, 'message-content');
17
+ const MessageHeader = dsClassnames.aggregatedClasses('div')(blockName, 'message-header');
18
+ const MessageText = dsClassnames.aggregatedClasses('span')(blockName, 'message-text');
19
+
20
+ const getIconByToastType = type => ({
21
+ [ToastType.ToastType.SUCCESS]: dsIcons.CheckmarkCircleFill,
22
+ [ToastType.ToastType.WARNING]: dsIcons.WarningCircleFill,
23
+ [ToastType.ToastType.INFO]: dsIcons.InfoCircleFill,
24
+ [ToastType.ToastType.ERROR]: dsIcons.WarningCircleFill,
25
+ [ToastType.ToastType.DEFAULT]: 'div'
26
+ })[type];
27
+
28
+ const ToastRender = _ref => {
29
+ let {
30
+ type = ToastType.ToastType.DEFAULT,
31
+ messageTitle = '',
32
+ messageText = ''
33
+ } = _ref;
34
+ const IconMessage = dsClassnames.aggregatedClasses(getIconByToastType(type))(blockName, 'icon-message');
35
+ return /*#__PURE__*/_jsx__default["default"](Container, {
36
+ "data-testid": "ds-toast-render"
37
+ }, void 0, /*#__PURE__*/_jsx__default["default"](IconContainer, {}, void 0, /*#__PURE__*/_jsx__default["default"](IconMessage, {
38
+ size: "m"
39
+ })), /*#__PURE__*/_jsx__default["default"](MessageContent, {}, void 0, /*#__PURE__*/_jsx__default["default"](MessageHeader, {}, void 0, messageTitle), /*#__PURE__*/_jsx__default["default"](MessageText, {}, void 0, messageText)));
40
+ };
41
+
42
+ module.exports = ToastRender;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const ToastType = {
6
+ INFO: 'info',
7
+ SUCCESS: 'success',
8
+ WARNING: 'warning',
9
+ ERROR: 'error',
10
+ // TODO remove from types, it's not in spec
11
+ DEFAULT: 'default'
12
+ };
13
+ const toastTypes = Object.values(ToastType);
14
+
15
+ exports.ToastType = ToastType;
16
+ exports.toastTypes = toastTypes;
package/cjs/index.js ADDED
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DSToast = require('./DSToast.js');
6
+ var toast = require('./toast.js');
7
+ var ToastType = require('./ToastType.js');
8
+ var ToastPosition = require('./ToastPosition.js');
9
+ var ToastAction = require('./ToastAction.js');
10
+
11
+
12
+
13
+ exports.DSToast = DSToast.DSToast;
14
+ exports.DSToastWithSchema = DSToast.DSToastWithSchema;
15
+ exports["default"] = DSToast.DSToast;
16
+ exports.toast = toast.toast;
17
+ exports.ToastType = ToastType.ToastType;
18
+ exports.toastTypes = ToastType.toastTypes;
19
+ exports.ToastPosition = ToastPosition.ToastPosition;
20
+ exports.toastsPositions = ToastPosition.toastsPositions;
21
+ exports.DSToastAction = ToastAction.DSToastAction;
22
+ exports.DSToastActionLink = ToastAction.DSToastActionLink;
23
+ exports.DSToastActionLinkWithSchema = ToastAction.DSToastActionLinkWithSchema;
24
+ exports.DSToastActionWithSchema = ToastAction.DSToastActionWithSchema;
package/cjs/toast.js ADDED
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('core-js/modules/esnext.async-iterator.filter.js');
6
+ require('core-js/modules/esnext.iterator.constructor.js');
7
+ require('core-js/modules/esnext.iterator.filter.js');
8
+ require('core-js/modules/esnext.async-iterator.for-each.js');
9
+ require('core-js/modules/esnext.iterator.for-each.js');
10
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
+ var _jsx = require('@babel/runtime/helpers/jsx');
12
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
13
+ require('react');
14
+ var reactToastify = require('react-toastify');
15
+ var ToastRender = require('./ToastRender.js');
16
+
17
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
+
19
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
20
+ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
21
+ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
22
+
23
+ const _excluded = ["type", "messageTitle", "messageText"];
24
+
25
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
+
27
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
+ const toast = Object.assign((_ref, options) => {
29
+ let {
30
+ type,
31
+ messageTitle,
32
+ messageText
33
+ } = _ref,
34
+ rest = _objectWithoutProperties__default["default"](_ref, _excluded);
35
+
36
+ return reactToastify.toast( /*#__PURE__*/_jsx__default["default"](ToastRender, {
37
+ messageText: messageText,
38
+ messageTitle: messageTitle,
39
+ type: type
40
+ }), _objectSpread(_objectSpread(_objectSpread({}, rest), options), {}, {
41
+ type
42
+ }));
43
+ }, _objectSpread(_objectSpread({}, reactToastify.toast), {}, {
44
+ isActive: id => reactToastify.toast.isActive(id)
45
+ }));
46
+
47
+ exports.toast = toast;
package/esm/DSToast.js ADDED
@@ -0,0 +1,90 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
8
+ import 'react';
9
+ import { PropTypes, describe } from 'react-desc';
10
+ import { ToastContainer, Slide } from 'react-toastify';
11
+ import { CloseSmall } from '@elliemae/ds-icons';
12
+ import DSButton from '@elliemae/ds-button';
13
+ import { toastsPositions } from './ToastPosition.js';
14
+ import { jsx } from 'react/jsx-runtime';
15
+
16
+ var _CloseSmall, _CloseButton;
17
+
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
+
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
+
22
+ const CloseButton = _ref => {
23
+ let {
24
+ closeToast
25
+ } = _ref;
26
+ return /*#__PURE__*/_jsx(DSButton, {
27
+ buttonType: "text",
28
+ className: "toast-close-button",
29
+ icon: _CloseSmall || (_CloseSmall = /*#__PURE__*/_jsx(CloseSmall, {})),
30
+ onClick: closeToast,
31
+ size: "m"
32
+ });
33
+ };
34
+
35
+ const DSToast = _ref2 => {
36
+ let {
37
+ containerProps = {},
38
+ position = 'bottom-left',
39
+ autoClose = 5000,
40
+ // can be false or a number in milliseconds
41
+ showProgressBar = false,
42
+ closeOnClick = false,
43
+ enableMultiContainer = false,
44
+ containerId = undefined,
45
+ toastId = undefined
46
+ } = _ref2;
47
+ return /*#__PURE__*/jsx(ToastContainer, _objectSpread(_objectSpread({}, containerProps), {}, {
48
+ autoClose: autoClose,
49
+ className: showProgressBar && 'with-progressbar' || '',
50
+ closeButton: _CloseButton || (_CloseButton = /*#__PURE__*/_jsx(CloseButton, {})),
51
+ closeOnClick: closeOnClick,
52
+ containerId: containerId,
53
+ enableMultiContainer: enableMultiContainer,
54
+ hideProgressBar: !showProgressBar,
55
+ newestOnTop: true,
56
+ position: position,
57
+ toastId: toastId,
58
+ transition: Slide
59
+ }));
60
+ };
61
+
62
+ const props = {
63
+ /** inject props to wrapper */
64
+ containerProps: PropTypes.object.description('inject props to wrapper'),
65
+
66
+ /** Position on the screen to show the toast */
67
+ position: PropTypes.oneOf(toastsPositions).description('Position on the screen to show the toast'),
68
+
69
+ /** ms to autoclose the toast */
70
+ autoClose: PropTypes.number.description('ms to autoclose the toast'),
71
+
72
+ /** Whether to show a progress bar indicating when the toast is going to be closed */
73
+ showProgressBar: PropTypes.bool.description('Whether to show a progress bar indicating when the toast is going to be closed'),
74
+
75
+ /** Close toast handler */
76
+ closeOnClick: PropTypes.bool.description('Close toast handler'),
77
+
78
+ /** Allows instantiating multiple Toast containers */
79
+ enableMultiContainer: PropTypes.bool.description('Allows instantiating multiple Toast containers'),
80
+
81
+ /** unique id for multi container */
82
+ containerId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('unique id for multi container'),
83
+
84
+ /** id for the toast */
85
+ toastId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('id for the toast')
86
+ };
87
+ const DSToastWithSchema = describe(DSToast);
88
+ DSToastWithSchema.propTypes = props;
89
+
90
+ export { DSToast, DSToastWithSchema, DSToast as default };
@@ -0,0 +1,55 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { PropTypes, describe } from 'react-desc';
4
+ import styled from 'styled-components';
5
+ import { color } from '@elliemae/ds-system';
6
+
7
+ const Link = /*#__PURE__*/styled.span.withConfig({
8
+ componentId: "sc-1bs5g4c-0"
9
+ })(["", ""], color('brand', '600'));
10
+
11
+ const DSToastAction = _ref => {
12
+ let {
13
+ children,
14
+ onClick,
15
+ onKeyDown
16
+ } = _ref;
17
+ return (
18
+ /*#__PURE__*/
19
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
20
+ _jsx("div", {
21
+ onKeyDown: onKeyDown,
22
+ onClick: onClick,
23
+ role: onClick ? 'button' : 'textbox'
24
+ }, void 0, children)
25
+ );
26
+ }; // eslint-disable-next-line jsx-a11y/anchor-is-valid
27
+
28
+
29
+ const DSToastActionLink = _ref2 => {
30
+ let {
31
+ children
32
+ } = _ref2;
33
+ return /*#__PURE__*/_jsx(Link, {}, void 0, children);
34
+ };
35
+
36
+ const actionprops = {
37
+ /** DSToastActionLink component or text string */
38
+ children: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).description('DSToastActionLink component or text string'),
39
+
40
+ /** click handler */
41
+ onClick: PropTypes.func.description('click handler'),
42
+
43
+ /** key down handler */
44
+ onKeyDown: PropTypes.func.description('key down handler')
45
+ };
46
+ const linkprops = {
47
+ /** link text */
48
+ children: PropTypes.string.isRequired.description('link text')
49
+ };
50
+ const DSToastActionWithSchema = describe(DSToastAction);
51
+ const DSToastActionLinkWithSchema = describe(DSToastActionLink);
52
+ DSToastActionLinkWithSchema.propTypes = linkprops;
53
+ DSToastActionWithSchema.propTypes = actionprops;
54
+
55
+ export { DSToastAction, DSToastActionLink, DSToastActionLinkWithSchema, DSToastActionWithSchema };
@@ -0,0 +1,11 @@
1
+ const ToastPosition = {
2
+ TOP_RIGHT: 'top-right',
3
+ TOP_CENTER: 'top-center',
4
+ TOP_LEFT: 'top-left',
5
+ BOTTOM_RIGHT: 'bottom-right',
6
+ BOTTOM_CENTER: 'bottom-center',
7
+ BOTTOM_LEFT: 'bottom-left'
8
+ };
9
+ const toastsPositions = Object.values(ToastPosition);
10
+
11
+ export { ToastPosition, toastsPositions };
@@ -0,0 +1,36 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
4
+ import { CheckmarkCircleFill, WarningCircleFill, InfoCircleFill } from '@elliemae/ds-icons';
5
+ import { ToastType } from './ToastType.js';
6
+
7
+ const blockName = 'toast-content';
8
+ const Container = aggregatedClasses('div')(blockName);
9
+ const IconContainer = aggregatedClasses('div')(blockName, 'icon-container');
10
+ const MessageContent = aggregatedClasses('div')(blockName, 'message-content');
11
+ const MessageHeader = aggregatedClasses('div')(blockName, 'message-header');
12
+ const MessageText = aggregatedClasses('span')(blockName, 'message-text');
13
+
14
+ const getIconByToastType = type => ({
15
+ [ToastType.SUCCESS]: CheckmarkCircleFill,
16
+ [ToastType.WARNING]: WarningCircleFill,
17
+ [ToastType.INFO]: InfoCircleFill,
18
+ [ToastType.ERROR]: WarningCircleFill,
19
+ [ToastType.DEFAULT]: 'div'
20
+ })[type];
21
+
22
+ const ToastRender = _ref => {
23
+ let {
24
+ type = ToastType.DEFAULT,
25
+ messageTitle = '',
26
+ messageText = ''
27
+ } = _ref;
28
+ const IconMessage = aggregatedClasses(getIconByToastType(type))(blockName, 'icon-message');
29
+ return /*#__PURE__*/_jsx(Container, {
30
+ "data-testid": "ds-toast-render"
31
+ }, void 0, /*#__PURE__*/_jsx(IconContainer, {}, void 0, /*#__PURE__*/_jsx(IconMessage, {
32
+ size: "m"
33
+ })), /*#__PURE__*/_jsx(MessageContent, {}, void 0, /*#__PURE__*/_jsx(MessageHeader, {}, void 0, messageTitle), /*#__PURE__*/_jsx(MessageText, {}, void 0, messageText)));
34
+ };
35
+
36
+ export { ToastRender as default };
@@ -0,0 +1,11 @@
1
+ const ToastType = {
2
+ INFO: 'info',
3
+ SUCCESS: 'success',
4
+ WARNING: 'warning',
5
+ ERROR: 'error',
6
+ // TODO remove from types, it's not in spec
7
+ DEFAULT: 'default'
8
+ };
9
+ const toastTypes = Object.values(ToastType);
10
+
11
+ export { ToastType, toastTypes };
package/esm/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { DSToast, DSToastWithSchema, DSToast as default } from './DSToast.js';
2
+ export { toast } from './toast.js';
3
+ export { ToastType, toastTypes } from './ToastType.js';
4
+ export { ToastPosition, toastsPositions } from './ToastPosition.js';
5
+ export { DSToastAction, DSToastActionLink, DSToastActionLinkWithSchema, DSToastActionWithSchema } from './ToastAction.js';
package/esm/toast.js ADDED
@@ -0,0 +1,37 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
8
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
+ import 'react';
10
+ import { toast as toast$1 } from 'react-toastify';
11
+ import ToastRender from './ToastRender.js';
12
+
13
+ const _excluded = ["type", "messageTitle", "messageText"];
14
+
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
+ const toast = Object.assign((_ref, options) => {
19
+ let {
20
+ type,
21
+ messageTitle,
22
+ messageText
23
+ } = _ref,
24
+ rest = _objectWithoutProperties(_ref, _excluded);
25
+
26
+ return toast$1( /*#__PURE__*/_jsx(ToastRender, {
27
+ messageText: messageText,
28
+ messageTitle: messageTitle,
29
+ type: type
30
+ }), _objectSpread(_objectSpread(_objectSpread({}, rest), options), {}, {
31
+ type
32
+ }));
33
+ }, _objectSpread(_objectSpread({}, toast$1), {}, {
34
+ isActive: id => toast$1.isActive(id)
35
+ }));
36
+
37
+ export { toast };