@elliemae/ds-banner 2.0.0-next.10 → 2.0.0-next.11

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.
package/cjs/DSBanner.js CHANGED
@@ -5,8 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
6
  var _jsx = require('@babel/runtime/helpers/jsx');
7
7
  require('core-js/modules/web.dom-collections.iterator.js');
8
- var react = require('react');
9
- var CloseX = require('@elliemae/ds-icons/CloseX');
8
+ require('core-js/modules/esnext.async-iterator.filter.js');
9
+ require('core-js/modules/esnext.iterator.constructor.js');
10
+ require('core-js/modules/esnext.iterator.filter.js');
11
+ require('core-js/modules/esnext.async-iterator.for-each.js');
12
+ require('core-js/modules/esnext.iterator.for-each.js');
13
+ var React = require('react');
14
+ var dsIcons = require('@elliemae/ds-icons');
10
15
  var reactDesc = require('react-desc');
11
16
  var icons = require('./utils/icons.js');
12
17
  var propTypes = require('./propTypes.js');
@@ -18,38 +23,57 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
18
23
 
19
24
  var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
20
25
  var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
21
- var CloseX__default = /*#__PURE__*/_interopDefaultLegacy(CloseX);
26
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
27
 
23
- var _CloseX;
28
+ var _CloseX, _span;
24
29
 
25
30
  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; }
26
31
 
