@transferwise/components 46.73.0 → 46.74.1

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.
Files changed (71) hide show
  1. package/build/common/bottomSheet/BottomSheet.js +3 -1
  2. package/build/common/bottomSheet/BottomSheet.js.map +1 -1
  3. package/build/common/bottomSheet/BottomSheet.mjs +3 -1
  4. package/build/common/bottomSheet/BottomSheet.mjs.map +1 -1
  5. package/build/common/responsivePanel/ResponsivePanel.js +7 -1
  6. package/build/common/responsivePanel/ResponsivePanel.js.map +1 -1
  7. package/build/common/responsivePanel/ResponsivePanel.mjs +7 -1
  8. package/build/common/responsivePanel/ResponsivePanel.mjs.map +1 -1
  9. package/build/dimmer/Dimmer.js +3 -1
  10. package/build/dimmer/Dimmer.js.map +1 -1
  11. package/build/dimmer/Dimmer.mjs +3 -1
  12. package/build/dimmer/Dimmer.mjs.map +1 -1
  13. package/build/drawer/Drawer.js +2 -0
  14. package/build/drawer/Drawer.js.map +1 -1
  15. package/build/drawer/Drawer.mjs +2 -0
  16. package/build/drawer/Drawer.mjs.map +1 -1
  17. package/build/modal/Modal.js +3 -0
  18. package/build/modal/Modal.js.map +1 -1
  19. package/build/modal/Modal.mjs +3 -0
  20. package/build/modal/Modal.mjs.map +1 -1
  21. package/build/popover/Popover.js +6 -1
  22. package/build/popover/Popover.js.map +1 -1
  23. package/build/popover/Popover.mjs +7 -2
  24. package/build/popover/Popover.mjs.map +1 -1
  25. package/build/types/common/bottomSheet/BottomSheet.d.ts +1 -1
  26. package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
  27. package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
  28. package/build/types/dimmer/Dimmer.d.ts +2 -1
  29. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  30. package/build/types/drawer/Drawer.d.ts +2 -1
  31. package/build/types/drawer/Drawer.d.ts.map +1 -1
  32. package/build/types/modal/Modal.d.ts +2 -1
  33. package/build/types/modal/Modal.d.ts.map +1 -1
  34. package/build/types/popover/Popover.d.ts +6 -4
  35. package/build/types/popover/Popover.d.ts.map +1 -1
  36. package/build/types/uploadInput/UploadInput.d.ts +9 -0
  37. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  38. package/build/types/uploadInput/uploadItem/UploadItem.d.ts +16 -1
  39. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  40. package/build/types/uploadInput/uploadItem/UploadItemLink.d.ts.map +1 -1
  41. package/build/uploadInput/UploadInput.js +71 -66
  42. package/build/uploadInput/UploadInput.js.map +1 -1
  43. package/build/uploadInput/UploadInput.mjs +72 -67
  44. package/build/uploadInput/UploadInput.mjs.map +1 -1
  45. package/build/uploadInput/uploadItem/UploadItem.js +13 -4
  46. package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
  47. package/build/uploadInput/uploadItem/UploadItem.mjs +13 -4
  48. package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
  49. package/build/uploadInput/uploadItem/UploadItemLink.js +1 -0
  50. package/build/uploadInput/uploadItem/UploadItemLink.js.map +1 -1
  51. package/build/uploadInput/uploadItem/UploadItemLink.mjs +1 -0
  52. package/build/uploadInput/uploadItem/UploadItemLink.mjs.map +1 -1
  53. package/package.json +3 -3
  54. package/src/common/bottomSheet/BottomSheet.tsx +4 -2
  55. package/src/common/responsivePanel/ResponsivePanel.tsx +13 -3
  56. package/src/dimmer/Dimmer.spec.js +8 -0
  57. package/src/dimmer/Dimmer.tsx +4 -0
  58. package/src/drawer/Drawer.spec.js +25 -6
  59. package/src/drawer/Drawer.tsx +3 -1
  60. package/src/modal/Modal.spec.js +19 -1
  61. package/src/modal/Modal.tsx +4 -0
  62. package/src/popover/Popover.spec.tsx +64 -21
  63. package/src/popover/Popover.story.tsx +54 -42
  64. package/src/popover/Popover.tsx +12 -5
  65. package/src/popover/__snapshots__/Popover.spec.tsx.snap +2 -0
  66. package/src/uploadInput/UploadInput.spec.tsx +121 -9
  67. package/src/uploadInput/UploadInput.tests.story.tsx +207 -140
  68. package/src/uploadInput/UploadInput.tsx +110 -77
  69. package/src/uploadInput/uploadItem/UploadItem.spec.tsx +1 -0
  70. package/src/uploadInput/uploadItem/UploadItem.tsx +30 -6
  71. package/src/uploadInput/uploadItem/UploadItemLink.tsx +9 -1
