@elliemae/ds-banner 3.3.0-next.3 → 3.3.0-next.6
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/dist/cjs/DSBanner.js +8 -31
- package/dist/cjs/DSBanner.js.map +1 -1
- package/dist/cjs/react-desc-prop-types.js +4 -19
- package/dist/cjs/react-desc-prop-types.js.map +1 -1
- package/dist/esm/DSBanner.js +8 -33
- package/dist/esm/DSBanner.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js +4 -21
- package/dist/esm/react-desc-prop-types.js.map +1 -1
- package/package.json +5 -5
package/dist/cjs/DSBanner.js
CHANGED
|
@@ -3,34 +3,8 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __objRest = (source, exclude) => {
|
|
23
|
-
var target = {};
|
|
24
|
-
for (var prop in source)
|
|
25
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
if (source != null && __getOwnPropSymbols)
|
|
28
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
8
|
var __export = (target, all) => {
|
|
35
9
|
for (var name in all)
|
|
36
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -62,8 +36,8 @@ var import_exported_related = require("./exported-related");
|
|
|
62
36
|
var import_styles = require("./styles");
|
|
63
37
|
const DSBanner = (props) => {
|
|
64
38
|
const propsWithDefaults = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
|
|
65
|
-
const
|
|
66
|
-
const
|
|
39
|
+
const { type, isOpen, onClose, label, body, actionLink, showCloseButton, containerProps, actionRef, ...rest } = propsWithDefaults;
|
|
40
|
+
const { height: globalHeight, ...globalAttrs } = (0, import_ds_utilities.useGetGlobalAttributes)(rest);
|
|
67
41
|
const xstyledAttrs = (0, import_ds_utilities.useGetXstyledProps)(rest);
|
|
68
42
|
const innerContainerRef = (0, import_react.useRef)(null);
|
|
69
43
|
const linkRef = (0, import_react.useRef)(null);
|
|
@@ -111,13 +85,16 @@ const DSBanner = (props) => {
|
|
|
111
85
|
}, [isOpen, current]);
|
|
112
86
|
if (!isAnimating && !isOpen)
|
|
113
87
|
return null;
|
|
114
|
-
return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledBannerContainer,
|
|
88
|
+
return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledBannerContainer, {
|
|
115
89
|
isOpen,
|
|
116
90
|
height,
|
|
117
91
|
isAnimating,
|
|
118
92
|
onAnimationEnd: () => setCurrent(isOpen),
|
|
119
|
-
"data-testid": import_exported_related.DSBannerDatatestid.CONTAINER
|
|
120
|
-
|
|
93
|
+
"data-testid": import_exported_related.DSBannerDatatestid.CONTAINER,
|
|
94
|
+
...containerProps,
|
|
95
|
+
...globalAttrs,
|
|
96
|
+
...xstyledAttrs
|
|
97
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledInnerContainer, {
|
|
121
98
|
type,
|
|
122
99
|
isOpen,
|
|
123
100
|
ref: innerContainerRef,
|
package/dist/cjs/DSBanner.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSBanner.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useCallback, useState, useEffect } from 'react';\nimport {\n describe,\n useMemoMergePropsWithDefault,\n useGetGlobalAttributes,\n useGetXstyledProps,\n} from '@elliemae/ds-utilities';\nimport { CloseX } from '@elliemae/ds-icons';\nimport { icons } from './utils/icons';\nimport { propTypes, defaultProps } from './react-desc-prop-types';\nimport { DSBannerDatatestid, DSBannerName } from './exported-related';\nimport {\n StyledActionLink,\n StyledCloseButton,\n StyledInnerContainer,\n StyledBannerContainer,\n StyledIconContainer,\n StyledSubTitle,\n StyledTitle,\n} from './styles';\nimport type { DSBannerT } from './react-desc-prop-types';\n\nconst DSBanner: React.ComponentType<DSBannerT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n\n const { type, isOpen, onClose, label, body, actionLink, showCloseButton, containerProps, actionRef, ...rest } =\n propsWithDefaults;\n\n const { height: globalHeight, ...globalAttrs } = useGetGlobalAttributes(rest);\n\n const xstyledAttrs = useGetXstyledProps(rest);\n\n const innerContainerRef = useRef<HTMLDivElement>(null);\n const linkRef = useRef<HTMLAnchorElement>(null);\n const [current, setCurrent] = useState<boolean>(isOpen);\n const [isAnimating, setIsAnimating] = useState<boolean>(false);\n const [height, setHeight] = useState(0);\n const [alertTabIndex, setAlertTabIndex] = useState<number | undefined>(undefined);\n\n useEffect(() => {\n if (innerContainerRef.current) {\n setHeight(innerContainerRef.current.offsetHeight);\n }\n }, [isAnimating, isOpen]);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnWrapper = () => {\n if (innerContainerRef.current) {\n setAlertTabIndex(0);\n setTimeout(() => {\n innerContainerRef.current?.focus();\n }, 300);\n }\n };\n actionRef.current.focusOnLink = () => {\n if (linkRef.current) {\n linkRef.current.focus();\n }\n };\n }\n }, [actionRef]);\n\n const handleBlur = useCallback(() => {\n setAlertTabIndex(undefined);\n }, []);\n\n const handleOnKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n if (linkRef.current) linkRef.current.click();\n }\n }, []);\n\n useLayoutEffect(() => {\n if (isOpen !== current || isOpen) setIsAnimating(true);\n else setIsAnimating(false);\n }, [isOpen, current]);\n\n if (!isAnimating && !isOpen) return null;\n\n return (\n <StyledBannerContainer\n isOpen={isOpen}\n height={height}\n isAnimating={isAnimating}\n onAnimationEnd={() => setCurrent(isOpen)}\n data-testid={DSBannerDatatestid.CONTAINER}\n {...containerProps}\n {...globalAttrs}\n {...xstyledAttrs}\n >\n <StyledInnerContainer\n type={type}\n isOpen={isOpen}\n ref={innerContainerRef}\n isAnimating={isAnimating}\n data-testid={DSBannerDatatestid.INNER_CONTAINER}\n role=\"alert\"\n tabIndex={alertTabIndex}\n onBlur={handleBlur}\n >\n <StyledIconContainer data-testid={DSBannerDatatestid.ICON_CONTAINER}>{icons[type]}</StyledIconContainer>\n <StyledTitle>{label}</StyledTitle>\n <StyledSubTitle>\n <span>{body}</span>\n {actionLink && (\n <StyledActionLink\n data-testid={DSBannerDatatestid.ACTION_LINK}\n onClick={actionLink.onClick}\n href={actionLink.href}\n ref={linkRef}\n onKeyDown={handleOnKeyDown}\n tabIndex={0}\n isBodyEmpty={body}\n >\n {actionLink.label}\n </StyledActionLink>\n )}\n </StyledSubTitle>\n {showCloseButton ? (\n <StyledCloseButton\n data-testid={DSBannerDatatestid.CLOSE_BUTTON}\n buttonType=\"icon\"\n onClick={onClose}\n aria-label=\"Close icon\"\n >\n <CloseX width={12} height={12} />\n </StyledCloseButton>\n ) : (\n <span />\n )}\n </StyledInnerContainer>\n </StyledBannerContainer>\n );\n};\n\nDSBanner.displayName = DSBannerName;\nconst DSBannerWithSchema = describe(DSBanner);\nDSBannerWithSchema.propTypes = propTypes;\n\nexport default DSBanner;\nexport { DSBanner, DSBannerWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAiF;AACjF,0BAKO;AACP,sBAAuB;AACvB,mBAAsB;AACtB,mCAAwC;AACxC,8BAAiD;AACjD,oBAQO;AAGP,MAAM,WAAiD,CAAC,UAAU;AAChE,QAAM,oBAAoB,sDAA6B,OAAO,yCAAY;AAE1E,QAAM,EAAE,MAAM,QAAQ,SAAS,OAAO,MAAM,YAAY,iBAAiB,gBAAgB,cAAc,SACrG;AAEF,QAAM,EAAE,QAAQ,iBAAiB,gBAAgB,gDAAuB,IAAI;AAE5E,QAAM,eAAe,4CAAmB,IAAI;AAE5C,QAAM,oBAAoB,yBAAuB,IAAI;AACrD,QAAM,UAAU,yBAA0B,IAAI;AAC9C,QAAM,CAAC,SAAS,cAAc,2BAAkB,MAAM;AACtD,QAAM,CAAC,aAAa,kBAAkB,2BAAkB,KAAK;AAC7D,QAAM,CAAC,QAAQ,aAAa,2BAAS,CAAC;AACtC,QAAM,CAAC,eAAe,oBAAoB,2BAA6B,MAAS;AAEhF,8BAAU,MAAM;AACd,QAAI,kBAAkB,SAAS;AAC7B,gBAAU,kBAAkB,QAAQ,YAAY;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,aAAa,MAAM,CAAC;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DAAC,iCAAa,KAAM,GACpB,mDAAC,oCACC,mDAAC,cAAM,IAAK,GACX,cACC,mDAAC;AAAA,IACC,eAAa,2CAAmB;AAAA,IAChC,SAAS,WAAW;AAAA,IACpB,MAAM,WAAW;AAAA,IACjB,KAAK;AAAA,IACL,WAAW;AAAA,IACX,UAAU;AAAA,IACV,aAAa;AAAA,KAEZ,WAAW,KACd,CAEJ,GACC,kBACC,mDAAC;AAAA,IACC,eAAa,2CAAmB;AAAA,IAChC,YAAW;AAAA,IACX,SAAS;AAAA,IACT,cAAW;AAAA,KAEX,mDAAC;AAAA,IAAO,OAAO;AAAA,IAAI,QAAQ;AAAA,GAAI,CACjC,IAEA,mDAAC,YAAK,CAEV,CACF;AAEJ;AAEA,SAAS,cAAc;AACvB,MAAM,qBAAqB,kCAAS,QAAQ;AAC5C,mBAAmB,YAAY;AAE/B,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -54,7 +37,9 @@ const defaultProps = {
|
|
|
54
37
|
onClose: () => null,
|
|
55
38
|
showCloseButton: true
|
|
56
39
|
};
|
|
57
|
-
const propTypes =
|
|
40
|
+
const propTypes = {
|
|
41
|
+
...import_ds_utilities.globalAttributesPropTypes,
|
|
42
|
+
...import_ds_utilities.xstyledPropTypes,
|
|
58
43
|
containerProps: import_ds_utilities.PropTypes.object.description("Set of Properties attached to the main container.").defaultValue({}),
|
|
59
44
|
label: import_ds_utilities.PropTypes.string.description("Banner label.").defaultValue(""),
|
|
60
45
|
body: import_ds_utilities.PropTypes.string.description("Banner body content").defaultValue(""),
|
|
@@ -72,5 +57,5 @@ const propTypes = __spreadProps(__spreadValues(__spreadValues({}, import_ds_util
|
|
|
72
57
|
- focusOnLink: function to focus the banner
|
|
73
58
|
- focusOnWrapper: function to focus the link
|
|
74
59
|
`).defaultValue({})
|
|
75
|
-
}
|
|
60
|
+
};
|
|
76
61
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { WeakValidationMap } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-utilities';\nimport { BANNER_TYPES } from './exported-related';\nimport type { DSBannerInternalsT } from './sharedTypes';\n\nexport declare namespace DSBannerT {\n export interface Props {\n type?: DSBannerInternalsT.BannerTypesT;\n isOpen?: boolean;\n onClose?: () => void | null;\n actionLink?: DSBannerInternalsT.ActionLinkT;\n label?: string;\n body?: string;\n showCloseButton?: boolean;\n containerProps?: Record<string, unknown>;\n actionRef?: {\n current: {\n focusOnWrapper?: () => void;\n focusOnLink?: () => void;\n };\n };\n }\n}\n\nexport const defaultProps: DSBannerT.Props = {\n containerProps: {},\n label: '',\n body: '',\n type: BANNER_TYPES.INFO,\n isOpen: true,\n onClose: () => null,\n showCloseButton: true,\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n containerProps: PropTypes.object.description('Set of Properties attached to the main container.').defaultValue({}),\n label: PropTypes.string.description('Banner label.').defaultValue(''),\n body: PropTypes.string.description('Banner body content').defaultValue(''),\n type: PropTypes.oneOf(Object.values(BANNER_TYPES)).description('Banner type.').defaultValue(BANNER_TYPES.INFO),\n onClose: PropTypes.func.description('Callback when the Banner closes.'),\n isOpen: PropTypes.bool.description('Whether the Banner is open or closed.').defaultValue(true),\n showCloseButton: PropTypes.bool.description('Whether to show close button or not.').defaultValue(true),\n actionLink: PropTypes.shape({\n label: PropTypes.string,\n onClick: PropTypes.func,\n href: PropTypes.string,\n })\n .description('Properties for the Action Link.')\n .defaultValue({}),\n actionRef: PropTypes.object\n .description(\n `\n Reference to use actions:\n - focusOnLink: function to focus the banner\n - focusOnWrapper: function to focus the link\n `,\n )\n .defaultValue({}),\n} as WeakValidationMap<unknown>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,0BAAuE;AACvE,8BAA6B;AAsBtB,MAAM,eAAgC;AAAA,EAC3C,gBAAgB,CAAC;AAAA,EACjB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM,qCAAa;AAAA,EACnB,QAAQ;AAAA,EACR,SAAS,MAAM;AAAA,EACf,iBAAiB;AACnB;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,gBAAgB,8BAAU,OAAO,YAAY,mDAAmD,EAAE,aAAa,CAAC,CAAC;AAAA,EACjH,OAAO,8BAAU,OAAO,YAAY,eAAe,EAAE,aAAa,EAAE;AAAA,EACpE,MAAM,8BAAU,OAAO,YAAY,qBAAqB,EAAE,aAAa,EAAE;AAAA,EACzE,MAAM,8BAAU,MAAM,OAAO,OAAO,oCAAY,CAAC,EAAE,YAAY,cAAc,EAAE,aAAa,qCAAa,IAAI;AAAA,EAC7G,SAAS,8BAAU,KAAK,YAAY,kCAAkC;AAAA,EACtE,QAAQ,8BAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,IAAI;AAAA,EAC7F,iBAAiB,8BAAU,KAAK,YAAY,sCAAsC,EAAE,aAAa,IAAI;AAAA,EACrG,YAAY,8BAAU,MAAM;AAAA,IAC1B,OAAO,8BAAU;AAAA,IACjB,SAAS,8BAAU;AAAA,IACnB,MAAM,8BAAU;AAAA,EAClB,CAAC,EACE,YAAY,iCAAiC,EAC7C,aAAa,CAAC,CAAC;AAAA,EAClB,WAAW,8BAAU,OAClB,YACC;AAAA;AAAA;AAAA;AAAA,KAKF,EACC,aAAa,CAAC,CAAC;AACpB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSBanner.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __spreadValues = (a, b) => {
|
|
8
|
-
for (var prop in b || (b = {}))
|
|
9
|
-
if (__hasOwnProp.call(b, prop))
|
|
10
|
-
__defNormalProp(a, prop, b[prop]);
|
|
11
|
-
if (__getOwnPropSymbols)
|
|
12
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
13
|
-
if (__propIsEnum.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
}
|
|
16
|
-
return a;
|
|
17
|
-
};
|
|
18
|
-
var __objRest = (source, exclude) => {
|
|
19
|
-
var target = {};
|
|
20
|
-
for (var prop in source)
|
|
21
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
22
|
-
target[prop] = source[prop];
|
|
23
|
-
if (source != null && __getOwnPropSymbols)
|
|
24
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
25
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
}
|
|
28
|
-
return target;
|
|
29
|
-
};
|
|
30
2
|
import * as React from "react";
|
|
31
3
|
import React2, { useLayoutEffect, useRef, useCallback, useState, useEffect } from "react";
|
|
32
4
|
import {
|
|
@@ -50,8 +22,8 @@ import {
|
|
|
50
22
|
} from "./styles";
|
|
51
23
|
const DSBanner = (props) => {
|
|
52
24
|
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
25
|
+
const { type, isOpen, onClose, label, body, actionLink, showCloseButton, containerProps, actionRef, ...rest } = propsWithDefaults;
|
|
26
|
+
const { height: globalHeight, ...globalAttrs } = useGetGlobalAttributes(rest);
|
|
55
27
|
const xstyledAttrs = useGetXstyledProps(rest);
|
|
56
28
|
const innerContainerRef = useRef(null);
|
|
57
29
|
const linkRef = useRef(null);
|
|
@@ -99,13 +71,16 @@ const DSBanner = (props) => {
|
|
|
99
71
|
}, [isOpen, current]);
|
|
100
72
|
if (!isAnimating && !isOpen)
|
|
101
73
|
return null;
|
|
102
|
-
return /* @__PURE__ */ React2.createElement(StyledBannerContainer,
|
|
74
|
+
return /* @__PURE__ */ React2.createElement(StyledBannerContainer, {
|
|
103
75
|
isOpen,
|
|
104
76
|
height,
|
|
105
77
|
isAnimating,
|
|
106
78
|
onAnimationEnd: () => setCurrent(isOpen),
|
|
107
|
-
"data-testid": DSBannerDatatestid.CONTAINER
|
|
108
|
-
|
|
79
|
+
"data-testid": DSBannerDatatestid.CONTAINER,
|
|
80
|
+
...containerProps,
|
|
81
|
+
...globalAttrs,
|
|
82
|
+
...xstyledAttrs
|
|
83
|
+
}, /* @__PURE__ */ React2.createElement(StyledInnerContainer, {
|
|
109
84
|
type,
|
|
110
85
|
isOpen,
|
|
111
86
|
ref: innerContainerRef,
|
package/dist/esm/DSBanner.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSBanner.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useCallback, useState, useEffect } from 'react';\nimport {\n describe,\n useMemoMergePropsWithDefault,\n useGetGlobalAttributes,\n useGetXstyledProps,\n} from '@elliemae/ds-utilities';\nimport { CloseX } from '@elliemae/ds-icons';\nimport { icons } from './utils/icons';\nimport { propTypes, defaultProps } from './react-desc-prop-types';\nimport { DSBannerDatatestid, DSBannerName } from './exported-related';\nimport {\n StyledActionLink,\n StyledCloseButton,\n StyledInnerContainer,\n StyledBannerContainer,\n StyledIconContainer,\n StyledSubTitle,\n StyledTitle,\n} from './styles';\nimport type { DSBannerT } from './react-desc-prop-types';\n\nconst DSBanner: React.ComponentType<DSBannerT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n\n const { type, isOpen, onClose, label, body, actionLink, showCloseButton, containerProps, actionRef, ...rest } =\n propsWithDefaults;\n\n const { height: globalHeight, ...globalAttrs } = useGetGlobalAttributes(rest);\n\n const xstyledAttrs = useGetXstyledProps(rest);\n\n const innerContainerRef = useRef<HTMLDivElement>(null);\n const linkRef = useRef<HTMLAnchorElement>(null);\n const [current, setCurrent] = useState<boolean>(isOpen);\n const [isAnimating, setIsAnimating] = useState<boolean>(false);\n const [height, setHeight] = useState(0);\n const [alertTabIndex, setAlertTabIndex] = useState<number | undefined>(undefined);\n\n useEffect(() => {\n if (innerContainerRef.current) {\n setHeight(innerContainerRef.current.offsetHeight);\n }\n }, [isAnimating, isOpen]);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnWrapper = () => {\n if (innerContainerRef.current) {\n setAlertTabIndex(0);\n setTimeout(() => {\n innerContainerRef.current?.focus();\n }, 300);\n }\n };\n actionRef.current.focusOnLink = () => {\n if (linkRef.current) {\n linkRef.current.focus();\n }\n };\n }\n }, [actionRef]);\n\n const handleBlur = useCallback(() => {\n setAlertTabIndex(undefined);\n }, []);\n\n const handleOnKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n if (linkRef.current) linkRef.current.click();\n }\n }, []);\n\n useLayoutEffect(() => {\n if (isOpen !== current || isOpen) setIsAnimating(true);\n else setIsAnimating(false);\n }, [isOpen, current]);\n\n if (!isAnimating && !isOpen) return null;\n\n return (\n <StyledBannerContainer\n isOpen={isOpen}\n height={height}\n isAnimating={isAnimating}\n onAnimationEnd={() => setCurrent(isOpen)}\n data-testid={DSBannerDatatestid.CONTAINER}\n {...containerProps}\n {...globalAttrs}\n {...xstyledAttrs}\n >\n <StyledInnerContainer\n type={type}\n isOpen={isOpen}\n ref={innerContainerRef}\n isAnimating={isAnimating}\n data-testid={DSBannerDatatestid.INNER_CONTAINER}\n role=\"alert\"\n tabIndex={alertTabIndex}\n onBlur={handleBlur}\n >\n <StyledIconContainer data-testid={DSBannerDatatestid.ICON_CONTAINER}>{icons[type]}</StyledIconContainer>\n <StyledTitle>{label}</StyledTitle>\n <StyledSubTitle>\n <span>{body}</span>\n {actionLink && (\n <StyledActionLink\n data-testid={DSBannerDatatestid.ACTION_LINK}\n onClick={actionLink.onClick}\n href={actionLink.href}\n ref={linkRef}\n onKeyDown={handleOnKeyDown}\n tabIndex={0}\n isBodyEmpty={body}\n >\n {actionLink.label}\n </StyledActionLink>\n )}\n </StyledSubTitle>\n {showCloseButton ? (\n <StyledCloseButton\n data-testid={DSBannerDatatestid.CLOSE_BUTTON}\n buttonType=\"icon\"\n onClick={onClose}\n aria-label=\"Close icon\"\n >\n <CloseX width={12} height={12} />\n </StyledCloseButton>\n ) : (\n <span />\n )}\n </StyledInnerContainer>\n </StyledBannerContainer>\n );\n};\n\nDSBanner.displayName = DSBannerName;\nconst DSBannerWithSchema = describe(DSBanner);\nDSBannerWithSchema.propTypes = propTypes;\n\nexport default DSBanner;\nexport { DSBanner, DSBannerWithSchema };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAAA;ACCA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,WAAiD,CAAC,UAAU;AAChE,QAAM,oBAAoB,6BAA6B,OAAO,YAAY;AAE1E,QAAM,EAAE,MAAM,QAAQ,SAAS,OAAO,MAAM,YAAY,iBAAiB,gBAAgB,cAAc,SACrG;AAEF,QAAM,EAAE,QAAQ,iBAAiB,gBAAgB,uBAAuB,IAAI;AAE5E,QAAM,eAAe,mBAAmB,IAAI;AAE5C,QAAM,oBAAoB,OAAuB,IAAI;AACrD,QAAM,UAAU,OAA0B,IAAI;AAC9C,QAAM,CAAC,SAAS,cAAc,SAAkB,MAAM;AACtD,QAAM,CAAC,aAAa,kBAAkB,SAAkB,KAAK;AAC7D,QAAM,CAAC,QA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C;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA,eAAa,mBAAmB;AAAA,IAChC,MAAK;AAAA,IACL,UAAU;AAAA,IACV,QAAQ;AAAA,KAER,qCAAC;AAAA,IAAoB,eAAa,mBAAmB;AAAA,KAAiB,MAAM,KAAM,GAClF,qCAAC,mBAAa,KAAM,GACpB,qCAAC,sBACC,qCAAC,cAAM,IAAK,GACX,cACC,qCAAC;AAAA,IACC,eAAa,mBAAmB;AAAA,IAChC,SAAS,WAAW;AAAA,IACpB,MAAM,WAAW;AAAA,IACjB,KAAK;AAAA,IACL,WAAW;AAAA,IACX,UAAU;AAAA,IACV,aAAa;AAAA,KAEZ,WAAW,KACd,CAEJ,GACC,kBACC,qCAAC;AAAA,IACC,eAAa,mBAAmB;AAAA,IAChC,YAAW;AAAA,IACX,SAAS;AAAA,IACT,cAAW;AAAA,KAEX,qCAAC;AAAA,IAAO,OAAO;AAAA,IAAI,QAAQ;AAAA,GAAI,CACjC,IAEA,qCAAC,YAAK,CAEV,CACF;AAEJ;AAEA,SAAS,cAAc;AACvB,MAAM,qBAAqB,SAAS,QAAQ;AAC5C,mBAAmB,YAAY;AAE/B,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
2
|
import * as React from "react";
|
|
22
3
|
import { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from "@elliemae/ds-utilities";
|
|
23
4
|
import { BANNER_TYPES } from "./exported-related";
|
|
@@ -30,7 +11,9 @@ const defaultProps = {
|
|
|
30
11
|
onClose: () => null,
|
|
31
12
|
showCloseButton: true
|
|
32
13
|
};
|
|
33
|
-
const propTypes =
|
|
14
|
+
const propTypes = {
|
|
15
|
+
...globalAttributesPropTypes,
|
|
16
|
+
...xstyledPropTypes,
|
|
34
17
|
containerProps: PropTypes.object.description("Set of Properties attached to the main container.").defaultValue({}),
|
|
35
18
|
label: PropTypes.string.description("Banner label.").defaultValue(""),
|
|
36
19
|
body: PropTypes.string.description("Banner body content").defaultValue(""),
|
|
@@ -48,7 +31,7 @@ const propTypes = __spreadProps(__spreadValues(__spreadValues({}, globalAttribut
|
|
|
48
31
|
- focusOnLink: function to focus the banner
|
|
49
32
|
- focusOnWrapper: function to focus the link
|
|
50
33
|
`).defaultValue({})
|
|
51
|
-
}
|
|
34
|
+
};
|
|
52
35
|
export {
|
|
53
36
|
defaultProps,
|
|
54
37
|
propTypes
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { WeakValidationMap } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-utilities';\nimport { BANNER_TYPES } from './exported-related';\nimport type { DSBannerInternalsT } from './sharedTypes';\n\nexport declare namespace DSBannerT {\n export interface Props {\n type?: DSBannerInternalsT.BannerTypesT;\n isOpen?: boolean;\n onClose?: () => void | null;\n actionLink?: DSBannerInternalsT.ActionLinkT;\n label?: string;\n body?: string;\n showCloseButton?: boolean;\n containerProps?: Record<string, unknown>;\n actionRef?: {\n current: {\n focusOnWrapper?: () => void;\n focusOnLink?: () => void;\n };\n };\n }\n}\n\nexport const defaultProps: DSBannerT.Props = {\n containerProps: {},\n label: '',\n body: '',\n type: BANNER_TYPES.INFO,\n isOpen: true,\n onClose: () => null,\n showCloseButton: true,\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n containerProps: PropTypes.object.description('Set of Properties attached to the main container.').defaultValue({}),\n label: PropTypes.string.description('Banner label.').defaultValue(''),\n body: PropTypes.string.description('Banner body content').defaultValue(''),\n type: PropTypes.oneOf(Object.values(BANNER_TYPES)).description('Banner type.').defaultValue(BANNER_TYPES.INFO),\n onClose: PropTypes.func.description('Callback when the Banner closes.'),\n isOpen: PropTypes.bool.description('Whether the Banner is open or closed.').defaultValue(true),\n showCloseButton: PropTypes.bool.description('Whether to show close button or not.').defaultValue(true),\n actionLink: PropTypes.shape({\n label: PropTypes.string,\n onClick: PropTypes.func,\n href: PropTypes.string,\n })\n .description('Properties for the Action Link.')\n .defaultValue({}),\n actionRef: PropTypes.object\n .description(\n `\n Reference to use actions:\n - focusOnLink: function to focus the banner\n - focusOnWrapper: function to focus the link\n `,\n )\n .defaultValue({}),\n} as WeakValidationMap<unknown>;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAAA;ACCA;AACA;AAsBO,MAAM,eAAgC;AAAA,EAC3C,gBAAgB,CAAC;AAAA,EACjB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM,aAAa;AAAA,EACnB,QAAQ;AAAA,EACR,SAAS,MAAM;AAAA,EACf,iBAAiB;AACnB;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,gBAAgB,UAAU,OAAO,YAAY,mDAAmD,EAAE,aAAa,CAAC,CAAC;AAAA,EACjH,OAAO,UAAU,OAAO,YAAY,eAAe,EAAE,aAAa,EAAE;AAAA,EACpE,MAAM,UAAU,OAAO,YAAY,qBAAqB,EAAE,aAAa,EAAE;AAAA,EACzE,MAAM,UAAU,MAAM,OAAO,OAAO,YAAY,CAAC,EAAE,YAAY,cAAc,EAAE,aAAa,aAAa,IAAI;AAAA,EAC7G,SAAS,UAAU,KAAK,YAAY,kCAAkC;AAAA,EACtE,QAAQ,UAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,IAAI;AAAA,EAC7F,iBAAiB,UAAU,KAAK,YAAY,sCAAsC,EAAE,aAAa,IAAI;AAAA,EACrG,YAAY,UAAU,MAAM;AAAA,IAC1B,OAAO,UAAU;AAAA,IACjB,SAAS,UAAU;AAAA,IACnB,MAAM,UAAU;AAAA,EAClB,CAAC,EACE,YAAY,iCAAiC,EAC7C,aAAa,CAAC,CAAC;AAAA,EAClB,WAAW,UAAU,OAClB,YACC;AAAA;AAAA;AAAA;AAAA,KAKF,EACC,aAAa,CAAC,CAAC;AACpB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-banner",
|
|
3
|
-
"version": "3.3.0-next.
|
|
3
|
+
"version": "3.3.0-next.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Banner",
|
|
6
6
|
"files": [
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"indent": 4
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@elliemae/ds-button": "3.3.0-next.
|
|
67
|
-
"@elliemae/ds-icons": "3.3.0-next.
|
|
68
|
-
"@elliemae/ds-system": "3.3.0-next.
|
|
69
|
-
"@elliemae/ds-utilities": "3.3.0-next.
|
|
66
|
+
"@elliemae/ds-button": "3.3.0-next.6",
|
|
67
|
+
"@elliemae/ds-icons": "3.3.0-next.6",
|
|
68
|
+
"@elliemae/ds-system": "3.3.0-next.6",
|
|
69
|
+
"@elliemae/ds-utilities": "3.3.0-next.6"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@testing-library/jest-dom": "~5.16.4",
|