27
32
  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) { _defineProperty__default["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; }
28
33
 
29
- const DSBanner = ({
30
- type,
31
- isOpen,
32
- onClose,
33
- label,
34
- body,
35
- actionLink,
36
- showCloseButton,
37
- containerProps
38
- }) => {
39
- const innerContainerRef = react.useRef(null);
40
- const linkRef = react.useRef(null);
41
- const [current, setCurrent] = react.useState(isOpen);
42
- const [isAnimating, setIsAnimating] = react.useState(false);
43
- const [height, setHeight] = react.useState(0);
44
- react.useEffect(() => {
45
- if (innerContainerRef.current) {
46
- setHeight(innerContainerRef.current.offsetHeight);
34
+ const DSBanner = _ref => {
35
+ let {
36
+ type,
37
+ isOpen,
38
+ onClose,
39
+ label,
40
+ body,
41
+ actionLink,
42
+ showCloseButton,
43
+ containerProps,
44
+ actionRef
45
+ } = _ref;
46
+ const innerContainerRef = React.useRef(null);
47
+ const linkRef = React.useRef(null);
48
+ const [current, setCurrent] = React.useState(isOpen);
49
+ const [isAnimating, setIsAnimating] = React.useState(false);
50
+ const [height, setHeight] = React.useState(0);
51
+ const [alertTabIndex, setAlertTabIndex] = React.useState(undefined);
52
+ React__default["default"].useEffect(() => {
53
+ if (actionRef && actionRef.current) {
54
+ actionRef.current.focusOnWrapper = () => {
55
+ if (innerContainerRef.current) {
56
+ setAlertTabIndex(0);
57
+ setTimeout(() => {
58
+ innerContainerRef.current.focus();
59
+ }, 100);
60
+ }
61
+ };
62
+
63
+ actionRef.current.focusOnLink = () => {
64
+ if (linkRef.current) {
65
+ linkRef.current.focus();
66
+ }
67
+ };
47
68
  }
48
- }, [isAnimating, isOpen]);
49
- react.useLayoutEffect(() => {
69
+ }, [actionRef]);
70
+ React.useLayoutEffect(() => {
50
71
  if (isOpen !== current || isOpen) setIsAnimating(true);else setIsAnimating(false);
51
72
  }, [isOpen, current]);
52
- const handleOnKeyDown = react.useCallback(e => {
73
+ const handleBlur = React.useCallback(() => {
74
+ setAlertTabIndex(undefined);
75
+ }, []);
76
+ const handleOnKeyDown = React.useCallback(e => {
53
77
  if (e.key === 'Enter' || e.key === ' ') {
54
78
  e.preventDefault();
55
79
  if (linkRef.current) linkRef.current.click();
@@ -71,6 +95,8 @@ const DSBanner = ({
71
95
  isAnimating: isAnimating,
72
96
  "data-testid": "ds-banner",
73
97
  role: "alert",
98
+ tabIndex: alertTabIndex,
99
+ onBlur: handleBlur,
74
100
  children: [/*#__PURE__*/_jsx__default["default"](styles.StyledIconContainer, {
75
101
  "data-testid": "ds-banner-icon"
76
102
  }, void 0, icons.icons[type]), /*#__PURE__*/_jsx__default["default"](styles.StyledTitle, {}, void 0, label), /*#__PURE__*/_jsx__default["default"](styles.StyledSubTitle, {}, void 0, /*#__PURE__*/_jsx__default["default"]("span", {}, void 0, body), actionLink && /*#__PURE__*/jsxRuntime.jsx(styles.StyledActionLink, {
@@ -82,16 +108,16 @@ const DSBanner = ({
82
108
  tabIndex: 0,
83
109
  isBodyEmpty: body,
84
110
  children: actionLink.label
85
- })), showCloseButton && /*#__PURE__*/_jsx__default["default"](styles.StyledCloseButton, {
111
+ })), showCloseButton ? /*#__PURE__*/_jsx__default["default"](styles.StyledCloseButton, {
86
112
  "data-testid": "ds-banner-close-button",
87
113
  buttonType: "secondary",
88
114
  onClick: onClose,
89
115
  "aria-label": "Close icon",
90
- icon: _CloseX || (_CloseX = /*#__PURE__*/_jsx__default["default"](CloseX__default["default"], {
116
+ icon: _CloseX || (_CloseX = /*#__PURE__*/_jsx__default["default"](dsIcons.CloseX, {
91
117
  width: "12px",
92
118
  height: "12px"
93
119
  }))
94
- })]
120
+ }) : _span || (_span = /*#__PURE__*/_jsx__default["default"]("span", {}))]
95
121
  })
96
122
  }));
97
123
  };
package/cjs/propTypes.js CHANGED
@@ -17,7 +17,8 @@ const propTypes = {
17
17
  label: reactDesc.PropTypes.string,
18
18
  onClick: reactDesc.PropTypes.func,
19
19
  href: reactDesc.PropTypes.string
20
- }).description('Properties of the ActionLink component').defaultValue({})
20
+ }).description('Properties of the ActionLink component').defaultValue({}),
21
+ actionRef: reactDesc.PropTypes.object.description("\n Reference to use actions:\n - focusOnLink: function to focus the banner\n - focusOnWrapper: function to focus the link\n ").defaultValue({})
21
22
  };
22
23
 
23
24
  exports.propTypes = propTypes;
package/cjs/styles.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var styled = require('styled-components');
6
- var DSButton = require('@elliemae/ds-basic/Button');
6
+ var DSButton = require('@elliemae/ds-button');
7
7
  var styleHelpers = require('./utils/styleHelpers.js');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -13,66 +13,120 @@ var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
13
13
 
14
14
  const StyledBannerContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
15
15
  componentId: "sc-ffu2hq-0"
16
- })(["overflow:hidden;height:", ";", ";"], ({
17
- isOpen
18
- }) => isOpen ? 'auto' : '0px', ({
19
- isAnimating,
20
- isOpen,
21
- height
22
- }) => styleHelpers.handleAnimation(isAnimating, isOpen, height));
16
+ })(["overflow:hidden;height:", ";", ";"], _ref => {
17
+ let {
18
+ isOpen
19
+ } = _ref;
20
+ return isOpen ? 'auto' : '0px';
21
+ }, _ref2 => {
22
+ let {
23
+ isAnimating,
24
+ isOpen,
25
+ height
26
+ } = _ref2;
27
+ return styleHelpers.handleAnimation(isAnimating, isOpen, height);
28
+ });
23
29
  const StyledInnerContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
24
30
  componentId: "sc-ffu2hq-1"
25
- })(["padding-right:6px;display:flex;align-items:center;min-height:41px;width:100%;background-color:", ";border-bottom:5px solid ", ";", ";"], ({
26
- theme
27
- }) => theme.colors.neutral['000'], ({
28
- type,
29
- theme
30
- }) => styleHelpers.handleBorderColor(type, theme), ({
31
- isAnimating,
32
- isOpen
33
- }) => styleHelpers.handleAnimation(isAnimating, isOpen));
31
+ })(["padding-right:6px;display:grid;align-items:center;min-height:41px;width:100%;background-color:", ";border-bottom:5px solid ", ";", ";&:focus{position:relative;&:after{content:'';display:block;position:absolute;top:0;left:0;pointer-events:none;border-radius:2px;width:calc(100%);border:2px solid #1e79c2;height:calc(100% + 4px);}}grid-template-columns:auto minmax(auto,auto) minmax(auto,1fr) auto;"], _ref3 => {
32
+ let {
33
+ theme
34
+ } = _ref3;
35
+ return theme.colors.neutral['000'];
36
+ }, _ref4 => {
37
+ let {
38
+ type,
39
+ theme
40
+ } = _ref4;
41
+ return styleHelpers.handleBorderColor(type, theme);
42
+ }, _ref5 => {
43
+ let {
44
+ isAnimating,
45
+ isOpen
46
+ } = _ref5;
47
+ return styleHelpers.handleAnimation(isAnimating, isOpen);
48
+ });
34
49
  const StyledIconContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
