@elliemae/ds-banner 3.16.0-next.1 → 3.16.0-next.3
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 +5 -5
- package/dist/cjs/DSBanner.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +15 -15
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/esm/DSBanner.js +1 -1
- package/dist/esm/DSBanner.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js +1 -1
- package/dist/esm/react-desc-prop-types.js.map +1 -1
- package/dist/types/DSBanner.d.ts +1 -1
- package/package.json +7 -6
package/dist/cjs/DSBanner.js
CHANGED
|
@@ -32,17 +32,17 @@ module.exports = __toCommonJS(DSBanner_exports);
|
|
|
32
32
|
var React = __toESM(require("react"));
|
|
33
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
34
|
var import_react = require("react");
|
|
35
|
-
var
|
|
35
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
36
36
|
var import_ds_icons = require("@elliemae/ds-icons");
|
|
37
37
|
var import_icons = require("./utils/icons");
|
|
38
38
|
var import_react_desc_prop_types = require("./react-desc-prop-types");
|
|
39
39
|
var import_exported_related = require("./exported-related");
|
|
40
40
|
var import_styles = require("./styles");
|
|
41
41
|
const DSBanner = (props) => {
|
|
42
|
-
const propsWithDefaults = (0,
|
|
42
|
+
const propsWithDefaults = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
|
|
43
43
|
const { type, isOpen, onClose, label, body, actionLink, showCloseButton, containerProps, actionRef, ...rest } = propsWithDefaults;
|
|
44
|
-
const { height: globalHeight, ...globalAttrs } = (0,
|
|
45
|
-
const xstyledAttrs = (0,
|
|
44
|
+
const { height: globalHeight, ...globalAttrs } = (0, import_ds_props_helpers.useGetGlobalAttributes)(rest);
|
|
45
|
+
const xstyledAttrs = (0, import_ds_props_helpers.useGetXstyledProps)(rest);
|
|
46
46
|
const innerContainerRef = (0, import_react.useRef)(null);
|
|
47
47
|
const linkRef = (0, import_react.useRef)(null);
|
|
48
48
|
const [current, setCurrent] = (0, import_react.useState)(isOpen);
|
|
@@ -147,7 +147,7 @@ const DSBanner = (props) => {
|
|
|
147
147
|
);
|
|
148
148
|
};
|
|
149
149
|
DSBanner.displayName = import_exported_related.DSBannerName;
|
|
150
|
-
const DSBannerWithSchema = (0,
|
|
150
|
+
const DSBannerWithSchema = (0, import_ds_props_helpers.describe)(DSBanner);
|
|
151
151
|
DSBannerWithSchema.propTypes = import_react_desc_prop_types.propTypes;
|
|
152
152
|
var DSBanner_default = DSBanner;
|
|
153
153
|
//# sourceMappingURL=DSBanner.js.map
|
package/dist/cjs/DSBanner.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSBanner.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
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-
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuGf;AAtGR,mBAAiF;AACjF,
|
|
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-props-helpers';\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": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuGf;AAtGR,mBAAiF;AACjF,8BAKO;AACP,sBAAuB;AACvB,mBAAsB;AACtB,mCAAwC;AACxC,8BAAiD;AACjD,oBAQO;AAGP,MAAM,WAAiD,CAAC,UAAU;AAChE,QAAM,wBAAoB,sDAA6B,OAAO,yCAAY;AAE1E,QAAM,EAAE,MAAM,QAAQ,SAAS,OAAO,MAAM,YAAY,i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
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,7 +29,7 @@ __export(react_desc_prop_types_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
31
31
|
var React = __toESM(require("react"));
|
|
32
|
-
var
|
|
32
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
33
33
|
var import_exported_related = require("./exported-related");
|
|
34
34
|
const defaultProps = {
|
|
35
35
|
containerProps: {},
|
|
@@ -41,21 +41,21 @@ const defaultProps = {
|
|
|
41
41
|
showCloseButton: true
|
|
42
42
|
};
|
|
43
43
|
const propTypes = {
|
|
44
|
-
...
|
|
45
|
-
...
|
|
46
|
-
containerProps:
|
|
47
|
-
label:
|
|
48
|
-
body:
|
|
49
|
-
type:
|
|
50
|
-
onClose:
|
|
51
|
-
isOpen:
|
|
52
|
-
showCloseButton:
|
|
53
|
-
actionLink:
|
|
54
|
-
label:
|
|
55
|
-
onClick:
|
|
56
|
-
href:
|
|
44
|
+
...import_ds_props_helpers.globalAttributesPropTypes,
|
|
45
|
+
...import_ds_props_helpers.xstyledPropTypes,
|
|
46
|
+
containerProps: import_ds_props_helpers.PropTypes.object.description("Set of Properties attached to the main container.").defaultValue({}),
|
|
47
|
+
label: import_ds_props_helpers.PropTypes.string.description("Banner label.").defaultValue(""),
|
|
48
|
+
body: import_ds_props_helpers.PropTypes.string.description("Banner body content").defaultValue(""),
|
|
49
|
+
type: import_ds_props_helpers.PropTypes.oneOf(Object.values(import_exported_related.BANNER_TYPES)).description("Banner type.").defaultValue(import_exported_related.BANNER_TYPES.INFO),
|
|
50
|
+
onClose: import_ds_props_helpers.PropTypes.func.description("Callback when the Banner closes."),
|
|
51
|
+
isOpen: import_ds_props_helpers.PropTypes.bool.description("Whether the Banner is open or closed.").defaultValue(true),
|
|
52
|
+
showCloseButton: import_ds_props_helpers.PropTypes.bool.description("Whether to show close button or not.").defaultValue(true),
|
|
53
|
+
actionLink: import_ds_props_helpers.PropTypes.shape({
|
|
54
|
+
label: import_ds_props_helpers.PropTypes.string,
|
|
55
|
+
onClick: import_ds_props_helpers.PropTypes.func,
|
|
56
|
+
href: import_ds_props_helpers.PropTypes.string
|
|
57
57
|
}).description("Properties for the Action Link.").defaultValue({}),
|
|
58
|
-
actionRef:
|
|
58
|
+
actionRef: import_ds_props_helpers.PropTypes.object.description(
|
|
59
59
|
`
|
|
60
60
|
Reference to use actions:
|
|
61
61
|
- focusOnLink: function to focus the banner
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type { WeakValidationMap } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,
|
|
4
|
+
"sourcesContent": ["import type { WeakValidationMap } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\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": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,8BAAuE;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,kCAAU,OAAO,YAAY,mDAAmD,EAAE,aAAa,CAAC,CAAC;AAAA,EACjH,OAAO,kCAAU,OAAO,YAAY,eAAe,EAAE,aAAa,EAAE;AAAA,EACpE,MAAM,kCAAU,OAAO,YAAY,qBAAqB,EAAE,aAAa,EAAE;AAAA,EACzE,MAAM,kCAAU,MAAM,OAAO,OAAO,oCAAY,CAAC,EAAE,YAAY,cAAc,EAAE,aAAa,qCAAa,IAAI;AAAA,EAC7G,SAAS,kCAAU,KAAK,YAAY,kCAAkC;AAAA,EACtE,QAAQ,kCAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,IAAI;AAAA,EAC7F,iBAAiB,kCAAU,KAAK,YAAY,sCAAsC,EAAE,aAAa,IAAI;AAAA,EACrG,YAAY,kCAAU,MAAM;AAAA,IAC1B,OAAO,kCAAU;AAAA,IACjB,SAAS,kCAAU;AAAA,IACnB,MAAM,kCAAU;AAAA,EAClB,CAAC,EACE,YAAY,iCAAiC,EAC7C,aAAa,CAAC,CAAC;AAAA,EAClB,WAAW,kCAAU,OAClB;AAAA,IACC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKF,EACC,aAAa,CAAC,CAAC;AACpB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSBanner.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useMemoMergePropsWithDefault,
|
|
7
7
|
useGetGlobalAttributes,
|
|
8
8
|
useGetXstyledProps
|
|
9
|
-
} from "@elliemae/ds-
|
|
9
|
+
} from "@elliemae/ds-props-helpers";
|
|
10
10
|
import { CloseX } from "@elliemae/ds-icons";
|
|
11
11
|
import { icons } from "./utils/icons";
|
|
12
12
|
import { propTypes, defaultProps } from "./react-desc-prop-types";
|
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", "/* 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-
|
|
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-props-helpers';\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
5
|
"mappings": "AAAA,YAAY,WAAW;ACuGf,cAEA,YAFA;AAtGR,SAAgB,iBAAiB,QAAQ,aAAa,UAAU,iBAAiB;AACjF;AAAA,EACE;AAAA,EAC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AC;AAAA;AAAA,gBACC,eAAa,mBAAmB;AAAA,gBAChC,YAAW;AAAA,gBACX,SAAS;AAAA,gBACT,cAAW;AAAA,gBAEX,8BAAC,UAAO,OAAO,IAAI,QAAQ,IAAI;AAAA;AAAA,YACjC,IAEA,oBAAC,UAAK;AAAA;AAAA;AAAA,MAEV;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,cAAc;AACvB,MAAM,qBAAqB,SAAS,QAAQ;AAC5C,mBAAmB,YAAY;AAE/B,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from "@elliemae/ds-
|
|
2
|
+
import { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from "@elliemae/ds-props-helpers";
|
|
3
3
|
import { BANNER_TYPES } from "./exported-related";
|
|
4
4
|
const defaultProps = {
|
|
5
5
|
containerProps: {},
|
|
@@ -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 { WeakValidationMap } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { WeakValidationMap } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\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
5
|
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,WAAW,2BAA2B,wBAAwB;AACvE,SAAS,oBAAoB;AAsBtB,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;AAAA,IACC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKF,EACC,aAAa,CAAC,CAAC;AACpB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/types/DSBanner.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DSBannerT } from './react-desc-prop-types';
|
|
3
3
|
declare const DSBanner: React.ComponentType<DSBannerT.Props>;
|
|
4
|
-
declare const DSBannerWithSchema: import("@elliemae/ds-
|
|
4
|
+
declare const DSBannerWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types").DocumentedReactComponent<DSBannerT.Props>;
|
|
5
5
|
export default DSBanner;
|
|
6
6
|
export { DSBanner, DSBannerWithSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-banner",
|
|
3
|
-
"version": "3.16.0-next.
|
|
3
|
+
"version": "3.16.0-next.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Banner",
|
|
6
6
|
"files": [
|
|
@@ -63,10 +63,11 @@
|
|
|
63
63
|
"indent": 4
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@elliemae/ds-
|
|
67
|
-
"@elliemae/ds-
|
|
68
|
-
"@elliemae/ds-
|
|
69
|
-
"@elliemae/ds-
|
|
66
|
+
"@elliemae/ds-props-helpers": "3.16.0-next.3",
|
|
67
|
+
"@elliemae/ds-button": "3.16.0-next.3",
|
|
68
|
+
"@elliemae/ds-system": "3.16.0-next.3",
|
|
69
|
+
"@elliemae/ds-icons": "3.16.0-next.3",
|
|
70
|
+
"@elliemae/ds-utilities": "3.16.0-next.3"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@testing-library/jest-dom": "~5.16.4",
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
"eslint:fix": "eslint --ext='.js,.jsx,.test.js,.ts,.tsx' --fix --config='../../.eslintrc.js' src/",
|
|
92
93
|
"dts": "node ../../scripts/dts.mjs",
|
|
93
94
|
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs",
|
|
94
|
-
"dev:build": "pnpm --filter {.}... build
|
|
95
|
+
"dev:build": "pnpm --filter {.}... build",
|
|
95
96
|
"dev:install": "pnpm --filter {.}... i --no-lockfile && pnpm run dev:build",
|
|
96
97
|
"checkDeps": "npx -yes ../ds-codemods check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\""
|
|
97
98
|
}
|