@drivy/cobalt 0.14.6 → 0.14.7
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.
|
@@ -16,22 +16,18 @@ var isModalFooterAPIComponent = function (component) {
|
|
|
16
16
|
return React.isValidElement(component) && component.type === ModalFooterAPI;
|
|
17
17
|
};
|
|
18
18
|
var _Modal = forwardRef(function (_a, ref) {
|
|
19
|
-
var ariaLabel = _a["aria-label"], children = _a.children, isOpen = _a.isOpen, close = _a.close, _b = _a.overflowHidden, overflowHidden = _b === void 0 ? true : _b, initialFocusRef = _a.initialFocusRef, bodySpacing = _a.bodySpacing, onDismissAttempt = _a.onDismissAttempt, onHidden = _a.onHidden, onShow = _a.onShow, title = _a.title;
|
|
20
|
-
var defaultBodyStyle = useRef(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
}, []);
|
|
19
|
+
var ariaLabel = _a["aria-label"], children = _a.children, isOpen = _a.isOpen, close = _a.close, _b = _a.overflowHidden, overflowHidden = _b === void 0 ? true : _b, initialFocusRef = _a.initialFocusRef, bodySpacing = _a.bodySpacing, onDismissAttempt = _a.onDismissAttempt, onHidden = _a.onHidden, onShow = _a.onShow, title = _a.title, _c = _a.skipAnimation, skipAnimation = _c === void 0 ? { enter: false, leave: false } : _c;
|
|
20
|
+
var defaultBodyStyle = useRef({
|
|
21
|
+
paddingRight: document.body.style.paddingRight,
|
|
22
|
+
overflow: document.body.style.overflow,
|
|
23
|
+
isRestored: false,
|
|
24
|
+
});
|
|
27
25
|
var restoreDefaultBodyStyle = function () {
|
|
28
|
-
if (defaultBodyStyle.current) {
|
|
29
|
-
var _a = defaultBodyStyle.current,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
document.body.style.paddingRight = paddingRight_1;
|
|
34
|
-
}, 0);
|
|
26
|
+
if (defaultBodyStyle.current && !defaultBodyStyle.current.isRestored) {
|
|
27
|
+
var _a = defaultBodyStyle.current, overflow = _a.overflow, paddingRight = _a.paddingRight;
|
|
28
|
+
document.body.style.overflow = overflow;
|
|
29
|
+
document.body.style.paddingRight = paddingRight;
|
|
30
|
+
defaultBodyStyle.current.isRestored = true;
|
|
35
31
|
}
|
|
36
32
|
};
|
|
37
33
|
useEffect(function () {
|
|
@@ -41,6 +37,7 @@ var _Modal = forwardRef(function (_a, ref) {
|
|
|
41
37
|
// dangerouslyBypassScrollLock is used to disabled it
|
|
42
38
|
// + fake scrollbar width to avoid visual layout shift
|
|
43
39
|
if (isOpen) {
|
|
40
|
+
defaultBodyStyle.current.isRestored = false;
|
|
44
41
|
document.body.style.paddingRight = "".concat(getScrollbarWidth() +
|
|
45
42
|
parseInt(window.getComputedStyle(document.body).paddingRight, 10), "px"); // to avoid visual shift due to removing an existing scrollbar
|
|
46
43
|
document.body.style.overflow = "hidden";
|
|
@@ -58,11 +55,13 @@ var _Modal = forwardRef(function (_a, ref) {
|
|
|
58
55
|
modalTransform: transformTransitionOut,
|
|
59
56
|
},
|
|
60
57
|
enter: {
|
|
58
|
+
immediate: skipAnimation.enter,
|
|
61
59
|
overlayOpacity: 1,
|
|
62
60
|
modalTransform: 0,
|
|
63
61
|
config: springConfig,
|
|
64
62
|
},
|
|
65
63
|
leave: {
|
|
64
|
+
immediate: skipAnimation.leave,
|
|
66
65
|
overlayOpacity: 0,
|
|
67
66
|
modalTransform: transformTransitionOut,
|
|
68
67
|
config: springConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import React, { forwardRef, useEffect, useRef } from \"react\"\nimport cx from \"classnames\"\nimport { DialogOverlay, DialogContent } from \"@reach/dialog\"\nimport { useTransition, animated } from \"@react-spring/web\"\n\nimport useBreakpoint from \"../../hooks/useBreakpoint\"\nimport ModalHeader from \"./ModalHeader\"\nimport ModalBody from \"./ModalBody\"\nimport ModalFooter, { ModalFooterPropsType } from \"./ModalFooter\"\nimport { getScrollbarWidth } from \"../utils/\"\n\nexport type ModalPropsType = {\n /**\n * mandatory for A11y\n */\n [\"aria-label\"]: string\n /**\n * Function called to close the modal, providing it make the modal closeable\n */\n close?: () => void\n /**\n * React.ref of the element to focus first when the modal opens\n */\n initialFocusRef?: React.RefObject<HTMLElement>\n /**\n * State to show or hide the modal/dialog\n */\n isOpen: boolean\n /**\n * Action to fire if the user try to dismiss when the modal is not closeable\n */\n onDismissAttempt?: () => void\n /**\n * Listener called when the modal has been fully hidden\n */\n onHidden?: () => void\n /**\n * Listener called when the modal begins to show\n */\n onShow?: () => void\n /**\n * Modal title\n */\n title?: string\n /**\n * Disable/Enable body paddings (enabled by default)\n */\n bodySpacing?: boolean\n /**\n * Disable/Enable hidding overflowing absolute elements (enabled by default)\n */\n overflowHidden?: boolean\n /**\n * Modal body content\n */\n children: React.ReactNode\n}\n\n// Only for the API, render nothing, we use ModalFooterInternal internally\nexport const ModalFooterAPI = (_props: ModalFooterPropsType) => null\n\nexport const isModalFooterAPIComponent = (\n component: React.ReactNode\n): component is React.ReactElement<ModalFooterPropsType> =>\n React.isValidElement(component) && component.type === ModalFooterAPI\n\nconst _Modal = forwardRef<HTMLDivElement, ModalPropsType>(\n (\n {\n [\"aria-label\"]: ariaLabel,\n children,\n isOpen,\n close,\n overflowHidden = true,\n initialFocusRef,\n bodySpacing,\n onDismissAttempt,\n onHidden,\n onShow,\n title,\n }: ModalPropsType,\n ref\n ) => {\n const defaultBodyStyle =\n useRef<Record<\"paddingRight\" | \"overflow\", string>>()\n\n useEffect(() => {\n defaultBodyStyle.current = {\n paddingRight: document.body.style.paddingRight,\n overflow: document.body.style.overflow,\n }\n }, [])\n\n const restoreDefaultBodyStyle = () => {\n if (defaultBodyStyle.current) {\n const { overflow, paddingRight } = defaultBodyStyle.current\n setTimeout(() => {\n // setTimeout is used to ensure that the restore style job is done as a final step\n document.body.style.overflow = overflow\n document.body.style.paddingRight = paddingRight\n }, 0)\n }\n }\n\n useEffect(() => {\n // disable / enable body scroll\n // default reach ui solution to lock body scroll is broken with range inputs on mobile (no drag)\n // https://github.com/reach/reach-ui/issues/678\n // dangerouslyBypassScrollLock is used to disabled it\n // + fake scrollbar width to avoid visual layout shift\n if (isOpen) {\n document.body.style.paddingRight = `${\n getScrollbarWidth() +\n parseInt(window.getComputedStyle(document.body).paddingRight, 10)\n }px` // to avoid visual shift due to removing an existing scrollbar\n\n document.body.style.overflow = \"hidden\"\n }\n return () => {\n isOpen && restoreDefaultBodyStyle()\n }\n }, [isOpen])\n\n const { isMobile } = useBreakpoint()\n\n const transformTransitionOut = isMobile ? 500 : -20\n\n const springConfig = { tension: 300, friction: 30, clamp: true }\n\n const transition = useTransition(isOpen, {\n from: {\n overlayOpacity: 0,\n modalTransform: transformTransitionOut,\n },\n enter: {\n overlayOpacity: 1,\n modalTransform: 0,\n config: springConfig,\n },\n leave: {\n overlayOpacity: 0,\n modalTransform: transformTransitionOut,\n config: springConfig,\n },\n onStart: () => {\n if (onShow) onShow()\n },\n onDestroyed: (isTransitioned) => {\n !isOpen && restoreDefaultBodyStyle()\n if (onHidden && isTransitioned) onHidden()\n },\n })\n\n const AnimatedDialogOverlay = animated(DialogOverlay)\n const AnimatedDialogContent = animated(DialogContent)\n\n const modalFooter = React.Children.toArray(children).find((c) =>\n isModalFooterAPIComponent(c)\n )\n\n let header: React.ReactNode = null\n if (title || close) {\n header = <ModalHeader title={title} {...(close ? { close } : {})} />\n }\n const hasHeader = !!title || !!close\n\n let footer: React.ReactNode = null\n if (React.isValidElement(modalFooter)) {\n footer = <ModalFooter {...modalFooter.props} />\n }\n\n const getDismissHandler = (onClose?: ModalPropsType[\"close\"]) => {\n if (onClose) return onClose\n if (onDismissAttempt) return onDismissAttempt\n return\n }\n\n return (\n <>\n {transition(\n (styles, isOpenState) =>\n isOpenState && (\n <AnimatedDialogOverlay\n initialFocusRef={initialFocusRef}\n onDismiss={getDismissHandler(close)}\n className=\"cobalt-modal__overlay\"\n style={{ opacity: styles.overlayOpacity }}\n onTouchEnd={(e) => e.stopPropagation()}\n onMouseUp={(e) => e.stopPropagation()}\n dangerouslyBypassScrollLock\n >\n <AnimatedDialogContent\n className={cx(\"cobalt-modal\", {\n \"cobalt-modal--desktop\": !isMobile,\n \"cobalt-modal--mobile\": isMobile,\n \"cobalt-modal--overflowHidden\": overflowHidden,\n })}\n aria-label={ariaLabel}\n style={{ translateY: styles.modalTransform }}\n ref={ref}\n >\n {header}\n <ModalBody\n bodySpacing={bodySpacing}\n hasHeader={hasHeader}\n hasFooter={!!footer}\n >\n {children}\n </ModalBody>\n {footer}\n </AnimatedDialogContent>\n </AnimatedDialogOverlay>\n )\n )}\n </>\n )\n }\n)\n\n_Modal.displayName = \"Modal\"\n\nconst Modal = Object.assign(_Modal, { Footer: ModalFooterAPI })\n\nexport default Modal\n"],"names":[],"mappings":";;;;;;;;;;;;AA0DA;IACa,cAAc,GAAG,UAAC,MAA4B,IAAK,OAAA,IAAI,IAAA;IAEvD,yBAAyB,GAAG,UACvC,SAA0B;IAE1B,OAAA,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,KAAK,cAAc;AAApE,EAAoE;AAEtE,IAAM,MAAM,GAAG,UAAU,CACvB,UACE,EAYiB,EACjB,GAAG;QAZe,SAAS,mBAAA,EACzB,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,KAAK,WAAA,EACL,sBAAqB,EAArB,cAAc,mBAAG,IAAI,KAAA,EACrB,eAAe,qBAAA,EACf,WAAW,iBAAA,EACX,gBAAgB,sBAAA,EAChB,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,KAAK,WAAA;IAIP,IAAM,gBAAgB,GACpB,MAAM,EAA+C,CAAA;IAEvD,SAAS,CAAC;QACR,gBAAgB,CAAC,OAAO,GAAG;YACzB,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY;YAC9C,QAAQ,EAAE,QAAQ,CAAC,IA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OAAM;KACP,CAAA;IAED,QACE,0CACG,UAAU,CACT,UAAC,MAAM,EAAE,WAAW;QAClB,OAAA,WAAW,KACT,oBAAC,qBAAqB,IACpB,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,iBAAiB,CAAC,KAAK,CAAC,EACnC,SAAS,EAAC,uBAAuB,EACjC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,cAAc,EAAE,EACzC,UAAU,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,eAAe,EAAE,GAAA,EACtC,SAAS,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,eAAe,EAAE,GAAA,EACrC,2BAA2B;YAE3B,oBAAC,qBAAqB,IACpB,SAAS,EAAE,EAAE,CAAC,cAAc,EAAE;oBAC5B,uBAAuB,EAAE,CAAC,QAAQ;oBAClC,sBAAsB,EAAE,QAAQ;oBAChC,8BAA8B,EAAE,cAAc;iBAC/C,CAAC,gBACU,SAAS,EACrB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,cAAc,EAAE,EAC5C,GAAG,EAAE,GAAG;gBAEP,MAAM;gBACP,oBAAC,SAAS,IACR,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,CAAC,CAAC,MAAM,IAElB,QAAQ,CACC;gBACX,MAAM,CACe,CACF,CACzB;KAAA,CACJ,CACA,EACJ;AACH,CAAC,CACF,CAAA;AAED,MAAM,CAAC,WAAW,GAAG,OAAO,CAAA;IAEtB,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import React, { forwardRef, useEffect, useRef } from \"react\"\nimport cx from \"classnames\"\nimport { DialogOverlay, DialogContent } from \"@reach/dialog\"\nimport { useTransition, animated } from \"@react-spring/web\"\n\nimport useBreakpoint from \"../../hooks/useBreakpoint\"\nimport ModalHeader from \"./ModalHeader\"\nimport ModalBody from \"./ModalBody\"\nimport ModalFooter, { ModalFooterPropsType } from \"./ModalFooter\"\nimport { getScrollbarWidth } from \"../utils/\"\n\nexport type ModalPropsType = {\n /**\n * mandatory for A11y\n */\n [\"aria-label\"]: string\n /**\n * Function called to close the modal, providing it make the modal closeable\n */\n close?: () => void\n /**\n * React.ref of the element to focus first when the modal opens\n */\n initialFocusRef?: React.RefObject<HTMLElement>\n /**\n * State to show or hide the modal/dialog\n */\n isOpen: boolean\n /**\n * Action to fire if the user try to dismiss when the modal is not closeable\n */\n onDismissAttempt?: () => void\n /**\n * Listener called when the modal has been fully hidden\n */\n onHidden?: () => void\n /**\n * Listener called when the modal begins to show\n */\n onShow?: () => void\n /**\n * Modal title\n */\n title?: string\n /**\n * Disable/Enable body paddings (enabled by default)\n */\n bodySpacing?: boolean\n /**\n * Disable/Enable hidding overflowing absolute elements (enabled by default)\n */\n overflowHidden?: boolean\n /**\n * Disable enter/leave animation (animation enabled by default)\n */\n skipAnimation?: {\n enter: boolean\n leave: boolean\n }\n /**\n * Modal body content\n */\n children: React.ReactNode\n}\n\n// Only for the API, render nothing, we use ModalFooterInternal internally\nexport const ModalFooterAPI = (_props: ModalFooterPropsType) => null\n\nexport const isModalFooterAPIComponent = (\n component: React.ReactNode\n): component is React.ReactElement<ModalFooterPropsType> =>\n React.isValidElement(component) && component.type === ModalFooterAPI\n\nconst _Modal = forwardRef<HTMLDivElement, ModalPropsType>(\n (\n {\n [\"aria-label\"]: ariaLabel,\n children,\n isOpen,\n close,\n overflowHidden = true,\n initialFocusRef,\n bodySpacing,\n onDismissAttempt,\n onHidden,\n onShow,\n title,\n skipAnimation = { enter: false, leave: false },\n }: ModalPropsType,\n ref\n ) => {\n const defaultBodyStyle = useRef({\n paddingRight: document.body.style.paddingRight,\n overflow: document.body.style.overflow,\n isRestored: false,\n })\n\n const restoreDefaultBodyStyle = () => {\n if (defaultBodyStyle.current && !defaultBodyStyle.current.isRestored) {\n const { overflow, paddingRight } = defaultBodyStyle.current\n\n document.body.style.overflow = overflow\n document.body.style.paddingRight = paddingRight\n\n defaultBodyStyle.current.isRestored = true\n }\n }\n\n useEffect(() => {\n // disable / enable body scroll\n // default reach ui solution to lock body scroll is broken with range inputs on mobile (no drag)\n // https://github.com/reach/reach-ui/issues/678\n // dangerouslyBypassScrollLock is used to disabled it\n // + fake scrollbar width to avoid visual layout shift\n if (isOpen) {\n defaultBodyStyle.current.isRestored = false\n\n document.body.style.paddingRight = `${\n getScrollbarWidth() +\n parseInt(window.getComputedStyle(document.body).paddingRight, 10)\n }px` // to avoid visual shift due to removing an existing scrollbar\n\n document.body.style.overflow = \"hidden\"\n }\n return () => {\n isOpen && restoreDefaultBodyStyle()\n }\n }, [isOpen])\n\n const { isMobile } = useBreakpoint()\n\n const transformTransitionOut = isMobile ? 500 : -20\n\n const springConfig = { tension: 300, friction: 30, clamp: true }\n\n const transition = useTransition(isOpen, {\n from: {\n overlayOpacity: 0,\n modalTransform: transformTransitionOut,\n },\n enter: {\n immediate: skipAnimation.enter,\n overlayOpacity: 1,\n modalTransform: 0,\n config: springConfig,\n },\n leave: {\n immediate: skipAnimation.leave,\n overlayOpacity: 0,\n modalTransform: transformTransitionOut,\n config: springConfig,\n },\n onStart: () => {\n if (onShow) onShow()\n },\n onDestroyed: (isTransitioned) => {\n !isOpen && restoreDefaultBodyStyle()\n if (onHidden && isTransitioned) onHidden()\n },\n })\n\n const AnimatedDialogOverlay = animated(DialogOverlay)\n const AnimatedDialogContent = animated(DialogContent)\n\n const modalFooter = React.Children.toArray(children).find((c) =>\n isModalFooterAPIComponent(c)\n )\n\n let header: React.ReactNode = null\n if (title || close) {\n header = <ModalHeader title={title} {...(close ? { close } : {})} />\n }\n const hasHeader = !!title || !!close\n\n let footer: React.ReactNode = null\n if (React.isValidElement(modalFooter)) {\n footer = <ModalFooter {...modalFooter.props} />\n }\n\n const getDismissHandler = (onClose?: ModalPropsType[\"close\"]) => {\n if (onClose) return onClose\n if (onDismissAttempt) return onDismissAttempt\n return\n }\n\n return (\n <>\n {transition(\n (styles, isOpenState) =>\n isOpenState && (\n <AnimatedDialogOverlay\n initialFocusRef={initialFocusRef}\n onDismiss={getDismissHandler(close)}\n className=\"cobalt-modal__overlay\"\n style={{ opacity: styles.overlayOpacity }}\n onTouchEnd={(e) => e.stopPropagation()}\n onMouseUp={(e) => e.stopPropagation()}\n dangerouslyBypassScrollLock\n >\n <AnimatedDialogContent\n className={cx(\"cobalt-modal\", {\n \"cobalt-modal--desktop\": !isMobile,\n \"cobalt-modal--mobile\": isMobile,\n \"cobalt-modal--overflowHidden\": overflowHidden,\n })}\n aria-label={ariaLabel}\n style={{ translateY: styles.modalTransform }}\n ref={ref}\n >\n {header}\n <ModalBody\n bodySpacing={bodySpacing}\n hasHeader={hasHeader}\n hasFooter={!!footer}\n >\n {children}\n </ModalBody>\n {footer}\n </AnimatedDialogContent>\n </AnimatedDialogOverlay>\n )\n )}\n </>\n )\n }\n)\n\n_Modal.displayName = \"Modal\"\n\nconst Modal = Object.assign(_Modal, { Footer: ModalFooterAPI })\n\nexport default Modal\n"],"names":[],"mappings":";;;;;;;;;;;;AAiEA;IACa,cAAc,GAAG,UAAC,MAA4B,IAAK,OAAA,IAAI,IAAA;IAEvD,yBAAyB,GAAG,UACvC,SAA0B;IAE1B,OAAA,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,KAAK,cAAc;AAApE,EAAoE;AAEtE,IAAM,MAAM,GAAG,UAAU,CACvB,UACE,EAaiB,EACjB,GAAG;QAbe,SAAS,mBAAA,EACzB,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,KAAK,WAAA,EACL,sBAAqB,EAArB,cAAc,mBAAG,IAAI,KAAA,EACrB,eAAe,qBAAA,EACf,WAAW,iBAAA,EACX,gBAAgB,sBAAA,EAChB,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,KAAK,WAAA,EACL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Q,CACC;gBACX,MAAM,CACe,CACF,CACzB;KAAA,CACJ,CACA,EACJ;AACH,CAAC,CACF,CAAA;AAED,MAAM,CAAC,WAAW,GAAG,OAAO,CAAA;IAEtB,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drivy/cobalt",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.7",
|
|
4
4
|
"description": "Opinionated design system for Drivy's projects.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"date-fns": "2.28.0",
|
|
32
32
|
"lodash.throttle": "4.1.1",
|
|
33
33
|
"media-typer": "1.1.0",
|
|
34
|
-
"nanoid": "3.
|
|
35
|
-
"postcss": "8.4.
|
|
34
|
+
"nanoid": "3.3.1",
|
|
35
|
+
"postcss": "8.4.6",
|
|
36
36
|
"tailwindcss": "2.2.19",
|
|
37
37
|
"tippy.js": "6.3.7"
|
|
38
38
|
},
|
|
@@ -49,25 +49,25 @@
|
|
|
49
49
|
"@percy/storybook": "3.3.1",
|
|
50
50
|
"@rollup/plugin-json": "4.1.0",
|
|
51
51
|
"@rushstack/eslint-patch": "1.1.0",
|
|
52
|
-
"@storybook/addon-essentials": "6.4.
|
|
53
|
-
"@storybook/addons": "6.4.
|
|
54
|
-
"@storybook/builder-webpack5": "6.4.
|
|
55
|
-
"@storybook/manager-webpack5": "6.4.
|
|
56
|
-
"@storybook/react": "6.4.
|
|
52
|
+
"@storybook/addon-essentials": "6.4.19",
|
|
53
|
+
"@storybook/addons": "6.4.19",
|
|
54
|
+
"@storybook/builder-webpack5": "6.4.19",
|
|
55
|
+
"@storybook/manager-webpack5": "6.4.19",
|
|
56
|
+
"@storybook/react": "6.4.19",
|
|
57
57
|
"@svgr/cli": "5.5.0",
|
|
58
|
-
"@testing-library/jest-dom": "5.16.
|
|
59
|
-
"@testing-library/react": "12.1.
|
|
58
|
+
"@testing-library/jest-dom": "5.16.2",
|
|
59
|
+
"@testing-library/react": "12.1.3",
|
|
60
60
|
"@testing-library/react-hooks": "7.0.2",
|
|
61
61
|
"@types/classnames": "2.3.0",
|
|
62
62
|
"@types/jest": "27.4.0",
|
|
63
63
|
"@types/lodash.throttle": "4.1.6",
|
|
64
64
|
"@types/media-typer": "1.1.1",
|
|
65
|
-
"@types/react": "17.0.
|
|
65
|
+
"@types/react": "17.0.39",
|
|
66
66
|
"autoprefixer": "10.4.2",
|
|
67
|
-
"core-js": "3.
|
|
68
|
-
"css-loader": "6.
|
|
69
|
-
"eslint": "8.
|
|
70
|
-
"jest": "27.
|
|
67
|
+
"core-js": "3.21.1",
|
|
68
|
+
"css-loader": "6.6.0",
|
|
69
|
+
"eslint": "8.9.0",
|
|
70
|
+
"jest": "27.5.1",
|
|
71
71
|
"np": "7.6.0",
|
|
72
72
|
"postcss-flexbugs-fixes": "5.0.2",
|
|
73
73
|
"postcss-loader": "6.2.1",
|
|
@@ -77,15 +77,15 @@
|
|
|
77
77
|
"react-dom": "17.0.2",
|
|
78
78
|
"react-test-renderer": "17.0.2",
|
|
79
79
|
"regenerator-runtime": "0.13.9",
|
|
80
|
-
"rollup": "2.
|
|
80
|
+
"rollup": "2.67.3",
|
|
81
81
|
"rollup-plugin-copy": "3.4.0",
|
|
82
82
|
"rollup-plugin-postcss": "4.0.2",
|
|
83
83
|
"rollup-plugin-svgo": "1.1.0",
|
|
84
|
-
"rollup-plugin-typescript2": "0.31.
|
|
85
|
-
"sass": "1.49.
|
|
86
|
-
"sass-loader": "12.
|
|
84
|
+
"rollup-plugin-typescript2": "0.31.2",
|
|
85
|
+
"sass": "1.49.8",
|
|
86
|
+
"sass-loader": "12.6.0",
|
|
87
87
|
"style-loader": "3.3.1",
|
|
88
|
-
"stylelint": "14.
|
|
88
|
+
"stylelint": "14.5.1",
|
|
89
89
|
"svgo": "2.8.0",
|
|
90
90
|
"ts-jest": "27.1.3",
|
|
91
91
|
"typescript": "4.5.5"
|
|
@@ -132,6 +132,6 @@
|
|
|
132
132
|
"access": "public"
|
|
133
133
|
},
|
|
134
134
|
"resolutions": {
|
|
135
|
-
"@types/react": "17.0.
|
|
135
|
+
"@types/react": "17.0.39"
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -43,13 +43,16 @@
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
.cobalt-radio-with-details__title {
|
|
46
|
-
@include text-style-section-header;
|
|
47
46
|
color: color(indigo);
|
|
47
|
+
font-size: 14px;
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
line-height: 18px;
|
|
48
50
|
|
|
49
51
|
transition: color 150ms ease-in-out;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
.cobalt-radio-with-details__description {
|
|
55
|
+
@include text-style-body;
|
|
53
56
|
color: color(grey, dark);
|
|
54
57
|
|
|
55
58
|
transition: color 150ms ease-in-out;
|
|
@@ -41,6 +41,13 @@ export declare type ModalPropsType = {
|
|
|
41
41
|
* Disable/Enable hidding overflowing absolute elements (enabled by default)
|
|
42
42
|
*/
|
|
43
43
|
overflowHidden?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Disable enter/leave animation (animation enabled by default)
|
|
46
|
+
*/
|
|
47
|
+
skipAnimation?: {
|
|
48
|
+
enter: boolean;
|
|
49
|
+
leave: boolean;
|
|
50
|
+
};
|
|
44
51
|
/**
|
|
45
52
|
* Modal body content
|
|
46
53
|
*/
|