35
50
  componentId: "sc-ffu2hq-2"
36
- })(["margin-right:", ";margin-left:", ";"], ({
37
- theme
38
- }) => theme.space.xxs, ({
39
- theme
40
- }) => theme.space.xs);
51
+ })(["margin-right:", ";margin-left:", ";"], _ref6 => {
52
+ let {
53
+ theme
54
+ } = _ref6;
55
+ return theme.space.xxs;
56
+ }, _ref7 => {
57
+ let {
58
+ theme
59
+ } = _ref7;
60
+ return theme.space.xs;
61
+ });
41
62
  const StyledTitle = /*#__PURE__*/styled__default["default"].div.withConfig({
42
63
  componentId: "sc-ffu2hq-3"
43
- })(["color:", ";font-size:", ";font-weight:", ";white-space:nowrap;"], ({
44
- theme
45
- }) => theme.colors.neutral[700], ({
46
- theme
47
- }) => theme.fontSizes.label[400], ({
48
- theme
49
- }) => theme.fontWeights.semibold);
64
+ })(["color:", ";font-size:", ";font-weight:", ";"], _ref8 => {
65
+ let {
66
+ theme
67
+ } = _ref8;
68
+ return theme.colors.neutral[700];
69
+ }, _ref9 => {
70
+ let {
71
+ theme
72
+ } = _ref9;
73
+ return theme.fontSizes.label[400];
74
+ }, _ref10 => {
75
+ let {
76
+ theme
77
+ } = _ref10;
78
+ return theme.fontWeights.semibold;
79
+ });
50
80
  const StyledSubTitle = /*#__PURE__*/styled__default["default"].div.withConfig({
51
81
  componentId: "sc-ffu2hq-4"
52
- })(["width:100%;margin-left:", ";font-size:", ";font-weight:", ";"], ({
53
- theme
54
- }) => theme.space.xs, ({
55
- theme
56
- }) => theme.fontSizes.subTitle[400], ({
57
- theme
58
- }) => theme.fontWeights.regular);
82
+ })(["width:100%;margin-left:", ";font-size:", ";font-weight:", ";"], _ref11 => {
83
+ let {
84
+ theme
85
+ } = _ref11;
86
+ return theme.space.xs;
87
+ }, _ref12 => {
88
+ let {
89
+ theme
90
+ } = _ref12;
91
+ return theme.fontSizes.subTitle[400];
92
+ }, _ref13 => {
93
+ let {
94
+ theme
95
+ } = _ref13;
96
+ return theme.fontWeights.regular;
97
+ });
59
98
  const StyledActionLink = /*#__PURE__*/styled__default["default"].a.withConfig({
60
99
  componentId: "sc-ffu2hq-5"
61
- })(["margin-left:", ";white-space:nowrap;text-decoration:none;line-height:1.1;font-size:", ";font-weight:", ";color:", ";"], ({
62
- theme,
63
- isBodyEmpty
64
- }) => isBodyEmpty ? theme.space.xs : 0, ({
65
- theme
66
- }) => theme.fontSizes.hyperlink[400], ({
67
- theme
68
- }) => theme.fontWeights.regular, ({
69
- theme
70
- }) => theme.colors.brand[600]);
100
+ })(["margin-left:", ";white-space:nowrap;text-decoration:none;line-height:1.1;font-size:", ";font-weight:", ";color:", ";"], _ref14 => {
101
+ let {
102
+ theme,
103
+ isBodyEmpty
104
+ } = _ref14;
105
+ return isBodyEmpty ? theme.space.xs : 0;
106
+ }, _ref15 => {
107
+ let {
108
+ theme
109
+ } = _ref15;
110
+ return theme.fontSizes.hyperlink[400];
111
+ }, _ref16 => {
112
+ let {
113
+ theme
114
+ } = _ref16;
115
+ return theme.fontWeights.regular;
116
+ }, _ref17 => {
117
+ let {
118
+ theme
119
+ } = _ref17;
120
+ return theme.colors.brand[600];
121
+ });
71
122
  const StyledCloseButton = /*#__PURE__*/styled__default["default"](DSButton__default["default"]).withConfig({
72
123
  componentId: "sc-ffu2hq-6"
73
- })(["margin-left:", ";&:not(focus){border:transparent;}"], ({
74
- theme
75
- }) => theme.space.s);
124
+ })(["margin-left:", ";&:not(focus){border:transparent;}"], _ref18 => {
125
+ let {
126
+ theme
127
+ } = _ref18;
128
+ return theme.space.xxs;
129
+ });
76
130
 
77
131
  exports.StyledActionLink = StyledActionLink;
