@elliemae/ds-banner 3.80.0-next.4 → 3.80.0-next.41
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 +31 -58
- package/dist/cjs/DSBanner.js.map +3 -3
- package/dist/cjs/DSBannerContent.js +25 -23
- package/dist/cjs/DSBannerContent.js.map +2 -2
- package/dist/cjs/LiveRegionCorrectlyImplemented.js +67 -0
- package/dist/cjs/LiveRegionCorrectlyImplemented.js.map +7 -0
- package/dist/cjs/{exported-related → constants}/index.js +8 -3
- package/dist/cjs/constants/index.js.map +7 -0
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +11 -6
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/styles.js +79 -45
- package/dist/cjs/styles.js.map +2 -2
- package/dist/cjs/typescript-testing/slot-props.js +52 -0
- package/dist/cjs/typescript-testing/slot-props.js.map +7 -0
- package/dist/cjs/typescript-testing/typescript-banner-valid.js +2 -1
- package/dist/cjs/typescript-testing/typescript-banner-valid.js.map +2 -2
- package/dist/cjs/useBannerContainer.js +55 -0
- package/dist/cjs/useBannerContainer.js.map +7 -0
- package/dist/cjs/useBannerExitAnimation.js +66 -0
- package/dist/cjs/useBannerExitAnimation.js.map +7 -0
- package/dist/cjs/usePageNotice.js +53 -0
- package/dist/cjs/usePageNotice.js.map +7 -0
- package/dist/esm/DSBanner.js +26 -59
- package/dist/esm/DSBanner.js.map +2 -2
- package/dist/esm/DSBannerContent.js +25 -23
- package/dist/esm/DSBannerContent.js.map +2 -2
- package/dist/esm/LiveRegionCorrectlyImplemented.js +37 -0
- package/dist/esm/LiveRegionCorrectlyImplemented.js.map +7 -0
- package/dist/esm/{exported-related → constants}/index.js +5 -0
- package/dist/esm/constants/index.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js +8 -3
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/styles.js +59 -25
- package/dist/esm/styles.js.map +2 -2
- package/dist/esm/typescript-testing/slot-props.js +29 -0
- package/dist/esm/typescript-testing/slot-props.js.map +7 -0
- package/dist/esm/typescript-testing/typescript-banner-valid.js +2 -1
- package/dist/esm/typescript-testing/typescript-banner-valid.js.map +2 -2
- package/dist/esm/useBannerContainer.js +25 -0
- package/dist/esm/useBannerContainer.js.map +7 -0
- package/dist/esm/useBannerExitAnimation.js +36 -0
- package/dist/esm/useBannerExitAnimation.js.map +7 -0
- package/dist/esm/usePageNotice.js +23 -0
- package/dist/esm/usePageNotice.js.map +7 -0
- package/dist/types/DSBannerContent.d.ts +2 -0
- package/dist/types/LiveRegionCorrectlyImplemented.d.ts +11 -0
- package/dist/types/{exported-related → constants}/index.d.ts +9 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react-desc-prop-types.d.ts +15 -1
- package/dist/types/styles.d.ts +3 -1
- package/dist/types/useBannerContainer.d.ts +10 -0
- package/dist/types/useBannerExitAnimation.d.ts +15 -0
- package/dist/types/usePageNotice.d.ts +11 -0
- package/package.json +12 -10
- package/dist/cjs/exported-related/index.js.map +0 -7
- package/dist/esm/exported-related/index.js.map +0 -7
package/dist/esm/DSBanner.js
CHANGED
|
@@ -9,48 +9,18 @@ import {
|
|
|
9
9
|
useOwnerProps
|
|
10
10
|
} from "@elliemae/ds-props-helpers";
|
|
11
11
|
import React2, { useCallback, useEffect, useMemo } from "react";
|
|
12
|
-
import ReactDOM from "react-dom";
|
|
13
|
-
import { uid } from "uid";
|
|
14
12
|
import { useGetLayoutMode } from "@elliemae/ds-system";
|
|
15
13
|
import { DSBannerContent } from "./DSBannerContent.js";
|
|
16
|
-
import {
|
|
14
|
+
import { LiveRegionCorrectlyImplemented } from "./LiveRegionCorrectlyImplemented.js";
|
|
15
|
+
import { DSBannerDatatestid, DSBannerName } from "./constants/index.js";
|
|
16
|
+
import { useBannerContainer } from "./useBannerContainer.js";
|
|
17
|
+
import { usePageNotice } from "./usePageNotice.js";
|
|
17
18
|
import { defaultProps, DSBannerPropTypesSchema } from "./react-desc-prop-types.js";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
StyledBannerContainer,
|
|
21
|
-
StyledBannerLayout,
|
|
22
|
-
StyledCloseButton,
|
|
23
|
-
StyledInnerContainer
|
|
24
|
-
} from "./styles.js";
|
|
25
|
-
const outOfTheBoxCols = ["auto", "fit-content(50%)", "1fr"];
|
|
19
|
+
import { StyledBannerContainer, StyledBannerLayout, StyledCloseButton, StyledInnerContainer } from "./styles.js";
|
|
20
|
+
const outOfTheBoxCols = ["auto", "1fr"];
|
|
26
21
|
const outOfTheBoxColsSmallLayout = ["auto", "1fr"];
|
|
27
22
|
const colsWithCustomBody = ["1fr", "auto"];
|
|
28
|
-
const typeMap = {
|
|
29
|
-
alert: void 0,
|
|
30
|
-
polite: "polite",
|
|
31
|
-
assertive: "assertive",
|
|
32
|
-
none: "off"
|
|
33
|
-
};
|
|
34
23
|
const getIsLiveRegion = (type) => type === "polite" || type === "assertive";
|
|
35
|
-
const LiveRegionCorrectlyImplemented = ({
|
|
36
|
-
id,
|
|
37
|
-
innerRef,
|
|
38
|
-
announcementType,
|
|
39
|
-
ownerPropsConfig
|
|
40
|
-
}) => ReactDOM.createPortal(
|
|
41
|
-
/* @__PURE__ */ jsx(
|
|
42
|
-
StyledLiveRegionPortal,
|
|
43
|
-
{
|
|
44
|
-
id,
|
|
45
|
-
innerRef,
|
|
46
|
-
"aria-atomic": "true",
|
|
47
|
-
"aria-live": typeMap[announcementType],
|
|
48
|
-
"data-testid": DSBannerDatatestid.LIVE_REGION_PORTAL,
|
|
49
|
-
...ownerPropsConfig
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
document.body
|
|
53
|
-
);
|
|
54
24
|
const DSBanner = (props) => {
|
|
55
25
|
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);
|
|
56
26
|
const {
|
|
@@ -67,6 +37,7 @@ const DSBanner = (props) => {
|
|
|
67
37
|
actionRef,
|
|
68
38
|
withLiveRegionAnnouncement,
|
|
69
39
|
isPageNotice,
|
|
40
|
+
bannerId,
|
|
70
41
|
...rest
|
|
71
42
|
} = propsWithDefaults;
|
|
72
43
|
const { height: globalHeight, ...globalAttrs } = useGetGlobalAttributes(rest);
|
|
@@ -78,21 +49,11 @@ const DSBanner = (props) => {
|
|
|
78
49
|
if (CustomBody) return colsWithCustomBody;
|
|
79
50
|
return isSmall ? outOfTheBoxColsSmallLayout : outOfTheBoxCols;
|
|
80
51
|
}, [CustomBody, isSmall]);
|
|
81
|
-
const handleActionRefForContainer =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
actionRef.current.focusOnWrapper = () => {
|
|
85
|
-
if (containerNode) {
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
containerNode?.focus();
|
|
88
|
-
}, 300);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
[actionRef]
|
|
52
|
+
const { handleActionRefForContainer, isContainerRendered, containerExitProps, liveRegionKey } = useBannerContainer(
|
|
53
|
+
isOpen,
|
|
54
|
+
actionRef
|
|
94
55
|
);
|
|
95
|
-
const
|
|
56
|
+
const { baseId, contentIds, pageNoticeNameProps } = usePageNotice(propsWithDefaults, props, globalAttrs);
|
|
96
57
|
const handleOnKeyDownToClose = useCallback(
|
|
97
58
|
(e) => {
|
|
98
59
|
if (e.key === "Escape") {
|
|
@@ -116,14 +77,15 @@ const DSBanner = (props) => {
|
|
|
116
77
|
useEffect(() => {
|
|
117
78
|
if (isOpen && getIsLiveRegion(withLiveRegionAnnouncement)) read();
|
|
118
79
|
}, [isOpen, withLiveRegionAnnouncement, read]);
|
|
119
|
-
if (!
|
|
80
|
+
if (!isContainerRendered)
|
|
120
81
|
return getIsLiveRegion(withLiveRegionAnnouncement) ? /* @__PURE__ */ jsx(
|
|
121
82
|
LiveRegionCorrectlyImplemented,
|
|
122
83
|
{
|
|
123
|
-
id: `${
|
|
84
|
+
id: `${baseId}-live-region`,
|
|
124
85
|
innerRef: liveRegionRef,
|
|
125
86
|
announcementType: withLiveRegionAnnouncement,
|
|
126
|
-
ownerPropsConfig
|
|
87
|
+
ownerPropsConfig,
|
|
88
|
+
globalAttrs
|
|
127
89
|
}
|
|
128
90
|
) : null;
|
|
129
91
|
return /* @__PURE__ */ jsxs(
|
|
@@ -134,9 +96,12 @@ const DSBanner = (props) => {
|
|
|
134
96
|
innerRef: handleActionRefForContainer,
|
|
135
97
|
tabIndex: -1,
|
|
136
98
|
role: isPageNotice ? "region" : void 0,
|
|
99
|
+
$isExpanded: isOpen,
|
|
100
|
+
...pageNoticeNameProps,
|
|
137
101
|
...containerProps,
|
|
138
102
|
...globalAttrs,
|
|
139
103
|
...xstyledAttrs,
|
|
104
|
+
...containerExitProps,
|
|
140
105
|
...ownerPropsConfig,
|
|
141
106
|
children: [
|
|
142
107
|
/* @__PURE__ */ jsxs(StyledBannerLayout, { ...ownerPropsConfig, $type: type, children: [
|
|
@@ -147,9 +112,9 @@ const DSBanner = (props) => {
|
|
|
147
112
|
"data-type": type,
|
|
148
113
|
"data-testid": DSBannerDatatestid.INNER_CONTAINER,
|
|
149
114
|
role: withLiveRegionAnnouncement === "alert" ? "alert" : void 0,
|
|
150
|
-
id:
|
|
115
|
+
id: baseId,
|
|
151
116
|
...ownerPropsConfig,
|
|
152
|
-
children: !CustomBody ? /* @__PURE__ */ jsx(DSBannerContent, { propsWithDefaults }) : /* @__PURE__ */ jsx(CustomBody, {})
|
|
117
|
+
children: !CustomBody ? /* @__PURE__ */ jsx(DSBannerContent, { propsWithDefaults, ...contentIds }) : /* @__PURE__ */ jsx(CustomBody, {})
|
|
153
118
|
}
|
|
154
119
|
),
|
|
155
120
|
!CustomBody && showCloseButton ? /* @__PURE__ */ jsx(
|
|
@@ -160,7 +125,7 @@ const DSBanner = (props) => {
|
|
|
160
125
|
innerRef: closeBtnRef,
|
|
161
126
|
onClick: onClose,
|
|
162
127
|
"aria-label": "Visually dismiss the banner",
|
|
163
|
-
"aria-describedby":
|
|
128
|
+
"aria-describedby": baseId,
|
|
164
129
|
...ownerPropsConfig,
|
|
165
130
|
children: /* @__PURE__ */ jsx(CloseX, { width: 12, height: 12 })
|
|
166
131
|
}
|
|
@@ -169,11 +134,13 @@ const DSBanner = (props) => {
|
|
|
169
134
|
getIsLiveRegion(withLiveRegionAnnouncement) ? /* @__PURE__ */ jsx(
|
|
170
135
|
LiveRegionCorrectlyImplemented,
|
|
171
136
|
{
|
|
172
|
-
id: `${
|
|
137
|
+
id: `${baseId}-live-region`,
|
|
173
138
|
innerRef: liveRegionRef,
|
|
174
139
|
announcementType: withLiveRegionAnnouncement,
|
|
175
|
-
ownerPropsConfig
|
|
176
|
-
|
|
140
|
+
ownerPropsConfig,
|
|
141
|
+
globalAttrs
|
|
142
|
+
},
|
|
143
|
+
liveRegionKey
|
|
177
144
|
) : null
|
|
178
145
|
]
|
|
179
146
|
}
|
package/dist/esm/DSBanner.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSBanner.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { CloseX } from '@elliemae/ds-icons';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useOwnerProps,\n} from '@elliemae/ds-props-helpers';\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { CloseX } from '@elliemae/ds-icons';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useOwnerProps,\n} from '@elliemae/ds-props-helpers';\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport { useGetLayoutMode } from '@elliemae/ds-system';\nimport { DSBannerContent } from './DSBannerContent.js';\nimport { LiveRegionCorrectlyImplemented } from './LiveRegionCorrectlyImplemented.js';\nimport { DSBannerDatatestid, DSBannerName } from './constants/index.js';\nimport { useBannerContainer } from './useBannerContainer.js';\nimport { usePageNotice } from './usePageNotice.js';\nimport type { DSBannerT } from './react-desc-prop-types.js';\nimport { defaultProps, DSBannerPropTypesSchema } from './react-desc-prop-types.js';\nimport { StyledBannerContainer, StyledBannerLayout, StyledCloseButton, StyledInnerContainer } from './styles.js';\n\nconst outOfTheBoxCols = ['auto', '1fr'];\nconst outOfTheBoxColsSmallLayout = ['auto', '1fr'];\nconst colsWithCustomBody = ['1fr', 'auto'];\n\nconst getIsLiveRegion = (type: string) => type === 'polite' || type === 'assertive';\n\nconst DSBanner: React.ComponentType<DSBannerT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSBannerT.InternalProps>(props, defaultProps);\n\n const {\n type,\n isOpen,\n onClose,\n label,\n body,\n closeBtnRef,\n CustomBody,\n actionLink,\n showCloseButton,\n containerProps,\n actionRef,\n withLiveRegionAnnouncement,\n isPageNotice,\n bannerId,\n ...rest\n } = propsWithDefaults;\n // eslint-disable-next-line no-unused-vars\n const { height: globalHeight, ...globalAttrs } = useGetGlobalAttributes(rest);\n const ownerPropsConfig = useOwnerProps(propsWithDefaults, { ...props });\n const xstyledAttrs = useGetXstyledProps(rest);\n\n const layoutMode = useGetLayoutMode();\n const isSmall = layoutMode === 's' || layoutMode === 'xs';\n const innerContainerCols = useMemo(() => {\n if (CustomBody) return colsWithCustomBody;\n return isSmall ? outOfTheBoxColsSmallLayout : outOfTheBoxCols;\n }, [CustomBody, isSmall]);\n\n const { handleActionRefForContainer, isContainerRendered, containerExitProps, liveRegionKey } = useBannerContainer(\n isOpen,\n actionRef,\n );\n\n const { baseId, contentIds, pageNoticeNameProps } = usePageNotice(propsWithDefaults, props, globalAttrs);\n\n const handleOnKeyDownToClose = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n onClose();\n }\n },\n [onClose],\n );\n\n const liveRegionRef = React.useRef<HTMLDivElement>(null);\n const isOpenRef = React.useRef(isOpen);\n isOpenRef.current = isOpen;\n const textToAnnounceRef = React.useRef(`${label} ${body}`);\n textToAnnounceRef.current = `${label} ${body}`;\n const read = React.useCallback(() => {\n if (liveRegionRef.current) {\n if (isOpenRef.current) liveRegionRef.current.textContent = textToAnnounceRef.current;\n else liveRegionRef.current.textContent = '';\n }\n }, []);\n\n useEffect(() => {\n if (isOpen && getIsLiveRegion(withLiveRegionAnnouncement)) read();\n }, [isOpen, withLiveRegionAnnouncement, read]);\n\n // the container stays mounted while it slides up after closing (see useBannerExitAnimation)\n if (!isContainerRendered)\n return getIsLiveRegion(withLiveRegionAnnouncement) ? (\n <LiveRegionCorrectlyImplemented\n id={`${baseId}-live-region`}\n innerRef={liveRegionRef}\n announcementType={withLiveRegionAnnouncement}\n ownerPropsConfig={ownerPropsConfig}\n globalAttrs={globalAttrs}\n />\n ) : null;\n\n return (\n <StyledBannerContainer\n onKeyDown={handleOnKeyDownToClose}\n data-testid={DSBannerDatatestid.CONTAINER}\n innerRef={handleActionRefForContainer}\n tabIndex={-1}\n role={isPageNotice ? 'region' : undefined}\n $isExpanded={isOpen}\n {...pageNoticeNameProps}\n {...containerProps}\n {...globalAttrs}\n {...xstyledAttrs}\n {...containerExitProps}\n {...ownerPropsConfig}\n >\n <StyledBannerLayout {...ownerPropsConfig} $type={type}>\n <StyledInnerContainer\n cols={innerContainerCols}\n data-type={type}\n data-testid={DSBannerDatatestid.INNER_CONTAINER}\n role={withLiveRegionAnnouncement === 'alert' ? 'alert' : undefined}\n id={baseId}\n {...ownerPropsConfig}\n >\n {!CustomBody ? <DSBannerContent propsWithDefaults={propsWithDefaults} {...contentIds} /> : <CustomBody />}\n </StyledInnerContainer>\n {!CustomBody && showCloseButton ? (\n <StyledCloseButton\n data-testid={DSBannerDatatestid.CLOSE_BUTTON}\n buttonType=\"icon\"\n innerRef={closeBtnRef}\n onClick={onClose}\n aria-label=\"Visually dismiss the banner\"\n aria-describedby={baseId}\n {...ownerPropsConfig}\n >\n <CloseX width={12} height={12} />\n </StyledCloseButton>\n ) : null}\n </StyledBannerLayout>\n {getIsLiveRegion(withLiveRegionAnnouncement) ? (\n <LiveRegionCorrectlyImplemented\n key={liveRegionKey}\n id={`${baseId}-live-region`}\n innerRef={liveRegionRef}\n announcementType={withLiveRegionAnnouncement}\n ownerPropsConfig={ownerPropsConfig}\n globalAttrs={globalAttrs}\n />\n ) : null}\n </StyledBannerContainer>\n );\n};\n\nDSBanner.displayName = DSBannerName;\nconst DSBannerWithSchema = describe(DSBanner);\nDSBannerWithSchema.propTypes = DSBannerPropTypesSchema;\n\nexport default DSBanner;\nexport { DSBanner, DSBannerWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC6FjB,cAwBA,YAxBA;AA7FN,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAOA,UAAS,aAAa,WAAW,eAAe;AACvD,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,sCAAsC;AAC/C,SAAS,oBAAoB,oBAAoB;AACjD,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAE9B,SAAS,cAAc,+BAA+B;AACtD,SAAS,uBAAuB,oBAAoB,mBAAmB,4BAA4B;AAEnG,MAAM,kBAAkB,CAAC,QAAQ,KAAK;AACtC,MAAM,6BAA6B,CAAC,QAAQ,KAAK;AACjD,MAAM,qBAAqB,CAAC,OAAO,MAAM;AAEzC,MAAM,kBAAkB,CAAC,SAAiB,SAAS,YAAY,SAAS;AAExE,MAAM,WAAiD,CAAC,UAAU;AAChE,QAAM,oBAAoB,6BAAsD,OAAO,YAAY;AAEnG,QAAM;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,MAAM;AAAA,YACb,UAAU;AAAA,YACV,kBAAkB;AAAA,YAClB;AAAA,YACA;AAAA;AAAA,UALK;AAAA,QAMP,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,cAAc;AACvB,MAAM,qBAAqB,SAAS,QAAQ;AAC5C,mBAAmB,YAAY;AAE/B,IAAO,mBAAQ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -4,8 +4,8 @@ import { AlertsDetailFill, InfoFill, SuccessFill, WarningSquare } from "@elliema
|
|
|
4
4
|
import { useOwnerProps } from "@elliemae/ds-props-helpers";
|
|
5
5
|
import { TYPOGRAPHY_VARIANTS } from "@elliemae/ds-typography";
|
|
6
6
|
import React2, { useCallback } from "react";
|
|
7
|
-
import {
|
|
8
|
-
import { StyledActionLink, StyledIconContainer, StyledSubTitle, StyledTitle } from "./styles.js";
|
|
7
|
+
import { DSBannerDatatestid } from "./constants/index.js";
|
|
8
|
+
import { StyledActionLink, StyledIconContainer, StyledSubTitle, StyledTitle, StyledBody } from "./styles.js";
|
|
9
9
|
const icons = {
|
|
10
10
|
success: /* @__PURE__ */ jsx(SuccessFill, { color: ["success", "900"], width: "20px", height: "20px" }),
|
|
11
11
|
info: /* @__PURE__ */ jsx(InfoFill, { color: ["brand-primary", "600"], width: "20px", height: "20px" }),
|
|
@@ -15,6 +15,8 @@ const icons = {
|
|
|
15
15
|
const DSBannerContent = (props) => {
|
|
16
16
|
const {
|
|
17
17
|
propsWithDefaults,
|
|
18
|
+
titleId,
|
|
19
|
+
bodyId,
|
|
18
20
|
propsWithDefaults: { type, label, body, actionLink, actionRef }
|
|
19
21
|
} = props;
|
|
20
22
|
const ownerPropsConfig = useOwnerProps(propsWithDefaults, { ...props });
|
|
@@ -40,27 +42,27 @@ const DSBannerContent = (props) => {
|
|
|
40
42
|
}, []);
|
|
41
43
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
44
|
/* @__PURE__ */ jsx(StyledIconContainer, { "data-testid": DSBannerDatatestid.ICON_CONTAINER, ...ownerPropsConfig, children: icons[type] }),
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
|
|
45
|
-
body,
|
|
46
|
-
actionLink &&
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
/* @__PURE__ */ jsxs(StyledBody, { ...ownerPropsConfig, children: [
|
|
46
|
+
/* @__PURE__ */ jsx(StyledTitle, { id: titleId, variant: TYPOGRAPHY_VARIANTS.H5_STRONG, component: "span", ...ownerPropsConfig, children: label }),
|
|
47
|
+
/* @__PURE__ */ jsx(StyledSubTitle, { id: bodyId, variant: TYPOGRAPHY_VARIANTS.B1, ...ownerPropsConfig, children: body }),
|
|
48
|
+
actionLink && // its own element (a sibling of the description, not inline in it): the spacing is CSS, not literal spaces.
|
|
49
|
+
// the DSTypography link variant gives the size + DSTypography-root class, the underline/weight pending UX are in styles.tsx
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
StyledActionLink,
|
|
52
|
+
{
|
|
53
|
+
variant: TYPOGRAPHY_VARIANTS.LINK_SML_TITLE,
|
|
54
|
+
"data-testid": DSBannerDatatestid.ACTION_LINK,
|
|
55
|
+
onClick: actionLink.onClick,
|
|
56
|
+
href: actionLink.href,
|
|
57
|
+
innerRef: handleActionRefForLink,
|
|
58
|
+
onKeyDown: handleOnKeyDown,
|
|
59
|
+
tabIndex: 0,
|
|
60
|
+
isBodyEmpty: !body,
|
|
61
|
+
title: actionLink.label,
|
|
62
|
+
...ownerPropsConfig,
|
|
63
|
+
children: actionLink.label
|
|
64
|
+
}
|
|
65
|
+
)
|
|
64
66
|
] })
|
|
65
67
|
] });
|
|
66
68
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSBannerContent.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport { AlertsDetailFill, InfoFill, SuccessFill, WarningSquare } from '@elliemae/ds-icons';\nimport { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { TYPOGRAPHY_VARIANTS } from '@elliemae/ds-typography';\nimport React, { useCallback } from 'react';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACUZ,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport { AlertsDetailFill, InfoFill, SuccessFill, WarningSquare } from '@elliemae/ds-icons';\nimport { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { TYPOGRAPHY_VARIANTS } from '@elliemae/ds-typography';\nimport React, { useCallback } from 'react';\nimport { DSBannerDatatestid } from './constants/index.js';\nimport type { DSBannerT } from './react-desc-prop-types.js';\nimport { StyledActionLink, StyledIconContainer, StyledSubTitle, StyledTitle, StyledBody } from './styles.js';\n\nexport const icons: Record<string, JSX.Element> = {\n success: <SuccessFill color={['success', '900']} width=\"20px\" height=\"20px\" />,\n info: <InfoFill color={['brand-primary', '600']} width=\"20px\" height=\"20px\" />,\n danger: <AlertsDetailFill color={['danger', '900']} width=\"20px\" height=\"20px\" />,\n warning: <WarningSquare color={['warning', '900']} width=\"20px\" height=\"20px\" />,\n};\n\ninterface DSBannerContentProps {\n propsWithDefaults: DSBannerT.InternalProps;\n titleId?: string;\n bodyId?: string;\n}\n\nexport const DSBannerContent: React.ComponentType<DSBannerContentProps> = (props) => {\n const {\n propsWithDefaults,\n titleId,\n bodyId,\n propsWithDefaults: { type, label, body, actionLink, actionRef },\n } = props;\n const ownerPropsConfig = useOwnerProps(propsWithDefaults, { ...props });\n\n const linkRef = React.useRef<HTMLElement>(null) as React.MutableRefObject<HTMLElement>;\n\n const handleActionRefForLink = useCallback<React.RefCallback<HTMLElement>>(\n (linkNode) => {\n if (linkNode) {\n linkRef.current = linkNode;\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnLink = () => {\n linkNode?.focus?.();\n };\n }\n }\n },\n [actionRef],\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 return (\n <>\n <StyledIconContainer data-testid={DSBannerDatatestid.ICON_CONTAINER} {...ownerPropsConfig}>\n {icons[type]}\n </StyledIconContainer>\n <StyledBody {...ownerPropsConfig}>\n {/* h5-strong look, but a span: the title must not inject a heading into the host page outline.\n `component` (not `as`): on a styled(DSTypography) wrapper `as` would replace DSTypography itself. */}\n <StyledTitle id={titleId} variant={TYPOGRAPHY_VARIANTS.H5_STRONG} component=\"span\" {...ownerPropsConfig}>\n {label}\n </StyledTitle>\n <StyledSubTitle id={bodyId} variant={TYPOGRAPHY_VARIANTS.B1} {...ownerPropsConfig}>\n {body}\n </StyledSubTitle>\n {actionLink && (\n // its own element (a sibling of the description, not inline in it): the spacing is CSS, not literal spaces.\n // the DSTypography link variant gives the size + DSTypography-root class, the underline/weight pending UX are in styles.tsx\n <StyledActionLink\n variant={TYPOGRAPHY_VARIANTS.LINK_SML_TITLE}\n data-testid={DSBannerDatatestid.ACTION_LINK}\n onClick={actionLink.onClick}\n href={actionLink.href}\n innerRef={handleActionRefForLink}\n onKeyDown={handleOnKeyDown}\n tabIndex={0}\n isBodyEmpty={!body}\n title={actionLink.label}\n {...ownerPropsConfig}\n >\n {actionLink.label}\n </StyledActionLink>\n )}\n </StyledBody>\n </>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACUZ,SA6CP,UA7CO,KAiDL,YAjDK;AATX,SAAS,kBAAkB,UAAU,aAAa,qBAAqB;AACvE,SAAS,q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,uBAAoB,eAAa,mBAAmB,gBAAiB,GAAG,kBACtE,gBAAM,IAAI,GACb;AAAA,IACA,qBAAC,cAAY,GAAG,kBAGd;AAAA,0BAAC,eAAY,IAAI,SAAS,SAAS,oBAAoB,WAAW,WAAU,QAAQ,GAAG,kBACpF,iBACH;AAAA,MACA,oBAAC,kBAAe,IAAI,QAAQ,SAAS,oBAAoB,IAAK,GAAG,kBAC9D,gBACH;AAAA,MACC;AAAA;AAAA,MAGC;AAAA,QAAC;AAAA;AAAA,UACC,SAAS,oBAAoB;AAAA,UAC7B,eAAa,mBAAmB;AAAA,UAChC,SAAS,WAAW;AAAA,UACpB,MAAM,WAAW;AAAA,UACjB,UAAU;AAAA,UACV,WAAW;AAAA,UACX,UAAU;AAAA,UACV,aAAa,CAAC;AAAA,UACd,OAAO,WAAW;AAAA,UACjB,GAAG;AAAA,UAEH,qBAAW;AAAA;AAAA,MACd;AAAA,OAEJ;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import { DSBannerDatatestid } from "./constants/index.js";
|
|
5
|
+
import { StyledLiveRegionPortal } from "./styles.js";
|
|
6
|
+
const typeMap = {
|
|
7
|
+
alert: void 0,
|
|
8
|
+
polite: "polite",
|
|
9
|
+
assertive: "assertive",
|
|
10
|
+
none: "off"
|
|
11
|
+
};
|
|
12
|
+
const LiveRegionCorrectlyImplemented = ({
|
|
13
|
+
id,
|
|
14
|
+
innerRef,
|
|
15
|
+
announcementType,
|
|
16
|
+
ownerPropsConfig,
|
|
17
|
+
globalAttrs: { lang, dir }
|
|
18
|
+
}) => ReactDOM.createPortal(
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
StyledLiveRegionPortal,
|
|
21
|
+
{
|
|
22
|
+
lang,
|
|
23
|
+
dir,
|
|
24
|
+
id,
|
|
25
|
+
innerRef,
|
|
26
|
+
"aria-atomic": "true",
|
|
27
|
+
"aria-live": typeMap[announcementType],
|
|
28
|
+
"data-testid": DSBannerDatatestid.LIVE_REGION_PORTAL,
|
|
29
|
+
...ownerPropsConfig
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
document.body
|
|
33
|
+
);
|
|
34
|
+
export {
|
|
35
|
+
LiveRegionCorrectlyImplemented
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=LiveRegionCorrectlyImplemented.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/LiveRegionCorrectlyImplemented.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { DSBannerDatatestid } from './constants/index.js';\nimport { StyledLiveRegionPortal } from './styles.js';\n\nconst typeMap = {\n alert: undefined,\n polite: 'polite',\n assertive: 'assertive',\n none: 'off',\n} as const;\n\nexport const LiveRegionCorrectlyImplemented = ({\n id,\n innerRef,\n announcementType,\n ownerPropsConfig,\n globalAttrs: { lang, dir },\n}: {\n id: string;\n innerRef: React.Ref<HTMLDivElement>;\n announcementType: 'alert' | 'polite' | 'assertive' | 'none';\n ownerPropsConfig: Record<string, unknown>;\n globalAttrs: { lang?: string; dir?: string };\n}) =>\n ReactDOM.createPortal(\n <StyledLiveRegionPortal\n // the portal lives in document.body (outside the banner subtree) so it does not inherit lang/dir from the banner\n // only these two are forwarded, the rest of the global attributes belong to the banner container\n lang={lang}\n dir={dir}\n id={id}\n innerRef={innerRef}\n aria-atomic=\"true\"\n // off is never going to be printed because this portal is not printed when announcement is none\n // the off is just a quick hack to circumvent typescript typechecks in the static building\n aria-live={typeMap[announcementType]}\n data-testid={DSBannerDatatestid.LIVE_REGION_PORTAL}\n {...ownerPropsConfig}\n />,\n document.body,\n );\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0BnB;AAzBJ,OAAO,cAAc;AACrB,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AAEvC,MAAM,UAAU;AAAA,EACd,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM;AACR;AAEO,MAAM,iCAAiC,CAAC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa,EAAE,MAAM,IAAI;AAC3B,MAOE,SAAS;AAAA,EACP;AAAA,IAAC;AAAA;AAAA,MAGC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAY;AAAA,MAGZ,aAAW,QAAQ,gBAAgB;AAAA,MACnC,eAAa,mBAAmB;AAAA,MAC/B,GAAG;AAAA;AAAA,EACN;AAAA,EACA,SAAS;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -7,11 +7,15 @@ const BANNER_TYPES = {
|
|
|
7
7
|
WARNING: "warning",
|
|
8
8
|
DANGER: "danger"
|
|
9
9
|
};
|
|
10
|
+
const BANNER_SLIDE_DURATION_MS = 500;
|
|
10
11
|
const BANNER_BODY_ID = "ds-banner-body";
|
|
11
12
|
const DSBannerSlots = {
|
|
12
13
|
CONTAINER: "container",
|
|
13
14
|
INNER_CONTAINER: "inner-container",
|
|
15
|
+
// reserved slot: declared but never rendered. It is part of the public surface (DSBannerDatatestid, dsBannerCustomContainer slot prop)
|
|
16
|
+
// and pinned by DSBanner.data-testid.test.js, so removing it is a breaking change. See KNOWN_INTENTIONAL_DEVIATIONS.md
|
|
14
17
|
CUSTOM_CONTAINER: "custom-container",
|
|
18
|
+
BODY: "body",
|
|
15
19
|
TITLE: "title",
|
|
16
20
|
SUBTITLE: "subtitle",
|
|
17
21
|
ICON_CONTAINER: "icon-container",
|
|
@@ -28,6 +32,7 @@ const DSBannerDatatestid = {
|
|
|
28
32
|
};
|
|
29
33
|
export {
|
|
30
34
|
BANNER_BODY_ID,
|
|
35
|
+
BANNER_SLIDE_DURATION_MS,
|
|
31
36
|
BANNER_TYPES,
|
|
32
37
|
DSBannerDatatestid,
|
|
33
38
|
DSBannerName,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/constants/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSBannerName = 'DSBanner';\nexport const BANNER_TYPES = {\n INFO: 'info',\n SUCCESS: 'success',\n WARNING: 'warning',\n DANGER: 'danger',\n} as const;\n\n// duration of the slide down (open) and slide up (close) of the banner, defined by the Banner spec v2 \"Motion and Animation\"\nexport const BANNER_SLIDE_DURATION_MS = 500;\n\n/**\n * @deprecated legacy export, no longer rendered or used by the component (PUI-19089).\n * The body used to render with this fixed id, which duplicated across banners. The body id is now\n * `<bannerId>-body`, where `bannerId` is generated per instance or provided through the `bannerId` prop.\n * Kept only so imports of the old constant keep resolving.\n */\nexport const BANNER_BODY_ID = 'ds-banner-body';\n\n// previously this was the exported data-testid object\n// the one marked as // ok are the one that works with the slots convention and works with the slotObjectToDataTestIds function\n// the rest are not compatible and needs manual handling\n// export const DSBannerDatatestid = {\n// CONTAINER: 'ds-banner-container', // ok\n// CUSTOM_CONTAINER: 'ds-banner-custom-container', // ok\n// ACTION_LINK: 'ds-banner-action-link', // ok\n// CLOSE_BUTTON: 'ds-banner-close-button', // ok\n// // From here down are not compatible with the slotObjectToDataTestIds function.\n// INNER_CONTAINER: 'ds-banner',\n// ICON_CONTAINER: 'ds-banner-icon',\n// // from here they were not present but they had an asigned Slot.\n// // TITLE\n// // SUBTITLE\n// };\n\n// we are naming this with the ${component_name}_slots convention to namespace & avoid errors on duplicate exports variables in aggregators\n\nexport const DSBannerSlots = {\n CONTAINER: 'container',\n INNER_CONTAINER: 'inner-container',\n // reserved slot: declared but never rendered. It is part of the public surface (DSBannerDatatestid, dsBannerCustomContainer slot prop)\n // and pinned by DSBanner.data-testid.test.js, so removing it is a breaking change. See KNOWN_INTENTIONAL_DEVIATIONS.md\n CUSTOM_CONTAINER: 'custom-container',\n BODY: 'body',\n TITLE: 'title',\n SUBTITLE: 'subtitle',\n ICON_CONTAINER: 'icon-container',\n ACTION_LINK: 'action-link',\n CLOSE_BUTTON: 'close-button',\n LAYOUT: 'layout',\n LIVE_REGION_PORTAL: 'live-region-portal',\n} as const;\n\n// we are naming this with the ${component_name}_data_testid convention to namespace & avoid errors on duplicate exports variables in aggregators\nexport const DSBannerDatatestid = {\n ...(slotObjectToDataTestIds(DSBannerName, DSBannerSlots) as Record<keyof typeof DSBannerSlots, string>),\n // handling the rest of the data-testids that are not compatible with the slotObjectToDataTestIds function manually to avoid breaking changes\n INNER_CONTAINER: 'ds-banner',\n ICON_CONTAINER: 'ds-banner-icon',\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,eAAe;AACrB,MAAM,eAAe;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;AAGO,MAAM,2BAA2B;AAQjC,MAAM,iBAAiB;AAoBvB,MAAM,gBAAgB;AAAA,EAC3B,WAAW;AAAA,EACX,iBAAiB;AAAA;AAAA;AAAA,EAGjB,kBAAkB;AAAA,EAClB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,oBAAoB;AACtB;AAGO,MAAM,qBAAqB;AAAA,EAChC,GAAI,wBAAwB,cAAc,aAAa;AAAA;AAAA,EAEvD,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DSBanner, DSBannerWithSchema } from "./DSBanner.js";
|
|
3
|
-
import { DSBannerName, BANNER_TYPES, DSBannerSlots, DSBannerDatatestid } from "./
|
|
3
|
+
import { DSBannerName, BANNER_TYPES, DSBannerSlots, DSBannerDatatestid } from "./constants/index.js";
|
|
4
4
|
export {
|
|
5
5
|
BANNER_TYPES,
|
|
6
6
|
DSBanner,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// eslint-disable-next-line no-restricted-exports\nexport { DSBanner, DSBannerWithSchema } from './DSBanner.js';\nexport { DSBannerName, BANNER_TYPES, DSBannerSlots, DSBannerDatatestid } from './
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// eslint-disable-next-line no-restricted-exports\nexport { DSBanner, DSBannerWithSchema } from './DSBanner.js';\nexport { DSBannerName, BANNER_TYPES, DSBannerSlots, DSBannerDatatestid } from './constants/index.js';\nexport type { DSBannerT } from './react-desc-prop-types.js';\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,UAAU,0BAA0B;AAC7C,SAAS,cAAc,cAAc,eAAe,0BAA0B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
xstyledPropTypes,
|
|
6
6
|
getPropsPerSlotPropTypes
|
|
7
7
|
} from "@elliemae/ds-props-helpers";
|
|
8
|
-
import { BANNER_TYPES, DSBannerName, DSBannerSlots } from "./
|
|
8
|
+
import { BANNER_TYPES, DSBannerName, DSBannerSlots } from "./constants/index.js";
|
|
9
9
|
const defaultProps = {
|
|
10
10
|
containerProps: {},
|
|
11
11
|
label: "",
|
|
@@ -42,8 +42,13 @@ const DSBannerPropTypes = {
|
|
|
42
42
|
- focusOnWrapper: function to focus the link
|
|
43
43
|
`
|
|
44
44
|
).defaultValue({}),
|
|
45
|
-
withLiveRegionAnnouncement: PropTypes.oneOf(["alert", "assertive", "polite"]).description("Whether to announce the banner content in a live region when it opens.").defaultValue("alert"),
|
|
46
|
-
isPageNotice: PropTypes.bool.description(
|
|
45
|
+
withLiveRegionAnnouncement: PropTypes.oneOf(["alert", "assertive", "polite", "none"]).description("Whether to announce the banner content in a live region when it opens.").defaultValue("alert"),
|
|
46
|
+
isPageNotice: PropTypes.bool.description(
|
|
47
|
+
"Whether to add role region to the banner. The region is named by default from the label prop; a name passed via aria-label/aria-labelledby (containerProps or dsBannerContainer) takes precedence."
|
|
48
|
+
).defaultValue(false),
|
|
49
|
+
bannerId: PropTypes.string.description(
|
|
50
|
+
`Base id of the banner. Every id the banner renders derives from it: the inner container uses it as is, the title uses "<bannerId>-title", the body uses "<bannerId>-body" and the live region uses "<bannerId>-live-region". When omitted, a unique base is generated per instance ("ds-banner-<random>"). Must start with a letter. Pass your own to reference the banner parts from aria-describedby / aria-labelledby.`
|
|
51
|
+
)
|
|
47
52
|
};
|
|
48
53
|
const DSBannerPropTypesSchema = DSBannerPropTypes;
|
|
49
54
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { MutableRefObject, RefCallback } from 'react';\nimport type { XstyledProps, DSPropTypesSchema, ValidationMap } from '@elliemae/ds-props-helpers';\nimport {\n PropTypes,\n globalAttributesPropTypes,\n xstyledPropTypes,\n getPropsPerSlotPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { BANNER_TYPES, DSBannerName, DSBannerSlots } from './
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,cAAc,cAAc,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { MutableRefObject, RefCallback } from 'react';\nimport type { XstyledProps, DSPropTypesSchema, ValidationMap } from '@elliemae/ds-props-helpers';\nimport {\n PropTypes,\n globalAttributesPropTypes,\n xstyledPropTypes,\n getPropsPerSlotPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { BANNER_TYPES, DSBannerName, DSBannerSlots } from './constants/index.js';\n\nexport declare namespace DSBannerT {\n export interface ActionRef {\n focusOnWrapper?: () => void;\n focusOnLink?: () => void;\n }\n\n export interface ActionLinkT {\n label: string;\n onClick?: (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void | null;\n href?: string;\n }\n\n export type BannerTypesT = (typeof BANNER_TYPES)[keyof typeof BANNER_TYPES];\n\n export interface RequiredProps {}\n\n export interface DefaultProps {\n containerProps: Record<string, unknown>;\n label: string;\n body: string;\n type: BannerTypesT;\n isOpen: boolean;\n onClose: () => void | null;\n showCloseButton: boolean;\n withLiveRegionAnnouncement: 'alert' | 'assertive' | 'polite' | 'none';\n isPageNotice: boolean;\n }\n\n export interface OptionalProps extends TypescriptHelpersT.PropsForGlobalOnSlots<\n typeof DSBannerName,\n typeof DSBannerSlots\n > {\n actionLink?: ActionLinkT;\n CustomBody?: React.ComponentType<Record<string, unknown>>;\n closeBtnRef?: React.MutableRefObject<HTMLButtonElement | null> | RefCallback<HTMLButtonElement>;\n actionRef?: MutableRefObject<ActionRef>;\n bannerId?: string;\n }\n export type SlotFunctionArguments = {\n dsBannerContainer: () => object;\n dsBannerInnerContainer: () => object;\n dsBannerCustomContainer: () => object;\n dsBannerBody: () => object;\n dsBannerTitle: () => object;\n dsBannerSubtitle: () => object;\n dsBannerIconContainer: () => object;\n dsBannerActionLink: () => object;\n dsBannerCloseButton: () => object;\n dsBannerLayout: () => object;\n dsBannerLiveRegionPortal: () => object;\n };\n\n export interface Props extends Partial<DefaultProps>, OptionalProps, XstyledProps, RequiredProps {}\n\n export interface InternalProps extends DefaultProps, OptionalProps, XstyledProps, RequiredProps {}\n}\n\nexport const defaultProps: DSBannerT.DefaultProps = {\n containerProps: {},\n label: '',\n body: '',\n type: BANNER_TYPES.INFO,\n isOpen: true,\n onClose: () => null,\n showCloseButton: true,\n withLiveRegionAnnouncement: 'alert',\n isPageNotice: false,\n};\n\nexport const DSBannerPropTypes: DSPropTypesSchema<DSBannerT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n ...getPropsPerSlotPropTypes(DSBannerName, DSBannerSlots),\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 CustomBody: PropTypes.func.description('Banner custom 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 closeBtnRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).description('Inner ref to button component.'),\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 withLiveRegionAnnouncement: PropTypes.oneOf(['alert', 'assertive', 'polite', 'none'])\n .description('Whether to announce the banner content in a live region when it opens.')\n .defaultValue('alert'),\n isPageNotice: PropTypes.bool\n .description(\n 'Whether to add role region to the banner. The region is named by default from the label prop; a name passed via aria-label/aria-labelledby (containerProps or dsBannerContainer) takes precedence.',\n )\n .defaultValue(false),\n bannerId: PropTypes.string.description(\n `Base id of the banner. Every id the banner renders derives from it: the inner container uses it as is, the title uses \"<bannerId>-title\", the body uses \"<bannerId>-body\" and the live region uses \"<bannerId>-live-region\". When omitted, a unique base is generated per instance (\"ds-banner-<random>\"). Must start with a letter. Pass your own to reference the banner parts from aria-describedby / aria-labelledby.`,\n ),\n};\n\nexport const DSBannerPropTypesSchema = DSBannerPropTypes as unknown as ValidationMap<DSBannerT.Props>;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,cAAc,cAAc,qBAAqB;AA2DnD,MAAM,eAAuC;AAAA,EAClD,gBAAgB,CAAC;AAAA,EACjB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM,aAAa;AAAA,EACnB,QAAQ;AAAA,EACR,SAAS,MAAM;AAAA,EACf,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,cAAc;AAChB;AAEO,MAAM,oBAAwD;AAAA,EACnE,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG,yBAAyB,cAAc,aAAa;AAAA,EACvD,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,YAAY,UAAU,KAAK,YAAY,uBAAuB,EAAE,aAAa,EAAE;AAAA,EAC/E,MAAM,UAAU,MAAM,OAAO,OAAO,YAAY,CAAC,EAAE,YAAY,cAAc,EAAE,a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