@transferwise/components 0.0.0-experimental-cd50158 → 0.0.0-experimental-faee41b
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/build/drawer/Drawer.js +2 -0
- package/build/drawer/Drawer.js.map +1 -1
- package/build/drawer/Drawer.mjs +2 -0
- package/build/drawer/Drawer.mjs.map +1 -1
- package/build/modal/Modal.js +1 -0
- package/build/modal/Modal.js.map +1 -1
- package/build/modal/Modal.mjs +1 -0
- package/build/modal/Modal.mjs.map +1 -1
- package/build/types/drawer/Drawer.d.ts +2 -1
- package/build/types/drawer/Drawer.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/dimmer/Dimmer.spec.js +8 -0
- package/src/drawer/Drawer.spec.js +25 -6
- package/src/drawer/Drawer.tsx +3 -1
- package/src/modal/Modal.spec.js +19 -1
- package/src/modal/Modal.tsx +1 -0
- package/src/uploadInput/UploadInput.story.tsx +1 -1
- package/src/uploadInput/UploadInput.tests.story.tsx +0 -2
package/build/drawer/Drawer.js
CHANGED
|
@@ -19,6 +19,7 @@ function Drawer({
|
|
|
19
19
|
footerContent,
|
|
20
20
|
headerTitle,
|
|
21
21
|
onClose,
|
|
22
|
+
onUnmount,
|
|
22
23
|
open = false,
|
|
23
24
|
position: position$1 = 'right',
|
|
24
25
|
role = 'dialog',
|
|
@@ -33,6 +34,7 @@ function Drawer({
|
|
|
33
34
|
return /*#__PURE__*/jsxRuntime.jsx(Dimmer.default, {
|
|
34
35
|
open: open,
|
|
35
36
|
onClose: onClose,
|
|
37
|
+
onExited: onUnmount,
|
|
36
38
|
children: /*#__PURE__*/jsxRuntime.jsx(SlidingPanel.default, {
|
|
37
39
|
open: open,
|
|
38
40
|
position: isMobile ? position.Position.BOTTOM : position$1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sources":["../../src/drawer/Drawer.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { HTMLAttributes, useContext, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../slidingPanel';\nimport Title from '../title';\nimport { logActionRequiredIf } from '../utilities';\n\nexport type DrawerProps = {\n /** The content to appear in the drawer body. */\n children?: React.ReactNode;\n className?: string;\n /** The content to appear in the drawer footer. */\n footerContent?: React.ReactNode;\n /** The content to appear in the drawer header. */\n headerTitle?: React.ReactNode;\n /** The status of Drawer either open or not. */\n open?: boolean;\n /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */\n position?: `${Position.LEFT | Position.RIGHT | Position.BOTTOM}`;\n /** The action to perform on close click. */\n onClose?: (event: KeyboardEvent | React.MouseEvent) => void;\n} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>;\n\nexport default function Drawer({\n children,\n className,\n footerContent,\n headerTitle,\n onClose,\n open = false,\n position = 'right',\n role = 'dialog',\n 'aria-labelledby': ariaLabelledBy,\n}: DrawerProps) {\n logActionRequiredIf(\n 'Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.',\n !onClose,\n );\n\n const { isMobile } = useLayout();\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} onClose={onClose}>\n <SlidingPanel open={open} position={isMobile ? Position.BOTTOM : position}>\n <div\n id={overlayId}\n role={role}\n aria-modal\n aria-labelledby={ariaLabelledBy || (headerTitle ? titleId : undefined)}\n className={clsx('np-drawer', className)}\n >\n <div\n className={clsx('np-drawer-header', {\n 'np-drawer-header--withborder': headerTitle,\n })}\n >\n {headerTitle && (\n <Title id={titleId} type={Typography.TITLE_BODY}>\n {headerTitle}\n </Title>\n )}\n <CloseButton onClick={onClose} />\n </div>\n {children && <div className={clsx('np-drawer-content')}>{children}</div>}\n {footerContent && <div className={clsx('np-drawer-footer')}>{footerContent}</div>}\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n}\n"],"names":["Drawer","children","className","footerContent","headerTitle","onClose","open","position","role","ariaLabelledBy","logActionRequiredIf","isMobile","useLayout","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","SlidingPanel","Position","BOTTOM","_jsxs","id","undefined","clsx","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../../src/drawer/Drawer.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { HTMLAttributes, useContext, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../slidingPanel';\nimport Title from '../title';\nimport { logActionRequiredIf } from '../utilities';\n\nexport type DrawerProps = {\n /** The content to appear in the drawer body. */\n children?: React.ReactNode;\n className?: string;\n /** The content to appear in the drawer footer. */\n footerContent?: React.ReactNode;\n /** The content to appear in the drawer header. */\n headerTitle?: React.ReactNode;\n /** The status of Drawer either open or not. */\n open?: boolean;\n /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */\n position?: `${Position.LEFT | Position.RIGHT | Position.BOTTOM}`;\n /** The action to perform on close click. */\n onClose?: (event: KeyboardEvent | React.MouseEvent) => void;\n onUnmount?: () => void;\n} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>;\n\nexport default function Drawer({\n children,\n className,\n footerContent,\n headerTitle,\n onClose,\n onUnmount,\n open = false,\n position = 'right',\n role = 'dialog',\n 'aria-labelledby': ariaLabelledBy,\n}: DrawerProps) {\n logActionRequiredIf(\n 'Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.',\n !onClose,\n );\n\n const { isMobile } = useLayout();\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} onClose={onClose} onExited={onUnmount}>\n <SlidingPanel open={open} position={isMobile ? Position.BOTTOM : position}>\n <div\n id={overlayId}\n role={role}\n aria-modal\n aria-labelledby={ariaLabelledBy || (headerTitle ? titleId : undefined)}\n className={clsx('np-drawer', className)}\n >\n <div\n className={clsx('np-drawer-header', {\n 'np-drawer-header--withborder': headerTitle,\n })}\n >\n {headerTitle && (\n <Title id={titleId} type={Typography.TITLE_BODY}>\n {headerTitle}\n </Title>\n )}\n <CloseButton onClick={onClose} />\n </div>\n {children && <div className={clsx('np-drawer-content')}>{children}</div>}\n {footerContent && <div className={clsx('np-drawer-footer')}>{footerContent}</div>}\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n}\n"],"names":["Drawer","children","className","footerContent","headerTitle","onClose","onUnmount","open","position","role","ariaLabelledBy","logActionRequiredIf","isMobile","useLayout","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","onExited","SlidingPanel","Position","BOTTOM","_jsxs","id","undefined","clsx","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;;;AA6BwB,SAAAA,MAAMA,CAAC;EAC7BC,QAAQ;EACRC,SAAS;EACTC,aAAa;EACbC,WAAW;EACXC,OAAO;EACPC,SAAS;AACTC,EAAAA,IAAI,GAAG,KAAK;AACZC,YAAAA,UAAQ,GAAG,OAAO;AAClBC,EAAAA,IAAI,GAAG,QAAQ;AACf,EAAA,iBAAiB,EAAEC,cAAAA;AACP,CAAA,EAAA;AACZC,EAAAA,qCAAmB,CACjB,8GAA8G,EAC9G,CAACN,OAAO,CACT,CAAA;EAED,MAAM;AAAEO,IAAAA,QAAAA;GAAU,GAAGC,mBAAS,EAAE,CAAA;AAChC,EAAA,MAAMC,OAAO,GAAGC,WAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,SAAS,GAAGC,gBAAU,CAACC,kCAAgB,CAAC,CAAA;EAE9C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AAA,CAAA,KAAA,EAAA;AAAKjB,UAAAA,SAAS,EAAE0B,SAAI,CAAC,kBAAkB,CAAE;AAAA3B,UAAAA,QAAA,EAAEE,aAAAA;AAAa,SAAM,CAAC,CAAA;OAC9E,CAAA;KACO,CAAA;AAChB,GAAQ,CAAC,CAAA;AAEb;;;;"}
|
package/build/drawer/Drawer.mjs
CHANGED
|
@@ -17,6 +17,7 @@ function Drawer({
|
|
|
17
17
|
footerContent,
|
|
18
18
|
headerTitle,
|
|
19
19
|
onClose,
|
|
20
|
+
onUnmount,
|
|
20
21
|
open = false,
|
|
21
22
|
position = 'right',
|
|
22
23
|
role = 'dialog',
|
|
@@ -31,6 +32,7 @@ function Drawer({
|
|
|
31
32
|
return /*#__PURE__*/jsx(Dimmer, {
|
|
32
33
|
open: open,
|
|
33
34
|
onClose: onClose,
|
|
35
|
+
onExited: onUnmount,
|
|
34
36
|
children: /*#__PURE__*/jsx(SlidingPanel, {
|
|
35
37
|
open: open,
|
|
36
38
|
position: isMobile ? Position.BOTTOM : position,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.mjs","sources":["../../src/drawer/Drawer.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { HTMLAttributes, useContext, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../slidingPanel';\nimport Title from '../title';\nimport { logActionRequiredIf } from '../utilities';\n\nexport type DrawerProps = {\n /** The content to appear in the drawer body. */\n children?: React.ReactNode;\n className?: string;\n /** The content to appear in the drawer footer. */\n footerContent?: React.ReactNode;\n /** The content to appear in the drawer header. */\n headerTitle?: React.ReactNode;\n /** The status of Drawer either open or not. */\n open?: boolean;\n /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */\n position?: `${Position.LEFT | Position.RIGHT | Position.BOTTOM}`;\n /** The action to perform on close click. */\n onClose?: (event: KeyboardEvent | React.MouseEvent) => void;\n} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>;\n\nexport default function Drawer({\n children,\n className,\n footerContent,\n headerTitle,\n onClose,\n open = false,\n position = 'right',\n role = 'dialog',\n 'aria-labelledby': ariaLabelledBy,\n}: DrawerProps) {\n logActionRequiredIf(\n 'Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.',\n !onClose,\n );\n\n const { isMobile } = useLayout();\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} onClose={onClose}>\n <SlidingPanel open={open} position={isMobile ? Position.BOTTOM : position}>\n <div\n id={overlayId}\n role={role}\n aria-modal\n aria-labelledby={ariaLabelledBy || (headerTitle ? titleId : undefined)}\n className={clsx('np-drawer', className)}\n >\n <div\n className={clsx('np-drawer-header', {\n 'np-drawer-header--withborder': headerTitle,\n })}\n >\n {headerTitle && (\n <Title id={titleId} type={Typography.TITLE_BODY}>\n {headerTitle}\n </Title>\n )}\n <CloseButton onClick={onClose} />\n </div>\n {children && <div className={clsx('np-drawer-content')}>{children}</div>}\n {footerContent && <div className={clsx('np-drawer-footer')}>{footerContent}</div>}\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n}\n"],"names":["Drawer","children","className","footerContent","headerTitle","onClose","open","position","role","ariaLabelledBy","logActionRequiredIf","isMobile","useLayout","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","SlidingPanel","Position","BOTTOM","_jsxs","id","undefined","clsx","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Drawer.mjs","sources":["../../src/drawer/Drawer.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { HTMLAttributes, useContext, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../slidingPanel';\nimport Title from '../title';\nimport { logActionRequiredIf } from '../utilities';\n\nexport type DrawerProps = {\n /** The content to appear in the drawer body. */\n children?: React.ReactNode;\n className?: string;\n /** The content to appear in the drawer footer. */\n footerContent?: React.ReactNode;\n /** The content to appear in the drawer header. */\n headerTitle?: React.ReactNode;\n /** The status of Drawer either open or not. */\n open?: boolean;\n /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */\n position?: `${Position.LEFT | Position.RIGHT | Position.BOTTOM}`;\n /** The action to perform on close click. */\n onClose?: (event: KeyboardEvent | React.MouseEvent) => void;\n onUnmount?: () => void;\n} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>;\n\nexport default function Drawer({\n children,\n className,\n footerContent,\n headerTitle,\n onClose,\n onUnmount,\n open = false,\n position = 'right',\n role = 'dialog',\n 'aria-labelledby': ariaLabelledBy,\n}: DrawerProps) {\n logActionRequiredIf(\n 'Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.',\n !onClose,\n );\n\n const { isMobile } = useLayout();\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} onClose={onClose} onExited={onUnmount}>\n <SlidingPanel open={open} position={isMobile ? Position.BOTTOM : position}>\n <div\n id={overlayId}\n role={role}\n aria-modal\n aria-labelledby={ariaLabelledBy || (headerTitle ? titleId : undefined)}\n className={clsx('np-drawer', className)}\n >\n <div\n className={clsx('np-drawer-header', {\n 'np-drawer-header--withborder': headerTitle,\n })}\n >\n {headerTitle && (\n <Title id={titleId} type={Typography.TITLE_BODY}>\n {headerTitle}\n </Title>\n )}\n <CloseButton onClick={onClose} />\n </div>\n {children && <div className={clsx('np-drawer-content')}>{children}</div>}\n {footerContent && <div className={clsx('np-drawer-footer')}>{footerContent}</div>}\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n}\n"],"names":["Drawer","children","className","footerContent","headerTitle","onClose","onUnmount","open","position","role","ariaLabelledBy","logActionRequiredIf","isMobile","useLayout","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","onExited","SlidingPanel","Position","BOTTOM","_jsxs","id","undefined","clsx","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;AA6BwB,SAAAA,MAAMA,CAAC;EAC7BC,QAAQ;EACRC,SAAS;EACTC,aAAa;EACbC,WAAW;EACXC,OAAO;EACPC,SAAS;AACTC,EAAAA,IAAI,GAAG,KAAK;AACZC,EAAAA,QAAQ,GAAG,OAAO;AAClBC,EAAAA,IAAI,GAAG,QAAQ;AACf,EAAA,iBAAiB,EAAEC,cAAAA;AACP,CAAA,EAAA;AACZC,EAAAA,mBAAmB,CACjB,8GAA8G,EAC9G,CAACN,OAAO,CACT,CAAA;EAED,MAAM;AAAEO,IAAAA,QAAAA;GAAU,GAAGC,SAAS,EAAE,CAAA;AAChC,EAAA,MAAMC,OAAO,GAAGC,KAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,SAAS,GAAGC,UAAU,CAACC,gBAAgB,CAAC,CAAA;EAE9C,oBACEC,GAAA,CAACC,MAAM,EAAA;AAACb,IAAAA,IAAI,EAAEA,IAAK;AAACF,IAAAA,OAAO,EAAEA,OAAQ;AAACgB,IAAAA,QAAQ,EAAEf,SAAU;IAAAL,QAAA,eACxDkB,GAAA,CAACG,YAAY,EAAA;AAACf,MAAAA,IAAI,EAAEA,IAAK;AAACC,MAAAA,QAAQ,EAAEI,QAAQ,GAAGW,QAAQ,CAACC,MAAM,GAAGhB,QAAS;AAAAP,MAAAA,QAAA,eACxEwB,IAAA,CAAA,KAAA,EAAA;AACEC,QAAAA,EAAE,EAAEV,SAAU;AACdP,QAAAA,IAAI,EAAEA,IAAK;QACX,YAAU,EAAA,IAAA;AACV,QAAA,iBAAA,EAAiBC,cAAc,KAAKN,WAAW,GAAGU,OAAO,GAAGa,SAAS,CAAE;AACvEzB,QAAAA,SAAS,EAAE0B,IAAI,CAAC,WAAW,EAAE1B,SAAS,CAAE;AAAAD,QAAAA,QAAA,gBAExCwB,IAAA,CAAA,KAAA,EAAA;AACEvB,UAAAA,SAAS,EAAE0B,IAAI,CAAC,kBAAkB,EAAE;AAClC,YAAA,8BAA8B,EAAExB,WAAAA;AACjC,WAAA,CAAE;AAAAH,UAAAA,QAAA,EAEFG,CAAAA,WAAW,iBACVe,GAAA,CAACU,KAAK,EAAA;AAACH,YAAAA,EAAE,EAAEZ,OAAQ;YAACgB,IAAI,EAAEC,UAAU,CAACC,UAAW;AAAA/B,YAAAA,QAAA,EAC7CG,WAAAA;AAAW,WACP,CACR,eACDe,GAAA,CAACc,WAAW,EAAA;AAACC,YAAAA,OAAO,EAAE7B,OAAAA;AAAQ,WAChC,CAAA,CAAA;AAAA,SAAK,CACL,EAACJ,QAAQ,iBAAIkB,GAAA,CAAA,KAAA,EAAA;AAAKjB,UAAAA,SAAS,EAAE0B,IAAI,CAAC,mBAAmB,CAAE;AAAA3B,UAAAA,QAAA,EAAEA,QAAAA;AAAQ,SAAM,CAAC,EACvEE,aAAa,iBAAIgB,GAAA,CAAA,KAAA,EAAA;AAAKjB,UAAAA,SAAS,EAAE0B,IAAI,CAAC,kBAAkB,CAAE;AAAA3B,UAAAA,QAAA,EAAEE,aAAAA;AAAa,SAAM,CAAC,CAAA;OAC9E,CAAA;KACO,CAAA;AAChB,GAAQ,CAAC,CAAA;AAEb;;;;"}
|
package/build/modal/Modal.js
CHANGED
package/build/modal/Modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../src/modal/Modal.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ReactNode, useContext, useId, useRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n Size,\n Position,\n PositionTop,\n PositionCenter,\n Scroll,\n CommonProps,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n SizeExtraLarge,\n ScrollContent,\n ScrollViewport,\n Typography,\n} from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport Drawer from '../drawer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport Title from '../title/Title';\n\nconst TRANSITION_DURATION_IN_MILLISECONDS = 150;\n\nexport type ModalProps = CommonProps & {\n title?: ReactNode;\n body: ReactNode;\n footer?: ReactNode;\n size?: SizeSmall | SizeMedium | SizeLarge | SizeExtraLarge;\n onClose: () => void;\n onUnmount?: () => void;\n open: boolean;\n scroll?: ScrollContent | ScrollViewport;\n position?: PositionTop | PositionCenter;\n disableDimmerClickToClose?: boolean;\n};\n\nconst Modal = ({\n title = null,\n body,\n footer = null,\n onClose,\n onUnmount,\n className,\n open,\n size = Size.MEDIUM,\n scroll = Scroll.VIEWPORT,\n position = Position.CENTER,\n disableDimmerClickToClose = false,\n ...otherProps\n}: ModalProps) => {\n const checkSpecialClasses = (classToCheck: string) =>\n className?.split(' ').includes(classToCheck);\n const { isMedium } = useLayout();\n\n // These should be replaced with props in breaking change.\n const isCompact = checkSpecialClasses('compact');\n const noDivider = checkSpecialClasses('no-divider');\n\n const contentReference = useRef<HTMLDivElement>(null);\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return !isMedium ? (\n <Drawer\n open={open}\n headerTitle={title}\n footerContent={footer}\n position={Position.BOTTOM}\n onClose={onClose}\n >\n {body}\n </Drawer>\n ) : (\n <Dimmer\n open={open}\n scrollable={scroll === Scroll.VIEWPORT}\n contentPosition={position}\n disableClickToClose={disableDimmerClickToClose}\n onClose={onClose}\n onExited={onUnmount}\n >\n <CSSTransition\n nodeRef={contentReference}\n appear\n in={open}\n classNames={{ enterDone: 'in' }}\n timeout={TRANSITION_DURATION_IN_MILLISECONDS}\n unmountOnExit\n >\n <div\n ref={contentReference}\n className={clsx(\n 'tw-modal',\n 'd-flex',\n 'fade',\n 'outline-none',\n scroll === Scroll.CONTENT && 'tw-modal--scrollable',\n className,\n )}\n {...otherProps}\n >\n <div\n id={overlayId}\n role=\"dialog\"\n aria-modal\n aria-labelledby={titleId}\n className={clsx('tw-modal-dialog', 'd-flex', {\n [`tw-modal-${size}`]: size,\n })}\n >\n <div\n className={clsx(\n 'tw-modal-content',\n 'd-flex',\n 'flex-column',\n 'justify-content-between',\n {\n 'tw-modal-compact': isCompact,\n 'tw-modal-no-title': !title,\n },\n )}\n >\n <div\n className={clsx(\n 'tw-modal-header',\n 'd-flex',\n 'align-items-center',\n 'justify-content-between',\n 'flex-wrap',\n {\n 'modal--withoutborder': !title || noDivider,\n },\n )}\n >\n <Title id={titleId} type={Typography.TITLE_BODY} className=\"tw-modal-title\">\n {title}\n </Title>\n <CloseButton onClick={onClose} />\n </div>\n <div\n className={clsx('tw-modal-body', {\n 'tw-modal-body--scrollable': scroll === Scroll.CONTENT,\n })}\n >\n {body}\n </div>\n {footer && (\n <div\n className={clsx('tw-modal-footer', 'd-flex', 'align-items-center', 'flex-wrap', {\n 'modal--withoutborder': noDivider,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n </div>\n </div>\n </CSSTransition>\n </Dimmer>\n );\n};\n\nexport default Modal;\n"],"names":["TRANSITION_DURATION_IN_MILLISECONDS","Modal","title","body","footer","onClose","onUnmount","className","open","size","Size","MEDIUM","scroll","Scroll","VIEWPORT","position","Position","CENTER","disableDimmerClickToClose","otherProps","checkSpecialClasses","classToCheck","split","includes","isMedium","useLayout","isCompact","noDivider","contentReference","useRef","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Drawer","headerTitle","footerContent","BOTTOM","children","Dimmer","scrollable","contentPosition","disableClickToClose","onExited","CSSTransition","nodeRef","appear","in","classNames","enterDone","timeout","unmountOnExit","ref","clsx","CONTENT","id","role","_jsxs","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAMA,mCAAmC,GAAG,GAAG,CAAA;AAezCC,MAAAA,KAAK,GAAGA,CAAC;AACbC,EAAAA,KAAK,GAAG,IAAI;EACZC,IAAI;AACJC,EAAAA,MAAM,GAAG,IAAI;EACbC,OAAO;EACPC,SAAS;EACTC,SAAS;EACTC,IAAI;QACJC,MAAI,GAAGC,SAAI,CAACC,MAAM;UAClBC,QAAM,GAAGC,aAAM,CAACC,QAAQ;YACxBC,UAAQ,GAAGC,iBAAQ,CAACC,MAAM;AAC1BC,EAAAA,yBAAyB,GAAG,KAAK;EACjC,GAAGC,UAAAA;AACQ,CAAA,KAAI;AACf,EAAA,MAAMC,mBAAmB,GAAIC,YAAoB,IAC/Cd,SAAS,EAAEe,KAAK,CAAC,GAAG,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,CAAA;EAC9C,MAAM;AAAEG,IAAAA,QAAAA;GAAU,GAAGC,mBAAS,EAAE,CAAA;AAEhC;AACA,EAAA,MAAMC,SAAS,GAAGN,mBAAmB,CAAC,SAAS,CAAC,CAAA;AAChD,EAAA,MAAMO,SAAS,GAAGP,mBAAmB,CAAC,YAAY,CAAC,CAAA;AAEnD,EAAA,MAAMQ,gBAAgB,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;AACrD,EAAA,MAAMC,OAAO,GAAGC,WAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,SAAS,GAAGC,gBAAU,CAACC,kCAAgB,CAAC,CAAA;AAE9C,EAAA,OAAO,CAACV,QAAQ,gBACdW,cAAA,CAACC,MAAM,EAAA;AACL5B,IAAAA,IAAI,EAAEA,IAAK;AACX6B,IAAAA,WAAW,EAAEnC,KAAM;AACnBoC,IAAAA,aAAa,EAAElC,MAAO;IACtBW,QAAQ,EAAEC,iBAAQ,CAACuB,MAAO;AAC1BlC,IAAAA,OAAO,EAAEA,OAAQ;
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../src/modal/Modal.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ReactNode, useContext, useId, useRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n Size,\n Position,\n PositionTop,\n PositionCenter,\n Scroll,\n CommonProps,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n SizeExtraLarge,\n ScrollContent,\n ScrollViewport,\n Typography,\n} from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport Drawer from '../drawer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport Title from '../title/Title';\n\nconst TRANSITION_DURATION_IN_MILLISECONDS = 150;\n\nexport type ModalProps = CommonProps & {\n title?: ReactNode;\n body: ReactNode;\n footer?: ReactNode;\n size?: SizeSmall | SizeMedium | SizeLarge | SizeExtraLarge;\n onClose: () => void;\n onUnmount?: () => void;\n open: boolean;\n scroll?: ScrollContent | ScrollViewport;\n position?: PositionTop | PositionCenter;\n disableDimmerClickToClose?: boolean;\n};\n\nconst Modal = ({\n title = null,\n body,\n footer = null,\n onClose,\n onUnmount,\n className,\n open,\n size = Size.MEDIUM,\n scroll = Scroll.VIEWPORT,\n position = Position.CENTER,\n disableDimmerClickToClose = false,\n ...otherProps\n}: ModalProps) => {\n const checkSpecialClasses = (classToCheck: string) =>\n className?.split(' ').includes(classToCheck);\n const { isMedium } = useLayout();\n\n // These should be replaced with props in breaking change.\n const isCompact = checkSpecialClasses('compact');\n const noDivider = checkSpecialClasses('no-divider');\n\n const contentReference = useRef<HTMLDivElement>(null);\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return !isMedium ? (\n <Drawer\n open={open}\n headerTitle={title}\n footerContent={footer}\n position={Position.BOTTOM}\n onClose={onClose}\n onUnmount={onUnmount}\n >\n {body}\n </Drawer>\n ) : (\n <Dimmer\n open={open}\n scrollable={scroll === Scroll.VIEWPORT}\n contentPosition={position}\n disableClickToClose={disableDimmerClickToClose}\n onClose={onClose}\n onExited={onUnmount}\n >\n <CSSTransition\n nodeRef={contentReference}\n appear\n in={open}\n classNames={{ enterDone: 'in' }}\n timeout={TRANSITION_DURATION_IN_MILLISECONDS}\n unmountOnExit\n >\n <div\n ref={contentReference}\n className={clsx(\n 'tw-modal',\n 'd-flex',\n 'fade',\n 'outline-none',\n scroll === Scroll.CONTENT && 'tw-modal--scrollable',\n className,\n )}\n {...otherProps}\n >\n <div\n id={overlayId}\n role=\"dialog\"\n aria-modal\n aria-labelledby={titleId}\n className={clsx('tw-modal-dialog', 'd-flex', {\n [`tw-modal-${size}`]: size,\n })}\n >\n <div\n className={clsx(\n 'tw-modal-content',\n 'd-flex',\n 'flex-column',\n 'justify-content-between',\n {\n 'tw-modal-compact': isCompact,\n 'tw-modal-no-title': !title,\n },\n )}\n >\n <div\n className={clsx(\n 'tw-modal-header',\n 'd-flex',\n 'align-items-center',\n 'justify-content-between',\n 'flex-wrap',\n {\n 'modal--withoutborder': !title || noDivider,\n },\n )}\n >\n <Title id={titleId} type={Typography.TITLE_BODY} className=\"tw-modal-title\">\n {title}\n </Title>\n <CloseButton onClick={onClose} />\n </div>\n <div\n className={clsx('tw-modal-body', {\n 'tw-modal-body--scrollable': scroll === Scroll.CONTENT,\n })}\n >\n {body}\n </div>\n {footer && (\n <div\n className={clsx('tw-modal-footer', 'd-flex', 'align-items-center', 'flex-wrap', {\n 'modal--withoutborder': noDivider,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n </div>\n </div>\n </CSSTransition>\n </Dimmer>\n );\n};\n\nexport default Modal;\n"],"names":["TRANSITION_DURATION_IN_MILLISECONDS","Modal","title","body","footer","onClose","onUnmount","className","open","size","Size","MEDIUM","scroll","Scroll","VIEWPORT","position","Position","CENTER","disableDimmerClickToClose","otherProps","checkSpecialClasses","classToCheck","split","includes","isMedium","useLayout","isCompact","noDivider","contentReference","useRef","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Drawer","headerTitle","footerContent","BOTTOM","children","Dimmer","scrollable","contentPosition","disableClickToClose","onExited","CSSTransition","nodeRef","appear","in","classNames","enterDone","timeout","unmountOnExit","ref","clsx","CONTENT","id","role","_jsxs","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAMA,mCAAmC,GAAG,GAAG,CAAA;AAezCC,MAAAA,KAAK,GAAGA,CAAC;AACbC,EAAAA,KAAK,GAAG,IAAI;EACZC,IAAI;AACJC,EAAAA,MAAM,GAAG,IAAI;EACbC,OAAO;EACPC,SAAS;EACTC,SAAS;EACTC,IAAI;QACJC,MAAI,GAAGC,SAAI,CAACC,MAAM;UAClBC,QAAM,GAAGC,aAAM,CAACC,QAAQ;YACxBC,UAAQ,GAAGC,iBAAQ,CAACC,MAAM;AAC1BC,EAAAA,yBAAyB,GAAG,KAAK;EACjC,GAAGC,UAAAA;AACQ,CAAA,KAAI;AACf,EAAA,MAAMC,mBAAmB,GAAIC,YAAoB,IAC/Cd,SAAS,EAAEe,KAAK,CAAC,GAAG,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,CAAA;EAC9C,MAAM;AAAEG,IAAAA,QAAAA;GAAU,GAAGC,mBAAS,EAAE,CAAA;AAEhC;AACA,EAAA,MAAMC,SAAS,GAAGN,mBAAmB,CAAC,SAAS,CAAC,CAAA;AAChD,EAAA,MAAMO,SAAS,GAAGP,mBAAmB,CAAC,YAAY,CAAC,CAAA;AAEnD,EAAA,MAAMQ,gBAAgB,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;AACrD,EAAA,MAAMC,OAAO,GAAGC,WAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,SAAS,GAAGC,gBAAU,CAACC,kCAAgB,CAAC,CAAA;AAE9C,EAAA,OAAO,CAACV,QAAQ,gBACdW,cAAA,CAACC,MAAM,EAAA;AACL5B,IAAAA,IAAI,EAAEA,IAAK;AACX6B,IAAAA,WAAW,EAAEnC,KAAM;AACnBoC,IAAAA,aAAa,EAAElC,MAAO;IACtBW,QAAQ,EAAEC,iBAAQ,CAACuB,MAAO;AAC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CAAE;AAAAa,cAAAA,QAAA,EAEFpC,MAAAA;AAAM,aACJ,CACN,CAAA;WACE,CAAA;SACF,CAAA;OACF,CAAA;KACQ,CAAA;AACjB,GAAQ,CACT,CAAA;AACH;;;;"}
|
package/build/modal/Modal.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.mjs","sources":["../../src/modal/Modal.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ReactNode, useContext, useId, useRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n Size,\n Position,\n PositionTop,\n PositionCenter,\n Scroll,\n CommonProps,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n SizeExtraLarge,\n ScrollContent,\n ScrollViewport,\n Typography,\n} from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport Drawer from '../drawer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport Title from '../title/Title';\n\nconst TRANSITION_DURATION_IN_MILLISECONDS = 150;\n\nexport type ModalProps = CommonProps & {\n title?: ReactNode;\n body: ReactNode;\n footer?: ReactNode;\n size?: SizeSmall | SizeMedium | SizeLarge | SizeExtraLarge;\n onClose: () => void;\n onUnmount?: () => void;\n open: boolean;\n scroll?: ScrollContent | ScrollViewport;\n position?: PositionTop | PositionCenter;\n disableDimmerClickToClose?: boolean;\n};\n\nconst Modal = ({\n title = null,\n body,\n footer = null,\n onClose,\n onUnmount,\n className,\n open,\n size = Size.MEDIUM,\n scroll = Scroll.VIEWPORT,\n position = Position.CENTER,\n disableDimmerClickToClose = false,\n ...otherProps\n}: ModalProps) => {\n const checkSpecialClasses = (classToCheck: string) =>\n className?.split(' ').includes(classToCheck);\n const { isMedium } = useLayout();\n\n // These should be replaced with props in breaking change.\n const isCompact = checkSpecialClasses('compact');\n const noDivider = checkSpecialClasses('no-divider');\n\n const contentReference = useRef<HTMLDivElement>(null);\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return !isMedium ? (\n <Drawer\n open={open}\n headerTitle={title}\n footerContent={footer}\n position={Position.BOTTOM}\n onClose={onClose}\n >\n {body}\n </Drawer>\n ) : (\n <Dimmer\n open={open}\n scrollable={scroll === Scroll.VIEWPORT}\n contentPosition={position}\n disableClickToClose={disableDimmerClickToClose}\n onClose={onClose}\n onExited={onUnmount}\n >\n <CSSTransition\n nodeRef={contentReference}\n appear\n in={open}\n classNames={{ enterDone: 'in' }}\n timeout={TRANSITION_DURATION_IN_MILLISECONDS}\n unmountOnExit\n >\n <div\n ref={contentReference}\n className={clsx(\n 'tw-modal',\n 'd-flex',\n 'fade',\n 'outline-none',\n scroll === Scroll.CONTENT && 'tw-modal--scrollable',\n className,\n )}\n {...otherProps}\n >\n <div\n id={overlayId}\n role=\"dialog\"\n aria-modal\n aria-labelledby={titleId}\n className={clsx('tw-modal-dialog', 'd-flex', {\n [`tw-modal-${size}`]: size,\n })}\n >\n <div\n className={clsx(\n 'tw-modal-content',\n 'd-flex',\n 'flex-column',\n 'justify-content-between',\n {\n 'tw-modal-compact': isCompact,\n 'tw-modal-no-title': !title,\n },\n )}\n >\n <div\n className={clsx(\n 'tw-modal-header',\n 'd-flex',\n 'align-items-center',\n 'justify-content-between',\n 'flex-wrap',\n {\n 'modal--withoutborder': !title || noDivider,\n },\n )}\n >\n <Title id={titleId} type={Typography.TITLE_BODY} className=\"tw-modal-title\">\n {title}\n </Title>\n <CloseButton onClick={onClose} />\n </div>\n <div\n className={clsx('tw-modal-body', {\n 'tw-modal-body--scrollable': scroll === Scroll.CONTENT,\n })}\n >\n {body}\n </div>\n {footer && (\n <div\n className={clsx('tw-modal-footer', 'd-flex', 'align-items-center', 'flex-wrap', {\n 'modal--withoutborder': noDivider,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n </div>\n </div>\n </CSSTransition>\n </Dimmer>\n );\n};\n\nexport default Modal;\n"],"names":["TRANSITION_DURATION_IN_MILLISECONDS","Modal","title","body","footer","onClose","onUnmount","className","open","size","Size","MEDIUM","scroll","Scroll","VIEWPORT","position","Position","CENTER","disableDimmerClickToClose","otherProps","checkSpecialClasses","classToCheck","split","includes","isMedium","useLayout","isCompact","noDivider","contentReference","useRef","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Drawer","headerTitle","footerContent","BOTTOM","children","Dimmer","scrollable","contentPosition","disableClickToClose","onExited","CSSTransition","nodeRef","appear","in","classNames","enterDone","timeout","unmountOnExit","ref","clsx","CONTENT","id","role","_jsxs","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAMA,mCAAmC,GAAG,GAAG,CAAA;AAezCC,MAAAA,KAAK,GAAGA,CAAC;AACbC,EAAAA,KAAK,GAAG,IAAI;EACZC,IAAI;AACJC,EAAAA,MAAM,GAAG,IAAI;EACbC,OAAO;EACPC,SAAS;EACTC,SAAS;EACTC,IAAI;EACJC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,MAAM,GAAGC,MAAM,CAACC,QAAQ;EACxBC,QAAQ,GAAGC,QAAQ,CAACC,MAAM;AAC1BC,EAAAA,yBAAyB,GAAG,KAAK;EACjC,GAAGC,UAAAA;AACQ,CAAA,KAAI;AACf,EAAA,MAAMC,mBAAmB,GAAIC,YAAoB,IAC/Cd,SAAS,EAAEe,KAAK,CAAC,GAAG,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,CAAA;EAC9C,MAAM;AAAEG,IAAAA,QAAAA;GAAU,GAAGC,SAAS,EAAE,CAAA;AAEhC;AACA,EAAA,MAAMC,SAAS,GAAGN,mBAAmB,CAAC,SAAS,CAAC,CAAA;AAChD,EAAA,MAAMO,SAAS,GAAGP,mBAAmB,CAAC,YAAY,CAAC,CAAA;AAEnD,EAAA,MAAMQ,gBAAgB,GAAGC,MAAM,CAAiB,IAAI,CAAC,CAAA;AACrD,EAAA,MAAMC,OAAO,GAAGC,KAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,SAAS,GAAGC,UAAU,CAACC,gBAAgB,CAAC,CAAA;AAE9C,EAAA,OAAO,CAACV,QAAQ,gBACdW,GAAA,CAACC,MAAM,EAAA;AACL5B,IAAAA,IAAI,EAAEA,IAAK;AACX6B,IAAAA,WAAW,EAAEnC,KAAM;AACnBoC,IAAAA,aAAa,EAAElC,MAAO;IACtBW,QAAQ,EAAEC,QAAQ,CAACuB,MAAO;AAC1BlC,IAAAA,OAAO,EAAEA,OAAQ;
|
|
1
|
+
{"version":3,"file":"Modal.mjs","sources":["../../src/modal/Modal.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ReactNode, useContext, useId, useRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n Size,\n Position,\n PositionTop,\n PositionCenter,\n Scroll,\n CommonProps,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n SizeExtraLarge,\n ScrollContent,\n ScrollViewport,\n Typography,\n} from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport { useLayout } from '../common/hooks';\nimport Dimmer from '../dimmer';\nimport Drawer from '../drawer';\nimport { OverlayIdContext } from '../provider/overlay/OverlayIdProvider';\nimport Title from '../title/Title';\n\nconst TRANSITION_DURATION_IN_MILLISECONDS = 150;\n\nexport type ModalProps = CommonProps & {\n title?: ReactNode;\n body: ReactNode;\n footer?: ReactNode;\n size?: SizeSmall | SizeMedium | SizeLarge | SizeExtraLarge;\n onClose: () => void;\n onUnmount?: () => void;\n open: boolean;\n scroll?: ScrollContent | ScrollViewport;\n position?: PositionTop | PositionCenter;\n disableDimmerClickToClose?: boolean;\n};\n\nconst Modal = ({\n title = null,\n body,\n footer = null,\n onClose,\n onUnmount,\n className,\n open,\n size = Size.MEDIUM,\n scroll = Scroll.VIEWPORT,\n position = Position.CENTER,\n disableDimmerClickToClose = false,\n ...otherProps\n}: ModalProps) => {\n const checkSpecialClasses = (classToCheck: string) =>\n className?.split(' ').includes(classToCheck);\n const { isMedium } = useLayout();\n\n // These should be replaced with props in breaking change.\n const isCompact = checkSpecialClasses('compact');\n const noDivider = checkSpecialClasses('no-divider');\n\n const contentReference = useRef<HTMLDivElement>(null);\n const titleId = useId();\n\n const overlayId = useContext(OverlayIdContext);\n\n return !isMedium ? (\n <Drawer\n open={open}\n headerTitle={title}\n footerContent={footer}\n position={Position.BOTTOM}\n onClose={onClose}\n onUnmount={onUnmount}\n >\n {body}\n </Drawer>\n ) : (\n <Dimmer\n open={open}\n scrollable={scroll === Scroll.VIEWPORT}\n contentPosition={position}\n disableClickToClose={disableDimmerClickToClose}\n onClose={onClose}\n onExited={onUnmount}\n >\n <CSSTransition\n nodeRef={contentReference}\n appear\n in={open}\n classNames={{ enterDone: 'in' }}\n timeout={TRANSITION_DURATION_IN_MILLISECONDS}\n unmountOnExit\n >\n <div\n ref={contentReference}\n className={clsx(\n 'tw-modal',\n 'd-flex',\n 'fade',\n 'outline-none',\n scroll === Scroll.CONTENT && 'tw-modal--scrollable',\n className,\n )}\n {...otherProps}\n >\n <div\n id={overlayId}\n role=\"dialog\"\n aria-modal\n aria-labelledby={titleId}\n className={clsx('tw-modal-dialog', 'd-flex', {\n [`tw-modal-${size}`]: size,\n })}\n >\n <div\n className={clsx(\n 'tw-modal-content',\n 'd-flex',\n 'flex-column',\n 'justify-content-between',\n {\n 'tw-modal-compact': isCompact,\n 'tw-modal-no-title': !title,\n },\n )}\n >\n <div\n className={clsx(\n 'tw-modal-header',\n 'd-flex',\n 'align-items-center',\n 'justify-content-between',\n 'flex-wrap',\n {\n 'modal--withoutborder': !title || noDivider,\n },\n )}\n >\n <Title id={titleId} type={Typography.TITLE_BODY} className=\"tw-modal-title\">\n {title}\n </Title>\n <CloseButton onClick={onClose} />\n </div>\n <div\n className={clsx('tw-modal-body', {\n 'tw-modal-body--scrollable': scroll === Scroll.CONTENT,\n })}\n >\n {body}\n </div>\n {footer && (\n <div\n className={clsx('tw-modal-footer', 'd-flex', 'align-items-center', 'flex-wrap', {\n 'modal--withoutborder': noDivider,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n </div>\n </div>\n </CSSTransition>\n </Dimmer>\n );\n};\n\nexport default Modal;\n"],"names":["TRANSITION_DURATION_IN_MILLISECONDS","Modal","title","body","footer","onClose","onUnmount","className","open","size","Size","MEDIUM","scroll","Scroll","VIEWPORT","position","Position","CENTER","disableDimmerClickToClose","otherProps","checkSpecialClasses","classToCheck","split","includes","isMedium","useLayout","isCompact","noDivider","contentReference","useRef","titleId","useId","overlayId","useContext","OverlayIdContext","_jsx","Drawer","headerTitle","footerContent","BOTTOM","children","Dimmer","scrollable","contentPosition","disableClickToClose","onExited","CSSTransition","nodeRef","appear","in","classNames","enterDone","timeout","unmountOnExit","ref","clsx","CONTENT","id","role","_jsxs","Title","type","Typography","TITLE_BODY","CloseButton","onClick"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAMA,mCAAmC,GAAG,GAAG,CAAA;AAezCC,MAAAA,KAAK,GAAGA,CAAC;AACbC,EAAAA,KAAK,GAAG,IAAI;EACZC,IAAI;AACJC,EAAAA,MAAM,GAAG,IAAI;EACbC,OAAO;EACPC,SAAS;EACTC,SAAS;EACTC,IAAI;EACJC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,MAAM,GAAGC,MAAM,CAACC,QAAQ;EACxBC,QAAQ,GAAGC,QAAQ,CAACC,MAAM;AAC1BC,EAAAA,yBAAyB,GAAG,KAAK;EACjC,GAAGC,UAAAA;AACQ,CAAA,KAAI;AACf,EAAA,MAAMC,mBAAmB,GAAIC,YAAoB,IAC/Cd,SAAS,EAAEe,KAAK,CAAC,GAAG,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,CAAA;EAC9C,MAAM;AAAEG,IAAAA,QAAAA;GAAU,GAAGC,SAAS,EAAE,CAAA;AAEhC;AACA,EAAA,MAAMC,SAAS,GAAGN,mBAAmB,CAAC,SAAS,CAAC,CAAA;AAChD,EAAA,MAAMO,SAAS,GAAGP,mBAAmB,CAAC,YAAY,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,eAAA8B,GAAA,CAAA,KAAA,EAAA;AACE5B,cAAAA,SAAS,EAAEgD,IAAI,CAAC,eAAe,EAAE;AAC/B,gBAAA,2BAA2B,EAAE3C,MAAM,KAAKC,MAAM,CAAC2C,OAAAA;AAChD,eAAA,CAAE;AAAAhB,cAAAA,QAAA,EAEFrC,IAAAA;AAAI,aACF,CACL,EAACC,MAAM,iBACL+B,GAAA,CAAA,KAAA,EAAA;cACE5B,SAAS,EAAEgD,IAAI,CAAC,iBAAiB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,WAAW,EAAE;AAC9E,gBAAA,sBAAsB,EAAE5B,SAAAA;AACzB,eAAA,CAAE;AAAAa,cAAAA,QAAA,EAEFpC,MAAAA;AAAM,aACJ,CACN,CAAA;WACE,CAAA;SACF,CAAA;OACF,CAAA;KACQ,CAAA;AACjB,GAAQ,CACT,CAAA;AACH;;;;"}
|
|
@@ -14,6 +14,7 @@ export type DrawerProps = {
|
|
|
14
14
|
position?: `${Position.LEFT | Position.RIGHT | Position.BOTTOM}`;
|
|
15
15
|
/** The action to perform on close click. */
|
|
16
16
|
onClose?: (event: KeyboardEvent | React.MouseEvent) => void;
|
|
17
|
+
onUnmount?: () => void;
|
|
17
18
|
} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>;
|
|
18
|
-
export default function Drawer({ children, className, footerContent, headerTitle, onClose, open, position, role, 'aria-labelledby': ariaLabelledBy, }: DrawerProps): import("react").JSX.Element;
|
|
19
|
+
export default function Drawer({ children, className, footerContent, headerTitle, onClose, onUnmount, open, position, role, 'aria-labelledby': ariaLabelledBy, }: DrawerProps): import("react").JSX.Element;
|
|
19
20
|
//# sourceMappingURL=Drawer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/drawer/Drawer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAqB,MAAM,OAAO,CAAC;AAE1D,OAA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"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAG7D,OAAO,EAGL,WAAW,EACX,cAAc,EAEd,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EAEf,MAAM,WAAW,CAAC;AAUnB,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC;IACxC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF,QAAA,MAAM,KAAK,mIAaR,UAAU,gCAkHZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-faee41b",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
94
|
"@transferwise/less-config": "3.1.0",
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
95
|
+
"@transferwise/neptune-css": "14.19.1",
|
|
96
|
+
"@wise/components-theming": "1.6.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
@@ -15,6 +15,7 @@ describe('Dimmer', () => {
|
|
|
15
15
|
children: <div />,
|
|
16
16
|
className: undefined,
|
|
17
17
|
onClose: undefined,
|
|
18
|
+
onExited: jest.fn(),
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
beforeEach(() => {
|
|
@@ -76,4 +77,11 @@ describe('Dimmer', () => {
|
|
|
76
77
|
exit: 'dimmer--exit dimmer--exit-fade',
|
|
77
78
|
});
|
|
78
79
|
});
|
|
80
|
+
|
|
81
|
+
it('calls onExited when the exit animation is finished', () => {
|
|
82
|
+
component.setProps({ fadeContentOnExit: true });
|
|
83
|
+
const transition = component.find('CSSTransition');
|
|
84
|
+
transition.prop('onExited')();
|
|
85
|
+
expect(props.onExited).toHaveBeenCalled();
|
|
86
|
+
});
|
|
79
87
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mount } from 'enzyme';
|
|
2
2
|
|
|
3
3
|
import { mockMatchMedia } from '../test-utils';
|
|
4
4
|
import Title from '../title/Title';
|
|
@@ -12,7 +12,7 @@ jest.useFakeTimers();
|
|
|
12
12
|
jest.mock(
|
|
13
13
|
'../dimmer',
|
|
14
14
|
() =>
|
|
15
|
-
function ({ open, children }) {
|
|
15
|
+
function Dimmer({ open, children }) {
|
|
16
16
|
return open ? <div className="dimmer">{children}</div> : null;
|
|
17
17
|
},
|
|
18
18
|
);
|
|
@@ -20,7 +20,7 @@ jest.mock(
|
|
|
20
20
|
jest.mock(
|
|
21
21
|
'../slidingPanel',
|
|
22
22
|
() =>
|
|
23
|
-
function ({ open, children }) {
|
|
23
|
+
function SlidingPanel({ open, children }) {
|
|
24
24
|
return open ? <div className="sliding-panel">{children}</div> : null;
|
|
25
25
|
},
|
|
26
26
|
);
|
|
@@ -29,10 +29,10 @@ const defaultLocale = 'en-GB';
|
|
|
29
29
|
|
|
30
30
|
jest.mock('react-intl', () => ({
|
|
31
31
|
injectIntl: (Component) =>
|
|
32
|
-
function (props) {
|
|
32
|
+
function InjectedComponent(props) {
|
|
33
33
|
return <Component {...props} intl={{ locale: defaultLocale }} />;
|
|
34
34
|
},
|
|
35
|
-
useIntl: () => ({ locale: defaultLocale, formatMessage: (id) =>
|
|
35
|
+
useIntl: () => ({ locale: defaultLocale, formatMessage: (id) => String(id) }),
|
|
36
36
|
defineMessages: (translations) => translations,
|
|
37
37
|
}));
|
|
38
38
|
|
|
@@ -48,11 +48,12 @@ describe('Drawer', () => {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
beforeEach(() => {
|
|
51
|
-
component =
|
|
51
|
+
component = mount(<Drawer {...props} />);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
afterEach(() => {
|
|
55
55
|
jest.clearAllMocks();
|
|
56
|
+
component.unmount();
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
it('renders drawer header if title is provided', () => {
|
|
@@ -79,4 +80,22 @@ describe('Drawer', () => {
|
|
|
79
80
|
component.setProps({ footerContent: 'SomeContent' });
|
|
80
81
|
expect(component.find('.np-drawer-footer')).toHaveLength(1);
|
|
81
82
|
});
|
|
83
|
+
|
|
84
|
+
it('passes onUnmount to Dimmer onExited prop', () => {
|
|
85
|
+
const onUnmount = jest.fn();
|
|
86
|
+
component.setProps({ onUnmount });
|
|
87
|
+
component.setProps({ open: true });
|
|
88
|
+
expect(component.find('Dimmer').prop('onExited')).toBe(onUnmount);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('calls onUnmount when the component unmounts', () => {
|
|
92
|
+
const onUnmount = jest.fn();
|
|
93
|
+
component.setProps({ onUnmount });
|
|
94
|
+
component.setProps({ open: true });
|
|
95
|
+
expect(onUnmount).not.toHaveBeenCalled();
|
|
96
|
+
jest.runAllTimers();
|
|
97
|
+
component.setProps({ open: false });
|
|
98
|
+
component.find('Dimmer').prop('onExited')();
|
|
99
|
+
expect(onUnmount).toHaveBeenCalledTimes(1);
|
|
100
|
+
});
|
|
82
101
|
});
|
package/src/drawer/Drawer.tsx
CHANGED
|
@@ -24,6 +24,7 @@ export type DrawerProps = {
|
|
|
24
24
|
position?: `${Position.LEFT | Position.RIGHT | Position.BOTTOM}`;
|
|
25
25
|
/** The action to perform on close click. */
|
|
26
26
|
onClose?: (event: KeyboardEvent | React.MouseEvent) => void;
|
|
27
|
+
onUnmount?: () => void;
|
|
27
28
|
} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>;
|
|
28
29
|
|
|
29
30
|
export default function Drawer({
|
|
@@ -32,6 +33,7 @@ export default function Drawer({
|
|
|
32
33
|
footerContent,
|
|
33
34
|
headerTitle,
|
|
34
35
|
onClose,
|
|
36
|
+
onUnmount,
|
|
35
37
|
open = false,
|
|
36
38
|
position = 'right',
|
|
37
39
|
role = 'dialog',
|
|
@@ -48,7 +50,7 @@ export default function Drawer({
|
|
|
48
50
|
const overlayId = useContext(OverlayIdContext);
|
|
49
51
|
|
|
50
52
|
return (
|
|
51
|
-
<Dimmer open={open} onClose={onClose}>
|
|
53
|
+
<Dimmer open={open} onClose={onClose} onExited={onUnmount}>
|
|
52
54
|
<SlidingPanel open={open} position={isMobile ? Position.BOTTOM : position}>
|
|
53
55
|
<div
|
|
54
56
|
id={overlayId}
|
package/src/modal/Modal.spec.js
CHANGED
|
@@ -16,7 +16,7 @@ jest.mock('react-intl', () => ({
|
|
|
16
16
|
function (props) {
|
|
17
17
|
return <Component {...props} intl={{ locale: defaultLocale }} />;
|
|
18
18
|
},
|
|
19
|
-
useIntl: () => ({ locale: defaultLocale, formatMessage: (id) =>
|
|
19
|
+
useIntl: () => ({ locale: defaultLocale, formatMessage: (id) => String(id) }),
|
|
20
20
|
defineMessages: (translations) => translations,
|
|
21
21
|
}));
|
|
22
22
|
|
|
@@ -161,6 +161,24 @@ describe('Modal', () => {
|
|
|
161
161
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
+
it('passes onUnmount to Dimmer onExited prop', () => {
|
|
165
|
+
const onUnmount = jest.fn();
|
|
166
|
+
component.setProps({ onUnmount });
|
|
167
|
+
component.setProps({ open: true });
|
|
168
|
+
expect(component.find('Dimmer').prop('onExited')).toBe(onUnmount);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('calls onUnmount when the component unmounts', () => {
|
|
172
|
+
const onUnmount = jest.fn();
|
|
173
|
+
component.setProps({ onUnmount });
|
|
174
|
+
component.setProps({ open: true });
|
|
175
|
+
expect(onUnmount).not.toHaveBeenCalled();
|
|
176
|
+
jest.runAllTimers();
|
|
177
|
+
component.setProps({ open: false });
|
|
178
|
+
component.find('Dimmer').prop('onExited')();
|
|
179
|
+
expect(onUnmount).toHaveBeenCalledTimes(1);
|
|
180
|
+
});
|
|
181
|
+
|
|
164
182
|
const clickCloseButton = () => {
|
|
165
183
|
component.find('.close').simulate('click');
|
|
166
184
|
};
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -270,9 +270,7 @@ export const DeletingTop: Story = {
|
|
|
270
270
|
play: async ({ canvasElement }) => {
|
|
271
271
|
await userEvent.tab();
|
|
272
272
|
await triggerModalAndConfirm();
|
|
273
|
-
await wait(250);
|
|
274
273
|
await triggerModalAndConfirm({ isLink: false });
|
|
275
|
-
await wait(250);
|
|
276
274
|
await userEvent.tab();
|
|
277
275
|
await triggerModalAndConfirm();
|
|
278
276
|
},
|