78
132
  exports.StyledBannerContainer = StyledBannerContainer;
@@ -4,36 +4,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _jsx = require('@babel/runtime/helpers/jsx');
6
6
  require('react');
7
- var SuccessFill = require('@elliemae/ds-icons/SuccessFill');
8
- var InfoFill = require('@elliemae/ds-icons/InfoFill');
9
- var AlertsDetailFill = require('@elliemae/ds-icons/AlertsDetailFill');
10
- var WarningSquare = require('@elliemae/ds-icons/WarningSquare');
7
+ var dsIcons = require('@elliemae/ds-icons');
11
8
 
12
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
10
 
14
11
  var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
15
- var SuccessFill__default = /*#__PURE__*/_interopDefaultLegacy(SuccessFill);
16
- var InfoFill__default = /*#__PURE__*/_interopDefaultLegacy(InfoFill);
17
- var AlertsDetailFill__default = /*#__PURE__*/_interopDefaultLegacy(AlertsDetailFill);
18
- var WarningSquare__default = /*#__PURE__*/_interopDefaultLegacy(WarningSquare);
19
12
 
20
13
  const icons = {
21
- success: /*#__PURE__*/_jsx__default["default"](SuccessFill__default["default"], {
14
+ success: /*#__PURE__*/_jsx__default["default"](dsIcons.SuccessFill, {
22
15
  fill: "#207e56",
23
16
  width: "20px",
24
17
  height: "20px"
25
18
  }),
26
- info: /*#__PURE__*/_jsx__default["default"](InfoFill__default["default"], {
19
+ info: /*#__PURE__*/_jsx__default["default"](dsIcons.InfoFill, {
27
20
  fill: "#1e79c2",
28
21
  width: "20px",
29
22
  height: "20px"
30
23
  }),
31
- danger: /*#__PURE__*/_jsx__default["default"](AlertsDetailFill__default["default"], {
24
+ danger: /*#__PURE__*/_jsx__default["default"](dsIcons.AlertsDetailFill, {
32
25
  fill: "#c64252",
33
26
  width: "20px",
34
27
  height: "20px"
35
28
  }),
36
- warning: /*#__PURE__*/_jsx__default["default"](WarningSquare__default["default"], {
29
+ warning: /*#__PURE__*/_jsx__default["default"](dsIcons.WarningSquare, {
37
30
  fill: "#d17a00",
38
31
  width: "20px",
39
32
  height: "20px"
@@ -18,9 +18,11 @@ const spanContainer = height => dsSystem.kfrm(_templateObject3 || (_templateObje
18
18
 
19
19
  const shrinkContainer = height => dsSystem.kfrm(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["\n 0% {\n height: ", "px;\n }\n 100% {\n height: 0px;\n }\n"])), height);
20
20
 
21
- const handleBorderColor = (type, {
22
- colors
23
- }) => {
21
+ const handleBorderColor = (type, _ref) => {
22
+ let {
23
+ colors
24
+ } = _ref;
25
+
24
26
  switch (type) {
25
27
  case bannerTypes.BANNER_TYPES.SUCCESS:
26
28
  return colors.success[900];
@@ -35,7 +37,9 @@ const handleBorderColor = (type, {
35
37
  return colors.danger[900];
36
38
  }
37
39
  };
38
- const handleAnimation = (isAnimating, isOpen, height = null) => {
40
+ const handleAnimation = function (isAnimating, isOpen) {
41
+ let height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
42
+
39
43
  if (isAnimating) {
40
44
  if (isOpen) {
41
45
  return dsSystem.css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral__default["default"](["\n animation: ", " 0.5s ease-in;\n "])), height ? spanContainer(height) : slideIn);
package/esm/DSBanner.js CHANGED
@@ -1,8 +1,13 @@
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';
1
6
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
7
  import _jsx from '@babel/runtime/helpers/esm/jsx';
3
8
  import 'core-js/modules/web.dom-collections.iterator.js';
4
- import { useRef, useState, useEffect, useLayoutEffect, useCallback } from 'react';
5
- import CloseX from '@elliemae/ds-icons/CloseX';
9
+ import React, { useRef, useState, useLayoutEffect, useCallback } from 'react';
10
+ import { CloseX } from '@elliemae/ds-icons';
6
11
  import { describe } from 'react-desc';
7
12
  import { icons } from './utils/icons.js';
8
13
  import { propTypes } from './propTypes.js';
@@ -10,35 +15,54 @@ import { defaultProps } from './defaultProps.js';
10
15
  import { StyledBannerContainer, StyledInnerContainer, StyledIconContainer, StyledTitle, StyledSubTitle, StyledActionLink, StyledCloseButton } from './styles.js';
11
16
  import { jsx, jsxs } from 'react/jsx-runtime';
12
17
 
13
- var _CloseX;
18
+ var _CloseX, _span;
14
19
 
15
20
  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; }
16
21
 
17
22
  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) { _defineProperty(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; }
18
23
 
19
- const DSBanner = ({
20
- type,
21
- isOpen,
22
- onClose,
23
- label,
24
- body,
25
- actionLink,
26
- showCloseButton,
27
- containerProps
28
- }) => {
24
+ const DSBanner = _ref => {
25
+ let {
26
+ type,
27
+ isOpen,
28
+ onClose,
29
+ label,
30
+ body,
31
+ actionLink,
32
+ showCloseButton,
33
+ containerProps,
34
+ actionRef
35
+ } = _ref;
29
36
  const innerContainerRef = useRef(null);
30
37
  const linkRef = useRef(null);
31
38
  const [current, setCurrent] = useState(isOpen);
32
39
  const [isAnimating, setIsAnimating] = useState(false);
33
40
  const [height, setHeight] = useState(0);
34
- useEffect(() => {
35
- if (innerContainerRef.current) {
36
- setHeight(innerContainerRef.current.offsetHeight);
41
+ const [alertTabIndex, setAlertTabIndex] = useState(undefined);
42
+ React.useEffect(() => {
43
+ if (actionRef && actionRef.current) {
44
+ actionRef.current.focusOnWrapper = () => {
45
+ if (innerContainerRef.current) {
46
+ setAlertTabIndex(0);
47
+ setTimeout(() => {
48
+ innerContainerRef.current.focus();
49
+ }, 100);
50
+ }
51
+ };
52
+
53
+ actionRef.current.focusOnLink = () => {
54
+ if (linkRef.current) {
55
+ linkRef.current.focus();
56
+ }
57
+ };
37
58
  }
38
- }, [isAnimating, isOpen]);
59
+ }, [actionRef]);
39
60
  useLayoutEffect(() => {
40
61
  if (isOpen !== current || isOpen) setIsAnimating(true);else setIsAnimating(false);
41
62
  }, [isOpen, current]);
63
+ const handleBlur = useCallback(() => {
64
+ setAlertTabIndex(undefined);
65
+ }, []);
42
66
  const handleOnKeyDown = useCallback(e => {
43
67
  if (e.key === 'Enter' || e.key === ' ') {
44
68
  e.preventDefault();
@@ -61,6 +85,8 @@ const DSBanner = ({
61
85
  isAnimating: isAnimating,
62
86
  "data-testid": "ds-banner",
63
87
  role: "alert",
88
+ tabIndex: alertTabIndex,
89
+ onBlur: handleBlur,
64
90
  children: [/*#__PURE__*/_jsx(StyledIconContainer, {
65
91
  "data-testid": "ds-banner-icon"
66
92
  }, void 0, icons[type]), /*#__PURE__*/_jsx(StyledTitle, {}, void 0, label), /*#__PURE__*/_jsx(StyledSubTitle, {}, void 0, /*#__PURE__*/_jsx("span", {}, void 0, body), actionLink && /*#__PURE__*/jsx(StyledActionLink, {
@@ -72,7 +98,7 @@ const DSBanner = ({
72
98
  tabIndex: 0,
73
99
  isBodyEmpty: body,
74
100
  children: actionLink.label
75
- })), showCloseButton && /*#__PURE__*/_jsx(StyledCloseButton, {
101
+ })), showCloseButton ? /*#__PURE__*/_jsx(StyledCloseButton, {
76
102
  "data-testid": "ds-banner-close-button",
77
103
  buttonType: "secondary",
78
104
  onClick: onClose,
@@ -81,7 +107,7 @@ const DSBanner = ({
81
107
  width: "12px",
82
108
  height: "12px"
83
109
  }))
84
- })]
110
+ }) : _span || (_span = /*#__PURE__*/_jsx("span", {}))]
85
111
  })
86
112
  }));
87
113
  };
package/esm/propTypes.js CHANGED
@@ -13,7 +13,8 @@ const propTypes = {
13
13
  label: PropTypes.string,
14
14
  onClick: PropTypes.func,
15
15
  href: PropTypes.string
16
- }).description('Properties of the ActionLink component').defaultValue({})
16
+ }).description('Properties of the ActionLink component').defaultValue({}),
17
+ actionRef: PropTypes.object.description("\n Reference to use actions:\n - focusOnLink: function to focus the banner\n - focusOnWrapper: function to focus the link\n ").defaultValue({})
17
18
  };
18
19
 
19
20
  export { propTypes };
package/esm/styles.js CHANGED
@@ -1,68 +1,122 @@
1
1
  import styled from 'styled-components';
2
- import DSButton from '@elliemae/ds-basic/Button';
2
+ import DSButton from '@elliemae/ds-button';
3
3
  import { handleAnimation, handleBorderColor } from './utils/styleHelpers.js';
4
4
 
5
5
  const StyledBannerContainer = /*#__PURE__*/styled.div.withConfig({
6
6
  componentId: "sc-ffu2hq-0"
7
- })(["overflow:hidden;height:", ";", ";"], ({
8
- isOpen
9
- }) => isOpen ? 'auto' : '0px', ({
10
- isAnimating,
11
- isOpen,
12
- height
13
- }) => handleAnimation(isAnimating, isOpen, height));
7
+ })(["overflow:hidden;height:", ";", ";"], _ref => {
8
+ let {
9
+ isOpen
10
+ } = _ref;
11
+ return isOpen ? 'auto' : '0px';
12
+ }, _ref2 => {
13
+ let {
14
+ isAnimating,
15
+ isOpen,
16
+ height
17
+ } = _ref2;
18
+ return handleAnimation(isAnimating, isOpen, height);
19
+ });
14
20
  const StyledInnerContainer = /*#__PURE__*/styled.div.withConfig({
15
21
  componentId: "sc-ffu2hq-1"
16
- })(["padding-right:6px;display:flex;align-items:center;min-height:41px;width:100%;background-color:", ";border-bottom:5px solid ", ";", ";"], ({
17
- theme
18
- }) => theme.colors.neutral['000'], ({
19
- type,
20
- theme
21
- }) => handleBorderColor(type, theme), ({
22
- isAnimating,
23
- isOpen
24
- }) => handleAnimation(isAnimating, isOpen));
22
+ })(["padding-right:6px;display:grid;align-items:center;min-height:41px;width:100%;background-color:", ";border-bottom:5px solid ", ";", ";&:focus{position:relative;&:after{content:'';display:block;position:absolute;top:0;left:0;pointer-events:none;border-radius:2px;width:calc(100%);border:2px solid #1e79c2;height:calc(100% + 4px);}}grid-template-columns:auto minmax(auto,auto) minmax(auto,1fr) auto;"], _ref3 => {
23
+ let {
24
+ theme
25
+ } = _ref3;
26
+ return theme.colors.neutral['000'];
27
+ }, _ref4 => {
28
+ let {
29
+ type,
30
+ theme
31
+ } = _ref4;
32
+ return handleBorderColor(type, theme);
33
+ }, _ref5 => {
34
+ let {
35
+ isAnimating,
36
+ isOpen
37
+ } = _ref5;
38
+ return handleAnimation(isAnimating, isOpen);
39
+ });
25
40
  const StyledIconContainer = /*#__PURE__*/styled.div.withConfig({
26
41
  componentId: "sc-ffu2hq-2"
27
- })(["margin-right:", ";margin-left:", ";"], ({
28
- theme
29
- }) => theme.space.xxs, ({
30
- theme
31
- }) => theme.space.xs);
42
+ })(["margin-right:", ";margin-left:", ";"], _ref6 => {
43
+ let {
44
+ theme
45
+ } = _ref6;
46
+ return theme.space.xxs;
47
+ }, _ref7 => {
48
+ let {
49
+ theme
50
+ } = _ref7;
51
+ return theme.space.xs;
52
+ });
32
53
  const StyledTitle = /*#__PURE__*/styled.div.withConfig({
33
54
  componentId: "sc-ffu2hq-3"
34
- })(["color:", ";font-size:", ";font-weight:", ";white-space:nowrap;"], ({
35
- theme
36
- }) => theme.colors.neutral[700], ({
37
- theme
38
- }) => theme.fontSizes.label[400], ({
39
- theme
40
- }) => theme.fontWeights.semibold);
55
+ })(["color:", ";font-size:", ";font-weight:", ";"], _ref8 => {
56
+ let {
57
+ theme
58
+ } = _ref8;
59
+ return theme.colors.neutral[700];
60
+ }, _ref9 => {
61
+ let {
62
+ theme
63
+ } = _ref9;
64
+ return theme.fontSizes.label[400];
65
+ }, _ref10 => {
66
+ let {
67
+ theme
68
+ } = _ref10;
69
+ return theme.fontWeights.semibold;
70
+ });
41
71
  const StyledSubTitle = /*#__PURE__*/styled.div.withConfig({
42
72
  componentId: "sc-ffu2hq-4"
43
- })(["width:100%;margin-left:", ";font-size:", ";font-weight:", ";"], ({
44
- theme
45
- }) => theme.space.xs, ({
46
- theme
47
- }) => theme.fontSizes.subTitle[400], ({
48
- theme
49
- }) => theme.fontWeights.regular);
73
+ })(["width:100%;margin-left:", ";font-size:", ";font-weight:", ";"], _ref11 => {
74
+ let {
75
+ theme
76
+ } = _ref11;
77
+ return theme.space.xs;
78
+ }, _ref12 => {
79
+ let {
80
+ theme
81
+ } = _ref12;
82
+ return theme.fontSizes.subTitle[400];
83
+ }, _ref13 => {
84
+ let {
85
+ theme
86
+ } = _ref13;
87
+ return theme.fontWeights.regular;
88
+ });
50
89
  const StyledActionLink = /*#__PURE__*/styled.a.withConfig({
51
90
  componentId: "sc-ffu2hq-5"
52
- })(["margin-left:", ";white-space:nowrap;text-decoration:none;line-height:1.1;font-size:", ";font-weight:", ";color:", ";"], ({
53
- theme,
54
- isBodyEmpty
55
- }) => isBodyEmpty ? theme.space.xs : 0, ({
56
- theme
57
- }) => theme.fontSizes.hyperlink[400], ({
58
- theme
59
- }) => theme.fontWeights.regular, ({
60
- theme
61
- }) => theme.colors.brand[600]);
91
+ })(["margin-left:", ";white-space:nowrap;text-decoration:none;line-height:1.1;font-size:", ";font-weight:", ";color:", ";"], _ref14 => {
92
+ let {
93
+ theme,
94
+ isBodyEmpty
95
+ } = _ref14;
96
+ return isBodyEmpty ? theme.space.xs : 0;
97
+ }, _ref15 => {
98
+ let {
99
+ theme
100
+ } = _ref15;
101
+ return theme.fontSizes.hyperlink[400];
102
+ }, _ref16 => {
103
+ let {
104
+ theme
105
+ } = _ref16;
106
+ return theme.fontWeights.regular;
107
+ }, _ref17 => {
108
+ let {
109
+ theme
110
+ } = _ref17;
111
+ return theme.colors.brand[600];
112
+ });
62
113
  const StyledCloseButton = /*#__PURE__*/styled(DSButton).withConfig({
63
114
  componentId: "sc-ffu2hq-6"
64
- })(["margin-left:", ";&:not(focus){border:transparent;}"], ({
65
- theme
66
- }) => theme.space.s);
115
+ })(["margin-left:", ";&:not(focus){border:transparent;}"], _ref18 => {
116
+ let {
117
+ theme
118
+ } = _ref18;
119
+ return theme.space.xxs;
120
+ });
67
121
 