@@ -148,6 +148,7 @@ const BottomSheet = ({
148
148
  const overlayId = React.useContext(OverlayIdProvider.OverlayIdContext);
149
149
  return is400Zoom ? /*#__PURE__*/jsxRuntime.jsx(Drawer, {
150
150
  "aria-labelledby": props['aria-labelledby'],
151
+ "aria-label": props['aria-label'],
151
152
  role: role,
152
153
  open: props.open,
153
154
  className: props.className,
@@ -165,7 +166,8 @@ const BottomSheet = ({
165
166
  className: clsx.clsx('np-bottom-sheet', props.className),
166
167
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
167
168
  id: overlayId,
168
- "aria-labelledby": props['aria-labelledby'],
169
+ "aria-labelledby": props['aria-labelledby'] || undefined,
170
+ "aria-label": props['aria-label'] || undefined,
169
171
  role: role,
170
172
  "aria-modal": true,
171
173
  onTouchStart: onSwipeStart,
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheet.js","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby']}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAUhC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAGA,CAAC;AAAEC,EAAAA,IAAI,GAAG,QAAQ;EAAE,GAAGC,KAAAA;AAAyB,CAAA,KAAI;AACtE,EAAA,MAAMC,oBAAoB,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;AACzD,EAAA,MAAMC,eAAe,GAAGD,YAAM,CAAiB,IAAI,CAAC,CAAA;AACpD,EAAA,MAAME,gBAAgB,GAAGF,YAAM,CAAiB,IAAI,CAAC,CAAA;EAErD,MAAM,CAACG,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAQ,CAAU,KAAK,CAAC,CAAA;AAEtD;;;;AAIG;AACH,EAAA,MAAMC,WAAW,GAAGN,YAAM,CAAS,CAAC,CAAC,CAAA;AAErC;;;;;AAKG;AACH,EAAA,MAAMO,UAAU,GAAGP,YAAM,CAAS,CAAC,CAAC,CAAA;AACpC,EAAA,MAAMQ,kBAAkB,GAAGR,YAAM,CAAS,CAAC,CAAC,CAAA;AAE5C;AACAS,EAAAA,6CAAsB,CAAC;IACrBC,cAAc,EAAEZ,KAAK,CAACa,IAAI,IAAI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A;AACEQ,UAAAA,GAAG,EAAE/D,gBAAiB;UACtBuB,KAAK,EAAEiB,mBAAmB,EAAG;AAC7BiB,UAAAA,SAAS,EAAC,0BAA0B;UAAAC,QAAA,EAEnC9D,KAAK,CAAC8D,QAAAA;AAAQ,SACZ,CACP,CAAA;OAAK,CAAA;KACO,CAAA;AAChB,GAAQ,CACT,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"BottomSheet.js","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby' | 'aria-label'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n aria-label={props['aria-label']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby'] || undefined}\n aria-label={props['aria-label'] || undefined}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;;;A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  const overlayId = useContext(OverlayIdContext);
147
147
  return is400Zoom ? /*#__PURE__*/jsx(Drawer, {
148
148
  "aria-labelledby": props['aria-labelledby'],
149
+ "aria-label": props['aria-label'],
149
150
  role: role,
150
151
  open: props.open,
151
152
  className: props.className,
@@ -163,7 +164,8 @@ const BottomSheet = ({
163
164
  className: clsx('np-bottom-sheet', props.className),
164
165
  children: /*#__PURE__*/jsxs("div", {
165
166
  id: overlayId,
166
- "aria-labelledby": props['aria-labelledby'],
167
+ "aria-labelledby": props['aria-labelledby'] || undefined,
168
+ "aria-label": props['aria-label'] || undefined,
167
169
  role: role,
168
170
  "aria-modal": true,
169
171
  onTouchStart: onSwipeStart,
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheet.mjs","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby']}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAUhC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAGA,CAAC;AAAEC,EAAAA,IAAI,GAAG,QAAQ;EAAE,GAAGC,KAAAA;AAAyB,CAAA,KAAI;AACtE,EAAA,MAAMC,oBAAoB,GAAGC,MAAM,CAAiB,IAAI,CAAC,CAAA;AACzD,EAAA,MAAMC,eAAe,GAAGD,MAAM,CAAiB,IAAI,CAAC,CAAA;AACpD,EAAA,MAAME,gBAAgB,GAAGF,MAAM,CAAiB,IAAI,CAAC,CAAA;EAErD,MAAM,CAACG,OAAO,EAAEC,UAAU,CAAC,GAAGC,QAAQ,CAAU,KAAK,CAAC,CAAA;AAEtD;;;;AAIG;AACH,EAAA,MAAMC,WAAW,GAAGN,MAAM,CAAS,CAAC,CAAC,CAAA;AAErC;;;;;AAKG;AACH,EAAA,MAAMO,UAAU,GAAGP,MAAM,CAAS,CAAC,CAAC,CAAA;AACpC,EAAA,MAAMQ,kBAAkB,GAAGR,MAAM,CAAS,CAAC,CAAC,CAAA;AAE5C;AACAS,EAAAA,sBAAsB,CAAC;IACrBC,cAAc,EAAEZ,KAAK,CAACa,IAAI,IAAI,CAACC,YAAY,EAAE;IAC7CC,QAAQ,EAAEA,MAAK;AACb,MAAA,IAAIZ,eAAe,CAACa,OAAO,KAAK,IAAI,EAAE;QACpC,MAAM;AAAEC,UAAAA,SAAAA;SAAW,GAAGd,eAAe,CAACa,OAAO,CAAA;AAC7C,QAAA,IAAI,CAACE,4BAA4B,EAAE,EAAE;AACnCD,UAAAA,SAAS,CAACE,GAAG,CAAC,kCAAkC,CAAC,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/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby' | 'aria-label'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n aria-label={props['aria-label']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby'] || undefined}\n aria-label={props['aria-label'] || undefined}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAUhC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAGA,CAAC;AAAEC,EAAAA,IAAI,GAAG,QAAQ;EAAE,GAAGC,KAAAA;AAAyB,CAAA,KAAI;AACtE,EAAA,MAAMC,oBAAoB,GAAGC,MAAM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,IAAA;AACV2E,QAAAA,YAAY,EAAEzC,YAAa;AAC3B0C,QAAAA,WAAW,EAAEvC,WAAY;AACzBwC,QAAAA,UAAU,EAAEpC,UAAW;AACvBqC,QAAAA,WAAW,EAAE5C,YAAa;AAC1B6C,QAAAA,WAAW,EAAE1C,WAAY;AACzB2C,QAAAA,SAAS,EAAEvC,UAAW;AAAAsB,QAAAA,QAAA,gBAEtBU,IAAA,CAAA,KAAA,EAAA;AAAKL,UAAAA,GAAG,EAAEhE,eAAgB;AAAC0D,UAAAA,SAAS,EAAC,0BAA0B;AAAAC,UAAAA,QAAA,gBAC7DH,GAAA,CAAA,KAAA,EAAA;AAAKE,YAAAA,SAAS,EAAC,0BAAA;AAA0B,WACzC,CAAA,eAAAF,GAAA,CAACqB,WAAW,EAAA;AAACC,YAAAA,IAAI,EAAC,IAAI;AAACpB,YAAAA,SAAS,EAAC,oCAAoC;AAACqB,YAAAA,OAAO,EAAErD,KAAAA;AAAM,WACvF,CAAA,CAAA;SAAK,CACL,eAAA8B,GAAA,CAAA,KAAA,EAAA;AACEQ,UAAAA,GAAG,EAAE/D,gBAAiB;UACtBuB,KAAK,EAAEiB,mBAAmB,EAAG;AAC7BiB,UAAAA,SAAS,EAAC,0BAA0B;UAAAC,QAAA,EAEnC9D,KAAK,CAAC8D,QAAAA;AAAQ,SACZ,CACP,CAAA;OAAK,CAAA;KACO,CAAA;AAChB,GAAQ,CACT,CAAA;AACH;;;;"}
@@ -16,13 +16,17 @@ const ResponsivePanel = /*#__PURE__*/React.forwardRef(function ResponsivePanel({
16
16
  onClose,
17
17
  open = false,
18
18
  position: position$1 = position.Position.BOTTOM,
19
- anchorWidth = false
19
+ anchorWidth = false,
20
+ 'aria-label': ariaLabel,
21
+ 'aria-labelledby': ariaLabelledBy
20
22
  }, reference) {
21
23
  const {
22
24
  isMobile
23
25
  } = useLayout.useLayout();
24
26
  if (isMobile) {
25
27
  return /*#__PURE__*/jsxRuntime.jsx(BottomSheet, {
28
+ "aria-label": ariaLabel,
29
+ "aria-labelledby": ariaLabelledBy,
26
30
  open: open,
27
31
  className: className,
28
32
  onClose: onClose,
@@ -37,6 +41,8 @@ const ResponsivePanel = /*#__PURE__*/React.forwardRef(function ResponsivePanel({
37
41
  position: position$1,
38
42
  anchorWidth: anchorWidth,
39
43
  anchorRef: anchorRef,
44
+ "aria-label": ariaLabel,
45
+ "aria-labelledby": ariaLabelledBy,
40
46
  className: className,
41
47
  onClose: onClose,
42
48
  children: children
@@ -1 +1 @@
1
- {"version":3,"file":"ResponsivePanel.js","sources":["../../../src/common/responsivePanel/ResponsivePanel.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport { Position } from '..';\nimport BottomSheet from '../bottomSheet';\nimport { useLayout } from '../hooks';\nimport Panel from '../panel';\nimport { PanelProps } from '../panel/Panel';\n\nconst ResponsivePanel = forwardRef<HTMLDivElement, PanelProps>(function ResponsivePanel(\n {\n anchorRef,\n arrow = false,\n flip = true,\n children,\n className = undefined,\n onClose,\n open = false,\n position = Position.BOTTOM,\n anchorWidth = false,\n }: PanelProps,\n reference,\n) {\n const { isMobile } = useLayout();\n if (isMobile) {\n return (\n <BottomSheet key=\"bottomSheet\" open={open} className={className} onClose={onClose}>\n {children}\n </BottomSheet>\n );\n }\n return (\n <Panel\n key=\"panel\"\n ref={reference}\n flip={flip}\n arrow={arrow}\n open={open}\n position={position}\n anchorWidth={anchorWidth}\n anchorRef={anchorRef}\n className={className}\n onClose={onClose}\n >\n {children}\n </Panel>\n );\n});\n\nexport default ResponsivePanel;\n"],"names":["ResponsivePanel","forwardRef","anchorRef","arrow","flip","children","className","undefined","onClose","open","position","Position","BOTTOM","anchorWidth","reference","isMobile","useLayout","_jsx","BottomSheet","Panel","ref"],"mappings":";;;;;;;;;AAQA,MAAMA,eAAe,gBAAGC,gBAAU,CAA6B,SAASD,eAAeA,CACrF;EACEE,SAAS;AACTC,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;EACXC,QAAQ;AACRC,EAAAA,SAAS,GAAGC,SAAS;EACrBC,OAAO;AACPC,EAAAA,IAAI,GAAG,KAAK;YACZC,UAAQ,GAAGC,iBAAQ,CAACC,MAAM;AAC1BC,EAAAA,WAAW,GAAG,KAAA;AAAK,CACR,EACbC,SAAS,EAAA;EAET,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,mBAAS,EAAE,CAAA;AAChC,EAAA,IAAID,QAAQ,EAAE;IACZ,oBACEE,cAAA,CAACC,WAAW,EAAA;AAAmBT,MAAAA,IAAI,EAAEA,IAAK;AAACH,MAAAA,SAAS,EAAEA,SAAU;AAACE,MAAAA,OAAO,EAAEA,OAAQ;AAAAH,MAAAA,QAAA,EAC/EA,QAAAA;AAAQ,KAAA,EADM,aAEJ,CAAC,CAAA;AAElB,GAAA;EACA,oBACEY,cAAA,CAACE,KAAK,EAAA;AAEJC,IAAAA,GAAG,EAAEN,SAAU;AACfV,IAAAA,IAAI,EAAEA,IAAK;AACXD,IAAAA,KAAK,EAAEA,KAAM;AACbM,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,QAAQ,EAAEA,UAAS;AACnBG,IAAAA,WAAW,EAAEA,WAAY;AACzBX,IAAAA,SAAS,EAAEA,SAAU;AACrBI,IAAAA,SAAS,EAAEA,SAAU;AACrBE,IAAAA,OAAO,EAAEA,OAAQ;AAAAH,IAAAA,QAAA,EAEhBA,QAAAA;AAAQ,GAAA,EAXL,OAYC,CAAC,CAAA;AAEZ,CAAC;;;;"}
1
+ {"version":3,"file":"ResponsivePanel.js","sources":["../../../src/common/responsivePanel/ResponsivePanel.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport { Position } from '..';\nimport BottomSheet from '../bottomSheet';\nimport { useLayout } from '../hooks';\nimport Panel, { type PanelProps } from '../panel';\n\nconst ResponsivePanel = forwardRef<HTMLDivElement, PanelProps>(function ResponsivePanel(\n {\n anchorRef,\n arrow = false,\n flip = true,\n children,\n className = undefined,\n onClose,\n open = false,\n position = Position.BOTTOM,\n anchorWidth = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n }: PanelProps,\n reference,\n) {\n const { isMobile } = useLayout();\n if (isMobile) {\n return (\n <BottomSheet\n key=\"bottomSheet\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n open={open}\n className={className}\n onClose={onClose}\n >\n {children}\n </BottomSheet>\n );\n }\n return (\n <Panel\n key=\"panel\"\n ref={reference}\n flip={flip}\n arrow={arrow}\n open={open}\n position={position}\n anchorWidth={anchorWidth}\n anchorRef={anchorRef}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={className}\n onClose={onClose}\n >\n {children}\n </Panel>\n );\n});\n\nexport default ResponsivePanel;\n"],"names":["ResponsivePanel","forwardRef","anchorRef","arrow","flip","children","className","undefined","onClose","open","position","Position","BOTTOM","anchorWidth","ariaLabel","ariaLabelledBy","reference","isMobile","useLayout","_jsx","BottomSheet","Panel","ref"],"mappings":";;;;;;;;;AAOA,MAAMA,eAAe,gBAAGC,gBAAU,CAA6B,SAASD,eAAeA,CACrF;EACEE,SAAS;AACTC,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;EACXC,QAAQ;AACRC,EAAAA,SAAS,GAAGC,SAAS;EACrBC,OAAO;AACPC,EAAAA,IAAI,GAAG,KAAK;YACZC,UAAQ,GAAGC,iBAAQ,CAACC,MAAM;AAC1BC,EAAAA,WAAW,GAAG,KAAK;AACnB,EAAA,YAAY,EAAEC,SAAS;AACvB,EAAA,iBAAiB,EAAEC,cAAAA;AACR,CAAA,EACbC,SAAS,EAAA;EAET,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,mBAAS,EAAE,CAAA;AAChC,EAAA,IAAID,QAAQ,EAAE;IACZ,oBACEE,cAAA,CAACC,WAAW,EAAA;AAEV,MAAA,YAAA,EAAYN,SAAU;AACtB,MAAA,iBAAA,EAAiBC,cAAe;AAChCN,MAAAA,IAAI,EAAEA,IAAK;AACXH,MAAAA,SAAS,EAAEA,SAAU;AACrBE,MAAAA,OAAO,EAAEA,OAAQ;AAAAH,MAAAA,QAAA,EAEhBA,QAAAA;AAAQ,KAAA,EAPL,aAQO,CAAC,CAAA;AAElB,GAAA;EACA,oBACEc,cAAA,CAACE,KAAK,EAAA;AAEJC,IAAAA,GAAG,EAAEN,SAAU;AACfZ,IAAAA,IAAI,EAAEA,IAAK;AACXD,IAAAA,KAAK,EAAEA,KAAM;AACbM,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,QAAQ,EAAEA,UAAS;AACnBG,IAAAA,WAAW,EAAEA,WAAY;AACzBX,IAAAA,SAAS,EAAEA,SAAU;AACrB,IAAA,YAAA,EAAYY,SAAU;AACtB,IAAA,iBAAA,EAAiBC,cAAe;AAChCT,IAAAA,SAAS,EAAEA,SAAU;AACrBE,IAAAA,OAAO,EAAEA,OAAQ;AAAAH,IAAAA,QAAA,EAEhBA,QAAAA;AAAQ,GAAA,EAbL,OAcC,CAAC,CAAA;AAEZ,CAAC;;;;"}
@@ -14,13 +14,17 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(function ResponsivePanel({
14
14
  onClose,
15
15
  open = false,
16
16
  position = Position.BOTTOM,
17
- anchorWidth = false
17
+ anchorWidth = false,
18
+ 'aria-label': ariaLabel,
19
+ 'aria-labelledby': ariaLabelledBy
18
20
  }, reference) {
19
21
  const {
20
22
  isMobile
21
23
  } = useLayout();
22
24
  if (isMobile) {
23
25
  return /*#__PURE__*/jsx(BottomSheet, {
26
+ "aria-label": ariaLabel,
27
+ "aria-labelledby": ariaLabelledBy,
24
28
  open: open,
25
29
  className: className,
26
30
  onClose: onClose,
@@ -35,6 +39,8 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(function ResponsivePanel({
35
39
  position: position,
36
40
  anchorWidth: anchorWidth,
37
41
  anchorRef: anchorRef,
42
+ "aria-label": ariaLabel,
43
+ "aria-labelledby": ariaLabelledBy,
38
44
  className: className,
39
45
  onClose: onClose,
40
46
  children: children
@@ -1 +1 @@
1
- {"version":3,"file":"ResponsivePanel.mjs","sources":["../../../src/common/responsivePanel/ResponsivePanel.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport { Position } from '..';\nimport BottomSheet from '../bottomSheet';\nimport { useLayout } from '../hooks';\nimport Panel from '../panel';\nimport { PanelProps } from '../panel/Panel';\n\nconst ResponsivePanel = forwardRef<HTMLDivElement, PanelProps>(function ResponsivePanel(\n {\n anchorRef,\n arrow = false,\n flip = true,\n children,\n className = undefined,\n onClose,\n open = false,\n position = Position.BOTTOM,\n anchorWidth = false,\n }: PanelProps,\n reference,\n) {\n const { isMobile } = useLayout();\n if (isMobile) {\n return (\n <BottomSheet key=\"bottomSheet\" open={open} className={className} onClose={onClose}>\n {children}\n </BottomSheet>\n );\n }\n return (\n <Panel\n key=\"panel\"\n ref={reference}\n flip={flip}\n arrow={arrow}\n open={open}\n position={position}\n anchorWidth={anchorWidth}\n anchorRef={anchorRef}\n className={className}\n onClose={onClose}\n >\n {children}\n </Panel>\n );\n});\n\nexport default ResponsivePanel;\n"],"names":["ResponsivePanel","forwardRef","anchorRef","arrow","flip","children","className","undefined","onClose","open","position","Position","BOTTOM","anchorWidth","reference","isMobile","useLayout","_jsx","BottomSheet","Panel","ref"],"mappings":";;;;;;;AAQA,MAAMA,eAAe,gBAAGC,UAAU,CAA6B,SAASD,eAAeA,CACrF;EACEE,SAAS;AACTC,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;EACXC,QAAQ;AACRC,EAAAA,SAAS,GAAGC,SAAS;EACrBC,OAAO;AACPC,EAAAA,IAAI,GAAG,KAAK;EACZC,QAAQ,GAAGC,QAAQ,CAACC,MAAM;AAC1BC,EAAAA,WAAW,GAAG,KAAA;AAAK,CACR,EACbC,SAAS,EAAA;EAET,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,SAAS,EAAE,CAAA;AAChC,EAAA,IAAID,QAAQ,EAAE;IACZ,oBACEE,GAAA,CAACC,WAAW,EAAA;AAAmBT,MAAAA,IAAI,EAAEA,IAAK;AAACH,MAAAA,SAAS,EAAEA,SAAU;AAACE,MAAAA,OAAO,EAAEA,OAAQ;AAAAH,MAAAA,QAAA,EAC/EA,QAAAA;AAAQ,KAAA,EADM,aAEJ,CAAC,CAAA;AAElB,GAAA;EACA,oBACEY,GAAA,CAACE,KAAK,EAAA;AAEJC,IAAAA,GAAG,EAAEN,SAAU;AACfV,IAAAA,IAAI,EAAEA,IAAK;AACXD,IAAAA,KAAK,EAAEA,KAAM;AACbM,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,QAAQ,EAAEA,QAAS;AACnBG,IAAAA,WAAW,EAAEA,WAAY;AACzBX,IAAAA,SAAS,EAAEA,SAAU;AACrBI,IAAAA,SAAS,EAAEA,SAAU;AACrBE,IAAAA,OAAO,EAAEA,OAAQ;AAAAH,IAAAA,QAAA,EAEhBA,QAAAA;AAAQ,GAAA,EAXL,OAYC,CAAC,CAAA;AAEZ,CAAC;;;;"}
1
+ {"version":3,"file":"ResponsivePanel.mjs","sources":["../../../src/common/responsivePanel/ResponsivePanel.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport { Position } from '..';\nimport BottomSheet from '../bottomSheet';\nimport { useLayout } from '../hooks';\nimport Panel, { type PanelProps } from '../panel';\n\nconst ResponsivePanel = forwardRef<HTMLDivElement, PanelProps>(function ResponsivePanel(\n {\n anchorRef,\n arrow = false,\n flip = true,\n children,\n className = undefined,\n onClose,\n open = false,\n position = Position.BOTTOM,\n anchorWidth = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n }: PanelProps,\n reference,\n) {\n const { isMobile } = useLayout();\n if (isMobile) {\n return (\n <BottomSheet\n key=\"bottomSheet\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n open={open}\n className={className}\n onClose={onClose}\n >\n {children}\n </BottomSheet>\n );\n }\n return (\n <Panel\n key=\"panel\"\n ref={reference}\n flip={flip}\n arrow={arrow}\n open={open}\n position={position}\n anchorWidth={anchorWidth}\n anchorRef={anchorRef}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={className}\n onClose={onClose}\n >\n {children}\n </Panel>\n );\n});\n\nexport default ResponsivePanel;\n"],"names":["ResponsivePanel","forwardRef","anchorRef","arrow","flip","children","className","undefined","onClose","open","position","Position","BOTTOM","anchorWidth","ariaLabel","ariaLabelledBy","reference","isMobile","useLayout","_jsx","BottomSheet","Panel","ref"],"mappings":";;;;;;;AAOA,MAAMA,eAAe,gBAAGC,UAAU,CAA6B,SAASD,eAAeA,CACrF;EACEE,SAAS;AACTC,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;EACXC,QAAQ;AACRC,EAAAA,SAAS,GAAGC,SAAS;EACrBC,OAAO;AACPC,EAAAA,IAAI,GAAG,KAAK;EACZC,QAAQ,GAAGC,QAAQ,CAACC,MAAM;AAC1BC,EAAAA,WAAW,GAAG,KAAK;AACnB,EAAA,YAAY,EAAEC,SAAS;AACvB,EAAA,iBAAiB,EAAEC,cAAAA;AACR,CAAA,EACbC,SAAS,EAAA;EAET,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,SAAS,EAAE,CAAA;AAChC,EAAA,IAAID,QAAQ,EAAE;IACZ,oBACEE,GAAA,CAACC,WAAW,EAAA;AAEV,MAAA,YAAA,EAAYN,SAAU;AACtB,MAAA,iBAAA,EAAiBC,cAAe;AAChCN,MAAAA,IAAI,EAAEA,IAAK;AACXH,MAAAA,SAAS,EAAEA,SAAU;AACrBE,MAAAA,OAAO,EAAEA,OAAQ;AAAAH,MAAAA,QAAA,EAEhBA,QAAAA;AAAQ,KAAA,EAPL,aAQO,CAAC,CAAA;AAElB,GAAA;EACA,oBACEc,GAAA,CAACE,KAAK,EAAA;AAEJC,IAAAA,GAAG,EAAEN,SAAU;AACfZ,IAAAA,IAAI,EAAEA,IAAK;AACXD,IAAAA,KAAK,EAAEA,KAAM;AACbM,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,QAAQ,EAAEA,QAAS;AACnBG,IAAAA,WAAW,EAAEA,WAAY;AACzBX,IAAAA,SAAS,EAAEA,SAAU;AACrB,IAAA,YAAA,EAAYY,SAAU;AACtB,IAAA,iBAAA,EAAiBC,cAAe;AAChCT,IAAAA,SAAS,EAAEA,SAAU;AACrBE,IAAAA,OAAO,EAAEA,OAAQ;AAAAH,IAAAA,QAAA,EAEhBA,QAAAA;AAAQ,GAAA,EAbL,OAcC,CAAC,CAAA;AAEZ,CAAC;;;;"}
@@ -35,7 +35,8 @@ const Dimmer = ({
35
35
  open = false,
36
36
  scrollable = false,
37
37
  transparent = false,
38
- onClose
38
+ onClose,
39
+ onExited: handleExited
39
40
  }) => {
40
41
  const [hasNotExited, setHasNotExited] = React.useState(false);
41
42
  const dimmerReference = React.useRef(null);
@@ -70,6 +71,7 @@ const Dimmer = ({
70
71
  if (dimmerReference.current) {
71
72
  dimmerManager.remove(dimmerReference.current);
72
73
  }
74
+ handleExited?.();
73
75
  };
74
76
  React.useEffect(() => {
75
77
  const localReferenceCopy = dimmerReference.current;
@@ -1 +1 @@
1
- {"version":3,"file":"Dimmer.js","sources":["../../src/dimmer/Dimmer.tsx"],"sourcesContent":["import { ThemeProvider, useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { MouseEvent, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n addNoScrollClass,\n CommonProps,\n PositionBottom,\n PositionCenter,\n PositionTop,\n removeNoScrollClass,\n} from '../common';\nimport { isIosDevice } from '../common/deviceDetection';\nimport FocusBoundary from '../common/focusBoundary';\nimport withNextPortal from '../withNextPortal/withNextPortal';\n\nimport DimmerManager from './dimmerManager';\n\nexport const EXIT_ANIMATION = 350;\n\nconst dimmerManager = new DimmerManager();\n\nexport type DimmerProps = CommonProps & {\n children?: ReactNode;\n disableClickToClose?: boolean;\n contentPosition?: PositionTop | PositionCenter | PositionBottom;\n fadeContentOnEnter?: boolean;\n fadeContentOnExit?: boolean;\n open?: boolean;\n scrollable?: boolean;\n transparent?: boolean;\n onClose?: (event: KeyboardEvent | MouseEvent) => void;\n};\n\nexport const handleTouchMove = (event: Event) => {\n const isTouchedElementDimmer = (event.target as HTMLDivElement).classList.contains('dimmer');\n\n // disable scroll on iOS devices for Dimmer area\n // this is because of bug in WebKit https://bugs.webkit.org/show_bug.cgi?id=220908\n // note: scrolling still works for children(s) as expected\n if (isIosDevice() && isTouchedElementDimmer) {\n event.stopPropagation();\n event.preventDefault();\n }\n};\n\nconst Dimmer = ({\n children,\n className,\n disableClickToClose = false,\n contentPosition,\n fadeContentOnEnter = false,\n fadeContentOnExit = false,\n open = false,\n scrollable = false,\n transparent = false,\n onClose,\n}: DimmerProps) => {\n const [hasNotExited, setHasNotExited] = useState(false);\n const dimmerReference = useRef<HTMLDivElement>(null);\n\n const closeOnClick = (event: MouseEvent<HTMLDivElement>) => {\n if (event.target === dimmerReference.current) {\n onClose?.(event);\n }\n };\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n if (disableClickToClose || !onClose) {\n return;\n }\n\n closeOnClick(event);\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n event.stopPropagation();\n\n if (onClose && dimmerReference.current && dimmerManager.isTop(dimmerReference.current)) {\n onClose(event);\n }\n },\n [onClose],\n );\n\n const onEnter = () => {\n setHasNotExited(true);\n\n if (dimmerReference.current) {\n dimmerManager.add(dimmerReference.current);\n }\n };\n const onExited = () => {\n setHasNotExited(false);\n\n if (dimmerReference.current) {\n dimmerManager.remove(dimmerReference.current);\n }\n };\n\n useEffect(() => {\n const localReferenceCopy = dimmerReference.current;\n\n if (open) {\n document.addEventListener('keydown', handleKeyDown);\n localReferenceCopy?.addEventListener('touchmove', handleTouchMove, { passive: true });\n }\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n\n localReferenceCopy?.removeEventListener('touchmove', handleTouchMove);\n };\n }, [handleKeyDown, open]);\n\n return (\n <DimmerWrapper open={open} hasNotExited={hasNotExited}>\n <CSSTransition\n nodeRef={dimmerReference}\n in={open}\n appear\n // Wait for animation to finish before unmount.\n timeout={{ enter: 0, exit: EXIT_ANIMATION }}\n classNames={{\n enter: clsx({ 'dimmer--enter-fade': fadeContentOnEnter }),\n enterDone: clsx('dimmer--enter-done', {\n 'dimmer--enter-fade': fadeContentOnEnter,\n }),\n exit: clsx('dimmer--exit', { 'dimmer--exit-fade': fadeContentOnExit }),\n }}\n unmountOnExit\n onEnter={onEnter}\n onExited={onExited}\n >\n <DimmerContentWrapper scrollBody={!transparent}>\n <FocusBoundary>\n <div\n ref={dimmerReference}\n className={clsx(\n 'dimmer',\n { 'dimmer--scrollable': scrollable, 'dimmer--transparent': transparent },\n className,\n )}\n role=\"presentation\"\n onClick={handleClick}\n >\n <div\n className={clsx(\n 'dimmer-content-positioner',\n contentPosition != null && [\n 'd-flex justify-content-center',\n {\n 'align-items-start': contentPosition === 'top',\n 'align-items-center': contentPosition === 'center',\n 'align-items-end': contentPosition === 'bottom',\n },\n ],\n )}\n >\n {children}\n </div>\n </div>\n </FocusBoundary>\n </DimmerContentWrapper>\n </CSSTransition>\n </DimmerWrapper>\n );\n};\n\nconst DimmerWrapper: React.ComponentType<{\n open: boolean;\n hasNotExited: boolean;\n children: React.ReactNode;\n}> = ({ open, hasNotExited, children }) => {\n const { screenMode, theme } = useTheme();\n\n return open || hasNotExited ? (\n <ThemeProvider\n theme=\"personal\"\n screenMode={theme === 'personal' ? screenMode : 'light'}\n isNotRootProvider\n >\n {children}\n </ThemeProvider>\n ) : (\n <>{children}</>\n );\n};\n\nexport const DimmerContentWrapper = ({\n children,\n scrollBody,\n}: {\n children: React.ReactElement;\n scrollBody: boolean;\n}) => {\n useEffect(() => {\n if (scrollBody) {\n addNoScrollClass();\n }\n\n return () => {\n if (scrollBody) {\n removeNoScrollClass();\n }\n };\n }, [scrollBody]);\n\n return children;\n};\n\n// Export without the Portal for tests only\nexport { Dimmer };\n\nexport default withNextPortal(Dimmer);\n"],"names":["EXIT_ANIMATION","dimmerManager","DimmerManager","handleTouchMove","event","isTouchedElementDimmer","target","classList","contains","isIosDevice","stopPropagation","preventDefault","Dimmer","children","className","disableClickToClose","contentPosition","fadeContentOnEnter","fadeContentOnExit","open","scrollable","transparent","onClose","hasNotExited","setHasNotExited","useState","dimmerReference","useRef","closeOnClick","current","handleClick","handleKeyDown","useCallback","key","isTop","onEnter","add","onExited","remove","useEffect","localReferenceCopy","document","addEventListener","passive","removeEventListener","_jsx","DimmerWrapper","CSSTransition","nodeRef","in","appear","timeout","enter","exit","classNames","clsx","enterDone","unmountOnExit","DimmerContentWrapper","scrollBody","FocusBoundary","ref","role","onClick","screenMode","theme","useTheme","ThemeProvider","isNotRootProvider","_Fragment","addNoScrollClass","removeNoScrollClass","withNextPortal"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG,IAAG;AAEjC,MAAMC,aAAa,GAAG,IAAIC,aAAa,EAAE,CAAA;AAc5BC,MAAAA,eAAe,GAAIC,KAAY,IAAI;EAC9C,MAAMC,sBAAsB,GAAID,KAAK,CAACE,MAAyB,CAACC,SAAS,CAACC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAE5F;AACA;AACA;AACA,EAAA,IAAIC,2BAAW,EAAE,IAAIJ,sBAAsB,EAAE;IAC3CD,KAAK,CAACM,eAAe,EAAE,CAAA;IACvBN,KAAK,CAACO,cAAc,EAAE,CAAA;AACxB,GAAA;AACF,EAAC;AAEKC,MAAAA,MAAM,GAAGA,CAAC;EACdC,QAAQ;EACRC,SAAS;AACTC,EAAAA,mBAAmB,GAAG,KAAK;EAC3BC,eAAe;AACfC,EAAAA,kBAAkB,GAAG,KAAK;AAC1BC,EAAAA,iBAAiB,G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;EAAE3B,IAAI;EAAEI,YAAY;AAAEV,EAAAA,QAAAA;AAAU,CAAA,KAAI;EACxC,MAAM;IAAEmD,UAAU;AAAEC,IAAAA,KAAAA;GAAO,GAAGC,0BAAQ,EAAE,CAAA;AAExC,EAAA,OAAO/C,IAAI,IAAII,YAAY,gBACzBsB,cAAA,CAACsB,+BAAa,EAAA;AACZF,IAAAA,KAAK,EAAC,UAAU;AAChBD,IAAAA,UAAU,EAAEC,KAAK,KAAK,UAAU,GAAGD,UAAU,GAAG,OAAQ;IACxDI,iBAAiB,EAAA,IAAA;AAAAvD,IAAAA,QAAA,EAEhBA,QAAAA;AAAQ,GACI,CAAC,gBAEhBgC,cAAA,CAAAwB,mBAAA,EAAA;AAAAxD,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAC,CACb,CAAA;AACH,CAAC,CAAA;AAEM,MAAM6C,oBAAoB,GAAGA,CAAC;EACnC7C,QAAQ;AACR8C,EAAAA,UAAAA;AAID,CAAA,KAAI;AACHpB,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAIoB,UAAU,EAAE;AACdW,MAAAA,8BAAgB,EAAE,CAAA;AACpB,KAAA;AAEA,IAAA,OAAO,MAAK;AACV,MAAA,IAAIX,UAAU,EAAE;AACdY,QAAAA,iCAAmB,EAAE,CAAA;AACvB,OAAA;KACD,CAAA;AACH,GAAC,EAAE,CAACZ,UAAU,CAAC,CAAC,CAAA;AAEhB,EAAA,OAAO9C,QAAQ,CAAA;AACjB,EAAC;AAKD,eAAe2D,cAAc,CAAC5D,MAAM,CAAC;;;;;;;;"}
1
+ {"version":3,"file":"Dimmer.js","sources":["../../src/dimmer/Dimmer.tsx"],"sourcesContent":["import { ThemeProvider, useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { MouseEvent, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n addNoScrollClass,\n CommonProps,\n PositionBottom,\n PositionCenter,\n PositionTop,\n removeNoScrollClass,\n} from '../common';\nimport { isIosDevice } from '../common/deviceDetection';\nimport FocusBoundary from '../common/focusBoundary';\nimport withNextPortal from '../withNextPortal/withNextPortal';\n\nimport DimmerManager from './dimmerManager';\n\nexport const EXIT_ANIMATION = 350;\n\nconst dimmerManager = new DimmerManager();\n\nexport type DimmerProps = CommonProps & {\n children?: ReactNode;\n disableClickToClose?: boolean;\n contentPosition?: PositionTop | PositionCenter | PositionBottom;\n fadeContentOnEnter?: boolean;\n fadeContentOnExit?: boolean;\n open?: boolean;\n scrollable?: boolean;\n transparent?: boolean;\n onClose?: (event: KeyboardEvent | MouseEvent) => void;\n onExited?: () => void;\n};\n\nexport const handleTouchMove = (event: Event) => {\n const isTouchedElementDimmer = (event.target as HTMLDivElement).classList.contains('dimmer');\n\n // disable scroll on iOS devices for Dimmer area\n // this is because of bug in WebKit https://bugs.webkit.org/show_bug.cgi?id=220908\n // note: scrolling still works for children(s) as expected\n if (isIosDevice() && isTouchedElementDimmer) {\n event.stopPropagation();\n event.preventDefault();\n }\n};\n\nconst Dimmer = ({\n children,\n className,\n disableClickToClose = false,\n contentPosition,\n fadeContentOnEnter = false,\n fadeContentOnExit = false,\n open = false,\n scrollable = false,\n transparent = false,\n onClose,\n onExited: handleExited,\n}: DimmerProps) => {\n const [hasNotExited, setHasNotExited] = useState(false);\n const dimmerReference = useRef<HTMLDivElement>(null);\n\n const closeOnClick = (event: MouseEvent<HTMLDivElement>) => {\n if (event.target === dimmerReference.current) {\n onClose?.(event);\n }\n };\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n if (disableClickToClose || !onClose) {\n return;\n }\n\n closeOnClick(event);\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n event.stopPropagation();\n\n if (onClose && dimmerReference.current && dimmerManager.isTop(dimmerReference.current)) {\n onClose(event);\n }\n },\n [onClose],\n );\n\n const onEnter = () => {\n setHasNotExited(true);\n\n if (dimmerReference.current) {\n dimmerManager.add(dimmerReference.current);\n }\n };\n const onExited = () => {\n setHasNotExited(false);\n\n if (dimmerReference.current) {\n dimmerManager.remove(dimmerReference.current);\n }\n\n handleExited?.();\n };\n\n useEffect(() => {\n const localReferenceCopy = dimmerReference.current;\n\n if (open) {\n document.addEventListener('keydown', handleKeyDown);\n localReferenceCopy?.addEventListener('touchmove', handleTouchMove, { passive: true });\n }\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n\n localReferenceCopy?.removeEventListener('touchmove', handleTouchMove);\n };\n }, [handleKeyDown, open]);\n\n return (\n <DimmerWrapper open={open} hasNotExited={hasNotExited}>\n <CSSTransition\n nodeRef={dimmerReference}\n in={open}\n appear\n // Wait for animation to finish before unmount.\n timeout={{ enter: 0, exit: EXIT_ANIMATION }}\n classNames={{\n enter: clsx({ 'dimmer--enter-fade': fadeContentOnEnter }),\n enterDone: clsx('dimmer--enter-done', {\n 'dimmer--enter-fade': fadeContentOnEnter,\n }),\n exit: clsx('dimmer--exit', { 'dimmer--exit-fade': fadeContentOnExit }),\n }}\n unmountOnExit\n onEnter={onEnter}\n onExited={onExited}\n >\n <DimmerContentWrapper scrollBody={!transparent}>\n <FocusBoundary>\n <div\n ref={dimmerReference}\n className={clsx(\n 'dimmer',\n { 'dimmer--scrollable': scrollable, 'dimmer--transparent': transparent },\n className,\n )}\n role=\"presentation\"\n onClick={handleClick}\n >\n <div\n className={clsx(\n 'dimmer-content-positioner',\n contentPosition != null && [\n 'd-flex justify-content-center',\n {\n 'align-items-start': contentPosition === 'top',\n 'align-items-center': contentPosition === 'center',\n 'align-items-end': contentPosition === 'bottom',\n },\n ],\n )}\n >\n {children}\n </div>\n </div>\n </FocusBoundary>\n </DimmerContentWrapper>\n </CSSTransition>\n </DimmerWrapper>\n );\n};\n\nconst DimmerWrapper: React.ComponentType<{\n open: boolean;\n hasNotExited: boolean;\n children: React.ReactNode;\n}> = ({ open, hasNotExited, children }) => {\n const { screenMode, theme } = useTheme();\n\n return open || hasNotExited ? (\n <ThemeProvider\n theme=\"personal\"\n screenMode={theme === 'personal' ? screenMode : 'light'}\n isNotRootProvider\n >\n {children}\n </ThemeProvider>\n ) : (\n <>{children}</>\n );\n};\n\nexport const DimmerContentWrapper = ({\n children,\n scrollBody,\n}: {\n children: React.ReactElement;\n scrollBody: boolean;\n}) => {\n useEffect(() => {\n if (scrollBody) {\n addNoScrollClass();\n }\n\n return () => {\n if (scrollBody) {\n removeNoScrollClass();\n }\n };\n }, [scrollBody]);\n\n return children;\n};\n\n// Export without the Portal for tests only\nexport { Dimmer };\n\nexport default withNextPortal(Dimmer);\n"],"names":["EXIT_ANIMATION","dimmerManager","DimmerManager","handleTouchMove","event","isTouchedElementDimmer","target","classList","contains","isIosDevice","stopPropagation","preventDefault","Dimmer","children","className","disableClickToClose","contentPosition","fadeContentOnEnter","fadeContentOnExit","open","scrollable","transparent","onClose","onExited","handleExited","hasNotExited","setHasNotExited","useState","dimmerReference","useRef","closeOnClick","current","handleClick","handleKeyDown","useCallback","key","isTop","onEnter","add","remove","useEffect","localReferenceCopy","document","addEventListener","passive","removeEventListener","_jsx","DimmerWrapper","CSSTransition","nodeRef","in","appear","timeout","enter","exit","classNames","clsx","enterDone","unmountOnExit","DimmerContentWrapper","scrollBody","FocusBoundary","ref","role","onClick","screenMode","theme","useTheme","ThemeProvider","isNotRootProvider","_Fragment","addNoScrollClass","removeNoScrollClass","withNextPortal"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG,IAAG;AAEjC,MAAMC,aAAa,GAAG,IAAIC,aAAa,EAAE,CAAA;AAe5BC,MAAAA,eAAe,GAAIC,KAAY,IAAI;EAC9C,MAAMC,sBAAsB,GAAID,KAAK,CAACE,MAAyB,CAACC,SAAS,CAACC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAE5F;AACA;AACA;AACA,EAAA,IAAIC,2BAAW,EAAE,IAAIJ,sBAAsB,EAAE;IAC3CD,KAAK,CAACM,eA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B,EAAC;AAKD,eAAe4D,cAAc,CAAC7D,MAAM,CAAC;;;;;;;;"}
@@ -31,7 +31,8 @@ const Dimmer = ({
31
31
  open = false,
32
32
  scrollable = false,
33
33
  transparent = false,
34
- onClose
34
+ onClose,
35
+ onExited: handleExited
35
36
  }) => {
36
37
  const [hasNotExited, setHasNotExited] = useState(false);
37
38
  const dimmerReference = useRef(null);
@@ -66,6 +67,7 @@ const Dimmer = ({
66
67
  if (dimmerReference.current) {
67
68
  dimmerManager.remove(dimmerReference.current);
68
69
  }
70
+ handleExited?.();
69
71
  };
70
72
  useEffect(() => {
71
73
  const localReferenceCopy = dimmerReference.current;
@@ -1 +1 @@
1
- {"version":3,"file":"Dimmer.mjs","sources":["../../src/dimmer/Dimmer.tsx"],"sourcesContent":["import { ThemeProvider, useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { MouseEvent, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n addNoScrollClass,\n CommonProps,\n PositionBottom,\n PositionCenter,\n PositionTop,\n removeNoScrollClass,\n} from '../common';\nimport { isIosDevice } from '../common/deviceDetection';\nimport FocusBoundary from '../common/focusBoundary';\nimport withNextPortal from '../withNextPortal/withNextPortal';\n\nimport DimmerManager from './dimmerManager';\n\nexport const EXIT_ANIMATION = 350;\n\nconst dimmerManager = new DimmerManager();\n\nexport type DimmerProps = CommonProps & {\n children?: ReactNode;\n disableClickToClose?: boolean;\n contentPosition?: PositionTop | PositionCenter | PositionBottom;\n fadeContentOnEnter?: boolean;\n fadeContentOnExit?: boolean;\n open?: boolean;\n scrollable?: boolean;\n transparent?: boolean;\n onClose?: (event: KeyboardEvent | MouseEvent) => void;\n};\n\nexport const handleTouchMove = (event: Event) => {\n const isTouchedElementDimmer = (event.target as HTMLDivElement).classList.contains('dimmer');\n\n // disable scroll on iOS devices for Dimmer area\n // this is because of bug in WebKit https://bugs.webkit.org/show_bug.cgi?id=220908\n // note: scrolling still works for children(s) as expected\n if (isIosDevice() && isTouchedElementDimmer) {\n event.stopPropagation();\n event.preventDefault();\n }\n};\n\nconst Dimmer = ({\n children,\n className,\n disableClickToClose = false,\n contentPosition,\n fadeContentOnEnter = false,\n fadeContentOnExit = false,\n open = false,\n scrollable = false,\n transparent = false,\n onClose,\n}: DimmerProps) => {\n const [hasNotExited, setHasNotExited] = useState(false);\n const dimmerReference = useRef<HTMLDivElement>(null);\n\n const closeOnClick = (event: MouseEvent<HTMLDivElement>) => {\n if (event.target === dimmerReference.current) {\n onClose?.(event);\n }\n };\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n if (disableClickToClose || !onClose) {\n return;\n }\n\n closeOnClick(event);\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n event.stopPropagation();\n\n if (onClose && dimmerReference.current && dimmerManager.isTop(dimmerReference.current)) {\n onClose(event);\n }\n },\n [onClose],\n );\n\n const onEnter = () => {\n setHasNotExited(true);\n\n if (dimmerReference.current) {\n dimmerManager.add(dimmerReference.current);\n }\n };\n const onExited = () => {\n setHasNotExited(false);\n\n if (dimmerReference.current) {\n dimmerManager.remove(dimmerReference.current);\n }\n };\n\n useEffect(() => {\n const localReferenceCopy = dimmerReference.current;\n\n if (open) {\n document.addEventListener('keydown', handleKeyDown);\n localReferenceCopy?.addEventListener('touchmove', handleTouchMove, { passive: true });\n }\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n\n localReferenceCopy?.removeEventListener('touchmove', handleTouchMove);\n };\n }, [handleKeyDown, open]);\n\n return (\n <DimmerWrapper open={open} hasNotExited={hasNotExited}>\n <CSSTransition\n nodeRef={dimmerReference}\n in={open}\n appear\n // Wait for animation to finish before unmount.\n timeout={{ enter: 0, exit: EXIT_ANIMATION }}\n classNames={{\n enter: clsx({ 'dimmer--enter-fade': fadeContentOnEnter }),\n enterDone: clsx('dimmer--enter-done', {\n 'dimmer--enter-fade': fadeContentOnEnter,\n }),\n exit: clsx('dimmer--exit', { 'dimmer--exit-fade': fadeContentOnExit }),\n }}\n unmountOnExit\n onEnter={onEnter}\n onExited={onExited}\n >\n <DimmerContentWrapper scrollBody={!transparent}>\n <FocusBoundary>\n <div\n ref={dimmerReference}\n className={clsx(\n 'dimmer',\n { 'dimmer--scrollable': scrollable, 'dimmer--transparent': transparent },\n className,\n )}\n role=\"presentation\"\n onClick={handleClick}\n >\n <div\n className={clsx(\n 'dimmer-content-positioner',\n contentPosition != null && [\n 'd-flex justify-content-center',\n {\n 'align-items-start': contentPosition === 'top',\n 'align-items-center': contentPosition === 'center',\n 'align-items-end': contentPosition === 'bottom',\n },\n ],\n )}\n >\n {children}\n </div>\n </div>\n </FocusBoundary>\n </DimmerContentWrapper>\n </CSSTransition>\n </DimmerWrapper>\n );\n};\n\nconst DimmerWrapper: React.ComponentType<{\n open: boolean;\n hasNotExited: boolean;\n children: React.ReactNode;\n}> = ({ open, hasNotExited, children }) => {\n const { screenMode, theme } = useTheme();\n\n return open || hasNotExited ? (\n <ThemeProvider\n theme=\"personal\"\n screenMode={theme === 'personal' ? screenMode : 'light'}\n isNotRootProvider\n >\n {children}\n </ThemeProvider>\n ) : (\n <>{children}</>\n );\n};\n\nexport const DimmerContentWrapper = ({\n children,\n scrollBody,\n}: {\n children: React.ReactElement;\n scrollBody: boolean;\n}) => {\n useEffect(() => {\n if (scrollBody) {\n addNoScrollClass();\n }\n\n return () => {\n if (scrollBody) {\n removeNoScrollClass();\n }\n };\n }, [scrollBody]);\n\n return children;\n};\n\n// Export without the Portal for tests only\nexport { Dimmer };\n\nexport default withNextPortal(Dimmer);\n"],"names":["EXIT_ANIMATION","dimmerManager","DimmerManager","handleTouchMove","event","isTouchedElementDimmer","target","classList","contains","isIosDevice","stopPropagation","preventDefault","Dimmer","children","className","disableClickToClose","contentPosition","fadeContentOnEnter","fadeContentOnExit","open","scrollable","transparent","onClose","hasNotExited","setHasNotExited","useState","dimmerReference","useRef","closeOnClick","current","handleClick","handleKeyDown","useCallback","key","isTop","onEnter","add","onExited","remove","useEffect","localReferenceCopy","document","addEventListener","passive","removeEventListener","_jsx","DimmerWrapper","CSSTransition","nodeRef","in","appear","timeout","enter","exit","classNames","clsx","enterDone","unmountOnExit","DimmerContentWrapper","scrollBody","FocusBoundary","ref","role","onClick","screenMode","theme","useTheme","ThemeProvider","isNotRootProvider","_Fragment","addNoScrollClass","removeNoScrollClass","withNextPortal"],"mappings":";;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG,IAAG;AAEjC,MAAMC,aAAa,GAAG,IAAIC,aAAa,EAAE,CAAA;AAc5BC,MAAAA,eAAe,GAAIC,KAAY,IAAI;EAC9C,MAAMC,sBAAsB,GAAID,KAAK,CAACE,MAAyB,CAACC,SAAS,CAACC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAE5F;AACA;AACA;AACA,EAAA,IAAIC,WAAW,EAAE,IAAIJ,sBAAsB,EAAE;IAC3CD,KAAK,CAACM,eAAe,EAAE,CAAA;IACvBN,KAAK,CAACO,cAAc,EAAE,CAAA;AACxB,GAAA;AACF,EAAC;AAEKC,MAAAA,MAAM,GAAGA,CAAC;EACdC,QAAQ;EACRC,SAAS;AACTC,EAAAA,mBAAmB,GAAG,KAAK;EAC3BC,eAAe;AACfC,EAAAA,kBAAkB,GAAG,KAAK;AAC1BC,EAAAA,iBAAiB,GAAG,KAAK;AACzBC,EAAAA,IAAI,GAAG,KAAK;AACZC,EAAAA,UAAU,GAAG,KAAK;AAClBC,EAAAA,WAAW,GAAG,KAAK;AACnBC,EAAAA,OAAAA;AAAO,CACK,KAAI;EAChB,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACvD,EAAA,MAAMC,eAAe,GAAGC,MAAM,CAAiB,IAAI,CAAC,CAAA;EAEpD,MAAMC,YAAY,GAAIxB,KAAiC,IAAI;AACzD,IAAA,IAAIA,KAAK,CAACE,MAAM,KAAKoB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BA,QAAAA;AAAQ,GACI,CAAC,gBAEhBgC,GAAA,CAAAwB,QAAA,EAAA;AAAAxD,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAC,CACb,CAAA;AACH,CAAC,CAAA;AAEM,MAAM6C,oBAAoB,GAAGA,CAAC;EACnC7C,QAAQ;AACR8C,EAAAA,UAAAA;AAID,CAAA,KAAI;AACHpB,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAIoB,UAAU,EAAE;AACdW,MAAAA,gBAAgB,EAAE,CAAA;AACpB,KAAA;AAEA,IAAA,OAAO,MAAK;AACV,MAAA,IAAIX,UAAU,EAAE;AACdY,QAAAA,mBAAmB,EAAE,CAAA;AACvB,OAAA;KACD,CAAA;AACH,GAAC,EAAE,CAACZ,UAAU,CAAC,CAAC,CAAA;AAEhB,EAAA,OAAO9C,QAAQ,CAAA;AACjB,EAAC;AAKD,eAAe2D,qBAAc,CAAC5D,MAAM,CAAC;;;;"}
1
+ {"version":3,"file":"Dimmer.mjs","sources":["../../src/dimmer/Dimmer.tsx"],"sourcesContent":["import { ThemeProvider, useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { MouseEvent, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport {\n addNoScrollClass,\n CommonProps,\n PositionBottom,\n PositionCenter,\n PositionTop,\n removeNoScrollClass,\n} from '../common';\nimport { isIosDevice } from '../common/deviceDetection';\nimport FocusBoundary from '../common/focusBoundary';\nimport withNextPortal from '../withNextPortal/withNextPortal';\n\nimport DimmerManager from './dimmerManager';\n\nexport const EXIT_ANIMATION = 350;\n\nconst dimmerManager = new DimmerManager();\n\nexport type DimmerProps = CommonProps & {\n children?: ReactNode;\n disableClickToClose?: boolean;\n contentPosition?: PositionTop | PositionCenter | PositionBottom;\n fadeContentOnEnter?: boolean;\n fadeContentOnExit?: boolean;\n open?: boolean;\n scrollable?: boolean;\n transparent?: boolean;\n onClose?: (event: KeyboardEvent | MouseEvent) => void;\n onExited?: () => void;\n};\n\nexport const handleTouchMove = (event: Event) => {\n const isTouchedElementDimmer = (event.target as HTMLDivElement).classList.contains('dimmer');\n\n // disable scroll on iOS devices for Dimmer area\n // this is because of bug in WebKit https://bugs.webkit.org/show_bug.cgi?id=220908\n // note: scrolling still works for children(s) as expected\n if (isIosDevice() && isTouchedElementDimmer) {\n event.stopPropagation();\n event.preventDefault();\n }\n};\n\nconst Dimmer = ({\n children,\n className,\n disableClickToClose = false,\n contentPosition,\n fadeContentOnEnter = false,\n fadeContentOnExit = false,\n open = false,\n scrollable = false,\n transparent = false,\n onClose,\n onExited: handleExited,\n}: DimmerProps) => {\n const [hasNotExited, setHasNotExited] = useState(false);\n const dimmerReference = useRef<HTMLDivElement>(null);\n\n const closeOnClick = (event: MouseEvent<HTMLDivElement>) => {\n if (event.target === dimmerReference.current) {\n onClose?.(event);\n }\n };\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n if (disableClickToClose || !onClose) {\n return;\n }\n\n closeOnClick(event);\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n event.stopPropagation();\n\n if (onClose && dimmerReference.current && dimmerManager.isTop(dimmerReference.current)) {\n onClose(event);\n }\n },\n [onClose],\n );\n\n const onEnter = () => {\n setHasNotExited(true);\n\n if (dimmerReference.current) {\n dimmerManager.add(dimmerReference.current);\n }\n };\n const onExited = () => {\n setHasNotExited(false);\n\n if (dimmerReference.current) {\n dimmerManager.remove(dimmerReference.current);\n }\n\n handleExited?.();\n };\n\n useEffect(() => {\n const localReferenceCopy = dimmerReference.current;\n\n if (open) {\n document.addEventListener('keydown', handleKeyDown);\n localReferenceCopy?.addEventListener('touchmove', handleTouchMove, { passive: true });\n }\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n\n localReferenceCopy?.removeEventListener('touchmove', handleTouchMove);\n };\n }, [handleKeyDown, open]);\n\n return (\n <DimmerWrapper open={open} hasNotExited={hasNotExited}>\n <CSSTransition\n nodeRef={dimmerReference}\n in={open}\n appear\n // Wait for animation to finish before unmount.\n timeout={{ enter: 0, exit: EXIT_ANIMATION }}\n classNames={{\n enter: clsx({ 'dimmer--enter-fade': fadeContentOnEnter }),\n enterDone: clsx('dimmer--enter-done', {\n 'dimmer--enter-fade': fadeContentOnEnter,\n }),\n exit: clsx('dimmer--exit', { 'dimmer--exit-fade': fadeContentOnExit }),\n }}\n unmountOnExit\n onEnter={onEnter}\n onExited={onExited}\n >\n <DimmerContentWrapper scrollBody={!transparent}>\n <FocusBoundary>\n <div\n ref={dimmerReference}\n className={clsx(\n 'dimmer',\n { 'dimmer--scrollable': scrollable, 'dimmer--transparent': transparent },\n className,\n )}\n role=\"presentation\"\n onClick={handleClick}\n >\n <div\n className={clsx(\n 'dimmer-content-positioner',\n contentPosition != null && [\n 'd-flex justify-content-center',\n {\n 'align-items-start': contentPosition === 'top',\n 'align-items-center': contentPosition === 'center',\n 'align-items-end': contentPosition === 'bottom',\n },\n ],\n )}\n >\n {children}\n </div>\n </div>\n </FocusBoundary>\n </DimmerContentWrapper>\n </CSSTransition>\n </DimmerWrapper>\n );\n};\n\nconst DimmerWrapper: React.ComponentType<{\n open: boolean;\n hasNotExited: boolean;\n children: React.ReactNode;\n}> = ({ open, hasNotExited, children }) => {\n const { screenMode, theme } = useTheme();\n\n return open || hasNotExited ? (\n <ThemeProvider\n theme=\"personal\"\n screenMode={theme === 'personal' ? screenMode : 'light'}\n isNotRootProvider\n >\n {children}\n </ThemeProvider>\n ) : (\n <>{children}</>\n );\n};\n\nexport const DimmerContentWrapper = ({\n children,\n scrollBody,\n}: {\n children: React.ReactElement;\n scrollBody: boolean;\n}) => {\n useEffect(() => {\n if (scrollBody) {\n addNoScrollClass();\n }\n\n return () => {\n if (scrollBody) {\n removeNoScrollClass();\n }\n };\n }, [scrollBody]);\n\n return children;\n};\n\n// Export without the Portal for tests only\nexport { Dimmer };\n\nexport default withNextPortal(Dimmer);\n"],"names":["EXIT_ANIMATION","dimmerManager","DimmerManager","handleTouchMove","event","isTouchedElementDimmer","target","classList","contains","isIosDevice","stopPropagation","preventDefault","Dimmer","children","className","disableClickToClose","contentPosition","fadeContentOnEnter","fadeContentOnExit","open","scrollable","transparent","onClose","onExited","handleExited","hasNotExited","setHasNotExited","useState","dimmerReference","useRef","closeOnClick","current","handleClick","handleKeyDown","useCallback","key","isTop","onEnter","add","remove","useEffect","localReferenceCopy","document","addEventListener","passive","removeEventListener","_jsx","DimmerWrapper","CSSTransition","nodeRef","in","appear","timeout","enter","exit","classNames","clsx","enterDone","unmountOnExit","DimmerContentWrapper","scrollBody","FocusBoundary","ref","role","onClick","screenMode","theme","useTheme","ThemeProvider","isNotRootProvider","_Fragment","addNoScrollClass","removeNoScrollClass","withNextPortal"],"mappings":";;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG,IAAG;AAEjC,MAAMC,aAAa,GAAG,IAAIC,aAAa,EAAE,CAAA;AAe5BC,MAAAA,eAAe,GAAIC,KAAY,IAAI;EAC9C,MAAMC,sBAAsB,GAAID,KAAK,CAACE,MAAyB,CAACC,SAAS,CAACC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAE5F;AACA;AACA;AACA,EAAA,IAAIC,WAAW,EAAE,IAAIJ,sBAAsB,EAAE;IAC3CD,KAAK,CAACM,eAAe,EAAE,CAAA;IACvBN,KAAK,CAACO,cAAc,EAAE,CAAA;AACxB,GAAA;AACF,EAAC;AAEKC,MAAAA,MAAM,GAAGA,CAAC;EACdC,QAAQ;EACRC,SAAS;AACTC,EAAAA,mBAAmB,GAAG,KAAK;EAC3BC,eAAe;AACfC,EAAAA,kBAAkB,GAAG,KAAK;AAC1BC,EAAAA,iBAAiB,GAAG,KAAK;AACzBC,EAAAA,IAAI,GAAG,KAAK;AACZC,EAAAA,UAAU,GAAG,KAAK;AAClBC,EAAAA,WAAW,GAAG,KAAK;EACnBC,OAAO;AACPC,EAAAA,QAAQ,EAAEC,Y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D,UAAU;AAAEC,IAAAA,KAAAA;GAAO,GAAGC,QAAQ,EAAE,CAAA;AAExC,EAAA,OAAOhD,IAAI,IAAIM,YAAY,gBACzBqB,GAAA,CAACsB,aAAa,EAAA;AACZF,IAAAA,KAAK,EAAC,UAAU;AAChBD,IAAAA,UAAU,EAAEC,KAAK,KAAK,UAAU,GAAGD,UAAU,GAAG,OAAQ;IACxDI,iBAAiB,EAAA,IAAA;AAAAxD,IAAAA,QAAA,EAEhBA,QAAAA;AAAQ,GACI,CAAC,gBAEhBiC,GAAA,CAAAwB,QAAA,EAAA;AAAAzD,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAC,CACb,CAAA;AACH,CAAC,CAAA;AAEM,MAAM8C,oBAAoB,GAAGA,CAAC;EACnC9C,QAAQ;AACR+C,EAAAA,UAAAA;AAID,CAAA,KAAI;AACHpB,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAIoB,UAAU,EAAE;AACdW,MAAAA,gBAAgB,EAAE,CAAA;AACpB,KAAA;AAEA,IAAA,OAAO,MAAK;AACV,MAAA,IAAIX,UAAU,EAAE;AACdY,QAAAA,mBAAmB,EAAE,CAAA;AACvB,OAAA;KACD,CAAA;AACH,GAAC,EAAE,CAACZ,UAAU,CAAC,CAAC,CAAA;AAEhB,EAAA,OAAO/C,QAAQ,CAAA;AACjB,EAAC;AAKD,eAAe4D,qBAAc,CAAC7D,MAAM,CAAC;;;;"}
@@ -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":";;;;;;;;;;;;;;;AA4BwB,SAAAA,MAAMA,CAAC;EAC7BC,QAAQ;EACRC,SAAS;EACTC,aAAa;EACbC,WAAW;EACXC,OAAO;AACPC,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,CAACL,OAAO,CACT,CAAA;EAED,MAAM;AAAEM,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,oBACEC,cAAA,CAACC,cAAM,EAAA;AAACb,IAAAA,IAAI,EAAEA,IAAK;AAACD,IAAAA,OAAO,EAAEA,OAAQ;IAAAJ,QAAA,eACnCiB,cAAA,CAACE,oBAAY,EAAA;AAACd,MAAAA,IAAI,EAAEA,IAAK;AAACC,MAAAA,QAAQ,EAAEI,QAAQ,GAAGU,iBAAQ,CAACC,MAAM,GAAGf,UAAS;AAAAN,MAAAA,QAAA,eACxEsB,eAAA,CAAA,KAAA,EAAA;AACEC,QAAAA,EAAE,EAAET,SAAU;AACdP,QAAAA,IAAI,EAAEA,IAAK;QACX,YAAU,EAAA,IAAA;AACV,QAAA,iBAAA,EAAiBC,cAAc,KAAKL,WAAW,GAAGS,OAAO,GAAGY,SAAS,CAAE;AACvEvB,QAAAA,SAAS,EAAEwB,SAAI,CAAC,WAAW,EAAExB,SAAS,CAAE;AAAAD,QAAAA,QAAA,gBAExCsB,eAAA,CAAA,KAAA,EAAA;AACErB,UAAAA,SAAS,EAAEwB,SAAI,CAAC,kBAAkB,EAAE;AAClC,YAAA,8BAA8B,EAAEtB,WAAAA;AACjC,WAAA,CAAE;AAAAH,UAAAA,QAAA,EAEFG,CAAAA,WAAW,iBACVc,cAAA,CAACS,KAAK,EAAA;AAACH,YAAAA,EAAE,EAAEX,OAAQ;YAACe,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAAA7B,YAAAA,QAAA,EAC7CG,WAAAA;AAAW,WACP,CACR,eACDc,cAAA,CAACa,uBAAW,EAAA;AAACC,YAAAA,OAAO,EAAE3B,OAAAA;AAAQ,WAChC,CAAA,CAAA;AAAA,SAAK,CACL,EAACJ,QAAQ,iBAAIiB,cAAA,CAAA,KAAA,EAAA;AAAKhB,UAAAA,SAAS,EAAEwB,SAAI,CAAC,mBAAmB,CAAE;AAAAzB,UAAAA,QAAA,EAAEA,QAAAA;AAAQ,SAAM,CAAC,EACvEE,aAAa,iBAAIe,cAAA,CAAA,KAAA,EAAA;AAAKhB,UAAAA,SAAS,EAAEwB,SAAI,CAAC,kBAAkB,CAAE;AAAAzB,UAAAA,QAAA,EAAEE,aAAAA;AAAa,SAAM,CAAC,CAAA;OAC9E,CAAA;KACO,CAAA;AAChB,GAAQ,CAAC,CAAA;AAEb;;;;"}
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,oBACEC,cAAA,CAACC,cAAM,EAAA;AAACb,IAAAA,IAAI,EAAEA,IAAK;AAACF,IAAAA,OAAO,EAAEA,OAAQ;AAACgB,IAAAA,QAAQ,EAAEf,SAAU;IAAAL,QAAA,eACxDkB,cAAA,CAACG,oBAAY,EAAA;AAACf,MAAAA,IAAI,EAAEA,IAAK;AAACC,MAAAA,QAAQ,EAAEI,QAAQ,GAAGW,iBAAQ,CAACC,MAAM,GAAGhB,UAAS;AAAAP,MAAAA,QAAA,eACxEwB,eAAA,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,SAAI,CAAC,WAAW,EAAE1B,SAAS,CAAE;AAAAD,QAAAA,QAAA,gBAExCwB,eAAA,CAAA,KAAA,EAAA;AACEvB,UAAAA,SAAS,EAAE0B,SAAI,CAAC,kBAAkB,EAAE;AAClC,YAAA,8BAA8B,EAAExB,WAAAA;AACjC,WAAA,CAAE;AAAAH,UAAAA,QAAA,EAEFG,CAAAA,WAAW,iBACVe,cAAA,CAACU,KAAK,EAAA;AAACH,YAAAA,EAAE,EAAEZ,OAAQ;YAACgB,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAAA/B,YAAAA,QAAA,EAC7CG,WAAAA;AAAW,WACP,CACR,eACDe,cAAA,CAACc,uBAAW,EAAA;AAACC,YAAAA,OAAO,EAAE7B,OAAAA;AAAQ,WAChC,CAAA,CAAA;AAAA,SAAK,CACL,EAACJ,QAAQ,iBAAIkB,cAAA,CAAA,KAAA,EAAA;AAAKjB,UAAAA,SAAS,EAAE0B,SAAI,CAAC,mBAAmB,CAAE;AAAA3B,UAAAA,QAAA,EAAEA,QAAAA;AAAQ,SAAM,CAAC,EACvEE,aAAa,iBAAIgB,cAAA,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;;;;"}
@@ -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":";;;;;;;;;;;;;AA4BwB,SAAAA,MAAMA,CAAC;EAC7BC,QAAQ;EACRC,SAAS;EACTC,aAAa;EACbC,WAAW;EACXC,OAAO;AACPC,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,CAACL,OAAO,CACT,CAAA;EAED,MAAM;AAAEM,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;AAACD,IAAAA,OAAO,EAAEA,OAAQ;IAAAJ,QAAA,eACnCiB,GAAA,CAACE,YAAY,EAAA;AAACd,MAAAA,IAAI,EAAEA,IAAK;AAACC,MAAAA,QAAQ,EAAEI,QAAQ,GAAGU,QAAQ,CAACC,MAAM,GAAGf,QAAS;AAAAN,MAAAA,QAAA,eACxEsB,IAAA,CAAA,KAAA,EAAA;AACEC,QAAAA,EAAE,EAAET,SAAU;AACdP,QAAAA,IAAI,EAAEA,IAAK;QACX,YAAU,EAAA,IAAA;AACV,QAAA,iBAAA,EAAiBC,cAAc,KAAKL,WAAW,GAAGS,OAAO,GAAGY,SAAS,CAAE;AACvEvB,QAAAA,SAAS,EAAEwB,IAAI,CAAC,WAAW,EAAExB,SAAS,CAAE;AAAAD,QAAAA,QAAA,gBAExCsB,IAAA,CAAA,KAAA,EAAA;AACErB,UAAAA,SAAS,EAAEwB,IAAI,CAAC,kBAAkB,EAAE;AAClC,YAAA,8BAA8B,EAAEtB,WAAAA;AACjC,WAAA,CAAE;AAAAH,UAAAA,QAAA,EAEFG,CAAAA,WAAW,iBACVc,GAAA,CAACS,KAAK,EAAA;AAACH,YAAAA,EAAE,EAAEX,OAAQ;YAACe,IAAI,EAAEC,UAAU,CAACC,UAAW;AAAA7B,YAAAA,QAAA,EAC7CG,WAAAA;AAAW,WACP,CACR,eACDc,GAAA,CAACa,WAAW,EAAA;AAACC,YAAAA,OAAO,EAAE3B,OAAAA;AAAQ,WAChC,CAAA,CAAA;AAAA,SAAK,CACL,EAACJ,QAAQ,iBAAIiB,GAAA,CAAA,KAAA,EAAA;AAAKhB,UAAAA,SAAS,EAAEwB,IAAI,CAAC,mBAAmB,CAAE;AAAAzB,UAAAA,QAAA,EAAEA,QAAAA;AAAQ,SAAM,CAAC,EACvEE,aAAa,iBAAIe,GAAA,CAAA,KAAA,EAAA;AAAKhB,UAAAA,SAAS,EAAEwB,IAAI,CAAC,kBAAkB,CAAE;AAAAzB,UAAAA,QAAA,EAAEE,aAAAA;AAAa,SAAM,CAAC,CAAA;OAC9E,CAAA;KACO,CAAA;AAChB,GAAQ,CAAC,CAAA;AAEb;;;;"}
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;;;;"}
@@ -21,6 +21,7 @@ const Modal = ({
21
21
  body,
22
22
  footer = null,
23
23
  onClose,
24
+ onUnmount,
24
25
  className,
25
26
  open,
26
27
  size: size$1 = size.Size.MEDIUM,
@@ -45,6 +46,7 @@ const Modal = ({
45
46
  footerContent: footer,
46
47
  position: position.Position.BOTTOM,
47
48
  onClose: onClose,
49
+ onUnmount: onUnmount,
48
50
  children: body
49
51
  }) : /*#__PURE__*/jsxRuntime.jsx(Dimmer.default, {
50
52
  open: open,
@@ -52,6 +54,7 @@ const Modal = ({
52
54
  contentPosition: position$1,
53
55
  disableClickToClose: disableDimmerClickToClose,
54
56
  onClose: onClose,
57
+ onExited: onUnmount,
55
58
  children: /*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
56
59
  nodeRef: contentReference,
57
60
  appear: true,