68
122
  export { StyledActionLink, StyledBannerContainer, StyledCloseButton, StyledIconContainer, StyledInnerContainer, StyledSubTitle, StyledTitle };
@@ -1,9 +1,6 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import 'react';
3
- import SuccessFill from '@elliemae/ds-icons/SuccessFill';
4
- import InfoFill from '@elliemae/ds-icons/InfoFill';
5
- import AlertsDetailFill from '@elliemae/ds-icons/AlertsDetailFill';
6
- import WarningSquare from '@elliemae/ds-icons/WarningSquare';
3
+ import { SuccessFill, InfoFill, AlertsDetailFill, WarningSquare } from '@elliemae/ds-icons';
7
4
 
8
5
  const icons = {
9
6
  success: /*#__PURE__*/_jsx(SuccessFill, {
@@ -10,9 +10,11 @@ const spanContainer = height => kfrm(_templateObject3 || (_templateObject3 = _ta
10
10
 
11
11
  const shrinkContainer = height => kfrm(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n 0% {\n height: ", "px;\n }\n 100% {\n height: 0px;\n }\n"])), height);
12
12
 
13
- const handleBorderColor = (type, {
14
- colors
15
- }) => {
13
+ const handleBorderColor = (type, _ref) => {
14
+ let {
15
+ colors
16
+ } = _ref;
17
+
16
18
  switch (type) {
17
19
  case BANNER_TYPES.SUCCESS:
18
20
  return colors.success[900];
@@ -27,7 +29,9 @@ const handleBorderColor = (type, {
27
29
  return colors.danger[900];
28
30
  }
29
31
  };
30
- const handleAnimation = (isAnimating, isOpen, height = null) => {
32
+ const handleAnimation = function (isAnimating, isOpen) {
33
+ let height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
34
+
31
35
  if (isAnimating) {
32
36
  if (isOpen) {
33
37
  return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n animation: ", " 0.5s ease-in;\n "])), height ? spanContainer(height) : slideIn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-banner",
3
- "version": "2.0.0-next.10",
3
+ "version": "2.0.0-next.11",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Banner",
6
6
  "module": "./esm/index.js",
@@ -60,17 +60,20 @@
60
60
  "build": "node ../../scripts/build/build.js"
61
61
  },
62
62
  "dependencies": {
63
- "@elliemae/ds-basic": "2.0.0-next.10",
64
- "@elliemae/ds-classnames": "2.0.0-next.10"
63
+ "@elliemae/ds-basic": "2.0.0-next.11",
64
+ "@elliemae/ds-classnames": "2.0.0-next.11",
65
+ "@elliemae/ds-icons": "2.0.0-next.11",
66
+ "@elliemae/ds-system": "2.0.0-next.11",
67
+ "react-desc": "~4.1.2"
65
68
  },
66
69
  "devDependencies": {
67
- "styled-components": "~5.3.1"
70
+ "styled-components": "~5.3.3"
68
71
  },
69
72
  "peerDependencies": {
70
73
  "lodash": "^4.17.21",
71
74
  "react": "^17.0.2",
72
75
  "react-dom": "^17.0.2",
73
- "styled-components": "^5.3.1"
76
+ "styled-components": "^5.3.3"
74
77
  },
75
78
  "publishConfig": {
76
79
  "access": "public",
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { BannerPropsT } from './index.d';
3
3
  declare const DSBanner: {
4
- ({ type, isOpen, onClose, label, body, actionLink, showCloseButton, containerProps, }: BannerPropsT): JSX.Element;
4
+ ({ type, isOpen, onClose, label, body, actionLink, showCloseButton, containerProps, actionRef, }: BannerPropsT): JSX.Element;
5
5
  defaultProps: {
6
6
  containerProps: {};
7
7
  label: string;
@@ -25,6 +25,7 @@ declare const DSBanner: {
25
25
  isOpen: any;
26
26
  showCloseButton: any;
27
27
  actionLink: any;
28
+ actionRef: any;
28
29
  };
29
30
  };
30
31
  declare const DSBannerWithSchema: any;
@@ -7,4 +7,5 @@ export declare const propTypes: {
7
7
  isOpen: any;
8
8
  showCloseButton: any;
9
9
  actionLink: any;
10
+ actionRef: any;
10
11
  };
package/types/styles.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { StyledActionLinkT, StyledBannerContainerT, StyledInnerContainerT } from './index.d';
2
3
  export declare const StyledBannerContainer: import("styled-components").StyledComponent<"div", any, StyledBannerContainerT, never>;
3
4
  export declare const StyledInnerContainer: import("styled-components").StyledComponent<"div", any, StyledInnerContainerT, never>;
@@ -5,4 +6,62 @@ export declare const StyledIconContainer: import("styled-components").StyledComp
5
6
  export declare const StyledTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
6
7
  export declare const StyledSubTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
7
8
  export declare const StyledActionLink: import("styled-components").StyledComponent<"a", any, StyledActionLinkT, never>;
8
- export declare const StyledCloseButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
9
+ export declare const StyledCloseButton: import("styled-components").StyledComponent<{
10
+ ({ innerRef, disabled, buttonType, fluidWidth, size, labelText, icon, onBlur, onClick, onKeyPress, leftIcon, tabIndex, variant, intent, containerProps, className, as: Component, type, ...rest }: {
11
+ [x: string]: any;
12
+ innerRef: any;
13
+ disabled: any;
14
+ buttonType: any;
15
+ fluidWidth: any;
16
+ size: any;
17
+ labelText: any;
18
+ icon: any;
19
+ onBlur: any;
20
+ onClick: any;
21
+ onKeyPress: any;
22
+ leftIcon: any;
23
+ tabIndex: any;
24
+ variant: any;
25
+ intent: any;
26
+ containerProps: any;
27
+ className: any;
28
+ as: any;
29
+ type: any;
30
+ }): JSX.Element;
31
+ defaultProps: {
32
+ disabled: boolean;
33
+ fluidWidth: boolean;
34
+ labelText: string;
35
+ icon: null;
36
+ onBlur: () => null;
37
+ onClick: () => null;
38
+ onKeyPress: () => null;
39
+ leftIcon: null;
40
+ tabIndex: number;
41
+ variant: string;
42
+ containerProps: {};
43
+ as: string;
44
+ type: string;
45
+ };
46
+ propTypes: {
47
+ tabIndex: any;
48
+ className: any;
49
+ 'aria-disabled': any;
50
+ as: any;
51
+ disabled: any;
52
+ fluidWidth: any;
53
+ labelText: any;
54
+ icon: any;
55
+ leftIcon: any;
56
+ buttonType: any;
57
+ size: any;
58
+ type: any;
59
+ variant: any;
60
+ innerRef: any;
61
+ onBlur: any;
62
+ intent: any;
63
+ containerProps: any;
64
+ onClick: any;
65
+ onKeyPress: any;
66
+ };
67
+ }, any, {}, never>;